rtinit Kernel Service

Purpose

Sets up a routing table entry typically for a network interface.

Syntax

#include <sys/types.h>
#include <sys/errno.h>
#include <sys/socket.h>
#include <net/route.h>

int rtinit (ifa, cmd, flags)
struct ifaddr * ifa;
int  cmd,  flags;

Parameters

Item Description
ifa Specifies the address of an ifaddr structure containing destination address, interface address, and netmask.
cmd Specifies a request to add or delete route entry.
flags Identifies routing flags, as defined in the /usr/include/net/route.h file.

Description

The rtinit kernel service creates a routing table entry for an interface. It builds an rtentry structure using the values in the ifa and flags parameters.

The rtinit service then calls the rtrequest kernel service and passes the cmd parameter and the rtentry structure to process the request. The cmd parameter contains either the value RTM_ADD (a request to add the route entry) or the value RTM_DELETE (delete the route entry). Valid routing flags to set are defined in the /usr/include/route.h file.

Execution Environment

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

Return Values

The rtinit kernel service returns values from the rtrequest kernel service.

Example

To set up a routing table entry, invoke the rtinit kernel service as follows:

rtinit(ifa, RMT_ADD, flags ( RTF_DYNAMIC);