2 .\" Copyright 1996 Massachusetts Institute of Technology
4 .\" Permission to use, copy, modify, and distribute this software and
5 .\" its documentation for any purpose and without fee is hereby
6 .\" granted, provided that both the above copyright notice and this
7 .\" permission notice appear in all copies, that both the above
8 .\" copyright notice and this permission notice appear in all
9 .\" supporting documentation, and that the name of M.I.T. not be used
10 .\" in advertising or publicity pertaining to distribution of the
11 .\" software without specific, written prior permission. M.I.T. makes
12 .\" no representations about the suitability of this software for any
13 .\" purpose. It is provided "as is" without express or implied
16 .\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
17 .\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
18 .\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
20 .\" SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 .\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 .\" $Id: rtalloc.9,v 1.6 1997/04/13 14:49:08 bde Exp $
37 .Nd look up a route in the kernel routing table
39 .Fd #include <sys/types.h>
40 .Fd #include <sys/socket.h>
41 .Fd #include <net/route.h>
43 .Fn rtalloc "struct route *ro"
45 .Fn rtalloc_ign "struct route *ro" "u_long flags"
46 .Ft "struct rtentry *"
47 .Fn rtalloc1 "struct sockaddr *sa" "int report" "u_long flags"
49 The kernel uses a radix tree structure to manage routes for the
50 networking subsystem. The
52 family of routines is used by protocols to query this structure for a
53 route corresponding to a particular end-node address, and to cause
54 certain protocol\- and interface-specific actions to take place.
55 .\" XXX - -mdoc should contain a standard request for getting em and
58 When a route with the flag
62 is retrieved, and the action of those flags is not masked, the
64 facility automatically generates a new route using information in the
65 old route as a template, and in the case of
69 message to the appropriate interface-address route-management routine
70 .Pq Fn ifa->ifa_rtrequest .
72 routes are assumed to be managed by the protocol family and no
73 resolution requests are made, but all routes generated by the cloning
74 process retain a reference to the route from which they were
80 message is sent instead on the
82 socket interface, requesting that an external program resolve the
83 address in question and modify the route appropriately.
85 The default interface is
90 .Dq Li "struct route" ,
91 which is defined as follows:
92 .Bd -literal -offset indent
94 struct sockaddr ro_dst;
95 struct rtentry *ro_rt;
98 Thus, this function can only be used for address families which are
99 smaller than the default
100 .Dq Li "struct sockaddr" .
103 for the first time, callers should ensure that unused bits of the
104 structure are set to zero. On subsequent calls,
106 returns without performing a lookup if
110 flag is set in the route's
116 interface can be used when the default actions of
118 in the presence of the
122 flags are undesired. The
124 argument is the same as
126 but there is additionally a
128 argument, which lists the flags in the route which are to be
130 (ordinarily, one or both of
133 .Dv RTF_PRCLONING ) .
137 function is the most general form of
139 (and both of the other forms are implemented as calls to rtalloc1).
141 .Dq Li "struct route" ,
142 and is therefore suitable for address families which require more
143 space than is in a traditional
144 .Dq Li "struct sockaddr" .
146 .Dq Li "struct sockaddr *"
149 argument. The second argument,
153 requests are sent to the lower layers when an
157 route is cloned. Ordinarily a value of one should be passed, except
158 in the processing of those lower layers which use the cloning
162 is a set of flags to ignore, as in
169 functions do not return a value. The
171 function returns a pointer to a routing-table entry if it succeeds,
172 otherwise a null pointer. Lack of a route should in most cases be
183 facility first appeared in
185 although with much different internals. The
194 This manual page was written by
195 .An Garrett Wollman ,
196 as were the changes to implement