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.

264 lines
7.9 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. ripint.h
  5. Abstract:
  6. This module contains the definitions of the internal control structures
  7. used by the rip protocol module
  8. Author:
  9. Stefan Solomon 06/22/1995
  10. Revision History:
  11. --*/
  12. #ifndef _RIPINT_
  13. #define _RIPINT_
  14. //
  15. //*** RIP Internal Structures ***
  16. //
  17. // internal filter control block
  18. typedef struct _RIP_ROUTE_FILTER_INFO_I {
  19. ULONG Network;
  20. ULONG Mask;
  21. } RIP_ROUTE_FILTER_INFO_I, *PRIP_ROUTE_FILTER_INFO_I;
  22. typedef struct _RIP_IF_FILTERS_I {
  23. BOOL SupplyFilterAction; // TRUE - Pass, FALSE - Don't Pass
  24. ULONG SupplyFilterCount;
  25. BOOL ListenFilterAction; // TRUE - Pass, FALSE - Don't Pass
  26. ULONG ListenFilterCount;
  27. RIP_ROUTE_FILTER_INFO_I RouteFilterI[1];
  28. } RIP_IF_FILTERS_I, *PRIP_IF_FILTERS_I;
  29. // Interface Control Block
  30. typedef struct _ICB {
  31. ULONG InterfaceIndex;
  32. LIST_ENTRY IfListLinkage; // linkage in if list ordered by Index
  33. LIST_ENTRY IfHtLinkage; // linkage in if hash table
  34. LIST_ENTRY AdapterHtLinkage; // linkage in adapter hash table
  35. RIP_IF_INFO IfConfigInfo; // config info
  36. RIP_IF_STATS IfStats; // statistics
  37. ULONG RefCount; // reference counter
  38. IPX_ADAPTER_BINDING_INFO AdapterBindingInfo;
  39. CRITICAL_SECTION InterfaceLock;
  40. BOOL Discarded; // if the if CB is queued on discarded list
  41. LIST_ENTRY ChangesBcastQueue; // queue of bcast work items (packets) to be sent
  42. LIST_ENTRY AuxLinkage; // auxiliary linkage in temp queues
  43. USHORT LinkTickCount; // tick count equiv. of link speed
  44. ULONG IpxIfAdminState; // admin state of the IPX interface
  45. NET_INTERFACE_TYPE InterfaceType;
  46. UCHAR RemoteWkstaInternalNet[4]; // internal net of the remote client
  47. PRIP_IF_FILTERS_I RipIfFiltersIp; // pointer to the if filters block
  48. WCHAR InterfaceName[1];
  49. } ICB, *PICB;
  50. // Work Item
  51. typedef enum _WORK_ITEM_TYPE {
  52. PERIODIC_BCAST_PACKET_TYPE,
  53. GEN_RESPONSE_PACKET_TYPE,
  54. CHANGE_BCAST_PACKET_TYPE,
  55. UPDATE_STATUS_CHECK_TYPE,
  56. PERIODIC_GEN_REQUEST_TYPE,
  57. // if you change the order/number of work items above this line you
  58. // must change also the WorkItemHandler table
  59. RECEIVE_PACKET_TYPE,
  60. SEND_PACKET_TYPE,
  61. START_CHANGES_BCAST_TYPE,
  62. SHUTDOWN_INTERFACES_TYPE,
  63. DEBUG_TYPE
  64. } WORK_ITEM_TYPE;
  65. typedef struct _ENUM_ROUTES_SPECIFIC {
  66. HANDLE RtmEnumerationHandle;
  67. } ENUM_ROUTES_SPECIFIC, *PENUM_ROUTES_SPECIFIC;
  68. typedef struct _UPDATE_SPECIFIC {
  69. ULONG UpdatedRoutesCount;
  70. ULONG UpdateRetriesCount;
  71. ULONG OldRipListen; // saved Listen state when updating routes
  72. ULONG OldRipInterval; // saved update interval when updating routes
  73. } UPDATE_SPECIFIC, *PUPDATE_SPECIFIC;
  74. typedef struct _SHUTDOWN_INTERFACES_SPECIFIC {
  75. ULONG ShutdownState;
  76. } SHUTDOWN_INTERFACES_SPECIFIC, *PSHUTDOWN_INTERFACES_SPECIFIC;
  77. typedef struct _DEBUG_SPECIFIC {
  78. ULONG DebugData;
  79. } DEBUG_SPECIFIC, *PDEBUG_SPECIFIC;
  80. // shutdown states definitions
  81. #define SHUTDOWN_START 0
  82. #define SHUTDOWN_STATUS_CHECK 1
  83. typedef union _WORK_ITEM_SPECIFIC {
  84. ENUM_ROUTES_SPECIFIC WIS_EnumRoutes;
  85. UPDATE_SPECIFIC WIS_Update;
  86. SHUTDOWN_INTERFACES_SPECIFIC WIS_ShutdownInterfaces;
  87. DEBUG_SPECIFIC WIS_Debug;
  88. } WORK_ITEM_SPECIFIC, *PWORK_ITEM_SPECIFIC;
  89. typedef struct _WORK_ITEM {
  90. LIST_ENTRY Linkage; // linkage in the worker's work queue
  91. WORK_ITEM_TYPE Type; // work item type
  92. DWORD TimeStamp; // used by the send complete to stamp for interpacket gap calc.
  93. DWORD DueTime; // use for timer queue
  94. PICB icbp; // ptr to the referenced if CB
  95. ULONG AdapterIndex;
  96. DWORD IoCompletionStatus;
  97. WORK_ITEM_SPECIFIC WorkItemSpecific;
  98. OVERLAPPED Overlapped;
  99. ADDRESS_RESERVED AddressReserved;
  100. UCHAR Packet[1];
  101. } WORK_ITEM, *PWORK_ITEM;
  102. // event and message queued for the router manager
  103. typedef struct _RIP_MESSAGE {
  104. LIST_ENTRY Linkage;
  105. ROUTING_PROTOCOL_EVENTS Event;
  106. MESSAGE Result;
  107. } RIP_MESSAGE, *PRIP_MESSAGE;
  108. //
  109. //*** Constants ***
  110. //
  111. // Worker Thread Wait Objects Indices
  112. #define TIMER_EVENT 0
  113. #define REPOST_RCV_PACKETS_EVENT 1
  114. //#define WORKERS_QUEUE_EVENT 2
  115. #define RTM_EVENT 2
  116. #define RIP_CHANGES_EVENT 3
  117. #define TERMINATE_WORKER_EVENT 4
  118. #define MAX_WORKER_THREAD_OBJECTS 5
  119. // invalid (unbound) adapter
  120. #define INVALID_ADAPTER_INDEX 0xFFFFFFFF
  121. // size of interfaces and adapter hash tables
  122. #define IF_INDEX_HASH_TABLE_SIZE 32
  123. #define ADAPTER_INDEX_HASH_TABLE_SIZE 32
  124. // RIP packet length values
  125. #define FULL_PACKET RIP_PACKET_LEN
  126. #define EMPTY_PACKET RIP_INFO
  127. // Time interval to check and broadcast changes (in milisec)
  128. #define CHANGES_BCAST_TIME 1000
  129. //
  130. //*** Macros ***
  131. #define ACQUIRE_DATABASE_LOCK EnterCriticalSection(&DbaseCritSec)
  132. #define RELEASE_DATABASE_LOCK LeaveCriticalSection(&DbaseCritSec)
  133. #define ACQUIRE_QUEUES_LOCK EnterCriticalSection(&QueuesCritSec)
  134. #define RELEASE_QUEUES_LOCK LeaveCriticalSection(&QueuesCritSec)
  135. #define ACQUIRE_RIP_CHANGED_LIST_LOCK EnterCriticalSection(&RipChangedListCritSec)
  136. #define RELEASE_RIP_CHANGED_LIST_LOCK LeaveCriticalSection(&RipChangedListCritSec)
  137. #define ACQUIRE_IF_LOCK(icbp) EnterCriticalSection(&(icbp)->InterfaceLock)
  138. #define RELEASE_IF_LOCK(icbp) LeaveCriticalSection(&(icbp)->InterfaceLock)
  139. // macro to assess if time1 is later then time2 when both are ulong with wrap around
  140. #define IsLater(time1, time2) (((time1) - (time2)) < MAXULONG/2)
  141. // enqueue a work item in timer queue and increment the interface ref count
  142. #define IfRefStartWiTimer(wip, delay) (wip)->icbp->RefCount++;\
  143. StartWiTimer((wip), (delay));
  144. // Update Time and Route Time To Live definitions
  145. #define PERIODIC_UPDATE_INTERVAL_SECS(icbp) (icbp)->IfConfigInfo.PeriodicUpdateInterval // in seconds
  146. #define PERIODIC_UPDATE_INTERVAL_MILISECS(icbp) (PERIODIC_UPDATE_INTERVAL_SECS(icbp)) * 1000
  147. #define AGE_INTERVAL_MULTIPLIER(icbp) (icbp)->IfConfigInfo.AgeIntervalMultiplier
  148. #define ROUTE_TIME_TO_LIVE_SECS(icbp) (AGE_INTERVAL_MULTIPLIER(icbp)) * (PERIODIC_UPDATE_INTERVAL_SECS(icbp))
  149. #define CHECK_UPDATE_TIME_MILISECS (CheckUpdateTime*1000)
  150. //
  151. //*** Global Variables ***
  152. //
  153. extern CRITICAL_SECTION DbaseCritSec;
  154. extern CRITICAL_SECTION QueuesCritSec;
  155. extern CRITICAL_SECTION RipChangedListCritSec;
  156. extern ULONG RipOperState;
  157. extern LIST_ENTRY IndexIfList;
  158. extern LIST_ENTRY IfIndexHt[IF_INDEX_HASH_TABLE_SIZE];
  159. extern LIST_ENTRY AdapterIndexHt[ADAPTER_INDEX_HASH_TABLE_SIZE];
  160. extern LIST_ENTRY DiscardedIfList;
  161. extern CRITICAL_SECTION QueuesCritSec;
  162. extern ULONG RcvPostedCount;
  163. extern LIST_ENTRY RepostRcvPacketsQueue;
  164. extern LIST_ENTRY RipMessageQueue;
  165. extern HANDLE WorkerThreadObjects[MAX_WORKER_THREAD_OBJECTS];
  166. //extern LIST_ENTRY WorkersQueue;
  167. extern LIST_ENTRY TimerQueue;
  168. extern BOOL DestroyStartChangesBcastWi;
  169. extern ULONG WorkItemsCount;
  170. extern ULONG TimerTimeout;
  171. extern ULONG RipOperState;
  172. extern UCHAR bcastnet[4];
  173. extern UCHAR bcastnode[6];
  174. extern ULONG RcvPostedCount;
  175. extern ULONG SendPostedCount;
  176. extern UCHAR nullnet[4];
  177. extern HANDLE RipSocketHandle;
  178. extern HANDLE IoCompletionPortHandle;
  179. extern ULONG RipFiltersCount;
  180. extern ULONG SendGenReqOnWkstaDialLinks;
  181. extern ULONG CheckUpdateTime;
  182. #endif