isdn_ppp.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:7k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

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