186d7f5d3SJohn Marino.\" 286d7f5d3SJohn Marino.\" Copyright 1996 Massachusetts Institute of Technology 386d7f5d3SJohn Marino.\" 486d7f5d3SJohn Marino.\" Permission to use, copy, modify, and distribute this software and 586d7f5d3SJohn Marino.\" its documentation for any purpose and without fee is hereby 686d7f5d3SJohn Marino.\" granted, provided that both the above copyright notice and this 786d7f5d3SJohn Marino.\" permission notice appear in all copies, that both the above 886d7f5d3SJohn Marino.\" copyright notice and this permission notice appear in all 986d7f5d3SJohn Marino.\" supporting documentation, and that the name of M.I.T. not be used 1086d7f5d3SJohn Marino.\" in advertising or publicity pertaining to distribution of the 1186d7f5d3SJohn Marino.\" software without specific, written prior permission. M.I.T. makes 1286d7f5d3SJohn Marino.\" no representations about the suitability of this software for any 1386d7f5d3SJohn Marino.\" purpose. It is provided "as is" without express or implied 1486d7f5d3SJohn Marino.\" warranty. 1586d7f5d3SJohn Marino.\" 1686d7f5d3SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS 1786d7f5d3SJohn Marino.\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, 1886d7f5d3SJohn Marino.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 1986d7f5d3SJohn Marino.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT 2086d7f5d3SJohn Marino.\" SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2186d7f5d3SJohn Marino.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2286d7f5d3SJohn Marino.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 2386d7f5d3SJohn Marino.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 2486d7f5d3SJohn Marino.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 2586d7f5d3SJohn Marino.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 2686d7f5d3SJohn Marino.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2786d7f5d3SJohn Marino.\" SUCH DAMAGE. 2886d7f5d3SJohn Marino.\" 2986d7f5d3SJohn Marino.\" $FreeBSD: src/share/man/man9/rtalloc.9,v 1.8.2.4 2001/12/17 11:30:18 ru Exp $ 3086d7f5d3SJohn Marino.\" 3186d7f5d3SJohn Marino.Dd October 8, 1996 3286d7f5d3SJohn Marino.Dt RTALLOC 9 3386d7f5d3SJohn Marino.Os 3486d7f5d3SJohn Marino.Sh NAME 3586d7f5d3SJohn Marino.Nm rtalloc , 3686d7f5d3SJohn Marino.Nm rtalloc_ign , 3786d7f5d3SJohn Marino.Nm rtalloc1 3886d7f5d3SJohn Marino.Nd look up a route in the kernel routing table 3986d7f5d3SJohn Marino.Sh SYNOPSIS 4086d7f5d3SJohn Marino.In sys/types.h 4186d7f5d3SJohn Marino.In sys/socket.h 4286d7f5d3SJohn Marino.In net/route.h 4386d7f5d3SJohn Marino.Ft void 4486d7f5d3SJohn Marino.Fn rtalloc "struct route *ro" 4586d7f5d3SJohn Marino.Ft void 4686d7f5d3SJohn Marino.Fn rtalloc_ign "struct route *ro" "u_long flags" 4786d7f5d3SJohn Marino.Ft "struct rtentry *" 4886d7f5d3SJohn Marino.Fn rtalloc1 "struct sockaddr *sa" "int report" "u_long flags" 4986d7f5d3SJohn Marino.Sh DESCRIPTION 5086d7f5d3SJohn MarinoThe kernel uses a radix tree structure to manage routes for the 5186d7f5d3SJohn Marinonetworking subsystem. The 5286d7f5d3SJohn Marino.Fn rtalloc 5386d7f5d3SJohn Marinofamily of routines is used by protocols to query this structure for a 5486d7f5d3SJohn Marinoroute corresponding to a particular end-node address, and to cause 5586d7f5d3SJohn Marinocertain protocol\- and interface-specific actions to take place. 5686d7f5d3SJohn Marino.\" XXX - -mdoc should contain a standard request for getting em and 5786d7f5d3SJohn Marino.\" en dashes. 5886d7f5d3SJohn Marino.Pp 5986d7f5d3SJohn MarinoWhen a route with the flag 6086d7f5d3SJohn Marino.Dv RTF_CLONING 6186d7f5d3SJohn Marinoor 6286d7f5d3SJohn Marino.Dv RTF_PRCLONING 6386d7f5d3SJohn Marinois retrieved, and the action of those flags is not masked, the 6486d7f5d3SJohn Marino.Nm 6586d7f5d3SJohn Marinofacility automatically generates a new route using information in the 6686d7f5d3SJohn Marinoold route as a template, and in the case of 6786d7f5d3SJohn Marino.Dv RTF_CLONING , 6886d7f5d3SJohn Marinosends an 6986d7f5d3SJohn Marino.Dv RTM_RESOLVE 7086d7f5d3SJohn Marinomessage to the appropriate interface-address route-management routine 7186d7f5d3SJohn Marino.Pq Fn ifa->ifa_rtrequest . 7286d7f5d3SJohn Marino.Dv RTF_PRCLONING 7386d7f5d3SJohn Marinoroutes are assumed to be managed by the protocol family and no 7486d7f5d3SJohn Marinoresolution requests are made, but all routes generated by the cloning 7586d7f5d3SJohn Marinoprocess retain a reference to the route from which they were 7686d7f5d3SJohn Marinogenerated. 7786d7f5d3SJohn MarinoIf the 7886d7f5d3SJohn Marino.Dv RTF_XRESOLVE 7986d7f5d3SJohn Marinoflag is set, then the 8086d7f5d3SJohn Marino.Dv RTM_RESOLVE 8186d7f5d3SJohn Marinomessage is sent instead on the 8286d7f5d3SJohn Marino.Xr route 4 8386d7f5d3SJohn Marinosocket interface, requesting that an external program resolve the 8486d7f5d3SJohn Marinoaddress in question and modify the route appropriately. 8586d7f5d3SJohn Marino.Pp 8686d7f5d3SJohn MarinoThe default interface is 8786d7f5d3SJohn Marino.Fn rtalloc . 8886d7f5d3SJohn MarinoIts only argument is 8986d7f5d3SJohn Marino.Fa ro , 9086d7f5d3SJohn Marinoa pointer to a 9186d7f5d3SJohn Marino.Dq Li "struct route" , 9286d7f5d3SJohn Marinowhich is defined as follows: 9386d7f5d3SJohn Marino.Bd -literal -offset indent 9486d7f5d3SJohn Marinostruct route { 9586d7f5d3SJohn Marino struct sockaddr ro_dst; 9686d7f5d3SJohn Marino struct rtentry *ro_rt; 9786d7f5d3SJohn Marino}; 9886d7f5d3SJohn Marino.Ed 9986d7f5d3SJohn MarinoThus, this function can only be used for address families which are 10086d7f5d3SJohn Marinosmaller than the default 10186d7f5d3SJohn Marino.Dq Li "struct sockaddr" . 10286d7f5d3SJohn MarinoBefore calling 10386d7f5d3SJohn Marino.Fn rtalloc 10486d7f5d3SJohn Marinofor the first time, callers should ensure that unused bits of the 10586d7f5d3SJohn Marinostructure are set to zero. On subsequent calls, 10686d7f5d3SJohn Marino.Fn rtalloc 10786d7f5d3SJohn Marinoreturns without performing a lookup if 10886d7f5d3SJohn Marino.Va ro->ro_rt 10986d7f5d3SJohn Marinois non-null and the 11086d7f5d3SJohn Marino.Dv RTF_UP 11186d7f5d3SJohn Marinoflag is set in the route's 11286d7f5d3SJohn Marino.Li rt_flags 11386d7f5d3SJohn Marinofield. 11486d7f5d3SJohn Marino.Pp 11586d7f5d3SJohn MarinoThe 11686d7f5d3SJohn Marino.Fn rtalloc_ign 11786d7f5d3SJohn Marinointerface can be used when the default actions of 11886d7f5d3SJohn Marino.Fn rtalloc 11986d7f5d3SJohn Marinoin the presence of the 12086d7f5d3SJohn Marino.Dv RTF_CLONING 12186d7f5d3SJohn Marinoand 12286d7f5d3SJohn Marino.Dv RTF_PRCLONING 12386d7f5d3SJohn Marinoflags are undesired. The 12486d7f5d3SJohn Marino.Fa ro 12586d7f5d3SJohn Marinoargument is the same as 12686d7f5d3SJohn Marino.Fn rtalloc , 12786d7f5d3SJohn Marinobut there is additionally a 12886d7f5d3SJohn Marino.Fa flags 12986d7f5d3SJohn Marinoargument, which lists the flags in the route which are to be 13086d7f5d3SJohn Marino.Em ignored 13186d7f5d3SJohn Marino(ordinarily, one or both of 13286d7f5d3SJohn Marino.Dv RTF_CLONING 13386d7f5d3SJohn Marinoor 13486d7f5d3SJohn Marino.Dv RTF_PRCLONING ) . 13586d7f5d3SJohn Marino.Pp 13686d7f5d3SJohn MarinoThe 13786d7f5d3SJohn Marino.Fn rtalloc1 13886d7f5d3SJohn Marinofunction is the most general form of 13986d7f5d3SJohn Marino.Fn rtalloc 14086d7f5d3SJohn Marino(and both of the other forms are implemented as calls to rtalloc1). 14186d7f5d3SJohn MarinoIt does not use the 14286d7f5d3SJohn Marino.Dq Li "struct route" , 14386d7f5d3SJohn Marinoand is therefore suitable for address families which require more 14486d7f5d3SJohn Marinospace than is in a traditional 14586d7f5d3SJohn Marino.Dq Li "struct sockaddr" . 14686d7f5d3SJohn MarinoInstead, it takes a 14786d7f5d3SJohn Marino.Dq Li "struct sockaddr *" 14886d7f5d3SJohn Marinodirectly as the 14986d7f5d3SJohn Marino.Fa sa 15086d7f5d3SJohn Marinoargument. The second argument, 15186d7f5d3SJohn Marino.Fa report , 15286d7f5d3SJohn Marinocontrols whether 15386d7f5d3SJohn Marino.Dv RTM_RESOLVE 15486d7f5d3SJohn Marinorequests are sent to the lower layers when an 15586d7f5d3SJohn Marino.Dv RTF_CLONING 15686d7f5d3SJohn Marinoor 15786d7f5d3SJohn Marino.Dv RTF_PRCLONING 15886d7f5d3SJohn Marinoroute is cloned. Ordinarily a value of one should be passed, except 15986d7f5d3SJohn Marinoin the processing of those lower layers which use the cloning 16086d7f5d3SJohn Marinofacility. 16186d7f5d3SJohn MarinoThe third argument, 16286d7f5d3SJohn Marino.Fa flags , 16386d7f5d3SJohn Marinois a set of flags to ignore, as in 16486d7f5d3SJohn Marino.Fn rtalloc_ign . 16586d7f5d3SJohn Marino.Sh RETURN VALUES 16686d7f5d3SJohn MarinoThe 16786d7f5d3SJohn Marino.Fn rtalloc 16886d7f5d3SJohn Marinoand 16986d7f5d3SJohn Marino.Fn rtalloc_ign 17086d7f5d3SJohn Marinofunctions do not return a value. The 17186d7f5d3SJohn Marino.Fn rtalloc1 17286d7f5d3SJohn Marinofunction returns a pointer to a routing-table entry if it succeeds, 17386d7f5d3SJohn Marinootherwise a null pointer. Lack of a route should in most cases be 17486d7f5d3SJohn Marinotranslated to the 17586d7f5d3SJohn Marino.Xr errno 2 17686d7f5d3SJohn Marinovalue 17786d7f5d3SJohn Marino.Er EHOSTUNREACH . 17886d7f5d3SJohn Marino.Sh SEE ALSO 17986d7f5d3SJohn Marino.Xr route 4 , 18086d7f5d3SJohn Marino.Xr rtentry 9 18186d7f5d3SJohn Marino.Sh HISTORY 18286d7f5d3SJohn MarinoThe 18386d7f5d3SJohn Marino.Nm 18486d7f5d3SJohn Marinofacility first appeared in 18586d7f5d3SJohn Marino.Bx 4.2 , 18686d7f5d3SJohn Marinoalthough with much different internals. The 18786d7f5d3SJohn Marino.Fn rtalloc_ign 18886d7f5d3SJohn Marinofunction and the 18986d7f5d3SJohn Marino.Fa flags 19086d7f5d3SJohn Marinoargument to 19186d7f5d3SJohn Marino.Fn rtalloc1 19286d7f5d3SJohn Marinofirst appeared in 19386d7f5d3SJohn Marino.Fx 2.0 . 19486d7f5d3SJohn Marino.Sh AUTHORS 19586d7f5d3SJohn MarinoThis manual page was written by 19686d7f5d3SJohn Marino.An Garrett Wollman , 19786d7f5d3SJohn Marinoas were the changes to implement 19886d7f5d3SJohn Marino.Dv RTF_PRCLONING 19986d7f5d3SJohn Marinoand the 20086d7f5d3SJohn Marino.Fn rtalloc_ign 20186d7f5d3SJohn Marinofunction and the 20286d7f5d3SJohn Marino.Fa flags 20386d7f5d3SJohn Marinoargument to 20486d7f5d3SJohn Marino.Fn rtalloc1 . 205