Leaked source code of windows server 2003
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.

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