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