BSD 4_3_Tahoe release
[unix-history] / usr / src / etc / routed / table.h
CommitLineData
5ff67f98
DF
1/*
2 * Copyright (c) 1983 Regents of the University of California.
0eb85d71 3 * All rights reserved.
5ff67f98 4 *
0eb85d71 5 * Redistribution and use in source and binary forms are permitted
ca67e7b4
C
6 * provided that this notice is preserved and that due credit is given
7 * to the University of California at Berkeley. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
0eb85d71 11 *
ca67e7b4 12 * @(#)table.h 5.5 (Berkeley) 2/16/88
5ff67f98 13 */
d03054c7
SL
14
15/*
16 * Routing table management daemon.
17 */
18
19/*
20 * Routing table structure; differs a bit from kernel tables.
21 *
22 * Note: the union below must agree in the first 4 members
23 * so the ioctl's will work.
24 */
25struct rthash {
26 struct rt_entry *rt_forw;
27 struct rt_entry *rt_back;
28};
29
30struct rt_entry {
31 struct rt_entry *rt_forw;
32 struct rt_entry *rt_back;
33 union {
34 struct rtentry rtu_rt;
35 struct {
36 u_long rtu_hash;
37 struct sockaddr rtu_dst;
38 struct sockaddr rtu_router;
39 short rtu_flags;
40 short rtu_state;
41 int rtu_timer;
42 int rtu_metric;
88709531 43 int rtu_ifmetric;
d03054c7
SL
44 struct interface *rtu_ifp;
45 } rtu_entry;
46 } rt_rtu;
47};
48
49#define rt_rt rt_rtu.rtu_rt /* pass to ioctl */
50#define rt_hash rt_rtu.rtu_entry.rtu_hash /* for net or host */
51#define rt_dst rt_rtu.rtu_entry.rtu_dst /* match value */
52#define rt_router rt_rtu.rtu_entry.rtu_router /* who to forward to */
53#define rt_flags rt_rtu.rtu_entry.rtu_flags /* kernel flags */
54#define rt_timer rt_rtu.rtu_entry.rtu_timer /* for invalidation */
55#define rt_state rt_rtu.rtu_entry.rtu_state /* see below */
56#define rt_metric rt_rtu.rtu_entry.rtu_metric /* cost of route */
88709531 57#define rt_ifmetric rt_rtu.rtu_entry.rtu_ifmetric /* cost of route if */
d03054c7
SL
58#define rt_ifp rt_rtu.rtu_entry.rtu_ifp /* interface to take */
59
49139b80
MK
60#define ROUTEHASHSIZ 32 /* must be a power of 2 */
61#define ROUTEHASHMASK (ROUTEHASHSIZ - 1)
d03054c7
SL
62
63/*
64 * "State" of routing table entry.
65 */
66#define RTS_CHANGED 0x1 /* route has been altered recently */
4fad5a6e
MK
67#define RTS_EXTERNAL 0x2 /* extern info, not installed or sent */
68#define RTS_INTERNAL 0x4 /* internal route, not installed */
b7e4f8be
MK
69#define RTS_PASSIVE IFF_PASSIVE /* don't time out route */
70#define RTS_INTERFACE IFF_INTERFACE /* route is for network interface */
71#define RTS_REMOTE IFF_REMOTE /* route is for ``remote'' entity */
4fad5a6e
MK
72#define RTS_SUBNET IFF_SUBNET /* route is for network subnet */
73
74/*
75 * Flags are same as kernel, with this addition for af_rtflags:
76 */
77#define RTF_SUBNET 0x8000 /* pseudo: route to subnet */
d03054c7
SL
78
79struct rthash nethash[ROUTEHASHSIZ];
80struct rthash hosthash[ROUTEHASHSIZ];
81struct rt_entry *rtlookup();
82struct rt_entry *rtfind();