1 typedef struct Tcpc Tcpc;
2 typedef struct Pstate Pstate;
3 typedef struct Chap Chap;
4 typedef struct Qualstats Qualstats;
5 typedef struct Comptype Comptype;
6 typedef struct Uncomptype Uncomptype;
7 typedef struct PPP PPP;
8 typedef struct Lcpmsg Lcpmsg;
9 typedef struct Lcpopt Lcpopt;
10 typedef struct Qualpkt Qualpkt;
11 typedef struct Block Block;
13 typedef uchar Ipaddr[IPaddrlen];
15 #pragma incomplete Tcpc
24 Block *list; /* chain of block lists */
25 uchar *rptr; /* first unconsumed uchar */
26 uchar *wptr; /* first empty uchar */
27 uchar *lim; /* 1 past the end of the buffer */
28 uchar *base; /* start of the buffer */
34 #define BLEN(b) ((b)->wptr-(b)->rptr)
45 QFLOW = (1<<1), /* queue is flow controlled */
50 Block* concat(Block*);
52 Block* pullup(Block*, int);
53 Block* padb(Block*, int);
54 Block* btrim(Block*, int, int);
55 Block* copyb(Block*, int);
56 int pullb(Block**, int);
62 /* PPP frame fields */
70 Plink, /* doing LCP */
71 Pauth, /* doing chap */
72 Pnet, /* doing IPCP, CCP */
73 Pterm, /* closing down */
75 /* PPP protocol types */
76 Pip= 0x21, /* ip v4 */
77 Pipv6= 0x57, /* ip v6 */
78 Pvjctcp= 0x2d, /* compressing van jacobson tcp */
79 Pvjutcp= 0x2f, /* uncompressing van jacobson tcp */
80 Pcdata= 0xfd, /* compressed datagram */
81 Pipcp= 0x8021, /* ip control */
82 Pecp= 0x8053, /* encryption control */
83 Pccp= 0x80fd, /* compressed datagram control */
84 Plcp= 0xc021, /* link control */
85 Ppasswd= 0xc023, /* passwd authentication */
86 Plqm= 0xc025, /* link quality monitoring */
87 Pchap= 0xc223, /* challenge/response */
104 /* Lcp configure options */
113 /* authentication protocols */
116 APpasswd= Ppasswd, /* use Pap, not Chap */
122 Fquality= 1<<Oquality,
152 /* ccp configure options */
153 Ocoui= 0, /* proprietary compression */
154 Ocstac= 17, /* stac electronics LZS */
155 Ocmppc= 18, /* microsoft ppc */
156 Octhwack= 31, /* thwack; unofficial */
162 Fcthwack= 1<<Octhwack,
164 /* ecp configure options */
165 Oeoui= 0, /* proprietary compression */
172 /* ipcp configure options */
182 Fipaddrs= 1<<Oipaddrs,
183 Fipcompress= 1<<Oipcompress,
185 Fipdns= 1<<8, // Oipdns,
186 Fipwins= 1<<9, // Oipwins,
187 Fipdns2= 1<<10, // Oipdns2,
188 Fipwins2= 1<<11, // Oipwins2,
190 Period= 5*1000, /* period of retransmit process (in ms) */
191 Timeout= 20, /* xmit timeout (in Periods) */
194 MAX_STATES= 16, /* van jacobson compression states */
195 Defmtu= 1450, /* default that we will ask for */
196 Minmtu= 128, /* minimum that we will accept */
197 Maxmtu= 2000, /* maximum that we will accept */
203 int proto; /* protocol type */
204 int timeout; /* for current state */
205 int rxtimeout; /* for current retransmit */
206 ulong flags; /* options received */
207 uchar id; /* id of current message */
208 uchar confid; /* id of current config message */
209 uchar termid; /* id of current termination message */
210 uchar rcvdconfid; /* id of last conf message received */
211 uchar state; /* PPP link state */
212 ulong optmask; /* which options to request */
213 int echoack; /* recieved echo ack */
214 int echotimeout; /* echo timeout */
217 /* server chap state */
220 int proto; /* chap proto */
221 int state; /* chap state */
222 uchar id; /* id of current message */
223 int timeout; /* for current state */
239 Block* (*compress)(PPP*, ushort, Block*, int*);
240 Block* (*resetreq)(void*, Block*);
247 Block* (*uncompress)(PPP*, Block*, int*, Block**);
248 void (*resetack)(void*, Block*);
256 int ipfd; /* fd to ip stack */
257 int ipcfd; /* fd to control channel of ip stack */
258 int mediain; /* fd to media */
259 int mediaout; /* fd to media */
260 char *net; /* ip stack to use */
261 int framing; /* non-zero to use framing characters */
269 Ipaddr dns[2]; /* dns servers */
270 Ipaddr wins[2]; /* wins servers */
272 Block* inbuf; /* input buffer */
273 Block* outbuf; /* output buffer */
274 QLock outlock; /* and its lock */
275 ulong magic; /* magic number to detect loop backs */
276 ulong rctlmap; /* map of chars to ignore in rcvr */
277 ulong xctlmap; /* map of chars to excape in xmit */
278 int phase; /* PPP phase */
279 Pstate* lcp; /* lcp state */
280 Pstate* ccp; /* ccp state */
281 Pstate* ipcp; /* ipcp state */
282 Chap* chap; /* chap state */
283 Tcpc* ctcp; /* tcp compression state */
284 ulong mtu; /* maximum xmit size */
285 ulong mru; /* maximum recv size */
287 /* data compression */
288 int ctries; /* number of negotiation tries */
289 Comptype *ctype; /* compression virtual table */
290 void *cstate; /* compression state */
291 Uncomptype *unctype; /* uncompression virtual table */
292 void *uncstate; /* uncompression state */
299 char secret[256]; /* md5 key */
300 char chapname[256]; /* chap system name */
302 /* link quality monitoring */
303 int period; /* lqm period */
304 int timeout; /* time to next lqm packet */
305 Qualstats in; /* local */
307 Qualstats pin; /* peer */
309 Qualstats sin; /* saved */
330 extern Block* pppread(PPP*);
331 extern int pppwrite(PPP*, Block*);
332 extern void pppopen(PPP*, int, int, char*, Ipaddr, Ipaddr, int, int);
353 uchar lastoutreports[4];
354 uchar lastoutpackets[4];
355 uchar lastoutuchars[4];
356 uchar peerinreports[4];
357 uchar peerinpackets[4];
358 uchar peerindiscards[4];
359 uchar peerinerrors[4];
360 uchar peerinuchars[4];
361 uchar peeroutreports[4];
362 uchar peeroutpackets[4];
363 uchar peeroutuchars[4];
366 extern Block* compress(Tcpc*, Block*, int*);
367 extern void compress_error(Tcpc*);
368 extern Tcpc* compress_init(Tcpc*);
369 extern int compress_negotiate(Tcpc*, uchar*);
370 extern Block* tcpcompress(Tcpc*, Block*, int*);
371 extern Block* tcpuncompress(Tcpc*, Block*, int);
372 extern Block* alloclcp(int, int, int, Lcpmsg**);
373 extern ushort ptclcsum(Block*, int, int);
374 extern ushort ptclbsum(uchar*, int);
375 extern ushort ipcsum(uchar*);
377 extern Comptype cmppc;
378 extern Uncomptype uncmppc;
380 extern Comptype cthwack;
381 extern Uncomptype uncthwack;
383 extern void netlog(char*, ...);
384 #pragma varargck argpos netlog 1