xref: /original-bsd/sbin/routed/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	8.1 (Berkeley) 06/05/93
8  */
9 
10 /*
11  * Routing table management daemon.
12  */
13 
14 /*
15  * Routing table structure; differs a bit from kernel tables.
16  *
17  * Note: the union below must agree in the first 4 members
18  * so the ioctl's will work.
19  */
20 struct rthash {
21 	struct	rt_entry *rt_forw;
22 	struct	rt_entry *rt_back;
23 };
24 #ifdef RTM_ADD
25 #define rtentry ortentry
26 #endif
27 
28 struct rt_entry {
29 	struct	rt_entry *rt_forw;
30 	struct	rt_entry *rt_back;
31 	union {
32 		struct	rtentry rtu_rt;
33 		struct rtuentry {
34 			u_long	rtu_hash;
35 			struct	sockaddr rtu_dst;
36 			struct	sockaddr rtu_router;
37 			short	rtu_rtflags; /* used by rtioctl */
38 			short	rtu_wasted[5];
39 			int	rtu_flags;
40 			int	rtu_state;
41 			int	rtu_timer;
42 			int	rtu_metric;
43 			int	rtu_ifmetric;
44 			struct	interface *rtu_ifp;
45 		} rtu_entry;
46 	} rt_rtu;
47 };
48 
49 #define	rt_rt		rt_rtu.rtu_entry		/* 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_ifmetric	rt_rtu.rtu_entry.rtu_ifmetric	/* cost of route if */
58 #define	rt_ifp		rt_rtu.rtu_entry.rtu_ifp	/* interface to take */
59 
60 #define	ROUTEHASHSIZ	32		/* must be a power of 2 */
61 #define	ROUTEHASHMASK	(ROUTEHASHSIZ - 1)
62 
63 /*
64  * "State" of routing table entry.
65  */
66 #define	RTS_CHANGED	0x1		/* route has been altered recently */
67 #define	RTS_EXTERNAL	0x2		/* extern info, not installed or sent */
68 #define	RTS_INTERNAL	0x4		/* internal route, not installed */
69 #define	RTS_PASSIVE	IFF_PASSIVE	/* don't time out route */
70 #define	RTS_INTERFACE	IFF_INTERFACE	/* route is for network interface */
71 #define	RTS_REMOTE	IFF_REMOTE	/* route is for ``remote'' entity */
72 #define	RTS_SUBNET	IFF_SUBNET	/* route is for network subnet */
73 
74 /*
75  * Flags are same as kernel, with this addition for af_rtflags:
76  */
77 #define	RTF_SUBNET	0x80000		/* pseudo: route to subnet */
78 
79 struct	rthash nethash[ROUTEHASHSIZ];
80 struct	rthash hosthash[ROUTEHASHSIZ];
81 struct	rt_entry *rtlookup();
82 struct	rt_entry *rtfind();
83