xref: /csrg-svn/sbin/XNSrouted/table.h (revision 38688)
135592Sbostic /*
235592Sbostic  * Copyright (c) 1983 The Regents of the University of California.
335592Sbostic  * All rights reserved.
435592Sbostic  *
535592Sbostic  * Redistribution and use in source and binary forms are permitted
635592Sbostic  * provided that the above copyright notice and this paragraph are
735592Sbostic  * duplicated in all such forms and that any documentation,
835592Sbostic  * advertising materials, and other materials related to such
935592Sbostic  * distribution and use acknowledge that the software was developed
1035592Sbostic  * by the University of California, Berkeley.  The name of the
1135592Sbostic  * University may not be used to endorse or promote products derived
1235592Sbostic  * from this software without specific prior written permission.
1335592Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1435592Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1535592Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1635592Sbostic  *
1735592Sbostic  *	@(#)table.h	5.1 (Berkeley) 6/4/85 (routed/table.h)
1835592Sbostic  *
19*38688Skarels  *	@(#)table.h	5.2 (Berkeley) 08/21/89
2035592Sbostic  */
2135592Sbostic 
2235592Sbostic /*
2335592Sbostic  * Routing table management daemon.
2435592Sbostic  */
2535592Sbostic 
2635592Sbostic /*
2735592Sbostic  * Routing table structure; differs a bit from kernel tables.
2835592Sbostic  *
2935592Sbostic  * Note: the union below must agree in the first 4 members
3035592Sbostic  * so the ioctl's will work.
3135592Sbostic  */
3235592Sbostic struct rthash {
3335592Sbostic 	struct	rt_entry *rt_forw;
3435592Sbostic 	struct	rt_entry *rt_back;
3535592Sbostic };
3635592Sbostic 
37*38688Skarels #ifdef RTM_ADD
38*38688Skarels #define rtentry ortentry
39*38688Skarels #endif
40*38688Skarels 
4135592Sbostic struct rt_entry {
4235592Sbostic 	struct	rt_entry *rt_forw;
4335592Sbostic 	struct	rt_entry *rt_back;
4435592Sbostic 	union {
4535592Sbostic 		struct	rtentry rtu_rt;
4635592Sbostic 		struct {
4735592Sbostic 			u_long	rtu_hash;
4835592Sbostic 			struct	sockaddr rtu_dst;
4935592Sbostic 			struct	sockaddr rtu_router;
5035592Sbostic 			short	rtu_flags;
5135592Sbostic 			short	rtu_state;
5235592Sbostic 			int	rtu_timer;
5335592Sbostic 			int	rtu_metric;
5435592Sbostic 			struct	interface *rtu_ifp;
5535592Sbostic 		} rtu_entry;
5635592Sbostic 	} rt_rtu;
5735592Sbostic };
5835592Sbostic 
5935592Sbostic #define	rt_rt		rt_rtu.rtu_rt			/* pass to ioctl */
6035592Sbostic #define	rt_hash		rt_rtu.rtu_entry.rtu_hash	/* for net or host */
6135592Sbostic #define	rt_dst		rt_rtu.rtu_entry.rtu_dst	/* match value */
6235592Sbostic #define	rt_router	rt_rtu.rtu_entry.rtu_router	/* who to forward to */
6335592Sbostic #define	rt_flags	rt_rtu.rtu_entry.rtu_flags	/* kernel flags */
6435592Sbostic #define	rt_timer	rt_rtu.rtu_entry.rtu_timer	/* for invalidation */
6535592Sbostic #define	rt_state	rt_rtu.rtu_entry.rtu_state	/* see below */
6635592Sbostic #define	rt_metric	rt_rtu.rtu_entry.rtu_metric	/* cost of route */
6735592Sbostic #define	rt_ifp		rt_rtu.rtu_entry.rtu_ifp	/* interface to take */
6835592Sbostic 
6935592Sbostic #define	ROUTEHASHSIZ	32		/* must be a power of 2 */
7035592Sbostic #define	ROUTEHASHMASK	(ROUTEHASHSIZ - 1)
7135592Sbostic 
7235592Sbostic /*
7335592Sbostic  * "State" of routing table entry.
7435592Sbostic  */
7535592Sbostic #define	RTS_CHANGED	0x1		/* route has been altered recently */
7635592Sbostic #define	RTS_PASSIVE	IFF_PASSIVE	/* don't time out route */
7735592Sbostic #define	RTS_INTERFACE	IFF_INTERFACE	/* route is for network interface */
7835592Sbostic #define	RTS_REMOTE	IFF_REMOTE	/* route is for ``remote'' entity */
7935592Sbostic 
8035592Sbostic struct	rthash nethash[ROUTEHASHSIZ];
8135592Sbostic struct	rthash hosthash[ROUTEHASHSIZ];
8235592Sbostic struct	rt_entry *rtlookup();
8335592Sbostic struct	rt_entry *rtfind();
84