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