rtrequest Kernel Service

Purpose

Carries out a request to change the routing table.

Syntax

#include <sys/types.h>
#include <sys/errno.h>
#include <sys/mbuf.h>
#include <net/if.h>
#include <net/af.h>
#include <net/route.h>

int rtrequest ( req,  dst,  gateway,  netmask,  flags,  ret_nrt)
int req;
struct sockaddr *dst, *gateway, *netmask;
int flags;
struct rtentry **ret_nrt;

Parameters

Item Description
req Specifies a request to add or delete a route.
dst Specifies the destination part of the route.
gateway Specifies the gateway part of the route.
netmask Specifies the network mask to apply to the route.
flags Identifies routing flags, as defined in the /usr/include/net/route.h file.
ret_nrt Specifies to return the resultant route.

Description

The rtrequest kernel service carries out a request to change the routing table. Interfaces call the rtrequest service at boot time to make their local routes known for routing table ioctl operations. Interfaces also call the rtrequest service as the result of routing redirects. The request is either to add (if the req parameter has a value of RMT_ADD) or delete (the req parameter is a value of RMT_DELETE) the route.

Execution Environment

The rtrequest kernel service can be called from either the process or interrupt environment.

Return Values

Item Description
0 Indicates a successful operation.
ESRCH Indicates that the route was not there to delete.
EEXIST Indicates that the entry the rtrequest service tried to add already exists.
ENETUNREACH Indicates that the rtrequest service cannot find the interface for the route.
ENOBUFS Indicates that the rtrequest service cannot get an mbuf structure to add an entry.

Example

To carry out a request to change the routing table, invoke the rtrequest kernel service as follows:

rtrequest(RTM_ADD, dst, gateway, netmask, flags, &rtp);