table.h revision 50479
1148871Scperciva/*
2148871Scperciva * Copyright (c) 1983, 1993
3148871Scperciva *	The Regents of the University of California.  All rights reserved.
4148871Scperciva *
5148871Scperciva * Copyright (c) 1995 John Hay.  All rights reserved.
6148871Scperciva *
7148871Scperciva * Redistribution and use in source and binary forms, with or without
8148871Scperciva * modification, are permitted provided that the following conditions
9148871Scperciva * are met:
10148871Scperciva * 1. Redistributions of source code must retain the above copyright
11148871Scperciva *    notice, this list of conditions and the following disclaimer.
12148871Scperciva * 2. Redistributions in binary form must reproduce the above copyright
13148871Scperciva *    notice, this list of conditions and the following disclaimer in the
14148871Scperciva *    documentation and/or other materials provided with the distribution.
15148871Scperciva * 3. All advertising materials mentioning features or use of this software
16148871Scperciva *    must display the following acknowledgement:
17148871Scperciva *	This product includes software developed by the University of
18148871Scperciva *	California, Berkeley and its contributors.
19148871Scperciva * 4. Neither the name of the University nor the names of its contributors
20148871Scperciva *    may be used to endorse or promote products derived from this software
21148871Scperciva *    without specific prior written permission.
22148871Scperciva *
23148871Scperciva * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24148871Scperciva * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25148871Scperciva * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26148871Scperciva * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27148871Scperciva * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28148871Scperciva * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29148871Scperciva * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30148871Scperciva * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31148871Scperciva * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32148871Scperciva * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33148871Scperciva * SUCH DAMAGE.
34148871Scperciva *
35148871Scperciva *	@(#)table.h	5.1 (Berkeley) 6/4/85 (routed/table.h)
36148871Scperciva *
37149027Scperciva *	@(#)table.h	8.1 (Berkeley) 6/5/93
38148871Scperciva *
39148871Scperciva * $FreeBSD: head/usr.sbin/IPXrouted/table.h 50479 1999-08-28 01:35:59Z peter $
40148871Scperciva */
41148871Scperciva
42148871Scperciva/*
43148871Scperciva * Routing table management daemon.
44148871Scperciva */
45148871Scperciva
46148871Scperciva/*
47148871Scperciva * Routing table structure; differs a bit from kernel tables.
48148871Scperciva *
49148871Scperciva * Note: the union below must agree in the first 4 members
50148871Scperciva * so the ioctl's will work.
51148871Scperciva */
52148871Scpercivastruct rthash {
53148871Scperciva	struct	rt_entry *rt_forw;
54148871Scperciva	struct	rt_entry *rt_back;
55148871Scperciva};
56148871Scperciva
57148871Scperciva#ifdef RTM_ADD
58148871Scperciva#define rtentry ortentry
59148871Scperciva#endif
60148871Scperciva
61148871Scpercivastruct rt_entry {
62148871Scperciva	struct	rt_entry *rt_forw;
63148871Scperciva	struct	rt_entry *rt_back;
64148871Scperciva	union {
65148871Scperciva		struct	rtentry rtu_rt;
66148871Scperciva		struct  rtuentry {
67148871Scperciva			u_long	rtu_hash;
68148871Scperciva			struct	sockaddr rtu_dst;
69148871Scperciva			struct	sockaddr rtu_router;
70148871Scperciva			short	rtu_rtflags; /* used by old rtioctl */
71148871Scperciva			short	rtu_wasted; /* XXX routed does it this way. */
72148871Scperciva			int	rtu_flags;
73148871Scperciva			int	rtu_state;
74148871Scperciva			int	rtu_timer;
75149027Scperciva			int	rtu_metric;
76148871Scperciva			int	rtu_ticks;
77148871Scperciva			struct	interface *rtu_ifp;
78148871Scperciva		} rtu_entry;
79148879Scperciva	} rt_rtu;
80148871Scperciva	struct	rt_entry *rt_clone;
81148871Scperciva};
82148871Scperciva
83148871Scperciva#define	rt_rt		rt_rtu.rtu_entry		/* pass to ioctl */
84149824Scperciva#define	rt_hash		rt_rtu.rtu_entry.rtu_hash	/* for net or host */
85148871Scperciva#define	rt_dst		rt_rtu.rtu_entry.rtu_dst	/* match value */
86148871Scperciva#define	rt_router	rt_rtu.rtu_entry.rtu_router	/* who to forward to */
87148871Scperciva#define	rt_flags	rt_rtu.rtu_entry.rtu_flags	/* kernel flags */
88148871Scperciva#define	rt_timer	rt_rtu.rtu_entry.rtu_timer	/* for invalidation */
89148871Scperciva#define	rt_state	rt_rtu.rtu_entry.rtu_state	/* see below */
90148871Scperciva#define	rt_metric	rt_rtu.rtu_entry.rtu_metric	/* cost of route */
91148871Scperciva#define	rt_ticks	rt_rtu.rtu_entry.rtu_ticks	/* time of route */
92148871Scperciva#define	rt_ifp		rt_rtu.rtu_entry.rtu_ifp	/* interface to take */
93148871Scperciva
94148871Scperciva#define	ROUTEHASHSIZ	128		/* must be a power of 2 */
95148871Scperciva#define	ROUTEHASHMASK	(ROUTEHASHSIZ - 1)
96148871Scperciva
97148871Scperciva/*
98148871Scperciva * "State" of routing table entry.
99148871Scperciva */
100148871Scperciva#define	RTS_CHANGED	0x1		/* route has been altered recently */
101148879Scperciva#define	RTS_PASSIVE	IFF_PASSIVE	/* don't time out route */
102148871Scperciva#define	RTS_INTERFACE	IFF_INTERFACE	/* route is for network interface */
103148871Scperciva#define	RTS_REMOTE	IFF_REMOTE	/* route is for ``remote'' entity */
104148871Scperciva
105148871Scpercivaextern struct	rthash nethash[ROUTEHASHSIZ];
106148871Scpercivastruct	rt_entry *rtlookup(struct sockaddr *);
107148871Scpercivastruct	rt_entry *rtfind(struct sockaddr *);
108148871Scpercivavoid	rtadd(struct sockaddr *, struct sockaddr *, short, short, int);
109148871Scpercivavoid	rtadd_clone(struct rt_entry *, struct sockaddr *, struct sockaddr *,
110148871Scperciva		    short, short, int);
111148871Scpercivavoid	rtchange(struct rt_entry *, struct sockaddr *, short, short);
112148871Scpercivavoid	rtdelete(struct rt_entry *);
113148871Scpercivaint	rtioctl(int, struct rtuentry *);
114148871Scpercivavoid	rtinit(void);
115148871Scperciva
116148871Scperciva