VxWorks Reference Manual : Libraries

routeLib

NAME

routeLib - network route manipulation library

ROUTINES

routeAdd( ) - add a route
routeNetAdd( ) - add a route to a destination that is a network
routeDelete( ) - delete a route
mRouteAdd( ) - add multiple routes to the same destination
mRouteEntryAdd( ) - add a protocol-specific route to the routing table
mRouteEntryDelete( ) - delete route from the routing table
mRouteDelete( ) - delete a route from the routing table
routeProtoPrioritySet( ) - set the priority of routes added by the routing protocol

DESCRIPTION

This library contains the routines for inspecting the routing table, as well as routines for adding and deleting routes from that table. If you do not configure VxWorks to include a routing protocol, such as RIP or OSPF, you can use these routines to maintain the routing tables manually.

INCLUDE FILES

routeLib.h

SEE ALSO

routeLib, hostLib, Network Programmer's Guide


Libraries : Routines

routeAdd( )

NAME

routeAdd( ) - add a route

SYNOPSIS

STATUS routeAdd
    (
    char * destination, /* inet addr or name of route destination */
    char * gateway      /* inet addr or name of gateway to destination */
    )

DESCRIPTION

This routine adds gateways to the network routing tables. It is called from a VxWorks machine that needs to establish a gateway to a destination network (or machine).

You can specify both destination and gateway in standard Internet address format (for example, 90.0.0.2), or you can specify them using their host names, as specified with hostAdd( ).

EXAMPLE

Consider the following example:

    -> routeAdd "90.0.0.0", "gate"
This call tells VxWorks that the machine with the host name "gate" is the gateway to network 90.0.0.0. The host "gate" must already have been created by hostAdd( ).

Consider the following example:

    -> routeAdd "90.0.0.0", "91.0.0.3"
This call tells VxWorks that the machine with the Internet address 91.0.0.3 is the gateway to network 90.0.0.0.

Consider the following example:

    -> routeAdd "destination", "gate"
This call tells VxWorks that the machine with the host name "gate" is the gateway to the machine named "destination". The host names "gate" and "destination" must already have been created by hostAdd( ).

Consider the following example:

    -> routeAdd "0", "gate"
This call tells VxWorks that the machine with the host name "gate" is the default gateway. The host "gate" must already have been created by hostAdd( ). A default gateway is where Internet Protocol (IP) datagrams are routed when there is no specific routing table entry available for the destination IP network or host.

RETURNS

OK or ERROR.

SEE ALSO

routeLib


Libraries : Routines

routeNetAdd( )

NAME

routeNetAdd( ) - add a route to a destination that is a network

SYNOPSIS

STATUS routeNetAdd
    (
    char * destination, /* inet addr or name of network destination */
    char * gateway      /* inet addr or name of gateway to destination */
    )

DESCRIPTION

This routine is equivalent to routeAdd( ), except that the destination address is assumed to be a network. This is useful for adding a route to a sub-network that is not on the same overall network as the local network.

RETURNS

OK or ERROR.

SEE ALSO

routeLib


Libraries : Routines

routeDelete( )

NAME

routeDelete( ) - delete a route

SYNOPSIS

STATUS routeDelete
    (
    char * destination, /* inet addr or name of route destination */
    char * gateway      /* inet addr or name of gateway to destination */
    )

DESCRIPTION

This routine deletes a specified route from the network routing tables.

RETURNS

OK or ERROR.

SEE ALSO

routeLib, routeAdd( )


Libraries : Routines

mRouteAdd( )

NAME

mRouteAdd( ) - add multiple routes to the same destination

SYNOPSIS

STATUS mRouteAdd
    (
    char * pDest, /* destination addr in internet dot notation */
    char * pGate, /* gateway address in internet dot notation */
    long   mask,  /* mask for destination */
    int    tos,   /* type of service */
    int    flags  /* route flags */
    )

DESCRIPTION

This routine is similar to routeAdd( ), except that you can use multiple mRouteAdd( ) calls to add multiple routes to the same location. Use pDest to specify the destination, pGate to specify the gateway to that destination, mask to specify destination mask, and tos to specify the type of service. For tos, netinet/ip.h defines the following constants as valid values:

    IPTOS_LOWDELAY
    IPTOS_THROUGHPUT
    IPTOS_RELIABILITY
    IPTOS_MINCOST

Use flags to specify any flags you want to associate with this entry. The valid non-zero values are RTF_HOST and RTF_CLONING defined in net/route.h.

EXAMPLE

To add a route to the 90.0.0.0 network through 91.0.0.3:

    -> mRouteAdd ("90.0.0.0", "91.0.0.3", 0xffffff00, 0, 0);
Using mRouteAdd( ), you could create multiple routes to the same destination. VxWorks would distinguish among these routes based on factors such as the netmask or the type of service. Thus, it is perfectly legal to say:
    -> mRouteAdd ("90.0.0.0", "91.0.0.3", 0xffffff00, 0, 0);

    -> mRouteAdd ("90.0.0.0", "91.0.0.254", 0xffff0000, 0, 0);
This adds two routes to the same network, "90.0.0.0", that go by two different gateways. The differentiating factor is the netmask.

This routine adds a route of type M2_ipRouteProto_other, which is a static route. This route will not be modified or deleted until a call to mRouteDelete( ) removes it.

RETURNS

OK or ERROR.

SEE ALSO

routeLib, mRouteEntryAdd( ), mRouteDelete( ), routeAdd( )


Libraries : Routines

mRouteEntryAdd( )

NAME

mRouteEntryAdd( ) - add a protocol-specific route to the routing table

SYNOPSIS

STATUS mRouteEntryAdd
    (
    long destIp, /* destination address, network order */
    long gateIp, /* gateway address, network order */
    long mask,   /* mask for destination, network order */
    int  tos,    /* type of service */
    int  flags,  /* route flags */
    int  proto   /* routing protocol */
    )

DESCRIPTION

For a single destination destIp, this routine can add additional routes gateIp to the routing table. The different routes are distinguished by a destination mask mask, the type of service tos, and associated flag values flags. Valid values for flags are 0, RTF_HOST, RTF_CLONING (defined in net/route.h). The proto parameter identifies the protocol that generated this route. Values for proto may be found in m2Lib.h. The tos parameter takes one of following values (defined in netinet/ip.h):

    IPTOS_LOWDELAY
    IPTOS_THROUGHPUT
    IPTOS_RELIABILITY
    IPTOS_MINCOST

RETURNS

OK or ERROR.

SEE ALSO

routeLib, m2Lib.h, mRouteAdd( ), mRouteDelete( )


Libraries : Routines

mRouteEntryDelete( )

NAME

mRouteEntryDelete( ) - delete route from the routing table

SYNOPSIS

STATUS mRouteEntryDelete
    (
    long destIp, /* destination address, network order */
    long gateIp, /* gateway address, network order */
    long mask,   /* mask for destination, network order */
    int  tos,    /* type of service */
    int  flags,  /* route flags */
    int  proto   /* routing protocol */
    )

DESCRIPTION

This routine deletes a protocol-specific route from the routing table. Specify the route using a destination pDest, a gateway pGate, a destination mask mask, the type of service tos, a flags value, and a proto value that identifies the routing protocol that added the route. The valid values for flags are 0 and RTF_HOST (defined in net/route.h). Values for proto may be found in m2Lib.h and tos is one of the following values defined in netinet/ip.h:

    IPTOS_LOWDELA
    IPTOS_THROUGHPU
    IPTOS_RELIABILIT
    IPTOS_MINCOST

An existing route is deleted only if it is owned by the protocol specified by proto.

RETURNS

OK or ERROR.

SEE ALSO

routeLib


Libraries : Routines

mRouteDelete( )

NAME

mRouteDelete( ) - delete a route from the routing table

SYNOPSIS

STATUS mRouteDelete
    (
    char * pDest, /* destination address */
    long   mask,  /* mask for destination */
    int    tos,   /* type of service */
    int    flags  /* either 0 or RTF_HOST */
    )

DESCRIPTION

This routine deletes a routing table entry as specified by the destination, pDest, the destination mask, mask, and type of service, tos. The tos values are as defined in the reference entry for mRouteAdd( ).

EXAMPLE

Consider the case of a route added in the following manner:

    -> mRouteAdd ("90.0.0.0", "91.0.0.3", 0xffffff00, 0, 0);
To delete a route that was added in the above manner, call mRouteDelete( ) as follows:
    -> mRouteDelete("90.0.0.0", 0xffffff00, 0);
If the netmask and or type of service do not match, the route is not deleted.

The value of flags should be RTF_HOST for host routes, RTF_CLONING for routes which need to be cloned, and 0 in all other cases.

RETURNS

OK or ERROR.

SEE ALSO

routeLib, mRouteAdd( )


Libraries : Routines

routeProtoPrioritySet( )

NAME

routeProtoPrioritySet( ) - set the priority of routes added by the routing protocol

SYNOPSIS

STATUS routeProtoPrioritySet
    (
    int proto, /* protocol no, from m2Lib.h */
    int prio   /* priority, >= 0 , <= 200 */
    )

DESCRIPTION

This routine assigns a priority to a routing protocol. A route generated by the proto protocol is added to the routing table only if a protocol of higher priority does not already have that route installed in the table. Use proto to identify the protocol. See m2Lib.h for a listing of valid values for proto. Use prio to specify the priority level you want to assign to proto. The prio parameter may be any integer value greater or equal to 0 and less than or equal to 200. The higher values indicate higher priority. If you do not want VxWorks to prioritize protocols, do not call this routine.

Routes that are added with the routeAdd( ) or mRouteAdd( ) call are of type M2_ipRouteProto_other. These are static routes that are not affected by routing protocols such as RIP and OSPF. To change the priority of routes added in this way pass the value M2_ipRoute_Proto_other in the first argument of this routine.

RETURNS

OK if priority set successfully else ERROR.

SEE ALSO

routeLib