dan_schiro

How to obtain the routing table information in Nucleus NET

Discussion created by dan_schiro on Aug 6, 2012

Introduction:

Nucleus NET does not have an API that will 'dump' the routing table information similar to

>route print

on a PC.   However, it is possible to use some of the API functions  of NET to gather this information. Below is some sample code to walk the  routing tree using NU_Find_Next_Route_Entry:

 

The Code:

 

RTAB4_ROUTE_ENTRY   *current_route;

.

.

/* Get a pointer to the first route in the route table */

    current_route =

        (RTAB4_ROUTE_ENTRY*)NU_Find_Next_Route_Entry(OS_NULL, NU_FAMILY_IP);

 

       /*add code here to save/display the root entry by whatever method desired*/

while (current_route)

     {

        /* Get a pointer to the next route */

        current_route =

            (RTAB4_ROUTE_ENTRY*)NU_Find_Next_Route_Entry((ROUTE_ENTRY*)current_route,

                                     NU_FAMILY_IP);

 

        /*add code here to save/display the root entry by whatever method desired*/

     }

 

 

Understanding the return values:

 

The returned RTAB4_ROUTE_ENTRY structure is defined as:

struct rtab4_route_entry

{

    struct rtab4_route_entry    *rt_entry_next;

    struct rtab4_route_entry    *rt_entry_prev;

    struct route_entry_parms    rt_entry_parms;

    struct route_node           *rt_route_node; /* ROUTE_NODE to which the entry

                                                 * belongs. */

    SCK_SOCKADDR_IP             rt_gateway_v4;  /* gateway for route, if any */

};

 

 

Out of the above entries, the rt_entry_parms structure and the value  of the rt_gateway_v4, which is the next hop for this route, are the most  commonly sought items.

 

The rt_entry_parms structure is defined as:

struct route_entry_parms

{

    INT16               rt_parm_refcnt;      /* # held references */

    UINT16              rt_parm_routetag;

    UINT32              rt_parm_flags;       /* Up/Down, Host/Net */

    UINT32              rt_parm_use;         /* # of packets sent over this route */

    UINT32              rt_parm_clock;       /* number of clock ticks of last update */

    UINT32              rt_parm_metric;      /* must be a value of 1 to 16 */

    DV_DEVICE_ENTRY     *rt_parm_device;     /* pointer to the interface structure */

    UINT32              rt_parm_path_mtu;

#if (INCLUDE_PMTU_DISCOVERY == OS_TRUE)

    UINT32              rt_parm_pmtu_timestamp;

#endif

};

 

The common parameters used out of this structure for troubleshooting  are the rt_parm_refcnt, rt_parm_path_mtu, and *rt_parm_device.

 

The rt_parm_refcnt will be the count of the number of instances that  this route is currently being used by the system (generally 0 or 1).

 

The rt_parm_path_mtu value holds the MTU value for the route. Nucleus  NET will use the smaller of the device (Ethernet, PPP, etc) MTU or the  route MTU for segmenting packets.

 

*rt_parm_device is the device entry pointer for the device that will  be used to send packets using this route.  This value is helpful for  troubleshooting multi-homed systems when packets appear to be coming out  of the wrong interface.

Outcomes