]> git.saurik.com Git - apple/xnu.git/blame - bsd/net/route.h
xnu-2050.18.24.tar.gz
[apple/xnu.git] / bsd / net / route.h
CommitLineData
1c79356b 1/*
316670eb 2 * Copyright (c) 2000-2012 Apple Inc. All rights reserved.
5d5c5d0d 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
2d21ac55
A
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
8f6c56a5 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/*
29 * Copyright (c) 1980, 1986, 1993
30 * The Regents of the University of California. All rights reserved.
31 *
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
34 * are met:
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 * 3. All advertising materials mentioning features or use of this software
41 * must display the following acknowledgement:
42 * This product includes software developed by the University of
43 * California, Berkeley and its contributors.
44 * 4. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 *
60 * @(#)route.h 8.3 (Berkeley) 4/19/94
9bccf70c 61 * $FreeBSD: src/sys/net/route.h,v 1.36.2.1 2000/08/16 06:14:23 jayanth Exp $
1c79356b
A
62 */
63
64#ifndef _NET_ROUTE_H_
65#define _NET_ROUTE_H_
9bccf70c 66#include <sys/appleapiopts.h>
b0d623f7 67#include <stdint.h>
91447636
A
68#include <sys/types.h>
69#include <sys/socket.h>
1c79356b
A
70
71/*
72 * Kernel resident routing tables.
73 *
74 * The routing tables are initialized when interface addresses
75 * are set by making entries for all directly connected interfaces.
76 */
77
78/*
79 * A route consists of a destination address and a reference
80 * to a routing entry. These are often held by protocols
81 * in their control blocks, e.g. inpcb.
82 */
91447636
A
83#ifdef PRIVATE
84struct rtentry;
1c79356b 85struct route {
b0d623f7
A
86 /*
87 * N.B: struct route must begin with ro_rt and ro_flags
88 * because the code does some casts of a 'struct route_in6 *'
89 * to a 'struct route *'.
90 */
91 struct rtentry *ro_rt;
92 uint32_t ro_flags; /* route flags (see below) */
93 struct sockaddr ro_dst;
1c79356b 94};
c910b4d9
A
95
96#define ROF_SRCIF_SELECTED 0x1 /* source interface was selected */
97
6d2010ae
A
98/*
99 * Route reachability info (private)
100 */
101struct rt_reach_info {
102 u_int32_t ri_refcnt; /* reference count */
103 u_int32_t ri_probes; /* total # of probes */
104 u_int64_t ri_snd_expire; /* transmit expiration (calendar) time */
105 u_int64_t ri_rcv_expire; /* receive expiration (calendar) time */
316670eb
A
106 int32_t ri_rssi; /* received signal strength */
107 int32_t ri_lqm; /* link quality metric */
108 int32_t ri_npm; /* node proximity metric */
6d2010ae 109};
9bccf70c
A
110#else
111struct route;
91447636 112#endif /* PRIVATE */
1c79356b
A
113
114/*
115 * These numbers are used by reliable protocols for determining
116 * retransmission behavior and are included in the routing structure.
117 */
118struct rt_metrics {
2d21ac55
A
119 u_int32_t rmx_locks; /* Kernel must leave these values alone */
120 u_int32_t rmx_mtu; /* MTU for this path */
121 u_int32_t rmx_hopcount; /* max hops expected */
122 int32_t rmx_expire; /* lifetime for route, e.g. redirect */
123 u_int32_t rmx_recvpipe; /* inbound delay-bandwidth product */
124 u_int32_t rmx_sendpipe; /* outbound delay-bandwidth product */
125 u_int32_t rmx_ssthresh; /* outbound gateway buffer limit */
126 u_int32_t rmx_rtt; /* estimated round trip time */
127 u_int32_t rmx_rttvar; /* estimated rtt variance */
128 u_int32_t rmx_pksent; /* packets sent using this route */
129 u_int32_t rmx_filler[4]; /* will be used for T/TCP later */
1c79356b
A
130};
131
132/*
133 * rmx_rtt and rmx_rttvar are stored as microseconds;
1c79356b
A
134 */
135#define RTM_RTTUNIT 1000000 /* units for rtt, rttvar, as units per sec */
1c79356b 136
d1ecb069
A
137#ifdef KERNEL_PRIVATE
138/*
139 * New expiry value (in seconds) when dealing with interfaces which implement
140 * the if_want_aggressive_drain behavior. Otherwise the event mechanism wouldn't
141 * fire quick enough to cause any sort of significant gains in performance.
142 */
143#define RT_IF_IDLE_EXPIRE_TIMEOUT 30
144#define RT_IF_IDLE_DRAIN_INTERVAL 10
145#endif /* KERNEL_PRIVATE */
146
1c79356b
A
147/*
148 * We distinguish between routes to hosts and routes to networks,
149 * preferring the former if available. For each route we infer
150 * the interface to use from the gateway address supplied when
151 * the route was entered. Routes that forward packets through
152 * gateways are marked so that the output routines know to address the
153 * gateway rather than the ultimate destination.
154 */
b0d623f7
A
155#ifdef KERNEL_PRIVATE
156#include <kern/locks.h>
1c79356b
A
157#ifndef RNF_NORMAL
158#include <net/radix.h>
159#endif
316670eb 160struct ifnet_llreach_info; /* forward declaration */
b0d623f7
A
161/*
162 * Kernel routing entry structure (private).
163 */
1c79356b
A
164struct rtentry {
165 struct radix_node rt_nodes[2]; /* tree glue, and other values */
316670eb
A
166#define rt_key(r) ((struct sockaddr *)(void *)((r)->rt_nodes->rn_key))
167#define rt_mask(r) ((struct sockaddr *)(void *)((r)->rt_nodes->rn_mask))
1c79356b 168 struct sockaddr *rt_gateway; /* value */
9bccf70c 169 int32_t rt_refcnt; /* # held references */
b0d623f7 170 uint32_t rt_flags; /* up/down?, host/net */
1c79356b 171 struct ifnet *rt_ifp; /* the answer: interface to use */
b0d623f7 172 struct ifaddr *rt_ifa; /* the answer: interface addr to use */
1c79356b 173 struct sockaddr *rt_genmask; /* for generation of cloned routes */
b0d623f7 174 void *rt_llinfo; /* pointer to link level info cache */
6d2010ae
A
175 void (*rt_llinfo_get_ri) /* llinfo get reachability info fn */
176 (struct rtentry *, struct rt_reach_info *);
316670eb
A
177 void (*rt_llinfo_get_iflri) /* ifnet llinfo get reach. info fn */
178 (struct rtentry *, struct ifnet_llreach_info *);
6d2010ae 179 void (*rt_llinfo_purge)(struct rtentry *); /* llinfo purge fn */
b0d623f7 180 void (*rt_llinfo_free)(void *); /* link level info free function */
1c79356b
A
181 struct rt_metrics rt_rmx; /* metrics used by rx'ing protocols */
182 struct rtentry *rt_gwroute; /* implied entry for gatewayed routes */
2d21ac55 183 struct rtentry *rt_parent; /* cloning parent of this route */
b0d623f7
A
184 uint32_t generation_id; /* route generation id */
185 /*
186 * See bsd/net/route.c for synchronization notes.
187 */
188 decl_lck_mtx_data(, rt_lock); /* lock for routing entry */
6d2010ae 189 struct nstat_counts *rt_stats;
d1ecb069 190 void (*rt_if_ref_fn)(struct ifnet *, int); /* interface ref func */
6d2010ae
A
191
192 uint64_t rt_expire; /* expiration time in uptime seconds */
193 uint64_t base_calendartime; /* calendar time upon entry creation */
194 uint64_t base_uptime;/* uptime upon entry creation */
1c79356b 195};
6d2010ae
A
196
197extern void rt_setexpire(struct rtentry *, uint64_t);
b0d623f7 198#endif /* KERNEL_PRIVATE */
1c79356b 199
b0d623f7 200#ifdef KERNEL_PRIVATE
1c79356b 201#define rt_use rt_rmx.rmx_pksent
b0d623f7 202#endif /* KERNEL_PRIVATE */
1c79356b
A
203
204#define RTF_UP 0x1 /* route usable */
205#define RTF_GATEWAY 0x2 /* destination is a gateway */
206#define RTF_HOST 0x4 /* host entry (net otherwise) */
207#define RTF_REJECT 0x8 /* host or net unreachable */
208#define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */
209#define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */
210#define RTF_DONE 0x40 /* message confirmed */
9bccf70c 211#define RTF_DELCLONE 0x80 /* delete cloned route */
1c79356b
A
212#define RTF_CLONING 0x100 /* generate new routes on use */
213#define RTF_XRESOLVE 0x200 /* external daemon resolves name */
214#define RTF_LLINFO 0x400 /* generated by link layer (e.g. ARP) */
215#define RTF_STATIC 0x800 /* manually added */
216#define RTF_BLACKHOLE 0x1000 /* just discard pkts (during updates) */
217#define RTF_PROTO2 0x4000 /* protocol specific routing flag */
218#define RTF_PROTO1 0x8000 /* protocol specific routing flag */
219
220#define RTF_PRCLONING 0x10000 /* protocol requires cloning */
221#define RTF_WASCLONED 0x20000 /* route generated through cloning */
222#define RTF_PROTO3 0x40000 /* protocol specific routing flag */
91447636 223 /* 0x80000 unused */
1c79356b 224#define RTF_PINNED 0x100000 /* future use */
2d21ac55 225#define RTF_LOCAL 0x200000 /* route represents a local address */
1c79356b
A
226#define RTF_BROADCAST 0x400000 /* route represents a bcast address */
227#define RTF_MULTICAST 0x800000 /* route represents a mcast address */
c910b4d9 228#define RTF_IFSCOPE 0x1000000 /* has valid interface scope */
b0d623f7 229#define RTF_CONDEMNED 0x2000000 /* defunct; no longer modifiable */
d1ecb069 230#define RTF_IFREF 0x4000000 /* route holds a ref to interface */
316670eb
A
231#define RTF_PROXY 0x8000000 /* proxying, no interface scope */
232#define RTF_ROUTER 0x10000000 /* host is a router */
233 /* 0x20000000 and up unassigned */
1c79356b
A
234
235/*
236 * Routing statistics.
237 */
238struct rtstat {
239 short rts_badredirect; /* bogus redirect calls */
240 short rts_dynamic; /* routes created by redirects */
241 short rts_newgateway; /* routes modified by redirects */
242 short rts_unreach; /* lookups which failed */
243 short rts_wildcard; /* lookups satisfied by a wildcard */
244};
91447636 245
1c79356b
A
246/*
247 * Structures for routing messages.
248 */
249struct rt_msghdr {
2d21ac55
A
250 u_short rtm_msglen; /* to skip over non-understood messages */
251 u_char rtm_version; /* future binary compatibility */
252 u_char rtm_type; /* message type */
253 u_short rtm_index; /* index for associated ifp */
254 int rtm_flags; /* flags, incl. kern & message, e.g. DONE */
255 int rtm_addrs; /* bitmask identifying sockaddrs in msg */
256 pid_t rtm_pid; /* identify sender */
257 int rtm_seq; /* for sender to identify action */
258 int rtm_errno; /* why failed */
259 int rtm_use; /* from rtentry */
260 u_int32_t rtm_inits; /* which metrics we are initializing */
261 struct rt_metrics rtm_rmx; /* metrics themselves */
1c79356b
A
262};
263
91447636 264struct rt_msghdr2 {
2d21ac55
A
265 u_short rtm_msglen; /* to skip over non-understood messages */
266 u_char rtm_version; /* future binary compatibility */
267 u_char rtm_type; /* message type */
268 u_short rtm_index; /* index for associated ifp */
269 int rtm_flags; /* flags, incl. kern & message, e.g. DONE */
270 int rtm_addrs; /* bitmask identifying sockaddrs in msg */
271 int32_t rtm_refcnt; /* reference count */
272 int rtm_parentflags; /* flags of the parent route */
273 int rtm_reserved; /* reserved field set to 0 */
274 int rtm_use; /* from rtentry */
275 u_int32_t rtm_inits; /* which metrics we are initializing */
276 struct rt_metrics rtm_rmx; /* metrics themselves */
91447636
A
277};
278
6d2010ae
A
279#ifdef PRIVATE
280/*
281 * Extended routing message header (private).
282 */
283struct rt_msghdr_ext {
284 u_short rtm_msglen; /* to skip over non-understood messages */
285 u_char rtm_version; /* future binary compatibility */
286 u_char rtm_type; /* message type */
287 u_int32_t rtm_index; /* index for associated ifp */
288 u_int32_t rtm_flags; /* flags, incl. kern & message, e.g. DONE */
289 u_int32_t rtm_reserved; /* for future use */
290 u_int32_t rtm_addrs; /* bitmask identifying sockaddrs in msg */
291 pid_t rtm_pid; /* identify sender */
292 int rtm_seq; /* for sender to identify action */
293 int rtm_errno; /* why failed */
294 u_int32_t rtm_use; /* from rtentry */
295 u_int32_t rtm_inits; /* which metrics we are initializing */
296 struct rt_metrics rtm_rmx; /* metrics themselves */
297 struct rt_reach_info rtm_ri; /* route reachability info */
298};
299#endif /* PRIVATE */
91447636 300
1c79356b
A
301#define RTM_VERSION 5 /* Up the ante and ignore older versions */
302
303/*
304 * Message types.
305 */
306#define RTM_ADD 0x1 /* Add Route */
307#define RTM_DELETE 0x2 /* Delete Route */
308#define RTM_CHANGE 0x3 /* Change Metrics or flags */
309#define RTM_GET 0x4 /* Report Metrics */
310#define RTM_LOSING 0x5 /* Kernel Suspects Partitioning */
311#define RTM_REDIRECT 0x6 /* Told to use different route */
312#define RTM_MISS 0x7 /* Lookup failed on this address */
313#define RTM_LOCK 0x8 /* fix specified metrics */
314#define RTM_OLDADD 0x9 /* caused by SIOCADDRT */
315#define RTM_OLDDEL 0xa /* caused by SIOCDELRT */
316#define RTM_RESOLVE 0xb /* req to resolve dst to LL addr */
317#define RTM_NEWADDR 0xc /* address being added to iface */
318#define RTM_DELADDR 0xd /* address being removed from iface */
319#define RTM_IFINFO 0xe /* iface going up/down etc. */
320#define RTM_NEWMADDR 0xf /* mcast group membership being added to if */
321#define RTM_DELMADDR 0x10 /* mcast group membership being deleted */
91447636 322#ifdef PRIVATE
55e303ae 323#define RTM_GET_SILENT 0x11
b0d623f7 324#endif /* PRIVATE */
91447636
A
325#define RTM_IFINFO2 0x12 /* */
326#define RTM_NEWMADDR2 0x13 /* */
327#define RTM_GET2 0x14 /* */
6d2010ae
A
328#ifdef PRIVATE
329#define RTM_GET_EXT 0x15
330#endif /* PRIVATE */
1c79356b
A
331
332/*
333 * Bitmask values for rtm_inits and rmx_locks.
334 */
335#define RTV_MTU 0x1 /* init or lock _mtu */
336#define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */
337#define RTV_EXPIRE 0x4 /* init or lock _expire */
338#define RTV_RPIPE 0x8 /* init or lock _recvpipe */
339#define RTV_SPIPE 0x10 /* init or lock _sendpipe */
340#define RTV_SSTHRESH 0x20 /* init or lock _ssthresh */
341#define RTV_RTT 0x40 /* init or lock _rtt */
342#define RTV_RTTVAR 0x80 /* init or lock _rttvar */
343
344/*
345 * Bitmask values for rtm_addrs.
346 */
347#define RTA_DST 0x1 /* destination sockaddr present */
348#define RTA_GATEWAY 0x2 /* gateway sockaddr present */
349#define RTA_NETMASK 0x4 /* netmask sockaddr present */
350#define RTA_GENMASK 0x8 /* cloning mask sockaddr present */
351#define RTA_IFP 0x10 /* interface name sockaddr present */
352#define RTA_IFA 0x20 /* interface addr sockaddr present */
353#define RTA_AUTHOR 0x40 /* sockaddr for author of redirect */
354#define RTA_BRD 0x80 /* for NEWADDR, broadcast or p-p dest addr */
355
356/*
357 * Index offsets for sockaddr array for alternate internal encoding.
358 */
359#define RTAX_DST 0 /* destination sockaddr present */
360#define RTAX_GATEWAY 1 /* gateway sockaddr present */
361#define RTAX_NETMASK 2 /* netmask sockaddr present */
362#define RTAX_GENMASK 3 /* cloning mask sockaddr present */
363#define RTAX_IFP 4 /* interface name sockaddr present */
364#define RTAX_IFA 5 /* interface addr sockaddr present */
365#define RTAX_AUTHOR 6 /* sockaddr for author of redirect */
366#define RTAX_BRD 7 /* for NEWADDR, broadcast or p-p dest addr */
367#define RTAX_MAX 8 /* size of array to allocate */
368
369struct rt_addrinfo {
370 int rti_addrs;
371 struct sockaddr *rti_info[RTAX_MAX];
372};
373
374struct route_cb {
375 int ip_count;
376 int ip6_count;
377 int ipx_count;
378 int ns_count;
379 int iso_count;
380 int any_count;
381};
382
b0d623f7 383#ifdef PRIVATE
c910b4d9
A
384/*
385 * For scoped routing; a zero interface scope value means nil/no scope.
386 */
387#define IFSCOPE_NONE 0
b0d623f7
A
388#endif /* PRIVATE */
389
390#ifdef KERNEL_PRIVATE
391/*
392 * Generic call trace used by some subsystems (e.g. route, ifaddr)
393 */
394#define CTRACE_STACK_SIZE 8 /* depth of stack trace */
395#define CTRACE_HIST_SIZE 4 /* refcnt history size */
396typedef struct ctrace {
397 void *th; /* thread ptr */
398 void *pc[CTRACE_STACK_SIZE]; /* PC stack trace */
399} ctrace_t;
400
401extern void ctrace_record(ctrace_t *);
402
403#define RT_LOCK_ASSERT_HELD(_rt) \
404 lck_mtx_assert(&(_rt)->rt_lock, LCK_MTX_ASSERT_OWNED)
405
406#define RT_LOCK_ASSERT_NOTHELD(_rt) \
407 lck_mtx_assert(&(_rt)->rt_lock, LCK_MTX_ASSERT_NOTOWNED)
408
409#define RT_LOCK(_rt) do { \
410 if (!rte_debug) \
411 lck_mtx_lock(&(_rt)->rt_lock); \
412 else \
413 rt_lock(_rt, FALSE); \
414} while (0)
415
416#define RT_LOCK_SPIN(_rt) do { \
417 if (!rte_debug) \
418 lck_mtx_lock_spin(&(_rt)->rt_lock); \
419 else \
420 rt_lock(_rt, TRUE); \
421} while (0)
422
423#define RT_CONVERT_LOCK(_rt) do { \
424 RT_LOCK_ASSERT_HELD(_rt); \
425 lck_mtx_convert_spin(&(_rt)->rt_lock); \
426} while (0)
427
428#define RT_UNLOCK(_rt) do { \
429 if (!rte_debug) \
430 lck_mtx_unlock(&(_rt)->rt_lock); \
431 else \
432 rt_unlock(_rt); \
433} while (0)
434
435#define RT_ADDREF_LOCKED(_rt) do { \
436 if (!rte_debug) { \
437 RT_LOCK_ASSERT_HELD(_rt); \
438 if (++(_rt)->rt_refcnt == 0) \
439 panic("RT_ADDREF(%p) bad refcnt\n", _rt); \
440 } else { \
441 rtref(_rt); \
442 } \
443} while (0)
444
445/*
446 * Spin variant mutex is used here; caller is responsible for
447 * converting any previously-held similar lock to full mutex.
448 */
449#define RT_ADDREF(_rt) do { \
450 RT_LOCK_SPIN(_rt); \
451 RT_ADDREF_LOCKED(_rt); \
452 RT_UNLOCK(_rt); \
453} while (0)
454
455#define RT_REMREF_LOCKED(_rt) do { \
456 if (!rte_debug) { \
457 RT_LOCK_ASSERT_HELD(_rt); \
458 if ((_rt)->rt_refcnt == 0) \
459 panic("RT_REMREF(%p) bad refcnt\n", _rt); \
460 --(_rt)->rt_refcnt; \
461 } else { \
462 (void) rtunref(_rt); \
463 } \
464} while (0)
465
466/*
467 * Spin variant mutex is used here; caller is responsible for
468 * converting any previously-held similar lock to full mutex.
469 */
470#define RT_REMREF(_rt) do { \
471 RT_LOCK_SPIN(_rt); \
472 RT_REMREF_LOCKED(_rt); \
473 RT_UNLOCK(_rt); \
474} while (0)
475
476#define RTFREE(_rt) rtfree(_rt)
477#define RTFREE_LOCKED(_rt) rtfree_locked(_rt)
c910b4d9 478
1c79356b
A
479extern struct route_cb route_cb;
480extern struct radix_node_head *rt_tables[AF_MAX+1];
b0d623f7
A
481__private_extern__ lck_mtx_t *rnh_lock;
482__private_extern__ int use_routegenid;
483__private_extern__ uint32_t route_generation;
484__private_extern__ int rttrash;
485__private_extern__ unsigned int rte_debug;
1c79356b
A
486
487struct ifmultiaddr;
488struct proc;
489
2d21ac55 490extern void route_init(void) __attribute__((section("__TEXT, initcode")));
b0d623f7 491extern void routegenid_update(void);
2d21ac55
A
492extern void rt_ifmsg(struct ifnet *);
493extern void rt_missmsg(int, struct rt_addrinfo *, int, int);
494extern void rt_newaddrmsg(int, struct ifaddr *, int, struct rtentry *);
495extern void rt_newmaddrmsg(int, struct ifmultiaddr *);
496extern int rt_setgate(struct rtentry *, struct sockaddr *, struct sockaddr *);
6d2010ae
A
497extern void set_primary_ifscope(int, unsigned int);
498extern unsigned int get_primary_ifscope(int);
499extern boolean_t rt_primary_default(struct rtentry *, struct sockaddr *);
c910b4d9
A
500extern struct rtentry *rt_lookup(boolean_t, struct sockaddr *,
501 struct sockaddr *, struct radix_node_head *, unsigned int);
2d21ac55 502extern void rtalloc(struct route *);
6d2010ae 503extern void rtalloc_scoped(struct route *, unsigned int);
b0d623f7 504extern void rtalloc_ign(struct route *, uint32_t);
b0d623f7 505extern void rtalloc_scoped_ign(struct route *, uint32_t, unsigned int);
b0d623f7 506extern struct rtentry *rtalloc1(struct sockaddr *, int, uint32_t);
b0d623f7
A
507extern struct rtentry *rtalloc1_scoped(struct sockaddr *, int, uint32_t,
508 unsigned int);
c910b4d9 509extern struct rtentry *rtalloc1_scoped_locked(struct sockaddr *, int,
b0d623f7 510 uint32_t, unsigned int);
2d21ac55
A
511extern void rtfree(struct rtentry *);
512extern void rtfree_locked(struct rtentry *);
513extern void rtref(struct rtentry *);
9bccf70c
A
514/*
515 * rtunref will decrement the refcount, rtfree will decrement and free if
516 * the refcount has reached zero and the route is not up.
517 * Unless you have good reason to do otherwise, use rtfree.
518 */
b0d623f7 519extern int rtunref(struct rtentry *);
2d21ac55
A
520extern void rtsetifa(struct rtentry *, struct ifaddr *);
521extern int rtinit(struct ifaddr *, int, int);
522extern int rtinit_locked(struct ifaddr *, int, int);
b0d623f7 523extern int rtioctl(unsigned long, caddr_t, struct proc *);
c910b4d9 524extern void rtredirect(struct ifnet *, struct sockaddr *, struct sockaddr *,
2d21ac55
A
525 struct sockaddr *, int, struct sockaddr *, struct rtentry **);
526extern int rtrequest(int, struct sockaddr *,
527 struct sockaddr *, struct sockaddr *, int, struct rtentry **);
6d2010ae
A
528extern int rtrequest_scoped(int, struct sockaddr *, struct sockaddr *,
529 struct sockaddr *, int, struct rtentry **, unsigned int);
2d21ac55
A
530extern int rtrequest_locked(int, struct sockaddr *,
531 struct sockaddr *, struct sockaddr *, int, struct rtentry **);
c910b4d9
A
532extern int rtrequest_scoped_locked(int, struct sockaddr *, struct sockaddr *,
533 struct sockaddr *, int, struct rtentry **, unsigned int);
6d2010ae
A
534extern void sin_set_ifscope(struct sockaddr *, unsigned int);
535extern unsigned int sin_get_ifscope(struct sockaddr *);
536extern unsigned int sin6_get_ifscope(struct sockaddr *);
b0d623f7
A
537extern void rt_lock(struct rtentry *, boolean_t);
538extern void rt_unlock(struct rtentry *);
6d2010ae 539extern struct sockaddr *rtm_scrub_ifscope(int, int, struct sockaddr *,
b0d623f7 540 struct sockaddr *, struct sockaddr_storage *);
d1ecb069 541extern u_int64_t rt_expiry(struct rtentry *, u_int64_t, u_int32_t);
6d2010ae
A
542extern void rt_set_idleref(struct rtentry *);
543extern void rt_clear_idleref(struct rtentry *);
d1ecb069 544extern void rt_aggdrain(int);
6d2010ae 545extern boolean_t rt_validate(struct rtentry *);
316670eb
A
546extern void rt_set_proxy(struct rtentry *, boolean_t);
547extern void rt_set_gwroute(struct rtentry *, struct sockaddr *,
548 struct rtentry *);
549extern void rt_revalidate_gwroute(struct rtentry *, struct rtentry *);
550extern errno_t route_to_gwroute(const struct sockaddr *, struct rtentry *,
551 struct rtentry **);
6d2010ae
A
552
553#ifdef XNU_KERNEL_PRIVATE
554extern void route_copyin(struct route *src, struct route *dst, size_t length);
555extern void route_copyout(struct route *dst, const struct route *src, size_t length);
556#endif /* XNU_KERNEL_PRIVATE */
557
b0d623f7 558#endif /* KERNEL_PRIVATE */
1c79356b
A
559
560#endif