xref: /titanic_53/usr/src/head/protocols/routed.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
3*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
4*7c478bd9Sstevel@tonic-gate  */
5*7c478bd9Sstevel@tonic-gate 
6*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
7*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
8*7c478bd9Sstevel@tonic-gate 
9*7c478bd9Sstevel@tonic-gate /*
10*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1983, 1989, 1993
11*7c478bd9Sstevel@tonic-gate  *	The Regents of the University of California.  All rights reserved.
12*7c478bd9Sstevel@tonic-gate  *
13*7c478bd9Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
14*7c478bd9Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
15*7c478bd9Sstevel@tonic-gate  * are met:
16*7c478bd9Sstevel@tonic-gate  * 1. Redistributions of source code must retain the above copyright
17*7c478bd9Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
18*7c478bd9Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
19*7c478bd9Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in the
20*7c478bd9Sstevel@tonic-gate  *    documentation and/or other materials provided with the distribution.
21*7c478bd9Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this software
22*7c478bd9Sstevel@tonic-gate  *    must display the following acknowledgment:
23*7c478bd9Sstevel@tonic-gate  *	This product includes software developed by the University of
24*7c478bd9Sstevel@tonic-gate  *	California, Berkeley and its contributors.
25*7c478bd9Sstevel@tonic-gate  * 4. Neither the name of the University nor the names of its contributors
26*7c478bd9Sstevel@tonic-gate  *    may be used to endorse or promote products derived from this software
27*7c478bd9Sstevel@tonic-gate  *    without specific prior written permission.
28*7c478bd9Sstevel@tonic-gate  *
29*7c478bd9Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30*7c478bd9Sstevel@tonic-gate  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31*7c478bd9Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32*7c478bd9Sstevel@tonic-gate  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33*7c478bd9Sstevel@tonic-gate  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34*7c478bd9Sstevel@tonic-gate  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35*7c478bd9Sstevel@tonic-gate  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36*7c478bd9Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37*7c478bd9Sstevel@tonic-gate  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38*7c478bd9Sstevel@tonic-gate  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39*7c478bd9Sstevel@tonic-gate  * SUCH DAMAGE.
40*7c478bd9Sstevel@tonic-gate  */
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate /*
43*7c478bd9Sstevel@tonic-gate  * Routing Information Protocol
44*7c478bd9Sstevel@tonic-gate  *
45*7c478bd9Sstevel@tonic-gate  * Derived from Xerox NS Routing Information Protocol
46*7c478bd9Sstevel@tonic-gate  * by changing 32-bit net numbers to sockaddr's and
47*7c478bd9Sstevel@tonic-gate  * padding stuff to 32-bit boundaries.
48*7c478bd9Sstevel@tonic-gate  */
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate #ifndef _PROTOCOLS_ROUTED_H
51*7c478bd9Sstevel@tonic-gate #define	_PROTOCOLS_ROUTED_H
52*7c478bd9Sstevel@tonic-gate 
53*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
54*7c478bd9Sstevel@tonic-gate 
55*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
56*7c478bd9Sstevel@tonic-gate extern "C" {
57*7c478bd9Sstevel@tonic-gate #endif
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate /* The RIPv2 protocol is described in RFC 2453 */
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate #define	RIPv1		1
62*7c478bd9Sstevel@tonic-gate #define	RIPv2		2
63*7c478bd9Sstevel@tonic-gate #ifndef RIPVERSION
64*7c478bd9Sstevel@tonic-gate #define	RIPVERSION	RIPv1
65*7c478bd9Sstevel@tonic-gate #endif
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate #define	RIP_PORT	520
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate #if RIPVERSION == RIPv1
70*7c478bd9Sstevel@tonic-gate struct netinfo {
71*7c478bd9Sstevel@tonic-gate 	struct	sockaddr rip_dst;	/* destination net/host */
72*7c478bd9Sstevel@tonic-gate 	uint32_t   rip_metric;		/* cost of route */
73*7c478bd9Sstevel@tonic-gate };
74*7c478bd9Sstevel@tonic-gate #else
75*7c478bd9Sstevel@tonic-gate struct netinfo {
76*7c478bd9Sstevel@tonic-gate 	uint16_t   n_family;
77*7c478bd9Sstevel@tonic-gate #define	RIP_AF_INET	htons(AF_INET)
78*7c478bd9Sstevel@tonic-gate #define	    RIP_AF_UNSPEC   0
79*7c478bd9Sstevel@tonic-gate #define	    RIP_AF_AUTH	    0xffff
80*7c478bd9Sstevel@tonic-gate 	uint16_t   n_tag;		/* optional in RIPv2 */
81*7c478bd9Sstevel@tonic-gate 	uint32_t   n_dst;		/* destination net or host */
82*7c478bd9Sstevel@tonic-gate #define	    RIP_DEFAULT	    0
83*7c478bd9Sstevel@tonic-gate 	uint32_t   n_mask;		/* netmask in RIPv2 */
84*7c478bd9Sstevel@tonic-gate 	uint32_t   n_nhop;		/* optional next hop in RIPv2 */
85*7c478bd9Sstevel@tonic-gate 	uint32_t   n_metric;		/* cost of route */
86*7c478bd9Sstevel@tonic-gate };
87*7c478bd9Sstevel@tonic-gate #endif /* RIPv1 */
88*7c478bd9Sstevel@tonic-gate 
89*7c478bd9Sstevel@tonic-gate /* RIPv2 authentication */
90*7c478bd9Sstevel@tonic-gate struct netauth {
91*7c478bd9Sstevel@tonic-gate 	uint16_t   a_family;		/* always RIP_AF_AUTH */
92*7c478bd9Sstevel@tonic-gate 	uint16_t   a_type;
93*7c478bd9Sstevel@tonic-gate #define	RIP_AUTH_NONE		0
94*7c478bd9Sstevel@tonic-gate #define	RIP_AUTH_TRAILER	htons(1)	/* authentication data */
95*7c478bd9Sstevel@tonic-gate #define	RIP_AUTH_PW		htons(2)	/* password type */
96*7c478bd9Sstevel@tonic-gate #define	RIP_AUTH_MD5		htons(3)	/* Keyed MD5 */
97*7c478bd9Sstevel@tonic-gate 	union {
98*7c478bd9Sstevel@tonic-gate #define	    RIP_AUTH_PW_LEN 16
99*7c478bd9Sstevel@tonic-gate 	    uint8_t    au_pw[RIP_AUTH_PW_LEN];
100*7c478bd9Sstevel@tonic-gate 	    struct a_md5 {
101*7c478bd9Sstevel@tonic-gate 		int16_t	md5_pkt_len;	/* RIP-II packet length */
102*7c478bd9Sstevel@tonic-gate 		int8_t	md5_keyid;	/* key ID and auth data len */
103*7c478bd9Sstevel@tonic-gate 		int8_t	md5_auth_len;	/* 16 */
104*7c478bd9Sstevel@tonic-gate 		uint32_t md5_seqno;	/* sequence number */
105*7c478bd9Sstevel@tonic-gate 		uint32_t rsvd[2];	/* must be 0 */
106*7c478bd9Sstevel@tonic-gate #define	    RIP_AUTH_MD5_LEN RIP_AUTH_PW_LEN
107*7c478bd9Sstevel@tonic-gate 	    } a_md5;
108*7c478bd9Sstevel@tonic-gate 	} au;
109*7c478bd9Sstevel@tonic-gate };
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate struct rip {
112*7c478bd9Sstevel@tonic-gate 	uint8_t    rip_cmd;		/* request/response */
113*7c478bd9Sstevel@tonic-gate 	uint8_t    rip_vers;		/* protocol version # */
114*7c478bd9Sstevel@tonic-gate 	uint16_t   rip_res1;		/* pad to 32-bit boundary */
115*7c478bd9Sstevel@tonic-gate 	union {				/* variable length... */
116*7c478bd9Sstevel@tonic-gate 	    struct netinfo ru_nets[1];	/* variable length... */
117*7c478bd9Sstevel@tonic-gate 	    char    ru_tracefile[1];	/* ditto ... */
118*7c478bd9Sstevel@tonic-gate 	    struct netauth ru_auth[1];
119*7c478bd9Sstevel@tonic-gate 	} ripun;
120*7c478bd9Sstevel@tonic-gate #define	rip_nets	ripun.ru_nets
121*7c478bd9Sstevel@tonic-gate #define	rip_tracefile	ripun.ru_tracefile
122*7c478bd9Sstevel@tonic-gate #define	rip_auths	ripun.ru_auth
123*7c478bd9Sstevel@tonic-gate };
124*7c478bd9Sstevel@tonic-gate 
125*7c478bd9Sstevel@tonic-gate struct entryinfo {
126*7c478bd9Sstevel@tonic-gate 	struct	sockaddr rtu_dst;
127*7c478bd9Sstevel@tonic-gate 	struct	sockaddr rtu_router;
128*7c478bd9Sstevel@tonic-gate 	short	rtu_flags;
129*7c478bd9Sstevel@tonic-gate 	short	rtu_state;
130*7c478bd9Sstevel@tonic-gate 	int	rtu_timer;
131*7c478bd9Sstevel@tonic-gate 	int	rtu_metric;
132*7c478bd9Sstevel@tonic-gate 	int	int_flags;
133*7c478bd9Sstevel@tonic-gate 	char	int_name[16];
134*7c478bd9Sstevel@tonic-gate };
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate /*
137*7c478bd9Sstevel@tonic-gate  * Packet types.
138*7c478bd9Sstevel@tonic-gate  */
139*7c478bd9Sstevel@tonic-gate #define	RIPCMD_REQUEST		1	/* want info - from suppliers */
140*7c478bd9Sstevel@tonic-gate #define	RIPCMD_RESPONSE		2	/* responding to request */
141*7c478bd9Sstevel@tonic-gate #define	RIPCMD_TRACEON		3	/* turn tracing on */
142*7c478bd9Sstevel@tonic-gate #define	RIPCMD_TRACEOFF		4	/* turn it off */
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate /*
145*7c478bd9Sstevel@tonic-gate  * Gated extended RIP to include a "poll" command instead of using
146*7c478bd9Sstevel@tonic-gate  * RIPCMD_REQUEST with (RIP_AF_UNSPEC, RIP_DEFAULT).  RFC 1058 says
147*7c478bd9Sstevel@tonic-gate  * command 5 is used by Sun Microsystems for its own purposes.
148*7c478bd9Sstevel@tonic-gate  */
149*7c478bd9Sstevel@tonic-gate #define	RIPCMD_POLL		5	/* like request, but anyone answers */
150*7c478bd9Sstevel@tonic-gate #define	RIPCMD_POLLENTRY	6	/* like poll, but for entire entry */
151*7c478bd9Sstevel@tonic-gate 
152*7c478bd9Sstevel@tonic-gate #define	RIPCMD_MAX		7
153*7c478bd9Sstevel@tonic-gate 
154*7c478bd9Sstevel@tonic-gate #define	HOPCNT_INFINITY		16	/* per Xerox NS */
155*7c478bd9Sstevel@tonic-gate #define	MAXPACKETSIZE		512	/* max broadcast size */
156*7c478bd9Sstevel@tonic-gate #define	NETS_LEN ((MAXPACKETSIZE - sizeof (struct rip))	\
157*7c478bd9Sstevel@tonic-gate 	/ sizeof (struct netinfo) +1)
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate #define	INADDR_RIP_GROUP 0xe0000009U	/* 224.0.0.9 */
160*7c478bd9Sstevel@tonic-gate 
161*7c478bd9Sstevel@tonic-gate /*
162*7c478bd9Sstevel@tonic-gate  * Timer values used in managing the routing table.
163*7c478bd9Sstevel@tonic-gate  *
164*7c478bd9Sstevel@tonic-gate  * Complete tables are broadcast every SUPPLY_INTERVAL seconds.
165*7c478bd9Sstevel@tonic-gate  * If changes occur between updates, dynamic updates containing only changes
166*7c478bd9Sstevel@tonic-gate  * may be sent.  When these are sent, a timer is set for a random value
167*7c478bd9Sstevel@tonic-gate  * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates
168*7c478bd9Sstevel@tonic-gate  * are sent until the timer expires.
169*7c478bd9Sstevel@tonic-gate  *
170*7c478bd9Sstevel@tonic-gate  * Every update of a routing entry forces an entry's timer to be reset.
171*7c478bd9Sstevel@tonic-gate  * After EXPIRE_TIME without updates, the entry is marked invalid,
172*7c478bd9Sstevel@tonic-gate  * but held onto until GARBAGE_TIME so that others may see it, to
173*7c478bd9Sstevel@tonic-gate  * "poison" the bad route.
174*7c478bd9Sstevel@tonic-gate  */
175*7c478bd9Sstevel@tonic-gate #define	TIMER_RATE		30	/* alarm clocks every 30 seconds */
176*7c478bd9Sstevel@tonic-gate 
177*7c478bd9Sstevel@tonic-gate #define	SUPPLY_INTERVAL		30	/* time to supply tables */
178*7c478bd9Sstevel@tonic-gate #define	MIN_WAITTIME		2	/* min sec until next flash updates */
179*7c478bd9Sstevel@tonic-gate #define	MAX_WAITTIME		5	/* max sec until flash update */
180*7c478bd9Sstevel@tonic-gate 
181*7c478bd9Sstevel@tonic-gate #define	STALE_TIME		90	/* switch to a new gateway */
182*7c478bd9Sstevel@tonic-gate #define	EXPIRE_TIME		180	/* time to mark entry invalid */
183*7c478bd9Sstevel@tonic-gate #define	GARBAGE_TIME		300	/* time to garbage collect */
184*7c478bd9Sstevel@tonic-gate 
185*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
186*7c478bd9Sstevel@tonic-gate }
187*7c478bd9Sstevel@tonic-gate #endif
188*7c478bd9Sstevel@tonic-gate 
189*7c478bd9Sstevel@tonic-gate #endif	/* _PROTOCOLS_ROUTED_H */
190