xref: /csrg-svn/sbin/routed/table.h (revision 61540)
122006Sdist /*
2*61540Sbostic  * Copyright (c) 1983, 1993
3*61540Sbostic  *	The Regents of the University of California.  All rights reserved.
422006Sdist  *
542712Sbostic  * %sccs.include.redist.c%
633489Sbostic  *
7*61540Sbostic  *	@(#)table.h	8.1 (Berkeley) 06/05/93
822006Sdist  */
910241Ssam 
1010241Ssam /*
1110241Ssam  * Routing table management daemon.
1210241Ssam  */
1310241Ssam 
1410241Ssam /*
1510241Ssam  * Routing table structure; differs a bit from kernel tables.
1610241Ssam  *
1710241Ssam  * Note: the union below must agree in the first 4 members
1810241Ssam  * so the ioctl's will work.
1910241Ssam  */
2010241Ssam struct rthash {
2110241Ssam 	struct	rt_entry *rt_forw;
2210241Ssam 	struct	rt_entry *rt_back;
2310241Ssam };
2438684Ssklower #ifdef RTM_ADD
2538684Ssklower #define rtentry ortentry
2638684Ssklower #endif
2710241Ssam 
2810241Ssam struct rt_entry {
2910241Ssam 	struct	rt_entry *rt_forw;
3010241Ssam 	struct	rt_entry *rt_back;
3110241Ssam 	union {
3210241Ssam 		struct	rtentry rtu_rt;
3355906Ssklower 		struct rtuentry {
3410241Ssam 			u_long	rtu_hash;
3510241Ssam 			struct	sockaddr rtu_dst;
3610241Ssam 			struct	sockaddr rtu_router;
3755906Ssklower 			short	rtu_rtflags; /* used by rtioctl */
3855906Ssklower 			short	rtu_wasted[5];
3955906Ssklower 			int	rtu_flags;
4055906Ssklower 			int	rtu_state;
4110241Ssam 			int	rtu_timer;
4210241Ssam 			int	rtu_metric;
4330745Skarels 			int	rtu_ifmetric;
4410241Ssam 			struct	interface *rtu_ifp;
4510241Ssam 		} rtu_entry;
4610241Ssam 	} rt_rtu;
4710241Ssam };
4810241Ssam 
4955906Ssklower #define	rt_rt		rt_rtu.rtu_entry		/* pass to ioctl */
5010241Ssam #define	rt_hash		rt_rtu.rtu_entry.rtu_hash	/* for net or host */
5110241Ssam #define	rt_dst		rt_rtu.rtu_entry.rtu_dst	/* match value */
5210241Ssam #define	rt_router	rt_rtu.rtu_entry.rtu_router	/* who to forward to */
5310241Ssam #define	rt_flags	rt_rtu.rtu_entry.rtu_flags	/* kernel flags */
5410241Ssam #define	rt_timer	rt_rtu.rtu_entry.rtu_timer	/* for invalidation */
5510241Ssam #define	rt_state	rt_rtu.rtu_entry.rtu_state	/* see below */
5610241Ssam #define	rt_metric	rt_rtu.rtu_entry.rtu_metric	/* cost of route */
5730745Skarels #define	rt_ifmetric	rt_rtu.rtu_entry.rtu_ifmetric	/* cost of route if */
5810241Ssam #define	rt_ifp		rt_rtu.rtu_entry.rtu_ifp	/* interface to take */
5910241Ssam 
6016435Skarels #define	ROUTEHASHSIZ	32		/* must be a power of 2 */
6116435Skarels #define	ROUTEHASHMASK	(ROUTEHASHSIZ - 1)
6210241Ssam 
6310241Ssam /*
6410241Ssam  * "State" of routing table entry.
6510241Ssam  */
6610241Ssam #define	RTS_CHANGED	0x1		/* route has been altered recently */
6727232Skarels #define	RTS_EXTERNAL	0x2		/* extern info, not installed or sent */
6827232Skarels #define	RTS_INTERNAL	0x4		/* internal route, not installed */
6916314Skarels #define	RTS_PASSIVE	IFF_PASSIVE	/* don't time out route */
7016314Skarels #define	RTS_INTERFACE	IFF_INTERFACE	/* route is for network interface */
7116314Skarels #define	RTS_REMOTE	IFF_REMOTE	/* route is for ``remote'' entity */
7227232Skarels #define	RTS_SUBNET	IFF_SUBNET	/* route is for network subnet */
7310241Ssam 
7427232Skarels /*
7527232Skarels  * Flags are same as kernel, with this addition for af_rtflags:
7627232Skarels  */
7755906Ssklower #define	RTF_SUBNET	0x80000		/* pseudo: route to subnet */
7827232Skarels 
7910241Ssam struct	rthash nethash[ROUTEHASHSIZ];
8010241Ssam struct	rthash hosthash[ROUTEHASHSIZ];
8110241Ssam struct	rt_entry *rtlookup();
8210241Ssam struct	rt_entry *rtfind();
83