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.

556 lines
12 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. //
  170. // IP in IP config
  171. //
  172. PIPINIP_CONFIG_INFO pIpIpInfo;
  173. //
  174. // The TTL scope for multicasts
  175. //
  176. DWORD dwMcastTtl;
  177. //
  178. // The rate limit for multicast traffic.
  179. //
  180. DWORD dwMcastRateLimit;
  181. //
  182. // The multicast heartbeat info
  183. //
  184. MCAST_HBEAT_CB mhcHeartbeatInfo;
  185. //
  186. // For clients only
  187. //
  188. PINTERFACE_ROUTE_TABLE pStoredRoutes;
  189. //
  190. // Stuff for IPAddressTable
  191. //
  192. //
  193. // Indicates whether the interface is bound or not
  194. //
  195. BOOL bBound;
  196. //
  197. // Set to true if we bumped up metric
  198. //
  199. BOOL bChangedMetrics;
  200. //
  201. // The rest of the fields are valid only if an interface is
  202. // bound
  203. //
  204. //DWORD dwAdapterId;
  205. DWORD dwBCastBit;
  206. DWORD dwReassemblySize;
  207. ULONG ulMtu;
  208. ULONGLONG ullSpeed;
  209. DWORD dwGatewayCount;
  210. GATEWAY_INFO Gateways[MAX_DEFG];
  211. //
  212. // dwNumAddresses may be 0 even if the interface is bound. This happens
  213. // when the interface is in unnumbered mode
  214. //
  215. DWORD dwNumAddresses;
  216. DWORD dwRemoteAddress;
  217. PICB_BINDING pibBindings;
  218. }ICB, *PICB;
  219. //
  220. // An adapter info is an alternate store for the binding info kept in
  221. // the ICB to avoid some deadlock conditions
  222. // Even if this belongs to an unnumbered interface, we still have space
  223. // for one ICB_BINDING, iow the minimum size is SIZEOF_ADAPTER_INFO(1)
  224. //
  225. typedef struct _ADAPTER_INFO
  226. {
  227. LIST_ENTRY leHashLink;
  228. BOOL bBound;
  229. DWORD dwIfIndex;
  230. PICB pInterfaceCB;
  231. ROUTER_INTERFACE_TYPE ritType;
  232. DWORD dwNumAddresses;
  233. DWORD dwRemoteAddress;
  234. DWORD dwBCastBit;
  235. DWORD dwReassemblySize;
  236. DWORD dwSeqNumber;
  237. #if STATIC_RT_DBG
  238. BOOL bUnreach;
  239. #endif
  240. ICB_BINDING rgibBinding[1];
  241. }ADAPTER_INFO, *PADAPTER_INFO;
  242. #define SIZEOF_ADAPTER_INFO(X) \
  243. (FIELD_OFFSET(ADAPTER_INFO,rgibBinding[0]) + ((X) * sizeof(ICB_BINDING)))
  244. #define NDISWAN_NOTIFICATION_RECEIVED 0x00000001
  245. #define DDM_NOTIFICATION_RECEIVED 0x00000002
  246. #define ALL_NOTIFICATIONS_RECEIVED (NDISWAN_NOTIFICATION_RECEIVED | DDM_NOTIFICATION_RECEIVED)
  247. #define INTERFACE_MARKED_FOR_DELETION 0x00000004
  248. #define HasNdiswanNoticationBeenReceived(picb) \
  249. ((picb)->fConnectionFlags & NDISWAN_NOTIFICATION_RECEIVED)
  250. #define HasDDMNotificationBeenReceived(picb) \
  251. ((picb)->fConnectionFlags & DDM_NOTIFICATION_RECEIVED)
  252. #define IsInterfaceMarkedForDeletion(picb) \
  253. ((picb)->fConnectionFlags & INTERFACE_MARKED_FOR_DELETION)
  254. #define HaveAllNotificationsBeenReceived(picb) \
  255. (((picb)->fConnectionFlags & ALL_NOTIFICATIONS_RECEIVED) == ALL_NOTIFICATIONS_RECEIVED)
  256. #define ClearNotificationFlags(picb) ((picb)->fConnectionFlags = 0x00000000)
  257. #define SetNdiswanNotification(picb) \
  258. ((picb)->fConnectionFlags |= NDISWAN_NOTIFICATION_RECEIVED)
  259. #define SetDDMNotification(picb) \
  260. ((picb)->fConnectionFlags |= DDM_NOTIFICATION_RECEIVED)
  261. #define MarkInterfaceForDeletion(picb) \
  262. ((picb)->fConnectionFlags |= INTERFACE_MARKED_FOR_DELETION)
  263. //
  264. // List of NETMGMT routes that need to be restored to the stack
  265. //
  266. typedef struct _ROUTE_LIST_ENTRY
  267. {
  268. LIST_ENTRY leRouteList;
  269. MIB_IPFORWARDROW mibRoute;
  270. } ROUTE_LIST_ENTRY, *PROUTE_LIST_ENTRY;
  271. //
  272. // List of update route results
  273. //
  274. typedef struct _UpdateResultList
  275. {
  276. LIST_ENTRY URL_List;
  277. DWORD URL_UpdateStatus;
  278. }UpdateResultList, *pUpdateResultList;
  279. /*
  280. typedef struct _ADAPTER_MAP
  281. {
  282. LIST_ENTRY leHashLink;
  283. DWORD dwAdapterId;
  284. DWORD dwIfIndex;
  285. }ADAPTER_MAP, *PADAPTER_MAP;
  286. */
  287. typedef struct _IP_CACHE
  288. {
  289. PMIB_IPADDRTABLE pAddrTable;
  290. PMIB_IPFORWARDTABLE pForwardTable;
  291. PMIB_IPNETTABLE pNetTable;
  292. DWORD dwTotalAddrEntries;
  293. DWORD dwTotalForwardEntries;
  294. DWORD dwTotalNetEntries;
  295. }IP_CACHE, *PIP_CACHE;
  296. typedef struct _TCP_CACHE
  297. {
  298. PMIB_TCPTABLE pTcpTable;
  299. DWORD dwTotalEntries;
  300. }TCP_CACHE, *PTCP_CACHE;
  301. typedef struct _UDP_CACHE
  302. {
  303. PMIB_UDPTABLE pUdpTable;
  304. DWORD dwTotalEntries;
  305. }UDP_CACHE, *PUDP_CACHE;
  306. DWORD
  307. AddInterface(
  308. IN LPWSTR lpwsInterfaceName,
  309. IN LPVOID pInterfaceInfo,
  310. IN ROUTER_INTERFACE_TYPE InterfaceType,
  311. IN HANDLE hDIMInterface,
  312. IN OUT HANDLE *phInterface
  313. );
  314. DWORD
  315. RouterBootComplete(
  316. VOID
  317. );
  318. DWORD
  319. StopRouter(
  320. VOID
  321. );
  322. DWORD
  323. DeleteInterface(
  324. IN HANDLE hInterface
  325. );
  326. DWORD
  327. GetInterfaceInfo(
  328. IN HANDLE hInterface,
  329. OUT LPVOID pInterfaceInfo,
  330. IN OUT LPDWORD lpdwInterfaceInfoSize
  331. );
  332. DWORD
  333. SetInterfaceInfo(
  334. IN HANDLE hInterface,
  335. IN LPVOID pInterfaceInfo
  336. );
  337. DWORD
  338. InterfaceNotReachable(
  339. IN HANDLE hInterface,
  340. IN UNREACHABILITY_REASON Reason
  341. );
  342. DWORD
  343. InterfaceReachable(
  344. IN HANDLE hInterface
  345. );
  346. DWORD
  347. InterfaceConnected(
  348. IN HANDLE hInterface,
  349. IN PVOID pFilter,
  350. IN PVOID pPppProjectionResult
  351. );
  352. DWORD
  353. UpdateRoutes(
  354. IN HANDLE hInterface,
  355. IN HANDLE hEvent
  356. );
  357. DWORD
  358. GetUpdateRoutesResult(
  359. IN HANDLE hInterface,
  360. OUT LPDWORD pUpdateResult
  361. );
  362. DWORD
  363. SetGlobalInfo(
  364. IN LPVOID pGlobalInfo
  365. );
  366. DWORD
  367. GetGlobalInfo(
  368. OUT LPVOID pGlobalInfo,
  369. IN OUT LPDWORD lpdwGlobalInfoSize
  370. );
  371. DWORD
  372. DemandDialRequest(
  373. IN DWORD dwProtocolId,
  374. IN DWORD dwInterfaceIndex
  375. );
  376. DWORD
  377. RtrMgrMIBEntryCreate(
  378. IN DWORD dwRoutingPid,
  379. IN DWORD dwEntrySize,
  380. IN LPVOID lpEntry
  381. );
  382. DWORD
  383. RtrMgrMIBEntryDelete(
  384. IN DWORD dwRoutingPid,
  385. IN DWORD dwEntrySize,
  386. IN LPVOID lpEntry
  387. );
  388. DWORD
  389. RtrMgrMIBEntryGet(
  390. IN DWORD dwRoutingPid,
  391. IN DWORD dwInEntrySize,
  392. IN LPVOID lpInEntry,
  393. IN OUT LPDWORD lpOutEntrySize,
  394. OUT LPVOID lpOutEntry
  395. );
  396. DWORD
  397. RtrMgrMIBEntryGetFirst(
  398. IN DWORD dwRoutingPid,
  399. IN DWORD dwInEntrySize,
  400. IN LPVOID lpInEntry,
  401. IN OUT LPDWORD lpOutEntrySize,
  402. OUT LPVOID lpOutEntry
  403. );
  404. DWORD
  405. RtrMgrMIBEntryGetNext(
  406. IN DWORD dwRoutingPid,
  407. IN DWORD dwInEntrySize,
  408. IN LPVOID lpInEntry,
  409. IN OUT LPDWORD lpOutEntrySize,
  410. OUT LPVOID lpOutEntry
  411. );
  412. DWORD
  413. RtrMgrMIBEntrySet(
  414. IN DWORD dwRoutingPid,
  415. IN DWORD dwEntrySize,
  416. IN LPVOID lpEntry
  417. );
  418. #endif // __RTRMGR_IPRTRMGR_H__