xref: /original-bsd/sbin/routed/table.h (revision 7211505a)
1 /*
2  * Copyright (c) 1983 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that the above copyright notice and this paragraph are
7  * duplicated in all such forms and that any documentation,
8  * advertising materials, and other materials related to such
9  * distribution and use acknowledge that the software was developed
10  * by the University of California, Berkeley.  The name of the
11  * University may not be used to endorse or promote products derived
12  * from this software without specific prior written permission.
13  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  *	@(#)table.h	5.6 (Berkeley) 06/18/88
18  */
19 
20 /*
21  * Routing table management daemon.
22  */
23 
24 /*
25  * Routing table structure; differs a bit from kernel tables.
26  *
27  * Note: the union below must agree in the first 4 members
28  * so the ioctl's will work.
29  */
30 struct rthash {
31 	struct	rt_entry *rt_forw;
32 	struct	rt_entry *rt_back;
33 };
34 
35 struct rt_entry {
36 	struct	rt_entry *rt_forw;
37 	struct	rt_entry *rt_back;
38 	union {
39 		struct	rtentry rtu_rt;
40 		struct {
41 			u_long	rtu_hash;
42 			struct	sockaddr rtu_dst;
43 			struct	sockaddr rtu_router;
44 			short	rtu_flags;
45 			short	rtu_state;
46 			int	rtu_timer;
47 			int	rtu_metric;
48 			int	rtu_ifmetric;
49 			struct	interface *rtu_ifp;
50 		} rtu_entry;
51 	} rt_rtu;
52 };
53 
54 #define	rt_rt		rt_rtu.rtu_rt			/* pass to ioctl */
55 #define	rt_hash		rt_rtu.rtu_entry.rtu_hash	/* for net or host */
56 #define	rt_dst		rt_rtu.rtu_entry.rtu_dst	/* match value */
57 #define	rt_router	rt_rtu.rtu_entry.rtu_router	/* who to forward to */
58 #define	rt_flags	rt_rtu.rtu_entry.rtu_flags	/* kernel flags */
59 #define	rt_timer	rt_rtu.rtu_entry.rtu_timer	/* for invalidation */
60 #define	rt_state	rt_rtu.rtu_entry.rtu_state	/* see below */
61 #define	rt_metric	rt_rtu.rtu_entry.rtu_metric	/* cost of route */
62 #define	rt_ifmetric	rt_rtu.rtu_entry.rtu_ifmetric	/* cost of route if */
63 #define	rt_ifp		rt_rtu.rtu_entry.rtu_ifp	/* interface to take */
64 
65 #define	ROUTEHASHSIZ	32		/* must be a power of 2 */
66 #define	ROUTEHASHMASK	(ROUTEHASHSIZ - 1)
67 
68 /*
69  * "State" of routing table entry.
70  */
71 #define	RTS_CHANGED	0x1		/* route has been altered recently */
72 #define	RTS_EXTERNAL	0x2		/* extern info, not installed or sent */
73 #define	RTS_INTERNAL	0x4		/* internal route, not installed */
74 #define	RTS_PASSIVE	IFF_PASSIVE	/* don't time out route */
75 #define	RTS_INTERFACE	IFF_INTERFACE	/* route is for network interface */
76 #define	RTS_REMOTE	IFF_REMOTE	/* route is for ``remote'' entity */
77 #define	RTS_SUBNET	IFF_SUBNET	/* route is for network subnet */
78 
79 /*
80  * Flags are same as kernel, with this addition for af_rtflags:
81  */
82 #define	RTF_SUBNET	0x8000		/* pseudo: route to subnet */
83 
84 struct	rthash nethash[ROUTEHASHSIZ];
85 struct	rthash hosthash[ROUTEHASHSIZ];
86 struct	rt_entry *rtlookup();
87 struct	rt_entry *rtfind();
88