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.

177 lines
4.8 KiB

  1. /*++
  2. Copyright (c) 1997 - 98, Microsoft Corporation
  3. Module Name:
  4. rtmenum.h
  5. Abstract:
  6. Contains definitions for managing enumerations
  7. over destinations, routes and next hops in RTM.
  8. Author:
  9. Chaitanya Kodeboyina (chaitk) 23-Aug-1998
  10. Revision History:
  11. --*/
  12. #ifndef __ROUTING_RTMENUM_H__
  13. #define __ROUTING_RTMENUM_H__
  14. //
  15. // Enumeration Over Destinations
  16. //
  17. typedef struct _DEST_ENUM
  18. {
  19. OPEN_HEADER EnumHeader; // Enumeration Type and Reference Count
  20. RTM_VIEW_SET TargetViews; // Views over which enum is active
  21. UINT NumberOfViews; // Num of views in which enum is active
  22. ULONG ProtocolId; // OSPF, RIP, BEST_PROTOCOL etc.
  23. RTM_ENUM_FLAGS EnumFlags; // See RTM_ENUM_FLAGS in rtmv2.h
  24. #if DBG
  25. RTM_NET_ADDRESS StartAddress; // First NetAddress in the enum
  26. #endif
  27. RTM_NET_ADDRESS StopAddress; // Last NetAddress in the enum
  28. CRITICAL_SECTION EnumLock; // Lock that protects the 'NextDest'
  29. BOOL EnumDone; // Set to TRUE once last item is got
  30. RTM_NET_ADDRESS NextDest; // Points to the next dest in the enum
  31. }
  32. DEST_ENUM, *PDEST_ENUM;
  33. //
  34. // Enumeration Over Routes
  35. //
  36. typedef struct _ROUTE_ENUM
  37. {
  38. OPEN_HEADER EnumHeader; // Enumeration Type and Reference Count
  39. RTM_VIEW_SET TargetViews; // Views over which enum is active
  40. RTM_ENUM_FLAGS EnumFlags; // See RTM_ENUM_FLAGS in rtmv2.h
  41. RTM_MATCH_FLAGS MatchFlags; // See RTM_MATCH_FLAGS in rtmv2.h
  42. PRTM_ROUTE_INFO CriteriaRoute; // Match criteria used with flags above
  43. ULONG CriteriaInterface;// Interface on which routes r enum'ed
  44. CRITICAL_SECTION EnumLock; // Lock that protects the fields below
  45. PDEST_ENUM DestEnum; // Enum over dests (if enum'ing routes
  46. // on all destinations in the table)
  47. PRTM_DEST_INFO DestInfo; // Temp buffer used in above dest enum
  48. BOOL EnumDone; // Set to TRUE once last item is got
  49. PDEST_INFO Destination; // Dest for routes that we r enum'ing,
  50. UINT NextRoute; // Route to be given next on the dest
  51. UINT MaxRoutes; // Number of route slots in this array
  52. UINT NumRoutes; // Actual number of routes in the array
  53. PROUTE_INFO *RoutesOnDest; // Array of routes on this destination
  54. }
  55. ROUTE_ENUM, *PROUTE_ENUM;
  56. //
  57. // Enumeration Over Next Hops
  58. //
  59. typedef struct _NEXTHOP_ENUM
  60. {
  61. OPEN_HEADER EnumHeader; // Enumeration Type and Reference Count
  62. RTM_ENUM_FLAGS EnumFlags; // See RTM_ENUM_FLAGS
  63. #if DBG
  64. RTM_NET_ADDRESS StartAddress; // First NetAddress in the enum
  65. #endif
  66. RTM_NET_ADDRESS StopAddress; // Last NetAddress in the enum
  67. CRITICAL_SECTION EnumLock; // Lock that protects the 'NextNextHop'
  68. BOOL EnumDone; // Set to TRUE once last item is got
  69. RTM_NET_ADDRESS NextAddress; // Address of next next-hop in the enum
  70. ULONG NextIfIndex; // Interface of next next-hop in enum
  71. }
  72. NEXTHOP_ENUM, *PNEXTHOP_ENUM;
  73. //
  74. // Used to indicate the posn of 1st
  75. // next-hop on a list of next-hops
  76. //
  77. #define START_IF_INDEX (ULONG) (-1)
  78. //
  79. // Macro for determinining the type of enumeration handle
  80. //
  81. #define GET_ENUM_TYPE(EnumHandle, Enum) \
  82. ( \
  83. *Enum = (POPEN_HEADER) GetObjectFromHandle(EnumHandle, GENERIC_TYPE), \
  84. (*Enum)->HandleType \
  85. )
  86. //
  87. // Macros for acquiring various locks defined in this file
  88. //
  89. #define ACQUIRE_DEST_ENUM_LOCK(DestEnum) \
  90. ACQUIRE_LOCK(&DestEnum->EnumLock)
  91. #define RELEASE_DEST_ENUM_LOCK(DestEnum) \
  92. RELEASE_LOCK(&DestEnum->EnumLock)
  93. #define ACQUIRE_ROUTE_ENUM_LOCK(RouteEnum) \
  94. ACQUIRE_LOCK(&RouteEnum->EnumLock)
  95. #define RELEASE_ROUTE_ENUM_LOCK(RouteEnum) \
  96. RELEASE_LOCK(&RouteEnum->EnumLock)
  97. #define ACQUIRE_NEXTHOP_ENUM_LOCK(RouteEnum) \
  98. ACQUIRE_LOCK(&RouteEnum->EnumLock)
  99. #define RELEASE_NEXTHOP_ENUM_LOCK(RouteEnum) \
  100. RELEASE_LOCK(&RouteEnum->EnumLock)
  101. //
  102. // Enumeration helper functions
  103. //
  104. BOOL
  105. MatchRouteWithCriteria (
  106. IN PROUTE_INFO Route,
  107. IN RTM_MATCH_FLAGS MatchingFlags,
  108. IN PRTM_ROUTE_INFO CriteriaRouteInfo,
  109. IN ULONG CriteriaInterface
  110. );
  111. #endif // __ROUTING_RTMENUM_H__