RTREQUEST1(9)

NAME
rtrequest1 - add or remove routes from a routing table

SYNOPSIS
#include <net/route.h>
int
rtrequest1(int req, struct rt_addrinfo *info, u_int8_t prio, struct rtentry **rtp, u_int rtableid);

    struct rt_addrinfo {
    	int	rti_addrs;
    	struct	sockaddr *rti_info[RTAX_MAX];
    	int	rti_flags;
    	struct	ifaddr *rti_ifa;
    	struct	rt_msghdr *rti_rtm;
    	u_char	rti_mpls;
    };
    #define RTAX_DST	0	/* destination sockaddr present */
    #define RTAX_GATEWAY	1	/* gateway sockaddr present */
    #define RTAX_NETMASK	2	/* netmask sockaddr present */
    #define RTAX_IFP	4	/* interface name sockaddr present */
    #define RTAX_IFA	5	/* interface addr sockaddr present */
    #define RTAX_AUTHOR	6	/* sockaddr for author of redirect */
    #define RTAX_BRD	7	/* for NEWADDR, broadcast or p-p dest */
    #define RTAX_SRC	8	/* source sockaddr present */
    #define RTAX_SRCMASK	9	/* source netmask present */
    #define RTAX_LABEL	10	/* route label present */
    #define RTAX_MAX	11	/* size of array to allocate */

DESCRIPTION
The rtrequest1() function is used to add or remove routes from a specific routing table. It takes the following arguments:

req One of the following actions to perform:

    RTM_ADD
        Add a route to a given routing table.

    RTM_DELETE
        Remove a route from a given routing table. In case of a cloning route, all its children are deleted.

    RTM_RESOLVE
        Add a cloned route, based on the parent cloning route pointed by rtp, to a given routing table.

info
    Describes the route to add or remove.

prio
    Specifies the priority of the route described by info. If it is 0 and the requested action is RTM_ADD then a default priority based on the priority of the associated interface is chosen.

rtp Points to the cloning route if the action is RTM_RESOLVE or, if the action is RTM_DELETE and it is non-NULL, a pointer to the removed route is placed there. In this case, the caller must take care of releasing the returned route by calling rtfree(9).

rtableid
    The ID of the routing table to modify.

CONTEXT
rtrequest1() can be called during autoconf, from process context, or from interrupt context.

RETURN VALUES
rtrequest1() may fail with:

[EAFNOSUPPORT]
    The routing table with ID of rtableid does not exist or it does not support the protocol specified in info.
[ESRCH]
    No route corresponding to info could be found.
[ESRCH]
    Multipath route with no gateway provided in info.
[ESRCH]
    The route could not be found in the routing table of ID rtableid. specified
[EINVAL]
    The route pointed by rtp is not valid or does not point to a cloning route in the RTM_RESOLVE case.
[EEXIST]
    Multipath route conflicts with existing multipath route.
[EEXIST]
    The route could not be entered into the routing table.
[ENOMEM]
    Space for MPLS protocol data could not be allocated.
[ENOBUFS]
    Space for a new route could not be allocated.
[ENETUNREACH]
    An interface address corresponding to the route described by info could not be found.

SEE ALSO
rtable_get(9), rtfree(9)