xref: /original-bsd/sbin/routed/table.h (revision e9b82df0)
1 /*
2  * Copyright (c) 1983 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)table.h	5.8 (Berkeley) 06/01/90
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 {
34 			u_long	rtu_hash;
35 			struct	sockaddr rtu_dst;
36 			struct	sockaddr rtu_router;
37 			short	rtu_flags;
38 			short	rtu_state;
39 			int	rtu_timer;
40 			int	rtu_metric;
41 			int	rtu_ifmetric;
42 			struct	interface *rtu_ifp;
43 		} rtu_entry;
44 	} rt_rtu;
45 };
46 
47 #define	rt_rt		rt_rtu.rtu_rt			/* pass to ioctl */
48 #define	rt_hash		rt_rtu.rtu_entry.rtu_hash	/* for net or host */
49 #define	rt_dst		rt_rtu.rtu_entry.rtu_dst	/* match value */
50 #define	rt_router	rt_rtu.rtu_entry.rtu_router	/* who to forward to */
51 #define	rt_flags	rt_rtu.rtu_entry.rtu_flags	/* kernel flags */
52 #define	rt_timer	rt_rtu.rtu_entry.rtu_timer	/* for invalidation */
53 #define	rt_state	rt_rtu.rtu_entry.rtu_state	/* see below */
54 #define	rt_metric	rt_rtu.rtu_entry.rtu_metric	/* cost of route */
55 #define	rt_ifmetric	rt_rtu.rtu_entry.rtu_ifmetric	/* cost of route if */
56 #define	rt_ifp		rt_rtu.rtu_entry.rtu_ifp	/* interface to take */
57 
58 #define	ROUTEHASHSIZ	32		/* must be a power of 2 */
59 #define	ROUTEHASHMASK	(ROUTEHASHSIZ - 1)
60 
61 /*
62  * "State" of routing table entry.
63  */
64 #define	RTS_CHANGED	0x1		/* route has been altered recently */
65 #define	RTS_EXTERNAL	0x2		/* extern info, not installed or sent */
66 #define	RTS_INTERNAL	0x4		/* internal route, not installed */
67 #define	RTS_PASSIVE	IFF_PASSIVE	/* don't time out route */
68 #define	RTS_INTERFACE	IFF_INTERFACE	/* route is for network interface */
69 #define	RTS_REMOTE	IFF_REMOTE	/* route is for ``remote'' entity */
70 #define	RTS_SUBNET	IFF_SUBNET	/* route is for network subnet */
71 
72 /*
73  * Flags are same as kernel, with this addition for af_rtflags:
74  */
75 #define	RTF_SUBNET	0x8000		/* pseudo: route to subnet */
76 
77 struct	rthash nethash[ROUTEHASHSIZ];
78 struct	rthash hosthash[ROUTEHASHSIZ];
79 struct	rt_entry *rtlookup();
80 struct	rt_entry *rtfind();
81