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