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.

504 lines
14 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. marspkt.h
  5. Abstract:
  6. Definitions for MARS packets.
  7. Revision History:
  8. Who When What
  9. -------- -------- ----------------------------------------------
  10. arvindm 12-12-96 Created
  11. Notes:
  12. --*/
  13. #ifndef _MARS_PKT__H
  14. #define _MARS_PKT__H
  15. #include "arppkt.h"
  16. #include <pshpack1.h>
  17. //
  18. // LLC and OUI values for all (control and data) Multicast packets.
  19. //
  20. #define MC_LLC_SNAP_LLC0 ((UCHAR)0xAA)
  21. #define MC_LLC_SNAP_LLC1 ((UCHAR)0xAA)
  22. #define MC_LLC_SNAP_LLC2 ((UCHAR)0x03)
  23. #define MC_LLC_SNAP_OUI0 ((UCHAR)0x00)
  24. #define MC_LLC_SNAP_OUI1 ((UCHAR)0x00)
  25. #define MC_LLC_SNAP_OUI2 ((UCHAR)0x5E)
  26. //
  27. // "EtherType" (i.e. PID) values for MARS control and multicast data
  28. //
  29. #define AA_PKT_ETHERTYPE_MARS_CONTROL ((USHORT)0x003)
  30. #define AA_PKT_ETHERTYPE_MARS_CONTROL_NS ((USHORT)0x0300)
  31. #define AA_PKT_ETHERTYPE_MC_TYPE1 ((USHORT)0x001) // Type #1 data
  32. #define AA_PKT_ETHERTYPE_MC_TYPE1_NS ((USHORT)0x0100) // Type #1 data (Net format)
  33. #define AA_PKT_ETHERTYPE_MC_TYPE2 ((USHORT)0x004) // Type #2 data
  34. //
  35. // Address Family value for MARS control packets.
  36. //
  37. #define AA_MC_MARS_HEADER_AFN ((USHORT)0x000F)
  38. #define AA_MC_MARS_HEADER_AFN_NS ((USHORT)0x0F00)
  39. //
  40. // Common preamble for all packets: control, type #1 data and type #2 data.
  41. // This is the same as for ATMARP packets. The OUI bytes dictate whether
  42. // a packet is destined to a Unicast IP/ATM entity or to the Multicast IP/ATM
  43. // entity.
  44. //
  45. typedef AA_PKT_LLC_SNAP_HEADER AA_MC_MARS_PKT_HEADER;
  46. typedef AA_MC_MARS_PKT_HEADER UNALIGNED *PAA_MC_MARS_PKT_HEADER;
  47. //
  48. // Short form encapsulation for Type #1 Multicast data packets.
  49. //
  50. typedef struct _AA_MC_PKT_TYPE1_SHORT_HEADER
  51. {
  52. UCHAR LLC[3];
  53. UCHAR OUI[3];
  54. USHORT PID; // 0x001
  55. USHORT cmi; // Cluster Member ID
  56. USHORT pro; // Protocol type
  57. } AA_MC_PKT_TYPE1_SHORT_HEADER;
  58. typedef AA_MC_PKT_TYPE1_SHORT_HEADER UNALIGNED *PAA_MC_PKT_TYPE1_SHORT_HEADER;
  59. //
  60. // Long form encapsulation for Type #1 Multicast data packets.
  61. //
  62. typedef struct _AA_MC_PKT_TYPE1_LONG_HEADER
  63. {
  64. UCHAR LLC[3];
  65. UCHAR OUI[3];
  66. USHORT PID; // 0x001
  67. USHORT cmi; // Cluster Member ID
  68. USHORT pro; // Protocol type
  69. UCHAR snap[5];
  70. UCHAR padding[3];
  71. } AA_MC_PKT_TYPE1_LONG_HEADER;
  72. typedef AA_MC_PKT_TYPE1_LONG_HEADER UNALIGNED *PAA_MC_PKT_TYPE1_LONG_HEADER;
  73. //
  74. // Short form encapsulation for Type #2 Multicast data packets.
  75. //
  76. typedef struct _AA_MC_PKT_TYPE2_SHORT_HEADER
  77. {
  78. UCHAR LLC[3];
  79. UCHAR OUI[3];
  80. USHORT PID; // 0x004
  81. UCHAR sourceID[8]; // Ignored
  82. USHORT pro; // Protocol type
  83. UCHAR padding[2];
  84. } AA_MC_PKT_TYPE2_SHORT_HEADER;
  85. typedef AA_MC_PKT_TYPE2_SHORT_HEADER UNALIGNED *PAA_MC_PKT_TYPE2_SHORT_HEADER;
  86. //
  87. // Long form encapsulation for Type #2 Multicast data packets.
  88. //
  89. typedef struct _AA_MC_PKT_TYPE2_LONG_HEADER
  90. {
  91. UCHAR LLC[3];
  92. UCHAR OUI[3];
  93. USHORT PID; // 0x004
  94. UCHAR sourceID[8]; // Ignored
  95. USHORT pro; // Protocol type
  96. UCHAR snap[5];
  97. UCHAR padding[1];
  98. } AA_MC_PKT_TYPE2_LONG_HEADER;
  99. typedef AA_MC_PKT_TYPE2_LONG_HEADER UNALIGNED *PAA_MC_PKT_TYPE2_LONG_HEADER;
  100. //
  101. // The Fixed header part of every MARS control packet.
  102. //
  103. typedef struct _AA_MARS_PKT_FIXED_HEADER
  104. {
  105. UCHAR LLC[3];
  106. UCHAR OUI[3];
  107. USHORT PID; // 0x003
  108. USHORT afn; // Address Family (0x000F)
  109. UCHAR pro[7]; // Protocol Identification
  110. UCHAR hdrrsv[3]; // Reserved.
  111. USHORT chksum; // Checksum across entire MARS message
  112. USHORT extoff; // Extensions offset
  113. USHORT op; // Operation code
  114. UCHAR shtl; // Type & Length of source ATM number
  115. UCHAR sstl; // Type & Length of source ATM subaddress
  116. } AA_MARS_PKT_FIXED_HEADER;
  117. typedef AA_MARS_PKT_FIXED_HEADER UNALIGNED *PAA_MARS_PKT_FIXED_HEADER;
  118. //
  119. // MARS control packet types
  120. //
  121. #define AA_MARS_OP_TYPE_REQUEST ((USHORT)1)
  122. #define AA_MARS_OP_TYPE_MULTI ((USHORT)2)
  123. #define AA_MARS_OP_TYPE_JOIN ((USHORT)4)
  124. #define AA_MARS_OP_TYPE_LEAVE ((USHORT)5)
  125. #define AA_MARS_OP_TYPE_NAK ((USHORT)6)
  126. #define AA_MARS_OP_TYPE_GROUPLIST_REQUEST ((USHORT)10)
  127. #define AA_MARS_OP_TYPE_GROUPLIST_REPLY ((USHORT)11)
  128. #define AA_MARS_OP_TYPE_REDIRECT_MAP ((USHORT)12)
  129. #define AA_MARS_OP_TYPE_MIGRATE ((USHORT)13)
  130. //
  131. // Format of MARS JOIN and LEAVE message headers.
  132. //
  133. typedef struct _AA_MARS_JOIN_LEAVE_HEADER
  134. {
  135. UCHAR LLC[3];
  136. UCHAR OUI[3];
  137. USHORT PID; // 0x003
  138. USHORT afn; // Address Family (0x000F)
  139. UCHAR pro[7]; // Protocol Identification
  140. UCHAR hdrrsv[3]; // Reserved.
  141. USHORT chksum; // Checksum across entire MARS message
  142. USHORT extoff; // Extensions offset
  143. USHORT op; // Operation code (JOIN/LEAVE)
  144. UCHAR shtl; // Type & Length of source ATM number
  145. UCHAR sstl; // Type & Length of source ATM subaddress
  146. UCHAR spln; // Source protocol address length
  147. UCHAR tpln; // Length of group address
  148. USHORT pnum; // Number of group address pairs
  149. USHORT flags; // LAYER3GRP, COPY and REGISTER bits
  150. USHORT cmi; // Cluster Member ID
  151. ULONG msn; // MARS Sequence Number
  152. } AA_MARS_JOIN_LEAVE_HEADER;
  153. typedef AA_MARS_JOIN_LEAVE_HEADER UNALIGNED *PAA_MARS_JOIN_LEAVE_HEADER;
  154. //
  155. // Bit definitions for flags in JOIN/LEAVE messages
  156. //
  157. #define AA_MARS_JL_FLAG_LAYER3_GROUP NET_SHORT((USHORT)0x8000)
  158. #define AA_MARS_JL_FLAG_COPY NET_SHORT((USHORT)0x4000)
  159. #define AA_MARS_JL_FLAG_REGISTER NET_SHORT((USHORT)0x2000)
  160. #define AA_MARS_JL_FLAG_PUNCHED NET_SHORT((USHORT)0x1000)
  161. #define AA_MARS_JL_FLAG_SEQUENCE_MASK NET_SHORT((USHORT)0x00ff)
  162. //
  163. // Format of MARS REQUEST and MARS NAK message header.
  164. //
  165. typedef struct _AA_MARS_REQ_NAK_HEADER
  166. {
  167. UCHAR LLC[3];
  168. UCHAR OUI[3];
  169. USHORT PID; // 0x003
  170. USHORT afn; // Address Family (0x000F)
  171. UCHAR pro[7]; // Protocol Identification
  172. UCHAR hdrrsv[3]; // Reserved.
  173. USHORT chksum; // Checksum across entire MARS message
  174. USHORT extoff; // Extensions offset
  175. USHORT op; // Operation code (REQUEST/NAK)
  176. UCHAR shtl; // Type & Length of source ATM number
  177. UCHAR sstl; // Type & Length of source ATM subaddress
  178. UCHAR spln; // Source protocol address length
  179. UCHAR thtl; // Type & Length of target ATM number
  180. UCHAR tstl; // Type & Length of target ATM subaddress
  181. UCHAR tpln; // Length of target group address
  182. UCHAR pad[8];
  183. } AA_MARS_REQ_NAK_HEADER;
  184. typedef AA_MARS_REQ_NAK_HEADER UNALIGNED *PAA_MARS_REQ_NAK_HEADER;
  185. //
  186. // Format of MARS MULTI message header.
  187. //
  188. typedef struct _AA_MARS_MULTI_HEADER
  189. {
  190. UCHAR LLC[3];
  191. UCHAR OUI[3];
  192. USHORT PID; // 0x003
  193. USHORT afn; // Address Family (0x000F)
  194. UCHAR pro[7]; // Protocol Identification
  195. UCHAR hdrrsv[3]; // Reserved.
  196. USHORT chksum; // Checksum across entire MARS message
  197. USHORT extoff; // Extensions offset
  198. USHORT op; // Operation code (MULTI)
  199. UCHAR shtl; // Type & Length of source ATM number
  200. UCHAR sstl; // Type & Length of source ATM subaddress
  201. UCHAR spln; // Source protocol address length
  202. UCHAR thtl; // Type & Length of target ATM number
  203. UCHAR tstl; // Type & Length of target ATM subaddress
  204. UCHAR tpln; // Length of target group address
  205. USHORT tnum; // Number of target ATM addresses returned
  206. USHORT seqxy; // Boolean X and sequence number Y
  207. ULONG msn; // MARS Sequence Number
  208. } AA_MARS_MULTI_HEADER;
  209. typedef AA_MARS_MULTI_HEADER UNALIGNED *PAA_MARS_MULTI_HEADER;
  210. //
  211. // Format of MARS MIGRATE message header.
  212. //
  213. typedef struct _AA_MARS_MIGRATE_HEADER
  214. {
  215. UCHAR LLC[3];
  216. UCHAR OUI[3];
  217. USHORT PID; // 0x003
  218. USHORT afn; // Address Family (0x000F)
  219. UCHAR pro[7]; // Protocol Identification
  220. UCHAR hdrrsv[3]; // Reserved.
  221. USHORT chksum; // Checksum across entire MARS message
  222. USHORT extoff; // Extensions offset
  223. USHORT op; // Operation code (MIGRATE)
  224. UCHAR shtl; // Type & Length of source ATM number
  225. UCHAR sstl; // Type & Length of source ATM subaddress
  226. UCHAR spln; // Source protocol address length
  227. UCHAR thtl; // Type & Length of target ATM number
  228. UCHAR tstl; // Type & Length of target ATM subaddress
  229. UCHAR tpln; // Length of target group address
  230. USHORT tnum; // Number of Target ATM addresses returned
  231. USHORT resv; // Reserved
  232. ULONG msn; // MARS Sequence Number
  233. } AA_MARS_MIGRATE_HEADER;
  234. typedef AA_MARS_MIGRATE_HEADER UNALIGNED *PAA_MARS_MIGRATE_HEADER;
  235. //
  236. // Format of MARS REDIRECT MAP message header.
  237. //
  238. typedef struct _AA_MARS_REDIRECT_MAP_HEADER
  239. {
  240. UCHAR LLC[3];
  241. UCHAR OUI[3];
  242. USHORT PID; // 0x003
  243. USHORT afn; // Address Family (0x000F)
  244. UCHAR pro[7]; // Protocol Identification
  245. UCHAR hdrrsv[3]; // Reserved.
  246. USHORT chksum; // Checksum across entire MARS message
  247. USHORT extoff; // Extensions offset
  248. USHORT op; // Operation code (REDIRECT MAP)
  249. UCHAR shtl; // Type & Length of source ATM number
  250. UCHAR sstl; // Type & Length of source ATM subaddress
  251. UCHAR spln; // Source protocol address length
  252. UCHAR thtl; // Type & Length of target ATM number
  253. UCHAR tstl; // Type & Length of target ATM subaddress
  254. UCHAR redirf; // Flag controlling redirect behaviour
  255. USHORT tnum; // Number of MARS addresses returned
  256. USHORT seqxy; // Boolean flag x and seq number y
  257. ULONG msn; // MARS Sequence Number
  258. } AA_MARS_REDIRECT_MAP_HEADER;
  259. typedef AA_MARS_REDIRECT_MAP_HEADER UNALIGNED *PAA_MARS_REDIRECT_MAP_HEADER;
  260. //
  261. // Bit assignments for Boolean flag X and sequence number Y in
  262. // "seqxy" fields in MARS messages.
  263. //
  264. #define AA_MARS_X_MASK ((USHORT)0x8000)
  265. #define AA_MARS_Y_MASK ((USHORT)0x7fff)
  266. //
  267. // Initial value for sequence number Y
  268. //
  269. #define AA_MARS_INITIAL_Y ((USHORT)1)
  270. //
  271. // Structure of a MARS packet extension element (TLV = Type, Length, Value)
  272. //
  273. typedef struct _AA_MARS_TLV_HDR
  274. {
  275. USHORT Type;
  276. USHORT Length; // Number of significant octets in Value
  277. } AA_MARS_TLV_HDR;
  278. typedef AA_MARS_TLV_HDR UNALIGNED *PAA_MARS_TLV_HDR;
  279. //
  280. // Our experimental TLV that we use in MARS MULTI messages to
  281. // indicate that the returned target address is that of an MCS.
  282. //
  283. typedef struct _AA_MARS_TLV_MULTI_IS_MCS
  284. {
  285. AA_MARS_TLV_HDR;
  286. } AA_MARS_TLV_MULTI_IS_MCS;
  287. typedef AA_MARS_TLV_MULTI_IS_MCS UNALIGNED *PAA_MARS_TLV_MULTI_IS_MCS;
  288. #define AAMC_TLVT_MULTI_IS_MCS ((USHORT)0x3a00)
  289. //
  290. // Type of a NULL TLV
  291. //
  292. #define AAMC_TLVT_NULL ((USHORT)0x0000)
  293. //
  294. // Bit definitions for the Type field in a MARS TLV.
  295. //
  296. //
  297. // The Least significant 14 bits indicate the actual type.
  298. //
  299. #define AA_MARS_TLV_TYPE_MASK ((USHORT)0x3fff)
  300. //
  301. // The most significant 2 bits define the action to be taken
  302. // when we receive a TLV type that we don't recognize.
  303. //
  304. #define AA_MARS_TLV_ACTION_MASK ((USHORT)0xc000)
  305. #define AA_MARS_TLV_TA_SKIP ((USHORT)0x0000)
  306. #define AA_MARS_TLV_TA_STOP_SILENT ((USHORT)0x1000)
  307. #define AA_MARS_TLV_TA_STOP_LOG ((USHORT)0x2000)
  308. #define AA_MARS_TLV_TA_RESERVED ((USHORT)0x3000)
  309. #include <poppack.h>
  310. //
  311. // TLV List, internal representation. This stores information about
  312. // all TLVs sent/received in a packet. For each TLV, there is a
  313. // BOOLEAN that says whether it is present or not.
  314. //
  315. typedef struct _AA_MARS_TLV_LIST
  316. {
  317. //
  318. // MULTI_IS_MCS TLV:
  319. //
  320. BOOLEAN MultiIsMCSPresent;
  321. BOOLEAN MultiIsMCSValue;
  322. //
  323. // Add other TLVs...
  324. //
  325. } AA_MARS_TLV_LIST, *PAA_MARS_TLV_LIST;
  326. /*++
  327. BOOLEAN
  328. AAMC_PKT_IS_TYPE1_DATA(
  329. IN PAA_MC_PKT_TYPE1_SHORT_HEADER pH
  330. )
  331. --*/
  332. #define AAMC_PKT_IS_TYPE1_DATA(pH) \
  333. (((pH)->LLC[0] == MC_LLC_SNAP_LLC0) && \
  334. ((pH)->LLC[1] == MC_LLC_SNAP_LLC1) && \
  335. ((pH)->LLC[2] == MC_LLC_SNAP_LLC2) && \
  336. ((pH)->OUI[0] == MC_LLC_SNAP_OUI0) && \
  337. ((pH)->OUI[1] == MC_LLC_SNAP_OUI1) && \
  338. ((pH)->OUI[2] == MC_LLC_SNAP_OUI2) && \
  339. ((pH)->PID == NET_SHORT(AA_PKT_ETHERTYPE_MC_TYPE1)) && \
  340. ((pH)->pro == NET_SHORT(AA_PKT_ETHERTYPE_IP)))
  341. /*++
  342. BOOLEAN
  343. AAMC_PKT_IS_TYPE2_DATA(
  344. IN PAA_MC_PKT_TYPE2_SHORT_HEADER pH
  345. )
  346. --*/
  347. #define AAMC_PKT_IS_TYPE2_DATA(pH) \
  348. (((pH)->LLC[0] == MC_LLC_SNAP_LLC0) && \
  349. ((pH)->LLC[1] == MC_LLC_SNAP_LLC1) && \
  350. ((pH)->LLC[2] == MC_LLC_SNAP_LLC2) && \
  351. ((pH)->OUI[0] == MC_LLC_SNAP_OUI0) && \
  352. ((pH)->OUI[1] == MC_LLC_SNAP_OUI1) && \
  353. ((pH)->OUI[2] == MC_LLC_SNAP_OUI2) && \
  354. ((pH)->PID == NET_SHORT(AA_PKT_ETHERTYPE_MC_TYPE2)) && \
  355. ((pH)->pro == NET_SHORT(AA_PKT_ETHERTYPE_IP)))
  356. /*++
  357. BOOLEAN
  358. AAMC_PKT_IS_CONTROL(
  359. IN PAA_MARS_PKT_FIXED_HEADER pH
  360. )
  361. --*/
  362. #define AAMC_PKT_IS_CONTROL(pH) \
  363. (((pH)->LLC[0] == MC_LLC_SNAP_LLC0) && \
  364. ((pH)->LLC[1] == MC_LLC_SNAP_LLC1) && \
  365. ((pH)->LLC[2] == MC_LLC_SNAP_LLC2) && \
  366. ((pH)->OUI[0] == MC_LLC_SNAP_OUI0) && \
  367. ((pH)->OUI[1] == MC_LLC_SNAP_OUI1) && \
  368. ((pH)->OUI[2] == MC_LLC_SNAP_OUI2) && \
  369. ((pH)->PID == NET_SHORT(AA_PKT_ETHERTYPE_MARS_CONTROL)))
  370. /*++
  371. USHORT
  372. AAMC_GET_TLV_TYPE(
  373. IN USHORT _Type
  374. )
  375. --*/
  376. #define AAMC_GET_TLV_TYPE(_Type) NET_TO_HOST_SHORT((_Type) & AA_MARS_TLV_TYPE_MASK)
  377. /*++
  378. USHORT
  379. AAMC_GET_TLV_ACTION(
  380. IN USHORT _Type
  381. )
  382. --*/
  383. #define AAMC_GET_TLV_ACTION(_Type) NET_TO_HOST_SHORT((_Type) & AA_MARS_TLV_ACTION_MASK)
  384. /*++
  385. SHORT
  386. AAMC_GET_TLV_TOTAL_LENGTH(
  387. IN SHORT _TlvLength
  388. )
  389. Given the value stored in the Length field of a TLV, return
  390. the total (rounded-off) length of the TLV. This is just the
  391. length of the TLV header plus the given length rounded off
  392. to the nearest multiple of 4.
  393. --*/
  394. #define AAMC_GET_TLV_TOTAL_LENGTH(_TlvLength) \
  395. (sizeof(AA_MARS_TLV_HDR) + \
  396. (_TlvLength) + \
  397. ((4 - ((_TlvLength) & 3)) % 4))
  398. /*++
  399. BOOLEAN
  400. AAMC_IS_NULL_TLV(
  401. IN PAA_MARS_TLV_HDR _pTlv
  402. )
  403. Return TRUE iff the given TLV is a NULL TLV, meaning end of list.
  404. --*/
  405. #define AAMC_IS_NULL_TLV(_pTlv) \
  406. (((_pTlv)->Type == 0x0000) && ((_pTlv)->Length == 0x0000))
  407. #endif _MARS_PKT__H