xref: /original-bsd/sbin/XNSrouted/table.h (revision c3e32dec)
1 /*
2  * Copyright (c) 1983, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)table.h	5.1 (Berkeley) 6/4/85 (routed/table.h)
8  *
9  *	@(#)table.h	8.1 (Berkeley) 06/05/93
10  */
11 
12 /*
13  * Routing table management daemon.
14  */
15 
16 /*
17  * Routing table structure; differs a bit from kernel tables.
18  *
19  * Note: the union below must agree in the first 4 members
20  * so the ioctl's will work.
21  */
22 struct rthash {
23 	struct	rt_entry *rt_forw;
24 	struct	rt_entry *rt_back;
25 };
26 
27 #ifdef RTM_ADD
28 #define rtentry ortentry
29 #endif
30 
31 struct rt_entry {
32 	struct	rt_entry *rt_forw;
33 	struct	rt_entry *rt_back;
34 	union {
35 		struct	rtentry rtu_rt;
36 		struct {
37 			u_long	rtu_hash;
38 			struct	sockaddr rtu_dst;
39 			struct	sockaddr rtu_router;
40 			short	rtu_flags;
41 			short	rtu_state;
42 			int	rtu_timer;
43 			int	rtu_metric;
44 			struct	interface *rtu_ifp;
45 		} rtu_entry;
46 	} rt_rtu;
47 };
48 
49 #define	rt_rt		rt_rtu.rtu_rt			/* pass to ioctl */
50 #define	rt_hash		rt_rtu.rtu_entry.rtu_hash	/* for net or host */
51 #define	rt_dst		rt_rtu.rtu_entry.rtu_dst	/* match value */
52 #define	rt_router	rt_rtu.rtu_entry.rtu_router	/* who to forward to */
53 #define	rt_flags	rt_rtu.rtu_entry.rtu_flags	/* kernel flags */
54 #define	rt_timer	rt_rtu.rtu_entry.rtu_timer	/* for invalidation */
55 #define	rt_state	rt_rtu.rtu_entry.rtu_state	/* see below */
56 #define	rt_metric	rt_rtu.rtu_entry.rtu_metric	/* cost of route */
57 #define	rt_ifp		rt_rtu.rtu_entry.rtu_ifp	/* interface to take */
58 
59 #define	ROUTEHASHSIZ	32		/* must be a power of 2 */
60 #define	ROUTEHASHMASK	(ROUTEHASHSIZ - 1)
61 
62 /*
63  * "State" of routing table entry.
64  */
65 #define	RTS_CHANGED	0x1		/* route has been altered recently */
66 #define	RTS_PASSIVE	IFF_PASSIVE	/* don't time out route */
67 #define	RTS_INTERFACE	IFF_INTERFACE	/* route is for network interface */
68 #define	RTS_REMOTE	IFF_REMOTE	/* route is for ``remote'' entity */
69 
70 struct	rthash nethash[ROUTEHASHSIZ];
71 struct	rthash hosthash[ROUTEHASHSIZ];
72 struct	rt_entry *rtlookup();
73 struct	rt_entry *rtfind();
74