xref: /onnv-gate/usr/src/head/protocols/routed.h (revision 1676:37f4a3e2bd99)
10Sstevel@tonic-gate /*
2*1676Sjpk  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
30Sstevel@tonic-gate  * Use is subject to license terms.
40Sstevel@tonic-gate  */
50Sstevel@tonic-gate 
60Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
70Sstevel@tonic-gate /*	  All Rights Reserved  	*/
80Sstevel@tonic-gate 
90Sstevel@tonic-gate /*
100Sstevel@tonic-gate  * Copyright (c) 1983, 1989, 1993
110Sstevel@tonic-gate  *	The Regents of the University of California.  All rights reserved.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
140Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
150Sstevel@tonic-gate  * are met:
160Sstevel@tonic-gate  * 1. Redistributions of source code must retain the above copyright
170Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
180Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
190Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in the
200Sstevel@tonic-gate  *    documentation and/or other materials provided with the distribution.
210Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this software
220Sstevel@tonic-gate  *    must display the following acknowledgment:
230Sstevel@tonic-gate  *	This product includes software developed by the University of
240Sstevel@tonic-gate  *	California, Berkeley and its contributors.
250Sstevel@tonic-gate  * 4. Neither the name of the University nor the names of its contributors
260Sstevel@tonic-gate  *    may be used to endorse or promote products derived from this software
270Sstevel@tonic-gate  *    without specific prior written permission.
280Sstevel@tonic-gate  *
290Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
300Sstevel@tonic-gate  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
310Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
320Sstevel@tonic-gate  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
330Sstevel@tonic-gate  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
340Sstevel@tonic-gate  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
350Sstevel@tonic-gate  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
360Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
370Sstevel@tonic-gate  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
380Sstevel@tonic-gate  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
390Sstevel@tonic-gate  * SUCH DAMAGE.
400Sstevel@tonic-gate  */
410Sstevel@tonic-gate 
420Sstevel@tonic-gate /*
430Sstevel@tonic-gate  * Routing Information Protocol
440Sstevel@tonic-gate  *
450Sstevel@tonic-gate  * Derived from Xerox NS Routing Information Protocol
460Sstevel@tonic-gate  * by changing 32-bit net numbers to sockaddr's and
470Sstevel@tonic-gate  * padding stuff to 32-bit boundaries.
480Sstevel@tonic-gate  */
490Sstevel@tonic-gate 
500Sstevel@tonic-gate #ifndef _PROTOCOLS_ROUTED_H
510Sstevel@tonic-gate #define	_PROTOCOLS_ROUTED_H
520Sstevel@tonic-gate 
530Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
540Sstevel@tonic-gate 
550Sstevel@tonic-gate #ifdef	__cplusplus
560Sstevel@tonic-gate extern "C" {
570Sstevel@tonic-gate #endif
580Sstevel@tonic-gate 
590Sstevel@tonic-gate /* The RIPv2 protocol is described in RFC 2453 */
600Sstevel@tonic-gate 
610Sstevel@tonic-gate #define	RIPv1		1
620Sstevel@tonic-gate #define	RIPv2		2
630Sstevel@tonic-gate #ifndef RIPVERSION
640Sstevel@tonic-gate #define	RIPVERSION	RIPv1
650Sstevel@tonic-gate #endif
660Sstevel@tonic-gate 
670Sstevel@tonic-gate #define	RIP_PORT	520
680Sstevel@tonic-gate 
690Sstevel@tonic-gate #if RIPVERSION == RIPv1
700Sstevel@tonic-gate struct netinfo {
710Sstevel@tonic-gate 	struct	sockaddr rip_dst;	/* destination net/host */
720Sstevel@tonic-gate 	uint32_t   rip_metric;		/* cost of route */
730Sstevel@tonic-gate };
740Sstevel@tonic-gate #else
750Sstevel@tonic-gate struct netinfo {
760Sstevel@tonic-gate 	uint16_t   n_family;
770Sstevel@tonic-gate #define	RIP_AF_INET	htons(AF_INET)
780Sstevel@tonic-gate #define	    RIP_AF_UNSPEC   0
790Sstevel@tonic-gate #define	    RIP_AF_AUTH	    0xffff
800Sstevel@tonic-gate 	uint16_t   n_tag;		/* optional in RIPv2 */
810Sstevel@tonic-gate 	uint32_t   n_dst;		/* destination net or host */
820Sstevel@tonic-gate #define	    RIP_DEFAULT	    0
830Sstevel@tonic-gate 	uint32_t   n_mask;		/* netmask in RIPv2 */
840Sstevel@tonic-gate 	uint32_t   n_nhop;		/* optional next hop in RIPv2 */
850Sstevel@tonic-gate 	uint32_t   n_metric;		/* cost of route */
860Sstevel@tonic-gate };
870Sstevel@tonic-gate #endif /* RIPv1 */
880Sstevel@tonic-gate 
890Sstevel@tonic-gate /* RIPv2 authentication */
900Sstevel@tonic-gate struct netauth {
910Sstevel@tonic-gate 	uint16_t   a_family;		/* always RIP_AF_AUTH */
920Sstevel@tonic-gate 	uint16_t   a_type;
930Sstevel@tonic-gate #define	RIP_AUTH_NONE		0
940Sstevel@tonic-gate #define	RIP_AUTH_TRAILER	htons(1)	/* authentication data */
950Sstevel@tonic-gate #define	RIP_AUTH_PW		htons(2)	/* password type */
960Sstevel@tonic-gate #define	RIP_AUTH_MD5		htons(3)	/* Keyed MD5 */
970Sstevel@tonic-gate 	union {
980Sstevel@tonic-gate #define	    RIP_AUTH_PW_LEN 16
990Sstevel@tonic-gate 	    uint8_t    au_pw[RIP_AUTH_PW_LEN];
1000Sstevel@tonic-gate 	    struct a_md5 {
1010Sstevel@tonic-gate 		int16_t	md5_pkt_len;	/* RIP-II packet length */
1020Sstevel@tonic-gate 		int8_t	md5_keyid;	/* key ID and auth data len */
1030Sstevel@tonic-gate 		int8_t	md5_auth_len;	/* 16 */
1040Sstevel@tonic-gate 		uint32_t md5_seqno;	/* sequence number */
1050Sstevel@tonic-gate 		uint32_t rsvd[2];	/* must be 0 */
1060Sstevel@tonic-gate #define	    RIP_AUTH_MD5_LEN RIP_AUTH_PW_LEN
1070Sstevel@tonic-gate 	    } a_md5;
1080Sstevel@tonic-gate 	} au;
1090Sstevel@tonic-gate };
1100Sstevel@tonic-gate 
111*1676Sjpk struct rip_emetric {
112*1676Sjpk 	uint16_t	rip_metric;
113*1676Sjpk 	uint16_t	rip_mask;
114*1676Sjpk 	uint32_t	rip_token[1];
115*1676Sjpk };
116*1676Sjpk 
117*1676Sjpk struct rip_sec_entry {
118*1676Sjpk 	uint32_t	rip_dst;
119*1676Sjpk 	uint32_t	rip_count;
120*1676Sjpk 	struct rip_emetric rip_emetric[1];
121*1676Sjpk };
122*1676Sjpk 
1230Sstevel@tonic-gate struct rip {
1240Sstevel@tonic-gate 	uint8_t    rip_cmd;		/* request/response */
1250Sstevel@tonic-gate 	uint8_t    rip_vers;		/* protocol version # */
1260Sstevel@tonic-gate 	uint16_t   rip_res1;		/* pad to 32-bit boundary */
1270Sstevel@tonic-gate 	union {				/* variable length... */
1280Sstevel@tonic-gate 	    struct netinfo ru_nets[1];	/* variable length... */
1290Sstevel@tonic-gate 	    char    ru_tracefile[1];	/* ditto ... */
1300Sstevel@tonic-gate 	    struct netauth ru_auth[1];
131*1676Sjpk 	    struct {
132*1676Sjpk 		uint32_t rip_generation;
133*1676Sjpk 		struct rip_sec_entry rip_sec_entry[1];
134*1676Sjpk 	    } ru_tsol;
1350Sstevel@tonic-gate 	} ripun;
1360Sstevel@tonic-gate #define	rip_nets	ripun.ru_nets
1370Sstevel@tonic-gate #define	rip_tracefile	ripun.ru_tracefile
1380Sstevel@tonic-gate #define	rip_auths	ripun.ru_auth
139*1676Sjpk #define	rip_tsol	ripun.ru_tsol
1400Sstevel@tonic-gate };
1410Sstevel@tonic-gate 
1420Sstevel@tonic-gate struct entryinfo {
1430Sstevel@tonic-gate 	struct	sockaddr rtu_dst;
1440Sstevel@tonic-gate 	struct	sockaddr rtu_router;
1450Sstevel@tonic-gate 	short	rtu_flags;
1460Sstevel@tonic-gate 	short	rtu_state;
1470Sstevel@tonic-gate 	int	rtu_timer;
1480Sstevel@tonic-gate 	int	rtu_metric;
1490Sstevel@tonic-gate 	int	int_flags;
1500Sstevel@tonic-gate 	char	int_name[16];
1510Sstevel@tonic-gate };
1520Sstevel@tonic-gate 
1530Sstevel@tonic-gate /*
1540Sstevel@tonic-gate  * Packet types.
1550Sstevel@tonic-gate  */
1560Sstevel@tonic-gate #define	RIPCMD_REQUEST		1	/* want info - from suppliers */
1570Sstevel@tonic-gate #define	RIPCMD_RESPONSE		2	/* responding to request */
1580Sstevel@tonic-gate #define	RIPCMD_TRACEON		3	/* turn tracing on */
1590Sstevel@tonic-gate #define	RIPCMD_TRACEOFF		4	/* turn it off */
1600Sstevel@tonic-gate 
1610Sstevel@tonic-gate /*
1620Sstevel@tonic-gate  * Gated extended RIP to include a "poll" command instead of using
1630Sstevel@tonic-gate  * RIPCMD_REQUEST with (RIP_AF_UNSPEC, RIP_DEFAULT).  RFC 1058 says
1640Sstevel@tonic-gate  * command 5 is used by Sun Microsystems for its own purposes.
1650Sstevel@tonic-gate  */
1660Sstevel@tonic-gate #define	RIPCMD_POLL		5	/* like request, but anyone answers */
1670Sstevel@tonic-gate #define	RIPCMD_POLLENTRY	6	/* like poll, but for entire entry */
1680Sstevel@tonic-gate 
169*1676Sjpk #define	RIPCMD_SEC_RESPONSE	51	/* response includes E-metrics */
170*1676Sjpk #define	RIPCMD_SEC_T_RESPONSE	52	/* tunneling */
171*1676Sjpk 
1720Sstevel@tonic-gate #define	RIPCMD_MAX		7
1730Sstevel@tonic-gate 
1740Sstevel@tonic-gate #define	HOPCNT_INFINITY		16	/* per Xerox NS */
1750Sstevel@tonic-gate #define	MAXPACKETSIZE		512	/* max broadcast size */
1760Sstevel@tonic-gate #define	NETS_LEN ((MAXPACKETSIZE - sizeof (struct rip))	\
1770Sstevel@tonic-gate 	/ sizeof (struct netinfo) +1)
1780Sstevel@tonic-gate 
1790Sstevel@tonic-gate #define	INADDR_RIP_GROUP 0xe0000009U	/* 224.0.0.9 */
1800Sstevel@tonic-gate 
1810Sstevel@tonic-gate /*
1820Sstevel@tonic-gate  * Timer values used in managing the routing table.
1830Sstevel@tonic-gate  *
1840Sstevel@tonic-gate  * Complete tables are broadcast every SUPPLY_INTERVAL seconds.
1850Sstevel@tonic-gate  * If changes occur between updates, dynamic updates containing only changes
1860Sstevel@tonic-gate  * may be sent.  When these are sent, a timer is set for a random value
1870Sstevel@tonic-gate  * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates
1880Sstevel@tonic-gate  * are sent until the timer expires.
1890Sstevel@tonic-gate  *
1900Sstevel@tonic-gate  * Every update of a routing entry forces an entry's timer to be reset.
1910Sstevel@tonic-gate  * After EXPIRE_TIME without updates, the entry is marked invalid,
1920Sstevel@tonic-gate  * but held onto until GARBAGE_TIME so that others may see it, to
1930Sstevel@tonic-gate  * "poison" the bad route.
1940Sstevel@tonic-gate  */
1950Sstevel@tonic-gate #define	TIMER_RATE		30	/* alarm clocks every 30 seconds */
1960Sstevel@tonic-gate 
1970Sstevel@tonic-gate #define	SUPPLY_INTERVAL		30	/* time to supply tables */
1980Sstevel@tonic-gate #define	MIN_WAITTIME		2	/* min sec until next flash updates */
1990Sstevel@tonic-gate #define	MAX_WAITTIME		5	/* max sec until flash update */
2000Sstevel@tonic-gate 
2010Sstevel@tonic-gate #define	STALE_TIME		90	/* switch to a new gateway */
2020Sstevel@tonic-gate #define	EXPIRE_TIME		180	/* time to mark entry invalid */
2030Sstevel@tonic-gate #define	GARBAGE_TIME		300	/* time to garbage collect */
2040Sstevel@tonic-gate 
2050Sstevel@tonic-gate #ifdef	__cplusplus
2060Sstevel@tonic-gate }
2070Sstevel@tonic-gate #endif
2080Sstevel@tonic-gate 
2090Sstevel@tonic-gate #endif	/* _PROTOCOLS_ROUTED_H */
210