1*d05e1b8aSmpi.\" $OpenBSD: rtrequest.9,v 1.3 2019/07/12 16:57:45 mpi Exp $ 29ab903caSbluhm.\" 39ab903caSbluhm.\" Copyright (c) 2011 Bret S. Lambert <blambert@openbsd.org> 49ab903caSbluhm.\" All rights reserved. 59ab903caSbluhm.\" 69ab903caSbluhm.\" Permission to use, copy, modify, and distribute this software for any 79ab903caSbluhm.\" purpose with or without fee is hereby granted, provided that the above 89ab903caSbluhm.\" copyright notice and this permission notice appear in all copies. 99ab903caSbluhm.\" 109ab903caSbluhm.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 119ab903caSbluhm.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 129ab903caSbluhm.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 139ab903caSbluhm.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 149ab903caSbluhm.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 159ab903caSbluhm.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 169ab903caSbluhm.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 179ab903caSbluhm.\" 18*d05e1b8aSmpi.Dd $Mdocdate: July 12 2019 $ 1920ef8e6cSbluhm.Dt RTREQUEST 9 209ab903caSbluhm.Os 219ab903caSbluhm.Sh NAME 229ab903caSbluhm.Nm rtrequest 239ab903caSbluhm.Nd add or remove entries from a routing table 249ab903caSbluhm.Sh SYNOPSIS 259ab903caSbluhm.In sys/types.h 269ab903caSbluhm.In net/route.h 279ab903caSbluhm.Ft int 289ab903caSbluhm.Fn rtrequest "int req" "struct rt_addrinfo *info" "u_int8_t prio" \ 299ab903caSbluhm"struct rtentry **rtp" "u_int rtableid" 309ab903caSbluhm.Bd -literal 319ab903caSbluhmstruct rt_addrinfo { 329ab903caSbluhm int rti_addrs; 339ab903caSbluhm struct sockaddr *rti_info[RTAX_MAX]; 349ab903caSbluhm int rti_flags; 359ab903caSbluhm struct ifaddr *rti_ifa; 369ab903caSbluhm struct rt_msghdr *rti_rtm; 379ab903caSbluhm u_char rti_mpls; 389ab903caSbluhm}; 399ab903caSbluhm 409ab903caSbluhm#define RTAX_DST 0 /* destination sockaddr present */ 419ab903caSbluhm#define RTAX_GATEWAY 1 /* gateway sockaddr present */ 429ab903caSbluhm#define RTAX_NETMASK 2 /* netmask sockaddr present */ 439ab903caSbluhm#define RTAX_IFP 4 /* interface name sockaddr present */ 449ab903caSbluhm#define RTAX_IFA 5 /* interface addr sockaddr present */ 459ab903caSbluhm#define RTAX_AUTHOR 6 /* sockaddr for author of redirect */ 469ab903caSbluhm#define RTAX_BRD 7 /* for NEWADDR, broadcast or p-p dest */ 479ab903caSbluhm#define RTAX_SRC 8 /* source sockaddr present */ 489ab903caSbluhm#define RTAX_SRCMASK 9 /* source netmask present */ 499ab903caSbluhm#define RTAX_LABEL 10 /* route label present */ 509ab903caSbluhm#define RTAX_MAX 11 /* size of array to allocate */ 519ab903caSbluhm.Ed 529ab903caSbluhm.Sh DESCRIPTION 539ab903caSbluhmThe 549ab903caSbluhm.Fn rtrequest 559ab903caSbluhmfunction is used to add or remove entries from a specific routing table. 569ab903caSbluhmIt takes the following arguments: 579ab903caSbluhm.Bl -tag -width rtableid 589ab903caSbluhm.It Fa req 599ab903caSbluhmOne of the following actions to perform: 609ab903caSbluhm.Bl -tag -width RTM_RESOLVE -offset indent 619ab903caSbluhm.It Dv RTM_ADD 629ab903caSbluhmAdd an entry to a given routing table. 639ab903caSbluhm.It Dv RTM_DELETE 649ab903caSbluhmRemove an entry from a given routing table. 659ab903caSbluhmIn case of a cloning entry, all its children are deleted. 669ab903caSbluhm.It Dv RTM_RESOLVE 679ab903caSbluhmAdd a cloned entry, based on the parent cloning entry pointed by 689ab903caSbluhm.Fa rtp , 699ab903caSbluhmto a given routing table. 709ab903caSbluhm.El 719ab903caSbluhm.It Fa info 729ab903caSbluhmDescribes the routing entry to add or remove. 739ab903caSbluhm.It Fa prio 749ab903caSbluhmSpecifies the priority of the routing entry described by 759ab903caSbluhm.Fa info . 769ab903caSbluhmIf it is 779ab903caSbluhm.Dv 0 789ab903caSbluhmand the requested action is 799ab903caSbluhm.Dv RTM_ADD 809ab903caSbluhmthen a default priority based on the priority of the associated 819ab903caSbluhminterface is chosen. 829ab903caSbluhm.It Fa rtp 83*d05e1b8aSmpiMust point to the cloning entry if the action is 849ab903caSbluhm.Dv RTM_RESOLVE . 85*d05e1b8aSmpiIn all cases when no error is returned and it is not 86*d05e1b8aSmpi.Dv NULL , 87*d05e1b8aSmpia pointer to the deleted or added entry is placed there. 889ab903caSbluhmThe caller must take care of releasing the returned reference by 899ab903caSbluhmcalling 909ab903caSbluhm.Xr rtfree 9 . 919ab903caSbluhm.It Fa rtableid 929ab903caSbluhmThe ID of the routing table to modify. 939ab903caSbluhm.El 949ab903caSbluhm.Sh CONTEXT 959ab903caSbluhm.Fn rtrequest 969ab903caSbluhmcan be called during autoconf, from process context, or from interrupt context. 979ab903caSbluhm.Sh RETURN VALUES 989ab903caSbluhm.Fn rtrequest 999ab903caSbluhmmay fail with: 1009ab903caSbluhm.Pp 1019ab903caSbluhm.Bl -tag -width Er -compact 1029ab903caSbluhm.It Bq Er EAFNOSUPPORT 1039ab903caSbluhmThe routing table with ID of 1049ab903caSbluhm.Fa rtableid 1059ab903caSbluhmdoes not exist or it does not support the protocol specified in 1069ab903caSbluhm.Fa info . 1079ab903caSbluhm.It Bq Er ESRCH 1089ab903caSbluhmNo routing entry corresponding to 1099ab903caSbluhm.Fa info 1109ab903caSbluhmcould be found. 1119ab903caSbluhm.It Bq Er ESRCH 1129ab903caSbluhmMultipath routing entry with no gateway provided in 1139ab903caSbluhm.Fa info . 1149ab903caSbluhm.It Bq Er ESRCH 1159ab903caSbluhmThe entry could not be found in the routing table of ID 1169ab903caSbluhm.Fa rtableid . 1179ab903caSbluhmspecified 1189ab903caSbluhm.It Bq Er EINVAL 1199ab903caSbluhmThe entry pointed by 1209ab903caSbluhm.Fa rtp 1219ab903caSbluhmis not valid or does not point to a cloning entry in the 1229ab903caSbluhm.Dv RTM_RESOLVE 1239ab903caSbluhmcase. 1249ab903caSbluhm.It Bq Er EEXIST 1259ab903caSbluhmMultipath routing entry conflicts with an existing one. 1269ab903caSbluhm.It Bq Er EEXIST 1279ab903caSbluhmThe entry could not be entered into the routing table. 1289ab903caSbluhm.It Bq Er ENOMEM 1299ab903caSbluhmSpace for MPLS protocol data could not be allocated. 1309ab903caSbluhm.It Bq Er ENOBUFS 1319ab903caSbluhmSpace for a new routing entry could not be allocated. 1329ab903caSbluhm.It Bq Er ENETUNREACH 1339ab903caSbluhmAn interface address corresponding to the routing entry described by 1349ab903caSbluhm.Fa info 1359ab903caSbluhmcould not be found. 1369ab903caSbluhm.El 1379ab903caSbluhm.Sh SEE ALSO 1389ab903caSbluhm.Xr rtfree 9 139