xref: /openbsd/usr.sbin/eigrpd/eigrp.h (revision e14e95d7)
1 /*	$OpenBSD: eigrp.h,v 1.6 2016/09/02 16:34:20 renato Exp $ */
2 
3 /*
4  * Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
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 /* EIGRP protocol definitions */
20 
21 #ifndef _EIGRP_H_
22 #define _EIGRP_H_
23 
24 /* misc */
25 #define EIGRP_VERSION		2
26 #define IPPROTO_EIGRP		88
27 #define EIGRP_IP_TTL		2
28 
29 /* EIGRP multicast group addresses */
30 #define AllEIGRPRouters_v4		"224.0.0.10"
31 #define AllEIGRPRouters_v6		"ff02::a"
32 
33 #define EIGRP_INFINITE_METRIC	((uint32_t )(~0))
34 
35 #define RTP_RTRNS_INTERVAL	5
36 #define RTP_RTRNS_MAX_ATTEMPTS	16
37 
38 #define RTP_ACK_TIMEOUT		100000
39 
40 #define EIGRP_VERSION_MAJOR	1
41 #define EIGRP_VERSION_MINOR	2
42 
43 #define EIGRP_MIN_AS		1
44 #define EIGRP_MAX_AS		65535
45 
46 #define DEFAULT_HELLO_INTERVAL	5
47 #define MIN_HELLO_INTERVAL	1
48 #define MAX_HELLO_INTERVAL	65535
49 
50 #define DEFAULT_HELLO_HOLDTIME	15
51 #define MIN_HELLO_HOLDTIME	1
52 #define MAX_HELLO_HOLDTIME	65535
53 
54 #define EIGRP_SCALING_FACTOR	256
55 
56 #define DEFAULT_DELAY		10
57 #define MIN_DELAY		1
58 #define MAX_DELAY		16777215
59 
60 #define DEFAULT_BANDWIDTH	100000
61 #define MIN_BANDWIDTH		1
62 #define MAX_BANDWIDTH		10000000
63 
64 #define DEFAULT_RELIABILITY	255
65 #define MIN_RELIABILITY		1
66 #define MAX_RELIABILITY		255
67 
68 #define DEFAULT_LOAD		1
69 #define MIN_LOAD		1
70 #define MAX_LOAD		255
71 
72 #define MIN_MTU			1
73 #define MAX_MTU			65535
74 
75 #define MIN_KVALUE		0
76 #define MAX_KVALUE		254
77 
78 #define DEFAULT_ACTIVE_TIMEOUT	3
79 #define MIN_ACTIVE_TIMEOUT	0
80 #define MAX_ACTIVE_TIMEOUT	65535
81 
82 #define DEFAULT_MAXIMUM_HOPS	100
83 #define MIN_MAXIMUM_HOPS	1
84 #define MAX_MAXIMUM_HOPS	255
85 
86 #define DEFAULT_MAXIMUM_PATHS	4
87 #define MIN_MAXIMUM_PATHS	1
88 #define MAX_MAXIMUM_PATHS	32
89 
90 #define DEFAULT_VARIANCE	1
91 #define MIN_VARIANCE		1
92 #define MAX_VARIANCE		128
93 
94 #define EIGRP_HEADER_VERSION	2
95 
96 #define EIGRP_VRID_UNICAST_AF	0x0000
97 #define EIGRP_VRID_MULTICAST_AF	0x0001
98 #define EIGRP_VRID_UNICAST_SF	0x8000
99 
100 /* EIGRP packet types */
101 #define EIGRP_OPC_UPDATE	1
102 #define EIGRP_OPC_REQUEST	2
103 #define EIGRP_OPC_QUERY		3
104 #define EIGRP_OPC_REPLY		4
105 #define EIGRP_OPC_HELLO		5
106 #define EIGRP_OPC_PROBE		7
107 #define EIGRP_OPC_SIAQUERY	10
108 #define EIGRP_OPC_SIAREPLY	11
109 
110 struct eigrp_hdr {
111 	uint8_t			version;
112 	uint8_t			opcode;
113 	uint16_t		chksum;
114 	uint32_t		flags;
115 	uint32_t		seq_num;
116 	uint32_t		ack_num;
117 	uint16_t		vrid;
118 	uint16_t		as;
119 };
120 /* EIGRP header flags */
121 #define EIGRP_HDR_FLAG_INIT	0x01
122 #define EIGRP_HDR_FLAG_CR	0x02
123 #define EIGRP_HDR_FLAG_RS	0x04
124 #define EIGRP_HDR_FLAG_EOT	0x08
125 
126 /* TLV record */
127 struct tlv {
128 	uint16_t		type;
129 	uint16_t		length;
130 };
131 #define	TLV_HDR_LEN		4
132 
133 struct tlv_parameter {
134 	uint16_t		type;
135 	uint16_t		length;
136 	uint8_t			kvalues[6];
137 	uint16_t		holdtime;
138 };
139 
140 struct tlv_sw_version {
141 	uint16_t		type;
142 	uint16_t		length;
143 	uint8_t			vendor_os_major;
144 	uint8_t			vendor_os_minor;
145 	uint8_t			eigrp_major;
146 	uint8_t			eigrp_minor;
147 };
148 
149 struct tlv_mcast_seq {
150 	uint16_t		type;
151 	uint16_t		length;
152 	uint32_t		seq;
153 };
154 
155 struct classic_metric {
156 	uint32_t		delay;
157 	uint32_t		bandwidth;
158 	uint8_t			mtu[3]; /* 3 bytes, yeah... */
159 	uint8_t			hop_count;
160 	uint8_t			reliability;
161 	uint8_t			load;
162 	uint8_t			tag;
163 	uint8_t			flags;
164 };
165 #define F_METRIC_SRC_WITHDRAW	0x01
166 #define F_METRIC_C_DEFAULT	0x02
167 #define F_METRIC_ACTIVE		0x04
168 
169 struct classic_emetric {
170 	uint32_t		routerid;
171 	uint32_t		as;
172 	uint32_t		tag;
173 	uint32_t		metric;
174 	uint16_t		reserved;
175 	uint8_t			protocol;
176 	uint8_t			flags;
177 };
178 
179 #define EIGRP_EXT_PROTO_IGRP	1
180 #define EIGRP_EXT_PROTO_EIGRP	2
181 #define EIGRP_EXT_PROTO_STATIC	3
182 #define EIGRP_EXT_PROTO_RIP	4
183 #define EIGRP_EXT_PROTO_HELLO	5
184 #define EIGRP_EXT_PROTO_OSPF	6
185 #define EIGRP_EXT_PROTO_ISIS	7
186 #define EIGRP_EXT_PROTO_EGP	8
187 #define EIGRP_EXT_PROTO_BGP	9
188 #define EIGRP_EXT_PROTO_IDRP	10
189 #define EIGRP_EXT_PROTO_CONN	11
190 
191 /* EIGRP TLV types (v1.2) */
192 #define TLV_PROTO_GENERAL	0x0000
193 #define TLV_PROTO_IPV4		0x0100
194 #define TLV_PROTO_IPV6		0x0400
195 #define TLV_PROTO_MASK		0xff00
196 
197 #define TLV_ROUTE_REQUEST	0x0001
198 #define TLV_ROUTE_INTERNAL	0x0002
199 #define TLV_ROUTE_EXTERNAL	0x0003
200 #define TLV_ROUTE_COMMUNITY	0x0004
201 
202 #define TLV_TYPE_PARAMETER	(TLV_PROTO_GENERAL | 0x0001)
203 #define TLV_TYPE_AUTH		(TLV_PROTO_GENERAL | 0x0002)
204 #define TLV_TYPE_SEQ		(TLV_PROTO_GENERAL | 0x0003)
205 #define TLV_TYPE_SW_VERSION	(TLV_PROTO_GENERAL | 0x0004)
206 #define TLV_TYPE_MCAST_SEQ	(TLV_PROTO_GENERAL | 0x0005)
207 #define TLV_TYPE_PEER_TERM	(TLV_PROTO_GENERAL | 0x0007)
208 #define TLV_TYPE_IPV4_REQUEST	(TLV_PROTO_IPV4 | TLV_ROUTE_REQUEST)
209 #define TLV_TYPE_IPV4_INTERNAL	(TLV_PROTO_IPV4 | TLV_ROUTE_INTERNAL)
210 #define TLV_TYPE_IPV4_EXTERNAL	(TLV_PROTO_IPV4 | TLV_ROUTE_EXTERNAL)
211 #define TLV_TYPE_IPV4_COMMUNITY	(TLV_PROTO_IPV4 | TLV_ROUTE_COMMUNITY)
212 #define TLV_TYPE_IPV6_REQUEST	(TLV_PROTO_IPV6 | TLV_ROUTE_REQUEST)
213 #define TLV_TYPE_IPV6_INTERNAL	(TLV_PROTO_IPV6 | TLV_ROUTE_INTERNAL)
214 #define TLV_TYPE_IPV6_EXTERNAL	(TLV_PROTO_IPV6 | TLV_ROUTE_EXTERNAL)
215 #define TLV_TYPE_IPV6_COMMUNITY	(TLV_PROTO_IPV6 | TLV_ROUTE_COMMUNITY)
216 #define TLV_TYPE_MASK		0x00ff
217 
218 /* TLV lengths */
219 #define TLV_TYPE_PARAMETER_LEN		0x000C
220 #define TLV_TYPE_SW_VERSION_LEN		0x0008
221 #define TLV_TYPE_MCAST_SEQ_LEN		0x0008
222 #define TLV_TYPE_IPV4_INT_MIN_LEN	0x0019
223 #define TLV_TYPE_IPV6_INT_MIN_LEN	0x0025
224 
225 #endif /* _EIGRP_H_ */
226