]> git.ozlabs.org Git - ppp.git/blob - include/net/if_ppp.h
7f42e7325e115a411c09eb32350b174cf8f21bab
[ppp.git] / include / net / if_ppp.h
1 /*
2  * if_ppp.h - Point-to-Point Protocol definitions.
3  *
4  * Copyright (c) 1989 Carnegie Mellon University.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms are permitted
8  * provided that the above copyright notice and this paragraph are
9  * duplicated in all such forms and that any documentation,
10  * advertising materials, and other materials related to such
11  * distribution and use acknowledge that the software was developed
12  * by Carnegie Mellon University.  The name of the
13  * University may not be used to endorse or promote products derived
14  * from this software without specific prior written permission.
15  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18  *
19  * $Id: if_ppp.h,v 1.4 1994/09/01 00:45:32 paulus Exp $
20  */
21
22 #ifndef _IF_PPP_H_
23 #define _IF_PPP_H_
24
25 /*
26  * Standard PPP header.
27  */
28 struct ppp_header {
29         u_char  ph_address;     /* Address Field */
30         u_char  ph_control;     /* Control Field */
31         u_short ph_protocol;    /* Protocol Field */
32 };
33
34 #define PPP_HDRLEN      4       /* sizeof(struct ppp_header) must be 4 */
35 #define PPP_FCSLEN      2       /* octets for FCS */
36
37 #define PPP_ALLSTATIONS 0xff    /* All-Stations broadcast address */
38 #define PPP_UI          0x03    /* Unnumbered Information */
39 #define PPP_FLAG        0x7e    /* Flag Sequence */
40 #define PPP_ESCAPE      0x7d    /* Asynchronous Control Escape */
41 #define PPP_TRANS       0x20    /* Asynchronous transparency modifier */
42
43 /*
44  * Protocol field values.
45  */
46 #define PPP_IP          0x21    /* Internet Protocol */
47 #define PPP_XNS         0x25    /* Xerox NS */
48 #define PPP_VJC_COMP    0x2d    /* VJ compressed TCP */
49 #define PPP_VJC_UNCOMP  0x2f    /* VJ uncompressed TCP */
50 #define PPP_COMP        0xfd    /* compressed packet */
51 #define PPP_LCP         0xc021  /* Link Control Protocol */
52 #define PPP_CCP         0x80fd  /* Compression Control Protocol */
53
54 /*
55  * Important FCS values.
56  */
57 #define PPP_INITFCS     0xffff  /* Initial FCS value */
58 #define PPP_GOODFCS     0xf0b8  /* Good final FCS value */
59 #define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
60
61 /*
62  * Packet sizes
63  */
64 #define PPP_MTU         1500    /* Default MTU (size of Info field) */
65 #define PPP_MRU         1500    /* Default MRU (max receive unit) */
66 #define PPP_MAXMRU      65000   /* Largest MRU we allow */
67
68 /* Extended asyncmap - allows any character to be escaped. */
69 typedef u_long  ext_accm[8];
70
71 /*
72  * Structure describing each ppp unit.
73  */
74 struct ppp_softc {
75         struct ifnet sc_if;     /* network-visible interface */
76         u_int   sc_flags;       /* see below */
77         void    *sc_devp;       /* pointer to device-dependent structure */
78         int     (*sc_start)();  /* start routine */
79         short   sc_mru;         /* max receive unit */
80         pid_t   sc_xfer;        /* used in xferring unit to another dev */
81         struct  ifqueue sc_inq; /* TTY side input queue */
82         struct  ifqueue sc_fastq; /* IP interactive output packet queue */
83 #ifdef  VJC
84         struct  slcompress sc_comp; /* vjc control buffer */
85 #endif
86         u_int   sc_bytessent;   /* count of octets sent */
87         u_int   sc_bytesrcvd;   /* count of octets received */
88         caddr_t sc_bpf;         /* hook for BPF */
89         struct  compressor *sc_xcomp;   /* transmit compressor */
90         void    *sc_xc_state;   /* transmit compressor state */
91         struct  compressor *sc_rcomp;   /* receive decompressor */
92         void    *sc_rc_state;   /* receive decompressor state */
93         
94         /* Device-dependent part for async lines. */
95         ext_accm sc_asyncmap;   /* async control character map */
96         u_long  sc_rasyncmap;   /* receive async control char map */
97         struct  mbuf *sc_outm;  /* mbuf chain being output currently */
98         struct  mbuf *sc_m;     /* pointer to input mbuf chain */
99         struct  mbuf *sc_mc;    /* pointer to current input mbuf */
100         char    *sc_mp;         /* pointer to next char in input mbuf */
101         short   sc_ilen;        /* length of input-packet-so-far */
102         u_short sc_fcs;         /* FCS so far (input) */
103         u_short sc_outfcs;      /* FCS so far for output packet */
104         u_char  sc_rawin[16];   /* chars as received */
105         int     sc_rawin_count; /* # in sc_rawin */
106 };
107
108 /* flags */
109 #define SC_COMP_PROT    0x00000001      /* protocol compression (output) */
110 #define SC_COMP_AC      0x00000002      /* header compression (output) */
111 #define SC_COMP_TCP     0x00000004      /* TCP (VJ) compression (output) */
112 #define SC_NO_TCP_CCID  0x00000008      /* disable VJ connection-id comp. */
113 #define SC_REJ_COMP_AC  0x00000010      /* reject adrs/ctrl comp. on input */
114 #define SC_REJ_COMP_TCP 0x00000020      /* reject TCP (VJ) comp. on input */
115 #define SC_CCP_OPEN     0x00000040      /* Look at CCP packets */
116 #define SC_CCP_UP       0x00000080      /* May send/recv compressed packets */
117 #define SC_ENABLE_IP    0x00000100      /* IP packets may be exchanged */
118 #define SC_XCOMP_RUN    0x00001000      /* compressor has been inited */
119 #define SC_RCOMP_RUN    0x00002000      /* decompressor has been inited */
120 #define SC_DEBUG        0x00010000      /* enable debug messages */
121 #define SC_LOG_INPKT    0x00020000      /* log contents of good pkts recvd */
122 #define SC_LOG_OUTPKT   0x00040000      /* log contents of pkts sent */
123 #define SC_LOG_RAWIN    0x00080000      /* log all chars received */
124 #define SC_LOG_FLUSH    0x00100000      /* log all chars flushed */
125 #define SC_MASK         0x0fffffff      /* bits that user can change */
126
127 /* state bits */
128 #define SC_ESCAPED      0x80000000      /* saw a PPP_ESCAPE */
129 #define SC_FLUSH        0x40000000      /* flush input until next PPP_FLAG */
130 #define SC_RCV_B7_0     0x01000000      /* have rcvd char with bit 7 = 0 */
131 #define SC_RCV_B7_1     0x02000000      /* have rcvd char with bit 7 = 1 */
132 #define SC_RCV_EVNP     0x04000000      /* have rcvd char with even parity */
133 #define SC_RCV_ODDP     0x08000000      /* have rcvd char with odd parity */
134
135 /*
136  * What to do with network protocol (NP) packets.
137  */
138
139 enum NPmode {
140     NPMODE_PASS,                /* pass the packet through */
141     NPMODE_DROP,                /* silently drop the packet */
142     NPMODE_ERROR,               /* return an error */
143     NPMODE_QUEUE                /* save it up for later. */
144 };
145
146 struct npioctl {
147     int         protocol;       /* PPP procotol, e.g. PPP_IP */
148     enum NPmode mode;
149 };
150
151 /* Structure describing a CCP configuration option, for PPPIOCSCOMPRESS */
152 struct ppp_option_data {
153         u_char  *ptr;
154         u_int   length;
155         int     transmit;
156 };
157
158 /* this stuff doesn't belong here... */
159 #define PPPIOCGFLAGS    _IOR('t', 90, int)      /* get configuration flags */
160 #define PPPIOCSFLAGS    _IOW('t', 89, int)      /* set configuration flags */
161 #define PPPIOCGASYNCMAP _IOR('t', 88, int)      /* get async map */
162 #define PPPIOCSASYNCMAP _IOW('t', 87, int)      /* set async map */
163 #define PPPIOCGUNIT     _IOR('t', 86, int)      /* get ppp unit number */
164 #define PPPIOCGRASYNCMAP _IOR('t', 85, int)     /* get receive async map */
165 #define PPPIOCSRASYNCMAP _IOW('t', 84, int)     /* set receive async map */
166 #define PPPIOCGMRU      _IOR('t', 83, int)      /* get max receive unit */
167 #define PPPIOCSMRU      _IOW('t', 82, int)      /* set max receive unit */
168 #define PPPIOCSMAXCID   _IOW('t', 81, int)      /* set VJ max slot ID */
169 #define PPPIOCGXASYNCMAP _IOR('t', 80, ext_accm) /* get extended ACCM */
170 #define PPPIOCSXASYNCMAP _IOW('t', 79, ext_accm) /* set extended ACCM */
171 #define PPPIOCXFERUNIT  _IO('t', 78)            /* transfer PPP unit */
172 #define PPPIOCSCOMPRESS _IOW('t', 77, struct ppp_option_data)
173 #define PPPIOCGNPMODE   _IOWR('t', 76, struct npioctl) /* get NP mode */
174 #define PPPIOCSNPMODE   _IOW('t', 75, struct npioctl)  /* set NP mode */
175
176 #ifdef ultrix 
177 #define ifr_mtu ifr_ifru.ifru_metric
178 #endif
179
180 /* old copies of PPP may have defined this */
181 #if !defined(ifr_mtu)
182 #define ifr_mtu ifr_metric
183 #endif
184
185 #endif /* _IF_PPP_H_ */