if_ppp.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:8k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* if_ppp.h - Point-to-Point Protocol (PPP) Asynchronous driver header */
  2. /* Copyright 1995 Wind River Systems, Inc. */
  3. /*
  4.  * Copyright (c) 1989 Carnegie Mellon University.
  5.  * All rights reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms are permitted
  8.  * provided that the above copyright notice and this paragraph are
  9.  * duplicated in all such forms and that any documentation,
  10.  * advertising materials, and other materials related to such
  11.  * distribution and use acknowledge that the software was developed
  12.  * by Carnegie Mellon University.  The name of the
  13.  * University may not be used to endorse or promote products derived
  14.  * from this software without specific prior written permission.
  15.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  16.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  17.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  18.  */
  19. /*
  20. modification history
  21. --------------------
  22. 01b,09mar95,dzb  ppp_softc: added sc_iprcvd/sc_ipsent and removed bpf.
  23. 01a,16jan95,dab  VxWorks port - first WRS version.
  24.            +dzb  WRS-ize.  moved in global prototypes from if_ppp.c.
  25. */
  26. #ifndef __INCif_ppph
  27. #define __INCif_ppph
  28. #ifdef  __cplusplus
  29. extern "C" {
  30. #endif
  31. /* includes */
  32. #include "private/semLibP.h"
  33. #include "rngLib.h"
  34. #include "netinet/sl_compress.h"
  35. /*
  36.  * Standard PPP header.
  37.  */
  38. struct ppp_header {
  39. u_char ph_address; /* Address Field */
  40. u_char ph_control; /* Control Field */
  41. u_short ph_protocol; /* Protocol Field */
  42. };
  43. #define PPP_HDRLEN   4 /* sizeof(struct ppp_header) must be 4 */
  44. #define PPP_FCSLEN 2 /* octets for FCS */
  45. #define PPP_ALLSTATIONS 0xff    /* All-Stations broadcast address */
  46. #define PPP_UI          0x03    /* Unnumbered Information */
  47. #define PPP_FLAG        0x7e    /* Flag Sequence */
  48. #define PPP_ESCAPE      0x7d    /* Asynchronous Control Escape */
  49. #define PPP_TRANS       0x20    /* Asynchronous transparency modifier */
  50. /*
  51.  * Protocol field values.
  52.  */
  53. #define PPP_IP          0x21    /* Internet Protocol */
  54. #define PPP_XNS         0x25    /* Xerox NS */
  55. #define PPP_VJC_COMP    0x2d    /* VJ compressed TCP */
  56. #define PPP_VJC_UNCOMP  0x2f    /* VJ uncompressed TCP */
  57. #define PPP_COMP        0xfd    /* compressed packet */
  58. #define PPP_LCP         0xc021  /* Link Control Protocol */
  59. #define PPP_CCP         0x80fd  /* Compression Control Protocol */
  60. /*
  61.  * Important FCS values.
  62.  */
  63. #define PPP_INITFCS     0xffff  /* Initial FCS value */
  64. #define PPP_GOODFCS     0xf0b8  /* Good final FCS value */
  65. #define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
  66. /*
  67.  * Packet sizes
  68.  */
  69. #define PPP_MTU         1500    /* Default MTU (size of Info field) */
  70. #define PPP_MRU         1500    /* Default MRU (max receive unit) */
  71. #define PPP_MAXMRU      65000   /* Largest MRU we allow */
  72. /* Extended asyncmap - allows any character to be escaped. */
  73. typedef u_long  ext_accm[8];
  74. /*
  75.  * Structure describing each ppp unit.
  76.  */
  77. struct ppp_softc {
  78. struct  ifnet sc_if; /* network-visible interface */
  79. u_int sc_flags; /* see below */
  80. void    *sc_devp;       /* pointer to device-dependent structure */
  81. int     (*sc_start)();  /* start routine */
  82. short   sc_mru;         /* max receive unit */
  83. int sc_xfer;        /* used in xferring unit to another dev */
  84. struct  ifqueue sc_inq; /* TTY side input queue */
  85. struct  ifqueue sc_fastq; /* IP interactive output packet queue */
  86. #ifdef  VJC
  87. struct  slcompress sc_comp; /* vjc control buffer */
  88. #endif
  89. u_int   sc_bytessent;   /* count of octets sent */
  90. u_int   sc_bytesrcvd;   /* count of octets received */
  91. u_int sc_ipsent; /* count of ip packets sent */
  92. u_int sc_iprcvd; /* count of ip packets received */
  93.         /* Device-dependent part for async lines. */
  94. ext_accm sc_asyncmap;   /* async control character map */
  95. u_long  sc_rasyncmap;   /* receive async control char map */
  96. struct  mbuf *sc_outm;  /* mbuf chain being output currently */
  97. struct  mbuf *sc_m;     /* pointer to input mbuf chain */
  98. struct  mbuf *sc_mc;    /* pointer to current input mbuf */
  99. char *sc_mp; /* pointer to next char in input mbuf */
  100. short sc_ilen; /* length of input-packet-so-far */
  101. u_short sc_fcs;         /* FCS so far (input) */
  102. u_short sc_outfcs;      /* FCS so far for output packet */
  103. u_char  sc_rawin[16];   /* chars as received */
  104. int     sc_rawin_count; /* # in sc_rawin */
  105. /* VxWorks-dependent part */
  106. int sc_fd; /* file descriptor */
  107. short sc_qlen; /* length of tty input queue */
  108. SEMAPHORE    sc_wrtsem; /* write semaphore */
  109. int     sc_wrt_task_id; /* write task ID */
  110. int  pkt_len; /* length of current packet */
  111. int     sc_tid;         /* tid of daemon task */
  112. };
  113. /* flags */
  114. #define SC_COMP_PROT    0x00000001      /* protocol compression (output) */
  115. #define SC_COMP_AC      0x00000002      /* header compression (output) */
  116. #define SC_COMP_TCP     0x00000004      /* TCP (VJ) compression (output) */
  117. #define SC_NO_TCP_CCID  0x00000008      /* disable VJ connection-id comp. */
  118. #define SC_REJ_COMP_AC  0x00000010      /* reject adrs/ctrl comp. on input */
  119. #define SC_REJ_COMP_TCP 0x00000020      /* reject TCP (VJ) comp. on input */
  120. #define SC_ENABLE_IP    0x00000100      /* IP packets may be exchanged */
  121. #define SC_DEBUG        0x00010000      /* enable debug messages */
  122. #define SC_LOG_INPKT    0x00020000      /* log contents of good pkts recvd */
  123. #define SC_LOG_OUTPKT   0x00040000      /* log contents of pkts sent */
  124. #define SC_LOG_RAWIN    0x00080000      /* log all chars received */
  125. #define SC_LOG_FLUSH    0x00100000      /* log all chars flushed */
  126. #define SC_MASK         0x0fffffff      /* bits that user can change */
  127. /* state bits */
  128. #define SC_ESCAPED      0x80000000      /* saw a PPP_ESCAPE */
  129. #define SC_FLUSH        0x40000000      /* flush input until next PPP_FLAG */
  130. #define SC_DISCARD_PKT  0x20000000      /* Discard packet at interrupt level */
  131. #define SC_RCV_B7_0     0x01000000      /* have rcvd char with bit 7 = 0 */
  132. #define SC_RCV_B7_1     0x02000000      /* have rcvd char with bit 7 = 0 */
  133. #define SC_RCV_EVNP     0x04000000      /* have rcvd char with even parity */
  134. #define SC_RCV_ODDP     0x08000000      /* have rcvd char with odd parity */
  135. /* this stuff doesn't belong here... */
  136. #define PPPIOCGSEM _IOR('t', 92, int) /* get ppp read semaphore */
  137. #define PPPIOCGFD _IOR('t', 91, int) /* get ppp underlying fd */
  138. #define PPPIOCGFLAGS    _IOR('t', 90, int)      /* get configuration flags */
  139. #define PPPIOCSFLAGS    _IOW('t', 89, int)      /* set configuration flags */
  140. #define PPPIOCGASYNCMAP _IOR('t', 88, int)      /* get async map */
  141. #define PPPIOCSASYNCMAP _IOW('t', 87, int)      /* set async map */
  142. #define PPPIOCGUNIT     _IOR('t', 86, int)      /* get ppp unit number */
  143. #define PPPIOCGRASYNCMAP _IOR('t', 85, int)     /* get receive async map */
  144. #define PPPIOCSRASYNCMAP _IOW('t', 84, int)     /* set receive async map */
  145. #define PPPIOCGMRU      _IOR('t', 83, int)      /* get max receive unit */
  146. #define PPPIOCSMRU      _IOW('t', 82, int)      /* set max receive unit */
  147. #define PPPIOCSMAXCID   _IOW('t', 81, int)      /* set VJ max slot ID */
  148. #define PPPIOCGXASYNCMAP _IOR('t', 80, ext_accm) /* get extended ACCM */
  149. #define PPPIOCSXASYNCMAP _IOW('t', 79, ext_accm) /* set extended ACCM */
  150. #define PPPIOCXFERUNIT  _IO('t', 78)            /* transfer PPP unit */
  151. #ifdef ultrix
  152. #define ifr_mtu ifr_ifru.ifru_metric
  153. #endif
  154. /* old copies of PPP may have defined this */
  155. #if !defined(ifr_mtu)
  156. #define ifr_mtu ifr_metric
  157. #endif
  158. /* function declarations */
  159. extern int pppopen __ARGS((int, char *));
  160. extern int pppclose __ARGS((int));
  161. extern int pppread __ARGS((int , char *, int));
  162. extern int pppwrite __ARGS((int , char *, int));
  163. extern int ppptioctl __ARGS((int , int , caddr_t));
  164. extern void ppp_wrt_task __ARGS((struct ppp_softc *));
  165. #ifdef  __cplusplus
  166. }
  167. #endif
  168. #endif /* __INCif_ppph */