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.

392 lines
12 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. routing\inc\rtm.h
  5. Abstract:
  6. Router Manager private interface for Routing Table Manager DLL
  7. Author:
  8. Vadim Eydelman
  9. Revision History:
  10. --*/
  11. #ifndef _ROUTING_RMRTM
  12. #define _ROUTING_RMRTM
  13. // Two protocol families are currently supported (IP, IPX)
  14. // It should be enough to modify this constant to support additional
  15. // protocol families (from the RTM's point of view). Up to 256 families
  16. // can be supported (if somebody needs more (???!!!), the next constant should
  17. // be modified to free more low order bits for use by protocol family constants)
  18. //
  19. // Changed the number of protocol families from 2
  20. // to 1 (as we support only IPX). IP and other
  21. // future address families are supported by RTMv2.
  22. //
  23. #define RTM_NUM_OF_PROTOCOL_FAMILIES 1
  24. // Tag that rtm ors in Protocol Family field of the handles it
  25. // exports to clients for validation purposes
  26. #define RTM_CLIENT_HANDLE_TAG ('RTM'<<8)
  27. /*++
  28. *******************************************************************
  29. N E T W O R K _ N U M B E R _ C M P _ F U N C
  30. Routine Description:
  31. Compares two network numbers and returns result that can be used for
  32. route sorting
  33. Arguments:
  34. Net1,Net2 - pointers to protocol family dependent network number structures
  35. to be compared
  36. Return Value:
  37. <0 - Net2 follows Net1
  38. >0 - Net1 follows Net2
  39. =0 - Net1==Net2
  40. *******************************************************************
  41. --*/
  42. typedef
  43. INT
  44. (*PNETWORK_NUMBER_CMP_FUNC) (
  45. PVOID Net1,
  46. PVOID Net2
  47. );
  48. /*++
  49. *******************************************************************
  50. N E X T _ H O P _ A D D R E S S _ C M P _ F U N C
  51. Routine Description:
  52. Compares next hop addresses of two routes and returns result that can be used for
  53. route sorting
  54. Arguments:
  55. Route1,Route2 - pointers to protocol family dependent route structures whose
  56. next hop addresses are to be compared
  57. Return Value:
  58. <0 - Route2 should follow Route1 if sorted by next hop address
  59. >0 - Route1 should follow Route2 if sorted by next hop address
  60. =0 - Route1 has same next hop address as Route2
  61. *******************************************************************
  62. --*/
  63. typedef
  64. INT
  65. (*PNEXT_HOP_ADDRESS_CMP_FUNC) (
  66. PVOID Route1,
  67. PVOID Route2
  68. );
  69. /*++
  70. *******************************************************************
  71. F A M I L Y _ S P E C I F I C _ D A T A _ C M P _ F U N C
  72. Routine Description:
  73. Compares family specific data fields of two routes and returns if
  74. the are equal
  75. Arguments:
  76. Route1,Route2 - pointers to protocol family dependent route structures whose
  77. protocol family specific data fields are to be compared
  78. Return Value:
  79. TRUE - protocol family specific data fields of Route1 and Route2 are
  80. equivalent
  81. FALSE - protocol family specific data fields of Route1 and Route2 are
  82. different
  83. *******************************************************************
  84. --*/
  85. typedef
  86. BOOL
  87. (*PFAMILY_SPECIFIC_DATA_CMP_FUNC) (
  88. PVOID Route1,
  89. PVOID Route2
  90. );
  91. /*++
  92. *******************************************************************
  93. R O U T E _ M E T R I C _ C M P _ F U N C
  94. Routine Description:
  95. Compares two routes and returns result that identifies the
  96. better route
  97. Arguments:
  98. Route1,Route2 - pointers to protocol family dependent route structures whose
  99. parameters are to be compared
  100. Return Value:
  101. <0 - Route1 is better than Route2
  102. >0 - Route2 is better than Route1
  103. =0 - Route1 is as good as Route2
  104. *******************************************************************
  105. --*/
  106. typedef
  107. INT
  108. (*PROUTE_METRIC_CMP_FUNC) (
  109. PVOID Route1,
  110. PVOID Route2
  111. );
  112. /*++
  113. *******************************************************************
  114. R O U T E _ H A S H _ F U N C
  115. Routine Description:
  116. Retuns value that can be used for route hashing by network number
  117. Arguments:
  118. Net - network number to be used for hashing
  119. Return Value:
  120. Hash value
  121. *******************************************************************
  122. --*/
  123. typedef
  124. INT
  125. (*PROUTE_HASH_FUNC) (
  126. PVOID Net
  127. );
  128. /*++
  129. *******************************************************************
  130. R O U T E _ V A L I D A T E _ F U N C
  131. Routine Description:
  132. Validates the data in the route structure and possibly updates
  133. some of them. This routine is called each time the new route
  134. is added to tha table or any of parameters of an existing route
  135. changes
  136. Arguments:
  137. Route - pointer to protocol family dependent route structure to
  138. be validated
  139. Return Value:
  140. NO_ERROR - route was successfully validated
  141. ERROR_INVALID_PARAMETER - route structure is invalid, RTM will reject
  142. client's request to add or change the route
  143. *******************************************************************
  144. --*/
  145. typedef
  146. DWORD
  147. (*PROUTE_VALIDATE_FUNC) (
  148. PVOID Route
  149. );
  150. /*++
  151. *******************************************************************
  152. R O U T E _ C H A N G E _ C A L L B A C K
  153. Routine Description:
  154. Gets called whenever the best route to some desination network changes
  155. (intended to be used by the protocol family manager to notify kernel mode
  156. forwarders of route changes)
  157. Arguments:
  158. Flags - identifies what kind of change caused the call and what
  159. information is provided in the route buffers:
  160. RTM_ROUTE_ADDED - first route was added for a destination network,
  161. CurBestRoute is contains added route info
  162. RTM_ROUTE_DELETED - the only route available for a destination
  163. network was deleted, PrevBestRoute contains deleted
  164. route info
  165. RTM_ROUTE_CHANGED - there was a change in any of the following
  166. parameters of the BEST route to a destination
  167. network:
  168. RoutingProtocol,
  169. InterfaceID,
  170. Metric,
  171. NextHopAddress,
  172. FamilySpecificData.
  173. PrevBestRoute contains the route info as it was
  174. before the change, CurBestRoute contains current
  175. best route info.
  176. Note that the route change message can be generated
  177. both as result of protocol adding/deleting the route
  178. that becomes/was the best and changing best route parameters
  179. such that the route becomes/no longer is the best route.
  180. CurBestRoute - current best route info (if any)
  181. PrevBestRoute - previous best route info (if any)
  182. Return Value:
  183. None
  184. *******************************************************************
  185. --*/
  186. typedef
  187. VOID
  188. (*PROUTE_CHANGE_CALLBACK) (
  189. DWORD Flags,
  190. PVOID CurBestRoute,
  191. PVOID PrevBestRoute
  192. );
  193. typedef struct _RTM_PROTOCOL_FAMILY_CONFIG {
  194. ULONG RPFC_MaxTableSize; // Size of address space reserved
  195. // for the table
  196. INT RPFC_HashSize; // Size of hash table
  197. INT RPFC_RouteSize; // Size of route structure
  198. PNETWORK_NUMBER_CMP_FUNC RPFC_NNcmp;
  199. PNEXT_HOP_ADDRESS_CMP_FUNC RPFC_NHAcmp;
  200. PFAMILY_SPECIFIC_DATA_CMP_FUNC RPFC_FSDcmp;
  201. PROUTE_METRIC_CMP_FUNC RPFC_RMcmp;
  202. PROUTE_HASH_FUNC RPFC_Hash;
  203. PROUTE_VALIDATE_FUNC RPFC_Validate;
  204. PROUTE_CHANGE_CALLBACK RPFC_Change;
  205. } RTM_PROTOCOL_FAMILY_CONFIG, *PRTM_PROTOCOL_FAMILY_CONFIG;
  206. /*++
  207. *******************************************************************
  208. R t m C r e a t e R o u t e T a b l e
  209. Routine Description:
  210. Create route table for protocol family
  211. Arguments:
  212. ProtocolFamily - index that identifies protocol family
  213. Config - protocol family table configuration parameters
  214. Return Value:
  215. NO_ERROR - table was created ok
  216. ERROR_INVALID_PARAMETER - protocol family is out of range supported by the RTM
  217. ERROR_ALREDY_EXISTS - protocol family table already exists
  218. ERROR_NOT_ENOUGH_MEMORY - could not allocate memory to perform
  219. the operation
  220. ERROR_NO_SYSTEM_RESOURCES - not enough resources to perform the operation,
  221. try again later
  222. *******************************************************************
  223. --*/
  224. DWORD
  225. RtmCreateRouteTable (
  226. IN DWORD ProtocolFamily,
  227. IN PRTM_PROTOCOL_FAMILY_CONFIG Config
  228. );
  229. /*++
  230. *******************************************************************
  231. R t m D e l e t e R o u t e T a b l e
  232. Routine Description:
  233. Dispose of all resources allocated for the route table
  234. Arguments:
  235. ProtocolFamily - index that identifies protocol family
  236. Return Value:
  237. NO_ERROR - table was deleted ok
  238. ERROR_INVALID_PARAMETER - no table to delete
  239. *******************************************************************
  240. --*/
  241. DWORD
  242. RtmDeleteRouteTable (
  243. DWORD ProtocolFamily
  244. );
  245. /*++
  246. *******************************************************************
  247. R t m B l o c k S e t R o u t e E n a b l e
  248. Routine Description:
  249. Disables/Reenables all routes in subset specified by enumeration
  250. flags and corresponding criteria. This operation can only be performed
  251. by the registered client and applies only to routes added by this
  252. client.
  253. Route change messages will be generated for disabled/reenabled routes that
  254. were/became the best.
  255. Disabled routes are invisible for route queries, but could still be
  256. maintained by the RTM itself or routing protocol handler that added
  257. these routes (add, delete, and aging mechanisms still apply)
  258. Arguments:
  259. ClientHandle - handle that identifies the client and routing protocol
  260. of routes to be disabled/reenabled
  261. EnumerationFlags - further limit subset of routes being enabled to only
  262. those that have same values in the fields
  263. specified by the flags as in CriteriaRoute
  264. Note that only RTM_ONLY_THIS_NETWORK and RTM_ONLY_THIS_INTERFACE
  265. can be used (RTM_ONLY_BEST_ROUTES does not apply because best
  266. route designation is adjusted as routes are enabled/disabled and
  267. all routes will be affected anyway)
  268. CriteriaRoute - protocol family dependent structure (RTM_??_ROUTE) with
  269. set values in fields that correspond to EnumerationFlags
  270. Enable - FALSE: disable, TRUE: reenable
  271. Return Value:
  272. NO_ERROR - routes were disabled/reenabled ok
  273. ERROR_NO_ROUTES - no routes exist that match specified criteria
  274. ERROR_INVALID_HANDLE - client handle is not a valid RTM handle
  275. ERROR_NOT_ENOUGH_MEMORY - could not allocate memory to perform
  276. the operation
  277. ERROR_NO_SYSTEM_RESOURCES - not enough resources to perform the operation,
  278. try again later
  279. *******************************************************************
  280. --*/
  281. DWORD WINAPI
  282. RtmBlockSetRouteEnable (
  283. IN HANDLE ClientHandle,
  284. IN DWORD EnumerationFlags,
  285. IN PVOID CriteriaRoute,
  286. IN BOOL Enable
  287. );
  288. #define RtmBlockDisableRoutes(Handle,Flags,CriteriaRoute) \
  289. RtmBlockSetRouteEnable(Handle,Flags,CriteriaRoute,FALSE)
  290. #define RtmBlockReenableRoutes(Handle,Flags,CriteriaRoute) \
  291. RtmBlockSetRouteEnable(Handle,Flags,CriteriaRoute,TRUE)
  292. // Use this flags in enumeration methods to enumerate disabled routes
  293. #define RTM_INCLUDE_DISABLED_ROUTES 0x40000000
  294. /*++
  295. *******************************************************************
  296. R t m B l o c k C o n v e r t R o u t e s T o S t a t i c
  297. Routine Description:
  298. Converts all routes as specified by enumeration flags to routes of
  299. static protocol (as defined by StaticClientHandle).
  300. No route change messages are generated as the result of this operation.
  301. This functionality is normally used only by Router Manager for a specific
  302. protocol family
  303. Arguments:
  304. ClientHandle - handle that identifies static protocol client
  305. EnumerationFlags - limit subset of routes being converted to only
  306. those that have same values in the fields
  307. specified by the flags as in CriteriaRoute
  308. CriteriaRoute - protocol family dependent structure (RTM_??_ROUTE) with
  309. set values in fields that correspond to EnumerationFlags
  310. Return Value:
  311. NO_ERROR - routes were converted ok
  312. ERROR_NO_ROUTES - no routes exist that match specified criteria
  313. ERROR_INVALID_HANDLE - client handle is not a valid RTM handle
  314. ERROR_NOT_ENOUGH_MEMORY - could not allocate memory to perform
  315. the operation
  316. ERROR_NO_SYSTEM_RESOURCES - not enough resources to perform the operation,
  317. try again later
  318. *******************************************************************
  319. --*/
  320. DWORD WINAPI
  321. RtmBlockConvertRoutesToStatic (
  322. IN HANDLE ClientHandle,
  323. IN DWORD EnumerationFlags,
  324. IN PVOID CriteriaRoute
  325. );
  326. #endif