Subversion Repositories SvarDOS

Rev

Rev 616 | Details | Compare with Previous | Last modification | View Log | RSS feed

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