1
0

pptpdefs.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. /*
  2. * pptpdefs.h
  3. *
  4. * PPTP structs and defines
  5. *
  6. * $Id: pptpdefs.h,v 1.4 2006/12/08 00:01:40 quozl Exp $
  7. */
  8. #ifndef _PPTPD_PPTPDEFS_H
  9. #define _PPTPD_PPTPDEFS_H
  10. /* define "portable" htons, etc, copied to make Ananian's gre stuff work. */
  11. #define hton8(x) (x)
  12. #define ntoh8(x) (x)
  13. #define hton16(x) htons(x)
  14. #define ntoh16(x) ntohs(x)
  15. #define hton32(x) htonl(x)
  16. #define ntoh32(x) ntohl(x)
  17. #include <sys/types.h>
  18. /* PPTP ctrl message port */
  19. #define PPTP_PORT 1723
  20. /* PPTP gre prototype */
  21. #define PPTP_PROTO 47
  22. /* PPTP version */
  23. #define PPTP_VERSION 0x0100
  24. #define PPTP_FIRMWARE_VERSION 0x0001
  25. /* Hostname and Vendor */
  26. #define PPTP_HOSTNAME "local"
  27. #define PPTP_VENDOR "linux"
  28. #define MAX_HOSTNAME_SIZE 64
  29. #define MAX_VENDOR_SIZE 64
  30. /* Magic Cookie */
  31. #define PPTP_MAGIC_COOKIE 0x1a2b3c4d
  32. /* Message types */
  33. #define PPTP_CTRL_MESSAGE 1
  34. /* Maximum size of any PPTP control packet we will get */
  35. #define PPTP_MAX_CTRL_PCKT_SIZE 220
  36. /* Control Connection Management */
  37. #define START_CTRL_CONN_RQST 1
  38. #define START_CTRL_CONN_RPLY 2
  39. #define STOP_CTRL_CONN_RQST 3
  40. #define STOP_CTRL_CONN_RPLY 4
  41. #define ECHO_RQST 5
  42. #define ECHO_RPLY 6
  43. /* Call Management */
  44. #define OUT_CALL_RQST 7
  45. #define OUT_CALL_RPLY 8
  46. #define IN_CALL_RQST 9
  47. #define IN_CALL_RPLY 10
  48. #define IN_CALL_CONN 11
  49. #define CALL_CLR_RQST 12
  50. #define CALL_DISCONN_NTFY 13
  51. /* Error Reporting */
  52. #define WAN_ERR_NTFY 14
  53. /* PPP Session Control */
  54. #define SET_LINK_INFO 15
  55. /* how long before a link is idle? (seconds) */
  56. #define IDLE_WAIT 60
  57. /* how long should we wait for an echo reply? (seconds) */
  58. #define MAX_ECHO_WAIT 60
  59. #define RESERVED 0x0000
  60. /* Start Control Connection Reply */
  61. #define ASYNCHRONOUS_FRAMING 0x00000001
  62. #define SYNCHRONOUS_FRAMING 0x00000002
  63. #define ANALOG_ACCESS 0x00000001
  64. #define DIGITAL_ACCESS 0x00000002
  65. /* Our properties - we don't actually have any physical serial i/f's and only want
  66. * one call per client!
  67. */
  68. #define OUR_FRAMING 0x00000000
  69. #define OUR_BEARER 0x00000000
  70. #define MAX_CHANNELS 0x0001
  71. /* Out Call Reply Defines */
  72. #define PCKT_RECV_WINDOW_SIZE 0x0001
  73. #define PCKT_PROCESS_DELAY 0x0000
  74. #define CHANNEL_ID 0x00000000
  75. /* ERROR CODES */
  76. #define NO_ERROR 0x00
  77. /* CALL_CLEAR RESULT CODES */
  78. #define LOST_CARRIER 0x01
  79. #define ADMIN_SHUTDOWN 0x03
  80. #define CALL_CLEAR_REQUEST 0x04
  81. /* RESULT CODES */
  82. #define CONNECTED 0x01
  83. #define DISCONNECTED 0x01
  84. #define GENERAL_ERROR 0x02 /* also for ERROR CODES, CALL CLEAR */
  85. #define NO_CARRIER 0x03
  86. #define BUSY 0x04
  87. #define NO_DIAL_TONE 0x05
  88. #define TIME_OUT 0x06
  89. #define DO_NOT_ACCEPT 0x07
  90. /* CTRL CLOSE CODES */
  91. #define GENERAL_STOP_CTRL 0x01
  92. #define STOP_PROTOCOL 0x02
  93. #define STOP_LOCAL_SHUTDOWN 0x03
  94. /* PPTP CTRL structs */
  95. struct pptp_header {
  96. u_int16_t length; /* pptp message length incl header */
  97. u_int16_t pptp_type; /* pptp message type */
  98. u_int32_t magic; /* magic cookie */
  99. u_int16_t ctrl_type; /* control message type */
  100. u_int16_t reserved0; /* reserved */
  101. };
  102. struct pptp_start_ctrl_conn_rqst {
  103. struct pptp_header header; /* pptp header */
  104. u_int16_t version; /* pptp protocol version */
  105. u_int16_t reserved1; /* reserved */
  106. u_int32_t framing_cap; /* framing capabilities */
  107. u_int32_t bearer_cap; /* bearer capabilities */
  108. u_int16_t max_channels; /* maximum channels */
  109. u_int16_t firmware_rev; /* firmware revision */
  110. u_int8_t hostname[MAX_HOSTNAME_SIZE]; /* hostname */
  111. u_int8_t vendor[MAX_VENDOR_SIZE]; /* vendor */
  112. };
  113. struct pptp_start_ctrl_conn_rply {
  114. struct pptp_header header; /* pptp header */
  115. u_int16_t version; /* pptp protocol version */
  116. u_int8_t result_code; /* result code */
  117. u_int8_t error_code; /* error code */
  118. u_int32_t framing_cap; /* framing capabilities */
  119. u_int32_t bearer_cap; /* bearer capabilities */
  120. u_int16_t max_channels; /* maximum channels */
  121. u_int16_t firmware_rev; /* firmware revision */
  122. u_int8_t hostname[MAX_HOSTNAME_SIZE]; /* hostname */
  123. u_int8_t vendor[MAX_VENDOR_SIZE]; /* vendor */
  124. };
  125. struct pptp_stop_ctrl_conn_rqst {
  126. struct pptp_header header; /* header */
  127. u_int8_t reason; /* reason for closing */
  128. u_int8_t reserved1; /* reserved */
  129. u_int16_t reserved2; /* reserved */
  130. };
  131. struct pptp_stop_ctrl_conn_rply {
  132. struct pptp_header header; /* header */
  133. u_int8_t result_code; /* result code */
  134. u_int8_t error_code; /* error code */
  135. u_int16_t reserved1; /* reserved */
  136. };
  137. struct pptp_echo_rqst {
  138. struct pptp_header header; /* header */
  139. u_int32_t identifier; /* value to match rply with rqst */
  140. };
  141. struct pptp_echo_rply {
  142. struct pptp_header header; /* header */
  143. u_int32_t identifier; /* identifier of echo rqst */
  144. u_int8_t result_code; /* result code */
  145. u_int8_t error_code; /* error code */
  146. u_int16_t reserved1; /* reserved */
  147. };
  148. struct pptp_out_call_rqst {
  149. struct pptp_header header; /* header */
  150. u_int16_t call_id; /* unique identifier to PAC-PNS pair */
  151. u_int16_t call_serial; /* session identifier */
  152. u_int32_t min_bps; /* minimum line speed */
  153. u_int32_t max_bps; /* maximum line speed */
  154. u_int32_t bearer_type; /* bearer type */
  155. u_int32_t framing_type; /* framing type */
  156. u_int16_t pckt_recv_size; /* packet recv window size */
  157. u_int16_t pckt_delay; /* packet processing delay */
  158. u_int16_t phone_len; /* phone number length */
  159. u_int16_t reserved1; /* reserved */
  160. u_int8_t phone_num[64]; /* phone number */
  161. u_int8_t subaddress[64]; /* additional dialing info */
  162. };
  163. struct pptp_out_call_rply {
  164. struct pptp_header header; /* header */
  165. u_int16_t call_id; /* unique identifier to PAC-PNS pair */
  166. u_int16_t call_id_peer; /* set to call_id of the call rqst */
  167. u_int8_t result_code; /* result code */
  168. u_int8_t error_code; /* error code */
  169. u_int16_t cause_code; /* additional failure information */
  170. u_int32_t speed; /* actual connection speed */
  171. u_int16_t pckt_recv_size; /* packet recv window size */
  172. u_int16_t pckt_delay; /* packet processing delay */
  173. u_int32_t channel_id; /* physical channel ID */
  174. };
  175. struct pptp_in_call_rqst {
  176. struct pptp_header header; /* header */
  177. u_int16_t call_id; /* unique identifier for tunnel */
  178. u_int16_t call_serial; /* session identifier */
  179. u_int32_t bearer_type; /* bearer capability */
  180. u_int32_t channel_id; /* channel ID */
  181. u_int16_t dialed_len; /* dialed length */
  182. u_int16_t dialing_len; /* dialing length */
  183. u_int8_t dialed_num[64]; /* number that was dialed by the caller */
  184. u_int8_t dialing_num[64]; /* the number from which the call was placed */
  185. u_int8_t subaddress[64]; /* additional dialing information */
  186. };
  187. struct pptp_in_call_rply {
  188. struct pptp_header header; /* header */
  189. u_int16_t call_id; /* unique identifier for the tunnel */
  190. u_int16_t peers_call_id; /* set to rcvd call ID */
  191. u_int8_t result_code; /* result code */
  192. u_int8_t error_code; /* error code */
  193. u_int16_t pckt_recv_size; /* packet recv window size */
  194. u_int16_t pckt_delay; /* packet transmit delay */
  195. u_int16_t reserved1; /* reserved */
  196. };
  197. struct pptp_in_call_connect {
  198. struct pptp_header header; /* header */
  199. u_int16_t peers_call_id; /* set to rcvd call ID */
  200. u_int16_t reserved1; /* reserved */
  201. u_int32_t speed; /* connect speed */
  202. u_int16_t pckt_recv_size; /* packet rcvd window size */
  203. u_int16_t pckt_delay; /* packet transmit delay */
  204. u_int32_t framing_type; /* framing type */
  205. };
  206. struct pptp_call_clr_rqst {
  207. struct pptp_header header; /* header */
  208. u_int16_t call_id; /* call ID assigned by the PNS */
  209. u_int16_t reserved1; /* reserved */
  210. };
  211. struct pptp_call_disconn_ntfy {
  212. struct pptp_header header; /* header */
  213. u_int16_t call_id; /* call ID assigned by the PAC */
  214. u_int8_t result_code; /* result code */
  215. u_int8_t error_code; /* error code */
  216. u_int16_t cause_code; /* additional disconnect info */
  217. u_int16_t reserved1; /* reserved */
  218. u_int8_t call_stats[128]; /* vendor specific call stats */
  219. };
  220. struct pptp_wan_err_ntfy {
  221. struct pptp_header header; /* header */
  222. u_int16_t peers_call_id; /* call ID assigned by PNS */
  223. u_int16_t reserved1; /* reserved */
  224. u_int32_t crc_errors; /* # of PPP frames rcvd with CRC errors */
  225. u_int32_t framing_errors; /* # of improperly framed PPP pckts */
  226. u_int32_t hardware_overruns; /* # of receive buffer overruns */
  227. u_int32_t buff_overruns; /* # of buffer overruns */
  228. u_int32_t timeout_errors; /* # of timeouts */
  229. u_int32_t align_errors; /* # of alignment errors */
  230. };
  231. struct pptp_set_link_info {
  232. struct pptp_header header;
  233. u_int16_t peers_call_id; /* call ID assigned by PAC */
  234. u_int16_t reserved1; /* reserved */
  235. u_int32_t send_accm; /* send ACCM value the client should use */
  236. u_int32_t recv_accm; /* recv ACCM value the client should use */
  237. };
  238. /* GRE and PPP structs */
  239. /* Copied from C. S. Ananian */
  240. #define HDLC_FLAG 0x7E
  241. #define HDLC_ESCAPE 0x7D
  242. #define PPTP_GRE_PROTO 0x880B
  243. #define PPTP_GRE_VER 0x1
  244. #define PPTP_GRE_FLAG_C 0x80
  245. #define PPTP_GRE_FLAG_R 0x40
  246. #define PPTP_GRE_FLAG_K 0x20
  247. #define PPTP_GRE_FLAG_S 0x10
  248. #define PPTP_GRE_FLAG_A 0x80
  249. #define PPTP_GRE_IS_C(f) ((f)&PPTP_GRE_FLAG_C)
  250. #define PPTP_GRE_IS_R(f) ((f)&PPTP_GRE_FLAG_R)
  251. #define PPTP_GRE_IS_K(f) ((f)&PPTP_GRE_FLAG_K)
  252. #define PPTP_GRE_IS_S(f) ((f)&PPTP_GRE_FLAG_S)
  253. #define PPTP_GRE_IS_A(f) ((f)&PPTP_GRE_FLAG_A)
  254. struct pptp_gre_header {
  255. u_int8_t flags; /* bitfield */
  256. u_int8_t ver; /* should be PPTP_GRE_VER (enhanced GRE) */
  257. u_int16_t protocol; /* should be PPTP_GRE_PROTO (ppp-encaps) */
  258. u_int16_t payload_len; /* size of ppp payload, not inc. gre header */
  259. u_int16_t call_id; /* peer's call_id for this session */
  260. u_int32_t seq; /* sequence number. Present if S==1 */
  261. u_int32_t ack; /* seq number of highest packet recieved by */
  262. /* sender in this session */
  263. };
  264. /* For our call ID pairs */
  265. #define PNS_VALUE 0
  266. #define PAC_VALUE 1
  267. #define GET_VALUE(which, where) ((which ## _VALUE) ? ((where) & 0xffff) : ((where) >> 16))
  268. #define NOTE_VALUE(which, where, what) ((which ## _VALUE) \
  269. ? ((where) = ((where) & 0xffff0000) | (what)) \
  270. : ((where) = ((where) & 0xffff) | ((what) << 16)))
  271. #endif /* !_PPTPD_PPTPDEFS_H */