1 /* route.h 4.7 82/03/31 */ 2 3 /* 4 * Kernel resident routing tables. 5 * 6 * Each interface makes an entry at boot time so that 7 * correspondents directly addressible can be found. 8 * User programs can update this data base from information 9 * stored in the file system or information gleaned from 10 * routing protocol interactions with gateways. 11 * 12 * TODO: 13 * keep statistics 14 * smooth usage figures 15 */ 16 struct rtentry { 17 u_long rt_hash; /* for net or for host */ 18 struct sockaddr rt_dst; /* match value */ 19 struct sockaddr rt_gateway; /* who to forward to */ 20 short rt_flags; /* see below */ 21 short rt_refcnt; /* # held references */ 22 u_long rt_use; /* raw # packets forwarded */ 23 struct ifnet *rt_ifp; /* interface to use */ 24 }; 25 26 struct route { 27 struct rtentry *ro_rt; 28 struct sockaddr ro_dst; 29 caddr_t ro_pcb; /* back pointer? */ 30 }; 31 32 /* 33 * Flags and host/network status. 34 */ 35 #define RTF_UP 0x1 /* route useable */ 36 #define RTF_DIRECT 0x2 /* destination is a neighbor */ 37 #define RTF_HOST 0x4 /* host entry (net otherwise) */ 38 39 #define RTFREE(rt) \ 40 if ((rt)->rt_refcnt == 1) \ 41 rtfree(rt); \ 42 else \ 43 (rt)->rt_refcnt--; 44 45 #ifdef KERNEL 46 /* 47 * Lookup are hashed by a key. Each hash bucket 48 * consists of a linked list of mbuf's 49 * containing routing entries. Dead entries are 50 * reclaimed along with mbufs. 51 */ 52 #define RTHASHSIZ 7 53 struct mbuf *rthost[RTHASHSIZ]; 54 struct mbuf *rtnet[RTHASHSIZ]; 55 #endif 56