11897Swollman/* 21897Swollman * Copyright (c) 1983, 1993 31897Swollman * The Regents of the University of California. All rights reserved. 41897Swollman * 51897Swollman * Copyright (c) 1995 John Hay. All rights reserved. 61897Swollman * 71897Swollman * Redistribution and use in source and binary forms, with or without 8100441Scharnier * modification, are permitted provided that the following conditions 91897Swollman * are met: 101897Swollman * 1. Redistributions of source code must retain the above copyright 111897Swollman * notice, this list of conditions and the following disclaimer. 12100441Scharnier * 2. Redistributions in binary form must reproduce the above copyright 131897Swollman * notice, this list of conditions and the following disclaimer in the 141897Swollman * documentation and/or other materials provided with the distribution. 151897Swollman * 3. All advertising materials mentioning features or use of this software 16100441Scharnier * must display the following acknowledgement: 171897Swollman * This product includes software developed by the University of 181897Swollman * California, Berkeley and its contributors. 191897Swollman * 4. Neither the name of the University nor the names of its contributors 20100441Scharnier * may be used to endorse or promote products derived from this software 211897Swollman * without specific prior written permission. 221897Swollman * 231897Swollman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24100441Scharnier * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 251897Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 261897Swollman * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 271897Swollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 281897Swollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2912798Swpaul * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30100441Scharnier * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 311897Swollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32146833Sstefanf * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3312798Swpaul * SUCH DAMAGE. 341897Swollman * 3599979Salfred * @(#)table.h 5.1 (Berkeley) 6/4/85 (routed/table.h) 361897Swollman * 37100441Scharnier * @(#)table.h 8.1 (Berkeley) 6/5/93 38100441Scharnier * 39100441Scharnier * $FreeBSD$ 401897Swollman */ 41100441Scharnier 42100441Scharnier/* 431897Swollman * Routing table management daemon. 4412798Swpaul */ 4567191Sbrian 4667191Sbrian/* 4712798Swpaul * Routing table structure; differs a bit from kernel tables. 481897Swollman * 491897Swollman * Note: the union below must agree in the first 4 members 5012798Swpaul * so the ioctl's will work. 51152398Sdwmalone */ 521897Swollmanstruct rthash { 531897Swollman struct rt_entry *rt_forw; 541897Swollman struct rt_entry *rt_back; 551897Swollman}; 561897Swollman 571897Swollmanstruct rt_entry { 581897Swollman struct rt_entry *rt_forw; 591897Swollman struct rt_entry *rt_back; 601897Swollman union { 6192921Simp struct rtuentry { 62152398Sdwmalone u_long rtu_hash; 63152398Sdwmalone struct sockaddr rtu_dst; 64152398Sdwmalone struct sockaddr rtu_router; 6592921Simp short rtu_rtflags; /* used by old rtioctl */ 6692921Simp short rtu_wasted; /* XXX routed does it this way. */ 6792921Simp int rtu_flags; 6892921Simp int rtu_state; 69152398Sdwmalone int rtu_timer; 7012798Swpaul int rtu_metric; 711897Swollman int rtu_ticks; 72100441Scharnier struct interface *rtu_ifp; 731897Swollman } rtu_entry; 741897Swollman } rt_rtu; 75152398Sdwmalone struct rt_entry *rt_clone; 761897Swollman}; 771897Swollman 781897Swollman#define rt_rt rt_rtu.rtu_entry /* pass to ioctl */ 791897Swollman#define rt_hash rt_rtu.rtu_entry.rtu_hash /* for net or host */ 801897Swollman#define rt_dst rt_rtu.rtu_entry.rtu_dst /* match value */ 811897Swollman#define rt_router rt_rtu.rtu_entry.rtu_router /* who to forward to */ 821897Swollman#define rt_flags rt_rtu.rtu_entry.rtu_flags /* kernel flags */ 831897Swollman#define rt_timer rt_rtu.rtu_entry.rtu_timer /* for invalidation */ 84100441Scharnier#define rt_state rt_rtu.rtu_entry.rtu_state /* see below */ 851897Swollman#define rt_metric rt_rtu.rtu_entry.rtu_metric /* cost of route */ 861897Swollman#define rt_ticks rt_rtu.rtu_entry.rtu_ticks /* time of route */ 87152398Sdwmalone#define rt_ifp rt_rtu.rtu_entry.rtu_ifp /* interface to take */ 881897Swollman 891897Swollman#define ROUTEHASHSIZ 128 /* must be a power of 2 */ 901897Swollman#define ROUTEHASHMASK (ROUTEHASHSIZ - 1) 911897Swollman 921897Swollman/* 931897Swollman * "State" of routing table entry. 941897Swollman */ 951897Swollman#define RTS_CHANGED 0x1 /* route has been altered recently */ 96100441Scharnier#define RTS_PASSIVE IFF_PASSIVE /* don't time out route */ 971897Swollman#define RTS_INTERFACE IFF_INTERFACE /* route is for network interface */ 981897Swollman#define RTS_REMOTE IFF_REMOTE /* route is for ``remote'' entity */ 99152398Sdwmalone 1001897Swollmanextern struct rthash nethash[ROUTEHASHSIZ]; 1011897Swollmanstruct rt_entry *rtlookup(struct sockaddr *); 1021897Swollmanstruct rt_entry *rtfind(struct sockaddr *); 1031897Swollmanvoid rtadd(struct sockaddr *, struct sockaddr *, short, short, int); 1041897Swollmanvoid rtadd_clone(struct rt_entry *, struct sockaddr *, struct sockaddr *, 1051897Swollman short, short, int); 1061897Swollmanvoid rtchange(struct rt_entry *, struct sockaddr *, short, short); 1071897Swollmanvoid rtdelete(struct rt_entry *); 1081897Swollmanint rtioctl(int, struct rtuentry *); 109100441Scharniervoid rtinit(void); 1101897Swollman 1111897Swollman