Commit | Line | Data |
---|---|---|
15637ed4 RG |
1 | /* |
2 | * Copyright (c) 1983 Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: | |
8 | * 1. Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * 2. Redistributions in binary form must reproduce the above copyright | |
11 | * notice, this list of conditions and the following disclaimer in the | |
12 | * documentation and/or other materials provided with the distribution. | |
13 | * 3. All advertising materials mentioning features or use of this software | |
14 | * must display the following acknowledgement: | |
15 | * This product includes software developed by the University of | |
16 | * California, Berkeley and its contributors. | |
17 | * 4. Neither the name of the University nor the names of its contributors | |
18 | * may be used to endorse or promote products derived from this software | |
19 | * without specific prior written permission. | |
20 | * | |
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
31 | * SUCH DAMAGE. | |
32 | * | |
33 | * @(#)table.h 5.8 (Berkeley) 6/1/90 | |
34 | */ | |
35 | ||
36 | /* | |
37 | * Routing table management daemon. | |
38 | */ | |
39 | ||
40 | /* | |
41 | * Routing table structure; differs a bit from kernel tables. | |
42 | * | |
43 | * Note: the union below must agree in the first 4 members | |
44 | * so the ioctl's will work. | |
45 | */ | |
46 | struct rthash { | |
47 | struct rt_entry *rt_forw; | |
48 | struct rt_entry *rt_back; | |
49 | }; | |
50 | #ifdef RTM_ADD | |
51 | #define rtentry ortentry | |
52 | #endif | |
53 | ||
54 | struct rt_entry { | |
55 | struct rt_entry *rt_forw; | |
56 | struct rt_entry *rt_back; | |
57 | union { | |
58 | struct rtentry rtu_rt; | |
59 | struct { | |
60 | u_long rtu_hash; | |
61 | struct sockaddr rtu_dst; | |
62 | struct sockaddr rtu_router; | |
63 | short rtu_flags; | |
64 | short rtu_state; | |
65 | int rtu_timer; | |
66 | int rtu_metric; | |
67 | int rtu_ifmetric; | |
68 | struct interface *rtu_ifp; | |
69 | } rtu_entry; | |
70 | } rt_rtu; | |
71 | }; | |
72 | ||
73 | #define rt_rt rt_rtu.rtu_rt /* pass to ioctl */ | |
74 | #define rt_hash rt_rtu.rtu_entry.rtu_hash /* for net or host */ | |
75 | #define rt_dst rt_rtu.rtu_entry.rtu_dst /* match value */ | |
76 | #define rt_router rt_rtu.rtu_entry.rtu_router /* who to forward to */ | |
77 | #define rt_flags rt_rtu.rtu_entry.rtu_flags /* kernel flags */ | |
78 | #define rt_timer rt_rtu.rtu_entry.rtu_timer /* for invalidation */ | |
79 | #define rt_state rt_rtu.rtu_entry.rtu_state /* see below */ | |
80 | #define rt_metric rt_rtu.rtu_entry.rtu_metric /* cost of route */ | |
81 | #define rt_ifmetric rt_rtu.rtu_entry.rtu_ifmetric /* cost of route if */ | |
82 | #define rt_ifp rt_rtu.rtu_entry.rtu_ifp /* interface to take */ | |
83 | ||
84 | #define ROUTEHASHSIZ 32 /* must be a power of 2 */ | |
85 | #define ROUTEHASHMASK (ROUTEHASHSIZ - 1) | |
86 | ||
87 | /* | |
88 | * "State" of routing table entry. | |
89 | */ | |
90 | #define RTS_CHANGED 0x1 /* route has been altered recently */ | |
91 | #define RTS_EXTERNAL 0x2 /* extern info, not installed or sent */ | |
92 | #define RTS_INTERNAL 0x4 /* internal route, not installed */ | |
93 | #define RTS_PASSIVE IFF_PASSIVE /* don't time out route */ | |
94 | #define RTS_INTERFACE IFF_INTERFACE /* route is for network interface */ | |
95 | #define RTS_REMOTE IFF_REMOTE /* route is for ``remote'' entity */ | |
96 | #define RTS_SUBNET IFF_SUBNET /* route is for network subnet */ | |
97 | ||
98 | /* | |
99 | * Flags are same as kernel, with this addition for af_rtflags: | |
100 | */ | |
101 | #define RTF_SUBNET 0x8000 /* pseudo: route to subnet */ | |
102 | ||
103 | struct rthash nethash[ROUTEHASHSIZ]; | |
104 | struct rthash hosthash[ROUTEHASHSIZ]; | |
105 | struct rt_entry *rtlookup(); | |
106 | struct rt_entry *rtfind(); |