xref: /csrg-svn/sys/net/route.h (revision 12832)
1*12832Ssam /*	route.h	4.10	83/05/30	*/
26332Ssam 
36332Ssam /*
46412Ssam  * Kernel resident routing tables.
56412Ssam  *
67156Swnj  * The routing tables are initialized at boot time by
77156Swnj  * making entries for all directly connected interfaces.
86332Ssam  */
96332Ssam 
107156Swnj /*
117156Swnj  * A route consists of a destination address and a reference
127156Swnj  * to a routing entry.  These are often held by protocols
137156Swnj  * in their control blocks, e.g. inpcb.
147156Swnj  */
156332Ssam struct route {
166332Ssam 	struct	rtentry *ro_rt;
176332Ssam 	struct	sockaddr ro_dst;
187156Swnj #ifdef notdef
197156Swnj 	caddr_t	ro_pcb;			/* not used yet */
207156Swnj #endif
216332Ssam };
226332Ssam 
236332Ssam /*
247156Swnj  * We distinguish between routes to hosts and routes to networks,
257156Swnj  * preferring the former if available.  For each route we infer
267156Swnj  * the interface to use from the gateway address supplied when
277156Swnj  * the route was entered.  Routes that forward packets through
287156Swnj  * gateways are marked so that the output routines know to address the
297156Swnj  * gateway rather than the ultimate destination.
306332Ssam  */
317156Swnj struct rtentry {
327156Swnj 	u_long	rt_hash;		/* to speed lookups */
337156Swnj 	struct	sockaddr rt_dst;	/* key */
347156Swnj 	struct	sockaddr rt_gateway;	/* value */
357156Swnj 	short	rt_flags;		/* up/down?, host/net */
367156Swnj 	short	rt_refcnt;		/* # held references */
377156Swnj 	u_long	rt_use;			/* raw # packets forwarded */
387156Swnj 	struct	ifnet *rt_ifp;		/* the answer: interface to use */
397156Swnj };
407156Swnj 
416339Ssam #define	RTF_UP		0x1		/* route useable */
427156Swnj #define	RTF_GATEWAY	0x2		/* destination is a gateway */
436377Ssam #define	RTF_HOST	0x4		/* host entry (net otherwise) */
446332Ssam 
45*12832Ssam /*
46*12832Ssam  * Routing statistics.
47*12832Ssam  */
48*12832Ssam struct	rtstat {
49*12832Ssam 	short	rts_badredirect;	/* bogus redirect calls */
50*12832Ssam 	short	rts_dynamic;		/* routes created by redirects */
51*12832Ssam 	short	rts_newgateway;		/* routes modified by redirects */
52*12832Ssam 	short	rts_unreach;		/* lookups which failed */
53*12832Ssam 	short	rts_wildcard;		/* lookups satisfied by a wildcard */
54*12832Ssam };
55*12832Ssam 
56*12832Ssam #ifdef KERNEL
576412Ssam #define	RTFREE(rt) \
586412Ssam 	if ((rt)->rt_refcnt == 1) \
596412Ssam 		rtfree(rt); \
606412Ssam 	else \
616412Ssam 		(rt)->rt_refcnt--;
62*12832Ssam 
63*12832Ssam #define	RTHASHSIZ	7
64*12832Ssam struct	mbuf *rthost[RTHASHSIZ];
65*12832Ssam struct	mbuf *rtnet[RTHASHSIZ];
66*12832Ssam struct	rtstat	rtstat;
67*12832Ssam #endif
68