lint
[unix-history] / usr / src / sys / net / route.h
CommitLineData
a13c006d 1/* route.h 4.8 82/06/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 25};
a13c006d
BJ
26#ifdef KERNEL
27/*
28 * The route ``routetoif'' is a special atom passed to the output routines
29 * to implement the SO_DONTROUTE option.
30 */
31struct route routetoif;
32#endif
6c0a063b
SL
33
34/*
a13c006d
BJ
35 * We distinguish between routes to hosts and routes to networks,
36 * preferring the former if available. For each route we infer
37 * the interface to use from the gateway address supplied when
38 * the route was entered. Routes that forward packets through
39 * gateways are marked so that the output routines know to address the
40 * gateway rather than the ultimate destination.
6c0a063b 41 */
a13c006d
BJ
42struct rtentry {
43 u_long rt_hash; /* to speed lookups */
44 struct sockaddr rt_dst; /* key */
45 struct sockaddr rt_gateway; /* value */
46 short rt_flags; /* up/down?, host/net */
47 short rt_refcnt; /* # held references */
48 u_long rt_use; /* raw # packets forwarded */
49 struct ifnet *rt_ifp; /* the answer: interface to use */
50};
51#ifdef KERNEL
52#define RTHASHSIZ 7
53struct mbuf *rthost[RTHASHSIZ];
54struct mbuf *rtnet[RTHASHSIZ];
55#endif
56
ee787340 57#define RTF_UP 0x1 /* route useable */
a13c006d 58#define RTF_GATEWAY 0x2 /* destination is a gateway */
fc74f0c9 59#define RTF_HOST 0x4 /* host entry (net otherwise) */
6c0a063b 60
a9f3e174
SL
61#define RTFREE(rt) \
62 if ((rt)->rt_refcnt == 1) \
63 rtfree(rt); \
64 else \
65 (rt)->rt_refcnt--;