/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
#include "uucp.h"
#include "pk.h"
extern void xlatecntl();
extern int Connodata; /* Continuous No Valid Data Count */
extern int xpacksize;
/*
* receive control messages
* c -> message type fields
* pk -> line control unit
*/
void
int c;
{
if ( ! ISCNTL(c) ) {
return;
}
if (Debug >= 9)
xlatecntl(0, c);
switch(cntl) {
case INITB:
val++;
break;
}
break;
}
break;
case INITC:
} else
if (val)
break;
case INITA:
break;
}
if (val) {
}
break;
case RJ:
/* FALLTHRU */
case RR:
break;
case CLOSE:
return;
}
}
static int
pkaccept()
{
int x,seq;
unsigned short sum;
/*
* wait for input
*/
}
/*
* determine input window in m.
*/
m = t;
m |= t>>8;
/*
* mark newly accepted input buffers
*/
for(x=0; x<8; x++) {
continue;
bad++;
free:
continue;
}
dup:
skip++;
goto free;
}
if (x != seq) {
}
accept++;
cc = 0;
cc = (unsigned)*p++ & 0377;
if (cc & 0200) {
cc &= 0177;
cc |= *p << 7;
}
}
} else {
goto dup;
}
} else {
bad++;
goto free;
}
}
/*
* scan window again turning marked buffers into
* COPY buffers and looking for missing sequence
* numbers.
*/
accept = 0;
if (t >= 0) {
skip++;
} else
accept++;
} else if (t<0)
t = x;
}
if (bad) {
}
if (skip) {
}
return(accept);
}
int
char *ibuf;
int icount;
{
int x;
xfr = 0;
count = 0;
while (pkaccept()==0)
;
Connodata = 0; /* accecpted a packet -- good data */
while (icount) {
break;
}
else {
if (*cp++ & 0200)
cp++;
}
}
if (cc)
xfr++;
} else {
}
if (cc==0)
break;
} else
break;
}
return(count);
}
/* return number of bytes writtten */
int
char *ibuf;
int icount;
{
int x;
int partial;
return(-1);
}
do {
}
}
partial = 0;
if (fc > 127) {
*cp++ |= 0200;
} else
cp++;
} else
} while (icount);
return(count);
}
int
{
int x, i;
i = 0;
x = next[x];
i++;
Connodata = 0;
}
}
return(i);
}
void
{
int x;
char bstate;
int i;
return;
}
/*
* find seq number and buffer state
* of next output packet
*/
/*
* Send control packet if indicated
*/
for(i=0; i<8; i++)
if (x&1)
break;
else
x >>= 1;
x = i;
x <<= 3;
switch(i) {
case CLOSE:
break;
case RJ:
case RR:
break;
case INITB:
break;
case INITC:
break;
case INITA:
break;
}
goto out;
}
}
/*
* Don't send data packets if line is marked dead.
*/
goto out;
}
/*
* Start transmission (or retransmission) of data packets.
*/
char seq;
seq = x;
x |= 0100;
goto out;
}
/*
* enable timeout if there's nothing to send
* and transmission buffers are languishing
*/
} else
out:
}
/*
* shut down line by ignoring new input
* letting output drain
* releasing space
*/
void
pkclose()
{
int i;
int rcheck;
char **bp;
/*
* try to flush output
*/
i = 0;
break;
}
/*
* try to exchange CLOSE messages
*/
i = 0;
i++;
}
/*
* free space
*/
rcheck = 0;
for (i=0;i<8;i++) {
}
rcheck++;
}
}
rcheck++;
}
}
}
void
{
}
static int
chksum(s,n)
char *s;
int n;
{
short sum;
unsigned short t;
short x;
sum = -1;
x = 0;
do {
if (sum<0) {
sum <<= 1;
sum++;
} else
sum <<= 1;
t = sum;
sum += (unsigned)*s++ & 0377;
x += sum^n;
if ((unsigned short)sum <= t) {
sum ^= x;
}
} while (--n > 0);
return(sum);
}
static int
pksize(n)
int n;
{
int k;
n >>= 5;
for(k=0; n >>= 1; k++);
return(k);
}