2 * Copyright (c) 1998-2004 Hannes Gredler <hannes@tcpdump.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code
7 * distributions retain the above copyright notice and this paragraph
8 * in its entirety, and (2) distributions including binary code include
9 * the above copyright notice and this paragraph in its entirety in
10 * the documentation or other materials provided with the distribution.
11 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
12 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
13 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 * FOR A PARTICULAR PURPOSE.
18 static const char rcsid
[] _U_
=
19 "@(#) $Header: /tcpdump/master/tcpdump/print-eigrp.c,v 1.5 2004-05-12 22:22:40 hannes Exp $";
26 #include <tcpdump-stdinc.h>
32 #include "interface.h"
34 #include "addrtoname.h"
37 * packet format documented at
38 * http://www.rhyshaden.com/eigrp.htm
41 struct eigrp_common_header
{
51 #define EIGRP_VERSION 2
53 #define EIGRP_OPCODE_UPDATE 1
54 #define EIGRP_OPCODE_QUERY 3
55 #define EIGRP_OPCODE_REPLY 4
56 #define EIGRP_OPCODE_HELLO 5
57 #define EIGRP_OPCODE_IPXSAP 6
58 #define EIGRP_OPCODE_PROBE 7
60 static const struct tok eigrp_opcode_values
[] = {
61 { EIGRP_OPCODE_UPDATE
, "Update" },
62 { EIGRP_OPCODE_QUERY
, "Query" },
63 { EIGRP_OPCODE_REPLY
, "Reply" },
64 { EIGRP_OPCODE_HELLO
, "Hello" },
65 { EIGRP_OPCODE_IPXSAP
, "IPX SAP" },
66 { EIGRP_OPCODE_PROBE
, "Probe" },
70 static const struct tok eigrp_common_header_flag_values
[] = {
72 { 0x02, "Conditionally Received" },
76 struct eigrp_tlv_header
{
81 #define EIGRP_TLV_GENERAL_PARM 0x0001
82 #define EIGRP_TLV_AUTH 0x0002
83 #define EIGRP_TLV_SEQ 0x0003
84 #define EIGRP_TLV_SW_VERSION 0x0004
85 #define EIGRP_TLV_MCAST_SEQ 0x0005
86 #define EIGRP_TLV_IP_INT 0x0102
87 #define EIGRP_TLV_IP_EXT 0x0103
88 #define EIGRP_TLV_AT_INT 0x0202
89 #define EIGRP_TLV_AT_EXT 0x0203
90 #define EIGRP_TLV_AT_CABLE_SETUP 0x0204
91 #define EIGRP_TLV_IPX_INT 0x0302
92 #define EIGRP_TLV_IPX_EXT 0x0303
94 static const struct tok eigrp_tlv_values
[] = {
95 { EIGRP_TLV_GENERAL_PARM
, "General Parameters"},
96 { EIGRP_TLV_AUTH
, "Authentication"},
97 { EIGRP_TLV_SEQ
, "Sequence"},
98 { EIGRP_TLV_SW_VERSION
, "Software Version"},
99 { EIGRP_TLV_MCAST_SEQ
, "Next Multicast Sequence"},
100 { EIGRP_TLV_IP_INT
, "IP Internal routes"},
101 { EIGRP_TLV_IP_EXT
, "IP External routes"},
102 { EIGRP_TLV_AT_INT
, "AppleTalk Internal routes"},
103 { EIGRP_TLV_AT_EXT
, "AppleTalk External routes"},
104 { EIGRP_TLV_AT_CABLE_SETUP
, "AppleTalk Cable setup"},
105 { EIGRP_TLV_IPX_INT
, "IPX Internal routes"},
106 { EIGRP_TLV_IPX_EXT
, "IPX External routes"},
110 struct eigrp_tlv_general_parm_t
{
117 u_int8_t holdtime
[2];
120 struct eigrp_tlv_sw_version_t
{
123 u_int8_t eigrp_major
;
124 u_int8_t eigrp_minor
;
127 struct eigrp_tlv_ip_int_t
{
130 u_int8_t bandwidth
[4];
133 u_int8_t reliability
;
135 u_int8_t reserved
[2];
137 u_int8_t destination
; /* variable length [1-4] bytes encoding */
140 struct eigrp_tlv_ip_ext_t
{
142 u_int8_t origin_router
[4];
143 u_int8_t origin_as
[4];
146 u_int8_t reserved
[2];
150 u_int8_t bandwidth
[4];
153 u_int8_t reliability
;
155 u_int8_t reserved2
[2];
157 u_int8_t destination
; /* variable length [1-4] bytes encoding */
160 struct eigrp_tlv_at_cable_setup_t
{
161 u_int8_t cable_start
[2];
162 u_int8_t cable_end
[2];
163 u_int8_t router_id
[4];
166 struct eigrp_tlv_at_int_t
{
169 u_int8_t bandwidth
[4];
172 u_int8_t reliability
;
174 u_int8_t reserved
[2];
175 u_int8_t cable_start
[2];
176 u_int8_t cable_end
[2];
179 struct eigrp_tlv_at_ext_t
{
181 u_int8_t origin_router
[4];
182 u_int8_t origin_as
[4];
188 u_int8_t bandwidth
[4];
191 u_int8_t reliability
;
193 u_int8_t reserved2
[2];
194 u_int8_t cable_start
[2];
195 u_int8_t cable_end
[2];
198 static const struct tok eigrp_ext_proto_id_values
[] = {
209 { 0x0b, "Connected" },
214 eigrp_print(register const u_char
*pptr
, register u_int len
) {
216 const struct eigrp_common_header
*eigrp_com_header
;
217 const struct eigrp_tlv_header
*eigrp_tlv_header
;
218 const u_char
*tptr
,*tlv_tptr
;
219 int tlen
,eigrp_tlv_len
,eigrp_tlv_type
,tlv_tlen
,byte_length
, bit_length
;
223 const struct eigrp_tlv_general_parm_t
*eigrp_tlv_general_parm
;
224 const struct eigrp_tlv_sw_version_t
*eigrp_tlv_sw_version
;
225 const struct eigrp_tlv_ip_int_t
*eigrp_tlv_ip_int
;
226 const struct eigrp_tlv_ip_ext_t
*eigrp_tlv_ip_ext
;
227 const struct eigrp_tlv_at_cable_setup_t
*eigrp_tlv_at_cable_setup
;
228 const struct eigrp_tlv_at_int_t
*eigrp_tlv_at_int
;
229 const struct eigrp_tlv_at_ext_t
*eigrp_tlv_at_ext
;
233 eigrp_com_header
= (const struct eigrp_common_header
*)pptr
;
234 TCHECK(*eigrp_com_header
);
237 * Sanity checking of the header.
239 if (eigrp_com_header
->version
!= EIGRP_VERSION
) {
240 printf("EIGRP version %u packet not supported",eigrp_com_header
->version
);
244 /* in non-verbose mode just lets print the basic Message Type*/
246 printf("EIGRP %s, length: %u",
247 tok2str(eigrp_opcode_values
, "unknown (%u)",eigrp_com_header
->opcode
),
252 /* ok they seem to want to know everything - lets fully decode it */
254 tlen
=len
-sizeof(struct eigrp_common_header
);
256 /* FIXME print other header info */
257 printf("\n\tEIGRP v%u, opcode: %s (%u), chksum: 0x%04x, Flags: [%s]\n\tseq: 0x%08x, ack: 0x%08x, AS: %u, length: %u",
258 eigrp_com_header
->version
,
259 tok2str(eigrp_opcode_values
, "unknown, type: %u",eigrp_com_header
->opcode
),
260 eigrp_com_header
->opcode
,
261 EXTRACT_16BITS(&eigrp_com_header
->checksum
),
262 tok2str(eigrp_common_header_flag_values
,
264 EXTRACT_32BITS(&eigrp_com_header
->flags
)),
265 EXTRACT_32BITS(&eigrp_com_header
->seq
),
266 EXTRACT_32BITS(&eigrp_com_header
->ack
),
267 EXTRACT_32BITS(&eigrp_com_header
->asn
),
270 tptr
+=sizeof(const struct eigrp_common_header
);
273 /* did we capture enough for fully decoding the object header ? */
274 if (!TTEST2(*tptr
, sizeof(struct eigrp_tlv_header
)))
277 eigrp_tlv_header
= (const struct eigrp_tlv_header
*)tptr
;
278 eigrp_tlv_len
=EXTRACT_16BITS(&eigrp_tlv_header
->length
);
279 eigrp_tlv_type
=EXTRACT_16BITS(&eigrp_tlv_header
->type
);
282 if (eigrp_tlv_len
== 0 || eigrp_tlv_len
> tlen
) {
283 print_unknown_data(tptr
+sizeof(sizeof(struct eigrp_tlv_header
)),"\n\t ",tlen
);
287 printf("\n\t %s TLV (0x%04x), length: %u",
288 tok2str(eigrp_tlv_values
,
294 tlv_tptr
=tptr
+sizeof(struct eigrp_tlv_header
);
295 tlv_tlen
=eigrp_tlv_len
-sizeof(struct eigrp_tlv_header
);
297 /* did we capture enough for fully decoding the object ? */
298 if (!TTEST2(*tptr
, eigrp_tlv_len
))
301 switch(eigrp_tlv_type
) {
303 case EIGRP_TLV_GENERAL_PARM
:
304 tlv_ptr
.eigrp_tlv_general_parm
= (const struct eigrp_tlv_general_parm_t
*)tlv_tptr
;
306 printf("\n\t holdtime: %us, k1 %u, k2 %u, k3 %u, k4 %u, k5 %u",
307 EXTRACT_16BITS(tlv_ptr
.eigrp_tlv_general_parm
->holdtime
),
308 tlv_ptr
.eigrp_tlv_general_parm
->k1
,
309 tlv_ptr
.eigrp_tlv_general_parm
->k2
,
310 tlv_ptr
.eigrp_tlv_general_parm
->k3
,
311 tlv_ptr
.eigrp_tlv_general_parm
->k4
,
312 tlv_ptr
.eigrp_tlv_general_parm
->k5
);
315 case EIGRP_TLV_SW_VERSION
:
316 tlv_ptr
.eigrp_tlv_sw_version
= (const struct eigrp_tlv_sw_version_t
*)tlv_tptr
;
318 printf("\n\t IOS version: %u.%u, EIGRP version %u.%u",
319 tlv_ptr
.eigrp_tlv_sw_version
->ios_major
,
320 tlv_ptr
.eigrp_tlv_sw_version
->ios_minor
,
321 tlv_ptr
.eigrp_tlv_sw_version
->eigrp_major
,
322 tlv_ptr
.eigrp_tlv_sw_version
->eigrp_minor
);
325 case EIGRP_TLV_IP_INT
:
326 tlv_ptr
.eigrp_tlv_ip_int
= (const struct eigrp_tlv_ip_int_t
*)tlv_tptr
;
328 bit_length
= tlv_ptr
.eigrp_tlv_ip_int
->plen
;
329 if (bit_length
< 0 || bit_length
> 32) {
330 printf("\n\t illegal prefix length %u",bit_length
);
333 byte_length
= (bit_length
+ 7) / 8; /* variable length encoding */
334 memset(prefix
, 0, 4);
335 memcpy(prefix
,&tlv_ptr
.eigrp_tlv_ip_int
->destination
,byte_length
);
337 printf("\n\t IPv4 prefix: %15s/%u, nexthop: ",
338 ipaddr_string(prefix
),
340 if (EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_ip_int
->nexthop
) == 0)
343 printf("%s",ipaddr_string(EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_ip_int
->nexthop
)));
345 printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
346 (EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_ip_int
->delay
)/100),
347 EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_ip_int
->bandwidth
),
348 EXTRACT_24BITS(&tlv_ptr
.eigrp_tlv_ip_int
->mtu
),
349 tlv_ptr
.eigrp_tlv_ip_int
->hopcount
,
350 tlv_ptr
.eigrp_tlv_ip_int
->reliability
,
351 tlv_ptr
.eigrp_tlv_ip_int
->load
);
354 case EIGRP_TLV_IP_EXT
:
355 tlv_ptr
.eigrp_tlv_ip_ext
= (const struct eigrp_tlv_ip_ext_t
*)tlv_tptr
;
357 bit_length
= tlv_ptr
.eigrp_tlv_ip_ext
->plen
;
358 if (bit_length
< 0 || bit_length
> 32) {
359 printf("\n\t illegal prefix length %u",bit_length
);
362 byte_length
= (bit_length
+ 7) / 8; /* variable length encoding */
363 memset(prefix
, 0, 4);
364 memcpy(prefix
,&tlv_ptr
.eigrp_tlv_ip_ext
->destination
,byte_length
);
366 printf("\n\t IPv4 prefix: %15s/%u, nexthop: ",
367 ipaddr_string(prefix
),
369 if (EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_ip_ext
->nexthop
) == 0)
372 printf("%s",ipaddr_string(EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_ip_ext
->nexthop
)));
374 printf("\n\t origin-router %s, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u",
375 ipaddr_string(tlv_ptr
.eigrp_tlv_ip_ext
->origin_router
),
376 EXTRACT_32BITS(tlv_ptr
.eigrp_tlv_ip_ext
->origin_as
),
377 tok2str(eigrp_ext_proto_id_values
,"unknown",tlv_ptr
.eigrp_tlv_ip_ext
->proto_id
),
378 tlv_ptr
.eigrp_tlv_ip_ext
->flags
,
379 EXTRACT_32BITS(tlv_ptr
.eigrp_tlv_ip_ext
->tag
),
380 EXTRACT_32BITS(tlv_ptr
.eigrp_tlv_ip_ext
->metric
));
382 printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
383 (EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_ip_ext
->delay
)/100),
384 EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_ip_ext
->bandwidth
),
385 EXTRACT_24BITS(&tlv_ptr
.eigrp_tlv_ip_ext
->mtu
),
386 tlv_ptr
.eigrp_tlv_ip_ext
->hopcount
,
387 tlv_ptr
.eigrp_tlv_ip_ext
->reliability
,
388 tlv_ptr
.eigrp_tlv_ip_ext
->load
);
391 case EIGRP_TLV_AT_CABLE_SETUP
:
392 tlv_ptr
.eigrp_tlv_at_cable_setup
= (const struct eigrp_tlv_at_cable_setup_t
*)tlv_tptr
;
394 printf("\n\t Cable-range: %u-%u, Router-ID %u",
395 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_cable_setup
->cable_start
),
396 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_cable_setup
->cable_end
),
397 EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_at_cable_setup
->router_id
));
400 case EIGRP_TLV_AT_INT
:
401 tlv_ptr
.eigrp_tlv_at_int
= (const struct eigrp_tlv_at_int_t
*)tlv_tptr
;
403 printf("\n\t Cable-Range: %u-%u, nexthop: ",
404 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_int
->cable_start
),
405 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_int
->cable_end
));
407 if (EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_at_int
->nexthop
) == 0)
411 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_int
->nexthop
),
412 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_int
->nexthop
[2]));
414 printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
415 (EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_at_int
->delay
)/100),
416 EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_at_int
->bandwidth
),
417 EXTRACT_24BITS(&tlv_ptr
.eigrp_tlv_at_int
->mtu
),
418 tlv_ptr
.eigrp_tlv_at_int
->hopcount
,
419 tlv_ptr
.eigrp_tlv_at_int
->reliability
,
420 tlv_ptr
.eigrp_tlv_at_int
->load
);
423 case EIGRP_TLV_AT_EXT
:
424 tlv_ptr
.eigrp_tlv_at_ext
= (const struct eigrp_tlv_at_ext_t
*)tlv_tptr
;
426 printf("\n\t Cable-Range: %u-%u, nexthop: ",
427 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_ext
->cable_start
),
428 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_ext
->cable_end
));
430 if (EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_at_ext
->nexthop
) == 0)
434 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_ext
->nexthop
),
435 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_ext
->nexthop
[2]));
437 printf("\n\t origin-router %u, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u",
438 EXTRACT_32BITS(tlv_ptr
.eigrp_tlv_at_ext
->origin_router
),
439 EXTRACT_32BITS(tlv_ptr
.eigrp_tlv_at_ext
->origin_as
),
440 tok2str(eigrp_ext_proto_id_values
,"unknown",tlv_ptr
.eigrp_tlv_at_ext
->proto_id
),
441 tlv_ptr
.eigrp_tlv_at_ext
->flags
,
442 EXTRACT_32BITS(tlv_ptr
.eigrp_tlv_at_ext
->tag
),
443 EXTRACT_16BITS(tlv_ptr
.eigrp_tlv_at_ext
->metric
));
445 printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
446 (EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_at_ext
->delay
)/100),
447 EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_at_ext
->bandwidth
),
448 EXTRACT_24BITS(&tlv_ptr
.eigrp_tlv_at_ext
->mtu
),
449 tlv_ptr
.eigrp_tlv_at_ext
->hopcount
,
450 tlv_ptr
.eigrp_tlv_at_ext
->reliability
,
451 tlv_ptr
.eigrp_tlv_at_ext
->load
);
455 * FIXME those are the defined TLVs that lack a decoder
456 * you are welcome to contribute code ;-)
461 case EIGRP_TLV_MCAST_SEQ
:
462 case EIGRP_TLV_IPX_INT
:
463 case EIGRP_TLV_IPX_EXT
:
467 print_unknown_data(tlv_tptr
,"\n\t ",tlv_tlen
);
470 /* do we want to see an additionally hexdump ? */
472 print_unknown_data(tptr
+sizeof(sizeof(struct eigrp_tlv_header
)),"\n\t ",
473 eigrp_tlv_len
-sizeof(struct eigrp_tlv_header
));
480 printf("\n\t\t packet exceeded snapshot");