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.

195 lines
6.2 KiB

  1. /*++
  2. Copyright (c) 1997 - 98, Microsoft Corporation
  3. Module Name:
  4. rtmchng.h
  5. Abstract:
  6. Contains defintions related to change
  7. notification registrations to entities
  8. registered with the RTM.
  9. Author:
  10. Chaitanya Kodeboyina (chaitk) 10-Sep-1998
  11. Revision History:
  12. --*/
  13. #ifndef __ROUTING_RTMCHNG_H__
  14. #define __ROUTING_RTMCHNG_H__
  15. //
  16. // Constants used in change notification processing
  17. //
  18. #define TIMER_CALLBACK_FREQUENCY 1000
  19. #define MAX_DESTS_TO_PROCESS_ONCE 16
  20. //
  21. // Change type info must be consistent
  22. // with this information in rtmv2.h
  23. //
  24. // Change types that we support
  25. #define RTM_CHANGE_TYPE_ID_ALL 0
  26. #define RTM_CHANGE_TYPE_ID_BEST 1
  27. #define RTM_CHANGE_TYPE_ID_FORWARDING 2
  28. #define RTM_CHANGE_TYPES_MASK 0x0007
  29. //
  30. // Queue data structure used below
  31. //
  32. typedef struct _QUEUE
  33. {
  34. UINT Front;
  35. UINT Rear;
  36. UINT Size;
  37. PVOID Array[1];
  38. } QUEUE, *PQUEUE;
  39. //
  40. // Change Notification Info Block
  41. //
  42. typedef struct _NOTIFY_INFO
  43. {
  44. OPEN_HEADER NotifyHeader; // Signature, Type and Reference Count
  45. PENTITY_INFO OwningEntity; // Entity that opened this notification
  46. RTM_VIEW_SET TargetViews; // Views that we are interested in
  47. UINT NumberOfViews; // Num. of views we are interested in
  48. RTM_NOTIFY_FLAGS ChangeTypes; // Change types we are interested in
  49. INT CNIndex; // Index for this CN registration
  50. CRITICAL_SECTION NotifyLock; // Lock that serializes ops on CN
  51. HANDLE NotifyContext; // Context for the new changes callback
  52. QUEUE NotifyDests; // Dests to be notified to this CN
  53. }
  54. NOTIFY_INFO, *PNOTIFY_INFO;
  55. //
  56. // Macros for testing, setting and reseting CN related bits
  57. //
  58. #define IS_BIT_SET(Value, Bit) (Value & (1 << (Bit)))
  59. #define SET_BIT(Value, Bit) (Value |= (1 << (Bit)))
  60. #define RESET_BIT(Value, Bit) (Value &= ~(1 << (Bit)))
  61. #define LOCKED_SET_BIT(Value, BitIndex) \
  62. InterlockedExchangeAdd((PLONG) &(Value), +(1 << (BitIndex)))
  63. #define LOCKED_RESET_BIT(Value, BitIndex) \
  64. InterlockedExchangeAdd((PLONG) &(Value), -(1 << (BitIndex)))
  65. //
  66. // Macros for acquiring various locks defined in this file
  67. //
  68. #define ACQUIRE_CHANGE_NOTIFICATION_LOCK(Notification) \
  69. ACQUIRE_LOCK(&Notification->NotifyLock)
  70. #define RELEASE_CHANGE_NOTIFICATION_LOCK(Notification) \
  71. RELEASE_LOCK(&Notification->NotifyLock)
  72. //
  73. // Other misc macros
  74. //
  75. #define CHANGE_LIST_TO_INSERT(Dest) \
  76. (UINT)(((*(ULONG *)&Dest->DestAddress.AddrBits) >> 8) \
  77. % NUM_CHANGED_DEST_LISTS) \
  78. //
  79. // Queue manipulation macros
  80. //
  81. #define InitializeQueue(Q, N) \
  82. (Q)->Front = 0; \
  83. (Q)->Rear = 0; \
  84. (Q)->Size = (N); \
  85. #define IsQueueEmpty(Q) \
  86. ((Q)->Front == (Q)->Rear) \
  87. #define EnqueueItem(Q, I, S) \
  88. { \
  89. UINT _R_; \
  90. \
  91. _R_ = ((Q)->Rear + 1) % (Q)->Size; \
  92. \
  93. if ((Q)->Front == (_R_)) \
  94. { \
  95. (S) = TRUE; \
  96. } \
  97. else \
  98. { \
  99. (Q)->Rear = (_R_); \
  100. \
  101. (Q)->Array[(Q)->Rear] = I; \
  102. \
  103. (S) = FALSE; \
  104. } \
  105. } \
  106. #define DequeueItem(Q, I) \
  107. \
  108. if ((Q)->Front == (Q)->Rear) \
  109. { \
  110. (*(I)) = NULL; \
  111. } \
  112. else \
  113. { \
  114. ((Q)->Front)++; \
  115. \
  116. ((Q)->Front) %= (Q)->Size; \
  117. \
  118. (*(I)) = (Q)->Array[(Q)->Front]; \
  119. } \
  120. //
  121. // Change Notification Helper Functions
  122. //
  123. DWORD
  124. ComputeCNsToBeNotified (
  125. IN PADDRFAM_INFO AddrFamInfo,
  126. IN DWORD DestMarkedBits,
  127. IN DWORD *ViewsForChangeType
  128. );
  129. DWORD
  130. AddToChangedDestLists (
  131. IN PADDRFAM_INFO AddrFamInfo,
  132. IN PDEST_INFO Dest,
  133. IN ULONG NotifyCNs
  134. );
  135. VOID
  136. NTAPI
  137. ProcessChangedDestLists (
  138. IN PVOID Context,
  139. IN BOOLEAN TimeOut
  140. );
  141. #endif //__ROUTING_RTMCHNG_H__