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.

423 lines
12 KiB

  1. /*++
  2. Copyright (c) 1992-1996 Microsoft Corporation
  3. Module Name:
  4. mars.h
  5. Abstract:
  6. This file contains the definitions for Multicast Address Resolution Server (MARS).
  7. Author:
  8. Jameel Hyder (jameelh@microsoft.com) January 1997
  9. Environment:
  10. Kernel mode
  11. Revision History:
  12. --*/
  13. #ifndef _MARS_
  14. #define _MARS_
  15. //
  16. // IP Address values that can be used in comparisons:
  17. //
  18. #define MIN_CLASSD_IPADDR_VALUE ((IPADDR)0xE0000000) // 224.0.0.0
  19. #define MAX_CLASSD_IPADDR_VALUE ((IPADDR)0xEFFFFFFF) // 239.255.255.255
  20. #define IP_BROADCAST_ADDR_VALUE ((IPADDR)0xFFFFFFFF) // 255.255.255.255
  21. //
  22. // IP Address value we use to represent the "full multicast+broadcast range"
  23. //
  24. #define IPADDR_FULL_RANGE ((IPADDR)0x00000000)
  25. //
  26. // MARS_OP - Define these in network byte order
  27. //
  28. #define OP_MARS_REQUEST 0x0100
  29. #define OP_MARS_MULTI 0x0200
  30. #define OP_MARS_MSERV 0x0300
  31. #define OP_MARS_JOIN 0x0400
  32. #define OP_MARS_LEAVE 0x0500
  33. #define OP_MARS_NAK 0x0600
  34. #define OP_MARS_UNSERV 0x0700
  35. #define OP_MARS_SJOIN 0x0800
  36. #define OP_MARS_SLEAVE 0x0900
  37. #define OP_MARS_MIGRATE 0x0D00
  38. #define OP_MARS_GROUPLIST_REQUEST 0x0000
  39. #define OP_MARS_GROUPLIST_REPLY 0x0000
  40. #define OP_MARS_REDIRECT_MAP 0x0C00
  41. #define MARS_HWTYPE 0x0F00
  42. #define LAST_MULTI_FLAG 0x8000
  43. //
  44. // The layout of a MARS_JOIN and MARS_LEAVE request packets
  45. //
  46. typedef struct _MARS_HDR
  47. {
  48. LLC_SNAP_HDR LlcSnapHdr; // LLC SNAP Header
  49. USHORT HwType; // Must be 0x0F00 (0x000F on the wire)
  50. USHORT Protocol; // 16 bits
  51. UCHAR ProtocolSnap[5]; // 40 bits
  52. UCHAR Reserved[3]; // 24-bits
  53. USHORT CheckSum;
  54. USHORT ExtensionOffset;
  55. USHORT Opcode; // MARS_XXX above
  56. ATM_ADDR_TL SrcAddressTL;
  57. ATM_ADDR_TL SrcSubAddrTL;
  58. //
  59. // This is followed by variable length fields and is dictated by the value of Opcode.
  60. // The structures below define fixed part of individual MARS_XXX messages. The variable
  61. // part of each of these depends on the TL fields.
  62. //
  63. } MARS_HEADER, *PMARS_HEADER;
  64. //
  65. // Defines the structure of the MARS_REQUEST, MARS_MULTI, MARS_MIGRATE and MARS_NAK messages
  66. //
  67. typedef struct _MARS_REQUEST
  68. {
  69. MARS_HEADER;
  70. UCHAR SrcProtoAddrLen; // Src protocol addr length
  71. ATM_ADDR_TL TgtAddressTL;
  72. ATM_ADDR_TL TgtSubAddrTL;
  73. UCHAR TgtGroupAddrLen; // Target protocol addr length
  74. union
  75. {
  76. UCHAR Padding[8]; // For MARS_REQUEST and MARS_NAK
  77. struct
  78. { // For MARS_MULTI and MARS_MIGRATE
  79. USHORT NumTgtGroupAddr; // Should be converted to wire-format
  80. union
  81. {
  82. USHORT FlagSeq; // Should be converted to wire-format
  83. USHORT Reservedx; // For MARS_MIGRATE
  84. };
  85. ULONG SequenceNumber; // Should be converted to wire-format
  86. };
  87. };
  88. } MARS_REQUEST, MARS_MULTI, MARS_NAK, *PMARS_REQUEST, *PMARS_MULTI, *PMARS_NAK;
  89. typedef struct _MCAST_ADDR_PAIR
  90. {
  91. IPADDR MinAddr;
  92. IPADDR MaxAddr;
  93. } MCAST_ADDR_PAIR, *PMCAST_ADDR_PAIR;
  94. //
  95. // Defines the structure of the MARS_JOIN and MARS_LEAVE messages
  96. //
  97. typedef struct _MARS_JOIN_LEAVE
  98. {
  99. MARS_HEADER;
  100. UCHAR SrcProtoAddrLen; // Src protocol addr length
  101. UCHAR GrpProtoAddrLen; // Grp protocol addr length
  102. USHORT NumGrpAddrPairs; // # of group address pairs
  103. // Should be converted to wire-format
  104. USHORT Flags; // layer 3 frp copy & register flags
  105. // Should be converted to wire-format
  106. USHORT ClusterMemberId; // Should be converted to wire-format
  107. ULONG MarsSequenceNumber; // Should be converted to wire-format
  108. //
  109. // This is followed by Src ATM address/sub-address, src protocol address and N pairs of multicast addresses
  110. //
  111. } MARS_JOIN_LEAVE, *PMARS_JOIN_LEAVE;
  112. //
  113. // Definitions of flags masks
  114. //
  115. #define JL_FLAGS_L3GRP 0x8000
  116. #define JL_FLAGS_COPY 0x4000
  117. #define JL_FLAGS_REGISTER 0x2000
  118. #define JL_FLAGS_PUNCHED 0x1000
  119. #define JL_FLAGS_RESERVED 0x0F00
  120. #define JL_FLAGS_SEQUENCE 0x00FF
  121. //
  122. // Defines the structure of the MARS_GROUPLIST_REQUEST and MARS_GROUPLIST_REPLY messages
  123. //
  124. typedef struct _MARS_GROUPLIST_REPLY
  125. {
  126. MARS_HEADER;
  127. UCHAR SrcProtoAddrLen; // Src protocol addr length
  128. UCHAR Reserved1;
  129. UCHAR Reserved2;
  130. UCHAR TgtGroupAddrLen; // Target protocol addr length
  131. USHORT NumTgtGroupAddr; // Should be converted to wire-format
  132. USHORT FlagSeq; // Should be converted to wire-format
  133. ULONG SequenceNumber; // Should be converted to wire-format
  134. } MARS_GROUPLIST_REPLY, *PMARS_GROUPLIST_REPLY;
  135. //
  136. // Defines the structure of the MARS_REDIRECT_MAP messages
  137. //
  138. typedef struct _MARS_REDIRECT_MAP
  139. {
  140. MARS_HEADER;
  141. UCHAR SrcProtoAddrLen; // Src protocol addr length
  142. ATM_ADDR_TL TgtAddressTL;
  143. ATM_ADDR_TL TgtSubAddrTL;
  144. UCHAR Flags;
  145. USHORT NumTgtAddr; // Should be converted to wire-format
  146. USHORT FlagSeq; // Should be converted to wire-format
  147. ULONG SequenceNumber; // Should be converted to wire-format
  148. } MARS_REDIRECT_MAP, *PMARS_REDIRECT_MAP;
  149. //
  150. // Defines the structure of a MARS TLV header
  151. //
  152. typedef struct _MARS_TLV_HEADER
  153. {
  154. USHORT Type;
  155. USHORT Length;
  156. } MARS_TLV_HEADER;
  157. typedef MARS_TLV_HEADER UNALIGNED * PMARS_TLV_HEADER;
  158. //
  159. // Defines the structure of a MARS MULTI is MCS header. This TLV is appended
  160. // to any MULTI message we send out with our address as the MCS address.
  161. //
  162. typedef struct _MARS_TLV_MULTI_IS_MCS
  163. {
  164. MARS_TLV_HEADER;
  165. } MARS_TLV_MULTI_IS_MCS;
  166. typedef MARS_TLV_MULTI_IS_MCS UNALIGNED * PMARS_TLV_MULTI_IS_MCS;
  167. //
  168. // TLV Type value for MULTI is MCS TLV.
  169. //
  170. #define MARS_TLVT_MULTI_IS_MCS 0x003a // on-the-wire form
  171. //
  172. // Defines the structure of a NULL TLV, which is used to terminate
  173. // a list of TLVs.
  174. //
  175. typedef struct _MARS_TLV_NULL
  176. {
  177. MARS_TLV_HEADER;
  178. } MARS_TLV_NULL;
  179. typedef MARS_TLV_NULL UNALIGNED * PMARS_TLV_NULL;
  180. //
  181. // Forward references
  182. //
  183. struct _CLUSTER_MEMBER ;
  184. struct _GROUP_MEMBER ;
  185. struct _MARS_ENTRY ;
  186. struct _MCS_ENTRY ;
  187. struct _MARS_VC ;
  188. //
  189. // This represents a cluster-member, or an endstation that has registered
  190. // with MARS. A single cluster-member can be associated with many groups.
  191. //
  192. typedef struct _CLUSTER_MEMBER
  193. {
  194. ENTRY_HDR; // Must be the first entry
  195. HW_ADDR HwAddr; // HWADDR MUST FOLLOW ENTRY_HDR
  196. PINTF pIntF; // Back pointer to the interface
  197. USHORT Flags;
  198. USHORT CMI; // Cluster-Member-Id
  199. NDIS_HANDLE NdisPartyHandle; // Leaf-node for ClusterControlVc
  200. struct _GROUP_MEMBER * pGroupList; // List of groups this CM has JOINed
  201. // This is sorted in ascending order
  202. // of Group Address
  203. INT NumGroups; // Size of above list
  204. } CLUSTER_MEMBER, *PCLUSTER_MEMBER;
  205. #define NULL_PCLUSTER_MEMBER ((PCLUSTER_MEMBER)NULL)
  206. #define CM_CONN_FLAGS 0x000f
  207. #define CM_CONN_IDLE 0x0000 // No connection
  208. #define CM_CONN_SETUP_IN_PROGRESS 0x0001 // Sent MakeCall/AddParty
  209. #define CM_CONN_ACTIVE 0x0002 // Participating in ClusterControlVc
  210. #define CM_CONN_CLOSING 0x0004 // Sent CloseCall/DropParty
  211. #define CM_INVALID 0x8000 // Invalidated entry
  212. #define CM_GROUP_FLAGS 0x0010
  213. #define CM_GROUP_ACTIVE 0x0000 // Ok to add groups
  214. #define CM_GROUP_DISABLED 0x0010 // Don't add any more groups.
  215. //
  216. // This represents a member of a multicast address. There is one
  217. // of this for every node that joins a class-D address. That is,
  218. // this structure represents a <MulticastGroup, ClusterMember> relation.
  219. //
  220. typedef struct _GROUP_MEMBER
  221. {
  222. ENTRY_HDR; // Must be the first entry
  223. struct _MARS_ENTRY * pMarsEntry; // Pointer to group info
  224. PCLUSTER_MEMBER pClusterMember; // Cluster Member Joining this group
  225. struct _GROUP_MEMBER * pNextGroup; // Next group this CM has JOINed
  226. ULONG Flags;
  227. } GROUP_MEMBER, *PGROUP_MEMBER;
  228. #define NULL_PGROUP_MEMBER ((PGROUP_MEMBER)NULL)
  229. //
  230. // This represents a multi-cast IP address. These are linked to the IntF.
  231. // It contains a list of all cluster members who have Joined the group
  232. // identified by the address.
  233. //
  234. // A special entry is one with IPAddress set to 0. This entry is used to
  235. // represent the "All multicast and broadcast" range. Cluster Members who
  236. // Join this range are linked here.
  237. //
  238. typedef struct _MARS_ENTRY
  239. {
  240. ENTRY_HDR; // Must be the first entry
  241. IPADDR IPAddress; // Class D IP Addr (0 means entire
  242. // multicast+broadcast range)
  243. PGROUP_MEMBER pMembers; // List of group-members (Join list)
  244. UINT NumMembers; // Size of above list
  245. PINTF pIntF; // Back pointer to the interface
  246. } MARS_ENTRY, *PMARS_ENTRY;
  247. #define NULL_PMARS_ENTRY ((PMARS_ENTRY)NULL)
  248. //
  249. // This is used to represent an address range served by MCS. These
  250. // structures are linked to the IntF.
  251. //
  252. typedef struct _MCS_ENTRY
  253. {
  254. ENTRY_HDR; // Must be the first entry
  255. MCAST_ADDR_PAIR GrpAddrPair; // The range served by MCS
  256. PINTF pIntF; // Back pointer to the interface
  257. } MCS_ENTRY, *PMCS_ENTRY;
  258. #define NULL_PMCS_ENTRY ((PMCS_ENTRY)NULL)
  259. //
  260. // This represents a PMP uni-directional VC. MARS creates one for
  261. // ClusterControl and one for ServerControl (if and when external MCS'
  262. // are supported).
  263. //
  264. typedef struct _MARS_VC
  265. {
  266. ULONG VcType;
  267. ULONG Flags;
  268. LONG RefCount;
  269. NDIS_HANDLE NdisVcHandle;
  270. UINT NumParties;
  271. PINTF pIntF;
  272. } MARS_VC, *PMARS_VC;
  273. #define NULL_PMARS_VC ((PMARS_VC)NULL)
  274. #define MVC_CONN_FLAGS 0x0000000f
  275. #define MVC_CONN_IDLE 0x00000000
  276. #define MVC_CONN_SETUP_IN_PROGRESS 0x00000001 // Sent MakeCall
  277. #define MVC_CONN_ACTIVE 0x00000002 // MakeCall success
  278. #define MVC_CONN_NEED_CLOSE 0x00000004 // Need to CloseCall when the penultimate
  279. // party is gone
  280. #define MVC_CONN_CLOSING 0x00000008 // Sent CloseCall
  281. #define MVC_CONN_CLOSE_RECEIVED 0x00000010 // Seen IncomingCloseCall
  282. #ifndef MAX
  283. #define MAX(a, b) (((a) > (b)) ? (a) : (b))
  284. #endif
  285. #ifndef MIN
  286. #define MIN(a, b) (((a) > (b)) ? (b) : (a))
  287. #endif
  288. //
  289. // Be a little generous and use 256 as space for incoming requests
  290. //
  291. #if 0
  292. #define PKT_SPACE MAX(sizeof(ARPS_HEADER) + sizeof(ARPS_VAR_HDR), \
  293. sizeof(MARS_REQUEST) + sizeof(ARPS_VAR_HDR))
  294. #else
  295. #define PKT_SPACE 256
  296. #endif
  297. #define BYTES_TO_CELLS(_b) ((_b)/48)
  298. //
  299. // Rounded-off size of generic Q.2931 IE header
  300. //
  301. #define ROUND_OFF(_size) (((_size) + 3) & ~0x4)
  302. #define SIZEOF_Q2931_IE ROUND_OFF(sizeof(Q2931_IE))
  303. #define SIZEOF_AAL_PARAMETERS_IE ROUND_OFF(sizeof(AAL_PARAMETERS_IE))
  304. #define SIZEOF_ATM_TRAFFIC_DESCR_IE ROUND_OFF(sizeof(ATM_TRAFFIC_DESCRIPTOR_IE))
  305. #define SIZEOF_ATM_BBC_IE ROUND_OFF(sizeof(ATM_BROADBAND_BEARER_CAPABILITY_IE))
  306. #define SIZEOF_ATM_BLLI_IE ROUND_OFF(sizeof(ATM_BLLI_IE))
  307. #define SIZEOF_ATM_QOS_IE ROUND_OFF(sizeof(ATM_QOS_CLASS_IE))
  308. //
  309. // Total space required for Information Elements in an outgoing call.
  310. //
  311. #define MARS_MAKE_CALL_IE_SPACE ( \
  312. SIZEOF_Q2931_IE + SIZEOF_AAL_PARAMETERS_IE + \
  313. SIZEOF_Q2931_IE + SIZEOF_ATM_TRAFFIC_DESCR_IE + \
  314. SIZEOF_Q2931_IE + SIZEOF_ATM_BBC_IE + \
  315. SIZEOF_Q2931_IE + SIZEOF_ATM_BLLI_IE + \
  316. SIZEOF_Q2931_IE + SIZEOF_ATM_QOS_IE )
  317. //
  318. // Total space required for Information Elements in an outgoing AddParty.
  319. //
  320. #define MARS_ADD_PARTY_IE_SPACE ( \
  321. SIZEOF_Q2931_IE + SIZEOF_AAL_PARAMETERS_IE + \
  322. SIZEOF_Q2931_IE + SIZEOF_ATM_BLLI_IE )
  323. //
  324. // Some macros to set/get state
  325. //
  326. #define MARS_GET_CM_CONN_STATE(_pCm) ((_pCm)->Flags & CM_CONN_FLAGS)
  327. #define MARS_SET_CM_CONN_STATE(_pCm, _St) \
  328. { (_pCm)->Flags = ((_pCm)->Flags & ~CM_CONN_FLAGS) | (_St); }
  329. #define MARS_GET_CM_GROUP_STATE(_pCm) ((_pCm)->Flags & CM_GROUP_FLAGS)
  330. #define MARS_SET_CM_GROUP_STATE(_pCm, _St) \
  331. { (_pCm)->Flags = ((_pCm)->Flags & ~CM_GROUP_FLAGS) | (_St); }
  332. #define MARS_GET_VC_CONN_STATE(_pVc) ((_pVc)->Flags & MVC_CONN_FLAGS)
  333. #define MARS_SET_VC_CONN_STATE(_pVc, _St) \
  334. { (_pVc)->Flags = ((_pVc)->Flags & ~MVC_CONN_FLAGS) | (_St); }
  335. #endif // _MARS_