table.h revision 264298
113901Salanb/* 213901Salanb * Copyright (c) 1983, 1993 313901Salanb * The Regents of the University of California. All rights reserved. 413901Salanb * 513901Salanb * Copyright (c) 1995 John Hay. All rights reserved. 613901Salanb * 713901Salanb * Redistribution and use in source and binary forms, with or without 813901Salanb * modification, are permitted provided that the following conditions 913901Salanb * are met: 1013901Salanb * 1. Redistributions of source code must retain the above copyright 1113901Salanb * notice, this list of conditions and the following disclaimer. 1213901Salanb * 2. Redistributions in binary form must reproduce the above copyright 1313901Salanb * notice, this list of conditions and the following disclaimer in the 1413901Salanb * documentation and/or other materials provided with the distribution. 1513901Salanb * 3. All advertising materials mentioning features or use of this software 1613901Salanb * must display the following acknowledgement: 1713901Salanb * This product includes software developed by the University of 1813901Salanb * California, Berkeley and its contributors. 1913901Salanb * 4. Neither the name of the University nor the names of its contributors 2013901Salanb * may be used to endorse or promote products derived from this software 2113901Salanb * without specific prior written permission. 2213901Salanb * 2313901Salanb * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2413901Salanb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2513901Salanb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2615370Slancea * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2715370Slancea * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2816688Smli * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2916952Smchung * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3016688Smli * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3115370Slancea * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3213901Salanb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3313901Salanb * SUCH DAMAGE. 3417410Smchung * 3517410Smchung * @(#)table.h 5.1 (Berkeley) 6/4/85 (routed/table.h) 3617410Smchung * 3713901Salanb * @(#)table.h 8.1 (Berkeley) 6/5/93 3813901Salanb * 39 * $FreeBSD: stable/10/usr.sbin/IPXrouted/table.h 264298 2014-04-09 11:10:44Z glebius $ 40 */ 41 42/* 43 * Routing table management daemon. 44 */ 45 46/* 47 * Routing table structure; differs a bit from kernel tables. 48 * 49 * Note: the union below must agree in the first 4 members 50 * so the ioctl's will work. 51 */ 52struct rthash { 53 struct rt_entry *rt_forw; 54 struct rt_entry *rt_back; 55}; 56 57struct rt_entry { 58 struct rt_entry *rt_forw; 59 struct rt_entry *rt_back; 60 union { 61 struct rtuentry { 62 u_long rtu_hash; 63 struct sockaddr rtu_dst; 64 struct sockaddr rtu_router; 65 short rtu_rtflags; /* used by old rtioctl */ 66 short rtu_wasted; /* XXX routed does it this way. */ 67 int rtu_flags; 68 int rtu_state; 69 int rtu_timer; 70 int rtu_metric; 71 int rtu_ticks; 72 struct interface *rtu_ifp; 73 } rtu_entry; 74 } rt_rtu; 75 struct rt_entry *rt_clone; 76}; 77 78#define rt_rt rt_rtu.rtu_entry /* pass to ioctl */ 79#define rt_hash rt_rtu.rtu_entry.rtu_hash /* for net or host */ 80#define rt_dst rt_rtu.rtu_entry.rtu_dst /* match value */ 81#define rt_router rt_rtu.rtu_entry.rtu_router /* who to forward to */ 82#define rt_flags rt_rtu.rtu_entry.rtu_flags /* kernel flags */ 83#define rt_timer rt_rtu.rtu_entry.rtu_timer /* for invalidation */ 84#define rt_state rt_rtu.rtu_entry.rtu_state /* see below */ 85#define rt_metric rt_rtu.rtu_entry.rtu_metric /* cost of route */ 86#define rt_ticks rt_rtu.rtu_entry.rtu_ticks /* time of route */ 87#define rt_ifp rt_rtu.rtu_entry.rtu_ifp /* interface to take */ 88 89#define ROUTEHASHSIZ 128 /* must be a power of 2 */ 90#define ROUTEHASHMASK (ROUTEHASHSIZ - 1) 91 92/* 93 * "State" of routing table entry. 94 */ 95#define RTS_CHANGED 0x1 /* route has been altered recently */ 96#define RTS_PASSIVE IFF_PASSIVE /* don't time out route */ 97#define RTS_INTERFACE IFF_INTERFACE /* route is for network interface */ 98#define RTS_REMOTE IFF_REMOTE /* route is for ``remote'' entity */ 99 100extern struct rthash nethash[ROUTEHASHSIZ]; 101struct rt_entry *rtlookup(struct sockaddr *); 102struct rt_entry *rtfind(struct sockaddr *); 103void rtadd(struct sockaddr *, struct sockaddr *, short, short, int); 104void rtadd_clone(struct rt_entry *, struct sockaddr *, struct sockaddr *, 105 short, short, int); 106void rtchange(struct rt_entry *, struct sockaddr *, short, short); 107void rtdelete(struct rt_entry *); 108int rtioctl(int, struct rtuentry *); 109void rtinit(void); 110 111