route.h revision 205024
115103Sphk/*-
215103Sphk * Copyright (c) 1980, 1986, 1993
315103Sphk *	The Regents of the University of California.  All rights reserved.
415103Sphk *
515103Sphk * Redistribution and use in source and binary forms, with or without
615103Sphk * modification, are permitted provided that the following conditions
715103Sphk * are met:
815103Sphk * 1. Redistributions of source code must retain the above copyright
915103Sphk *    notice, this list of conditions and the following disclaimer.
1015103Sphk * 2. Redistributions in binary form must reproduce the above copyright
1115103Sphk *    notice, this list of conditions and the following disclaimer in the
1215103Sphk *    documentation and/or other materials provided with the distribution.
1315103Sphk * 4. Neither the name of the University nor the names of its contributors
1415103Sphk *    may be used to endorse or promote products derived from this software
1515103Sphk *    without specific prior written permission.
1615103Sphk *
1715103Sphk * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1815103Sphk * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1915103Sphk * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2015103Sphk * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2115103Sphk * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2215103Sphk * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2315103Sphk * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2415103Sphk * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2515103Sphk * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2615103Sphk * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2715103Sphk * SUCH DAMAGE.
2815103Sphk *
2915103Sphk *	@(#)route.h	8.4 (Berkeley) 1/9/95
3015103Sphk * $FreeBSD: head/sys/net/route.h 205024 2010-03-11 17:56:46Z qingli $
3115103Sphk */
3215103Sphk
3315103Sphk#ifndef _NET_ROUTE_H_
3415103Sphk#define _NET_ROUTE_H_
3515103Sphk
3615103Sphk/*
3715103Sphk * Kernel resident routing tables.
38116182Sobrien *
39116182Sobrien * The routing tables are initialized when interface addresses
40116182Sobrien * are set by making entries for all directly connected interfaces.
4186190Srwatson */
42169604Swkoszek
4384611Srwatson/*
4415103Sphk * A route consists of a destination address, a reference
4515103Sphk * to a routing entry, and a reference to an llentry.
46169507Swkoszek * These are often held by protocols in their control
4715103Sphk * blocks, e.g. inpcb.
4815103Sphk */
4915103Sphkstruct route {
5087275Srwatson	struct	rtentry *ro_rt;
5187275Srwatson	struct	llentry *ro_lle;
5246155Sphk	struct	sockaddr ro_dst;
5376078Sjhb};
54105046Smike
5528918Skato/*
5615103Sphk * These numbers are used by reliable protocols for determining
5715103Sphk * retransmission behavior and are included in the routing structure.
5815103Sphk */
5915103Sphkstruct rt_metrics_lite {
6015103Sphk	u_long	rmx_mtu;	/* MTU for this path */
6115103Sphk	u_long	rmx_expire;	/* lifetime for route, e.g. redirect */
6223382Sbde	u_long	rmx_pksent;	/* packets sent using this route */
6315103Sphk	u_long	rmx_weight;	/* absolute weight */
6415103Sphk};
6515103Sphk
6615103Sphkstruct rt_metrics {
6715103Sphk	u_long	rmx_locks;	/* Kernel must leave these values alone */
6848891Sphk	u_long	rmx_mtu;	/* MTU for this path */
6948891Sphk	u_long	rmx_hopcount;	/* max hops expected */
7015103Sphk	u_long	rmx_expire;	/* lifetime for route, e.g. redirect */
7115103Sphk	u_long	rmx_recvpipe;	/* inbound delay-bandwidth product */
7215103Sphk	u_long	rmx_sendpipe;	/* outbound delay-bandwidth product */
7315103Sphk	u_long	rmx_ssthresh;	/* outbound gateway buffer limit */
7415103Sphk	u_long	rmx_rtt;	/* estimated round trip time */
7515103Sphk	u_long	rmx_rttvar;	/* estimated rtt variance */
7634925Sdufault	u_long	rmx_pksent;	/* packets sent using this route */
7734925Sdufault	u_long	rmx_weight;	/* route weight */
7834029Sdufault	u_long	rmx_filler[3];	/* will be used for T/TCP later */
7950465Smarcel};
8050465Smarcel
8189414Sarr/*
8289414Sarr * rmx_rtt and rmx_rttvar are stored as microseconds;
8386190Srwatson * RTTTOPRHZ(rtt) converts to a value suitable for use
8486190Srwatson * by a protocol slowtimo counter.
8586190Srwatson */
8686190Srwatson#define	RTM_RTTUNIT	1000000	/* units for rtt, rttvar, as units per sec */
8750465Smarcel#define	RTTTOPRHZ(r)	((r) / (RTM_RTTUNIT / PR_SLOWHZ))
88116090Sjmallett
89116105Sjmallett/* MRT compile-time constants */
90116090Sjmallett#ifdef _KERNEL
9186189Srwatson #ifndef ROUTETABLES
9288019Sluigi  #define RT_NUMFIBS 1
9315103Sphk  #define RT_MAXFIBS 1
9486189Srwatson #else
9546381Sbillf  /* while we use 4 bits in the mbuf flags, we are limited to 16 */
9615103Sphk  #define RT_MAXFIBS 16
9786189Srwatson  #if ROUTETABLES > RT_MAXFIBS
9846381Sbillf   #define RT_NUMFIBS RT_MAXFIBS
9915103Sphk   #error "ROUTETABLES defined too big"
10086189Srwatson  #else
10146381Sbillf   #if ROUTETABLES == 0
10215103Sphk    #define RT_NUMFIBS 1
103119203Seivind   #else
104119203Seivind    #define RT_NUMFIBS ROUTETABLES
105119203Seivind   #endif
106119203Seivind  #endif
10715103Sphk #endif
10886189Srwatson#endif
109119203Seivind
11015103Sphkextern u_int rt_numfibs;	/* number fo usable routing tables */
111121307Ssilbyextern u_int tunnel_fib;	/* tunnels use these */
11246381Sbillfextern u_int fwd_fib;		/* packets being forwarded use these routes */
11315103Sphk/*
11486189Srwatson * XXX kernel function pointer `rt_output' is visible to applications.
11546381Sbillf */
11615103Sphkstruct mbuf;
117121307Ssilby
11880418Speter/*
11980418Speter * We distinguish between routes to hosts and routes to networks,
12086189Srwatson * preferring the former if available.  For each route we infer
12146381Sbillf * the interface to use from the gateway address supplied when
12215103Sphk * the route was entered.  Routes that forward packets through
12386189Srwatson * gateways are marked so that the output routines know to address the
124105046Smike * gateway rather than the ultimate destination.
12515103Sphk */
12686189Srwatson#ifndef RNF_NORMAL
12746381Sbillf#include <net/radix.h>
12815103Sphk#ifdef RADIX_MPATH
12986189Srwatson#include <net/radix_mpath.h>
13046381Sbillf#endif
13115103Sphk#endif
13215103Sphkstruct rtentry {
13386189Srwatson	struct	radix_node rt_nodes[2];	/* tree glue, and other values */
13446381Sbillf	/*
13515103Sphk	 * XXX struct rtentry must begin with a struct radix_node (or two!)
13686189Srwatson	 * because the code does some casts of a 'struct radix_node *'
13746381Sbillf	 * to a 'struct rtentry *'
13815103Sphk	 */
13915103Sphk#define	rt_key(r)	(*((struct sockaddr **)(&(r)->rt_nodes->rn_key)))
14015103Sphk#define	rt_mask(r)	(*((struct sockaddr **)(&(r)->rt_nodes->rn_mask)))
14115103Sphk	struct	sockaddr *rt_gateway;	/* value */
14286189Srwatson	int	rt_flags;		/* up/down?, host/net */
14346381Sbillf	int	rt_refcnt;		/* # held references */
14415103Sphk	struct	ifnet *rt_ifp;		/* the answer: interface to use */
14586189Srwatson	struct	ifaddr *rt_ifa;		/* the answer: interface address to use */
14646381Sbillf	struct	rt_metrics_lite rt_rmx;	/* metrics used by rx'ing protocols */
14715103Sphk	u_int	rt_fibnum;		/* which FIB */
14886189Srwatson#ifdef _KERNEL
14946381Sbillf	/* XXX ugly, user apps use this definition but don't have a mtx def */
15015103Sphk	struct	mtx rt_mtx;		/* mutex for routing entry */
15186189Srwatson#endif
15246381Sbillf};
15315103Sphk
154106605Stmm/*
155106605Stmm * Following structure necessary for 4.3 compatibility;
156106605Stmm * We should eventually move it to a compat file.
157106605Stmm */
158106605Stmmstruct ortentry {
159106605Stmm	u_long	rt_hash;		/* to speed lookups */
160106605Stmm	struct	sockaddr rt_dst;	/* key */
161106605Stmm	struct	sockaddr rt_gateway;	/* value */
162106605Stmm	short	rt_flags;		/* up/down?, host/net */
163106605Stmm	short	rt_refcnt;		/* # held references */
164106605Stmm	u_long	rt_use;			/* raw # packets forwarded */
165106605Stmm	struct	ifnet *rt_ifp;		/* the answer: interface to use */
166106605Stmm};
167142834Swes
168142834Swes#define rt_use rt_rmx.rmx_pksent
169142834Swes
170142834Swes#define	RTF_UP		0x1		/* route usable */
171142834Swes#define	RTF_GATEWAY	0x2		/* destination is a gateway */
172142834Swes#define	RTF_HOST	0x4		/* host entry (net otherwise) */
173142834Swes#define	RTF_REJECT	0x8		/* host or net unreachable */
174142834Swes#define	RTF_DYNAMIC	0x10		/* created dynamically (by redirect) */
175142834Swes#define	RTF_MODIFIED	0x20		/* modified dynamically (by redirect) */
176106605Stmm#define RTF_DONE	0x40		/* message confirmed */
177106605Stmm/*			0x80		   unused, was RTF_DELCLONE */
178106605Stmm/*			0x100		   unused, was RTF_CLONING */
179106605Stmm#define RTF_XRESOLVE	0x200		/* external daemon resolves name */
180106605Stmm#define RTF_LLINFO	0x400		/* DEPRECATED - exists ONLY for backward
181106605Stmm					   compatibility */
182106605Stmm#define RTF_LLDATA	0x400		/* used by apps to add/del L2 entries */
183106605Stmm#define RTF_STATIC	0x800		/* manually added */
184106605Stmm#define RTF_BLACKHOLE	0x1000		/* just discard pkts (during updates) */
185106605Stmm#define RTF_PROTO2	0x4000		/* protocol specific routing flag */
186106605Stmm#define RTF_PROTO1	0x8000		/* protocol specific routing flag */
187106605Stmm
188106605Stmm/* XXX: temporary to stay API/ABI compatible with userland */
18928885Skato#ifndef _KERNEL
19028885Skato#define RTF_PRCLONING	0x10000		/* unused, for compatibility */
19146381Sbillf#endif
19228885Skato
19315103Sphk/*			0x20000		   unused, was RTF_WASCLONED */
19415103Sphk#define RTF_PROTO3	0x40000		/* protocol specific routing flag */
19546155Sphk/*			0x80000		   unused */
19662573Sphk#define RTF_PINNED	0x100000	/* future use */
19746155Sphk#define	RTF_LOCAL	0x200000 	/* route represents a local address */
19887072Srwatson#define	RTF_BROADCAST	0x400000	/* route represents a bcast address */
19987275Srwatson#define	RTF_MULTICAST	0x800000	/* route represents a mcast address */
20046155Sphk					/* 0x8000000 and up unassigned */
20115103Sphk#define	RTF_STICKY	 0x10000000	/* always route dst->src */
20291406Sjhb
20387072Srwatson#define	RTF_RNH_LOCKED	 0x40000000	/* radix node head is locked */
20457163Srwatson
20586190Srwatson/* Mask of RTF flags that are allowed to be modified by RTM_CHANGE. */
20687275Srwatson#define RTF_FMASK	\
20787275Srwatson	(RTF_PROTO1 | RTF_PROTO2 | RTF_PROTO3 | RTF_BLACKHOLE | \
20887275Srwatson	 RTF_REJECT | RTF_STATIC | RTF_STICKY)
20987275Srwatson
21087275Srwatson/*
21187275Srwatson * Routing statistics.
21287275Srwatson */
21387275Srwatsonstruct	rtstat {
21487275Srwatson	short	rts_badredirect;	/* bogus redirect calls */
21587275Srwatson	short	rts_dynamic;		/* routes created by redirects */
21687072Srwatson	short	rts_newgateway;		/* routes modified by redirects */
21787275Srwatson	short	rts_unreach;		/* lookups which failed */
21887275Srwatson	short	rts_wildcard;		/* lookups satisfied by a wildcard */
21987275Srwatson};
22087275Srwatson/*
22187275Srwatson * Structures for routing messages.
22287275Srwatson */
22387275Srwatsonstruct rt_msghdr {
22487275Srwatson	u_short	rtm_msglen;	/* to skip over non-understood messages */
22587275Srwatson	u_char	rtm_version;	/* future binary compatibility */
22687275Srwatson	u_char	rtm_type;	/* message type */
22757111Srwatson	u_short	rtm_index;	/* index for associated ifp */
22886189Srwatson	int	rtm_flags;	/* flags, incl. kern & message, e.g. DONE */
22946155Sphk	int	rtm_addrs;	/* bitmask identifying sockaddrs in msg */
23046155Sphk	pid_t	rtm_pid;	/* identify sender */
23146155Sphk	int	rtm_seq;	/* for sender to identify action */
23246155Sphk	int	rtm_errno;	/* why failed */
23386189Srwatson	int	rtm_fmask;	/* bitmask used in RTM_CHANGE message */
23446155Sphk	u_long	rtm_inits;	/* which metrics we are initializing */
23546381Sbillf	struct	rt_metrics rtm_rmx; /* metrics themselves */
23646155Sphk};
23786190Srwatson
23884611Srwatson#define RTM_VERSION	5	/* Up the ante and ignore older versions */
23987072Srwatson
24084611Srwatson/*
24184611Srwatson * Message types.
24286190Srwatson */
24384611Srwatson#define RTM_ADD		0x1	/* Add Route */
24415103Sphk#define RTM_DELETE	0x2	/* Delete Route */
245114293Smarkm#define RTM_CHANGE	0x3	/* Change Metrics or flags */
24615103Sphk#define RTM_GET		0x4	/* Report Metrics */
24793686Sarr#define RTM_LOSING	0x5	/* Kernel Suspects Partitioning */
24893686Sarr#define RTM_REDIRECT	0x6	/* Told to use different route */
24993686Sarr#define RTM_MISS	0x7	/* Lookup failed on this address */
25015103Sphk#define RTM_LOCK	0x8	/* fix specified metrics */
25162573Sphk#define RTM_OLDADD	0x9	/* caused by SIOCADDRT */
25215103Sphk#define RTM_OLDDEL	0xa	/* caused by SIOCDELRT */
25386145Srwatson#define RTM_RESOLVE	0xb	/* req to resolve dst to LL addr */
25486140Srwatson#define RTM_NEWADDR	0xc	/* address being added to iface */
25515103Sphk#define RTM_DELADDR	0xd	/* address being removed from iface */
25691406Sjhb#define RTM_IFINFO	0xe	/* iface going up/down etc. */
25786145Srwatson#define	RTM_NEWMADDR	0xf	/* mcast group membership being added to if */
25886140Srwatson#define	RTM_DELMADDR	0x10	/* mcast group membership being deleted */
25986140Srwatson#define	RTM_IFANNOUNCE	0x11	/* iface arrival/departure */
260140676Srwatson#define	RTM_IEEE80211	0x12	/* IEEE80211 wireless event */
261141013Srwatson
26286140Srwatson/*
263140676Srwatson * Bitmask values for rtm_inits and rmx_locks.
26486145Srwatson */
265140676Srwatson#define RTV_MTU		0x1	/* init or lock _mtu */
26686140Srwatson#define RTV_HOPCOUNT	0x2	/* init or lock _hopcount */
26786140Srwatson#define RTV_EXPIRE	0x4	/* init or lock _expire */
26886140Srwatson#define RTV_RPIPE	0x8	/* init or lock _recvpipe */
26986140Srwatson#define RTV_SPIPE	0x10	/* init or lock _sendpipe */
27086140Srwatson#define RTV_SSTHRESH	0x20	/* init or lock _ssthresh */
27186140Srwatson#define RTV_RTT		0x40	/* init or lock _rtt */
27286140Srwatson#define RTV_RTTVAR	0x80	/* init or lock _rttvar */
27386140Srwatson#define RTV_WEIGHT	0x100	/* init or lock _weight */
27486145Srwatson
27587275Srwatson/*
27687072Srwatson * Bitmask values for rtm_addrs.
27787275Srwatson */
27887275Srwatson#define RTA_DST		0x1	/* destination sockaddr present */
27986140Srwatson#define RTA_GATEWAY	0x2	/* gateway sockaddr present */
28087275Srwatson#define RTA_NETMASK	0x4	/* netmask sockaddr present */
28186145Srwatson#define RTA_GENMASK	0x8	/* cloning mask sockaddr present */
28287275Srwatson#define RTA_IFP		0x10	/* interface name sockaddr present */
28386140Srwatson#define RTA_IFA		0x20	/* interface addr sockaddr present */
28493686Sarr#define RTA_AUTHOR	0x40	/* sockaddr for author of redirect */
28587072Srwatson#define RTA_BRD		0x80	/* for NEWADDR, broadcast or p-p dest addr */
28693686Sarr
28793686Sarr/*
28886140Srwatson * Index offsets for sockaddr array for alternate internal encoding.
28993686Sarr */
29086140Srwatson#define RTAX_DST	0	/* destination sockaddr present */
29193686Sarr#define RTAX_GATEWAY	1	/* gateway sockaddr present */
29286140Srwatson#define RTAX_NETMASK	2	/* netmask sockaddr present */
29386140Srwatson#define RTAX_GENMASK	3	/* cloning mask sockaddr present */
29415103Sphk#define RTAX_IFP	4	/* interface name sockaddr present */
29515103Sphk#define RTAX_IFA	5	/* interface addr sockaddr present */
29683990Srwatson#define RTAX_AUTHOR	6	/* sockaddr for author of redirect */
29783990Srwatson#define RTAX_BRD	7	/* for NEWADDR, broadcast or p-p dest addr */
29883990Srwatson#define RTAX_MAX	8	/* size of array to allocate */
29961370Srwatson
300169604Swkoszekstruct rt_addrinfo {
301169507Swkoszek	int	rti_addrs;
302169507Swkoszek	struct	sockaddr *rti_info[RTAX_MAX];
303169604Swkoszek	int	rti_flags;
304169604Swkoszek	struct	ifaddr *rti_ifa;
305169604Swkoszek	struct	ifnet *rti_ifp;
306169507Swkoszek};
307169507Swkoszek
308169507Swkoszek/*
309169507Swkoszek * This macro returns the size of a struct sockaddr when passed
310169507Swkoszek * through a routing socket. Basically we round up sa_len to
311169507Swkoszek * a multiple of sizeof(long), with a minimum of sizeof(long).
312169507Swkoszek * The check for a NULL pointer is just a convenience, probably never used.
313169507Swkoszek * The case sa_len == 0 should only apply to empty structures.
314169507Swkoszek */
315169507Swkoszek#define SA_SIZE(sa)						\
316169507Swkoszek    (  (!(sa) || ((struct sockaddr *)(sa))->sa_len == 0) ?	\
317169507Swkoszek	sizeof(long)		:				\
318169507Swkoszek	1 + ( (((struct sockaddr *)(sa))->sa_len - 1) | (sizeof(long) - 1) ) )
319169507Swkoszek
320169507Swkoszek#ifdef _KERNEL
321169507Swkoszek
322169507Swkoszek#define RT_LINK_IS_UP(ifp)	(((ifp)->if_flags &		    \
323169507Swkoszek				  (IFF_LOOPBACK | IFF_POINTOPOINT)) \
324169507Swkoszek				 || (ifp)->if_link_state == LINK_STATE_UP)
325169507Swkoszek
326169507Swkoszek#define	RT_LOCK_INIT(_rt) \
327169507Swkoszek	mtx_init(&(_rt)->rt_mtx, "rtentry", NULL, MTX_DEF | MTX_DUPOK)
328169507Swkoszek#define	RT_LOCK(_rt)		mtx_lock(&(_rt)->rt_mtx)
329169507Swkoszek#define	RT_TRYLOCK(_rt)		mtx_trylock(&(_rt)->rt_mtx)
330169507Swkoszek#define	RT_UNLOCK(_rt)		mtx_unlock(&(_rt)->rt_mtx)
331169507Swkoszek#define	RT_LOCK_DESTROY(_rt)	mtx_destroy(&(_rt)->rt_mtx)
332169507Swkoszek#define	RT_LOCK_ASSERT(_rt)	mtx_assert(&(_rt)->rt_mtx, MA_OWNED)
333169507Swkoszek
334169507Swkoszek#define	RT_ADDREF(_rt)	do {					\
335169507Swkoszek	RT_LOCK_ASSERT(_rt);					\
33615103Sphk	KASSERT((_rt)->rt_refcnt >= 0,				\
33717281Swollman		("negative refcnt %d", (_rt)->rt_refcnt));	\
33846381Sbillf	(_rt)->rt_refcnt++;					\
33915103Sphk} while (0)
34086190Srwatson
34178609Spirzyk#define	RT_REMREF(_rt)	do {					\
342168545Spjd	RT_LOCK_ASSERT(_rt);					\
343168545Spjd	KASSERT((_rt)->rt_refcnt > 0,				\
344168545Spjd		("bogus refcnt %d", (_rt)->rt_refcnt));	\
34515103Sphk	(_rt)->rt_refcnt--;					\
34615103Sphk} while (0)
34715103Sphk
34886189Srwatson#define	RTFREE_LOCKED(_rt) do {					\
34915103Sphk	if ((_rt)->rt_refcnt <= 1)				\
35015103Sphk		rtfree(_rt);					\
35186189Srwatson	else {							\
35246381Sbillf		RT_REMREF(_rt);					\
35386189Srwatson		RT_UNLOCK(_rt);					\
35446381Sbillf	}							\
35586189Srwatson	/* guard against invalid refs */			\
35646381Sbillf	_rt = 0;						\
35786189Srwatson} while (0)
35846381Sbillf
35986189Srwatson#define	RTFREE(_rt) do {					\
36046381Sbillf	RT_LOCK(_rt);						\
36186189Srwatson	RTFREE_LOCKED(_rt);					\
36246381Sbillf} while (0)
36318540Sbde
36486189Srwatson#define RT_TEMP_UNLOCK(_rt) do {				\
36546381Sbillf	RT_ADDREF(_rt);						\
36686189Srwatson	RT_UNLOCK(_rt);						\
36746381Sbillf} while (0)
36886189Srwatson
36986189Srwatson#define RT_RELOCK(_rt) do {					\
37046381Sbillf	RT_LOCK(_rt);						\
37186189Srwatson	if ((_rt)->rt_refcnt <= 1) {				\
37246381Sbillf		rtfree(_rt);					\
37386189Srwatson		_rt = 0; /*  signal that it went away */	\
37446381Sbillf	} else {						\
37586189Srwatson		RT_REMREF(_rt);					\
37646381Sbillf		/* note that _rt is still valid */		\
37786189Srwatson	}							\
37846381Sbillf} while (0)
37986189Srwatson
38046381Sbillfstruct radix_node_head *rt_tables_get_rnh(int, int);
38186189Srwatson
38246381Sbillfstruct ifmultiaddr;
38386189Srwatson
38446381Sbillfvoid	 rt_ieee80211msg(struct ifnet *, int, void *, size_t);
38586189Srwatsonvoid	 rt_ifannouncemsg(struct ifnet *, int);
38646381Sbillfvoid	 rt_ifmsg(struct ifnet *);
38786189Srwatsonvoid	 rt_missmsg(int, struct rt_addrinfo *, int, int);
38846381Sbillfvoid	 rt_newaddrmsg(int, struct ifaddr *, int, struct rtentry *);
38986189Srwatsonvoid	 rt_newmaddrmsg(int, struct ifmultiaddr *);
39046381Sbillfint	 rt_setgate(struct rtentry *, struct sockaddr *, struct sockaddr *);
39148891Sphkvoid 	 rt_maskedcopy(struct sockaddr *, struct sockaddr *, struct sockaddr *);
39248891Sphk
39386189Srwatson/*
39448891Sphk * Note the following locking behavior:
39548891Sphk *
39686189Srwatson *    rtalloc_ign() and rtalloc() return ro->ro_rt unlocked
39748891Sphk *
39848927Sphk *    rtalloc1() returns a locked rtentry
39960041Sphk *
40058926Sphk *    rtfree() and RTFREE_LOCKED() require a locked rtentry
40158926Sphk *
40258926Sphk *    RTFREE() uses an unlocked entry.
40358926Sphk */
40458926Sphk
40572376Sjakeint	 rtexpunge(struct rtentry *);
40672376Sjakevoid	 rtfree(struct rtentry *);
40772376Sjakeint	 rt_check(struct rtentry **, struct rtentry **, struct sockaddr *);
40872376Sjake
409108685Sjake/* XXX MRT COMPAT VERSIONS THAT SET UNIVERSE to 0 */
410108696Sjake/* Thes are used by old code not yet converted to use multiple FIBS */
411108696Sjakeint	 rt_getifa(struct rt_addrinfo *);
412108696Sjakevoid	 rtalloc_ign(struct route *ro, u_long ignflags);
413108696Sjakevoid	 rtalloc(struct route *ro); /* XXX deprecated, use rtalloc_ign(ro, 0) */
414108696Sjakestruct rtentry *rtalloc1(struct sockaddr *, int, u_long);
415108696Sjakeint	 rtinit(struct ifaddr *, int, int);
416int	 rtioctl(u_long, caddr_t);
417void	 rtredirect(struct sockaddr *, struct sockaddr *,
418	    struct sockaddr *, int, struct sockaddr *);
419int	 rtrequest(int, struct sockaddr *,
420	    struct sockaddr *, struct sockaddr *, int, struct rtentry **);
421
422/* defaults to "all" FIBs */
423int	 rtinit_fib(struct ifaddr *, int, int);
424
425/* XXX MRT NEW VERSIONS THAT USE FIBs
426 * For now the protocol indepedent versions are the same as the AF_INET ones
427 * but this will change..
428 */
429int	 rt_getifa_fib(struct rt_addrinfo *, u_int fibnum);
430void	 rtalloc_ign_fib(struct route *ro, u_long ignflags, u_int fibnum);
431void	 rtalloc_fib(struct route *ro, u_int fibnum);
432struct rtentry *rtalloc1_fib(struct sockaddr *, int, u_long, u_int);
433int	 rtioctl_fib(u_long, caddr_t, u_int);
434void	 rtredirect_fib(struct sockaddr *, struct sockaddr *,
435	    struct sockaddr *, int, struct sockaddr *, u_int);
436int	 rtrequest_fib(int, struct sockaddr *,
437	    struct sockaddr *, struct sockaddr *, int, struct rtentry **, u_int);
438int	 rtrequest1_fib(int, struct rt_addrinfo *, struct rtentry **, u_int);
439
440#include <sys/eventhandler.h>
441typedef void (*rtevent_arp_update_fn)(void *, struct rtentry *, uint8_t *, struct sockaddr *);
442typedef void (*rtevent_redirect_fn)(void *, struct rtentry *, struct rtentry *, struct sockaddr *);
443/* route_arp_update_event is no longer generated; see arp_update_event */
444EVENTHANDLER_DECLARE(route_arp_update_event, rtevent_arp_update_fn);
445EVENTHANDLER_DECLARE(route_redirect_event, rtevent_redirect_fn);
446#endif
447
448#endif
449