|
|
1.1 root 1: /*
2: ** Initialise structures for Channel talking
3: */
4:
5: #ifndef Blit
6: #include <signal.h>
7: #endif Blit
8: #include "pconfig.h"
9: #include "proto.h"
10: #include "packets.h"
11: #define DECLARE /* Define statistics array here */
12: #include "pstats.h"
13:
14:
15: Pch_p pconvsend; /* Pointer to end of pconvs */
16: Pbyte pseqtable[2*SEQMOD]; /* Table of sequence numbers */
17:
18:
19:
20: int
21: pinit(channels)
22: register int channels;
23: {
24: register int i;
25: register Pch_p pcp; /*SFBOTCH*/
26:
27: # ifndef Blit
28: if ( channels > MAXPCHAN )
29: return(-1);
30: # endif
31:
32: if ( Pscanrate == 0 || Prtimeout == 0 || Pxtimeout == 0 ) {
33: Pscanrate = PSCANRATE;
34: Prtimeout = PRTIMEOUT;
35: Pxtimeout = PXTIMEOUT;
36: }
37:
38: pconvsend = &pconvs[channels];
39:
40: while ( channels-- > 0 ) {
41: /*SFBOTCHregister Pch_p*/ pcp = &pconvs[channels];
42:
43: pcp->nextpkt = pcp->pkts;
44: pcp->freepkts = NPCBUFS;
45:
46: for ( i = 0 ; i < NPCBUFS ; i++) {
47:
48: pcp->pkts[i].state = PX_NULL;
49: pcp->pkts[i].timo = 0;
50: pcp->pkts[i].pkt.header = 0;
51: pcp->pkts[i].pkt.dsize = 0;
52: }
53: }
54:
55: for ( i = 0 ; i < 2 * SEQMOD ; i++)
56: pseqtable[i] = i % SEQMOD;
57:
58: # ifndef Blit
59: signal(SIGALRM, ptimeout);
60: Ptflag = 0;
61: # endif
62: return(0);
63: }
64:
65:
66:
67: #ifdef PDEBUG
68:
69: FILE * ptracefd = stderr;
70:
71: void
72: ptracepkt(pkp, s)
73: Pkt_p pkp;
74: char * s;
75: {
76: register Pbyte *ucp;
77: register int size;
78:
79: fprintf(ptracefd, "tracepkt: %s -- ", s);
80: if ( (size = pkp->dsize) > 10 )
81: size = 10;
82: size += 2 + EDSIZE;
83: for ( ucp = (Pbyte * )pkp ; size--; )
84: fprintf(ptracefd, "<%o>", *ucp++);
85: fprintf(ptracefd, "\n");
86: }
87:
88:
89:
90: static struct Pktstate log[PKTHIST];
91: static Pks_p inlog = log;
92: static Pks_p outlog = log;
93: static short logflag;
94:
95: void
96: plogpkt(pkp, ident)
97: Pkt_p pkp;
98: unsigned char ident;
99: {
100: inlog->pkt = *pkp;
101: inlog->state = ident;
102: if ( ++inlog >= &log[PKTHIST] )
103: inlog = log;
104: if ( logflag ) {
105: outlog = inlog;
106: logflag = 0;
107: }
108: if ( inlog == outlog )
109: logflag++;
110: }
111:
112:
113:
114: void
115: pdumphist(s)
116: char * s;
117: {
118: fprintf(ptracefd, "\nDumphist: %s\n", s);
119: while ( outlog != inlog || logflag ) {
120: logflag = 0;
121: ptracepkt(&outlog->pkt, outlog->state == PLOGIN ? "recv" : "xmit");
122: if ( ++outlog >= &log[PKTHIST] )
123: outlog = log;
124: }
125: fflush(ptracefd);
126: }
127:
128:
129: #endif PDEBUG
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.