keep separate interface list so we just delete routes when they expire
[unix-history] / usr / src / sbin / routed / defs.h
CommitLineData
e0a3d4f9 1/* defs.h 4.10 82/06/10 */
b242391c
SL
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 */
3cec0c76 9#include <net/route.h>
b242391c 10
e0a3d4f9
SL
11/*
12 * An ``interface'' is similar to an ifnet structure,
13 * except it doesn't contain q'ing info, and it also
14 * handles ``logical'' interfaces (remote gateways
15 * that we want to keep polling even if they go down).
16 * The list of interfaces which we maintain is used
17 * in supplying the gratuitous routing table updates.
18 */
19struct interface {
20 struct interface *int_next;
21 struct sockaddr int_addr; /* address on this host */
22 union {
23 struct sockaddr intu_broadaddr;
24 struct sockaddr intu_dstaddr;
25 } int_intu;
26#define int_broadaddr int_intu.intu_broadaddr /* broadcast address */
27#define int_dstaddr int_intu.intu_dstaddr /* other end of p-to-p link */
28 int int_metric; /* init's routing entry */
29 int int_flags; /* see below */
30 int int_net; /* network # */
31};
32
33/*
34 * 0x1 to 0x10 are reused from the kernel's ifnet definitions,
35 * the others agree with the RTS_ flags defined below
36 */
37#define IFF_UP 0x1 /* interface is up */
38#define IFF_BROADCAST 0x2 /* broadcast address valid */
39#define IFF_DEBUG 0x4 /* turn on debugging */
40#define IFF_ROUTE 0x8 /* routing entry installed */
41#define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */
42#define IFF_PASSIVE 0x20 /* can't tell if up/down */
43#define IFF_INTERFACE 0x40 /* hardware interface */
44#define IFF_REMOTE 0x80 /* interface isn't on this machine */
45
b242391c 46/*
e6b5ed24
SL
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.
b242391c 51 */
3cec0c76 52struct rthash {
b242391c
SL
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;
3cec0c76
SL
60 union {
61 struct rtentry rtu_rt;
62 struct {
63 u_long rtu_hash;
64 struct sockaddr rtu_dst;
6a8616d4 65 struct sockaddr rtu_router;
3cec0c76 66 short rtu_flags;
e6b5ed24 67 short rtu_state;
6a8616d4 68 int rtu_timer;
3cec0c76 69 int rtu_metric;
e0a3d4f9 70 struct interface *rtu_ifp;
3cec0c76
SL
71 } rtu_entry;
72 } rt_rtu;
b242391c
SL
73};
74
3cec0c76
SL
75#define rt_rt rt_rtu.rtu_rt /* pass to ioctl */
76#define rt_hash rt_rtu.rtu_entry.rtu_hash /* for net or host */
77#define rt_dst rt_rtu.rtu_entry.rtu_dst /* match value */
6a8616d4 78#define rt_router rt_rtu.rtu_entry.rtu_router /* who to forward to */
e6b5ed24 79#define rt_flags rt_rtu.rtu_entry.rtu_flags /* kernel flags */
3cec0c76 80#define rt_timer rt_rtu.rtu_entry.rtu_timer /* for invalidation */
e6b5ed24 81#define rt_state rt_rtu.rtu_entry.rtu_state /* see below */
3cec0c76
SL
82#define rt_metric rt_rtu.rtu_entry.rtu_metric /* cost of route */
83#define rt_ifp rt_rtu.rtu_entry.rtu_ifp /* interface to take */
84
b242391c
SL
85#define ROUTEHASHSIZ 19
86
87/*
e6b5ed24 88 * "State" of routing table entry.
b242391c 89 */
e0a3d4f9
SL
90#define RTS_CHANGED 0x1 /* route has been altered recently */
91#define RTS_PASSIVE 0x20 /* don't time out route */
92#define RTS_INTERFACE 0x40 /* route is for network interface */
93#define RTS_REMOTE 0x80 /* route is for ``remote'' entity */
b242391c 94
3cec0c76 95struct rthash nethash[ROUTEHASHSIZ], hosthash[ROUTEHASHSIZ];
eae14a37 96struct rt_entry *rtlookup(), *rtfind();
b242391c
SL
97
98/*
e6b5ed24 99 * Per address family routines.
b242391c
SL
100 */
101struct afswitch {
e6b5ed24
SL
102 int (*af_hash)(); /* returns keys based on address */
103 int (*af_netmatch)(); /* verifies net # matching */
104 int (*af_output)(); /* interprets address for sending */
75659c93
SL
105 int (*af_portmatch)(); /* packet from some other router? */
106 int (*af_portcheck)(); /* packet from priviledged peer? */
e6b5ed24 107 int (*af_checkhost)(); /* tells if address for host or net */
75659c93 108 int (*af_canon)(); /* canonicalize address for compares */
b242391c
SL
109};
110
e6b5ed24
SL
111/*
112 * Structure returned by af_hash routines.
113 */
b242391c 114struct afhash {
e6b5ed24
SL
115 u_int afh_hosthash; /* host based hash */
116 u_int afh_nethash; /* network based hash */
b242391c
SL
117};
118
e6b5ed24 119struct afswitch afswitch[AF_MAX]; /* table proper */
e0a3d4f9
SL
120
121/*
122 * When we find any interfaces marked down we rescan the
123 * kernel every CHECK_INTERVAL seconds to see if they've
124 * come up.
125 */
126#define CHECK_INTERVAL (1*60)