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.

530 lines
15 KiB

  1. //============================================================================
  2. // Copyright (c) 1995, Microsoft Corporation
  3. //
  4. // File: group.h
  5. //
  6. // History:
  7. // V Raman July-11-1997 Created.
  8. //
  9. // Data structures for and declarations for routines that manipulate
  10. // group and sources entries
  11. //============================================================================
  12. #ifndef _GROUP_H_
  13. #define _GROUP_H_
  14. //----------------------------------------------------------------------------
  15. // OUT_IF_ENTRY
  16. //
  17. // Each OUT_IF_ENTRY stores information about an outgoing interface in an
  18. // MFE. The fields in the structure are :
  19. //
  20. // leIfList - link to next entry in the outgoing interface
  21. // list.
  22. // dwIfIndex - Index of interface
  23. //
  24. // dwNextHopIfAddr - For interfaces with same index the next hop
  25. // address is used to distinguish them
  26. //
  27. // dwProtocolId - Protocol id of the routing protocol component
  28. // that owns dwIfIndex
  29. //
  30. // dwComponentId - Component id of the routing protocol component
  31. // that owns dwIfIndex
  32. //
  33. // wCreatedForFlag - Indicates if the interface entry was created
  34. // explicitly by a protocol or implicitly by
  35. // MGM (as a consequence of the interface being
  36. // being present in the Outgoing Interface list
  37. // of the corresponding (*, G) or (*, *) entry.
  38. //
  39. // dwAddedByFlag - if the interface entry is created by a
  40. // routing protocol then it could have been
  41. // created by both IGMP or by a full fledged
  42. // routing protocol (or both). This flag is
  43. // used to distinguish both.
  44. //
  45. // wNumAddsByIGMP - Count of number of times this interface has
  46. // been added to the OIL by IGMP. Can be at most
  47. // 2, once for a (*, G) addition and once for an
  48. // (S, G) addition.
  49. //
  50. // wNumAddsByRP - Count of number of times this interface has
  51. // been added to the OIL by the RP on this
  52. // interface. Can be at most
  53. // 3, once for a (*, *) addition, once for a
  54. // (*, G) addition and once for an (S, G)
  55. // addition.
  56. //
  57. // misIfStats - Statistics for this outgoing interface.
  58. //
  59. //----------------------------------------------------------------------------
  60. typedef struct _OUT_IF_ENTRY
  61. {
  62. LIST_ENTRY leIfList;
  63. DWORD dwIfIndex;
  64. DWORD dwIfNextHopAddr;
  65. DWORD dwProtocolId;
  66. DWORD dwComponentId;
  67. WORD wForward;
  68. WORD wAddedByFlag;
  69. WORD wNumAddsByIGMP;
  70. WORD wNumAddsByRP;
  71. IPMCAST_OIF_STATS imosIfStats;
  72. } OUT_IF_ENTRY, *POUT_IF_ENTRY;
  73. //
  74. // Macros to manipulate bit flags in OUT_IF_ENTRY
  75. //
  76. #define ADDED_BY_IGMP (DWORD) 0x8000
  77. #define ADDED_BY_ROUTING_PROTOCOL (DWORD) 0x4000
  78. #define SET_ADDED_BY_IGMP( p ) \
  79. (p)-> wAddedByFlag |= ADDED_BY_IGMP
  80. #define CLEAR_ADDED_BY_IGMP( p ) \
  81. (p)-> wAddedByFlag &= ~ADDED_BY_IGMP
  82. #define IS_ADDED_BY_IGMP( p ) \
  83. ( (p)-> wAddedByFlag & ADDED_BY_IGMP )
  84. #define SET_ADDED_BY_PROTOCOL( p ) \
  85. (p)-> wAddedByFlag |= ADDED_BY_ROUTING_PROTOCOL
  86. #define CLEAR_ADDED_BY_PROTOCOL( p ) \
  87. (p)-> wAddedByFlag &= ~ADDED_BY_ROUTING_PROTOCOL
  88. #define IS_ADDED_BY_PROTOCOL( p ) \
  89. ( (p)-> wAddedByFlag & ADDED_BY_ROUTING_PROTOCOL )
  90. //----------------------------------------------------------------------------
  91. // SOURCE_ENTRY
  92. //
  93. // Each SOURCE_ENTRY represents information about a specific source for a
  94. // specific group. The source can also be the wildcard source created by a
  95. // (*, G) join for a group. A source entry is either explicitly created by
  96. // a source specific (S, G) join or implicitly by MGM when creating an MFE
  97. // in response to packet arrival.
  98. //
  99. // leSrcList - Links along the lexicographically ordered
  100. // source list
  101. //
  102. // leSrcHashList - Links along the source hash table.
  103. //
  104. // leScopedIfList - List of interfaces that have been joined
  105. // but administratively scoped out.
  106. //
  107. // leOutIfList - Outgoing interface list. Entries in this
  108. // list are created as a result of explicit
  109. // (S, G) joins by a protocol
  110. //
  111. // leMfeIfList - Outgoing interface list created when an MFE
  112. // for this source, for this group is created
  113. // by MGM. This list is created by MGM
  114. // when a new packet for this (source, group)
  115. // and respresents the merge of the outgoing
  116. // interface lists of the (*, *) entry, (*, G)
  117. // entry and the (S,G) entry.
  118. //
  119. // dwOutIfCount - Count of number of entries in leOutIfList.
  120. // Used to determine callback order.
  121. //
  122. // dwOutIfCompCount - Count of number of protocol components that
  123. // have added interfaces to the outgoing list.
  124. // Used to determine the order of callbacks to
  125. // routing protocols
  126. //
  127. // dwSourceAddr - IP Address of source.
  128. //
  129. // dwSourceMask - IP mask corresponding to dwSourceAddr
  130. //
  131. // dwInIfIndex - Interface index of the incmoing interface.
  132. // A source entry is considered to be an MFE
  133. // if it has a valid incoming interface.
  134. //
  135. // dwInIfNextHopAddr - next hop address for dwInIfIndex
  136. //
  137. // dwInProtocolId - Protocol Id of the protocol owning dwInIfIndex
  138. //
  139. // dwInComponentId - Component Id of the protocol component owning
  140. // dwIfInIndex
  141. //
  142. // bInForwarder - Flag indicating if the MFE is present in the
  143. // kernel mode forwarder.
  144. //
  145. // liExpiryTime - Expiration time of the source entry.
  146. //
  147. // mgmGrpStatistics - Statistics associated with this (S, G) entry
  148. //
  149. //----------------------------------------------------------------------------
  150. typedef struct _SOURCE_ENTRY
  151. {
  152. LIST_ENTRY leSrcList;
  153. LIST_ENTRY leSrcHashList;
  154. DWORD dwInUse;
  155. DWORD dwOutIfCount;
  156. DWORD dwOutCompCount;
  157. LIST_ENTRY leOutIfList;
  158. LIST_ENTRY leScopedIfList;
  159. DWORD dwMfeIfCount;
  160. LIST_ENTRY leMfeIfList;
  161. DWORD dwSourceAddr;
  162. DWORD dwSourceMask;
  163. DWORD dwInIfIndex;
  164. DWORD dwInIfNextHopAddr;
  165. DWORD dwUpstreamNeighbor;
  166. DWORD dwRouteProtocol;
  167. DWORD dwRouteNetwork;
  168. DWORD dwRouteMask;
  169. DWORD dwInProtocolId;
  170. DWORD dwInComponentId;
  171. BOOL bInForwarder;
  172. HANDLE hTimer;
  173. DWORD dwTimeOut;
  174. LARGE_INTEGER liCreationTime;
  175. IPMCAST_MFE_STATS imsStatistics;
  176. } SOURCE_ENTRY, *PSOURCE_ENTRY;
  177. #define MGM_SOURCE_ENUM_SIGNATURE 'sMGM'
  178. //----------------------------------------------------------------------------
  179. // GROUP_ENTRY
  180. //
  181. // Each group entry contains information for a specific group that has been
  182. // explicitly added by a protocol (or implicitly by MGM). The group can
  183. // a wildcard group created by a (*, *) join.
  184. //
  185. // leGrpList - Links along the lexicographically ordered
  186. // group list.
  187. //
  188. // leGrpHashList - Links along the group hash bucket.
  189. //
  190. // dwGroupAddr - Group address of entry.
  191. //
  192. // dwGroupMask - Mask corresponding to the group address
  193. //
  194. // leSourceList - Head of lexicographically ordered source list
  195. //
  196. // pleSrcHashTable - hash table of source entries for this group
  197. //
  198. //----------------------------------------------------------------------------
  199. typedef struct _GROUP_ENTRY
  200. {
  201. LIST_ENTRY leGrpList;
  202. LIST_ENTRY leGrpHashList;
  203. DWORD dwGroupAddr;
  204. DWORD dwGroupMask;
  205. PMGM_READ_WRITE_LOCK pmrwlLock;
  206. DWORD dwSourceCount;
  207. DWORD dwNumTempEntries;
  208. LIST_ENTRY leTempSrcList;
  209. LIST_ENTRY leSourceList;
  210. LIST_ENTRY pleSrcHashTable[1];
  211. } GROUP_ENTRY, *PGROUP_ENTRY;
  212. #define MGM_GROUP_ENUM_SIGNATURE 'gMGM'
  213. DWORD
  214. CreateGroupEntry(
  215. PLIST_ENTRY pleHashList,
  216. DWORD dwGroupAddr,
  217. DWORD dwGroupMask,
  218. PGROUP_ENTRY * ppge
  219. );
  220. PGROUP_ENTRY
  221. GetGroupEntry(
  222. PLIST_ENTRY pleGroupList,
  223. DWORD dwGroupAddr,
  224. DWORD dwGroupMask
  225. );
  226. VOID
  227. DeleteGroupEntry(
  228. PGROUP_ENTRY pge
  229. );
  230. BOOL
  231. FindGroupEntry(
  232. PLIST_ENTRY pleGroupList,
  233. DWORD dwGroupAddr,
  234. DWORD dwGroupMask,
  235. PGROUP_ENTRY * ppge,
  236. BOOL bHashList
  237. );
  238. DWORD
  239. CreateSourceEntry(
  240. PGROUP_ENTRY pge,
  241. PLIST_ENTRY pleSrcList,
  242. DWORD dwSourceAddr,
  243. DWORD dwSourceMask,
  244. PSOURCE_ENTRY * ppse
  245. );
  246. PSOURCE_ENTRY
  247. GetSourceEntry(
  248. PLIST_ENTRY pleSrcList,
  249. DWORD dwSourceAddr,
  250. DWORD dwSourceMask
  251. );
  252. VOID
  253. DeleteSourceEntry(
  254. PSOURCE_ENTRY pse
  255. );
  256. BOOL
  257. FindSourceEntry(
  258. PLIST_ENTRY pleSrcList,
  259. DWORD dwSourceAddr,
  260. DWORD dwSourceMask,
  261. PSOURCE_ENTRY * ppse,
  262. BOOL bHashList
  263. );
  264. DWORD
  265. CreateOutInterfaceEntry(
  266. PLIST_ENTRY pleOutIfList,
  267. DWORD dwIfIndex,
  268. DWORD dwIfNextHopAddr,
  269. DWORD dwProtocolId,
  270. DWORD dwComponentId,
  271. BOOL bIGMP,
  272. POUT_IF_ENTRY * ppoie
  273. );
  274. POUT_IF_ENTRY
  275. GetOutInterfaceEntry(
  276. PLIST_ENTRY pleOutIfList,
  277. DWORD dwIfIndex,
  278. DWORD dwIfNextHopAddr,
  279. DWORD dwProtocolId,
  280. DWORD dwComponentId
  281. );
  282. VOID
  283. DeleteOutInterfaceEntry(
  284. POUT_IF_ENTRY poie
  285. );
  286. BOOL
  287. FindOutInterfaceEntry(
  288. PLIST_ENTRY pleOutIfList,
  289. DWORD dwIfIndex,
  290. DWORD dwIfNextHopAddr,
  291. DWORD dwProtocolId,
  292. DWORD dwComponentId,
  293. PBOOL pbNewComponent,
  294. POUT_IF_ENTRY * ppoie
  295. );
  296. DWORD
  297. AddInterfaceToSourceEntry(
  298. PPROTOCOL_ENTRY ppe,
  299. DWORD dwGroupAddr,
  300. DWORD dwGroupMask,
  301. DWORD dwSourceAddr,
  302. DWORD dwSourceMask,
  303. DWORD dwIfIndex,
  304. DWORD dwIfNextHopAddr,
  305. BOOL bIGMP,
  306. PBOOL pbUpdateMfe,
  307. PLIST_ENTRY pleSourceList
  308. );
  309. VOID
  310. AddInterfaceToAllMfeInGroupBucket(
  311. DWORD dwIfIndex,
  312. DWORD dwIfNextHopAddr,
  313. DWORD dwProtocolId,
  314. DWORD dwComponentId,
  315. DWORD dwInd,
  316. BOOL bIGMP,
  317. BOOL bAdd,
  318. PLIST_ENTRY pleSourceList
  319. );
  320. VOID
  321. AddInterfaceToGroupMfe(
  322. PGROUP_ENTRY pge,
  323. DWORD dwIfIndex,
  324. DWORD dwIfNextHopAddr,
  325. DWORD dwProtocolId,
  326. DWORD dwComponentId,
  327. BOOL bIGMP,
  328. BOOL bAdd,
  329. PLIST_ENTRY pleSourceList
  330. );
  331. VOID
  332. AddInterfaceToSourceMfe(
  333. PGROUP_ENTRY pge,
  334. PSOURCE_ENTRY pse,
  335. DWORD dwIfIndex,
  336. DWORD dwIfNextHopAddr,
  337. DWORD dwProtocolId,
  338. DWORD dwComponentId,
  339. BOOL bIGMP,
  340. POUT_IF_ENTRY * ppoie
  341. );
  342. VOID
  343. DeleteInterfaceFromSourceEntry(
  344. PPROTOCOL_ENTRY ppe,
  345. DWORD dwGroupAddr,
  346. DWORD dwGroupMask,
  347. DWORD dwSourceAddr,
  348. DWORD dwSourceMask,
  349. DWORD dwIfIndex,
  350. DWORD dwIfNextHopAddr,
  351. BOOL bIGMP
  352. );
  353. VOID
  354. DeleteInterfaceFromAllMfe(
  355. DWORD dwIfIndex,
  356. DWORD dwIfNextHopAddr,
  357. DWORD dwProtocolId,
  358. DWORD dwComponentId,
  359. BOOL bIGMP
  360. );
  361. VOID
  362. DeleteInterfaceFromGroupMfe(
  363. PGROUP_ENTRY pge,
  364. DWORD dwIfIndex,
  365. DWORD dwIfNextHopAddr,
  366. DWORD dwProtocolId,
  367. DWORD dwComponentId,
  368. BOOL bIGMP
  369. );
  370. VOID
  371. DeleteInterfaceFromSourceMfe(
  372. PGROUP_ENTRY pge,
  373. PSOURCE_ENTRY pse,
  374. DWORD dwIfIndex,
  375. DWORD dwIfNextHopAddr,
  376. DWORD dwProtocolId,
  377. DWORD dwComponentId,
  378. BOOL bIGMP,
  379. BOOL bDel
  380. );
  381. VOID
  382. LookupAndDeleteYourMfe(
  383. DWORD dwSourceAddr,
  384. DWORD dwSourceMask,
  385. DWORD dwGroupAddr,
  386. DWORD dwGroupMask,
  387. BOOL bDeleteTimer,
  388. PDWORD pdwInIfIndex OPTIONAL,
  389. PDWORD pdwInIfNextHopAddr OPTIONAL
  390. );
  391. VOID
  392. DeleteMfe(
  393. PGROUP_ENTRY pge,
  394. PSOURCE_ENTRY pse
  395. );
  396. VOID
  397. MergeTempAndMasterGroupLists(
  398. PLIST_ENTRY pleTempList
  399. );
  400. VOID
  401. MergeTempAndMasterSourceLists(
  402. PGROUP_ENTRY pge
  403. );
  404. #endif // _GROUP_H_