isdn_ppp.h 7.9 KB

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