xref: /illumos-gate/usr/src/head/protocols/routed.h (revision b4203d75)
17c478bd9Sstevel@tonic-gate /*
245916cd2Sjpk  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
37c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
47c478bd9Sstevel@tonic-gate  */
57c478bd9Sstevel@tonic-gate 
67c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
77c478bd9Sstevel@tonic-gate /*	  All Rights Reserved	*/
87c478bd9Sstevel@tonic-gate 
97c478bd9Sstevel@tonic-gate /*
107c478bd9Sstevel@tonic-gate  * Copyright (c) 1983, 1989, 1993
117c478bd9Sstevel@tonic-gate  *	The Regents of the University of California.  All rights reserved.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
147c478bd9Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
157c478bd9Sstevel@tonic-gate  * are met:
167c478bd9Sstevel@tonic-gate  * 1. Redistributions of source code must retain the above copyright
177c478bd9Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
187c478bd9Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
197c478bd9Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in the
207c478bd9Sstevel@tonic-gate  *    documentation and/or other materials provided with the distribution.
217c478bd9Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this software
227c478bd9Sstevel@tonic-gate  *    must display the following acknowledgment:
237c478bd9Sstevel@tonic-gate  *	This product includes software developed by the University of
247c478bd9Sstevel@tonic-gate  *	California, Berkeley and its contributors.
257c478bd9Sstevel@tonic-gate  * 4. Neither the name of the University nor the names of its contributors
267c478bd9Sstevel@tonic-gate  *    may be used to endorse or promote products derived from this software
277c478bd9Sstevel@tonic-gate  *    without specific prior written permission.
287c478bd9Sstevel@tonic-gate  *
297c478bd9Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
307c478bd9Sstevel@tonic-gate  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
317c478bd9Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
327c478bd9Sstevel@tonic-gate  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
337c478bd9Sstevel@tonic-gate  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
347c478bd9Sstevel@tonic-gate  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
357c478bd9Sstevel@tonic-gate  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
367c478bd9Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
377c478bd9Sstevel@tonic-gate  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
387c478bd9Sstevel@tonic-gate  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
397c478bd9Sstevel@tonic-gate  * SUCH DAMAGE.
407c478bd9Sstevel@tonic-gate  */
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  * Routing Information Protocol
447c478bd9Sstevel@tonic-gate  *
457c478bd9Sstevel@tonic-gate  * Derived from Xerox NS Routing Information Protocol
467c478bd9Sstevel@tonic-gate  * by changing 32-bit net numbers to sockaddr's and
477c478bd9Sstevel@tonic-gate  * padding stuff to 32-bit boundaries.
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate #ifndef _PROTOCOLS_ROUTED_H
517c478bd9Sstevel@tonic-gate #define	_PROTOCOLS_ROUTED_H
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
547c478bd9Sstevel@tonic-gate extern "C" {
557c478bd9Sstevel@tonic-gate #endif
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /* The RIPv2 protocol is described in RFC 2453 */
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate #define	RIPv1		1
607c478bd9Sstevel@tonic-gate #define	RIPv2		2
617c478bd9Sstevel@tonic-gate #ifndef RIPVERSION
627c478bd9Sstevel@tonic-gate #define	RIPVERSION	RIPv1
637c478bd9Sstevel@tonic-gate #endif
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate #define	RIP_PORT	520
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate #if RIPVERSION == RIPv1
687c478bd9Sstevel@tonic-gate struct netinfo {
697c478bd9Sstevel@tonic-gate 	struct	sockaddr rip_dst;	/* destination net/host */
707c478bd9Sstevel@tonic-gate 	uint32_t   rip_metric;		/* cost of route */
717c478bd9Sstevel@tonic-gate };
727c478bd9Sstevel@tonic-gate #else
737c478bd9Sstevel@tonic-gate struct netinfo {
747c478bd9Sstevel@tonic-gate 	uint16_t   n_family;
757c478bd9Sstevel@tonic-gate #define	RIP_AF_INET	htons(AF_INET)
767c478bd9Sstevel@tonic-gate #define	    RIP_AF_UNSPEC   0
777c478bd9Sstevel@tonic-gate #define	    RIP_AF_AUTH	    0xffff
787c478bd9Sstevel@tonic-gate 	uint16_t   n_tag;		/* optional in RIPv2 */
797c478bd9Sstevel@tonic-gate 	uint32_t   n_dst;		/* destination net or host */
807c478bd9Sstevel@tonic-gate #define	    RIP_DEFAULT	    0
817c478bd9Sstevel@tonic-gate 	uint32_t   n_mask;		/* netmask in RIPv2 */
827c478bd9Sstevel@tonic-gate 	uint32_t   n_nhop;		/* optional next hop in RIPv2 */
837c478bd9Sstevel@tonic-gate 	uint32_t   n_metric;		/* cost of route */
847c478bd9Sstevel@tonic-gate };
857c478bd9Sstevel@tonic-gate #endif /* RIPv1 */
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate /* RIPv2 authentication */
887c478bd9Sstevel@tonic-gate struct netauth {
897c478bd9Sstevel@tonic-gate 	uint16_t   a_family;		/* always RIP_AF_AUTH */
907c478bd9Sstevel@tonic-gate 	uint16_t   a_type;
917c478bd9Sstevel@tonic-gate #define	RIP_AUTH_NONE		0
927c478bd9Sstevel@tonic-gate #define	RIP_AUTH_TRAILER	htons(1)	/* authentication data */
937c478bd9Sstevel@tonic-gate #define	RIP_AUTH_PW		htons(2)	/* password type */
947c478bd9Sstevel@tonic-gate #define	RIP_AUTH_MD5		htons(3)	/* Keyed MD5 */
957c478bd9Sstevel@tonic-gate 	union {
967c478bd9Sstevel@tonic-gate #define	    RIP_AUTH_PW_LEN 16
977c478bd9Sstevel@tonic-gate 	    uint8_t    au_pw[RIP_AUTH_PW_LEN];
987c478bd9Sstevel@tonic-gate 	    struct a_md5 {
997c478bd9Sstevel@tonic-gate 		int16_t	md5_pkt_len;	/* RIP-II packet length */
1007c478bd9Sstevel@tonic-gate 		int8_t	md5_keyid;	/* key ID and auth data len */
1017c478bd9Sstevel@tonic-gate 		int8_t	md5_auth_len;	/* 16 */
1027c478bd9Sstevel@tonic-gate 		uint32_t md5_seqno;	/* sequence number */
1037c478bd9Sstevel@tonic-gate 		uint32_t rsvd[2];	/* must be 0 */
1047c478bd9Sstevel@tonic-gate #define	    RIP_AUTH_MD5_LEN RIP_AUTH_PW_LEN
1057c478bd9Sstevel@tonic-gate 	    } a_md5;
1067c478bd9Sstevel@tonic-gate 	} au;
1077c478bd9Sstevel@tonic-gate };
1087c478bd9Sstevel@tonic-gate 
10945916cd2Sjpk struct rip_emetric {
11045916cd2Sjpk 	uint16_t	rip_metric;
11145916cd2Sjpk 	uint16_t	rip_mask;
11245916cd2Sjpk 	uint32_t	rip_token[1];
11345916cd2Sjpk };
11445916cd2Sjpk 
11545916cd2Sjpk struct rip_sec_entry {
11645916cd2Sjpk 	uint32_t	rip_dst;
11745916cd2Sjpk 	uint32_t	rip_count;
11845916cd2Sjpk 	struct rip_emetric rip_emetric[1];
11945916cd2Sjpk };
12045916cd2Sjpk 
1217c478bd9Sstevel@tonic-gate struct rip {
1227c478bd9Sstevel@tonic-gate 	uint8_t    rip_cmd;		/* request/response */
1237c478bd9Sstevel@tonic-gate 	uint8_t    rip_vers;		/* protocol version # */
1247c478bd9Sstevel@tonic-gate 	uint16_t   rip_res1;		/* pad to 32-bit boundary */
1257c478bd9Sstevel@tonic-gate 	union {				/* variable length... */
1267c478bd9Sstevel@tonic-gate 	    struct netinfo ru_nets[1];	/* variable length... */
1277c478bd9Sstevel@tonic-gate 	    char    ru_tracefile[1];	/* ditto ... */
1287c478bd9Sstevel@tonic-gate 	    struct netauth ru_auth[1];
12945916cd2Sjpk 	    struct {
13045916cd2Sjpk 		uint32_t rip_generation;
13145916cd2Sjpk 		struct rip_sec_entry rip_sec_entry[1];
13245916cd2Sjpk 	    } ru_tsol;
1337c478bd9Sstevel@tonic-gate 	} ripun;
1347c478bd9Sstevel@tonic-gate #define	rip_nets	ripun.ru_nets
1357c478bd9Sstevel@tonic-gate #define	rip_tracefile	ripun.ru_tracefile
1367c478bd9Sstevel@tonic-gate #define	rip_auths	ripun.ru_auth
13745916cd2Sjpk #define	rip_tsol	ripun.ru_tsol
1387c478bd9Sstevel@tonic-gate };
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate struct entryinfo {
1417c478bd9Sstevel@tonic-gate 	struct	sockaddr rtu_dst;
1427c478bd9Sstevel@tonic-gate 	struct	sockaddr rtu_router;
1437c478bd9Sstevel@tonic-gate 	short	rtu_flags;
1447c478bd9Sstevel@tonic-gate 	short	rtu_state;
1457c478bd9Sstevel@tonic-gate 	int	rtu_timer;
1467c478bd9Sstevel@tonic-gate 	int	rtu_metric;
1477c478bd9Sstevel@tonic-gate 	int	int_flags;
1487c478bd9Sstevel@tonic-gate 	char	int_name[16];
1497c478bd9Sstevel@tonic-gate };
1507c478bd9Sstevel@tonic-gate 
151*3173664eSapersson typedef struct rdisc_info_s {
152*3173664eSapersson 	uint_t  info_type;
153*3173664eSapersson 	uint_t  info_version;
154*3173664eSapersson 	uint_t	info_num_of_routers;
155*3173664eSapersson } rdisc_info_t;
156*3173664eSapersson 
157*3173664eSapersson /*
158*3173664eSapersson  * Structure that is returned with the default router info.
159*3173664eSapersson  */
160*3173664eSapersson typedef struct defr_s {
161*3173664eSapersson 	uint32_t	defr_info_type;
162*3173664eSapersson 	uint32_t	defr_version;
163*3173664eSapersson 	struct in_addr	defr_addr;
164*3173664eSapersson 	uint32_t	defr_index;
165*3173664eSapersson 	uint32_t	defr_life;
166*3173664eSapersson 	uint32_t	defr_pref;
167*3173664eSapersson } defr_t;
168*3173664eSapersson 
169*3173664eSapersson 
1707c478bd9Sstevel@tonic-gate /*
1717c478bd9Sstevel@tonic-gate  * Packet types.
1727c478bd9Sstevel@tonic-gate  */
1737c478bd9Sstevel@tonic-gate #define	RIPCMD_REQUEST		1	/* want info - from suppliers */
1747c478bd9Sstevel@tonic-gate #define	RIPCMD_RESPONSE		2	/* responding to request */
1757c478bd9Sstevel@tonic-gate #define	RIPCMD_TRACEON		3	/* turn tracing on */
1767c478bd9Sstevel@tonic-gate #define	RIPCMD_TRACEOFF		4	/* turn it off */
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate /*
1797c478bd9Sstevel@tonic-gate  * Gated extended RIP to include a "poll" command instead of using
1807c478bd9Sstevel@tonic-gate  * RIPCMD_REQUEST with (RIP_AF_UNSPEC, RIP_DEFAULT).  RFC 1058 says
1817c478bd9Sstevel@tonic-gate  * command 5 is used by Sun Microsystems for its own purposes.
1827c478bd9Sstevel@tonic-gate  */
1837c478bd9Sstevel@tonic-gate #define	RIPCMD_POLL		5	/* like request, but anyone answers */
1847c478bd9Sstevel@tonic-gate #define	RIPCMD_POLLENTRY	6	/* like poll, but for entire entry */
1857c478bd9Sstevel@tonic-gate 
18645916cd2Sjpk #define	RIPCMD_SEC_RESPONSE	51	/* response includes E-metrics */
18745916cd2Sjpk #define	RIPCMD_SEC_T_RESPONSE	52	/* tunneling */
18845916cd2Sjpk 
1897c478bd9Sstevel@tonic-gate #define	RIPCMD_MAX		7
1907c478bd9Sstevel@tonic-gate 
191*3173664eSapersson #define	RDISC_SNMP_SOCKET	"/var/run/in.rdisc_mib"
192*3173664eSapersson 
193*3173664eSapersson #define	RDISC_SNMP_INFO_REQ		1
194*3173664eSapersson #define	RDISC_SNMP_INFO_RESPONSE	2
195*3173664eSapersson #define	RDISC_DEF_ROUTER_INFO		3
196*3173664eSapersson 
197*3173664eSapersson #define	RDISC_SNMP_INFO_VER	1
198*3173664eSapersson #define	RDISC_DEF_ROUTER_VER	1
199*3173664eSapersson 
2007c478bd9Sstevel@tonic-gate #define	HOPCNT_INFINITY		16	/* per Xerox NS */
2017c478bd9Sstevel@tonic-gate #define	MAXPACKETSIZE		512	/* max broadcast size */
2027c478bd9Sstevel@tonic-gate #define	NETS_LEN ((MAXPACKETSIZE - sizeof (struct rip))	\
2037c478bd9Sstevel@tonic-gate 	/ sizeof (struct netinfo) +1)
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate #define	INADDR_RIP_GROUP 0xe0000009U	/* 224.0.0.9 */
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate /*
2087c478bd9Sstevel@tonic-gate  * Timer values used in managing the routing table.
2097c478bd9Sstevel@tonic-gate  *
2107c478bd9Sstevel@tonic-gate  * Complete tables are broadcast every SUPPLY_INTERVAL seconds.
2117c478bd9Sstevel@tonic-gate  * If changes occur between updates, dynamic updates containing only changes
2127c478bd9Sstevel@tonic-gate  * may be sent.  When these are sent, a timer is set for a random value
2137c478bd9Sstevel@tonic-gate  * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates
2147c478bd9Sstevel@tonic-gate  * are sent until the timer expires.
2157c478bd9Sstevel@tonic-gate  *
2167c478bd9Sstevel@tonic-gate  * Every update of a routing entry forces an entry's timer to be reset.
2177c478bd9Sstevel@tonic-gate  * After EXPIRE_TIME without updates, the entry is marked invalid,
2187c478bd9Sstevel@tonic-gate  * but held onto until GARBAGE_TIME so that others may see it, to
2197c478bd9Sstevel@tonic-gate  * "poison" the bad route.
2207c478bd9Sstevel@tonic-gate  */
2217c478bd9Sstevel@tonic-gate #define	TIMER_RATE		30	/* alarm clocks every 30 seconds */
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate #define	SUPPLY_INTERVAL		30	/* time to supply tables */
2247c478bd9Sstevel@tonic-gate #define	MIN_WAITTIME		2	/* min sec until next flash updates */
2257c478bd9Sstevel@tonic-gate #define	MAX_WAITTIME		5	/* max sec until flash update */
2267c478bd9Sstevel@tonic-gate 
2277c478bd9Sstevel@tonic-gate #define	STALE_TIME		90	/* switch to a new gateway */
2287c478bd9Sstevel@tonic-gate #define	EXPIRE_TIME		180	/* time to mark entry invalid */
2297c478bd9Sstevel@tonic-gate #define	GARBAGE_TIME		300	/* time to garbage collect */
2307c478bd9Sstevel@tonic-gate 
2317c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2327c478bd9Sstevel@tonic-gate }
2337c478bd9Sstevel@tonic-gate #endif
2347c478bd9Sstevel@tonic-gate 
2357c478bd9Sstevel@tonic-gate #endif	/* _PROTOCOLS_ROUTED_H */
236