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 are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 * @(#)table.h 5.7 (Berkeley) 08/21/89 18 */ 19 20 /* 21 * Routing table management daemon. 22 */ 23 24 /* 25 * Routing table structure; differs a bit from kernel tables. 26 * 27 * Note: the union below must agree in the first 4 members 28 * so the ioctl's will work. 29 */ 30 struct rthash { 31 struct rt_entry *rt_forw; 32 struct rt_entry *rt_back; 33 }; 34 #ifdef RTM_ADD 35 #define rtentry ortentry 36 #endif 37 38 struct rt_entry { 39 struct rt_entry *rt_forw; 40 struct rt_entry *rt_back; 41 union { 42 struct rtentry rtu_rt; 43 struct { 44 u_long rtu_hash; 45 struct sockaddr rtu_dst; 46 struct sockaddr rtu_router; 47 short rtu_flags; 48 short rtu_state; 49 int rtu_timer; 50 int rtu_metric; 51 int rtu_ifmetric; 52 struct interface *rtu_ifp; 53 } rtu_entry; 54 } rt_rtu; 55 }; 56 57 #define rt_rt rt_rtu.rtu_rt /* pass to ioctl */ 58 #define rt_hash rt_rtu.rtu_entry.rtu_hash /* for net or host */ 59 #define rt_dst rt_rtu.rtu_entry.rtu_dst /* match value */ 60 #define rt_router rt_rtu.rtu_entry.rtu_router /* who to forward to */ 61 #define rt_flags rt_rtu.rtu_entry.rtu_flags /* kernel flags */ 62 #define rt_timer rt_rtu.rtu_entry.rtu_timer /* for invalidation */ 63 #define rt_state rt_rtu.rtu_entry.rtu_state /* see below */ 64 #define rt_metric rt_rtu.rtu_entry.rtu_metric /* cost of route */ 65 #define rt_ifmetric rt_rtu.rtu_entry.rtu_ifmetric /* cost of route if */ 66 #define rt_ifp rt_rtu.rtu_entry.rtu_ifp /* interface to take */ 67 68 #define ROUTEHASHSIZ 32 /* must be a power of 2 */ 69 #define ROUTEHASHMASK (ROUTEHASHSIZ - 1) 70 71 /* 72 * "State" of routing table entry. 73 */ 74 #define RTS_CHANGED 0x1 /* route has been altered recently */ 75 #define RTS_EXTERNAL 0x2 /* extern info, not installed or sent */ 76 #define RTS_INTERNAL 0x4 /* internal route, not installed */ 77 #define RTS_PASSIVE IFF_PASSIVE /* don't time out route */ 78 #define RTS_INTERFACE IFF_INTERFACE /* route is for network interface */ 79 #define RTS_REMOTE IFF_REMOTE /* route is for ``remote'' entity */ 80 #define RTS_SUBNET IFF_SUBNET /* route is for network subnet */ 81 82 /* 83 * Flags are same as kernel, with this addition for af_rtflags: 84 */ 85 #define RTF_SUBNET 0x8000 /* pseudo: route to subnet */ 86 87 struct rthash nethash[ROUTEHASHSIZ]; 88 struct rthash hosthash[ROUTEHASHSIZ]; 89 struct rt_entry *rtlookup(); 90 struct rt_entry *rtfind(); 91