1.\" $OpenBSD: rtrequest.9,v 1.2 2015/10/30 09:57:39 bluhm Exp $ 2.\" 3.\" Copyright (c) 2011 Bret S. Lambert <blambert@openbsd.org> 4.\" All rights reserved. 5.\" 6.\" Permission to use, copy, modify, and distribute this software for any 7.\" purpose with or without fee is hereby granted, provided that the above 8.\" copyright notice and this permission notice appear in all copies. 9.\" 10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" 18.Dd $Mdocdate: October 30 2015 $ 19.Dt RTREQUEST 9 20.Os 21.Sh NAME 22.Nm rtrequest 23.Nd add or remove entries from a routing table 24.Sh SYNOPSIS 25.In sys/types.h 26.In net/route.h 27.Ft int 28.Fn rtrequest "int req" "struct rt_addrinfo *info" "u_int8_t prio" \ 29"struct rtentry **rtp" "u_int rtableid" 30.Bd -literal 31struct rt_addrinfo { 32 int rti_addrs; 33 struct sockaddr *rti_info[RTAX_MAX]; 34 int rti_flags; 35 struct ifaddr *rti_ifa; 36 struct rt_msghdr *rti_rtm; 37 u_char rti_mpls; 38}; 39 40#define RTAX_DST 0 /* destination sockaddr present */ 41#define RTAX_GATEWAY 1 /* gateway sockaddr present */ 42#define RTAX_NETMASK 2 /* netmask sockaddr present */ 43#define RTAX_IFP 4 /* interface name sockaddr present */ 44#define RTAX_IFA 5 /* interface addr sockaddr present */ 45#define RTAX_AUTHOR 6 /* sockaddr for author of redirect */ 46#define RTAX_BRD 7 /* for NEWADDR, broadcast or p-p dest */ 47#define RTAX_SRC 8 /* source sockaddr present */ 48#define RTAX_SRCMASK 9 /* source netmask present */ 49#define RTAX_LABEL 10 /* route label present */ 50#define RTAX_MAX 11 /* size of array to allocate */ 51.Ed 52.Sh DESCRIPTION 53The 54.Fn rtrequest 55function is used to add or remove entries from a specific routing table. 56It takes the following arguments: 57.Bl -tag -width rtableid 58.It Fa req 59One of the following actions to perform: 60.Bl -tag -width RTM_RESOLVE -offset indent 61.It Dv RTM_ADD 62Add an entry to a given routing table. 63.It Dv RTM_DELETE 64Remove an entry from a given routing table. 65In case of a cloning entry, all its children are deleted. 66.It Dv RTM_RESOLVE 67Add a cloned entry, based on the parent cloning entry pointed by 68.Fa rtp , 69to a given routing table. 70.El 71.It Fa info 72Describes the routing entry to add or remove. 73.It Fa prio 74Specifies the priority of the routing entry described by 75.Fa info . 76If it is 77.Dv 0 78and the requested action is 79.Dv RTM_ADD 80then a default priority based on the priority of the associated 81interface is chosen. 82.It Fa rtp 83Must be non-NULL and point to the cloning entry if the action is 84.Dv RTM_RESOLVE . 85In all cases when no error is returned and it is non-NULL, a pointer 86to the deleted or added entry is placed there. 87The caller must take care of releasing the returned reference by 88calling 89.Xr rtfree 9 . 90.It Fa rtableid 91The ID of the routing table to modify. 92.El 93.Sh CONTEXT 94.Fn rtrequest 95can be called during autoconf, from process context, or from interrupt context. 96.Sh RETURN VALUES 97.Fn rtrequest 98may fail with: 99.Pp 100.Bl -tag -width Er -compact 101.It Bq Er EAFNOSUPPORT 102The routing table with ID of 103.Fa rtableid 104does not exist or it does not support the protocol specified in 105.Fa info . 106.It Bq Er ESRCH 107No routing entry corresponding to 108.Fa info 109could be found. 110.It Bq Er ESRCH 111Multipath routing entry with no gateway provided in 112.Fa info . 113.It Bq Er ESRCH 114The entry could not be found in the routing table of ID 115.Fa rtableid . 116specified 117.It Bq Er EINVAL 118The entry pointed by 119.Fa rtp 120is not valid or does not point to a cloning entry in the 121.Dv RTM_RESOLVE 122case. 123.It Bq Er EEXIST 124Multipath routing entry conflicts with an existing one. 125.It Bq Er EEXIST 126The entry could not be entered into the routing table. 127.It Bq Er ENOMEM 128Space for MPLS protocol data could not be allocated. 129.It Bq Er ENOBUFS 130Space for a new routing entry could not be allocated. 131.It Bq Er ENETUNREACH 132An interface address corresponding to the routing entry described by 133.Fa info 134could not be found. 135.El 136.Sh SEE ALSO 137.Xr rtfree 9 138