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