111820Sjulian/* 211820Sjulian * Copyright (c) 1983, 1993 311820Sjulian * The Regents of the University of California. All rights reserved. 411820Sjulian * 511820Sjulian * Copyright (c) 1995 John Hay. All rights reserved. 611820Sjulian * 711820Sjulian * Redistribution and use in source and binary forms, with or without 811820Sjulian * modification, are permitted provided that the following conditions 911820Sjulian * are met: 1011820Sjulian * 1. Redistributions of source code must retain the above copyright 1111820Sjulian * notice, this list of conditions and the following disclaimer. 1211820Sjulian * 2. Redistributions in binary form must reproduce the above copyright 1311820Sjulian * notice, this list of conditions and the following disclaimer in the 1411820Sjulian * documentation and/or other materials provided with the distribution. 1511820Sjulian * 3. All advertising materials mentioning features or use of this software 1611820Sjulian * must display the following acknowledgement: 1711820Sjulian * This product includes software developed by the University of 1811820Sjulian * California, Berkeley and its contributors. 1911820Sjulian * 4. Neither the name of the University nor the names of its contributors 2011820Sjulian * may be used to endorse or promote products derived from this software 2111820Sjulian * without specific prior written permission. 2211820Sjulian * 2311820Sjulian * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2411820Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2511820Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2611820Sjulian * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2711820Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2811820Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2911820Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3011820Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3111820Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3211820Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3311820Sjulian * SUCH DAMAGE. 3411820Sjulian * 3511820Sjulian * @(#)table.h 5.1 (Berkeley) 6/4/85 (routed/table.h) 3611820Sjulian * 3711820Sjulian * @(#)table.h 8.1 (Berkeley) 6/5/93 3811820Sjulian * 3950479Speter * $FreeBSD$ 4011820Sjulian */ 4111820Sjulian 4211820Sjulian/* 4311820Sjulian * Routing table management daemon. 4411820Sjulian */ 4511820Sjulian 4611820Sjulian/* 4711820Sjulian * Routing table structure; differs a bit from kernel tables. 4811820Sjulian * 4911820Sjulian * Note: the union below must agree in the first 4 members 5011820Sjulian * so the ioctl's will work. 5111820Sjulian */ 5211820Sjulianstruct rthash { 5311820Sjulian struct rt_entry *rt_forw; 5411820Sjulian struct rt_entry *rt_back; 5511820Sjulian}; 5611820Sjulian 5711820Sjulian#ifdef RTM_ADD 5811820Sjulian#define rtentry ortentry 5911820Sjulian#endif 6011820Sjulian 6111820Sjulianstruct rt_entry { 6211820Sjulian struct rt_entry *rt_forw; 6311820Sjulian struct rt_entry *rt_back; 6411820Sjulian union { 6511820Sjulian struct rtentry rtu_rt; 6611820Sjulian struct rtuentry { 6711820Sjulian u_long rtu_hash; 6811820Sjulian struct sockaddr rtu_dst; 6911820Sjulian struct sockaddr rtu_router; 7011820Sjulian short rtu_rtflags; /* used by old rtioctl */ 7111820Sjulian short rtu_wasted; /* XXX routed does it this way. */ 7211820Sjulian int rtu_flags; 7311820Sjulian int rtu_state; 7411820Sjulian int rtu_timer; 7511820Sjulian int rtu_metric; 7611820Sjulian int rtu_ticks; 7711820Sjulian struct interface *rtu_ifp; 7811820Sjulian } rtu_entry; 7911820Sjulian } rt_rtu; 8011820Sjulian struct rt_entry *rt_clone; 8111820Sjulian}; 8211820Sjulian 8311820Sjulian#define rt_rt rt_rtu.rtu_entry /* pass to ioctl */ 8411820Sjulian#define rt_hash rt_rtu.rtu_entry.rtu_hash /* for net or host */ 8511820Sjulian#define rt_dst rt_rtu.rtu_entry.rtu_dst /* match value */ 8611820Sjulian#define rt_router rt_rtu.rtu_entry.rtu_router /* who to forward to */ 8711820Sjulian#define rt_flags rt_rtu.rtu_entry.rtu_flags /* kernel flags */ 8811820Sjulian#define rt_timer rt_rtu.rtu_entry.rtu_timer /* for invalidation */ 8911820Sjulian#define rt_state rt_rtu.rtu_entry.rtu_state /* see below */ 9011820Sjulian#define rt_metric rt_rtu.rtu_entry.rtu_metric /* cost of route */ 9111820Sjulian#define rt_ticks rt_rtu.rtu_entry.rtu_ticks /* time of route */ 9211820Sjulian#define rt_ifp rt_rtu.rtu_entry.rtu_ifp /* interface to take */ 9311820Sjulian 9427244Sjhay#define ROUTEHASHSIZ 128 /* must be a power of 2 */ 9511820Sjulian#define ROUTEHASHMASK (ROUTEHASHSIZ - 1) 9611820Sjulian 9711820Sjulian/* 9811820Sjulian * "State" of routing table entry. 9911820Sjulian */ 10011820Sjulian#define RTS_CHANGED 0x1 /* route has been altered recently */ 10111820Sjulian#define RTS_PASSIVE IFF_PASSIVE /* don't time out route */ 10211820Sjulian#define RTS_INTERFACE IFF_INTERFACE /* route is for network interface */ 10311820Sjulian#define RTS_REMOTE IFF_REMOTE /* route is for ``remote'' entity */ 10411820Sjulian 10515248Sjhayextern struct rthash nethash[ROUTEHASHSIZ]; 10611820Sjulianstruct rt_entry *rtlookup(struct sockaddr *); 10711820Sjulianstruct rt_entry *rtfind(struct sockaddr *); 10811820Sjulianvoid rtadd(struct sockaddr *, struct sockaddr *, short, short, int); 10911820Sjulianvoid rtadd_clone(struct rt_entry *, struct sockaddr *, struct sockaddr *, 11011820Sjulian short, short, int); 11111820Sjulianvoid rtchange(struct rt_entry *, struct sockaddr *, short, short); 11211820Sjulianvoid rtdelete(struct rt_entry *); 11311820Sjulianint rtioctl(int, struct rtuentry *); 11411820Sjulianvoid rtinit(void); 11511820Sjulian 116