lint
[unix-history] / usr / src / sys / net / route.h
CommitLineData
6262939d 1/* route.h 4.9 83/05/12 */
6c0a063b
SL
2
3/*
a9f3e174
SL
4 * Kernel resident routing tables.
5 *
a13c006d
BJ
6 * The routing tables are initialized at boot time by
7 * making entries for all directly connected interfaces.
8 * Routing daemons can thereafter update the routing tables.
6c0a063b 9 *
a9f3e174
SL
10 * TODO:
11 * keep statistics
6c0a063b 12 */
6c0a063b 13
a13c006d
BJ
14/*
15 * A route consists of a destination address and a reference
16 * to a routing entry. These are often held by protocols
17 * in their control blocks, e.g. inpcb.
18 */
6c0a063b
SL
19struct route {
20 struct rtentry *ro_rt;
21 struct sockaddr ro_dst;
a13c006d
BJ
22#ifdef notdef
23 caddr_t ro_pcb; /* not used yet */
24#endif
6c0a063b
SL
25};
26
27/*
a13c006d
BJ
28 * We distinguish between routes to hosts and routes to networks,
29 * preferring the former if available. For each route we infer
30 * the interface to use from the gateway address supplied when
31 * the route was entered. Routes that forward packets through
32 * gateways are marked so that the output routines know to address the
33 * gateway rather than the ultimate destination.
6c0a063b 34 */
a13c006d
BJ
35struct rtentry {
36 u_long rt_hash; /* to speed lookups */
37 struct sockaddr rt_dst; /* key */
38 struct sockaddr rt_gateway; /* value */
39 short rt_flags; /* up/down?, host/net */
40 short rt_refcnt; /* # held references */
41 u_long rt_use; /* raw # packets forwarded */
42 struct ifnet *rt_ifp; /* the answer: interface to use */
43};
44#ifdef KERNEL
45#define RTHASHSIZ 7
46struct mbuf *rthost[RTHASHSIZ];
47struct mbuf *rtnet[RTHASHSIZ];
48#endif
49
ee787340 50#define RTF_UP 0x1 /* route useable */
a13c006d 51#define RTF_GATEWAY 0x2 /* destination is a gateway */
fc74f0c9 52#define RTF_HOST 0x4 /* host entry (net otherwise) */
6c0a063b 53
a9f3e174
SL
54#define RTFREE(rt) \
55 if ((rt)->rt_refcnt == 1) \
56 rtfree(rt); \
57 else \
58 (rt)->rt_refcnt--;