1*86d7f5d3SJohn Marino.\" 2*86d7f5d3SJohn Marino.\" Copyright 1996 Massachusetts Institute of Technology 3*86d7f5d3SJohn Marino.\" 4*86d7f5d3SJohn Marino.\" Permission to use, copy, modify, and distribute this software and 5*86d7f5d3SJohn Marino.\" its documentation for any purpose and without fee is hereby 6*86d7f5d3SJohn Marino.\" granted, provided that both the above copyright notice and this 7*86d7f5d3SJohn Marino.\" permission notice appear in all copies, that both the above 8*86d7f5d3SJohn Marino.\" copyright notice and this permission notice appear in all 9*86d7f5d3SJohn Marino.\" supporting documentation, and that the name of M.I.T. not be used 10*86d7f5d3SJohn Marino.\" in advertising or publicity pertaining to distribution of the 11*86d7f5d3SJohn Marino.\" software without specific, written prior permission. M.I.T. makes 12*86d7f5d3SJohn Marino.\" no representations about the suitability of this software for any 13*86d7f5d3SJohn Marino.\" purpose. It is provided "as is" without express or implied 14*86d7f5d3SJohn Marino.\" warranty. 15*86d7f5d3SJohn Marino.\" 16*86d7f5d3SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS 17*86d7f5d3SJohn Marino.\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, 18*86d7f5d3SJohn Marino.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19*86d7f5d3SJohn Marino.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT 20*86d7f5d3SJohn Marino.\" SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21*86d7f5d3SJohn Marino.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22*86d7f5d3SJohn Marino.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 23*86d7f5d3SJohn Marino.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24*86d7f5d3SJohn Marino.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25*86d7f5d3SJohn Marino.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 26*86d7f5d3SJohn Marino.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27*86d7f5d3SJohn Marino.\" SUCH DAMAGE. 28*86d7f5d3SJohn Marino.\" 29*86d7f5d3SJohn Marino.\" $FreeBSD: src/share/man/man9/rtalloc.9,v 1.8.2.4 2001/12/17 11:30:18 ru Exp $ 30*86d7f5d3SJohn Marino.\" 31*86d7f5d3SJohn Marino.Dd October 8, 1996 32*86d7f5d3SJohn Marino.Dt RTALLOC 9 33*86d7f5d3SJohn Marino.Os 34*86d7f5d3SJohn Marino.Sh NAME 35*86d7f5d3SJohn Marino.Nm rtalloc , 36*86d7f5d3SJohn Marino.Nm rtalloc_ign , 37*86d7f5d3SJohn Marino.Nm rtalloc1 38*86d7f5d3SJohn Marino.Nd look up a route in the kernel routing table 39*86d7f5d3SJohn Marino.Sh SYNOPSIS 40*86d7f5d3SJohn Marino.In sys/types.h 41*86d7f5d3SJohn Marino.In sys/socket.h 42*86d7f5d3SJohn Marino.In net/route.h 43*86d7f5d3SJohn Marino.Ft void 44*86d7f5d3SJohn Marino.Fn rtalloc "struct route *ro" 45*86d7f5d3SJohn Marino.Ft void 46*86d7f5d3SJohn Marino.Fn rtalloc_ign "struct route *ro" "u_long flags" 47*86d7f5d3SJohn Marino.Ft "struct rtentry *" 48*86d7f5d3SJohn Marino.Fn rtalloc1 "struct sockaddr *sa" "int report" "u_long flags" 49*86d7f5d3SJohn Marino.Sh DESCRIPTION 50*86d7f5d3SJohn MarinoThe kernel uses a radix tree structure to manage routes for the 51*86d7f5d3SJohn Marinonetworking subsystem. The 52*86d7f5d3SJohn Marino.Fn rtalloc 53*86d7f5d3SJohn Marinofamily of routines is used by protocols to query this structure for a 54*86d7f5d3SJohn Marinoroute corresponding to a particular end-node address, and to cause 55*86d7f5d3SJohn Marinocertain protocol\- and interface-specific actions to take place. 56*86d7f5d3SJohn Marino.\" XXX - -mdoc should contain a standard request for getting em and 57*86d7f5d3SJohn Marino.\" en dashes. 58*86d7f5d3SJohn Marino.Pp 59*86d7f5d3SJohn MarinoWhen a route with the flag 60*86d7f5d3SJohn Marino.Dv RTF_CLONING 61*86d7f5d3SJohn Marinoor 62*86d7f5d3SJohn Marino.Dv RTF_PRCLONING 63*86d7f5d3SJohn Marinois retrieved, and the action of those flags is not masked, the 64*86d7f5d3SJohn Marino.Nm 65*86d7f5d3SJohn Marinofacility automatically generates a new route using information in the 66*86d7f5d3SJohn Marinoold route as a template, and in the case of 67*86d7f5d3SJohn Marino.Dv RTF_CLONING , 68*86d7f5d3SJohn Marinosends an 69*86d7f5d3SJohn Marino.Dv RTM_RESOLVE 70*86d7f5d3SJohn Marinomessage to the appropriate interface-address route-management routine 71*86d7f5d3SJohn Marino.Pq Fn ifa->ifa_rtrequest . 72*86d7f5d3SJohn Marino.Dv RTF_PRCLONING 73*86d7f5d3SJohn Marinoroutes are assumed to be managed by the protocol family and no 74*86d7f5d3SJohn Marinoresolution requests are made, but all routes generated by the cloning 75*86d7f5d3SJohn Marinoprocess retain a reference to the route from which they were 76*86d7f5d3SJohn Marinogenerated. 77*86d7f5d3SJohn MarinoIf the 78*86d7f5d3SJohn Marino.Dv RTF_XRESOLVE 79*86d7f5d3SJohn Marinoflag is set, then the 80*86d7f5d3SJohn Marino.Dv RTM_RESOLVE 81*86d7f5d3SJohn Marinomessage is sent instead on the 82*86d7f5d3SJohn Marino.Xr route 4 83*86d7f5d3SJohn Marinosocket interface, requesting that an external program resolve the 84*86d7f5d3SJohn Marinoaddress in question and modify the route appropriately. 85*86d7f5d3SJohn Marino.Pp 86*86d7f5d3SJohn MarinoThe default interface is 87*86d7f5d3SJohn Marino.Fn rtalloc . 88*86d7f5d3SJohn MarinoIts only argument is 89*86d7f5d3SJohn Marino.Fa ro , 90*86d7f5d3SJohn Marinoa pointer to a 91*86d7f5d3SJohn Marino.Dq Li "struct route" , 92*86d7f5d3SJohn Marinowhich is defined as follows: 93*86d7f5d3SJohn Marino.Bd -literal -offset indent 94*86d7f5d3SJohn Marinostruct route { 95*86d7f5d3SJohn Marino struct sockaddr ro_dst; 96*86d7f5d3SJohn Marino struct rtentry *ro_rt; 97*86d7f5d3SJohn Marino}; 98*86d7f5d3SJohn Marino.Ed 99*86d7f5d3SJohn MarinoThus, this function can only be used for address families which are 100*86d7f5d3SJohn Marinosmaller than the default 101*86d7f5d3SJohn Marino.Dq Li "struct sockaddr" . 102*86d7f5d3SJohn MarinoBefore calling 103*86d7f5d3SJohn Marino.Fn rtalloc 104*86d7f5d3SJohn Marinofor the first time, callers should ensure that unused bits of the 105*86d7f5d3SJohn Marinostructure are set to zero. On subsequent calls, 106*86d7f5d3SJohn Marino.Fn rtalloc 107*86d7f5d3SJohn Marinoreturns without performing a lookup if 108*86d7f5d3SJohn Marino.Va ro->ro_rt 109*86d7f5d3SJohn Marinois non-null and the 110*86d7f5d3SJohn Marino.Dv RTF_UP 111*86d7f5d3SJohn Marinoflag is set in the route's 112*86d7f5d3SJohn Marino.Li rt_flags 113*86d7f5d3SJohn Marinofield. 114*86d7f5d3SJohn Marino.Pp 115*86d7f5d3SJohn MarinoThe 116*86d7f5d3SJohn Marino.Fn rtalloc_ign 117*86d7f5d3SJohn Marinointerface can be used when the default actions of 118*86d7f5d3SJohn Marino.Fn rtalloc 119*86d7f5d3SJohn Marinoin the presence of the 120*86d7f5d3SJohn Marino.Dv RTF_CLONING 121*86d7f5d3SJohn Marinoand 122*86d7f5d3SJohn Marino.Dv RTF_PRCLONING 123*86d7f5d3SJohn Marinoflags are undesired. The 124*86d7f5d3SJohn Marino.Fa ro 125*86d7f5d3SJohn Marinoargument is the same as 126*86d7f5d3SJohn Marino.Fn rtalloc , 127*86d7f5d3SJohn Marinobut there is additionally a 128*86d7f5d3SJohn Marino.Fa flags 129*86d7f5d3SJohn Marinoargument, which lists the flags in the route which are to be 130*86d7f5d3SJohn Marino.Em ignored 131*86d7f5d3SJohn Marino(ordinarily, one or both of 132*86d7f5d3SJohn Marino.Dv RTF_CLONING 133*86d7f5d3SJohn Marinoor 134*86d7f5d3SJohn Marino.Dv RTF_PRCLONING ) . 135*86d7f5d3SJohn Marino.Pp 136*86d7f5d3SJohn MarinoThe 137*86d7f5d3SJohn Marino.Fn rtalloc1 138*86d7f5d3SJohn Marinofunction is the most general form of 139*86d7f5d3SJohn Marino.Fn rtalloc 140*86d7f5d3SJohn Marino(and both of the other forms are implemented as calls to rtalloc1). 141*86d7f5d3SJohn MarinoIt does not use the 142*86d7f5d3SJohn Marino.Dq Li "struct route" , 143*86d7f5d3SJohn Marinoand is therefore suitable for address families which require more 144*86d7f5d3SJohn Marinospace than is in a traditional 145*86d7f5d3SJohn Marino.Dq Li "struct sockaddr" . 146*86d7f5d3SJohn MarinoInstead, it takes a 147*86d7f5d3SJohn Marino.Dq Li "struct sockaddr *" 148*86d7f5d3SJohn Marinodirectly as the 149*86d7f5d3SJohn Marino.Fa sa 150*86d7f5d3SJohn Marinoargument. The second argument, 151*86d7f5d3SJohn Marino.Fa report , 152*86d7f5d3SJohn Marinocontrols whether 153*86d7f5d3SJohn Marino.Dv RTM_RESOLVE 154*86d7f5d3SJohn Marinorequests are sent to the lower layers when an 155*86d7f5d3SJohn Marino.Dv RTF_CLONING 156*86d7f5d3SJohn Marinoor 157*86d7f5d3SJohn Marino.Dv RTF_PRCLONING 158*86d7f5d3SJohn Marinoroute is cloned. Ordinarily a value of one should be passed, except 159*86d7f5d3SJohn Marinoin the processing of those lower layers which use the cloning 160*86d7f5d3SJohn Marinofacility. 161*86d7f5d3SJohn MarinoThe third argument, 162*86d7f5d3SJohn Marino.Fa flags , 163*86d7f5d3SJohn Marinois a set of flags to ignore, as in 164*86d7f5d3SJohn Marino.Fn rtalloc_ign . 165*86d7f5d3SJohn Marino.Sh RETURN VALUES 166*86d7f5d3SJohn MarinoThe 167*86d7f5d3SJohn Marino.Fn rtalloc 168*86d7f5d3SJohn Marinoand 169*86d7f5d3SJohn Marino.Fn rtalloc_ign 170*86d7f5d3SJohn Marinofunctions do not return a value. The 171*86d7f5d3SJohn Marino.Fn rtalloc1 172*86d7f5d3SJohn Marinofunction returns a pointer to a routing-table entry if it succeeds, 173*86d7f5d3SJohn Marinootherwise a null pointer. Lack of a route should in most cases be 174*86d7f5d3SJohn Marinotranslated to the 175*86d7f5d3SJohn Marino.Xr errno 2 176*86d7f5d3SJohn Marinovalue 177*86d7f5d3SJohn Marino.Er EHOSTUNREACH . 178*86d7f5d3SJohn Marino.Sh SEE ALSO 179*86d7f5d3SJohn Marino.Xr route 4 , 180*86d7f5d3SJohn Marino.Xr rtentry 9 181*86d7f5d3SJohn Marino.Sh HISTORY 182*86d7f5d3SJohn MarinoThe 183*86d7f5d3SJohn Marino.Nm 184*86d7f5d3SJohn Marinofacility first appeared in 185*86d7f5d3SJohn Marino.Bx 4.2 , 186*86d7f5d3SJohn Marinoalthough with much different internals. The 187*86d7f5d3SJohn Marino.Fn rtalloc_ign 188*86d7f5d3SJohn Marinofunction and the 189*86d7f5d3SJohn Marino.Fa flags 190*86d7f5d3SJohn Marinoargument to 191*86d7f5d3SJohn Marino.Fn rtalloc1 192*86d7f5d3SJohn Marinofirst appeared in 193*86d7f5d3SJohn Marino.Fx 2.0 . 194*86d7f5d3SJohn Marino.Sh AUTHORS 195*86d7f5d3SJohn MarinoThis manual page was written by 196*86d7f5d3SJohn Marino.An Garrett Wollman , 197*86d7f5d3SJohn Marinoas were the changes to implement 198*86d7f5d3SJohn Marino.Dv RTF_PRCLONING 199*86d7f5d3SJohn Marinoand the 200*86d7f5d3SJohn Marino.Fn rtalloc_ign 201*86d7f5d3SJohn Marinofunction and the 202*86d7f5d3SJohn Marino.Fa flags 203*86d7f5d3SJohn Marinoargument to 204*86d7f5d3SJohn Marino.Fn rtalloc1 . 205