Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

334 lines
10 KiB

  1. /*****************************************************************************
  2. *
  3. * Copyright (c) 1998-1999 Microsoft Corporation
  4. *
  5. * PROTOCOL.H - PPTP and GRE Protocol data types and constants
  6. *
  7. * Author: Stan Adermann (stana)
  8. *
  9. * Created: 7/23/1998
  10. *
  11. *****************************************************************************/
  12. #ifndef PROTOCOL_H
  13. #define PROTOCOL_H
  14. /* IP ----------------------------------------------------------------------*/
  15. typedef struct {
  16. UCHAR HeaderLength : 4;
  17. UCHAR Version : 4;
  18. UCHAR TypeOfService;
  19. USHORT TotalLength;
  20. USHORT Identification;
  21. USHORT FlagsAndFragmentOffset;
  22. UCHAR TimeToLive;
  23. UCHAR Protocol;
  24. USHORT Checksum;
  25. ULONG SourceIp;
  26. ULONG DestinationIp;
  27. } IP4_HEADER, *PIP4_HEADER;
  28. typedef struct {
  29. USHORT SourcePort;
  30. USHORT DestinationPort;
  31. USHORT Length;
  32. USHORT Checksum;
  33. } UDP_HEADER, *PUDP_HEADER;
  34. /* GRE ---------------------------------------------------------------------*/
  35. typedef struct {
  36. UCHAR RecursionControl : 3;
  37. UCHAR StrictSourceRoutePresent : 1;
  38. UCHAR SequenceNumberPresent : 1;
  39. UCHAR KeyPresent : 1;
  40. UCHAR RoutingPresent : 1;
  41. UCHAR ChecksumPresent : 1;
  42. UCHAR Version : 3;
  43. UCHAR Flags : 4;
  44. UCHAR AckSequenceNumberPresent : 1;
  45. USHORT ProtocolType;
  46. #define GRE_PROTOCOL_TYPE 0x880B
  47. #define GRE_PROTOCOL_TYPE_NS 0x0B88
  48. USHORT KeyLength;
  49. USHORT KeyCallId;
  50. } GRE_HEADER, *PGRE_HEADER;
  51. #define GreSequence(g) (*(PULONG)(((PUCHAR)(g)) + sizeof(GRE_HEADER)))
  52. #define GreAckSequence(g) \
  53. ((g)->SequenceNumberPresent ? \
  54. (*(PULONG)(((PUCHAR)(g)) + sizeof(GRE_HEADER) + sizeof(ULONG))) : \
  55. GreSequence(g))
  56. /* PPTP --------------------------------------------------------------------*/
  57. #define PPTP_TCP_PORT 1723
  58. #define PPTP_IP_GRE_PROTOCOL 47
  59. #define PPTP_PROTOCOL_VERSION_1_00 0x100
  60. #define PPTP_PROTOCOL_SECURE_VERSION 0x200
  61. #define PPTP_MAGIC_COOKIE 0x1A2B3C4D
  62. #define INADDR_NONE 0xffffffff
  63. #define MAX_HOSTNAME_LENGTH 64
  64. #define MAX_VENDOR_LENGTH 64
  65. #define MAX_PHONE_NUMBER_LENGTH 64
  66. #define MAX_SUBADDRESS_LENGTH 64
  67. #define MAX_CALL_STATS_LENGTH 128
  68. #define PPTP_MAX_PACKET_SIZE 1532
  69. #define PPTP_MAX_LOOKAHEAD PPTP_MAX_PACKET_SIZE
  70. #define PPTP_MAX_TRANSMIT 32
  71. #define PPTP_MAX_RECEIVE_SIZE (1614+20+12+8) // To allow for PPP padding, etc.
  72. #define PPTP_RECV_WINDOW 64
  73. #define PPTP_STATUS_SUCCESS 0
  74. #define PPTP_STATUS_NOT_CONNECTED 1
  75. #define PPTP_STATUS_BAD_FORMAT 2
  76. #define PPTP_STATUS_BAD_VALUE 3
  77. #define PPTP_STATUS_INSUFFICIENT_RESOURCES 4
  78. #define PPTP_STATUS_BAD_CALL_ID 5
  79. #define PPTP_STATUS_PAC_ERROR 6
  80. typedef enum {
  81. PPTP_CONTROL_MESSAGE = 1
  82. } PPTP_PACKET_TYPE;
  83. typedef enum {
  84. CONTROL_START_REQUEST = 1,
  85. CONTROL_START_REPLY,
  86. CONTROL_STOP_REQUEST,
  87. CONTROL_STOP_REPLY,
  88. CONTROL_ECHO_REQUEST,
  89. CONTROL_ECHO_REPLY,
  90. CALL_OUT_REQUEST,
  91. CALL_OUT_REPLY,
  92. CALL_IN_REQUEST,
  93. CALL_IN_REPLY,
  94. CALL_IN_CONNECTED,
  95. CALL_CLEAR_REQUEST,
  96. CALL_DISCONNECT_NOTIFY,
  97. WAN_ERROR_NOTIFY,
  98. SET_LINK_INFO,
  99. NUM_MESSAGE_TYPES
  100. } PPTP_MESSAGE_TYPE;
  101. typedef struct {
  102. USHORT Length;
  103. USHORT PacketType;
  104. ULONG Cookie;
  105. USHORT MessageType;
  106. USHORT Reserved0;
  107. } PPTP_HEADER, *PPPTP_HEADER;
  108. typedef struct {
  109. PPTP_HEADER;
  110. USHORT Version;
  111. union {
  112. USHORT Reserved1;
  113. struct {
  114. UCHAR ResultCode;
  115. #define RESULT_CONTROL_START_SUCCESS 1
  116. #define RESULT_CONTROL_START_ERROR 2
  117. #define RESULT_CONTROL_START_ALREADY_CONNECTED 3
  118. #define RESULT_CONTROL_START_UNAUTHORIZED 4
  119. #define RESULT_CONTROL_START_VERSION_NOT_SUPPORTED 5
  120. UCHAR ErrorCode;
  121. };
  122. };
  123. ULONG FramingCapabilities;
  124. #define FRAMING_ASYNC BIT(0)
  125. #define FRAMING_SYNC BIT(1)
  126. ULONG BearerCapabilities;
  127. #define BEARER_ANALOG BIT(0)
  128. #define BEARER_DIGITAL BIT(1)
  129. USHORT MaxChannels;
  130. USHORT FirmwareRevision;
  131. UCHAR HostName[MAX_HOSTNAME_LENGTH];
  132. UCHAR Vendor[MAX_VENDOR_LENGTH];
  133. } PPTP_CONTROL_START_PACKET, *PPPTP_CONTROL_START_PACKET;
  134. typedef struct {
  135. PPTP_HEADER;
  136. union {
  137. struct {
  138. UCHAR Reason;
  139. #define CONTROL_STOP_GENERAL 1
  140. #define CONTROL_STOP_VERSION 2
  141. #define CONTROL_STOP_LOCAL 3
  142. UCHAR Reserved1;
  143. };
  144. struct {
  145. UCHAR ResultCode;
  146. #define RESULT_CONTROL_STOP_SUCCESS 1
  147. #define RESULT_CONTROL_STOP_ERROR 2
  148. UCHAR ErrorCode;
  149. };
  150. };
  151. USHORT Reserved2;
  152. } PPTP_CONTROL_STOP_PACKET, *PPPTP_CONTROL_STOP_PACKET;
  153. typedef struct {
  154. PPTP_HEADER;
  155. ULONG Identifier;
  156. } PPTP_CONTROL_ECHO_REQUEST_PACKET, *PPPTP_CONTROL_ECHO_REQUEST_PACKET;
  157. typedef struct {
  158. PPTP_HEADER;
  159. ULONG Identifier;
  160. UCHAR ResultCode;
  161. #define RESULT_CONTROL_ECHO_SUCCESS 1
  162. #define RESULT_CONTROL_ECHO_FAILURE 2
  163. UCHAR ErrorCode;
  164. USHORT Reserved1;
  165. } PPTP_CONTROL_ECHO_REPLY_PACKET, *PPPTP_CONTROL_ECHO_REPLY_PACKET;
  166. typedef struct {
  167. PPTP_HEADER;
  168. USHORT CallId;
  169. USHORT SerialNumber;
  170. ULONG MinimumBPS;
  171. ULONG MaximumBPS;
  172. ULONG BearerType;
  173. ULONG FramingType;
  174. USHORT RecvWindowSize;
  175. USHORT ProcessingDelay;
  176. USHORT PhoneNumberLength;
  177. USHORT Reserved1;
  178. UCHAR PhoneNumber[MAX_PHONE_NUMBER_LENGTH];
  179. UCHAR Subaddress[MAX_SUBADDRESS_LENGTH];
  180. } PPTP_CALL_OUT_REQUEST_PACKET, *PPPTP_CALL_OUT_REQUEST_PACKET;
  181. typedef struct {
  182. PPTP_HEADER;
  183. USHORT CallId;
  184. USHORT PeerCallId;
  185. UCHAR ResultCode;
  186. #define RESULT_CALL_OUT_CONNECTED 1
  187. #define RESULT_CALL_OUT_ERROR 2
  188. #define RESULT_CALL_OUT_NO_CARRIER 3
  189. #define RESULT_CALL_OUT_BUSY 4
  190. #define RESULT_CALL_OUT_NO_DIAL_TONE 5
  191. #define RESULT_CALL_OUT_TIMEOUT 6
  192. #define RESULT_CALL_OUT_REFUSED 7
  193. UCHAR ErrorCode;
  194. USHORT CauseCode;
  195. ULONG ConnectSpeed;
  196. USHORT RecvWindowSize;
  197. USHORT ProcessingDelay;
  198. ULONG PhysicalChannelId;
  199. } PPTP_CALL_OUT_REPLY_PACKET, *PPPTP_CALL_OUT_REPLY_PACKET;
  200. typedef struct {
  201. PPTP_HEADER;
  202. USHORT CallId;
  203. USHORT SerialNumber;
  204. ULONG BearerType;
  205. ULONG PhysicalChannelId;
  206. USHORT DialedNumberLength;
  207. USHORT DialingNumberLength;
  208. UCHAR DialedNumber[MAX_PHONE_NUMBER_LENGTH];
  209. UCHAR DialingNumber[MAX_PHONE_NUMBER_LENGTH];
  210. UCHAR Subaddress[MAX_SUBADDRESS_LENGTH];
  211. } PPTP_CALL_IN_REQUEST_PACKET, *PPPTP_CALL_IN_REQUEST_PACKET;
  212. typedef struct {
  213. PPTP_HEADER;
  214. USHORT CallId;
  215. USHORT PeerCallId;
  216. UCHAR ResultCode;
  217. #define RESULT_CALL_IN_CONNECTED 1
  218. #define RESULT_CALL_IN_ERROR 2
  219. #define RESULT_CALL_IN_REFUSED 3
  220. UCHAR ErrorCode;
  221. USHORT RecvWindowSize;
  222. USHORT ProcessingDelay;
  223. USHORT Reserved1;
  224. } PPTP_CALL_IN_REPLY_PACKET, *PPPTP_CALL_IN_REPLY_PACKET;
  225. typedef struct {
  226. PPTP_HEADER;
  227. USHORT PeerCallId;
  228. USHORT Reserved1;
  229. ULONG ConnectSpeed;
  230. USHORT RecvWindowSize;
  231. USHORT ProcessingDelay;
  232. ULONG FramingType;
  233. } PPTP_CALL_IN_CONNECT_PACKET, *PPPTP_CALL_IN_CONNECT_PACKET;
  234. typedef struct {
  235. PPTP_HEADER;
  236. USHORT CallId;
  237. USHORT Reserved1;
  238. } PPTP_CALL_CLEAR_REQUEST_PACKET, *PPPTP_CALL_CLEAR_REQUEST_PACKET;
  239. typedef struct {
  240. PPTP_HEADER;
  241. USHORT CallId;
  242. UCHAR ResultCode;
  243. #define RESULT_CALL_DISCONNECT_LOST_CARRIER 1
  244. #define RESULT_CALL_DISCONNECT_ERROR 2
  245. #define RESULT_CALL_DISCONNECT_ADMIN 3
  246. #define RESULT_CALL_DISCONNECT_REQUEST 4
  247. UCHAR ErrorCode;
  248. USHORT CauseCode;
  249. USHORT Reserved1;
  250. UCHAR CallStatistics[MAX_CALL_STATS_LENGTH];
  251. } PPTP_CALL_DISCONNECT_NOTIFY_PACKET, *PPPTP_CALL_DISCONNECT_NOTIFY_PACKET;
  252. typedef struct {
  253. PPTP_HEADER;
  254. USHORT PeerCallId;
  255. USHORT Reserved1;
  256. ULONG CrcErrors;
  257. ULONG FramingErrors;
  258. ULONG HardwareOverruns;
  259. ULONG BufferOverruns;
  260. ULONG TimeoutErrors;
  261. ULONG AlignmentErrors;
  262. } PPTP_WAN_ERROR_NOTIFY_PACKET, *PPPTP_WAN_ERROR_NOTIFY_PACKET;
  263. typedef struct {
  264. PPTP_HEADER;
  265. USHORT PeerCallId;
  266. USHORT Reserved1;
  267. ULONG SendAccm;
  268. ULONG RecvAccm;
  269. } PPTP_SET_LINK_INFO_PACKET, *PPPTP_SET_LINK_INFO_PACKET;
  270. #define MAX_CONTROL_PACKET_LENGTH sizeof(PPTP_CALL_IN_REQUEST_PACKET)
  271. #endif //PROTOCOL_H