1
0

pptpdefs.h 13 KB

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