get rid of unneeded header files
[unix-history] / usr / src / sys / net / route.h
CommitLineData
cb1c44c2 1/*
1810611d 2 * Copyright (c) 1980, 1986 Regents of the University of California.
5b519e94 3 * All rights reserved.
cb1c44c2 4 *
5b519e94 5 * Redistribution and use in source and binary forms are permitted
50c7758a
KB
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
5b519e94 16 *
573d82c4 17 * @(#)route.h 7.4 (Berkeley) 6/27/88
cb1c44c2 18 */
6c0a063b
SL
19
20/*
a9f3e174
SL
21 * Kernel resident routing tables.
22 *
a839f328
MK
23 * The routing tables are initialized when interface addresses
24 * are set by making entries for all directly connected interfaces.
6c0a063b 25 */
6c0a063b 26
a13c006d
BJ
27/*
28 * A route consists of a destination address and a reference
29 * to a routing entry. These are often held by protocols
30 * in their control blocks, e.g. inpcb.
31 */
6c0a063b
SL
32struct route {
33 struct rtentry *ro_rt;
34 struct sockaddr ro_dst;
6c0a063b
SL
35};
36
37/*
a13c006d
BJ
38 * We distinguish between routes to hosts and routes to networks,
39 * preferring the former if available. For each route we infer
40 * the interface to use from the gateway address supplied when
41 * the route was entered. Routes that forward packets through
42 * gateways are marked so that the output routines know to address the
43 * gateway rather than the ultimate destination.
6c0a063b 44 */
573d82c4 45#include "radix.h"
a13c006d 46struct rtentry {
573d82c4
KS
47 struct radix_node rt_nodes[2]; /* tree glue, and other values */
48#define rt_key(r) ((struct sockaddr *)((r)->rt_nodes->rn_key))
49#define rt_mask(r) ((struct sockaddr *)((r)->rt_nodes->rn_mask))
50 struct sockaddr *rt_gateway; /* value */
51 short rt_flags; /* up/down?, host/net */
52 short rt_refcnt; /* # held references */
53 u_long rt_use; /* raw # packets forwarded */
54 struct ifnet *rt_ifp; /* the answer: interface to use */
b72a6efb 55 struct ifaddr *rt_ifa; /* the answer: interface to use */
573d82c4
KS
56};
57
58/*
59 * Following structure necessary for 4.3 compatibility;
60 * We should eventually move it to a compat file.
61 */
62struct ortentry {
a13c006d
BJ
63 u_long rt_hash; /* to speed lookups */
64 struct sockaddr rt_dst; /* key */
65 struct sockaddr rt_gateway; /* value */
66 short rt_flags; /* up/down?, host/net */
67 short rt_refcnt; /* # held references */
68 u_long rt_use; /* raw # packets forwarded */
69 struct ifnet *rt_ifp; /* the answer: interface to use */
70};
a13c006d 71
ee787340 72#define RTF_UP 0x1 /* route useable */
a13c006d 73#define RTF_GATEWAY 0x2 /* destination is a gateway */
fc74f0c9 74#define RTF_HOST 0x4 /* host entry (net otherwise) */
a839f328 75#define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */
31150b52 76#define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */
573d82c4
KS
77#define RTF_DONE 0x40 /* message confirmed */
78#define RTF_MASK 0x80 /* subnet mask present */
79
6c0a063b 80
a9ea8834
SL
81/*
82 * Routing statistics.
83 */
84struct rtstat {
85 short rts_badredirect; /* bogus redirect calls */
86 short rts_dynamic; /* routes created by redirects */
87 short rts_newgateway; /* routes modified by redirects */
88 short rts_unreach; /* lookups which failed */
89 short rts_wildcard; /* lookups satisfied by a wildcard */
90};
573d82c4
KS
91/*
92 * Structures for routing messages.
93 */
94struct rt_metrics {
95 u_long rtm_mtu; /* MTU for this path */
96 u_long rtm_hopcount; /* max hops expected */
97 u_long rtm_expire; /* lifetime for route, e.g. redirect */
98 u_long rtm_recvpipe; /* inbound delay-bandwith product */
99 u_long rtm_sendpipe; /* outbound delay-bandwith product */
100 u_long rtm_ssthresh; /* outbound gateway buffer limit */
101 u_long rtm_rtt; /* estimated round trip time */
102 u_long rtm_rttvar; /* estimated rtt variance */
103};
104
105struct rt_msghdr {
106 u_short rtm_msglen; /* to skip over non-understood messages */
107 u_char rtm_version; /* future binary compatability */
108 u_char rtm_type; /* message type */
109 u_char rtm_count; /* number of sockaddrs */
110 pid_t rtm_pid; /* identify sender */
111 int rtm_seq; /* for sender to identify action */
112 int rtm_errno; /* why failed */
113 int rtm_flags; /* flags, incl. kern & message, e.g. DONE */
114 int rtm_locks; /* which values kernel can alter */
115 int rtm_inits; /* which values we are initializing */
116};
117
118struct rt_chgmsg { /* Good for RTM_ADD, RTM_CHANGE, RTM_GET */
119 struct rt_msghdr cm_h;
120 struct rt_metrics cm_m;
121};
122
123struct route_cb {
124 int ip_count;
125 int ns_count;
126 int iso_count;
127 int any_count;
128};
129
130#define RTM_ADD 0x1 /* Add Route */
131#define RTM_DELETE 0x2 /* Delete Route */
132#define RTM_CHANGE 0x3 /* Change Metrics or flags */
133#define RTM_GET 0x4 /* Report Metrics */
134#define RTM_LOSING 0x5 /* Kernel Suspects Partitioning */
135#define RTM_REDIRECT 0x6 /* Told to use different route */
136#define RTM_MISS 0x7 /* Lookup failed on this address */
137#define RTM_LOCK 0x8 /* fix specified metrics */
138#define RTM_OLDADD 0x9 /* caused by SIOCADDRT */
139#define RTM_OLDDEL 0xa /* caused by SIOCDELRT */
140
141#define RTV_MTU 0x1 /* init or lock _mtu */
142#define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */
143#define RTV_EXPIRE 0x4 /* init or lock _hopcount */
144#define RTV_RPIPE 0x8 /* init or lock _recvpipe */
145#define RTV_SPIPE 0x10 /* init or lock _sendpipe */
146#define RTV_SSTHRESH 0x20 /* init or lock _ssthresh */
147#define RTV_RTT 0x40 /* init or lock _rtt */
148#define RTV_RTTVAR 0x80 /* init or lock _rttvar */
149
150#ifdef KERNEL
151struct route_cb route_cb;
152#endif
a9ea8834
SL
153
154#ifdef KERNEL
a9f3e174
SL
155#define RTFREE(rt) \
156 if ((rt)->rt_refcnt == 1) \
157 rtfree(rt); \
158 else \
159 (rt)->rt_refcnt--;
a9ea8834 160
b4ad5b30
MK
161#ifdef GATEWAY
162#define RTHASHSIZ 64
163#else
0ab3c88a 164#define RTHASHSIZ 8
b4ad5b30 165#endif
0ab3c88a
MK
166#if (RTHASHSIZ & (RTHASHSIZ - 1)) == 0
167#define RTHASHMOD(h) ((h) & (RTHASHSIZ - 1))
168#else
169#define RTHASHMOD(h) ((h) % RTHASHSIZ)
170#endif
a9ea8834
SL
171struct mbuf *rthost[RTHASHSIZ];
172struct mbuf *rtnet[RTHASHSIZ];
173struct rtstat rtstat;
573d82c4 174struct rtentry *rtalloc1();
a9ea8834 175#endif