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