1/*	$OpenBSD: rip.h,v 1.4 2007/10/18 17:00:59 deraadt Exp $ */
2
3/*
4 * Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/* RIP protocol definitions */
20
21#ifndef	_RIP_H_
22#define	_RIP_H_
23
24/* misc */
25#define	RIP_VERSION		2
26#define ALL_RIP_ROUTERS		"224.0.0.9"
27#define	RIP_PORT		520
28
29#define	MIN_MD_ID		0
30#define	MAX_MD_ID		255
31
32/* metric */
33#define	INFINITY		16
34#define	DEFAULT_COST		1
35
36/* timers */
37#define	KEEPALIVE		30
38#define	OFFSET			10
39#define	FAILED_NBR_TIMEOUT	86400
40
41#define MAX_RIP_ENTRIES		25
42
43/* RIP command */
44#define	COMMAND_REQUEST		1
45#define	COMMAND_RESPONSE	2
46
47#define	RIP_HDR_LEN		sizeof(struct rip_hdr)
48#define	RIP_ENTRY_LEN		sizeof(struct rip_entry)
49
50struct rip_hdr {
51	u_int8_t	command;
52	u_int8_t	version;
53	u_int16_t	dummy;
54};
55
56struct rip_entry {
57	u_int16_t	AFI;
58	u_int16_t	route_tag;
59	u_int32_t	address;
60	u_int32_t	mask;
61	u_int32_t	nexthop;
62	u_int32_t	metric;
63};
64
65/* auth */
66#define AUTH			0xFFFF
67#define	AUTH_TRLR_HDR_LEN	4
68
69/* auth general struct */
70struct rip_auth {
71	u_int16_t	 auth_fixed;
72	u_int16_t	 auth_type;
73};
74
75/* Keyed MD5 auth struct */
76struct md5_auth {
77	u_int16_t	 auth_offset;
78	u_int8_t	 auth_keyid;
79	u_int8_t	 auth_length;
80	u_int32_t	 auth_seq;
81	u_int64_t	 auth_reserved;
82};
83
84#endif /* _RIP_H_ */
85