2 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
10 * Copyright (c) 1983, 1989, 1993
11 * The Regents of the University of California. All rights reserved.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgment:
23 * This product includes software developed by the University of
24 * California, Berkeley and its contributors.
25 * 4. Neither the name of the University nor the names of its contributors
26 * may be used to endorse or promote products derived from this software
27 * without specific prior written permission.
29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 * Routing Information Protocol
45 * Derived from Xerox NS Routing Information Protocol
46 * by changing 32-bit net numbers to sockaddr's and
47 * padding stuff to 32-bit boundaries.
50 #ifndef _PROTOCOLS_ROUTED_H
51 #define _PROTOCOLS_ROUTED_H
53 #pragma ident "%Z%%M% %I% %E% SMI"
59 /* The RIPv2 protocol is described in RFC 2453 */
64 #define RIPVERSION RIPv1
69 #if RIPVERSION == RIPv1
71 struct sockaddr rip_dst
; /* destination net/host */
72 uint32_t rip_metric
; /* cost of route */
77 #define RIP_AF_INET htons(AF_INET)
78 #define RIP_AF_UNSPEC 0
79 #define RIP_AF_AUTH 0xffff
80 uint16_t n_tag
; /* optional in RIPv2 */
81 uint32_t n_dst
; /* destination net or host */
83 uint32_t n_mask
; /* netmask in RIPv2 */
84 uint32_t n_nhop
; /* optional next hop in RIPv2 */
85 uint32_t n_metric
; /* cost of route */
89 /* RIPv2 authentication */
91 uint16_t a_family
; /* always RIP_AF_AUTH */
93 #define RIP_AUTH_NONE 0
94 #define RIP_AUTH_TRAILER htons(1) /* authentication data */
95 #define RIP_AUTH_PW htons(2) /* password type */
96 #define RIP_AUTH_MD5 htons(3) /* Keyed MD5 */
98 #define RIP_AUTH_PW_LEN 16
99 uint8_t au_pw
[RIP_AUTH_PW_LEN
];
101 int16_t md5_pkt_len
; /* RIP-II packet length */
102 int8_t md5_keyid
; /* key ID and auth data len */
103 int8_t md5_auth_len
; /* 16 */
104 uint32_t md5_seqno
; /* sequence number */
105 uint32_t rsvd
[2]; /* must be 0 */
106 #define RIP_AUTH_MD5_LEN RIP_AUTH_PW_LEN
114 uint32_t rip_token
[1];
118 uint8_t rip_cmd
; /* request/response */
119 uint8_t rip_vers
; /* protocol version # */
120 uint16_t rip_res1
; /* pad to 32-bit boundary */
121 union { /* variable length... */
122 struct netinfo ru_nets
[1]; /* variable length... */
123 char ru_tracefile
[1]; /* ditto ... */
124 struct netauth ru_auth
[1];
126 #define rip_nets ripun.ru_nets
127 #define rip_tracefile ripun.ru_tracefile
128 #define rip_auths ripun.ru_auth
132 struct sockaddr rtu_dst
;
133 struct sockaddr rtu_router
;
142 typedef struct rdisc_info_s
{
145 uint_t info_num_of_routers
;
149 * Structure that is returned with the default router info.
151 typedef struct defr_s
{
152 uint32_t defr_info_type
;
153 uint32_t defr_version
;
154 struct in_addr defr_addr
;
164 #define RIPCMD_REQUEST 1 /* want info - from suppliers */
165 #define RIPCMD_RESPONSE 2 /* responding to request */
166 #define RIPCMD_TRACEON 3 /* turn tracing on */
167 #define RIPCMD_TRACEOFF 4 /* turn it off */
170 * Gated extended RIP to include a "poll" command instead of using
171 * RIPCMD_REQUEST with (RIP_AF_UNSPEC, RIP_DEFAULT). RFC 1058 says
172 * command 5 is used by Sun Microsystems for its own purposes.
174 #define RIPCMD_POLL 5 /* like request, but anyone answers */
175 #define RIPCMD_POLLENTRY 6 /* like poll, but for entire entry */
179 #define RDISC_SNMP_SOCKET "/var/run/in.rdisc_mib"
181 #define RDISC_SNMP_INFO_REQ 1
182 #define RDISC_SNMP_INFO_RESPONSE 2
183 #define RDISC_DEF_ROUTER_INFO 3
185 #define RDISC_SNMP_INFO_VER 1
186 #define RDISC_DEF_ROUTER_VER 1
188 #define HOPCNT_INFINITY 16 /* per Xerox NS */
189 #define MAXPACKETSIZE 512 /* max broadcast size */
190 #define NETS_LEN ((MAXPACKETSIZE - sizeof (struct rip)) \
191 / sizeof (struct netinfo) +1)
193 #define INADDR_RIP_GROUP 0xe0000009U /* 224.0.0.9 */
196 * Timer values used in managing the routing table.
198 * Complete tables are broadcast every SUPPLY_INTERVAL seconds.
199 * If changes occur between updates, dynamic updates containing only changes
200 * may be sent. When these are sent, a timer is set for a random value
201 * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates
202 * are sent until the timer expires.
204 * Every update of a routing entry forces an entry's timer to be reset.
205 * After EXPIRE_TIME without updates, the entry is marked invalid,
206 * but held onto until GARBAGE_TIME so that others may see it, to
207 * "poison" the bad route.
209 #define TIMER_RATE 30 /* alarm clocks every 30 seconds */
211 #define SUPPLY_INTERVAL 30 /* time to supply tables */
212 #define MIN_WAITTIME 2 /* min sec until next flash updates */
213 #define MAX_WAITTIME 5 /* max sec until flash update */
215 #define STALE_TIME 90 /* switch to a new gateway */
216 #define EXPIRE_TIME 180 /* time to mark entry invalid */
217 #define GARBAGE_TIME 300 /* time to garbage collect */
223 #endif /* _PROTOCOLS_ROUTED_H */