File: /usr/src/linux/include/linux/isdn_ppp.h
1 /* -*- mode: c; c-basic-offset: 2 -*- */
2
3 #ifndef _LINUX_ISDN_PPP_H
4 #define _LINUX_ISDN_PPP_H
5
6
7 #define CALLTYPE_INCOMING 0x1
8 #define CALLTYPE_OUTGOING 0x2
9 #define CALLTYPE_CALLBACK 0x4
10
11 #define IPPP_VERSION "2.2.0"
12
13 struct pppcallinfo
14 {
15 int calltype;
16 unsigned char local_num[64];
17 unsigned char remote_num[64];
18 int charge_units;
19 };
20
21 #define PPPIOCGCALLINFO _IOWR('t',128,struct pppcallinfo)
22 #define PPPIOCBUNDLE _IOW('t',129,int)
23 #define PPPIOCGMPFLAGS _IOR('t',130,int)
24 #define PPPIOCSMPFLAGS _IOW('t',131,int)
25 #define PPPIOCSMPMTU _IOW('t',132,int)
26 #define PPPIOCSMPMRU _IOW('t',133,int)
27 #define PPPIOCGCOMPRESSORS _IOR('t',134,unsigned long [8])
28 #define PPPIOCSCOMPRESSOR _IOW('t',135,int)
29 #define PPPIOCGIFNAME _IOR('t',136, char [IFNAMSIZ] )
30
31
32 #define SC_MP_PROT 0x00000200
33 #define SC_REJ_MP_PROT 0x00000400
34 #define SC_OUT_SHORT_SEQ 0x00000800
35 #define SC_IN_SHORT_SEQ 0x00004000
36
37 #define SC_DECOMP_ON 0x01
38 #define SC_COMP_ON 0x02
39 #define SC_DECOMP_DISCARD 0x04
40 #define SC_COMP_DISCARD 0x08
41 #define SC_LINK_DECOMP_ON 0x10
42 #define SC_LINK_COMP_ON 0x20
43 #define SC_LINK_DECOMP_DISCARD 0x40
44 #define SC_LINK_COMP_DISCARD 0x80
45
46 #define ISDN_PPP_COMP_MAX_OPTIONS 16
47
48 #define IPPP_COMP_FLAG_XMIT 0x1
49 #define IPPP_COMP_FLAG_LINK 0x2
50
51 struct isdn_ppp_comp_data {
52 int num;
53 unsigned char options[ISDN_PPP_COMP_MAX_OPTIONS];
54 int optlen;
55 int flags;
56 };
57
58 #ifdef __KERNEL__
59
60
61 #include <linux/config.h>
62
63
64 #define DECOMP_ERR_NOMEM (-10)
65
66 #define MP_END_FRAG 0x40
67 #define MP_BEGIN_FRAG 0x80
68
69 #define MP_MAX_QUEUE_LEN 16
70
71 /*
72 * We need a way for the decompressor to influence the generation of CCP
73 * Reset-Requests in a variety of ways. The decompressor is already returning
74 * a lot of information (generated skb length, error conditions) so we use
75 * another parameter. This parameter is a pointer to a structure which is
76 * to be marked valid by the decompressor and only in this case is ever used.
77 * Furthermore, the only case where this data is used is when the decom-
78 * pressor returns DECOMP_ERROR.
79 *
80 * We use this same struct for the reset entry of the compressor to commu-
81 * nicate to its caller how to deal with sending of a Reset Ack. In this
82 * case, expra is not used, but other options still apply (suppressing
83 * sending with rsend, appending arbitrary data, etc).
84 */
85
86 #define IPPP_RESET_MAXDATABYTES 32
87
88 struct isdn_ppp_resetparams {
89 unsigned char valid:1; /* rw Is this structure filled at all ? */
90 unsigned char rsend:1; /* rw Should we send one at all ? */
91 unsigned char idval:1; /* rw Is the id field valid ? */
92 unsigned char dtval:1; /* rw Is the data field valid ? */
93 unsigned char expra:1; /* rw Is an Ack expected for this Req ? */
94 unsigned char id; /* wo Send CCP ResetReq with this id */
95 unsigned short maxdlen; /* ro Max bytes to be stored in data field */
96 unsigned short dlen; /* rw Bytes stored in data field */
97 unsigned char *data; /* wo Data for ResetReq info field */
98 };
99
100 /*
101 * this is an 'old friend' from ppp-comp.h under a new name
102 * check the original include for more information
103 */
104 struct isdn_ppp_compressor {
105 struct isdn_ppp_compressor *next, *prev;
106 int num; /* CCP compression protocol number */
107
108 void *(*alloc) (struct isdn_ppp_comp_data *);
109 void (*free) (void *state);
110 int (*init) (void *state, struct isdn_ppp_comp_data *,
111 int unit,int debug);
112
113 /* The reset entry needs to get more exact information about the
114 ResetReq or ResetAck it was called with. The parameters are
115 obvious. If reset is called without a Req or Ack frame which
116 could be handed into it, code MUST be set to 0. Using rsparm,
117 the reset entry can control if and how a ResetAck is returned. */
118
119 void (*reset) (void *state, unsigned char code, unsigned char id,
120 unsigned char *data, unsigned len,
121 struct isdn_ppp_resetparams *rsparm);
122
123 int (*compress) (void *state, struct sk_buff *in,
124 struct sk_buff *skb_out, int proto);
125
126 int (*decompress) (void *state,struct sk_buff *in,
127 struct sk_buff *skb_out,
128 struct isdn_ppp_resetparams *rsparm);
129
130 void (*incomp) (void *state, struct sk_buff *in,int proto);
131 void (*stat) (void *state, struct compstat *stats);
132 };
133
134 extern int isdn_ppp_register_compressor(struct isdn_ppp_compressor *);
135 extern int isdn_ppp_unregister_compressor(struct isdn_ppp_compressor *);
136 extern int isdn_ppp_dial_slave(char *);
137 extern int isdn_ppp_hangup_slave(char *);
138
139 typedef struct {
140 unsigned long seqerrs;
141 unsigned long frame_drops;
142 unsigned long overflows;
143 unsigned long max_queue_len;
144 } isdn_mppp_stats;
145
146 typedef struct {
147 int mp_mrru; /* unused */
148 struct sk_buff * frags; /* fragments sl list -- use skb->next */
149 long frames; /* number of frames in the frame list */
150 unsigned int seq; /* last processed packet seq #: any packets
151 * with smaller seq # will be dropped
152 * unconditionally */
153 spinlock_t lock;
154 int ref_ct;
155 /* statistics */
156 isdn_mppp_stats stats;
157 } ippp_bundle;
158
159 #define NUM_RCV_BUFFS 64
160
161 struct ippp_buf_queue {
162 struct ippp_buf_queue *next;
163 struct ippp_buf_queue *last;
164 char *buf; /* NULL here indicates end of queue */
165 int len;
166 };
167
168 /* The data structure for one CCP reset transaction */
169 enum ippp_ccp_reset_states {
170 CCPResetIdle,
171 CCPResetSentReq,
172 CCPResetRcvdReq,
173 CCPResetSentAck,
174 CCPResetRcvdAck
175 };
176
177 struct ippp_ccp_reset_state {
178 enum ippp_ccp_reset_states state; /* State of this transaction */
179 struct ippp_struct *is; /* Backlink to device stuff */
180 unsigned char id; /* Backlink id index */
181 unsigned char ta:1; /* The timer is active (flag) */
182 unsigned char expra:1; /* We expect a ResetAck at all */
183 int dlen; /* Databytes stored in data */
184 struct timer_list timer; /* For timeouts/retries */
185 /* This is a hack but seems sufficient for the moment. We do not want
186 to have this be yet another allocation for some bytes, it is more
187 memory management overhead than the whole mess is worth. */
188 unsigned char data[IPPP_RESET_MAXDATABYTES];
189 };
190
191 /* The data structure keeping track of the currently outstanding CCP Reset
192 transactions. */
193 struct ippp_ccp_reset {
194 struct ippp_ccp_reset_state *rs[256]; /* One per possible id */
195 unsigned char lastid; /* Last id allocated by the engine */
196 };
197
198 struct ippp_struct {
199 struct ippp_struct *next_link;
200 int state;
201 struct ippp_buf_queue rq[NUM_RCV_BUFFS]; /* packet queue for isdn_ppp_read() */
202 struct ippp_buf_queue *first; /* pointer to (current) first packet */
203 struct ippp_buf_queue *last; /* pointer to (current) last used packet in queue */
204 wait_queue_head_t wq;
205 struct task_struct *tk;
206 unsigned int mpppcfg;
207 unsigned int pppcfg;
208 unsigned int mru;
209 unsigned int mpmru;
210 unsigned int mpmtu;
211 unsigned int maxcid;
212 struct isdn_net_local_s *lp;
213 int unit;
214 int minor;
215 unsigned int last_link_seqno;
216 long mp_seqno;
217 #ifdef CONFIG_ISDN_PPP_VJ
218 unsigned char *cbuf;
219 struct slcompress *slcomp;
220 #endif
221 unsigned long debug;
222 struct isdn_ppp_compressor *compressor,*decompressor;
223 struct isdn_ppp_compressor *link_compressor,*link_decompressor;
224 void *decomp_stat,*comp_stat,*link_decomp_stat,*link_comp_stat;
225 struct ippp_ccp_reset *reset; /* Allocated on demand, may never be needed */
226 unsigned long compflags;
227 };
228
229 #endif /* __KERNEL__ */
230 #endif /* _LINUX_ISDN_PPP_H */
231