xref: /openbsd/include/protocols/routed.h (revision df930be7)
1 /*	$NetBSD: routed.h,v 1.4 1995/06/20 22:22:04 christos Exp $	*/
2 
3 /*-
4  * Copyright (c) 1983, 1989 Regents of the University of California.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *	This product includes software developed by the University of
18  *	California, Berkeley and its contributors.
19  * 4. Neither the name of the University nor the names of its contributors
20  *    may be used to endorse or promote products derived from this software
21  *    without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  *	@(#)routed.h	5.3 (Berkeley) 4/3/91
36  */
37 
38 #ifndef _ROUTED_H_
39 #define	_ROUTED_H_
40 
41 /*
42  * Routing Information Protocol
43  *
44  * Derived from Xerox NS Routing Information Protocol
45  * by changing 32-bit net numbers to sockaddr's and
46  * padding stuff to 32-bit boundaries.
47  */
48 #define	RIP_VERSION_0	0
49 #define	RIP_VERSION_1	1
50 #define	RIP_VERSION_2	2
51 
52 struct netinfo {
53 	u_int16_t	rip_family;
54 	u_int16_t	rip_tag;
55 	u_int32_t	rip_dst;		/* destination net/host */
56 	/* Version 2 specific info */
57 	u_int32_t	rip_netmask;
58 	u_int32_t	rip_router;
59 	u_int32_t	rip_metric;		/* cost of route */
60 };
61 
62 struct rip {
63 	u_char	rip_cmd;		/* request/response */
64 	u_char	rip_vers;		/* protocol version # */
65 	u_char	rip_res1[2];		/* pad to 32-bit boundary */
66 	union {
67 		struct	netinfo ru_nets[1];	/* variable length... */
68 		char	ru_tracefile[1];	/* ditto ... */
69 	} ripun;
70 #define	rip_nets	ripun.ru_nets
71 #define	rip_tracefile	ripun.ru_tracefile
72 };
73 
74 /*
75  * Packet types.
76  */
77 #define	RIPCMD_REQUEST		1	/* want info */
78 #define	RIPCMD_RESPONSE		2	/* responding to request */
79 #define	RIPCMD_TRACEON		3	/* turn tracing on */
80 #define	RIPCMD_TRACEOFF		4	/* turn it off */
81 
82 #define	RIPCMD_MAX		5
83 #ifdef RIPCMDS
84 char *ripcmds[RIPCMD_MAX] =
85   { "#0", "REQUEST", "RESPONSE", "TRACEON", "TRACEOFF" };
86 #endif
87 
88 #define	HOPCNT_INFINITY		16	/* per Xerox NS */
89 #define	MAXPACKETSIZE		512	/* max broadcast size */
90 
91 /*
92  * Timer values used in managing the routing table.
93  * Complete tables are broadcast every SUPPLY_INTERVAL seconds.
94  * If changes occur between updates, dynamic updates containing only changes
95  * may be sent.  When these are sent, a timer is set for a random value
96  * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates
97  * are sent until the timer expires.
98  *
99  * Every update of a routing entry forces an entry's timer to be reset.
100  * After EXPIRE_TIME without updates, the entry is marked invalid,
101  * but held onto until GARBAGE_TIME so that others may
102  * see it "be deleted".
103  */
104 #define	TIMER_RATE		30	/* alarm clocks every 30 seconds */
105 
106 #define	SUPPLY_INTERVAL		30	/* time to supply tables */
107 #define	MIN_WAITTIME		2	/* min. interval to broadcast changes */
108 #define	MAX_WAITTIME		5	/* max. time to delay changes */
109 
110 #define	EXPIRE_TIME		180	/* time to mark entry invalid */
111 #define	GARBAGE_TIME		240	/* time to garbage collect */
112 
113 #endif /* !_ROUTED_H_ */
114