xref: /original-bsd/sbin/XNSrouted/table.h (revision 7717c4d4)
1 /*
2  * Copyright (c) 1983 The 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.1 (Berkeley) 6/4/85 (routed/table.h)
18  *
19  *	@(#)table.h	5.2 (Berkeley) 08/21/89
20  */
21 
22 /*
23  * Routing table management daemon.
24  */
25 
26 /*
27  * Routing table structure; differs a bit from kernel tables.
28  *
29  * Note: the union below must agree in the first 4 members
30  * so the ioctl's will work.
31  */
32 struct rthash {
33 	struct	rt_entry *rt_forw;
34 	struct	rt_entry *rt_back;
35 };
36 
37 #ifdef RTM_ADD
38 #define rtentry ortentry
39 #endif
40 
41 struct rt_entry {
42 	struct	rt_entry *rt_forw;
43 	struct	rt_entry *rt_back;
44 	union {
45 		struct	rtentry rtu_rt;
46 		struct {
47 			u_long	rtu_hash;
48 			struct	sockaddr rtu_dst;
49 			struct	sockaddr rtu_router;
50 			short	rtu_flags;
51 			short	rtu_state;
52 			int	rtu_timer;
53 			int	rtu_metric;
54 			struct	interface *rtu_ifp;
55 		} rtu_entry;
56 	} rt_rtu;
57 };
58 
59 #define	rt_rt		rt_rtu.rtu_rt			/* pass to ioctl */
60 #define	rt_hash		rt_rtu.rtu_entry.rtu_hash	/* for net or host */
61 #define	rt_dst		rt_rtu.rtu_entry.rtu_dst	/* match value */
62 #define	rt_router	rt_rtu.rtu_entry.rtu_router	/* who to forward to */
63 #define	rt_flags	rt_rtu.rtu_entry.rtu_flags	/* kernel flags */
64 #define	rt_timer	rt_rtu.rtu_entry.rtu_timer	/* for invalidation */
65 #define	rt_state	rt_rtu.rtu_entry.rtu_state	/* see below */
66 #define	rt_metric	rt_rtu.rtu_entry.rtu_metric	/* cost of route */
67 #define	rt_ifp		rt_rtu.rtu_entry.rtu_ifp	/* interface to take */
68 
69 #define	ROUTEHASHSIZ	32		/* must be a power of 2 */
70 #define	ROUTEHASHMASK	(ROUTEHASHSIZ - 1)
71 
72 /*
73  * "State" of routing table entry.
74  */
75 #define	RTS_CHANGED	0x1		/* route has been altered recently */
76 #define	RTS_PASSIVE	IFF_PASSIVE	/* don't time out route */
77 #define	RTS_INTERFACE	IFF_INTERFACE	/* route is for network interface */
78 #define	RTS_REMOTE	IFF_REMOTE	/* route is for ``remote'' entity */
79 
80 struct	rthash nethash[ROUTEHASHSIZ];
81 struct	rthash hosthash[ROUTEHASHSIZ];
82 struct	rt_entry *rtlookup();
83 struct	rt_entry *rtfind();
84