Commit | Line | Data |
---|---|---|
a9ea8834 | 1 | /* route.h 4.10 83/05/30 */ |
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. | |
6c0a063b | 8 | */ |
6c0a063b | 9 | |
a13c006d BJ |
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 | */ | |
6c0a063b SL |
15 | struct route { |
16 | struct rtentry *ro_rt; | |
17 | struct sockaddr ro_dst; | |
a13c006d BJ |
18 | #ifdef notdef |
19 | caddr_t ro_pcb; /* not used yet */ | |
20 | #endif | |
6c0a063b SL |
21 | }; |
22 | ||
23 | /* | |
a13c006d BJ |
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. | |
6c0a063b | 30 | */ |
a13c006d BJ |
31 | struct 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 | }; | |
a13c006d | 40 | |
ee787340 | 41 | #define RTF_UP 0x1 /* route useable */ |
a13c006d | 42 | #define RTF_GATEWAY 0x2 /* destination is a gateway */ |
fc74f0c9 | 43 | #define RTF_HOST 0x4 /* host entry (net otherwise) */ |
6c0a063b | 44 | |
a9ea8834 SL |
45 | /* |
46 | * Routing statistics. | |
47 | */ | |
48 | struct 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 | |
a9f3e174 SL |
57 | #define RTFREE(rt) \ |
58 | if ((rt)->rt_refcnt == 1) \ | |
59 | rtfree(rt); \ | |
60 | else \ | |
61 | (rt)->rt_refcnt--; | |
a9ea8834 SL |
62 | |
63 | #define RTHASHSIZ 7 | |
64 | struct mbuf *rthost[RTHASHSIZ]; | |
65 | struct mbuf *rtnet[RTHASHSIZ]; | |
66 | struct rtstat rtstat; | |
67 | #endif |