xref: /csrg-svn/sys/net/route.h (revision 6412)
1*6412Ssam /*	route.h	4.7	82/03/31	*/
26332Ssam 
36332Ssam /*
4*6412Ssam  * Kernel resident routing tables.
5*6412Ssam  *
6*6412Ssam  * Each interface makes an entry at boot time so that
7*6412Ssam  * correspondents directly addressible can be found.
8*6412Ssam  * User programs can update this data base from information
9*6412Ssam  * stored in the file system or information gleaned from
10*6412Ssam  * routing protocol interactions with gateways.
116332Ssam  *
12*6412Ssam  * TODO:
13*6412Ssam  *	keep statistics
14*6412Ssam  *	smooth usage figures
156332Ssam  */
166332Ssam struct rtentry {
176377Ssam 	u_long	rt_hash;		/* for net or for host */
186332Ssam 	struct	sockaddr rt_dst;	/* match value */
196332Ssam 	struct	sockaddr rt_gateway;	/* who to forward to */
206332Ssam 	short	rt_flags;		/* see below */
216332Ssam 	short	rt_refcnt;		/* # held references */
226332Ssam 	u_long	rt_use;			/* raw # packets forwarded */
236332Ssam 	struct	ifnet *rt_ifp;		/* interface to use */
246332Ssam };
256332Ssam 
266332Ssam struct route {
276332Ssam 	struct	rtentry *ro_rt;
286332Ssam 	struct	sockaddr ro_dst;
296332Ssam 	caddr_t	ro_pcb;			/* back pointer? */
306332Ssam };
316332Ssam 
326332Ssam /*
336332Ssam  * Flags and host/network status.
346332Ssam  */
356339Ssam #define	RTF_UP		0x1		/* route useable */
366357Ssam #define	RTF_DIRECT	0x2		/* destination is a neighbor */
376377Ssam #define	RTF_HOST	0x4		/* host entry (net otherwise) */
386332Ssam 
39*6412Ssam #define	RTFREE(rt) \
40*6412Ssam 	if ((rt)->rt_refcnt == 1) \
41*6412Ssam 		rtfree(rt); \
42*6412Ssam 	else \
43*6412Ssam 		(rt)->rt_refcnt--;
44*6412Ssam 
456332Ssam #ifdef KERNEL
466332Ssam /*
476332Ssam  * Lookup are hashed by a key.  Each hash bucket
486332Ssam  * consists of a linked list of mbuf's
496332Ssam  * containing routing entries.  Dead entries are
506332Ssam  * reclaimed along with mbufs.
516332Ssam  */
526377Ssam #define	RTHASHSIZ	7
536377Ssam struct	mbuf *rthost[RTHASHSIZ];
546377Ssam struct	mbuf *rtnet[RTHASHSIZ];
556332Ssam #endif
56