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.

269 lines
6.3 KiB

  1. //=============================================================================
  2. // Copyright (c) 1997 Microsoft Corporation
  3. // File Name: global.h
  4. //
  5. // Abstract:
  6. // This file contains declarations for the global variables
  7. // and some global #defines.
  8. //
  9. // Author: K.S.Lokesh (lokeshs@) 11-1-97
  10. //
  11. //=============================================================================
  12. #ifndef _IGMP_H_
  13. #define _IGMP_H_
  14. //------------------------------------------------------------------------------
  15. // SOME GLOBAL #DEFINES
  16. //------------------------------------------------------------------------------
  17. // log warning every 60 min if ver-1 router present when my router is ver-2
  18. #define OTHER_VER_ROUTER_WARN_INTERVAL 60
  19. //
  20. // the router remains in ver-1 for 400secs after hearing from a ver-1 router
  21. //
  22. #define IGMP_VER1_RTR_PRESENT_TIMEOUT 40000L
  23. //
  24. // the default size set for local mib enumeration.
  25. //
  26. #define MIB_DEFAULT_BUFFER_SIZE 500
  27. //
  28. // for the first 5 sockets, I bind them to different event objects
  29. //
  30. #define NUM_SINGLE_SOCKET_EVENTS 5
  31. //
  32. // at most 30 sockets will be bound to the same event.
  33. //
  34. #define MAX_SOCKETS_PER_EVENT 30
  35. //
  36. // various codes describing states of igmp
  37. //
  38. typedef enum _IGMP_STATUS_CODE {
  39. IGMP_STATUS_STARTING = 100,
  40. IGMP_STATUS_RUNNING = 101,
  41. IGMP_STATUS_STOPPING = 102,
  42. IGMP_STATUS_STOPPED = 103
  43. } IGMP_STATUS_CODE, *PIGMP_STATUS_CODE;
  44. //------------------------------------------------------------------------------
  45. //
  46. // struct: IGMP_GLOBAL
  47. //
  48. // The critical section IGMP_GLOBAL::CS protects the fields Status,
  49. // ActivityCount and ActivitySemaphore.
  50. // Changes: if any new fields are added, make sure that StartProtocol() takes
  51. // appropriate action of its value being reset if StartProtocol() is called
  52. // immediately after StopProtocol().
  53. // Locks for ProxyIfEntry: take the lock on the interface, and then check
  54. // again if the g_pProxyIfEntry value has been changed.
  55. //
  56. // Note: if any new field is added, you might have to reset it in StartProtocol
  57. //------------------------------------------------------------------------------
  58. // used during cleanup to see what all structures need to be deleted
  59. extern DWORD g_Initialized;
  60. //
  61. // Interface table: IF_HASHTABLE_SZ set in table.h to 256
  62. // Contains the hash table, lists, etc.
  63. //
  64. extern PIGMP_IF_TABLE g_pIfTable;
  65. // group table: GROUP_HASH_TABLE_SZ set in table.h to 256
  66. extern PGROUP_TABLE g_pGroupTable;
  67. // defined in table.h. contains LoggingLevel and RasClientStats
  68. extern GLOBAL_CONFIG g_Config;
  69. // defined in table.h. contains Current-Added GroupMemberships
  70. extern IGMP_GLOBAL_STATS g_Info;
  71. //
  72. // list of sockets (1st 4 interfaces will be bound to different sockets).
  73. // After that, a socket will be created for every 30 interfaces
  74. // Most of the operations take read lock (input packet).
  75. //
  76. extern LIST_ENTRY g_ListOfSocketEvents;
  77. extern READ_WRITE_LOCK g_SocketsRWLock;
  78. // enum lock
  79. extern READ_WRITE_LOCK g_EnumRWLock;
  80. // Igmp global timer. defined in igmptimer.h
  81. extern IGMP_TIMER_GLOBAL g_TimerStruct;
  82. //
  83. // MGMhandle for igmp router and proxy.
  84. //
  85. extern HANDLE g_MgmIgmprtrHandle;
  86. extern HANDLE g_MgmProxyHandle;
  87. extern CRITICAL_SECTION g_ProxyAlertCS;
  88. extern LIST_ENTRY g_ProxyAlertsList;
  89. //------------------------------------------------------------------------------
  90. // proxy interface.
  91. //
  92. // For accessing proxy Interface,
  93. // 1. tmpVar = g_ProxyIfIndex.
  94. // 2. Read/WriteLockInterface(tmpVar).
  95. // 3. check(tmpVar==g_ProxyIfIndex). If FALSE, UnlockInterface using tmpVar
  96. // as index, and goto 1 and try again.
  97. // 4. if TRUE, g_ProxyIfEntry is valid for use. Release IF lock when done.
  98. //
  99. // While deleting, the interface is write locked and g_ProxyIfIndex is
  100. // changed using interlocked operation
  101. //
  102. // most of the operations for the proxy interface involve creating/deleting
  103. // group entries and (un)binding the Mcast group from the socket. The
  104. // processing being less, I dont create dynamic lock for each bucket,
  105. // also no point creating a ProxyHT_CS. I just take a write lock for the
  106. // interface. Change this if required. However dynamic locking would require
  107. // additional 3 lockings in addition to interface locking.
  108. //------------------------------------------------------------------------------
  109. extern DWORD g_ProxyIfIndex;
  110. extern PIF_TABLE_ENTRY g_pProxyIfEntry;
  111. #define PROXY_HASH_TABLE_SZ 128
  112. //
  113. // ras interface
  114. //
  115. extern DWORD g_RasIfIndex;
  116. extern PIF_TABLE_ENTRY g_pRasIfEntry;
  117. //
  118. // global lock:
  119. // protects g_ActivitySemaphore, g_ActivityCount, g_RunningStatus
  120. //
  121. extern CRITICAL_SECTION g_CS;
  122. //
  123. // contains list of free dynamic CS locks and the MainLock
  124. //
  125. extern DYNAMIC_LOCKS_STORE g_DynamicCSStore;
  126. extern DYNAMIC_LOCKS_STORE g_DynamicRWLStore;
  127. //
  128. // used to know how many active threads are running
  129. // protected by g_CS
  130. //
  131. extern HANDLE g_ActivitySemaphore;
  132. extern LONG g_ActivityCount;
  133. extern DWORD g_RunningStatus;
  134. extern HINSTANCE g_DllHandle;
  135. // rtm event and queue
  136. extern HANDLE g_RtmNotifyEvent;
  137. extern LOCKED_LIST g_RtmQueue;
  138. extern HANDLE g_Heap;
  139. extern DWORD g_TraceId;
  140. extern HANDLE g_LogHandle;
  141. // global variable used to assign unique ids for mib enumeration
  142. extern USHORT g_GlobalIfGroupEnumSignature;
  143. #ifdef MIB_DEBUG
  144. extern DWORD g_MibTraceId;
  145. extern IGMP_TIMER_ENTRY g_MibTimer;
  146. #endif
  147. // IGMP_GLOBAL
  148. //------------------------------------------------------------------------------
  149. // type definitions for event message queue
  150. //------------------------------------------------------------------------------
  151. typedef struct _EVENT_QUEUE_ENTRY {
  152. ROUTING_PROTOCOL_EVENTS EventType;
  153. MESSAGE Msg;
  154. LIST_ENTRY Link;
  155. } EVENT_QUEUE_ENTRY, *PEVENT_QUEUE_ENTRY;
  156. DWORD
  157. EnqueueEvent(
  158. PLOCKED_LIST pQueue,
  159. ROUTING_PROTOCOL_EVENTS EventType,
  160. MESSAGE Msg
  161. );
  162. DWORD
  163. DequeueEvent(
  164. PLOCKED_LIST pQueue,
  165. ROUTING_PROTOCOL_EVENTS *pEventType,
  166. PMESSAGE pResult
  167. );
  168. #endif // #ifndef _IGMP_H_