source: branches/libc-0.6/src/emx/include/net/route.h

Last change on this file was 183, checked in by bird, 22 years ago

#434: Initial tcpip header merges.

  • Property cvs2svn:cvs-rev set to 1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 10.8 KB
Line 
1/* Modified for emx by hv and em 1994,1996
2 * Modified for gcc/os2 by bird 2003
3 *
4 * Copyright (c) 1980, 1986 Regents of the University of California.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * from: @(#)route.h 7.13 (Berkeley) 4/25/91
36 * $Id: route.h,v 1.3 1993/05/20 03:06:10 cgd Exp $
37 */
38
39#ifndef _NET_ROUTE_H_
40#define _NET_ROUTE_H_
41
42#include <net/if.h>
43
44#if defined (__cplusplus)
45extern "C" {
46#endif
47
48/*
49 * Kernel resident routing tables.
50 *
51 * The routing tables are initialized when interface addresses
52 * are set by making entries for all directly connected interfaces.
53 */
54
55/*
56 * A route consists of a destination address and a reference
57 * to a routing entry. These are often held by protocols
58 * in their control blocks, e.g. inpcb.
59 */
60struct route {
61 struct rtentry *ro_rt;
62 struct sockaddr ro_dst;
63};
64
65
66#ifndef TCPV40HDRS
67/*
68 * These numbers are used by reliable protocols for determining
69 * retransmission behavior and are included in the routing structure.
70 */
71struct rt_metrics {
72 u_long rmx_locks; /* Kernel must leave these values alone */
73 u_long rmx_mtu; /* MTU for this path */
74 u_long rmx_hopcount; /* max hops expected */
75 u_long rmx_expire; /* lifetime for route, e.g. redirect */
76 u_long rmx_recvpipe; /* inbound delay-bandwith product */
77 u_long rmx_sendpipe; /* outbound delay-bandwith product */
78 u_long rmx_ssthresh; /* outbound gateway buffer limit */
79 u_long rmx_rtt; /* estimated round trip time */
80 u_long rmx_rttvar; /* estimated rtt variance */
81 u_long rmx_pksent; /* packets sent using this route */
82 u_long rmx_filler[4]; /* will be used for T/TCP later */
83};
84
85/*
86 * rmx_rtt and rmx_rttvar are stored as microseconds;
87 * RTTTOPRHZ(rtt) converts to a value suitable for use
88 * by a protocol slowtimo counter.
89 */
90#define RTM_RTTUNIT 1000000 /* units for rtt, rttvar, as units per sec */
91#define RTTTOPRHZ(r) ((r) / (RTM_RTTUNIT / PR_SLOWHZ))
92#endif /* !TCPV40HDRS */
93
94
95/*
96 * We distinguish between routes to hosts and routes to networks,
97 * preferring the former if available. For each route we infer
98 * the interface to use from the gateway address supplied when
99 * the route was entered. Routes that forward packets through
100 * gateways are marked so that the output routines know to address the
101 * gateway rather than the ultimate destination.
102 *
103 * Following structure necessary for 4.3 compatibility;
104 */
105#pragma pack(1)
106#ifdef TCPV40HDRS
107struct rtentry
108#else
109struct ortentry
110#endif
111{
112 u_long rt_hash; /* to speed lookups */
113 struct sockaddr rt_dst; /* key */
114 struct sockaddr rt_gateway; /* value */
115 short rt_flags; /* up/down?, host/net */
116 short rt_refcnt; /* # held references */
117 u_long rt_use; /* raw # packets forwarded */
118 struct ifnet *rt_ifp; /* the answer: interface to use */
119 long metric1,metric2,metric3,metric4; /*IBM special */
120};
121#pragma pack()
122
123/* IBM: hv: I think this is the internal structure of the RT table of the
124 * router daemon. Don't think it belongs here, but the toolkit has it as well
125 */
126#define RTENTRY_COUNT 512
127#pragma pack(1)
128struct rtentries {
129 short hostcount;
130 short netcount;
131 #ifdef TCPV40HDRS
132 struct rtentry rttable[RTENTRY_COUNT];
133 #else
134 struct ortentry rttable[RTENTRY_COUNT];
135 #endif
136};
137#pragma pack()
138
139
140#define RTF_UP 0x1 /* route usable */
141#define RTF_GATEWAY 0x2 /* destination is a gateway */
142#define RTF_HOST 0x4 /* host entry (net otherwise) */
143#define RTF_REJECT 0x8 /* host or net unreachable */
144#define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */
145#define RTF_MODIFIED 0x20 /* modified dynamically (by redirect) */
146#define RTF_DONE 0x40 /* message confirmed */
147#define RTF_MASK 0x80 /* subnet mask present */
148#define RTF_CLONING 0x100 /* generate new routes on use */
149#define RTF_XRESOLVE 0x200 /* external daemon resolves name */
150#define RTF_LLINFO 0x400 /* generated by ARP or ESIS */
151#define RTF_STATIC 0x800 /* route manually added */
152#define RTF_BLACKHOLE 0x1000 /* discard packets during updates */
153#ifndef TCPV40HDRS
154#define RTF_LLTEMP 0x2000 /* manually added temporary arp entry */
155#endif
156#define RTF_PROTO2 0x4000 /* protocol specific routing flag */
157#define RTF_PROTO1 0x8000 /* protocol specific routing flag */
158#ifndef TCPV40HDRS
159#define RTF_PRCLONING 0x10000 /* protocol requires cloning */
160#define RTF_WASCLONED 0x20000 /* route generated through cloning */
161#define RTF_PROTO3 0x40000 /* protocol specific routing flag */
162#define RTF_CHAINDELETE 0x80000 /* chain is being deleted (internal) */
163#define RTF_PINNED 0x100000 /* future use */
164#define RTF_TUNNEL 0x200000 /* tunnelling bit */
165#define RTF_CRYPT 0x400000 /* encrypting tunnel */
166#define RTF_AUTH 0x800000 /* authenticating tunnel */
167#endif
168
169
170/*
171 * Routing statistics.
172 */
173struct rtstat {
174 short rts_badredirect; /* bogus redirect calls */
175 short rts_dynamic; /* routes created by redirects */
176 short rts_newgateway; /* routes modified by redirects */
177 short rts_unreach; /* lookups which failed */
178 short rts_wildcard; /* lookups satisfied by a wildcard */
179};
180#ifndef TCPV40HDRS
181/*
182 * Structures for routing messages.
183 */
184#pragma pack(1)
185struct rt_msghdr {
186#define IFNAMSIZ 16
187 u_short rtm_msglen; /* to skip over non-understood messages */
188 u_char rtm_version; /* future binary compatibility */
189 u_char rtm_type; /* message type */
190 u_short rtm_index; /* index for associated ifp */
191 short rtm_unit; /* new field for subnet routing */
192 int rtm_flags; /* flags, incl. kern & message, e.g. DONE */
193 int rtm_addrs; /* bitmask identifying sockaddrs in msg */
194 pid_t rtm_pid; /* identify sender */
195 int rtm_seq; /* for sender to identify action */
196 int rtm_errno; /* why failed */
197 int rtm_use; /* from rtentry */
198 u_long rtm_inits; /* which metrics we are initializing */
199 u_long rtm_netmask; /* new field for subnet routing */
200 char rtm_name[IFNAMSIZ]; /* new field for subnet routing */
201 struct rt_metrics rtm_rmx; /* metrics themselves */
202};
203#pragma pack()
204
205#define RTM_VERSION 4 /* Up the ante and ignore older versions */
206
207#define RTM_ADD 0x1 /* Add Route */
208#define RTM_DELETE 0x2 /* Delete Route */
209#define RTM_CHANGE 0x3 /* Change Metrics or flags */
210#define RTM_GET 0x4 /* Report Metrics */
211#define RTM_LOSING 0x5 /* Kernel Suspects Partitioning */
212#define RTM_REDIRECT 0x6 /* Told to use different route */
213#define RTM_MISS 0x7 /* Lookup failed on this address */
214#define RTM_LOCK 0x8 /* fix specified metrics */
215#define RTM_OLDADD 0x9 /* caused by SIOCADDRT */
216#define RTM_OLDDEL 0xa /* caused by SIOCDELRT */
217#define RTM_RESOLVE 0xb /* req to resolve dst to LL addr */
218#define RTM_NEWADDR 0xc /* address being added to iface */
219#define RTM_DELADDR 0xd /* address being removed from iface */
220#define RTM_IFINFO 0xe /* iface going up/down etc. */
221
222#define RTV_MTU 0x1 /* init or lock _mtu */
223#define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */
224#define RTV_EXPIRE 0x4 /* init or lock _hopcount */
225#define RTV_RPIPE 0x8 /* init or lock _recvpipe */
226#define RTV_SPIPE 0x10 /* init or lock _sendpipe */
227#define RTV_SSTHRESH 0x20 /* init or lock _ssthresh */
228#define RTV_RTT 0x40 /* init or lock _rtt */
229#define RTV_RTTVAR 0x80 /* init or lock _rttvar */
230
231/*
232 * Bitmask values for rtm_addr.
233 */
234#define RTA_DST 0x1 /* destination sockaddr present */
235#define RTA_GATEWAY 0x2 /* gateway sockaddr present */
236#define RTA_NETMASK 0x4 /* netmask sockaddr present */
237#define RTA_GENMASK 0x8 /* cloning mask sockaddr present */
238#define RTA_IFP 0x10 /* interface name sockaddr present */
239#define RTA_IFA 0x20 /* interface addr sockaddr present */
240#define RTA_AUTHOR 0x40 /* sockaddr for author of redirect */
241#define RTA_BRD 0x80 /* for NEWADDR, broadcast or p-p dest addr */
242
243/*
244 * Index offsets for sockaddr array for alternate internal encoding.
245 */
246#define RTAX_DST 0 /* destination sockaddr present */
247#define RTAX_GATEWAY 1 /* gateway sockaddr present */
248#define RTAX_NETMASK 2 /* netmask sockaddr present */
249#define RTAX_GENMASK 3 /* cloning mask sockaddr present */
250#define RTAX_IFP 4 /* interface name sockaddr present */
251#define RTAX_IFA 5 /* interface addr sockaddr present */
252#define RTAX_AUTHOR 6 /* sockaddr for author of redirect */
253#define RTAX_BRD 7 /* for NEWADDR, broadcast or p-p dest addr */
254#define RTAX_MAX 8 /* size of array to allocate */
255
256struct rt_addrinfo {
257 int rti_addrs;
258 struct sockaddr *rti_info[RTAX_MAX];
259};
260
261struct route_cb {
262 int ip_count;
263 int ns_count;
264 int iso_count;
265 int any_count;
266};
267#endif /* !TCPV40HDRS */
268
269#if defined (__cplusplus)
270}
271#endif
272
273#endif /* !_NET_ROUTE_H_ */
Note: See TracBrowser for help on using the repository browser.