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.

1171 lines
36 KiB

  1. //============================================================================
  2. // Copyright (c) 1995, Microsoft Corporation
  3. //
  4. // File: ipmgm.h
  5. //
  6. // History:
  7. // V Raman Aug-6-1997 Created.
  8. //
  9. // Contains type definitions and declarations for IP MGM.
  10. //============================================================================
  11. #ifndef _IPMGM_H_
  12. #define _IPMGM_H_
  13. //
  14. // various codes describing states of IPMGM.
  15. //
  16. typedef enum _IPMGM_STATUS_CODE {
  17. IPMGM_STATUS_STARTING = 100,
  18. IPMGM_STATUS_RUNNING = 101,
  19. IPMGM_STATUS_STOPPING = 102,
  20. IPMGM_STATUS_STOPPED = 103
  21. } IPMGM_STATUS_CODE, *PIPMGM_STATUS_CODE;
  22. //
  23. // Structure of global information maintained by MGM.
  24. //
  25. //
  26. typedef struct _IPMGM_GLOBALS
  27. {
  28. //------------------------------------------------------------------------
  29. // global stuff.
  30. //------------------------------------------------------------------------
  31. CRITICAL_SECTION csGlobal;
  32. IPMGM_STATUS_CODE imscStatus;
  33. HANDLE hIpMgmGlobalHeap;
  34. LONG lActivityCount;
  35. HANDLE hActivitySemaphore;
  36. ROUTER_MANAGER_CONFIG rmcRmConfig;
  37. //------------------------------------------------------------------------
  38. // hash table sizes
  39. //------------------------------------------------------------------------
  40. DWORD dwRouteTableSize;
  41. DWORD dwTimerQTableSize;
  42. //------------------------------------------------------------------------
  43. // Timer handles
  44. //------------------------------------------------------------------------
  45. HANDLE hRouteCheckTimer;
  46. //------------------------------------------------------------------------
  47. // lists and tables
  48. //------------------------------------------------------------------------
  49. LOCK_LIST llStackOfLocks;
  50. DWORD dwNumProtocols;
  51. MGM_LOCKED_LIST mllProtocolList;
  52. MGM_LOCKED_LIST mllOutstandingJoinList;
  53. PMGM_LOCKED_LIST pmllIfHashTable;
  54. PMGM_LOCKED_LIST pmllRouteHashTable;
  55. DWORD dwNumTempEntries;
  56. MGM_LOCKED_LIST mllTempGrpList;
  57. MGM_LOCKED_LIST mllGrpList;
  58. PMGM_LOCKED_LIST pmllGrpHashTable;
  59. PHANDLE phTimerQHandleTable;
  60. //------------------------------------------------------------------------
  61. // trace stuff.
  62. //------------------------------------------------------------------------
  63. DWORD dwTraceID;
  64. DWORD dwLogLevel;
  65. HANDLE hLogHandle;
  66. } IPMGM_GLOBALS, *PIPMGM_GLOBALS;
  67. //============================================================================
  68. // external declaration of the global IPMGM struct
  69. //============================================================================
  70. extern IPMGM_GLOBALS ig;
  71. //============================================================================
  72. // Macros to access hash functions and hash table sizes
  73. //============================================================================
  74. #define IF_TABLE_SIZE ig.rmcRmConfig.dwIfTableSize
  75. #define IF_TABLE_HASH( Index ) \
  76. ( ( Index ) % IF_TABLE_SIZE )
  77. #define ROUTE_TABLE_SIZE ig.dwRouteTableSize
  78. #define ROUTE_TABLE_HASH( p ) \
  79. ( ( (p)-> RR_Network.N_NetNumber ) % ROUTE_TABLE_SIZE )
  80. #define GROUP_TABLE_SIZE ig.rmcRmConfig.dwGrpTableSize
  81. #define GROUP_TABLE_HASH( Group, Mask ) \
  82. ( Group ? ( Group % ( GROUP_TABLE_SIZE - 1 ) + 1 ) : 0 )
  83. #define SOURCE_TABLE_SIZE ig.rmcRmConfig.dwSrcTableSize
  84. #define SOURCE_TABLE_HASH( Source, Mask ) \
  85. ( Source ? ( Source % ( SOURCE_TABLE_SIZE - 1 ) + 1 ) : 0 )
  86. #define TIMER_TABLE_SIZE ig.dwTimerQTableSize
  87. #define TIMER_TABLE_HASH( Group ) \
  88. ( ( Group ) % TIMER_TABLE_SIZE )
  89. //============================================================================
  90. // Max number of entries in the temp group list.
  91. // if more entries are added to the temp group list then
  92. // the temp group list is merged with the master group list
  93. //============================================================================
  94. #define TEMP_GROUP_LIST_MAXSIZE 16
  95. #define TEMP_SOURCE_LIST_MAXSIZE 16
  96. //============================================================================
  97. // macros to access list heads
  98. //============================================================================
  99. #define PROTOCOL_LIST_HEAD() &ig.mllProtocolList.leHead
  100. #define JOIN_LIST_HEAD() &ig.mllOutstandingJoinList.leHead
  101. #define IF_BUCKET_HEAD( i ) &ig.pmllIfHashTable[ (i) ].leHead
  102. #define ROUTE_BUCKET_HEAD( i ) &ig.pmllRouteHashTable[ (i) ].leHead
  103. #define GROUP_BUCKET_HEAD( i ) &ig.pmllGrpHashTable[ (i) ].leHead
  104. #define TEMP_GROUP_LIST_HEAD() &ig.mllTempGrpList.leHead
  105. #define MASTER_GROUP_LIST_HEAD() &ig.mllGrpList.leHead
  106. #define SOURCE_BUCKET_HEAD( a, b ) &(a)-> pleSrcHashTable[ (b) ]
  107. #define MASTER_SOURCE_LIST_HEAD(a) &(a)-> leSourceList
  108. #define TEMP_SOURCE_LIST_HEAD( a ) &(a)-> leTempSrcList
  109. #define TIMER_QUEUE_HANDLE( i ) ig.phTimerQHandleTable[ i ]
  110. //============================================================================
  111. // Macros to access router manager callback for kernel mode forwarder
  112. //============================================================================
  113. #define IS_ADD_MFE_CALLBACK() \
  114. ig.rmcRmConfig.pfnAddMfeCallback != NULL
  115. #define ADD_MFE_CALLBACK() \
  116. ( *(ig.rmcRmConfig.pfnAddMfeCallback) )
  117. #define IS_DELETE_MFE_CALLBACK()\
  118. ig.rmcRmConfig.pfnDeleteMfeCallback != NULL
  119. #define DELETE_MFE_CALLBACK() \
  120. ( *(ig.rmcRmConfig.pfnDeleteMfeCallback) )
  121. #define IS_GET_MFE_CALLBACK() \
  122. ig.rmcRmConfig.pfnGetMfeCallback != NULL
  123. #define GET_MFE_CALLBACK() \
  124. ( *(ig.rmcRmConfig.pfnGetMfeCallback) )
  125. #define IS_HAS_BOUNDARY_CALLBACK() \
  126. ig.rmcRmConfig.pfnHasBoundaryCallback != NULL
  127. #define HAS_BOUNDARY_CALLBACK() \
  128. ( *(ig.rmcRmConfig.pfnHasBoundaryCallback) )
  129. //============================================================================
  130. // memory-allocation constants and macros
  131. //============================================================================
  132. #define GLOBAL_HEAP ig.hIpMgmGlobalHeap
  133. #define MGM_ALLOC(size) HeapAlloc(GLOBAL_HEAP, 0, size)
  134. #define MGM_FREE(ptr) HeapFree(GLOBAL_HEAP, 0, ptr)
  135. //============================================================================
  136. // macros invoked when entering API or worker functions
  137. //============================================================================
  138. #define ENTER_MGM_API() EnterMgmAPI()
  139. #define ENTER_MGM_WORKER() EnterMgmWorker()
  140. //----------------------------------------------------------------------------
  141. // macro invoked when leaving API or worker functions
  142. //----------------------------------------------------------------------------
  143. #define LEAVE_MGM_API() LeaveMgmWorker()
  144. #define LEAVE_MGM_WORKER() LeaveMgmWorker()
  145. //============================================================================
  146. // constants used for tracing
  147. //============================================================================
  148. #define IPMGM_TRACE_ANY ((DWORD)0xFFFF0000 | TRACE_USE_MASK)
  149. #define IPMGM_TRACE_ENTER ((DWORD)0x00010000 | TRACE_USE_MASK)
  150. #define IPMGM_TRACE_LEAVE ((DWORD)0x00020000 | TRACE_USE_MASK)
  151. #define IPMGM_TRACE_TIMER ((DWORD)0x00040000 | TRACE_USE_MASK)
  152. #define IPMGM_TRACE_IF ((DWORD)0x00080000 | TRACE_USE_MASK)
  153. #define IPMGM_TRACE_GROUP ((DWORD)0x00100000 | TRACE_USE_MASK)
  154. #define IPMGM_TRACE_PROTOCOL ((DWORD)0x00200000 | TRACE_USE_MASK)
  155. #define IPMGM_TRACE_LOCK ((DWORD)0x00400000 | TRACE_USE_MASK)
  156. #define IPMGM_TRACE_LOCK_COUNT ((DWORD)0x00800000 | TRACE_USE_MASK)
  157. #define IPMGM_TRACE_START ((DWORD)0x01000000 | TRACE_USE_MASK)
  158. #define IPMGM_TRACE_STOP ((DWORD)0x02000000 | TRACE_USE_MASK)
  159. #define IPMGM_TRACE_PACKET ((DWORD)0x04000000 | TRACE_USE_MASK)
  160. #define IPMGM_TRACE_FORWARD ((DWORD)0x08000000 | TRACE_USE_MASK)
  161. #define IPMGM_TRACE_CALLBACK ((DWORD)0x10000000 | TRACE_USE_MASK)
  162. #define IPMGM_TRACE_ENUM ((DWORD)0x20000000 | TRACE_USE_MASK)
  163. #define IPMGM_TRACE_ROUTE ((DWORD)0x40000000 | TRACE_USE_MASK)
  164. #define IPMGM_TRACE_SCOPE ((DWORD)0x80000000 | TRACE_USE_MASK)
  165. //============================================================================
  166. //
  167. // macros used for locking and unlocking protected structures
  168. //
  169. //============================================================================
  170. #ifdef LOCK_DEBUG
  171. //
  172. // Sync functions/lock creation-deletion tracing
  173. //
  174. #define TRACELOCK0(a) \
  175. TracePrintfEx(TRACEID, IPMGM_TRACE_LOCK, a)
  176. #define TRACELOCK1(a, b) \
  177. TracePrintfEx(TRACEID, IPMGM_TRACE_LOCK, a, b)
  178. #define TRACELOCK2(a, b, c) \
  179. TracePrintfEx(TRACEID, IPMGM_TRACE_LOCK, a, b, c)
  180. #define TRACELOCK3(a, b, c, d) \
  181. TracePrintfEx(TRACEID, IPMGM_TRACE_LOCK, a, b, c, d)
  182. #define TRACECOUNT0(a) \
  183. TracePrintfEx(TRACEID, IPMGM_TRACE_LOCK_COUNT, a)
  184. #define TRACECOUNT1(a, b) \
  185. TracePrintfEx(TRACEID, IPMGM_TRACE_LOCK_COUNT, a, b)
  186. #define TRACECOUNT2(a, b, c) \
  187. TracePrintfEx(TRACEID, IPMGM_TRACE_LOCK_COUNT, a, b, c)
  188. #else
  189. #define TRACELOCK0(a)
  190. #define TRACELOCK1(a, b)
  191. #define TRACELOCK2(a, b, c)
  192. #define TRACELOCK3(a, b, c, d)
  193. #define TRACECOUNT0(a)
  194. #define TRACECOUNT1(a, b)
  195. #define TRACECOUNT2(a, b, c)
  196. #endif
  197. //
  198. // Protocol locks
  199. //
  200. #define ACQUIRE_PROTOCOL_LOCK_EXCLUSIVE() \
  201. { \
  202. TRACELOCK0( "Acquiring protocol lock exclusive" ); \
  203. AcquireWriteLock(&ig.mllProtocolList.pmrwlLock); \
  204. TRACELOCK0( "Acquired protocol lock exclusive" ); \
  205. }
  206. #define RELEASE_PROTOCOL_LOCK_EXCLUSIVE() \
  207. { \
  208. TRACELOCK0( "Releasing protocol lock exclusive" ); \
  209. ReleaseWriteLock(&ig.mllProtocolList.pmrwlLock); \
  210. TRACELOCK0( "Released protocol lock exclusive" ); \
  211. }
  212. #define ACQUIRE_PROTOCOL_LOCK_SHARED() \
  213. { \
  214. TRACELOCK0( "Acquiring protocol lock shared" ); \
  215. AcquireReadLock(&ig.mllProtocolList.pmrwlLock); \
  216. TRACELOCK0( "Acquired protocol lock shared" ); \
  217. }
  218. #define RELEASE_PROTOCOL_LOCK_SHARED() \
  219. { \
  220. TRACELOCK0( "Releasing protocol lock shared" ); \
  221. ReleaseReadLock(&ig.mllProtocolList.pmrwlLock); \
  222. TRACELOCK0( "Released protocol lock shared" ); \
  223. }
  224. //
  225. // scope boundaries lock
  226. //
  227. #define ACQUIRE_JOIN_LIST_LOCK_EXCLUSIVE() \
  228. { \
  229. TRACELOCK0( "Acquiring Join list lock exclusive" ); \
  230. AcquireWriteLock(&ig.mllOutstandingJoinList.pmrwlLock); \
  231. TRACELOCK0( "Acquired Join list lock exclusive" ); \
  232. }
  233. #define RELEASE_JOIN_LIST_LOCK_EXCLUSIVE() \
  234. { \
  235. TRACELOCK0( "Releasing join list lock exclusive" ); \
  236. ReleaseWriteLock(&ig.mllOutstandingJoinList.pmrwlLock); \
  237. TRACELOCK0( "Released join list lock exclusive" ); \
  238. }
  239. #define ACQUIRE_JOIN_LIST_LOCK_SHARED() \
  240. { \
  241. TRACELOCK0( "Acquiring join list lock shared" ); \
  242. AcquireReadLock(&ig.mllOutstandingJoinList.pmrwlLock); \
  243. TRACELOCK0( "Acquired join list lock shared" ); \
  244. }
  245. #define RELEASE_JOIN_LIST_LOCK_SHARED() \
  246. { \
  247. TRACELOCK0( "Releasing join list lock shared" ); \
  248. ReleaseReadLock(&ig.mllOutstandingJoinList.pmrwlLock); \
  249. TRACELOCK0( "Released join list lock shared" ); \
  250. }
  251. //
  252. // Interfaces locking
  253. //
  254. #define ACQUIRE_IF_LOCK_EXCLUSIVE( i ) \
  255. { \
  256. TRACELOCK1( "Acquiring interface lock exclusive : %d", i ); \
  257. AcquireWriteLock(&ig.pmllIfHashTable[ i ].pmrwlLock); \
  258. TRACELOCK1( "Acquired interface lock exclusive : %d", i ); \
  259. }
  260. #define RELEASE_IF_LOCK_EXCLUSIVE( i ) \
  261. { \
  262. TRACELOCK1( "Releasing interface lock exclusive : %d", i ); \
  263. ReleaseWriteLock(&ig.pmllIfHashTable[ i ].pmrwlLock); \
  264. TRACELOCK1( "Released interface lock exclusive : %d", i ); \
  265. }
  266. #define ACQUIRE_IF_LOCK_SHARED( i ) \
  267. { \
  268. TRACELOCK1( "Acquiring interface lock shared : %d", i ); \
  269. AcquireReadLock(&ig.pmllIfHashTable[ i ].pmrwlLock); \
  270. TRACELOCK1( "Acquired interface lock shared : %d", i ); \
  271. }
  272. #define RELEASE_IF_LOCK_SHARED( i ) \
  273. { \
  274. TRACELOCK1( "Releasing interface lock shared : %d", i ); \
  275. ReleaseReadLock(&ig.pmllIfHashTable[ i ].pmrwlLock); \
  276. TRACELOCK1( "Released interface lock shared : %d", i ); \
  277. }
  278. //
  279. // Route references lock
  280. //
  281. #define ACQUIRE_ROUTE_LOCK_EXCLUSIVE( p ) \
  282. { \
  283. TRACELOCK0( "Acquiring route lock exclusive" ); \
  284. AcquireWriteLock(&(p)->pmrwlLock); \
  285. TRACELOCK0( "Acquired route lock exclusive"); \
  286. }
  287. #define RELEASE_ROUTE_LOCK_EXCLUSIVE( p ) \
  288. { \
  289. TRACELOCK0( "Releasing route lock exclusive"); \
  290. ReleaseWriteLock(&(p)->pmrwlLock); \
  291. TRACELOCK0( "Released route lock exclusive" ); \
  292. }
  293. #define ACQUIRE_ROUTE_LOCK_SHARED( p ) \
  294. { \
  295. TRACELOCK0( "Acquiring route lock shared : %x"); \
  296. AcquireReadLock(&(p)->pmrwlLock); \
  297. TRACELOCK0( "Acquired route lock shared : %x"); \
  298. }
  299. #define RELEASE_ROUTE_LOCK_SHARED( p ) \
  300. { \
  301. TRACELOCK0( "Releasing route lock shared : %x"); \
  302. ReleaseReadLock(&(p)->pmrwlLock); \
  303. TRACELOCK0( "Released route lock shared : %x"); \
  304. }
  305. //
  306. // Group table locks
  307. //
  308. #define ACQUIRE_GROUP_LOCK_EXCLUSIVE( i ) \
  309. { \
  310. TRACELOCK1( "Acquiring group lock exclusive : %d", i ); \
  311. AcquireWriteLock(&ig.pmllGrpHashTable[ i ].pmrwlLock); \
  312. TRACELOCK1( "Acquired group lock exclusive : %d", i ); \
  313. }
  314. #define RELEASE_GROUP_LOCK_EXCLUSIVE( i ) \
  315. { \
  316. TRACELOCK1( "Releasing group lock exclusive : %d", i ); \
  317. ReleaseWriteLock(&ig.pmllGrpHashTable[ i ].pmrwlLock); \
  318. TRACELOCK1( "Released group lock exclusive : %d", i ); \
  319. }
  320. #define ACQUIRE_GROUP_LOCK_SHARED( i ) \
  321. { \
  322. TRACELOCK1( "Acquiring group lock shared : %d", i ); \
  323. AcquireReadLock(&ig.pmllGrpHashTable[ i ].pmrwlLock); \
  324. TRACELOCK1( "Acquired group lock shared : %d", i ); \
  325. }
  326. #define RELEASE_GROUP_LOCK_SHARED( i ) \
  327. { \
  328. TRACELOCK1( "Releasing group lock shared : %d", i ); \
  329. ReleaseReadLock(&ig.pmllGrpHashTable[ i ].pmrwlLock); \
  330. TRACELOCK1( "Released group lock shared : %d", i ); \
  331. }
  332. //
  333. // Master group list locks
  334. //
  335. #define ACQUIRE_MASTER_GROUP_LOCK_EXCLUSIVE() \
  336. { \
  337. TRACELOCK0( "Acquiring master group lock exclusive" ); \
  338. AcquireWriteLock(&ig.mllGrpList.pmrwlLock); \
  339. TRACELOCK0( "Acquired master group lock exclusive" ); \
  340. }
  341. #define RELEASE_MASTER_GROUP_LOCK_EXCLUSIVE() \
  342. { \
  343. TRACELOCK0( "Releasing master group lock exclusive" ); \
  344. ReleaseWriteLock(&ig.mllGrpList.pmrwlLock); \
  345. TRACELOCK0( "Released master group lock exclusive" ); \
  346. }
  347. #define ACQUIRE_MASTER_GROUP_LOCK_SHARED() \
  348. { \
  349. TRACELOCK0( "Acquiring master group lock shared" ); \
  350. AcquireReadLock(&ig.mllGrpList.pmrwlLock); \
  351. TRACELOCK0( "Acquired master group lock shared" ); \
  352. }
  353. #define RELEASE_MASTER_GROUP_LOCK_SHARED() \
  354. { \
  355. TRACELOCK0( "Releasing master group lock shared" ); \
  356. ReleaseReadLock(&ig.mllGrpList.pmrwlLock); \
  357. TRACELOCK0( "Released master group lock shared" ); \
  358. }
  359. //
  360. // Temp group list locks
  361. //
  362. #define ACQUIRE_TEMP_GROUP_LOCK_EXCLUSIVE() \
  363. { \
  364. TRACELOCK0( "Acquiring temp group lock exclusive" ); \
  365. AcquireWriteLock(&ig.mllTempGrpList.pmrwlLock); \
  366. TRACELOCK0( "Acquired temp group lock exclusive" ); \
  367. }
  368. #define RELEASE_TEMP_GROUP_LOCK_EXCLUSIVE() \
  369. { \
  370. TRACELOCK0( "Releasing temp group lock exclusive" ); \
  371. ReleaseWriteLock(&ig.mllTempGrpList.pmrwlLock); \
  372. TRACELOCK0( "Released temp group lock exclusive" ); \
  373. }
  374. #define ACQUIRE_TEMP_GROUP_LOCK_SHARED() \
  375. { \
  376. TRACELOCK0( "Acquiring temp group lock shared" ); \
  377. AcquireReadLock(&ig.mllTempGrpList.pmrwlLock); \
  378. TRACELOCK0( "Acquired temp group lock shared" ); \
  379. }
  380. #define RELEASE_TEMP_GROUP_LOCK_SHARED() \
  381. { \
  382. TRACELOCK0( "Releasing temp group lock shared" ); \
  383. ReleaseReadLock(&ig.mllTempGrpList.pmrwlLock); \
  384. TRACELOCK0( "Released temp group lock shared" ); \
  385. }
  386. //
  387. // Group entry locks
  388. //
  389. #define ACQUIRE_GROUP_ENTRY_LOCK_EXCLUSIVE( p ) \
  390. { \
  391. TRACELOCK3( "Acquiring group entry lock exclusive : %x, %d, %s", (p)-> dwGroupAddr, __LINE__, __FILE__ ); \
  392. AcquireWriteLock(&(p)->pmrwlLock); \
  393. TRACELOCK1( "Acquired group entry lock exclusive : %x", (p)-> dwGroupAddr ); \
  394. }
  395. #define RELEASE_GROUP_ENTRY_LOCK_EXCLUSIVE( p ) \
  396. { \
  397. TRACELOCK3( "Releasing group entry lock exclusive : %x, %d, %s", (p)-> dwGroupAddr,, __LINE__, __FILE__ ); \
  398. ReleaseWriteLock(&(p)->pmrwlLock); \
  399. TRACELOCK1( "Released group entry lock exclusive : %x", (p)-> dwGroupAddr ); \
  400. }
  401. #define ACQUIRE_GROUP_ENTRY_LOCK_SHARED( p ) \
  402. { \
  403. TRACELOCK3( "Acquiring group entry lock shared : %x, %d, %s", (p)-> dwGroupAddr, __LINE__, __FILE__ ); \
  404. AcquireReadLock(&(p)->pmrwlLock); \
  405. TRACELOCK1( "Acquired group entry lock shared : %x", (p)-> dwGroupAddr ); \
  406. }
  407. #define RELEASE_GROUP_ENTRY_LOCK_SHARED( p ) \
  408. { \
  409. TRACELOCK3( "Releasing group entry lock shared : %x, %d, %s", (p)-> dwGroupAddr, __LINE__, __FILE__ ); \
  410. ReleaseReadLock(&(p)->pmrwlLock); \
  411. TRACELOCK1( "Released group entry lock shared : %x", (p)-> dwGroupAddr ); \
  412. }
  413. #define ENTER_GLOBAL_SECTION() \
  414. EnterCriticalSection(&ig.csGlobal)
  415. #define LEAVE_GLOBAL_SECTION() \
  416. LeaveCriticalSection(&ig.csGlobal)
  417. #define ENTER_GLOBAL_LOCK_LIST_SECTION() \
  418. EnterCriticalSection(&ig.llStackOfLocks.csListLock)
  419. #define LEAVE_GLOBAL_LOCK_LIST_SECTION() \
  420. LeaveCriticalSection(&ig.llStackOfLocks.csListLock)
  421. //============================================================================
  422. // macros used for tracing
  423. //============================================================================
  424. #define TRACEID ig.dwTraceID
  425. #define TRACESTART() \
  426. TRACEID = TraceRegister("IPMGM")
  427. #define TRACESTOP() \
  428. TraceDeregister(TRACEID)
  429. #define TRACE0(l,a) \
  430. TracePrintfEx(TRACEID, IPMGM_TRACE_ ## l, a)
  431. #define TRACE1(l,a,b) \
  432. TracePrintfEx(TRACEID, IPMGM_TRACE_ ## l, a, b)
  433. #define TRACE2(l,a,b,c) \
  434. TracePrintfEx(TRACEID, IPMGM_TRACE_ ## l, a, b, c)
  435. #define TRACE3(l,a,b,c,d) \
  436. TracePrintfEx(TRACEID, IPMGM_TRACE_ ## l, a, b, c, d)
  437. #define TRACE4(l,a,b,c,d,e) \
  438. TracePrintfEx(TRACEID, IPMGM_TRACE_ ## l, a, b, c, d, e)
  439. #define TRACE5(l,a,b,c,d,e,f) \
  440. TracePrintfEx(TRACEID, IPMGM_TRACE_ ## l, a, b, c, d, e, f)
  441. #define TRACE6(l,a,b,c,d,e,f,g) \
  442. TracePrintfEx(TRACEID, IPMGM_TRACE_ ## l, a, b, c, d, e, f, g)
  443. #define TRACEDUMP(l,a,b,c) \
  444. TraceDumpEx(TRACEID,l,a,b,c,TRUE)
  445. //============================================================================
  446. // macros for debug trace only
  447. //============================================================================
  448. //
  449. // enum trace
  450. //
  451. #if ENUM_DBG
  452. #define TRACEENUM0 TRACE0
  453. #define TRACEENUM1 TRACE1
  454. #define TRACEENUM2 TRACE2
  455. #define TRACEENUM3 TRACE3
  456. #define TRACEENUM4 TRACE4
  457. #else
  458. #define TRACEENUM0(l,a)
  459. #define TRACEENUM1(l,a,b)
  460. #define TRACEENUM2(l,a,b,c)
  461. #define TRACEENUM3(l,a,b,c,d)
  462. #define TRACEENUM4(l,a,b,c,d,e)
  463. #endif
  464. //
  465. // forward trace
  466. //
  467. #if FORWARD_DBG
  468. #define TRACEFORWARD0 TRACE0
  469. #define TRACEFORWARD1 TRACE1
  470. #define TRACEFORWARD2 TRACE2
  471. #define TRACEFORWARD3 TRACE3
  472. #define TRACEFORWARD4 TRACE4
  473. #define TRACEFORWARD5 TRACE5
  474. #define TRACEFORWARD6 TRACE6
  475. #else
  476. #define TRACEFORWARD0(l,a)
  477. #define TRACEFORWARD1(l,a,b)
  478. #define TRACEFORWARD2(l,a,b,c)
  479. #define TRACEFORWARD3(l,a,b,c,d)
  480. #define TRACEFORWARD4(l,a,b,c,d,e)
  481. #define TRACEFORWARD5(l,a,b,c,d,e,f)
  482. #define TRACEFORWARD6(l,a,b,c,d,e,f,g)
  483. #endif
  484. //
  485. // group trace
  486. //
  487. #if GROUP_DBG
  488. #define TRACEGROUP0 TRACE0
  489. #define TRACEGROUP1 TRACE1
  490. #define TRACEGROUP2 TRACE2
  491. #define TRACEGROUP3 TRACE3
  492. #define TRACEGROUP4 TRACE4
  493. #define TRACEGROUP5 TRACE5
  494. #define TRACEGROUP6 TRACE6
  495. #else
  496. #define TRACEGROUP0(l,a)
  497. #define TRACEGROUP1(l,a,b)
  498. #define TRACEGROUP2(l,a,b,c)
  499. #define TRACEGROUP3(l,a,b,c,d)
  500. #define TRACEGROUP4(l,a,b,c,d,e)
  501. #define TRACEGROUP5(l,a,b,c,d,e,f)
  502. #define TRACEGROUP6(l,a,b,c,d,e,f,g)
  503. #endif
  504. //
  505. // Interface trace
  506. //
  507. #if IF_DBG
  508. #define TRACEIF0 TRACE0
  509. #define TRACEIF1 TRACE1
  510. #define TRACEIF2 TRACE2
  511. #define TRACEIF3 TRACE3
  512. #define TRACEIF4 TRACE4
  513. #define TRACEIF5 TRACE5
  514. #define TRACEIF6 TRACE6
  515. #else
  516. #define TRACEIF0(l,a)
  517. #define TRACEIF1(l,a,b)
  518. #define TRACEIF2(l,a,b,c)
  519. #define TRACEIF3(l,a,b,c,d)
  520. #define TRACEIF4(l,a,b,c,d,e)
  521. #define TRACEIF5(l,a,b,c,d,e,f)
  522. #define TRACEIF6(l,a,b,c,d,e,f,g)
  523. #endif
  524. //
  525. // packet trace
  526. //
  527. #if PACKET_DBG
  528. #define TRACEPACKET0 TRACE0
  529. #define TRACEPACKET1 TRACE1
  530. #define TRACEPACKET2 TRACE2
  531. #define TRACEPACKET3 TRACE3
  532. #define TRACEPACKET4 TRACE4
  533. #define TRACEPACKET5 TRACE5
  534. #define TRACEPACKET6 TRACE6
  535. #else
  536. #define TRACEPACKET0(l,a)
  537. #define TRACEPACKET1(l,a,b)
  538. #define TRACEPACKET2(l,a,b,c)
  539. #define TRACEPACKET3(l,a,b,c,d)
  540. #define TRACEPACKET4(l,a,b,c,d,e)
  541. #define TRACEPACKET5(l,a,b,c,d,e,f)
  542. #define TRACEPACKET6(l,a,b,c,d,e,f,g)
  543. #endif
  544. //
  545. // route trace
  546. //
  547. #if ROUTE_DBG
  548. #define TRACEROUTE0 TRACE0
  549. #define TRACEROUTE1 TRACE1
  550. #define TRACEROUTE2 TRACE2
  551. #define TRACEROUTE3 TRACE3
  552. #define TRACEROUTE4 TRACE4
  553. #define TRACEROUTE5 TRACE5
  554. #define TRACEROUTE6 TRACE6
  555. #else
  556. #define TRACEROUTE0(l,a)
  557. #define TRACEROUTE1(l,a,b)
  558. #define TRACEROUTE2(l,a,b,c)
  559. #define TRACEROUTE3(l,a,b,c,d)
  560. #define TRACEROUTE4(l,a,b,c,d,e)
  561. #define TRACEROUTE5(l,a,b,c,d,e,f)
  562. #define TRACEROUTE6(l,a,b,c,d,e,f,g)
  563. #endif
  564. //
  565. // scope trace
  566. //
  567. #if SCOPE_DBG
  568. #define TRACESCOPE0 TRACE0
  569. #define TRACESCOPE1 TRACE1
  570. #define TRACESCOPE2 TRACE2
  571. #define TRACESCOPE3 TRACE3
  572. #define TRACESCOPE4 TRACE4
  573. #define TRACESCOPE5 TRACE5
  574. #define TRACESCOPE6 TRACE6
  575. #else
  576. #define TRACESCOPE0(l,a)
  577. #define TRACESCOPE1(l,a,b)
  578. #define TRACESCOPE2(l,a,b,c)
  579. #define TRACESCOPE3(l,a,b,c,d)
  580. #define TRACESCOPE4(l,a,b,c,d,e)
  581. #define TRACESCOPE5(l,a,b,c,d,e,f)
  582. #define TRACESCOPE6(l,a,b,c,d,e,f,g)
  583. #endif
  584. //============================================================================
  585. // Event logging macros
  586. //============================================================================
  587. #define LOGLEVEL ig.dwLogLevel
  588. #define LOGHANDLE ig.hLogHandle
  589. #define LOGERR RouterLogError
  590. #define LOGWARN RouterLogWarning
  591. #define LOGINFO RouterLogInformation
  592. #define LOGWARNDATA RouterLogWarningData
  593. //
  594. // Error logging
  595. //
  596. #define LOGERR0(msg,err) \
  597. if (LOGLEVEL >= IPMGM_LOGGING_ERROR) \
  598. LOGERR(LOGHANDLE,IPMGMLOG_ ## msg,0,NULL,(err))
  599. #define LOGERR1(msg,a,err) \
  600. if (LOGLEVEL >= IPMGM_LOGGING_ERROR) \
  601. LOGERR(LOGHANDLE,IPMGMLOG_ ## msg,1,&(a),(err))
  602. #define LOGERR2(msg,a,b,err) \
  603. if (LOGLEVEL >= IPMGM_LOGGING_ERROR) { \
  604. LPSTR _asz[2] = { (a), (b) }; \
  605. LOGERR(LOGHANDLE,IPMGMLOG_ ## msg,2,_asz,(err)); \
  606. }
  607. #define LOGERR3(msg,a,b,c,err) \
  608. if (LOGLEVEL >= IPMGM_LOGGING_ERROR) { \
  609. LPSTR _asz[3] = { (a), (b), (c) }; \
  610. LOGERR(LOGHANDLE,IPMGMLOG_ ## msg,3,_asz,(err)); \
  611. }
  612. #define LOGERR4(msg,a,b,c,d,err) \
  613. if (LOGLEVEL >= IPMGM_LOGGING_ERROR) { \
  614. LPSTR _asz[4] = { (a), (b), (c), (d) }; \
  615. LOGERR(LOGHANDLE,IPMGMLOG_ ## msg,4,_asz,(err)); \
  616. }
  617. //
  618. // Warning logging
  619. //
  620. #define LOGWARN0(msg,err) \
  621. if (LOGLEVEL >= IPMGM_LOGGING_WARN) \
  622. LOGWARN(LOGHANDLE,IPMGMLOG_ ## msg,0,NULL,(err))
  623. #define LOGWARN1(msg,a,err) \
  624. if (LOGLEVEL >= IPMGM_LOGGING_WARN) \
  625. LOGWARN(LOGHANDLE,IPMGMLOG_ ## msg,1,&(a),(err))
  626. #define LOGWARN2(msg,a,b,err) \
  627. if (LOGLEVEL >= IPMGM_LOGGING_WARN) { \
  628. LPSTR _asz[2] = { (a), (b) }; \
  629. LOGWARN(LOGHANDLE,IPMGMLOG_ ## msg,2,_asz,(err)); \
  630. }
  631. #define LOGWARN3(msg,a,b,c,err) \
  632. if (LOGLEVEL >= IPMGM_LOGGING_WARN) { \
  633. LPSTR _asz[3] = { (a), (b), (c) }; \
  634. LOGWARN(LOGHANDLE,IPMGMLOG_ ## msg,3,_asz,(err)); \
  635. }
  636. #define LOGWARN4(msg,a,b,c,d,err) \
  637. if (LOGLEVEL >= IPMGM_LOGGING_WARN) { \
  638. LPSTR _asz[4] = { (a), (b), (c), (d) }; \
  639. LOGWARN(LOGHANDLE,IPMGMLOG_ ## msg,4,_asz,(err)); \
  640. }
  641. #define LOGWARNDATA2(msg,a,b,dw,buf) \
  642. if (LOGLEVEL >= IPMGM_LOGGING_WARN) { \
  643. LPSTR _asz[2] = { (a), (b) }; \
  644. LOGWARNDATA(LOGHANDLE,IPMGMLOG_ ## msg,2,_asz,(dw),(buf)); \
  645. }
  646. //
  647. // Information logging
  648. //
  649. #define LOGINFO0(msg,err) \
  650. if (LOGLEVEL >= IPMGM_LOGGING_INFO) \
  651. LOGINFO(LOGHANDLE,IPMGMLOG_ ## msg,0,NULL,(err))
  652. #define LOGINFO1(msg,a,err) \
  653. if (LOGLEVEL >= IPMGM_LOGGING_INFO) \
  654. LOGINFO(LOGHANDLE,IPMGMLOG_ ## msg,1,&(a),(err))
  655. #define LOGINFO2(msg,a,b,err) \
  656. if (LOGLEVEL >= IPMGM_LOGGING_INFO) { \
  657. LPSTR _asz[2] = { (a), (b) }; \
  658. LOGINFO(LOGHANDLE,IPMGMLOG_ ## msg,2,_asz,(err)); \
  659. }
  660. #define LOGINFO3(msg,a,b,c,err) \
  661. if (LOGLEVEL >= IPMGM_LOGGING_INFO) { \
  662. LPSTR _asz[3] = { (a), (b), (c) }; \
  663. LOGINFO(LOGHANDLE,IPMGMLOG_ ## msg,3,_asz,(err)); \
  664. }
  665. #define LOGINFO4(msg,a,b,c,d,err) \
  666. if (LOGLEVEL >= IPMGM_LOGGING_INFO) { \
  667. LPSTR _asz[4] = { (a), (b), (c), (d) }; \
  668. LOGINFO(LOGHANDLE,IPMGMLOG_ ## msg,4,_asz,(err)); \
  669. }
  670. //============================================================================
  671. // Macros to access routing protocol callbacks
  672. //============================================================================
  673. #define IS_JOIN_ALERT( p ) \
  674. (p)-> rpcProtocolConfig.pfnJoinAlertCallback != NULL
  675. #define IS_PRUNE_ALERT( p ) \
  676. (p)-> rpcProtocolConfig.pfnPruneAlertCallback != NULL
  677. #define IS_LOCAL_JOIN_ALERT( p ) \
  678. (p)-> rpcProtocolConfig.pfnLocalJoinCallback != NULL
  679. #define IS_LOCAL_LEAVE_ALERT( p ) \
  680. (p)-> rpcProtocolConfig.pfnLocalLeaveCallback != NULL
  681. #define IS_RPF_CALLBACK( p ) \
  682. (p)-> rpcProtocolConfig.pfnRpfCallback != NULL
  683. #define IS_CREATION_ALERT( p ) \
  684. (p)-> rpcProtocolConfig.pfnCreationAlertCallback != NULL
  685. #define RPF_CALLBACK( p ) \
  686. ( *( (p)-> rpcProtocolConfig.pfnRpfCallback ) )
  687. #if CALLBACK_DEBUG
  688. #define JOIN_ALERT( p ) \
  689. { \
  690. TRACE2( \
  691. CALLBACK, "Invoked Join Alert for protocol %x, %x", \
  692. (p)-> dwProtocolId, (p)-> dwComponentId \
  693. ); \
  694. } \
  695. ( *( (p)-> rpcProtocolConfig.pfnJoinAlertCallback ) )
  696. #define PRUNE_ALERT( p ) \
  697. { \
  698. TRACE2( \
  699. CALLBACK, "Invoked Prune Alert for protocol %x, %x", \
  700. (p)-> dwProtocolId, (p)-> dwComponentId \
  701. ); \
  702. } \
  703. ( *( (p)-> rpcProtocolConfig.pfnPruneAlertCallback ) )
  704. #define LOCAL_JOIN_ALERT( p ) \
  705. { \
  706. TRACE2( \
  707. CALLBACK, "Invoked Local Join Alert for protocol %x, %x", \
  708. (p)-> dwProtocolId, (p)-> dwComponentId \
  709. ); \
  710. } \
  711. ( *( (p)-> rpcProtocolConfig.pfnLocalJoinCallback ) )
  712. #define LOCAL_LEAVE_ALERT( p ) \
  713. { \
  714. TRACE2( \
  715. CALLBACK, "Invoked Local Leave Alert for protocol %x, %x", \
  716. (p)-> dwProtocolId, (p)-> dwComponentId \
  717. ); \
  718. } \
  719. ( *( (p)-> rpcProtocolConfig.pfnLocalLeaveCallback ) )
  720. #define CREATION_ALERT( p ) \
  721. { \
  722. TRACE2( \
  723. CALLBACK, "Invoked Creation Alert for protocol %x, %x", \
  724. (p)-> dwProtocolId, (p)-> dwComponentId \
  725. ); \
  726. } \
  727. ( *( (p)-> rpcProtocolConfig.pfnCreationAlertCallback ) )
  728. #define IGMP_DISABLE_CALLBACK( p ) \
  729. { \
  730. TRACE0( \
  731. CALLBACK, "Invoked Disable IGMP Alert ", \
  732. ); \
  733. } \
  734. ( *( (p)-> rpcProtocolConfig.pfnDisableIgmpCallback ) )
  735. #define IGMP_ENABLE_CALLBACK( p ) \
  736. { \
  737. TRACE0( \
  738. CALLBACK, "Invoked Enable IGMP Alert ", \
  739. ); \
  740. } \
  741. ( *( (p)-> rpcProtocolConfig.pfnEnableIgmpCallback ) )
  742. #else
  743. #define JOIN_ALERT( p ) \
  744. ( *( (p)-> rpcProtocolConfig.pfnJoinAlertCallback ) )
  745. #define PRUNE_ALERT( p ) \
  746. ( *( (p)-> rpcProtocolConfig.pfnPruneAlertCallback ) )
  747. #define LOCAL_JOIN_ALERT( p ) \
  748. ( *( (p)-> rpcProtocolConfig.pfnLocalJoinCallback ) )
  749. #define LOCAL_LEAVE_ALERT( p ) \
  750. ( *( (p)-> rpcProtocolConfig.pfnLocalLeaveCallback ) )
  751. #define CREATION_ALERT( p ) \
  752. ( *( (p)-> rpcProtocolConfig.pfnCreationAlertCallback ) )
  753. #define IGMP_DISABLE_CALLBACK( p ) \
  754. ( *( (p)-> rpcProtocolConfig.pfnDisableIgmpCallback ) )
  755. #define IGMP_ENABLE_CALLBACK( p ) \
  756. ( *( (p)-> rpcProtocolConfig.pfnEnableIgmpCallback ) )
  757. #endif
  758. //============================================================================
  759. // Client count and worker thread related stuff.
  760. //============================================================================
  761. DWORD
  762. QueueMgmWorker(
  763. WORKERFUNCTION pFunction,
  764. PVOID pContext
  765. );
  766. BOOL
  767. EnterMgmAPI(
  768. );
  769. BOOL
  770. EnterMgmWorker(
  771. );
  772. VOID
  773. LeaveMgmWorker(
  774. );
  775. VOID
  776. DisplayGroupTable(
  777. );
  778. extern RTM_ENTITY_INFO g_reiRtmEntity;
  779. extern RTM_REGN_PROFILE g_rrpRtmProfile;
  780. extern RTM_ENTITY_HANDLE g_hRtmHandle;
  781. extern RTM_NOTIFY_HANDLE g_hNotificationHandle;
  782. extern RTM_REGN_PROFILE g_rrpRtmProfile;
  783. #endif // _IPMGM_H_