home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / rtm.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  29KB  |  802 lines

  1. /*++
  2.  
  3. Copyright (c) 1995 - 1997 Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     rtm.h
  8.  
  9. Abstract:
  10.     Interface for Routing Table Manager DLL
  11.  
  12. --*/
  13.  
  14. #ifndef __ROUTING_RTM_H__
  15. #define __ROUTING_RTM_H__
  16.  
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20.  
  21. // Currently supported protocol families
  22. #define RTM_PROTOCOL_FAMILY_IPX            0
  23. #define RTM_PROTOCOL_FAMILY_IP            1
  24.  
  25. // Error messages specific to Routing Table Manager
  26. #define ERROR_MORE_MESSAGES                ERROR_MORE_DATA
  27. #define ERROR_CLIENT_ALREADY_EXISTS        ERROR_ALREADY_EXISTS
  28. #define ERROR_NO_MESSAGES                ERROR_NO_MORE_ITEMS
  29.  
  30. #define ERROR_NO_MORE_ROUTES            ERROR_NO_MORE_ITEMS
  31. #define ERROR_NO_ROUTES                    ERROR_NO_MORE_ITEMS
  32. #define ERROR_NO_SUCH_ROUTE                ERROR_NO_MORE_ITEMS
  33.  
  34. // Protocol family dependent network number structures
  35. typedef struct _IPX_NETWORK {
  36.     DWORD    N_NetNumber;
  37.     } IPX_NETWORK, *PIPX_NETWORK;
  38.  
  39.  
  40. typedef struct _IP_NETWORK {
  41.     DWORD    N_NetNumber;
  42.     DWORD    N_NetMask;
  43.     } IP_NETWORK, *PIP_NETWORK;
  44.  
  45.  
  46.  
  47. // Protocol family dependent next hop router address structures
  48. typedef struct _IPX_NEXT_HOP_ADDRESS {
  49.     BYTE            NHA_Mac[6];
  50.     } IPX_NEXT_HOP_ADDRESS, *PIPX_NEXT_HOP_ADDRESS;
  51.  
  52. typedef IP_NETWORK IP_NEXT_HOP_ADDRESS, *PIP_NEXT_HOP_ADDRESS;
  53.  
  54.  
  55. // Protocol family dependent specific data structures
  56. typedef struct _IPX_SPECIFIC_DATA {
  57.     DWORD        FSD_Flags;    // should be set to 0 if no flags are defined
  58.     USHORT        FSD_TickCount;    // ticks to destination network
  59.     USHORT        FSD_HopCount;    // hops to destination network
  60.     } IPX_SPECIFIC_DATA, *PIPX_SPECIFIC_DATA;
  61.  
  62. // The following flags are defined for the IPX family dependent Flags field
  63.  
  64. #define   IPX_GLOBAL_CLIENT_WAN_ROUTE    0x00000001
  65.  
  66.  
  67. typedef    struct _IP_SPECIFIC_DATA 
  68. {
  69.     DWORD       FSD_Type;               // One of : other,invalid,local,remote (1-4)
  70.     DWORD       FSD_Policy;             // See RFC 1354
  71.     DWORD       FSD_NextHopAS;          // Autonomous System Number of Next Hop
  72.     DWORD       FSD_Priority;           // For comparing Inter Protocol Metrics
  73.     DWORD       FSD_Metric;             // For comparing Intra Protocol Metrics
  74.     DWORD        FSD_Metric1;            // Protocol specific metrics for MIB II
  75.     DWORD        FSD_Metric2;            // conformance. MIB II agents will not
  76.     DWORD        FSD_Metric3;            // display FSD_Metric, they will only 
  77.     DWORD        FSD_Metric4;            // display Metrics1-5, so if you want your
  78.     DWORD        FSD_Metric5;            // metric displayed, put it in one of these
  79.                                         // fields ALSO (It has to be in the 
  80.                                         // FSD_Metric field always). It is up to the
  81.                                         // implementor to keep the fields consistent
  82.     DWORD       FSD_Flags;              // Flags defined below
  83. } IP_SPECIFIC_DATA, *PIP_SPECIFIC_DATA;
  84.  
  85. //
  86. // All routing protocols MUST clear out the FSD_Flags field.
  87. // If RTM notifies a protocol of a route and that route is marked 
  88. // invalid, the protocols MUST disregard this route. A protocol
  89. // may mark a route as invalid, if it does not want the route to
  90. // be indicated to other protocols or set to the stack. e.g. RIPv2
  91. // marks summarized routes as INVALID and uses the RTM purely as
  92. // a store for such routes. These routes are not considered when
  93. // comparing metrics etc to decide the "best" route
  94. //
  95.  
  96. #define IP_VALID_ROUTE      0x00000001
  97.  
  98. #define ClearRouteFlags(pRoute)         \
  99.     ((pRoute)->RR_FamilySpecificData.FSD_Flags = 0x00000000)
  100.  
  101.         
  102. #define IsRouteValid(pRoute)            \
  103.     ((pRoute)->RR_FamilySpecificData.FSD_Flags & IP_VALID_ROUTE)
  104.  
  105.  
  106.         
  107. #define SetRouteValid(pRoute)          \
  108.     ((pRoute)->RR_FamilySpecificData.FSD_Flags |= IP_VALID_ROUTE)
  109.  
  110. #define ClearRouteValid(pRoute)        \
  111.     ((pRoute)->RR_FamilySpecificData.FSD_Flags &= ~IP_VALID_ROUTE)
  112.  
  113.  
  114.         
  115.         
  116. #define IsRouteNonUnicast(pRoute)      \
  117.     (((DWORD)((pRoute)->RR_Network.N_NetNumber & 0x000000FF)) >= ((DWORD)0x000000E0))
  118.  
  119. #define IsRouteLoopback(pRoute)        \
  120.     ((((pRoute)->RR_Network.N_NetNumber & 0x000000FF) == 0x0000007F) ||     \
  121.         ((pRoute)->RR_NextHopAddress.N_NetNumber == 0x0100007F))
  122.  
  123.  
  124. // Protocol dependent specific data structure
  125. typedef struct _PROTOCOL_SPECIFIC_DATA {
  126.     DWORD        PSD_Data[4];
  127.     } PROTOCOL_SPECIFIC_DATA, *PPROTOCOL_SPECIFIC_DATA;
  128.  
  129.     
  130.  
  131.  
  132. #define DWORD_ALIGN(type,field)    \
  133.     union {                        \
  134.         type    field;            \
  135.         DWORD    field##Align;    \
  136.         }
  137.  
  138. // Standard header associated with all types of routes
  139. #define ROUTE_HEADER                                 \
  140. DWORD_ALIGN (                                        \
  141.     FILETIME,                    RR_TimeStamp);        \
  142.     DWORD                        RR_RoutingProtocol;    \
  143.     DWORD                        RR_InterfaceID;        \
  144. DWORD_ALIGN (                                        \
  145.     PROTOCOL_SPECIFIC_DATA,        RR_ProtocolSpecificData)
  146.  
  147.     // Ensure dword aligment of all fields
  148.  
  149. // Protocol family dependent route entries
  150. // (intended for use by protocol handlers to pass paramerters
  151. // to and from RTM routines)
  152. typedef struct _RTM_IPX_ROUTE {
  153.     ROUTE_HEADER;
  154. DWORD_ALIGN (
  155.     IPX_NETWORK,                RR_Network);
  156. DWORD_ALIGN (
  157.     IPX_NEXT_HOP_ADDRESS,    RR_NextHopAddress);
  158. DWORD_ALIGN (
  159.     IPX_SPECIFIC_DATA,        RR_FamilySpecificData);
  160.     } RTM_IPX_ROUTE, *PRTM_IPX_ROUTE; 
  161.  
  162. typedef struct _RTM_IP_ROUTE {
  163.     ROUTE_HEADER;
  164. DWORD_ALIGN (
  165.     IP_NETWORK,                RR_Network);
  166. DWORD_ALIGN (
  167.     IP_NEXT_HOP_ADDRESS,    RR_NextHopAddress);
  168. DWORD_ALIGN (
  169.     IP_SPECIFIC_DATA,        RR_FamilySpecificData);
  170.     } RTM_IP_ROUTE, *PRTM_IP_ROUTE; 
  171.  
  172.  
  173.  
  174. // RTM route change message flags
  175.     // Flags to test the presence of route change information 
  176.     // in the buffers filled by RTM routines
  177. #define RTM_CURRENT_BEST_ROUTE            0x00000001
  178. #define RTM_PREVIOUS_BEST_ROUTE            0x00000002
  179.  
  180.     // Flags that convey what acutally happened
  181. #define RTM_NO_CHANGE        0
  182. #define RTM_ROUTE_ADDED        RTM_CURRENT_BEST_ROUTE
  183. #define RTM_ROUTE_DELETED    RTM_PREVIOUS_BEST_ROUTE
  184. #define RTM_ROUTE_CHANGED    (RTM_CURRENT_BEST_ROUTE|RTM_PREVIOUS_BEST_ROUTE)
  185.  
  186. // Enumeration flags limit that enumerations of routes in the table
  187. // to only entries with the specified field(s)
  188. #define RTM_ONLY_THIS_NETWORK           0x00000001
  189. #define RTM_ONLY_THIS_INTERFACE            0x00000002
  190. #define RTM_ONLY_THIS_PROTOCOL            0x00000004
  191. #define RTM_ONLY_BEST_ROUTES            0x00000008
  192.  
  193. #define RTM_PROTOCOL_SINGLE_ROUTE        0x00000001
  194.  
  195. /*++
  196. *******************************************************************
  197.  
  198.     R t m R e g i s t e r C l i e n t
  199.  
  200. Routine Description:
  201.     Registers client as a handler of specified protocol.
  202.     Establishes route change notification mechanism for the client
  203.  
  204. Arguments:
  205.     ProtocolFamily - protocol family of the routing protocol to register
  206.     RoutingProtocol - which routing protocol is handled by the client
  207.     ChangeEvent - this event will be signalled when best route to any
  208.                     network in the table changes
  209.     Flags - flags that enable special features applied to routes maintained
  210.             by the protocol:
  211.                 RTM_PROTOCOL_SINGLE_ROUTE - RTM will only keep
  212.                     one route per destination network for the protocol
  213. Return Value:
  214.     Handle to be used to identify the client in calls made to Rtm
  215.     NULL - operation failed, call GetLastError() to get reason of
  216.     failure:
  217.         ERROR_INVALID_PARAMETER - specified protocol family is not supported
  218.         ERROR_CLIENT_ALREADY_EXISTS - another client already registered
  219.                                 to handle specified protocol
  220.         ERROR_NO_SYSTEM_RESOURCES - not enough resources to perform the opertaion,
  221.                             try again later
  222.         ERROR_NOT_ENOUGH_MEMORY - not enough memory to allocate client
  223.                              control block
  224.  
  225. *******************************************************************
  226. --*/
  227. HANDLE WINAPI
  228. RtmRegisterClient (
  229.     IN DWORD          ProtocolFamily,
  230.     IN DWORD          RoutingProtocol,
  231.     IN HANDLE        ChangeEvent OPTIONAL,
  232.     IN DWORD        Flags
  233.     );
  234.  
  235.  
  236. /*++
  237. *******************************************************************
  238.  
  239.     R t m D e r e g i s t e r C l i e n t
  240.  
  241. Routine Description:
  242.     Deregister client and frees associated resources (including all
  243.     routes added by the client).
  244.  
  245. Arguments:
  246.     ClientHandle - handle that identifies the client to deregister from RTM
  247. Return Value:
  248.     NO_ERROR - client was deregisterd and resources were disposed OK.
  249.     ERROR_INVALID_HANDLE - client handle is not a valid RTM handle
  250.     ERROR_NO_SYSTEM_RESOURCES - not enough resources to complete the operation,
  251.                             try again later
  252.  
  253. *******************************************************************
  254. --*/
  255. DWORD WINAPI
  256. RtmDeregisterClient (
  257.     IN HANDLE        ClientHandle
  258.     );
  259.  
  260.  
  261. /*++
  262. *******************************************************************
  263.  
  264.     R t m D e q u e u e R o u t e C h a n g e M e s s a g e
  265.  
  266. Routine Description:
  267.     Dequeues and returns first route change message from the queue
  268.     associated with the client
  269.  
  270. Arguments:
  271.     ClientHandle - handle that identifies the client for which the opertation
  272.                     is performed
  273.     Flags - identifies what kind of change the message is about and what
  274.             information was palced into the provided buffers:
  275.         RTM_ROUTE_ADDED - first route was added for a destination network,
  276.                             CurBestRoute is filled with added route info
  277.         RTM_ROUTE_DELETED - the only route available for a destination
  278.                             network was deleted, PrevBestRoute is filled
  279.                             with deleted route info
  280.         RTM_ROUTE_CHANGED - there was a change in any of the following
  281.                             parameters of the BEST route to a destination
  282.                             network:
  283.                                 RoutingProtocol,
  284.                                 InterfaceID,
  285.                                 Metric,
  286.                                 NextHopAddress,
  287.                                 FamilySpecificData.
  288.                             PrevBestRoute contains the route info as it was
  289.                             before the change, CurBestRoute contains current
  290.                             best route info.
  291.                 Note that the route change message can be generated
  292.                 both as result of protocol adding/deleting the route
  293.                 that becomes/was the best and changing best route parameters
  294.                 such that route becomes/no longer is the best route.
  295.     CurBestRoute - buffer to receive current best route info (if any)
  296.     PrevBestRoute - buffer to receive previous best route info (if any)
  297. Return Value:
  298.     NO_ERROR - this was the last (or only) message in the client's
  299.                  queue (event is reset)
  300.     ERROR_MORE_MESSAGES - there are more messages awaiting client,
  301.                 this call should be made again as soon as possible
  302.                 to let RTM free resources associated with unprocessed
  303.                 messages
  304.     ERROR_NO_MESSAGES - there are no messages in the clients queue,
  305.                 this was an unsolicited call (event is reset)
  306.     ERROR_INVALID_HANDLE - client handle is not a valid RTM handle
  307.     ERROR_NO_SYSTEM_RESOURCES - not enough resources to perform the operation,
  308.                             try again later
  309.  
  310. *******************************************************************
  311. --*/
  312. DWORD WINAPI
  313. RtmDequeueRouteChangeMessage (
  314.     IN    HANDLE        ClientHandle,
  315.     OUT    DWORD        *Flags,
  316.     OUT PVOID        CurBestRoute    OPTIONAL,
  317.     OUT    PVOID        PrevBestRoute    OPTIONAL
  318.     );
  319.  
  320.  
  321.  
  322. /*++
  323. *******************************************************************
  324.  
  325.     R t m A d d R o u t e
  326.  
  327. Routine Description:
  328.     Adds or updates existing route entry and generates route change
  329.     message if best route to a destination network has changed as the
  330.     result of this operation.
  331.     Note that route change message is not sent to the client that
  332.     makes this change, but rather relevant information is returned
  333.     by this routine directly.
  334.  
  335. Arguments:
  336.     ClientHandle - handle that identifies the client for which the opertation
  337.                     is performed, it also supplies RoutingProtocol field
  338.                     of the new/updated route
  339.     Route - route to be added/updated.
  340.             The following fields of protocol family dependent
  341.             RTM_??_ROUTE structure are used to construct/update
  342.             route entry:
  343.         RR_Network:            destination network
  344.         RR_InterfaceID:     id of interface through which route was received
  345.         RR_NextHopAddress:    address of next hop router
  346.         RR_FamilySpecificData: data specific to protocol's family
  347.         RR_ProtocolSpecificData: data specific to protocol which supplies the
  348.                             route (subject to size limitation defined by
  349.                             PROTOCOL_SPECIFIC_DATA structure above)
  350.         RR_TimeStamp:        current time, which is actually read from system
  351.                             timer (need not be supplied)
  352.         Note that combination of
  353.             RoutingProtocol,
  354.             Network,
  355.             InterfaceID, and
  356.             NextHopAddress
  357.                                 uniquely identifies route entry in the table.
  358.         New entry is created if one of these fields does not match those of
  359.         an existing entry, otherwise existing entry is changed (see also
  360.         ReplaceEntry flag below).
  361.  
  362.         Regardless of whether new entry is created or old one is updated,
  363.         this operation will generate a route change message if affected
  364.         route becomes/is/no longer is the best route to a destination network
  365.         and at least one of the following parameters in the best route is
  366.         changed as the result of this operation:
  367.                                 RoutingProtocol,
  368.                                 InterfaceID,
  369.                                 NextHopAddress,
  370.                                 FamilySpecificData.
  371.     TimeToLive -  how long route should be kept in the table in seconds.
  372.                 Pass INFINITE if route is to be kept until deleted explicitly
  373.         Note the current limit for TimeToLive is 2147483 sec (24+ days).
  374.     Flags - returns what change message (if any) will be generated by the
  375.             RTM as the result of this addition/update and identifies what
  376.             information was palced into the provided buffers:
  377.         RTM_NO_CHANGE - this was an update that either did not change any of
  378.                         the significant route parameters (described above)
  379.                         or the route entry affected is not the best
  380.                         to the destination network
  381.         RTM_ROUTE_ADDED - the route added is the first known route for a
  382.                             destination network,
  383.                             CurBestRoute is filled with added route info
  384.         RTM_ROUTE_CHANGED - there was a change in any of the significant
  385.                             parameters of the BEST route to a destination
  386.                             network as the result if this operation.
  387.                             PrevBestRoute contains the route info as it was
  388.                             before the change, CurBestRoute contains current
  389.                             best route info.
  390.                 Note the the CurBestRoute does not neccessarily the same
  391.                 as added route, because if update causes route metric
  392.                 to change, another route entry may become the best for
  393.                 a given destination and its info will be returned in
  394.                 CurBestRoute buffer.  PrevBestRoute buffer in the latter
  395.                 case will contain route entry as it was before this operation
  396.                 was performed.
  397.     CurBestRoute - buffer to receive current best route info (if any)
  398.     PrevBestRoute - buffer to receive previous best route info (if any)
  399. Return Value:
  400.     NO_ERROR                 - route was added/updated OK
  401.     ERROR_INVALID_PARAMETER - route contains invalid parameter 
  402.     ERROR_INVALID_HANDLE - client handle is not a valid RTM handle
  403.     ERROR_NOT_ENOUGH_MEMORY - route could not be adeed because of memory
  404.                                 allocation problem
  405.     ERROR_NO_SYSTEM_RESOURCES - not enough resources to perform the operation,
  406.                             try again later
  407.  
  408. *******************************************************************
  409. --*/
  410. DWORD WINAPI
  411. RtmAddRoute (
  412.     IN HANDLE        ClientHandle,
  413.     IN PVOID        Route,
  414.     IN DWORD        TimeToLive,
  415.     OUT DWORD        *Flags,
  416.     OUT PVOID        CurBestRoute OPTIONAL,
  417.     OUT PVOID        PrevBestRoute OPTIONAL
  418.     );
  419.      
  420.  
  421. /*++
  422. *******************************************************************
  423.  
  424.     R t m D e l e t e R o u t e
  425.  
  426. Routine Description:
  427.     Deletes existing route entry and generates route change
  428.     message if best route to a destination network has changed as the
  429.     result of this operation.
  430.     Note that route change message is not sent to the client that
  431.     makes this change, but rather relevant information is returned
  432.     by this routine directly.
  433.  
  434. Arguments:
  435.     ClientHandle - handle that identifies the client for which the opertation
  436.                     is performed, it also supplies RoutingProtocol field
  437.                     of the route to be deleted
  438.     Route - route to be deleted.
  439.             The following fields of protocol family dependent
  440.             RTM_??_ROUTE structure are used to identify
  441.             route entry to be deleted:
  442.         RR_Network:            destination network
  443.         RR_InterfaceID:     id of interface through which route was received
  444.         RR_NextHopAddress:    address of next hop router
  445.  
  446.         If the deleted entry represented the best route to a destination
  447.         network, this operation will generate route change message
  448.     Flags - returns what change message (if any) will be generated by the
  449.             RTM as the result of this deletion and identifies what
  450.             information was palced into the provided buffer:
  451.         RTM_NO_CHANGE - the deleted route did not affect best route to 
  452.                         any destination network (there is another entry that
  453.                         represents route to the same destination nework and
  454.                         it has better metric)
  455.         RTM_ROUTE_DELETED - the deleted route was the only route avaliable
  456.                             for the destination network
  457.         RTM_ROUTE_CHANGED - after this route was deleted another route
  458.                         became the best to the destination network,
  459.                         CurBestRoute will be filled with that route info
  460.     CurBestRoute - buffer to receive current best route info (if any)
  461. Return Value:
  462.     NO_ERROR                 - route was deleted OK
  463.     ERROR_INVALID_PARAMETER - route contains invalid parameter 
  464.     ERROR_INVALID_HANDLE - client handle is not a valid RTM handle
  465.     ERROR_NO_SUCH_ROUTE - there is no entry in the table that
  466.                         has specified parameters
  467.     ERROR_NO_SYSTEM_RESOURCES - not enough resources to perform the operation,
  468.                             try again later
  469.  
  470. *******************************************************************
  471. --*/
  472. DWORD WINAPI
  473. RtmDeleteRoute (
  474.     IN HANDLE        ClientHandle,
  475.     IN PVOID        Route,
  476.     OUT    DWORD        *Flags,
  477.     OUT PVOID        CurBestRoute OPTIONAL
  478.     );
  479.  
  480.  
  481.  
  482. /*++
  483. *******************************************************************
  484.  
  485.     R t m I s R o u t e
  486.  
  487. Routine Description:
  488.     Checks if route exists to specified network and returns best
  489.     route info
  490.  
  491. Arguments:
  492.     ProtocolFamily - identifies protocol family of route of interest
  493.     Network - contains protocol family dependent network number data
  494.             (as defined by ??_NETWORK structures above)
  495.     BestRoute - buffer to receive current best route info (if any)
  496. Return Value:
  497.     TRUE - route to network of interest exists
  498.     FALSE - not route exist or operation failed, call GetLastError()
  499.     to obtain reason of failure:
  500.         NO_ERROR                 - operation succeded but not route exists
  501.         ERROR_INVALID_PARAMETER - input parameter(s) is invalid (unsupported
  502.                                     protocol family)
  503.         ERROR_NO_SYSTEM_RESOURCES - not enough resources to perform the operation,
  504.                             try again later
  505.  
  506. *******************************************************************
  507. --*/
  508. BOOL WINAPI
  509. RtmIsRoute (
  510.     IN     DWORD        ProtocolFamily,
  511.     IN     PVOID       Network,
  512.     OUT    PVOID         BestRoute OPTIONAL
  513.     );
  514.  
  515.     
  516. /*++
  517. *******************************************************************
  518.  
  519.     R t m G e t N e t w o r k C o u n t
  520.  
  521. Routine Description:
  522.     Returns number of networks that RTM has routes to.
  523.  
  524. Arguments:
  525.     ProtocolFamily - identifies protocol family of interest
  526. Return Value:
  527.     Number of known networks
  528.     0 if no routes are availabel in the table or operation failed,
  529.     call GetLastError () to get reason of failure:
  530.         NO_ERROR - operation succeded but no routes available
  531.         ERROR_INVALID_PARAMETER - input parameter is invalid (unsupported
  532.                                     protocol family)
  533.  
  534. *******************************************************************
  535. --*/
  536. ULONG WINAPI
  537. RtmGetNetworkCount (
  538.     IN    DWORD        ProtocolFamily
  539.     );
  540.  
  541. /*++
  542. *******************************************************************
  543.  
  544.     R t m G e t R o u t e A g e
  545.  
  546. Routine Description:
  547.     Returns route age (time since it was created or updated) in seconds
  548.     Route structure must have been recently filled by RTM for this to
  549.     return valid results (route age is actually computed from
  550.     RR_TimeStamp field)
  551.  
  552. Arguments:
  553.     Route - protocol family dependent route data (RTM_??_ROUTE data
  554.             structure) that was obtained from RTM (returned by
  555.             its routines)
  556. Return Value:
  557.     Route age in seconds
  558.     INFINITE - if content of route is invalid (GetLastError () returns
  559.         ERROR_INVALID_PARAMETER)
  560.  
  561. *******************************************************************
  562. --*/
  563. ULONG WINAPI
  564. RtmGetRouteAge (
  565.     IN PVOID        Route
  566.     );
  567.  
  568.  
  569.  
  570.  
  571.  
  572. /*++
  573. *******************************************************************
  574.  
  575.     R t m C r e a t e E n u m e r a t i o n H a n d l e
  576.  
  577. Routine Description:
  578.     Creates a handle that will allow the caller to use fast and change
  579.     tolerant enumeration API to scan through all routes or a subset of them
  580.     known to the RTM. Note that scans performed by this API do not return
  581.     routes in any particular order.
  582.  
  583. Arguments:
  584.     ProtocolFamily - identifies protocol family of interest
  585.     EnumerationFlags - limit routes returned by enumeration API to a subset
  586.                         members of which have same values in the fields
  587.                         specified by the flags as in CriteriaRoute
  588.                         (RTM_ONLY_BEST_ROUTES does not require a criterion)
  589.     CriteriaRoute - protocol family dependent structure (RTM_??_ROUTE) with
  590.                     set values in fields that correspond to EnumerationFlags
  591. Return Value:
  592.     Handle that can be used with enumeration API below
  593.     NULL no routes exists with specified criteria or operation failed,
  594.             call GetLastError () to get reason of failure:
  595.         ERROR_NO_ROUTES - no routes exist with specified criteria
  596.         ERROR_INVALID_PARAMETER - input parameter(s) is invalid (unsupported
  597.                     protocol family, invalid enumeration flag, etc)
  598.         ERROR_NOT_ENOUGH_MEMORY - handle could not be created because of memory
  599.                                 allocation problem
  600.         ERROR_NO_SYSTEM_RESOURCES - not enough resources to perform the operation,
  601.                             try again later
  602.  
  603. *******************************************************************
  604. --*/
  605. HANDLE WINAPI
  606. RtmCreateEnumerationHandle (
  607.     IN    DWORD        ProtocolFamily,
  608.     IN    DWORD        EnumerationFlags,
  609.     IN    PVOID        CriteriaRoute
  610.     );
  611.  
  612.  
  613. /*++
  614. *******************************************************************
  615.  
  616.     R t m E n u m e r a t e G e t N e x t R o u t e
  617.  
  618. Routine Description:
  619.     Returns next route entry in enumeration started by
  620.     RtmCreateEnumerationHandle.
  621.  
  622. Arguments:
  623.     EnumerationHandle - handle that identifies enumeration
  624.     Route - buffer (RTM_??_ROUTE structure) that receives next
  625.             route in enumeration
  626. Return Value:
  627.     NO_ERROR - next availbale route was placed in the buffer
  628.     ERROR_NO_MORE_ROUTES - no more routes exist with soecified criteria
  629.     ERROR_INVALID_HANDLE - enumeration handle is not a valid RTM handle
  630.     ERROR_NO_SYSTEM_RESOURCES - not enough resources to perform the operation,
  631.                             try again later
  632.  
  633. *******************************************************************
  634. --*/
  635. DWORD WINAPI
  636. RtmEnumerateGetNextRoute (
  637.     IN  HANDLE        EnumerationHandle,
  638.     OUT PVOID        Route
  639.     );
  640.  
  641. /*++
  642. *******************************************************************
  643.  
  644.     R t m C l o s e E n u m e r a t i o n H a n d l e
  645.  
  646. Routine Description:
  647.     Terminates enumerationand frees associated resources
  648.  
  649. Arguments:
  650.     EnumerationHandle - handle that identifies enumeration
  651. Return Value:
  652.     NO_ERROR - enumeration was termineted ok
  653.     ERROR_INVALID_HANDLE - enumeration handle is not a valid RTM handle
  654.     ERROR_NO_SYSTEM_RESOURCES - not enough resources to perform the operation,
  655.                             try again later
  656.  
  657. *******************************************************************
  658. --*/
  659. DWORD WINAPI
  660. RtmCloseEnumerationHandle (
  661.     IN HANDLE        EnumerationHandle
  662.     );
  663.  
  664.  
  665. /*++
  666. *******************************************************************
  667.  
  668.     R t m B l o c k D e l e t e R o u t e s
  669.  
  670. Routine Description:
  671.     Deletes all routes in subset specified by enumeration flags and
  672.     corresponding criteria.  This operation can only be performed by
  673.     the registered client and applies only to routes added by this
  674.     client.
  675.     Route change messages will be generated for deleted routes that
  676.     were the best
  677. Arguments:
  678.     ClientHandle - handle that identifies the client and routing protocol
  679.                         of routes to be deleted
  680.     EnumerationFlags - further limit subset of routes being deleted to only
  681.                         those that have same values in the fields
  682.                         specified by the flags as in CriteriaRoute
  683.         Note that only RTM_ONLY_THIS_NETWORK and RTM_ONLY_THIS_INTERFACE
  684.         can be used (RTM_ONLY_BEST_ROUTES does not apply because best
  685.         route designation is adjusted as routes are deleted and
  686.         all routes will be deleted anyway)
  687.     CriteriaRoute - protocol family dependent structure (RTM_??_ROUTE) with
  688.                     set values in fields that correspond to EnumerationFlags
  689. Return Value:
  690.     NO_ERROR - routes were deleted ok
  691.     ERROR_NO_ROUTES - no routes exist that match specified criteria
  692.     ERROR_INVALID_HANDLE - client handle is not a valid RTM handle
  693.     ERROR_NOT_ENOUGH_MEMORY - could not allocate memory to perform
  694.                         the operation
  695.     ERROR_NO_SYSTEM_RESOURCES - not enough resources to perform the operation,
  696.                             try again later
  697.  
  698. *******************************************************************
  699. --*/
  700. DWORD WINAPI
  701. RtmBlockDeleteRoutes (
  702.     IN HANDLE        ClientHandle,
  703.     IN DWORD        EnumerationFlags,
  704.     IN PVOID        CriteriaRoute
  705.     );
  706.  
  707. /*++
  708. *******************************************************************
  709.  
  710.     R t m G e t F i r s t R o u t e
  711.  
  712. Routine Description:
  713.     Returns first route in the NetworkNumber.RoutingProtocol.InterfaceID.
  714.     NextHopAddress order from the subset specifed by the enumeration flags.
  715.     Note that this operation may consume significant processing time because
  716.     first all recently changed routes will have to be merged into the
  717.     ordered list, and this list will then have to be traversed to locate
  718.     the route of interest.
  719.  
  720. Arguments:
  721.     ProtocolFamily - identifies protocol family of interest
  722.     EnumerationFlags - limit routes returned by enumeration API to a subset
  723.                         members of which have same values in the fields
  724.                         specified by the flags as in CriteriaRoute
  725.                         (RTM_ONLY_BEST_ROUTES does not require a criterion)
  726.     Route - protocol family dependent structure (RTM_??_ROUTE) with
  727.                     set values in fields that correspond to EnumerationFlags
  728.                     on INPUT and first route that matches specified
  729.                     criteria on OUTPUT
  730. Return Value:
  731.     NO_ERROR - matching route was found
  732.     ERROR_NO_ROUTES - no routes exist with specified criteria
  733.     ERROR_INVALID_PARAMETER - input parameter(s) is invalid (unsupported
  734.                     protocol family, invalid enumeration flag, etc)
  735.     ERROR_NO_SYSTEM_RESOURCES - not enough resources to perform the operation,
  736.                             try again later
  737.  
  738. *******************************************************************
  739. --*/
  740. DWORD WINAPI
  741. RtmGetFirstRoute (
  742.     IN    DWORD        ProtocolFamily,
  743.     IN    DWORD        EnumerationFlags,
  744.     IN OUT PVOID     Route
  745.     );
  746.  
  747. #define RtmGetSpecificRoute(ProtocolFamily,Route)        \
  748.         RtmGetFirstRoute(ProtocolFamily,                \
  749.                         RTM_ONLY_THIS_NETWORK            \
  750.                             | RTM_ONLY_THIS_PROTOCOL    \
  751.                             | RTM_ONLY_THIS_INTERFACE,    \
  752.                         Route)
  753.  
  754. /*++
  755. *******************************************************************
  756.  
  757.     R t m G e t N e x t R o u t e
  758.  
  759. Routine Description:
  760.     Returns route that follows specified route in the NetworkNumber.
  761.     RoutingProtocol.InterfaceID.NextHopAddress order from the subset defined
  762.     by the enumeration flags.
  763.     Note that this operation may consume significant processing time because
  764.     first all recently changed routes will have to be merged into the
  765.     ordered list, and this list may then have to be traversed to locate
  766.     the route of interest.
  767.  
  768. Arguments:
  769.     ProtocolFamily - identifies protocol family of interest
  770.     EnumerationFlags - limit routes returned by enumeration API to a subset
  771.                         members of which have same values in the fields
  772.                         specified by the flags as in Route
  773.                         (RTM_ONLY_BEST_ROUTES does not require a criterion)
  774.     Route - protocol family dependent structure (RTM_??_ROUTE) which both
  775.                     provides the route from which to start the search and
  776.                     set values in fields that correspond to EnumerationFlags
  777.                     on INPUT and route that both follows input route in
  778.                     NetworkNumber.RoutingProtocol.InterfaceID.NextHopAddress
  779.                     order and matches specified criteria on OUTPUT
  780. Return Value:
  781.     NO_ERROR - matching route was found
  782.     ERROR_NO_ROUTES - no routes exist with specified criteria
  783.     ERROR_INVALID_PARAMETER - input parameter(s) is invalid (unsupported
  784.                     protocol family, invalid enumeration flag, etc)
  785.     ERROR_NO_SYSTEM_RESOURCES - not enough resources to perform the operation,
  786.                             try again later
  787.  
  788. *******************************************************************
  789. --*/
  790. DWORD WINAPI
  791. RtmGetNextRoute (
  792.     IN    DWORD        ProtocolFamily,
  793.     IN    DWORD        EnumerationFlags,
  794.     IN OUT PVOID     Route
  795.     );
  796.  
  797. #ifdef __cplusplus
  798. }
  799. #endif
  800.  
  801. #endif //__ROUTING_RTM_H__
  802.