]> git.ozlabs.org Git - ppp.git/blob - linux/ppp.h
153d9596dc919de868cb7e26fabc49c6dcdaa2e0
[ppp.git] / linux / ppp.h
1 #ifndef _LINUX_PPP_H
2 #define _LINUX_PPP_H
3
4 /* definitions for kernel PPP module
5    Michael Callahan <callahan@maths.ox.ac.uk>
6    Nov. 4 1993 */
7
8 /* $Id: ppp.h,v 1.1 1994/05/27 00:55:25 paulus Exp $ */
9
10 /* how many PPP units? */
11 #define PPP_NRUNIT     4
12
13 #define PPP_VERSION  "0.2.7"
14
15 /* line discipline number */
16 #define N_PPP          3
17
18 /* Magic value for the ppp structure */
19 #define PPP_MAGIC 0x5002
20
21 #define PPPIOCGFLAGS     0x5490 /* get configuration flags */
22 #define PPPIOCSFLAGS     0x5491 /* set configuration flags */
23 #define PPPIOCGASYNCMAP  0x5492 /* get async map */
24 #define PPPIOCSASYNCMAP  0x5493 /* set async map */
25 #define PPPIOCGUNIT      0x5494 /* get ppp unit number */
26 #define PPPIOCSINPSIG    0x5495 /* set input ready signal */
27 #define PPPIOCSDEBUG     0x5497 /* set debug level */
28 #define PPPIOCGDEBUG     0x5498 /* get debug level */
29 #define PPPIOCGSTAT      0x5499 /* read PPP statistic information */
30 #define PPPIOCGTIME      0x549A /* read time delta information */
31 #define PPPIOCGXASYNCMAP 0x549B /* get async table */
32 #define PPPIOCSXASYNCMAP 0x549C /* set async table */
33 #define PPPIOCSMRU       0x549D /* set receive unit size for PPP */
34 #define PPPIOCRASYNCMAP  0x549E /* set receive async map */
35 #define PPPIOCSMAXCID    0x549F /* set the maximum compression slot id */
36
37 /* special characters in the framing protocol */
38 #define PPP_ALLSTATIONS 0xff    /* All-Stations broadcast address */
39 #define PPP_UI          0x03    /* Unnumbered Information */
40 #define PPP_FLAG        0x7E    /* frame delimiter -- marks frame boundaries */
41 #define PPP_ADDRESS     0xFF    /* first character of frame   <--  (may be   */
42 #define PPP_CONTROL     0x03    /* second character of frame  <-- compressed)*/
43 #define PPP_TRANS       0x20    /* Asynchronous transparency modifier */
44 #define PPP_ESC         0x7d    /* escape charecter -- next character is
45                                    data, and the PPP_TRANS bit should be
46                                    toggled. PPP_ESC PPP_FLAG is illegal */
47
48 /* protocol numbers */
49 #define PROTO_IP       0x0021
50 #define PROTO_VJCOMP   0x002d
51 #define PROTO_VJUNCOMP 0x002f
52
53 /* FCS support */
54 #define PPP_FCS_INIT   0xffff
55 #define PPP_FCS_GOOD   0xf0b8
56
57 /* initial MTU */
58 #define PPP_MTU        1500
59
60 /* initial MRU */
61 #define PPP_MRU        PPP_MTU
62
63 /* flags */
64 #define SC_COMP_PROT    0x00000001      /* protocol compression (output) */
65 #define SC_COMP_AC      0x00000002      /* header compression (output) */
66 #define SC_COMP_TCP     0x00000004      /* TCP (VJ) compression (output) */
67 #define SC_NO_TCP_CCID  0x00000008      /* disable VJ connection-id comp. */
68 #define SC_REJ_COMP_AC  0x00000010      /* reject adrs/ctrl comp. on input */
69 #define SC_REJ_COMP_TCP 0x00000020      /* reject TCP (VJ) comp. on input */
70 #define SC_ENABLE_IP    0x00000100      /* IP packets may be exchanged */
71 #define SC_IP_DOWN      0x00000200      /* give ip frames to pppd */
72 #define SC_IP_FLUSH     0x00000400      /* "next time" flag for IP_DOWN */
73 #define SC_DEBUG        0x00010000      /* enable debug messages */
74 #define SC_LOG_INPKT    0x00020000      /* log contents of good pkts recvd */
75 #define SC_LOG_OUTPKT   0x00040000      /* log contents of pkts sent */
76 #define SC_LOG_RAWIN    0x00080000      /* log all chars received */
77 #define SC_LOG_FLUSH    0x00100000      /* log all chars flushed */
78
79 /* Flag bits to determine state of input characters */
80 #define SC_RCV_B7_0     0x01000000      /* have rcvd char with bit 7 = 0 */
81 #define SC_RCV_B7_1     0x02000000      /* have rcvd char with bit 7 = 0 */
82 #define SC_RCV_EVNP     0x04000000      /* have rcvd char with even parity */
83 #define SC_RCV_ODDP     0x08000000      /* have rcvd char with odd parity */
84
85 #define SC_MASK         0x0fffffff      /* bits that user can change */
86
87 /* flag for doing transmitter lockout */
88 #define SC_XMIT_BUSY    0x10000000      /* ppp_write_wakeup is active */
89
90 /*
91  * This is the format of the data buffer of a LQP packet. The packet data
92  * is sent/received to the peer.
93  */
94
95 struct ppp_lqp_packet_hdr {
96   unsigned long         LastOutLQRs;    /* Copied from PeerOutLQRs       */
97   unsigned long         LastOutPackets; /* Copied from PeerOutPackets    */
98   unsigned long         LastOutOctets;  /* Copied from PeerOutOctets     */
99   unsigned long         PeerInLQRs;     /* Copied from SavedInLQRs       */
100   unsigned long         PeerInPackets;  /* Copied from SavedInPackets    */
101   unsigned long         PeerInDiscards; /* Copied from SavedInDiscards   */
102   unsigned long         PeerInErrors;   /* Copied from SavedInErrors     */
103   unsigned long         PeerInOctets;   /* Copeid from SavedInOctets     */
104   unsigned long         PeerOutLQRs;    /* Copied from OutLQRs, plus 1   */
105   unsigned long         PeerOutPackets; /* Current ifOutUniPackets, + 1  */
106   unsigned long         PeerOutOctets;  /* Current ifOutOctets + LQR     */
107   };
108
109 /*
110  * This data is not sent to the remote. It is updated by the driver when
111  * a packet is received.
112  */
113
114 struct ppp_lqp_packet_trailer {
115   unsigned long         SaveInLQRs;     /* Current InLQRs on receiption  */
116   unsigned long         SaveInPackets;  /* Current ifInUniPackets        */
117   unsigned long         SaveInDiscards; /* Current ifInDiscards          */
118   unsigned long         SaveInErrors;   /* Current ifInErrors            */
119   unsigned long         SaveInOctets;   /* Current ifInOctects           */
120 };
121
122 /*
123  * PPP LQP packet. The packet is changed by the driver immediately prior
124  * to transmission and updated upon receiption with the current values.
125  * So, it must be known to the driver as well as the pppd software.
126  */
127
128 struct ppp_lpq_packet {
129   unsigned long                 magic;  /* current magic value           */
130   struct ppp_lqp_packet_hdr     hdr;    /* Header fields for structure   */
131   struct ppp_lqp_packet_trailer tail;   /* Trailer fields (not sent)     */
132 };
133
134 /*
135  * PPP interface statistics. (used by LQP / pppstats)
136  */
137
138 struct ppp_stats {
139   unsigned long         rbytes;         /* bytes received                */
140   unsigned long         rcomp;          /* compressed packets received   */
141   unsigned long         runcomp;        /* uncompressed packets received */
142   unsigned long         rothers;        /* non-ip frames received        */
143   unsigned long         rerrors;        /* received errors               */
144   unsigned long         roverrun;       /* "buffer overrun" counter      */
145   unsigned long         tossed;         /* packets discarded             */
146   unsigned long         runts;          /* frames too short to process   */
147   unsigned long         rgiants;        /* frames too large to process   */
148   unsigned long         sbytes;         /* bytes sent                    */
149   unsigned long         scomp;          /* compressed packets sent       */
150   unsigned long         suncomp;        /* uncompressed packets sent     */
151   unsigned long         sothers;        /* non-ip frames sent            */
152   unsigned long         serrors;        /* transmitter errors            */
153   unsigned long         sbusy;          /* "transmitter busy" counter    */
154 };
155
156 /*
157  * Demand dial fields
158  */
159
160 struct ppp_ddinfo {
161   unsigned long         ip_sjiffies;    /* time when last IP frame sent */
162   unsigned long         ip_rjiffies;    /* time when last IP frame recvd*/
163   unsigned long         nip_sjiffies;   /* time when last NON-IP sent   */
164   unsigned long         nip_rjiffies;   /* time when last NON-IP recvd  */
165 };
166
167 #ifdef __KERNEL__
168
169 struct ppp {
170   int                   magic;          /* magic value for structure    */
171
172   /* Bitmapped flag fields. */
173   char                  inuse;          /* are we allocated?            */
174   char                  sending;        /* "channel busy" indicator     */
175   char                  escape;         /* 0x20 if prev char was PPP_ESC*/
176   char                  toss;           /* toss this frame              */
177
178   unsigned int          flags;          /* miscellany                   */
179
180   unsigned long         xmit_async_map[8]; /* 1 bit means that given control 
181                                            character is quoted on output*/
182
183   unsigned long         recv_async_map; /* 1 bit means that given control 
184                                            character is ignored on input*/
185   int                   mtu;            /* maximum xmit frame size      */
186   int                   mru;            /* maximum receive frame size   */
187   unsigned short        fcs;            /* FCS field of current frame   */
188
189   /* Various fields. */
190   int                   line;           /* PPP channel number           */
191   struct tty_struct     *tty;           /* ptr to TTY structure         */
192   struct device         *dev;           /* easy for intr handling       */
193   struct slcompress     *slcomp;        /* for header compression       */
194   unsigned long         last_xmit;      /* time of last transmission    */
195
196   /* These are pointers to the malloc()ed frame buffers.
197      These buffers are used while processing a packet.  If a packet
198      has to hang around for the user process to read it, it lingers in
199      the user buffers below. */
200   unsigned char         *rbuff;         /* receiver buffer              */
201   unsigned char         *xbuff;         /* transmitter buffer           */
202   unsigned char         *cbuff;         /* compression buffer           */
203
204   /* These are the various pointers into the buffers. */
205   unsigned char         *rhead;         /* RECV buffer pointer (head)   */
206   unsigned char         *rend;          /* RECV buffer pointer (end)    */
207   int                   rcount;         /* PPP receive counter          */
208   unsigned char         *xhead;         /* XMIT buffer pointer (head)   */
209   unsigned char         *xtail;         /* XMIT buffer pointer (end)    */
210
211   /* Structures for interfacing with the user process. */
212 #define RBUFSIZE 4000
213   unsigned char         *us_rbuff;      /* circular incoming packet buf.*/
214   unsigned char         *us_rbuff_end;  /* end of allocated space       */
215   unsigned char         *us_rbuff_head; /* head of waiting packets      */
216   unsigned char         *us_rbuff_tail; /* tail of waiting packets      */
217   unsigned char         us_rbuff_lock;  /* lock: bit 0 head bit 1 tail  */
218   int                   inp_sig;        /* input ready signal for pgrp  */
219   int                   inp_sig_pid;    /* process to get notified      */
220
221   /* items to support the select() function */
222   struct wait_queue     *write_wait;    /* queue for reading processes  */
223   struct wait_queue     *read_wait;     /* queue for writing processes  */
224
225   /* PPP interface statistics. */
226   struct ppp_stats      stats;          /* statistic information        */
227
228   /* PPP demand dial information. */
229   struct ppp_ddinfo     ddinfo;         /* demand dial information      */
230 };
231
232 #endif  /* __KERNEL__ */
233 #endif  /* _LINUX_PPP_H */
234
235