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.

347 lines
7.8 KiB

  1. #ifndef __RSIPDEFS_H_FILE
  2. #define __RSIPDEFS_H_FILE
  3. //**********************************************************************
  4. // Constant definitions
  5. //**********************************************************************
  6. /*
  7. * Whats implemented:
  8. * as_req_rsap(localaddr=0,localports=4-a:b:c:d,
  9. * remaddr=0,remports=0)
  10. * as_res_rsap(localaddr=24.128.34.21,localports=4-A:B:C:D,
  11. * remaddr=0,remports=0)
  12. * where a,b,c,d are listening ports on the client (192.168.0.2)
  13. * and A,B,C,D are the associated ports visible
  14. * on the external IP address 24.128.34.21.
  15. *
  16. * Operation: When packet from the outside is destined for
  17. * 24.128.34.21:A is recieved, the ip->dst and udp->dst
  18. * (or tcp->dst) fields are changed to 192.168.0.2:a
  19. * and then sent along - unencapsulated.
  20. * When a packet is sent out from the client, the
  21. * app (e.g. dplay) uses 192.168.0.2:a as in the
  22. * IP+UDP/TCP header but uses 24.128.34.21:A for
  23. * any information encoded in the data portion of
  24. * the packet.
  25. */
  26. #define RSIP_VERSION 1
  27. #define RSIP_HOST_PORT 2234
  28. // How often we scan the list for liscence renewals
  29. #define RSIP_RENEW_TEST_INTERVAL 60000
  30. /* start RSIP retry timer at 12.5 ms */
  31. #define RSIP_tuRETRY_START 12500
  32. /* max starting retry is 100 ms */
  33. #define RSIP_tuRETRY_MAX 100000
  34. #define RESP_BUF_SIZE 100
  35. enum { /* TUNNELS */
  36. TUNNEL_RESERVED = 0,
  37. TUNNEL_IP_IP = 1,
  38. TUNNEL_GRE = 2, /* PPTP */
  39. TUNNEL_L2TP = 3,
  40. /*TUNNEL_NONE = 4, /* THIS IS NOT PART OR THE SPEC */
  41. };
  42. enum { /* METHODS */
  43. METHOD_RESERVED = 0,
  44. RSA_IP = 1,
  45. RSAP_IP = 2,
  46. RSA_IP_IPSEC = 3,
  47. RSAP_IP_IPSEC = 4,
  48. };
  49. enum { /* FLOWS */
  50. FLOW_RESERVED = 0,
  51. FLOW_MACRO = 1,
  52. FLOW_MICRO = 2,
  53. FLOW_NONE = 3,
  54. };
  55. enum { /* ERROR CODES */
  56. UNKNOWNERROR = 1,
  57. BADBINDID = 2,
  58. BADCLIENTID = 3,
  59. MISSINGPARAM = 4,
  60. DUPLICATEPARAM = 5,
  61. ILLEGALPARAM = 6,
  62. ILLEGALMESSAGE = 7,
  63. REGISTERFIRST = 8,
  64. BADMESSAGEID = 9,
  65. ALREADYREGISTERED = 10,
  66. ALREADYUNREGISTERED = 11,
  67. BADTUNNELTYPE = 12,
  68. ADDRUNAVAILABLE = 13,
  69. PORTUNAVAILABLE = 14,
  70. };
  71. enum { /* MESSAGES */
  72. RSIP_ERROR_RESPONSE = 1,
  73. RSIP_REGISTER_REQUEST = 2,
  74. RSIP_REGISTER_RESPONSE = 3,
  75. RSIP_DEREGISTER_REQUEST = 4,
  76. RSIP_DEREGISTER_RESPONSE = 5,
  77. RSIP_ASSIGN_REQUEST_RSA_IP = 6,
  78. RSIP_ASSIGN_RESPONSE_RSA_IP = 7,
  79. RSIP_ASSIGN_REQUEST_RSAP_IP = 8,
  80. RSIP_ASSIGN_RESPONSE_RSAP_IP = 9,
  81. RSIP_EXTEND_REQUEST = 10,
  82. RSIP_EXTEND_RESPONSE = 11,
  83. RSIP_FREE_REQUEST = 12,
  84. RSIP_FREE_RESPONSE = 13,
  85. RSIP_QUERY_REQUEST = 14,
  86. RSIP_QUERY_RESPONSE = 15,
  87. RSIP_DEALLOCATE = 16,
  88. RSIP_OK = 17,
  89. RSIP_LISTEN_REQUEST = 18,
  90. RSIP_LISTEN_RESPONSE = 19,
  91. };
  92. enum { /* PARAMETERS */
  93. RSIP_ADDRESS_CODE = 1,
  94. RSIP_PORTS_CODE = 2,
  95. RSIP_LEASE_CODE = 3,
  96. RSIP_CLIENTID_CODE = 4,
  97. RSIP_BINDID_CODE = 5,
  98. RSIP_MESSAGEID_CODE = 6,
  99. RSIP_TUNNELTYPE_CODE = 7,
  100. RSIP_RSIPMETHOD_CODE = 8,
  101. RSIP_ERROR_CODE = 9,
  102. RSIP_FLOWPOLICY_CODE = 10,
  103. RSIP_VENDOR_CODE = 11,
  104. };
  105. /*
  106. * MS specific Vendor Codes
  107. */
  108. #define RSIP_MS_VENDOR_ID 734
  109. enum {
  110. RSIP_NO_TUNNEL = 1,
  111. RSIP_TCP_PORT = 2,
  112. RSIP_UDP_PORT = 3,
  113. RSIP_SHARED_UDP_LISTENER = 4,
  114. RSIP_QUERY_MAPPING = 5,
  115. };
  116. #define ANY_PORT 0
  117. //**********************************************************************
  118. // Macro definitions
  119. //**********************************************************************
  120. //**********************************************************************
  121. // Structure definitions
  122. //**********************************************************************
  123. #pragma pack(push,1)
  124. typedef struct _RSIP_MSG_HDR {
  125. CHAR version;
  126. CHAR msgtype;
  127. } RSIP_MSG_HDR, *PRSIP_MSG_HDR;
  128. typedef struct _RSIP_PARAM {
  129. CHAR code;
  130. WORD len;
  131. } RSIP_PARAM, *PRSIP_PARAM;
  132. typedef struct _RSIP_MESSAGEID{
  133. CHAR code;
  134. WORD len;
  135. DWORD msgid;
  136. } RSIP_MESSAGEID, *PRSIP_MESSAGEID;
  137. typedef struct _RSIP_CLIENTID {
  138. CHAR code;
  139. WORD len;
  140. DWORD clientid;
  141. } RSIP_CLIENTID, *PRSIP_CLIENTID;
  142. typedef struct _RSIP_ADDRESS {
  143. CHAR code;
  144. WORD len;
  145. CHAR version; // 1==v4
  146. DWORD addr;
  147. } RSIP_ADDRESS, *PRSIP_ADDRESS;
  148. typedef struct _RSIP_PORT {
  149. CHAR code;
  150. WORD len;
  151. CHAR nports; // we only do 1 port at a time
  152. WORD port;
  153. } RSIP_PORT, *PRSIP_PORT;
  154. typedef struct _RSIP_LEASE {
  155. CHAR code;
  156. WORD len;
  157. DWORD leasetime;
  158. } RSIP_LEASE, *PRSIP_LEASE;
  159. typedef struct _RSIP_BINDID {
  160. CHAR code;
  161. WORD len;
  162. DWORD bindid;
  163. } RSIP_BINDID, *PRSIP_BINDID;
  164. typedef struct _RSIP_TUNNEL {
  165. CHAR code;
  166. WORD len;
  167. CHAR tunneltype;
  168. } RSIP_TUNNEL, *PRSIP_TUNNEL;
  169. // Vendor Specific structures
  170. typedef struct _RSIP_MSVENDOR_CODE {
  171. CHAR code;
  172. WORD len;
  173. WORD vendorid;
  174. WORD option;
  175. }RSIP_MSVENDOR_CODE, *PRSIP_MSVENDOR_CODE;
  176. //
  177. // RSIP Message templates
  178. //
  179. typedef struct _MSG_RSIP_REGISTER {
  180. CHAR version;
  181. CHAR command;
  182. RSIP_MESSAGEID msgid;
  183. } MSG_RSIP_REGISTER, *PMSG_RSIP_REGISTER;
  184. typedef struct _MSG_RSIP_DEREGISTER {
  185. CHAR version;
  186. CHAR command;
  187. RSIP_CLIENTID clientid;
  188. RSIP_MESSAGEID msgid;
  189. } MSG_RSIP_DEREGISTER, *PMSG_RSIP_DEREGISTER;
  190. typedef struct _MSG_RSIP_ASSIGN_PORT {
  191. CHAR version;
  192. CHAR command;
  193. RSIP_CLIENTID clientid;
  194. RSIP_ADDRESS laddress; // local
  195. RSIP_PORT lport;
  196. RSIP_ADDRESS raddress; // remote
  197. RSIP_PORT rport;
  198. RSIP_LEASE lease;
  199. RSIP_TUNNEL tunnel;
  200. RSIP_MESSAGEID msgid;
  201. RSIP_MSVENDOR_CODE porttype;
  202. RSIP_MSVENDOR_CODE tunneloptions;
  203. } MSG_RSIP_ASSIGN_PORT, *PMSG_RSIP_ASSIGN_PORT;
  204. typedef struct _MSG_RSIP_LISTEN_PORT {
  205. CHAR version;
  206. CHAR command;
  207. RSIP_CLIENTID clientid;
  208. RSIP_ADDRESS laddress; // local
  209. RSIP_PORT lport;
  210. RSIP_ADDRESS raddress; // remote
  211. RSIP_PORT rport;
  212. RSIP_LEASE lease;
  213. RSIP_TUNNEL tunnel;
  214. RSIP_MESSAGEID msgid;
  215. RSIP_MSVENDOR_CODE porttype;
  216. RSIP_MSVENDOR_CODE tunneloptions;
  217. RSIP_MSVENDOR_CODE listentype;
  218. } MSG_RSIP_LISTEN_PORT, *PMSG_RSIP_LISTEN_PORT;
  219. typedef struct _MSG_RSIP_EXTEND_PORT {
  220. CHAR version;
  221. CHAR command;
  222. RSIP_CLIENTID clientid;
  223. RSIP_BINDID bindid;
  224. RSIP_LEASE lease;
  225. RSIP_MESSAGEID msgid;
  226. } MSG_RSIP_EXTEND_PORT, *PMSG_RSIP_EXTEND_PORT;
  227. typedef struct _MSG_RSIP_FREE_PORT {
  228. CHAR version;
  229. CHAR command;
  230. RSIP_CLIENTID clientid;
  231. RSIP_BINDID bindid;
  232. RSIP_MESSAGEID msgid;
  233. } MSG_RSIP_FREE_PORT, *PMSG_RSIP_FREE_PORT;
  234. typedef struct _MSG_RSIP_QUERY {
  235. CHAR version;
  236. CHAR command;
  237. RSIP_CLIENTID clientid;
  238. RSIP_ADDRESS address;
  239. RSIP_PORT port;
  240. RSIP_MSVENDOR_CODE porttype;
  241. RSIP_MSVENDOR_CODE querytype;
  242. RSIP_MESSAGEID msgid;
  243. } MSG_RSIP_QUERY, *PMSG_RSIP_QUERY;
  244. typedef struct _RSIP_RESPONSE_INFO {
  245. DWORD clientid;
  246. DWORD messageid;
  247. DWORD bindid;
  248. DWORD leasetime;
  249. CHAR version;
  250. CHAR msgtype;
  251. CHAR tunneltype;
  252. CHAR rsipmethod;
  253. DWORD lAddressV4;
  254. WORD lPort;
  255. DWORD rAddressV4;
  256. WORD rPort;
  257. WORD error;
  258. } RSIP_RESPONSE_INFO, *PRSIP_RESPONSE_INFO;
  259. #pragma pack(pop)
  260. typedef struct _RSIP_LEASE_RECORD {
  261. struct _RSIP_LEASE_RECORD * pNext;
  262. DWORD dwRefCount;
  263. BOOL ftcp_udp;
  264. DWORD tExpiry;
  265. DWORD bindid;
  266. DWORD addrV4; // remote IP address
  267. SHORT rport; // remote port
  268. SHORT port; // local port
  269. } RSIP_LEASE_RECORD, *PRSIP_LEASE_RECORD;
  270. // Cache of queried address mappings so we don't
  271. // need to requery the mappings over and over
  272. typedef struct _ADDR_ENTRY {
  273. struct _ADDR_ENTRY *pNext;
  274. BOOL ftcp_udp;
  275. DWORD tExpiry;
  276. DWORD addr;
  277. DWORD raddr;
  278. WORD port;
  279. WORD rport;
  280. } ADDR_ENTRY, *PADDR_ENTRY;
  281. //**********************************************************************
  282. // Variable definitions
  283. //**********************************************************************
  284. #if 0
  285. static const char *rsip_error_strs[]={
  286. "RESERVED",
  287. "UNKNOWNERROR",
  288. "BADBINDID",
  289. "BADCLIENTID",
  290. "MISSINGPARAM",
  291. "DUPLICATEPARAM",
  292. "ILLEGALPARAM",
  293. "ILLEGALMESSAGE",
  294. "REGISTERFIRST",
  295. "BADMESSAGEID",
  296. "ALREADYREGISTERED",
  297. "ALREADYUNREGISTERED",
  298. "BADTUNNELTYPE",
  299. "ADDRUNAVAILABLE",
  300. "PORTUNAVAILABLE",
  301. (char *)0
  302. };
  303. #endif
  304. #endif // __RSIPDEFS_H_FILE