| 1 | /* defs.h 4.8 82/06/09 */ |
| 2 | |
| 3 | /* |
| 4 | * Internal data structure definitions for |
| 5 | * user routing process. Based on Xerox NS |
| 6 | * protocol specs with mods relevant to more |
| 7 | * general addressing scheme. |
| 8 | */ |
| 9 | #include <net/route.h> |
| 10 | |
| 11 | /* |
| 12 | * Routing table structure; differs a bit from kernel tables. |
| 13 | * |
| 14 | * Note: the union below must agree in the first 4 members |
| 15 | * so the ioctl's will work. |
| 16 | */ |
| 17 | struct rthash { |
| 18 | struct rt_entry *rt_forw; |
| 19 | struct rt_entry *rt_back; |
| 20 | }; |
| 21 | |
| 22 | struct rt_entry { |
| 23 | struct rt_entry *rt_forw; |
| 24 | struct rt_entry *rt_back; |
| 25 | union { |
| 26 | struct rtentry rtu_rt; |
| 27 | struct { |
| 28 | u_long rtu_hash; |
| 29 | struct sockaddr rtu_dst; |
| 30 | struct sockaddr rtu_router; |
| 31 | short rtu_flags; |
| 32 | short rtu_state; |
| 33 | int rtu_timer; |
| 34 | int rtu_metric; |
| 35 | struct ifnet *rtu_ifp; |
| 36 | struct sockaddr rtu_newrouter; |
| 37 | } rtu_entry; |
| 38 | } rt_rtu; |
| 39 | }; |
| 40 | |
| 41 | #define rt_rt rt_rtu.rtu_rt /* pass to ioctl */ |
| 42 | #define rt_hash rt_rtu.rtu_entry.rtu_hash /* for net or host */ |
| 43 | #define rt_dst rt_rtu.rtu_entry.rtu_dst /* match value */ |
| 44 | #define rt_router rt_rtu.rtu_entry.rtu_router /* who to forward to */ |
| 45 | #define rt_flags rt_rtu.rtu_entry.rtu_flags /* kernel flags */ |
| 46 | #define rt_timer rt_rtu.rtu_entry.rtu_timer /* for invalidation */ |
| 47 | #define rt_state rt_rtu.rtu_entry.rtu_state /* see below */ |
| 48 | #define rt_metric rt_rtu.rtu_entry.rtu_metric /* cost of route */ |
| 49 | #define rt_ifp rt_rtu.rtu_entry.rtu_ifp /* interface to take */ |
| 50 | #define rt_newrouter rt_rtu.rtu_entry.rtu_newrouter /* for change's */ |
| 51 | |
| 52 | #define ROUTEHASHSIZ 19 |
| 53 | |
| 54 | /* |
| 55 | * "State" of routing table entry. |
| 56 | */ |
| 57 | #define RTS_DELRT 0x1 /* delete pending */ |
| 58 | #define RTS_CHGRT 0x2 /* change command pending */ |
| 59 | #define RTS_ADDRT 0x4 /* add command pending */ |
| 60 | #define RTS_PASSIVE 0x8 /* don't send to router */ |
| 61 | #define RTS_INTERFACE 0x10 /* route is for an interface */ |
| 62 | #define RTS_GLOBAL 0x20 /* entry is non-local, don't lose it */ |
| 63 | |
| 64 | struct rthash nethash[ROUTEHASHSIZ], hosthash[ROUTEHASHSIZ]; |
| 65 | struct rt_entry *rtlookup(), *rtfind(); |
| 66 | |
| 67 | /* |
| 68 | * Per address family routines. |
| 69 | */ |
| 70 | struct afswitch { |
| 71 | int (*af_hash)(); /* returns keys based on address */ |
| 72 | int (*af_netmatch)(); /* verifies net # matching */ |
| 73 | int (*af_output)(); /* interprets address for sending */ |
| 74 | int (*af_portmatch)(); /* packet from some other router? */ |
| 75 | int (*af_portcheck)(); /* packet from priviledged peer? */ |
| 76 | int (*af_checkhost)(); /* tells if address for host or net */ |
| 77 | int (*af_canon)(); /* canonicalize address for compares */ |
| 78 | }; |
| 79 | |
| 80 | /* |
| 81 | * Structure returned by af_hash routines. |
| 82 | */ |
| 83 | struct afhash { |
| 84 | u_int afh_hosthash; /* host based hash */ |
| 85 | u_int afh_nethash; /* network based hash */ |
| 86 | }; |
| 87 | |
| 88 | struct afswitch afswitch[AF_MAX]; /* table proper */ |