Commit | Line | Data |
---|---|---|
02748149 KB |
1 | /* |
2 | * Copyright (c) 1983 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
af359dea C |
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. | |
02748149 KB |
32 | * |
33 | * @(#)table.h 5.1 (Berkeley) 6/4/85 (routed/table.h) | |
34 | * | |
1c15e888 | 35 | * @(#)table.h 5.3 (Berkeley) 6/1/90 |
02748149 KB |
36 | */ |
37 | ||
38 | /* | |
39 | * Routing table management daemon. | |
40 | */ | |
41 | ||
42 | /* | |
43 | * Routing table structure; differs a bit from kernel tables. | |
44 | * | |
45 | * Note: the union below must agree in the first 4 members | |
46 | * so the ioctl's will work. | |
47 | */ | |
48 | struct rthash { | |
49 | struct rt_entry *rt_forw; | |
50 | struct rt_entry *rt_back; | |
51 | }; | |
52 | ||
3470e246 MK |
53 | #ifdef RTM_ADD |
54 | #define rtentry ortentry | |
55 | #endif | |
56 | ||
02748149 KB |
57 | struct rt_entry { |
58 | struct rt_entry *rt_forw; | |
59 | struct rt_entry *rt_back; | |
60 | union { | |
61 | struct rtentry rtu_rt; | |
62 | struct { | |
63 | u_long rtu_hash; | |
64 | struct sockaddr rtu_dst; | |
65 | struct sockaddr rtu_router; | |
66 | short rtu_flags; | |
67 | short rtu_state; | |
68 | int rtu_timer; | |
69 | int rtu_metric; | |
70 | struct interface *rtu_ifp; | |
71 | } rtu_entry; | |
72 | } rt_rtu; | |
73 | }; | |
74 | ||
75 | #define rt_rt rt_rtu.rtu_rt /* pass to ioctl */ | |
76 | #define rt_hash rt_rtu.rtu_entry.rtu_hash /* for net or host */ | |
77 | #define rt_dst rt_rtu.rtu_entry.rtu_dst /* match value */ | |
78 | #define rt_router rt_rtu.rtu_entry.rtu_router /* who to forward to */ | |
79 | #define rt_flags rt_rtu.rtu_entry.rtu_flags /* kernel flags */ | |
80 | #define rt_timer rt_rtu.rtu_entry.rtu_timer /* for invalidation */ | |
81 | #define rt_state rt_rtu.rtu_entry.rtu_state /* see below */ | |
82 | #define rt_metric rt_rtu.rtu_entry.rtu_metric /* cost of route */ | |
83 | #define rt_ifp rt_rtu.rtu_entry.rtu_ifp /* interface to take */ | |
84 | ||
85 | #define ROUTEHASHSIZ 32 /* must be a power of 2 */ | |
86 | #define ROUTEHASHMASK (ROUTEHASHSIZ - 1) | |
87 | ||
88 | /* | |
89 | * "State" of routing table entry. | |
90 | */ | |
91 | #define RTS_CHANGED 0x1 /* route has been altered recently */ | |
92 | #define RTS_PASSIVE IFF_PASSIVE /* don't time out route */ | |
93 | #define RTS_INTERFACE IFF_INTERFACE /* route is for network interface */ | |
94 | #define RTS_REMOTE IFF_REMOTE /* route is for ``remote'' entity */ | |
95 | ||
96 | struct rthash nethash[ROUTEHASHSIZ]; | |
97 | struct rthash hosthash[ROUTEHASHSIZ]; | |
98 | struct rt_entry *rtlookup(); | |
99 | struct rt_entry *rtfind(); |