ppp_defs.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /* $OpenBSD: ppp_defs.h,v 1.13 2002/09/13 00:12:07 deraadt Exp $ */
  2. /* $NetBSD: ppp_defs.h,v 1.1 1995/07/04 06:28:26 paulus Exp $ */
  3. /*
  4. * ppp_defs.h - PPP definitions.
  5. *
  6. * Copyright (c) 1989-2002 Paul Mackerras. All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * 3. The name(s) of the authors of this software must not be used to
  21. * endorse or promote products derived from this software without
  22. * prior written permission.
  23. *
  24. * 4. Redistributions of any form whatsoever must retain the following
  25. * acknowledgment:
  26. * "This product includes software developed by Paul Mackerras
  27. * <paulus@samba.org>".
  28. *
  29. * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
  30. * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  31. * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
  32. * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  33. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
  34. * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  35. * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  36. */
  37. #ifndef _PPP_DEFS_H_
  38. #define _PPP_DEFS_H_
  39. /*
  40. * The basic PPP frame.
  41. */
  42. #define PPP_HDRLEN 4 /* octets for standard ppp header */
  43. #define PPP_FCSLEN 2 /* octets for FCS */
  44. #define PPP_MRU 1500 /* default MRU = max length of info field */
  45. #define PPP_ADDRESS(p) (((u_char *)(p))[0])
  46. #define PPP_CONTROL(p) (((u_char *)(p))[1])
  47. #define PPP_PROTOCOL(p) ((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3])
  48. /*
  49. * Significant octet values.
  50. */
  51. #define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */
  52. #define PPP_UI 0x03 /* Unnumbered Information */
  53. #define PPP_FLAG 0x7e /* Flag Sequence */
  54. #define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */
  55. #define PPP_TRANS 0x20 /* Asynchronous transparency modifier */
  56. /*
  57. * Protocol field values.
  58. */
  59. #define PPP_IP 0x21 /* Internet Protocol */
  60. #define PPP_XNS 0x25 /* Xerox NS */
  61. #define PPP_AT 0x29 /* AppleTalk Protocol */
  62. #define PPP_IPX 0x2b /* Internetwork Packet Exchange */
  63. #define PPP_VJC_COMP 0x2d /* VJ compressed TCP */
  64. #define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */
  65. #define PPP_IPV6 0x57 /* Internet Protocol Version 6 */
  66. #define PPP_COMP 0xfd /* compressed packet */
  67. #define PPP_IPCP 0x8021 /* IP Control Protocol */
  68. #define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */
  69. #define PPP_IPXCP 0x802b /* IPX Control Protocol */
  70. #define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */
  71. #define PPP_CCP 0x80fd /* Compression Control Protocol */
  72. #define PPP_LCP 0xc021 /* Link Control Protocol */
  73. #define PPP_PAP 0xc023 /* Password Authentication Protocol */
  74. #define PPP_LQR 0xc025 /* Link Quality Report protocol */
  75. #define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */
  76. #define PPP_CBCP 0xc029 /* Callback Control Protocol */
  77. /*
  78. * Values for FCS calculations.
  79. */
  80. #define PPP_INITFCS 0xffff /* Initial FCS value */
  81. #define PPP_GOODFCS 0xf0b8 /* Good final FCS value */
  82. #define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
  83. /*
  84. * A 32-bit unsigned integral type.
  85. */
  86. #ifndef __BIT_TYPES_DEFINED__
  87. #ifdef UINT32_T
  88. typedef UINT32_T u_int32_t;
  89. #else
  90. typedef unsigned int u_int32_t;
  91. typedef unsigned short u_int16_t;
  92. #endif
  93. #endif
  94. /*
  95. * Extended asyncmap - allows any character to be escaped.
  96. */
  97. typedef u_int32_t ext_accm[8];
  98. /*
  99. * What to do with network protocol (NP) packets.
  100. */
  101. enum NPmode {
  102. NPMODE_PASS, /* pass the packet through */
  103. NPMODE_DROP, /* silently drop the packet */
  104. NPMODE_ERROR, /* return an error */
  105. NPMODE_QUEUE /* save it up for later. */
  106. };
  107. /*
  108. * Statistics.
  109. */
  110. struct pppstat {
  111. u_int ppp_ibytes; /* bytes received */
  112. u_int ppp_ipackets; /* packets received */
  113. u_int ppp_ierrors; /* receive errors */
  114. u_int ppp_obytes; /* bytes sent */
  115. u_int ppp_opackets; /* packets sent */
  116. u_int ppp_oerrors; /* transmit errors */
  117. };
  118. struct vjstat {
  119. u_int vjs_packets; /* outbound packets */
  120. u_int vjs_compressed; /* outbound compressed packets */
  121. u_int vjs_searches; /* searches for connection state */
  122. u_int vjs_misses; /* times couldn't find conn. state */
  123. u_int vjs_uncompressedin; /* inbound uncompressed packets */
  124. u_int vjs_compressedin; /* inbound compressed packets */
  125. u_int vjs_errorin; /* inbound unknown type packets */
  126. u_int vjs_tossed; /* inbound packets tossed because of error */
  127. };
  128. struct ppp_stats {
  129. struct pppstat p; /* basic PPP statistics */
  130. struct vjstat vj; /* VJ header compression statistics */
  131. };
  132. struct compstat {
  133. u_int unc_bytes; /* total uncompressed bytes */
  134. u_int unc_packets; /* total uncompressed packets */
  135. u_int comp_bytes; /* compressed bytes */
  136. u_int comp_packets; /* compressed packets */
  137. u_int inc_bytes; /* incompressible bytes */
  138. u_int inc_packets; /* incompressible packets */
  139. u_int ratio; /* recent compression ratio << 8 */
  140. };
  141. struct ppp_comp_stats {
  142. struct compstat c; /* packet compression statistics */
  143. struct compstat d; /* packet decompression statistics */
  144. };
  145. /*
  146. * The following structure records the time in seconds since
  147. * the last NP packet was sent or received.
  148. */
  149. struct ppp_idle {
  150. time_t xmit_idle; /* time since last NP packet sent */
  151. time_t recv_idle; /* time since last NP packet received */
  152. };
  153. #endif /* _PPP_DEFS_H_ */