ppp_defs.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * ppp_defs.h - PPP definitions.
  3. */
  4. /*-
  5. * Copyright (c) 1994 The Australian National University.
  6. * All rights reserved.
  7. *
  8. * Permission to use, copy, modify, and distribute this software and its
  9. * documentation is hereby granted, provided that the above copyright
  10. * notice appears in all copies. This software is provided without any
  11. * warranty, express or implied. The Australian National University
  12. * makes no representations about the suitability of this software for
  13. * any purpose.
  14. *
  15. * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
  16. * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  17. * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
  18. * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
  19. * OF SUCH DAMAGE.
  20. *
  21. * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  22. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  23. * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
  24. * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
  25. * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
  26. * OR MODIFICATIONS.
  27. */
  28. #ifndef _PPP_DEFS_H_
  29. #define _PPP_DEFS_H_
  30. #include <sys/_types.h>
  31. /*
  32. * The basic PPP frame.
  33. */
  34. #define PPP_HDRLEN 4 /* octets for standard ppp header */
  35. #define PPP_FCSLEN 2 /* octets for FCS */
  36. #define PPP_MRU 1500 /* default MRU = max length of info field */
  37. #define PPP_ADDRESS(p) (((u_char *)(p))[0])
  38. #define PPP_CONTROL(p) (((u_char *)(p))[1])
  39. #define PPP_PROTOCOL(p) ((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3])
  40. /*
  41. * Significant octet values.
  42. */
  43. #define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */
  44. #define PPP_UI 0x03 /* Unnumbered Information */
  45. #define PPP_FLAG 0x7e /* Flag Sequence */
  46. #define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */
  47. #define PPP_TRANS 0x20 /* Asynchronous transparency modifier */
  48. /*
  49. * Protocol field values.
  50. */
  51. #define PPP_IP 0x21 /* Internet Protocol */
  52. #define PPP_XNS 0x25 /* Xerox NS */
  53. #define PPP_AT 0x29 /* AppleTalk Protocol */
  54. #define PPP_IPX 0x2b /* IPX Datagram (RFC1552) */
  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_IPCP 0x8021 /* IP Control Protocol */
  59. #define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */
  60. #define PPP_IPXCP 0x802b /* IPX Control Protocol (RFC1552) */
  61. #define PPP_CCP 0x80fd /* Compression Control Protocol */
  62. #define PPP_LCP 0xc021 /* Link Control Protocol */
  63. #define PPP_PAP 0xc023 /* Password Authentication Protocol */
  64. #define PPP_LQR 0xc025 /* Link Quality Report protocol */
  65. #define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */
  66. #define PPP_CBCP 0xc029 /* Callback Control Protocol */
  67. #define PPP_IPV6 0x57 /* Internet Protocol version 6*/
  68. #define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */
  69. /*
  70. * Values for FCS calculations.
  71. */
  72. #define PPP_INITFCS 0xffff /* Initial FCS value */
  73. #define PPP_GOODFCS 0xf0b8 /* Good final FCS value */
  74. #define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
  75. /*
  76. * Extended asyncmap - allows any character to be escaped.
  77. */
  78. typedef __uint32_t ext_accm[8];
  79. /*
  80. * What to do with network protocol (NP) packets.
  81. */
  82. enum NPmode {
  83. NPMODE_PASS, /* pass the packet through */
  84. NPMODE_DROP, /* silently drop the packet */
  85. NPMODE_ERROR, /* return an error */
  86. NPMODE_QUEUE /* save it up for later. */
  87. };
  88. /*
  89. * Statistics.
  90. */
  91. struct pppstat {
  92. unsigned int ppp_ibytes; /* bytes received */
  93. unsigned int ppp_ipackets; /* packets received */
  94. unsigned int ppp_ierrors; /* receive errors */
  95. unsigned int ppp_obytes; /* bytes sent */
  96. unsigned int ppp_opackets; /* packets sent */
  97. unsigned int ppp_oerrors; /* transmit errors */
  98. };
  99. struct vjstat {
  100. unsigned int vjs_packets; /* outbound packets */
  101. unsigned int vjs_compressed; /* outbound compressed packets */
  102. unsigned int vjs_searches; /* searches for connection state */
  103. unsigned int vjs_misses; /* times couldn't find conn. state */
  104. unsigned int vjs_uncompressedin; /* inbound uncompressed packets */
  105. unsigned int vjs_compressedin; /* inbound compressed packets */
  106. unsigned int vjs_errorin; /* inbound unknown type packets */
  107. unsigned int vjs_tossed; /* inbound packets tossed because of error */
  108. };
  109. struct ppp_stats {
  110. struct pppstat p; /* basic PPP statistics */
  111. struct vjstat vj; /* VJ header compression statistics */
  112. };
  113. struct compstat {
  114. unsigned int unc_bytes; /* total uncompressed bytes */
  115. unsigned int unc_packets; /* total uncompressed packets */
  116. unsigned int comp_bytes; /* compressed bytes */
  117. unsigned int comp_packets; /* compressed packets */
  118. unsigned int inc_bytes; /* incompressible bytes */
  119. unsigned int inc_packets; /* incompressible packets */
  120. unsigned int ratio; /* recent compression ratio << 8 */
  121. };
  122. struct ppp_comp_stats {
  123. struct compstat c; /* packet compression statistics */
  124. struct compstat d; /* packet decompression statistics */
  125. };
  126. /*
  127. * The following structure records the time in seconds since
  128. * the last NP packet was sent or received.
  129. */
  130. struct ppp_idle {
  131. __time_t xmit_idle; /* time since last NP packet sent */
  132. __time_t recv_idle; /* time since last NP packet received */
  133. };
  134. #ifndef __P
  135. #ifdef __STDC__
  136. #define __P(x) x
  137. #else
  138. #define __P(x) ()
  139. #endif
  140. #endif
  141. #endif /* _PPP_DEFS_H_ */