1: /*
2: * Copyright (c) 1980, 1986 Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms are permitted
6: * provided that this notice is preserved and that due credit is given
7: * to the University of California at Berkeley. The name of the University
8: * may not be used to endorse or promote products derived from this
9: * software without specific prior written permission. This software
10: * is provided ``as is'' without express or implied warranty.
11: *
12: * @(#)route.h 7.3 (Berkeley) 12/30/87
13: */
14:
15: /*
16: * Kernel resident routing tables.
17: *
18: * The routing tables are initialized when interface addresses
19: * are set by making entries for all directly connected interfaces.
20: */
21:
22: /*
23: * A route consists of a destination address and a reference
24: * to a routing entry. These are often held by protocols
25: * in their control blocks, e.g. inpcb.
26: */
27: struct route {
28: struct rtentry *ro_rt;
29: struct sockaddr ro_dst;
30: };
31:
32: /*
33: * We distinguish between routes to hosts and routes to networks,
34: * preferring the former if available. For each route we infer
35: * the interface to use from the gateway address supplied when
36: * the route was entered. Routes that forward packets through
37: * gateways are marked so that the output routines know to address the
38: * gateway rather than the ultimate destination.
39: */
40: struct rtentry {
41: u_int rt_hash; /* to speed lookups */
42: struct sockaddr rt_dst; /* key */
43: struct sockaddr rt_gateway; /* value */
44: short rt_flags; /* up/down?, host/net */
45: short rt_refcnt; /* # held references */
46: u_long rt_use; /* raw # packets forwarded */
47: struct ifnet *rt_ifp; /* the answer: interface to use */
48: };
49:
50: #define RTF_UP 0x1 /* route useable */
51: #define RTF_GATEWAY 0x2 /* destination is a gateway */
52: #define RTF_HOST 0x4 /* host entry (net otherwise) */
53: #define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */
54: #define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */
55:
56: /*
57: * Routing statistics.
58: */
59: struct rtstat {
60: short rts_badredirect; /* bogus redirect calls */
61: short rts_dynamic; /* routes created by redirects */
62: short rts_newgateway; /* routes modified by redirects */
63: short rts_unreach; /* lookups which failed */
64: short rts_wildcard; /* lookups satisfied by a wildcard */
65: };
66:
67: #ifdef SUPERVISOR
68: #define RTFREE(rt) \
69: if ((rt)->rt_refcnt == 1) \
70: rtfree(rt); \
71: else \
72: (rt)->rt_refcnt--;
73:
74: #ifdef GATEWAY
75: #define RTHASHSIZ 64
76: #else
77: #define RTHASHSIZ 8
78: #endif
79: #if (RTHASHSIZ & (RTHASHSIZ - 1)) == 0
80: #define RTHASHMOD(h) ((h) & (RTHASHSIZ - 1))
81: #else
82: #define RTHASHMOD(h) ((h) % RTHASHSIZ)
83: #endif
84: struct mbuf *rthost[RTHASHSIZ];
85: struct mbuf *rtnet[RTHASHSIZ];
86: struct rtstat rtstat;
87: #endif
Defined variables
rtnet
defined in line
85; used 2 times
rtstat
defined in line
86; used 34 times
Defined struct's
route
defined in line
27; used 50 times
- in /usr/src/sys/net/route.c line
36(2),
121(2)
- in /usr/src/sys/netinet/in_pcb.c line
145(2)
- in /usr/src/sys/netinet/ip_icmp.c line
438(2)
- in /usr/src/sys/netinet/ip_input.c line
87(2)
- in /usr/src/sys/netinet/ip_output.c line
49(2),
57(2)
- in /usr/src/sys/netinet/tcp_input.c line
1258(2)
- in /usr/src/sys/netinet/tcp_subr.c line
113(2)
- in /usr/src/sys/netns/idp_usrreq.c line
125(2),
198(2)
- in /usr/src/sys/netns/ns_error.c line
140(2),
300(2)
- in /usr/src/sys/netns/ns_input.c line
287-288(4),
410(2),
430(2)
- in /usr/src/sys/netns/ns_ip.c line
49(2),
227(2),
293(2),
368(2)
- in /usr/src/sys/netns/ns_output.c line
40(2),
46(2)
- in /usr/src/sys/netns/ns_pcb.c line
114(2)
- in /usr/src/sys/netns/spp_usrreq.c line
1016(2)
rtentry
defined in line
40; used 75 times
- in line 28
- in /usr/src/new/crash/dispnet.c line
526(2)
- in /usr/src/new/crash/route.c line
48(2),
55-56(4),
78-80(6),
101(2),
107-109(4),
123(2),
190(2)
- in /usr/src/sbin/route/route.c line
31(2),
105(2),
171(2)
- in /usr/src/sbin/routed/tables.c line
173(2)
- in /usr/src/sys/net/route.c line
38(2),
57(2),
96(2),
122(2),
203(2),
213-217(4),
239(2),
310-311(4),
335(2)
- in /usr/src/sys/netinet/in_pcb.c line
159-162(4),
337(2)
- in /usr/src/sys/netinet/ip_output.c line
92(2)
- in /usr/src/sys/netinet/tcp_input.c line
1265(2)
- in /usr/src/sys/netns/idp_usrreq.c line
237(2)
- in /usr/src/sys/netns/ns_pcb.c line
131-135(4)
- in /usr/src/ucb/netstat/route.c line
63(2),
103(2)
Defined macros
RTFREE
defined in line
68; used 13 times
RTF_HOST
defined in line
52; used 30 times
- in /usr/src/new/crash/route.c line
37,
136
- in /usr/src/sbin/route/route.c line
393
- in /usr/src/sbin/routed/inet.c line
136,
145
- in /usr/src/sbin/routed/startup.c line
259
- in /usr/src/sbin/routed/tables.c line
127
- in /usr/src/sbin/routed/trace.c line
127
- in /usr/src/sys/net/route.c line
160,
169(2),
229,
242,
283,
316
- in /usr/src/sys/netinet/in.c line
299-301(2),
362-365(2),
399-402(2)
- in /usr/src/sys/netinet/ip_icmp.c line
322
- in /usr/src/sys/netinet/ip_input.c line
935
- in /usr/src/sys/netns/idp_usrreq.c line
220
- in /usr/src/sys/netns/ns.c line
145,
210,
257
- in /usr/src/sys/netns/ns_output.c line
96
- in /usr/src/ucb/netstat/route.c line
50,
115
RTF_UP
defined in line
50; used 20 times
Usage of this include