]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/Include/net/route.h
Fix GCC build errors.
[mirror_edk2.git] / StdLib / Include / net / route.h
CommitLineData
d7ce7006 1/*\r
2 * Copyright (c) 1980, 1986, 1993\r
3 * The Regents of the University of California. All rights reserved.\r
4 *\r
5 * Redistribution and use in source and binary forms, with or without\r
6 * modification, are permitted provided that the following conditions\r
7 * are met:\r
8 * 1. Redistributions of source code must retain the above copyright\r
9 * notice, this list of conditions and the following disclaimer.\r
10 * 2. Redistributions in binary form must reproduce the above copyright\r
11 * notice, this list of conditions and the following disclaimer in the\r
12 * documentation and/or other materials provided with the distribution.\r
13 * 3. All advertising materials mentioning features or use of this software\r
14 * must display the following acknowledgement:\r
15 * This product includes software developed by the University of\r
16 * California, Berkeley and its contributors.\r
17 * 4. Neither the name of the University nor the names of its contributors\r
18 * may be used to endorse or promote products derived from this software\r
19 * without specific prior written permission.\r
20 *\r
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
31 * SUCH DAMAGE.\r
32 *\r
33 * @(#)route.h 8.3 (Berkeley) 4/19/94\r
34 * $Id: route.h,v 1.1.1.1 2006/05/30 06:12:46 hhzhou Exp $\r
35 */\r
36\r
37#ifndef _NET_ROUTE_H_\r
38#define _NET_ROUTE_H_\r
39\r
40#define __P(protos) protos /* full-blown ANSI C */\r
41\r
42\r
43/*\r
44 * Kernel resident routing tables.\r
45 *\r
46 * The routing tables are initialized when interface addresses\r
47 * are set by making entries for all directly connected interfaces.\r
48 */\r
49\r
50/*\r
51 * A route consists of a destination address and a reference\r
52 * to a routing entry. These are often held by protocols\r
53 * in their control blocks, e.g. inpcb.\r
54 */\r
55struct route {\r
56 struct rtentry *ro_rt;\r
57 struct sockaddr ro_dst;\r
58};\r
59\r
60/*\r
61 * These numbers are used by reliable protocols for determining\r
62 * retransmission behavior and are included in the routing structure.\r
63 */\r
64struct rt_metrics {\r
65 u_long rmx_locks; /* Kernel must leave these values alone */\r
66 u_long rmx_mtu; /* MTU for this path */\r
67 u_long rmx_hopcount; /* max hops expected */\r
68 u_long rmx_expire; /* lifetime for route, e.g. redirect */\r
69 u_long rmx_recvpipe; /* inbound delay-bandwidth product */\r
70 u_long rmx_sendpipe; /* outbound delay-bandwidth product */\r
71 u_long rmx_ssthresh; /* outbound gateway buffer limit */\r
72 u_long rmx_rtt; /* estimated round trip time */\r
73 u_long rmx_rttvar; /* estimated rtt variance */\r
74 u_long rmx_pksent; /* packets sent using this route */\r
75 u_long rmx_filler[4]; /* will be used for T/TCP later */\r
76};\r
77\r
78/*\r
79 * rmx_rtt and rmx_rttvar are stored as microseconds;\r
80 * RTTTOPRHZ(rtt) converts to a value suitable for use\r
81 * by a protocol slowtimo counter.\r
82 */\r
83#define RTM_RTTUNIT 1000000 /* units for rtt, rttvar, as units per sec */\r
84#define RTTTOPRHZ(r) ((r) / (RTM_RTTUNIT / PR_SLOWHZ))\r
85\r
86/*\r
87 * XXX kernel function pointer `rt_output' is visible to applications.\r
88 */\r
89struct mbuf;\r
90\r
91/*\r
92 * We distinguish between routes to hosts and routes to networks,\r
93 * preferring the former if available. For each route we infer\r
94 * the interface to use from the gateway address supplied when\r
95 * the route was entered. Routes that forward packets through\r
96 * gateways are marked so that the output routines know to address the\r
97 * gateway rather than the ultimate destination.\r
98 */\r
99#ifndef RNF_NORMAL\r
100#include <net/radix.h>\r
101#endif\r
102struct rtentry {\r
103 struct radix_node rt_nodes[2]; /* tree glue, and other values */\r
104#define rt_key(r) ((struct sockaddr *)((r)->rt_nodes->rn_key))\r
105#define rt_mask(r) ((struct sockaddr *)((r)->rt_nodes->rn_mask))\r
106 struct sockaddr *rt_gateway; /* value */\r
107 short rt_filler; /* was short flags field */\r
108 short rt_refcnt; /* # held references */\r
109 u_long rt_flags; /* up/down?, host/net */\r
110 struct ifnet *rt_ifp; /* the answer: interface to use */\r
111 struct ifaddr *rt_ifa; /* the answer: interface to use */\r
112 struct sockaddr *rt_genmask; /* for generation of cloned routes */\r
113 caddr_t rt_llinfo; /* pointer to link level info cache */\r
114 struct rt_metrics rt_rmx; /* metrics used by rx'ing protocols */\r
115 struct rtentry *rt_gwroute; /* implied entry for gatewayed routes */\r
116 int (*rt_output) __P((struct ifnet *, struct mbuf *,\r
117 struct sockaddr *, struct rtentry *));\r
118 /* output routine for this (rt,if) */\r
119 struct rtentry *rt_parent; /* cloning parent of this route */\r
120 void *rt_filler2; /* more filler */\r
121};\r
122\r
123/*\r
124 * Following structure necessary for 4.3 compatibility;\r
125 * We should eventually move it to a compat file.\r
126 */\r
127struct ortentry {\r
128 u_long rt_hash; /* to speed lookups */\r
129 struct sockaddr rt_dst; /* key */\r
130 struct sockaddr rt_gateway; /* value */\r
131 short rt_flags; /* up/down?, host/net */\r
132 short rt_refcnt; /* # held references */\r
133 u_long rt_use; /* raw # packets forwarded */\r
134 struct ifnet *rt_ifp; /* the answer: interface to use */\r
135};\r
136\r
137#define rt_use rt_rmx.rmx_pksent\r
138\r
139#define RTF_UP 0x1 /* route usable */\r
140#define RTF_GATEWAY 0x2 /* destination is a gateway */\r
141#define RTF_HOST 0x4 /* host entry (net otherwise) */\r
142#define RTF_REJECT 0x8 /* host or net unreachable */\r
143#define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */\r
144#define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */\r
145#define RTF_DONE 0x40 /* message confirmed */\r
146/* 0x80 unused */\r
147#define RTF_CLONING 0x100 /* generate new routes on use */\r
148#define RTF_XRESOLVE 0x200 /* external daemon resolves name */\r
149#define RTF_LLINFO 0x400 /* generated by link layer (e.g. ARP) */\r
150#define RTF_STATIC 0x800 /* manually added */\r
151#define RTF_BLACKHOLE 0x1000 /* just discard pkts (during updates) */\r
152#define RTF_PROTO2 0x4000 /* protocol specific routing flag */\r
153#define RTF_PROTO1 0x8000 /* protocol specific routing flag */\r
154\r
155#define RTF_PRCLONING 0x10000 /* protocol requires cloning */\r
156#define RTF_WASCLONED 0x20000 /* route generated through cloning */\r
157#define RTF_PROTO3 0x40000 /* protocol specific routing flag */\r
158/* 0x80000 unused */\r
159#define RTF_PINNED 0x100000 /* future use */\r
160#define RTF_LOCAL 0x200000 /* route represents a local address */\r
161#define RTF_BROADCAST 0x400000 /* route represents a bcast address */\r
162#define RTF_MULTICAST 0x800000 /* route represents a mcast address */\r
163 /* 0x1000000 and up unassigned */\r
164\r
165/*\r
166 * Routing statistics.\r
167 */\r
168struct rtstat {\r
169 short rts_badredirect; /* bogus redirect calls */\r
170 short rts_dynamic; /* routes created by redirects */\r
171 short rts_newgateway; /* routes modified by redirects */\r
172 short rts_unreach; /* lookups which failed */\r
173 short rts_wildcard; /* lookups satisfied by a wildcard */\r
174};\r
175/*\r
176 * Structures for routing messages.\r
177 */\r
178struct rt_msghdr {\r
179 u_short rtm_msglen; /* to skip over non-understood messages */\r
180 u_char rtm_version; /* future binary compatibility */\r
181 u_char rtm_type; /* message type */\r
182 u_short rtm_index; /* index for associated ifp */\r
183 int rtm_flags; /* flags, incl. kern & message, e.g. DONE */\r
184 int rtm_addrs; /* bitmask identifying sockaddrs in msg */\r
185 pid_t rtm_pid; /* identify sender */\r
186 int rtm_seq; /* for sender to identify action */\r
187 int rtm_errno; /* why failed */\r
188 int rtm_use; /* from rtentry */\r
189 u_long rtm_inits; /* which metrics we are initializing */\r
190 struct rt_metrics rtm_rmx; /* metrics themselves */\r
191};\r
192\r
193#define RTM_VERSION 5 /* Up the ante and ignore older versions */\r
194\r
195#define RTM_ADD 0x1 /* Add Route */\r
196#define RTM_DELETE 0x2 /* Delete Route */\r
197#define RTM_CHANGE 0x3 /* Change Metrics or flags */\r
198#define RTM_GET 0x4 /* Report Metrics */\r
199#define RTM_LOSING 0x5 /* Kernel Suspects Partitioning */\r
200#define RTM_REDIRECT 0x6 /* Told to use different route */\r
201#define RTM_MISS 0x7 /* Lookup failed on this address */\r
202#define RTM_LOCK 0x8 /* fix specified metrics */\r
203#define RTM_OLDADD 0x9 /* caused by SIOCADDRT */\r
204#define RTM_OLDDEL 0xa /* caused by SIOCDELRT */\r
205#define RTM_RESOLVE 0xb /* req to resolve dst to LL addr */\r
206#define RTM_NEWADDR 0xc /* address being added to iface */\r
207#define RTM_DELADDR 0xd /* address being removed from iface */\r
208#define RTM_IFINFO 0xe /* iface going up/down etc. */\r
209#define RTM_NEWMADDR 0xf /* mcast group membership being added to if */\r
210#define RTM_DELMADDR 0x10 /* mcast group membership being deleted */\r
211\r
212#define RTV_MTU 0x1 /* init or lock _mtu */\r
213#define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */\r
214#define RTV_EXPIRE 0x4 /* init or lock _hopcount */\r
215#define RTV_RPIPE 0x8 /* init or lock _recvpipe */\r
216#define RTV_SPIPE 0x10 /* init or lock _sendpipe */\r
217#define RTV_SSTHRESH 0x20 /* init or lock _ssthresh */\r
218#define RTV_RTT 0x40 /* init or lock _rtt */\r
219#define RTV_RTTVAR 0x80 /* init or lock _rttvar */\r
220\r
221/*\r
222 * Bitmask values for rtm_addr.\r
223 */\r
224#define RTA_DST 0x1 /* destination sockaddr present */\r
225#define RTA_GATEWAY 0x2 /* gateway sockaddr present */\r
226#define RTA_NETMASK 0x4 /* netmask sockaddr present */\r
227#define RTA_GENMASK 0x8 /* cloning mask sockaddr present */\r
228#define RTA_IFP 0x10 /* interface name sockaddr present */\r
229#define RTA_IFA 0x20 /* interface addr sockaddr present */\r
230#define RTA_AUTHOR 0x40 /* sockaddr for author of redirect */\r
231#define RTA_BRD 0x80 /* for NEWADDR, broadcast or p-p dest addr */\r
232\r
233/*\r
234 * Index offsets for sockaddr array for alternate internal encoding.\r
235 */\r
236#define RTAX_DST 0 /* destination sockaddr present */\r
237#define RTAX_GATEWAY 1 /* gateway sockaddr present */\r
238#define RTAX_NETMASK 2 /* netmask sockaddr present */\r
239#define RTAX_GENMASK 3 /* cloning mask sockaddr present */\r
240#define RTAX_IFP 4 /* interface name sockaddr present */\r
241#define RTAX_IFA 5 /* interface addr sockaddr present */\r
242#define RTAX_AUTHOR 6 /* sockaddr for author of redirect */\r
243#define RTAX_BRD 7 /* for NEWADDR, broadcast or p-p dest addr */\r
244#define RTAX_MAX 8 /* size of array to allocate */\r
245\r
246struct rt_addrinfo {\r
247 int rti_addrs;\r
248 struct sockaddr *rti_info[RTAX_MAX];\r
249};\r
250\r
251struct route_cb {\r
252 int ip_count;\r
253 int ipx_count;\r
254 int ns_count;\r
255 int iso_count;\r
256 int any_count;\r
257};\r
258\r
259#ifdef KERNEL\r
260#define RTFREE(rt) \\r
261 if ((rt)->rt_refcnt <= 1) \\r
262 rtfree(rt); \\r
263 else \\r
264 (rt)->rt_refcnt--;\r
265\r
266extern struct route_cb route_cb;\r
267extern struct radix_node_head *rt_tables[AF_MAX+1];\r
268\r
269struct ifmultiaddr;\r
270struct proc;\r
271\r
272void route_init __P((void));\r
273void rt_ifmsg __P((struct ifnet *));\r
274void rt_missmsg __P((int, struct rt_addrinfo *, int, int));\r
275void rt_newaddrmsg __P((int, struct ifaddr *, int, struct rtentry *));\r
276void rt_newmaddrmsg __P((int, struct ifmultiaddr *));\r
277int rt_setgate __P((struct rtentry *,\r
278 struct sockaddr *, struct sockaddr *));\r
279void rtalloc __P((struct route *));\r
280void rtalloc_ign __P((struct route *, unsigned long));\r
281struct rtentry *\r
282 rtalloc1 __P((struct sockaddr *, int, unsigned long));\r
283void rtfree __P((struct rtentry *));\r
284int rtinit __P((struct ifaddr *, int, int));\r
285int rtioctl __P((int, caddr_t, struct proc *));\r
286void rtredirect __P((struct sockaddr *, struct sockaddr *,\r
287 struct sockaddr *, int, struct sockaddr *, struct rtentry **));\r
288int rtrequest __P((int, struct sockaddr *,\r
289 struct sockaddr *, struct sockaddr *, int, struct rtentry **));\r
290#endif\r
291\r
292#endif\r