1 /*!\file protocol/routed.h
2 * Route Daeamon definitions.
5 /* $NetBSD: routed.h,v 1.10 1997/02/03 22:20:38 christos Exp $ */
8 * Copyright (c) 1983, 1989, 1993
9 * The Regents of the University of California. All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * @(#)routed.h 8.1 (Berkeley) 6/2/93
42 #ifndef __PROTOCOL_ROUTED_H
43 #define __PROTOCOL_ROUTED_H
46 * Routing Information Protocol
48 * Derived from Xerox NS Routing Information Protocol
49 * by changing 32-bit net numbers to sockaddr's and
50 * padding stuff to 32-bit boundaries.
53 #define RIP_VERSION_0 0
54 #define RIP_VERSION_1 1
55 #define RIP_VERSION_2 2
57 #define RIPv1 RIP_VERSION_1
58 #define RIPv2 RIP_VERSION_2
60 #define RIPVERSION RIPv1
65 #include <sys/packon.h>
68 /* We include the V2 fields to get the right size */
72 u_int32_t rip_dst; /* destination net/host */
73 u_int32_t rip_dst_mask; /* destination mask (V2 only) */
74 u_int32_t rip_router; /* next host (V2 only) */
75 u_int32_t rip_metric; /* cost of route */
80 #define RIP_AF_INET htons(AF_INET)
81 #define RIP_AF_UNSPEC 0
82 #define RIP_AF_AUTH 0xffff
83 u_int16_t n_tag; /* optional in RIPv2 */
84 u_int32_t n_dst; /* destination net or host */
86 u_int32_t n_mask; /* netmask in RIPv2 */
87 u_int32_t n_nhop; /* optional next hop in RIPv2 */
88 u_int32_t n_metric; /* cost of route */
92 /* RIPv2 authentication */
94 u_int16_t a_family; /* always RIP_AF_AUTH */
96 #define RIP_AUTH_NONE 0
97 #define RIP_AUTH_PW htons(2) /* password type */
98 #define RIP_AUTH_MD5 htons(3) /* Keyed MD5 */
100 #define RIP_AUTH_PW_LEN 16
101 u_int8_t au_pw[RIP_AUTH_PW_LEN];
103 int16_t md5_pkt_len; /* RIP-II packet length */
104 int8_t md5_keyid; /* key ID and auth data len */
105 int8_t md5_auth_len; /* 16 */
106 u_int32_t md5_seqno; /* sequence number */
107 u_int32_t rsvd[2]; /* must be 0 */
108 #define RIP_AUTH_MD5_LEN RIP_AUTH_PW_LEN
114 u_int8_t rip_cmd; /* request/response */
115 u_int8_t rip_vers; /* protocol version # */
116 u_int16_t rip_res1; /* pad to 32-bit boundary */
117 union { /* variable length... */
118 struct netinfo ru_nets[1];
119 int8_t ru_tracefile[1];
120 struct netauth ru_auth[1];
122 #define rip_nets ripun.ru_nets
123 #define rip_auths ripun.ru_auth
124 #define rip_tracefile ripun.ru_tracefile
127 #include <sys/packoff.h>
131 #define RIPCMD_REQUEST 1 /* want info */
132 #define RIPCMD_RESPONSE 2 /* responding to request */
133 #define RIPCMD_TRACEON 3 /* turn tracing on */
134 #define RIPCMD_TRACEOFF 4 /* turn it off */
136 /* Gated extended RIP to include a "poll" command instead of using
137 * RIPCMD_REQUEST with (RIP_AF_UNSPEC, RIP_DEFAULT). RFC 1058 says
138 * command 5 is used by Sun Microsystems for its own purposes.
140 #define RIPCMD_POLL 5
145 char *ripcmds[RIPCMD_MAX] = {
146 "#0", "REQUEST", "RESPONSE", "TRACEON", "TRACEOFF"
150 #define HOPCNT_INFINITY 16
151 #define MAXPACKETSIZE 512 /* max broadcast size */
152 #define NETS_LEN ((MAXPACKETSIZE-sizeof(struct rip)) \
153 / sizeof(struct netinfo) +1)
155 #define INADDR_RIP_GROUP (u_int32_t)0xe0000009 /* 224.0.0.9 */
158 /* Timer values used in managing the routing table.
160 * Complete tables are broadcast every SUPPLY_INTERVAL seconds.
161 * If changes occur between updates, dynamic updates containing only changes
162 * may be sent. When these are sent, a timer is set for a random value
163 * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates
164 * are sent until the timer expires.
166 * Every update of a routing entry forces an entry's timer to be reset.
167 * After EXPIRE_TIME without updates, the entry is marked invalid,
168 * but held onto until GARBAGE_TIME so that others may see it, to
169 * "poison" the bad route.
171 #define SUPPLY_INTERVAL 30 /* time to supply tables */
172 #define MIN_WAITTIME 2 /* min sec until next flash updates */
173 #define MAX_WAITTIME 5 /* max sec until flash update */
175 #define STALE_TIME 90 /* switch to a new gateway */
176 #define EXPIRE_TIME 180 /* time to mark entry invalid */
177 #define GARBAGE_TIME 240 /* time to garbage collect */