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.

558 lines
13 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. routing\ip\rtrmgr\iprtrmgr.h
  5. Abstract:
  6. Header for IP Router Manager
  7. Revision History:
  8. Gurdeep Singh Pall 6/8/95 Created
  9. --*/
  10. #ifndef __RTRMGR_IPRTRMGR_H__
  11. #define __RTRMGR_IPRTRMGR_H__
  12. //
  13. // Router State
  14. //
  15. typedef enum _RouterOperationalState
  16. {
  17. RTR_STATE_RUNNING,
  18. RTR_STATE_STOPPING,
  19. RTR_STATE_STOPPED
  20. }RouterOperationalState, ProtocolOperationalState ;
  21. typedef struct _IPRouterState
  22. {
  23. RouterOperationalState IRS_State ;
  24. DWORD IRS_RefCount ;
  25. }IPRouterState, *pIPRouterState ;
  26. //////////////////////////////////////////////////////////////////////////////
  27. // //
  28. // The following are the the operational states for WAN and LAN interfaces. //
  29. // These are not the same as the MIB-II operational states. //
  30. // //
  31. //////////////////////////////////////////////////////////////////////////////
  32. #define NON_OPERATIONAL IF_OPER_STATUS_NON_OPERATIONAL
  33. #define UNREACHABLE IF_OPER_STATUS_UNREACHABLE
  34. #define DISCONNECTED IF_OPER_STATUS_DISCONNECTED
  35. #define CONNECTING IF_OPER_STATUS_CONNECTING
  36. #define CONNECTED IF_OPER_STATUS_CONNECTED
  37. #define OPERATIONAL IF_OPER_STATUS_OPERATIONAL
  38. //
  39. // Control blocks for all Routing Protocols
  40. //
  41. #pragma warning(disable:4201)
  42. typedef struct _PROTO_CB
  43. {
  44. LIST_ENTRY leList;
  45. ProtocolOperationalState posOpState;
  46. PWCHAR pwszDllName;
  47. PWCHAR pwszDisplayName;
  48. HINSTANCE hiHInstance;
  49. MPR_ROUTING_CHARACTERISTICS;
  50. }PROTO_CB, *PPROTO_CB;
  51. #pragma warning(default:4201)
  52. typedef struct _IF_PROTO
  53. {
  54. LIST_ENTRY leIfProtoLink;
  55. BOOL bPromiscuous;
  56. PPROTO_CB pActiveProto;
  57. }IF_PROTO, *PIF_PROTO;
  58. typedef struct _ICB_BINDING
  59. {
  60. DWORD dwAddress;
  61. DWORD dwMask;
  62. }ICB_BINDING, *PICB_BINDING;
  63. typedef struct _GATEWAY_INFO
  64. {
  65. DWORD dwAddress;
  66. DWORD dwIfIndex;
  67. DWORD dwMetric;
  68. }GATEWAY_INFO, *PGATEWAY_INFO;
  69. #define MAX_DEFG 5
  70. //
  71. // Interface Control Block
  72. //
  73. typedef struct _ICB
  74. {
  75. //
  76. // Link into the doubly linked list of all interfaces
  77. //
  78. LIST_ENTRY leIfLink;
  79. //
  80. // The interface index
  81. //
  82. DWORD dwIfIndex;
  83. //
  84. // Link into the doubly linked list of interfaces hashed of the index
  85. //
  86. LIST_ENTRY leHashLink;
  87. //
  88. // Link into doubly linked list of interfaces hashed on ICB seq. number
  89. //
  90. LIST_ENTRY leICBHashLink;
  91. //
  92. // List of all the protocols on which the interface is added
  93. // (IF_PROTO structures)
  94. //
  95. LIST_ENTRY leProtocolList;
  96. //
  97. // Pointer to interface name. The storage for the name is after the ICB
  98. //
  99. PWCHAR pwszName;
  100. //
  101. // Pointer to device name
  102. // Only used for internal interfaces
  103. //
  104. PWCHAR pwszDeviceName;
  105. DWORD dwSeqNumber;
  106. //
  107. // Handle from PfCreateInterface. Set to INVALID_HANDLE_VALUE if
  108. // the interface was not/could not be created
  109. //
  110. INTERFACE_HANDLE ihFilterInterface;
  111. INTERFACE_HANDLE ihDemandFilterInterface;
  112. //
  113. // The filter info. We keep this here, because we dont have
  114. // a GET call from the filter driver
  115. //
  116. PFILTER_DESCRIPTOR pInFilter;
  117. PFILTER_DESCRIPTOR pOutFilter;
  118. PFILTER_DESCRIPTOR pDemandFilter;
  119. BOOL bFragCheckEnable;
  120. //
  121. // Set to true when we are restoring routes
  122. //
  123. BOOL bRestoringRoutes;
  124. //
  125. // Type of the interface
  126. //
  127. ROUTER_INTERFACE_TYPE ritType;
  128. NET_INTERFACE_TYPE nitProtocolType;
  129. DWORD dwMediaType;
  130. WORD wAccessType;
  131. WORD wConnectionType;
  132. //
  133. // Operational and admin states
  134. //
  135. DWORD dwOperationalState;
  136. DWORD dwAdminState;
  137. //
  138. // Mcast state
  139. //
  140. BOOL bMcastEnabled;
  141. //
  142. // State of the connection
  143. //
  144. DWORD fConnectionFlags;
  145. //
  146. // DIM's handle for this interface
  147. //
  148. HANDLE hDIMHandle;
  149. //
  150. // Event to be signalled to inform DIM that an UpdateRoutes is completed.
  151. // A non NULL value => UpdateRoutes in progress
  152. //
  153. HANDLE hDIMNotificationEvent;
  154. //
  155. // The list of results
  156. //
  157. LIST_ENTRY lePendingResultList;
  158. //
  159. // The router discovery information for this interface
  160. //
  161. ROUTER_DISC_CB rdcRtrDiscInfo;
  162. //
  163. // Pointer to the advertisement. The memory for this is allocated from
  164. // the IPRouterHeap
  165. //
  166. PICMP_ROUTER_ADVT_MSG pRtrDiscAdvt;
  167. WSABUF wsAdvtWSABuffer;
  168. DWORD dwRtrDiscAdvtSize;
  169. #ifdef KSL_IPINIP
  170. //
  171. // IP in IP config
  172. //
  173. PIPINIP_CONFIG_INFO pIpIpInfo;
  174. #endif //KSL_IPINIP
  175. //
  176. // The TTL scope for multicasts
  177. //
  178. DWORD dwMcastTtl;
  179. //
  180. // The rate limit for multicast traffic.
  181. //
  182. DWORD dwMcastRateLimit;
  183. //
  184. // The multicast heartbeat info
  185. //
  186. MCAST_HBEAT_CB mhcHeartbeatInfo;
  187. //
  188. // For clients only
  189. //
  190. PINTERFACE_ROUTE_TABLE pStoredRoutes;
  191. //
  192. // Stuff for IPAddressTable
  193. //
  194. //
  195. // Indicates whether the interface is bound or not
  196. //
  197. BOOL bBound;
  198. //
  199. // Set to true if we bumped up metric
  200. //
  201. BOOL bChangedMetrics;
  202. //
  203. // The rest of the fields are valid only if an interface is
  204. // bound
  205. //
  206. //DWORD dwAdapterId;
  207. DWORD dwBCastBit;
  208. DWORD dwReassemblySize;
  209. ULONG ulMtu;
  210. ULONGLONG ullSpeed;
  211. DWORD dwGatewayCount;
  212. GATEWAY_INFO Gateways[MAX_DEFG];
  213. //
  214. // dwNumAddresses may be 0 even if the interface is bound. This happens
  215. // when the interface is in unnumbered mode
  216. //
  217. DWORD dwNumAddresses;
  218. DWORD dwRemoteAddress;
  219. PICB_BINDING pibBindings;
  220. }ICB, *PICB;
  221. //
  222. // An adapter info is an alternate store for the binding info kept in
  223. // the ICB to avoid some deadlock conditions
  224. // Even if this belongs to an unnumbered interface, we still have space
  225. // for one ICB_BINDING, iow the minimum size is SIZEOF_ADAPTER_INFO(1)
  226. //
  227. typedef struct _ADAPTER_INFO
  228. {
  229. LIST_ENTRY leHashLink;
  230. BOOL bBound;
  231. DWORD dwIfIndex;
  232. PICB pInterfaceCB;
  233. ROUTER_INTERFACE_TYPE ritType;
  234. DWORD dwNumAddresses;
  235. DWORD dwRemoteAddress;
  236. DWORD dwBCastBit;
  237. DWORD dwReassemblySize;
  238. DWORD dwSeqNumber;
  239. #if STATIC_RT_DBG
  240. BOOL bUnreach;
  241. #endif
  242. ICB_BINDING rgibBinding[1];
  243. }ADAPTER_INFO, *PADAPTER_INFO;
  244. #define SIZEOF_ADAPTER_INFO(X) \
  245. (FIELD_OFFSET(ADAPTER_INFO,rgibBinding[0]) + ((X) * sizeof(ICB_BINDING)))
  246. #define NDISWAN_NOTIFICATION_RECEIVED 0x00000001
  247. #define DDM_NOTIFICATION_RECEIVED 0x00000002
  248. #define ALL_NOTIFICATIONS_RECEIVED (NDISWAN_NOTIFICATION_RECEIVED | DDM_NOTIFICATION_RECEIVED)
  249. #define INTERFACE_MARKED_FOR_DELETION 0x00000004
  250. #define HasNdiswanNoticationBeenReceived(picb) \
  251. ((picb)->fConnectionFlags & NDISWAN_NOTIFICATION_RECEIVED)
  252. #define HasDDMNotificationBeenReceived(picb) \
  253. ((picb)->fConnectionFlags & DDM_NOTIFICATION_RECEIVED)
  254. #define IsInterfaceMarkedForDeletion(picb) \
  255. ((picb)->fConnectionFlags & INTERFACE_MARKED_FOR_DELETION)
  256. #define HaveAllNotificationsBeenReceived(picb) \
  257. (((picb)->fConnectionFlags & ALL_NOTIFICATIONS_RECEIVED) == ALL_NOTIFICATIONS_RECEIVED)
  258. #define ClearNotificationFlags(picb) ((picb)->fConnectionFlags = 0x00000000)
  259. #define SetNdiswanNotification(picb) \
  260. ((picb)->fConnectionFlags |= NDISWAN_NOTIFICATION_RECEIVED)
  261. #define SetDDMNotification(picb) \
  262. ((picb)->fConnectionFlags |= DDM_NOTIFICATION_RECEIVED)
  263. #define MarkInterfaceForDeletion(picb) \
  264. ((picb)->fConnectionFlags |= INTERFACE_MARKED_FOR_DELETION)
  265. //
  266. // List of NETMGMT routes that need to be restored to the stack
  267. //
  268. typedef struct _ROUTE_LIST_ENTRY
  269. {
  270. LIST_ENTRY leRouteList;
  271. MIB_IPFORWARDROW mibRoute;
  272. } ROUTE_LIST_ENTRY, *PROUTE_LIST_ENTRY;
  273. //
  274. // List of update route results
  275. //
  276. typedef struct _UpdateResultList
  277. {
  278. LIST_ENTRY URL_List;
  279. DWORD URL_UpdateStatus;
  280. }UpdateResultList, *pUpdateResultList;
  281. /*
  282. typedef struct _ADAPTER_MAP
  283. {
  284. LIST_ENTRY leHashLink;
  285. DWORD dwAdapterId;
  286. DWORD dwIfIndex;
  287. }ADAPTER_MAP, *PADAPTER_MAP;
  288. */
  289. typedef struct _IP_CACHE
  290. {
  291. PMIB_IPADDRTABLE pAddrTable;
  292. PMIB_IPFORWARDTABLE pForwardTable;
  293. PMIB_IPNETTABLE pNetTable;
  294. DWORD dwTotalAddrEntries;
  295. DWORD dwTotalForwardEntries;
  296. DWORD dwTotalNetEntries;
  297. }IP_CACHE, *PIP_CACHE;
  298. typedef struct _TCP_CACHE
  299. {
  300. PMIB_TCPTABLE pTcpTable;
  301. DWORD dwTotalEntries;
  302. }TCP_CACHE, *PTCP_CACHE;
  303. typedef struct _UDP_CACHE
  304. {
  305. PMIB_UDPTABLE pUdpTable;
  306. DWORD dwTotalEntries;
  307. }UDP_CACHE, *PUDP_CACHE;
  308. DWORD
  309. AddInterface(
  310. IN LPWSTR lpwsInterfaceName,
  311. IN LPVOID pInterfaceInfo,
  312. IN ROUTER_INTERFACE_TYPE InterfaceType,
  313. IN HANDLE hDIMInterface,
  314. IN OUT HANDLE *phInterface
  315. );
  316. DWORD
  317. RouterBootComplete(
  318. VOID
  319. );
  320. DWORD
  321. StopRouter(
  322. VOID
  323. );
  324. DWORD
  325. DeleteInterface(
  326. IN HANDLE hInterface
  327. );
  328. DWORD
  329. GetInterfaceInfo(
  330. IN HANDLE hInterface,
  331. OUT LPVOID pInterfaceInfo,
  332. IN OUT LPDWORD lpdwInterfaceInfoSize
  333. );
  334. DWORD
  335. SetInterfaceInfo(
  336. IN HANDLE hInterface,
  337. IN LPVOID pInterfaceInfo
  338. );
  339. DWORD
  340. InterfaceNotReachable(
  341. IN HANDLE hInterface,
  342. IN UNREACHABILITY_REASON Reason
  343. );
  344. DWORD
  345. InterfaceReachable(
  346. IN HANDLE hInterface
  347. );
  348. DWORD
  349. InterfaceConnected(
  350. IN HANDLE hInterface,
  351. IN PVOID pFilter,
  352. IN PVOID pPppProjectionResult
  353. );
  354. DWORD
  355. UpdateRoutes(
  356. IN HANDLE hInterface,
  357. IN HANDLE hEvent
  358. );
  359. DWORD
  360. GetUpdateRoutesResult(
  361. IN HANDLE hInterface,
  362. OUT LPDWORD pUpdateResult
  363. );
  364. DWORD
  365. SetGlobalInfo(
  366. IN LPVOID pGlobalInfo
  367. );
  368. DWORD
  369. GetGlobalInfo(
  370. OUT LPVOID pGlobalInfo,
  371. IN OUT LPDWORD lpdwGlobalInfoSize
  372. );
  373. DWORD
  374. DemandDialRequest(
  375. IN DWORD dwProtocolId,
  376. IN DWORD dwInterfaceIndex
  377. );
  378. DWORD
  379. RtrMgrMIBEntryCreate(
  380. IN DWORD dwRoutingPid,
  381. IN DWORD dwEntrySize,
  382. IN LPVOID lpEntry
  383. );
  384. DWORD
  385. RtrMgrMIBEntryDelete(
  386. IN DWORD dwRoutingPid,
  387. IN DWORD dwEntrySize,
  388. IN LPVOID lpEntry
  389. );
  390. DWORD
  391. RtrMgrMIBEntryGet(
  392. IN DWORD dwRoutingPid,
  393. IN DWORD dwInEntrySize,
  394. IN LPVOID lpInEntry,
  395. IN OUT LPDWORD lpOutEntrySize,
  396. OUT LPVOID lpOutEntry
  397. );
  398. DWORD
  399. RtrMgrMIBEntryGetFirst(
  400. IN DWORD dwRoutingPid,
  401. IN DWORD dwInEntrySize,
  402. IN LPVOID lpInEntry,
  403. IN OUT LPDWORD lpOutEntrySize,
  404. OUT LPVOID lpOutEntry
  405. );
  406. DWORD
  407. RtrMgrMIBEntryGetNext(
  408. IN DWORD dwRoutingPid,
  409. IN DWORD dwInEntrySize,
  410. IN LPVOID lpInEntry,
  411. IN OUT LPDWORD lpOutEntrySize,
  412. OUT LPVOID lpOutEntry
  413. );
  414. DWORD
  415. RtrMgrMIBEntrySet(
  416. IN DWORD dwRoutingPid,
  417. IN DWORD dwEntrySize,
  418. IN LPVOID lpEntry
  419. );
  420. #endif // __RTRMGR_IPRTRMGR_H__