4 * Copyright (c) 1998-2004 Hannes Gredler <hannes@tcpdump.org>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that: (1) source code
9 * distributions retain the above copyright notice and this paragraph
10 * in its entirety, and (2) distributions including binary code include
11 * the above copyright notice and this paragraph in its entirety in
12 * the documentation or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
14 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
15 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
16 * FOR A PARTICULAR PURPOSE.
19 #include <sys/cdefs.h>
22 static const char rcsid
[] _U_
=
23 "@(#) Header: /tcpdump/master/tcpdump/print-eigrp.c,v 1.5.2.2 2005/05/06 02:53:41 guy Exp";
25 __RCSID("$NetBSD: tcpdump2rcsid.ex,v 1.1 2001/06/25 20:09:58 itojun Exp $");
33 #include <tcpdump-stdinc.h>
39 #include "interface.h"
41 #include "addrtoname.h"
44 * packet format documented at
45 * http://www.rhyshaden.com/eigrp.htm
48 struct eigrp_common_header
{
58 #define EIGRP_VERSION 2
60 #define EIGRP_OPCODE_UPDATE 1
61 #define EIGRP_OPCODE_QUERY 3
62 #define EIGRP_OPCODE_REPLY 4
63 #define EIGRP_OPCODE_HELLO 5
64 #define EIGRP_OPCODE_IPXSAP 6
65 #define EIGRP_OPCODE_PROBE 7
67 static const struct tok eigrp_opcode_values
[] = {
68 { EIGRP_OPCODE_UPDATE
, "Update" },
69 { EIGRP_OPCODE_QUERY
, "Query" },
70 { EIGRP_OPCODE_REPLY
, "Reply" },
71 { EIGRP_OPCODE_HELLO
, "Hello" },
72 { EIGRP_OPCODE_IPXSAP
, "IPX SAP" },
73 { EIGRP_OPCODE_PROBE
, "Probe" },
77 static const struct tok eigrp_common_header_flag_values
[] = {
79 { 0x02, "Conditionally Received" },
83 struct eigrp_tlv_header
{
88 #define EIGRP_TLV_GENERAL_PARM 0x0001
89 #define EIGRP_TLV_AUTH 0x0002
90 #define EIGRP_TLV_SEQ 0x0003
91 #define EIGRP_TLV_SW_VERSION 0x0004
92 #define EIGRP_TLV_MCAST_SEQ 0x0005
93 #define EIGRP_TLV_IP_INT 0x0102
94 #define EIGRP_TLV_IP_EXT 0x0103
95 #define EIGRP_TLV_AT_INT 0x0202
96 #define EIGRP_TLV_AT_EXT 0x0203
97 #define EIGRP_TLV_AT_CABLE_SETUP 0x0204
98 #define EIGRP_TLV_IPX_INT 0x0302
99 #define EIGRP_TLV_IPX_EXT 0x0303
101 static const struct tok eigrp_tlv_values
[] = {
102 { EIGRP_TLV_GENERAL_PARM
, "General Parameters"},
103 { EIGRP_TLV_AUTH
, "Authentication"},
104 { EIGRP_TLV_SEQ
, "Sequence"},
105 { EIGRP_TLV_SW_VERSION
, "Software Version"},
106 { EIGRP_TLV_MCAST_SEQ
, "Next Multicast Sequence"},
107 { EIGRP_TLV_IP_INT
, "IP Internal routes"},
108 { EIGRP_TLV_IP_EXT
, "IP External routes"},
109 { EIGRP_TLV_AT_INT
, "AppleTalk Internal routes"},
110 { EIGRP_TLV_AT_EXT
, "AppleTalk External routes"},
111 { EIGRP_TLV_AT_CABLE_SETUP
, "AppleTalk Cable setup"},
112 { EIGRP_TLV_IPX_INT
, "IPX Internal routes"},
113 { EIGRP_TLV_IPX_EXT
, "IPX External routes"},
117 struct eigrp_tlv_general_parm_t
{
124 u_int8_t holdtime
[2];
127 struct eigrp_tlv_sw_version_t
{
130 u_int8_t eigrp_major
;
131 u_int8_t eigrp_minor
;
134 struct eigrp_tlv_ip_int_t
{
137 u_int8_t bandwidth
[4];
140 u_int8_t reliability
;
142 u_int8_t reserved
[2];
144 u_int8_t destination
; /* variable length [1-4] bytes encoding */
147 struct eigrp_tlv_ip_ext_t
{
149 u_int8_t origin_router
[4];
150 u_int8_t origin_as
[4];
153 u_int8_t reserved
[2];
157 u_int8_t bandwidth
[4];
160 u_int8_t reliability
;
162 u_int8_t reserved2
[2];
164 u_int8_t destination
; /* variable length [1-4] bytes encoding */
167 struct eigrp_tlv_at_cable_setup_t
{
168 u_int8_t cable_start
[2];
169 u_int8_t cable_end
[2];
170 u_int8_t router_id
[4];
173 struct eigrp_tlv_at_int_t
{
176 u_int8_t bandwidth
[4];
179 u_int8_t reliability
;
181 u_int8_t reserved
[2];
182 u_int8_t cable_start
[2];
183 u_int8_t cable_end
[2];
186 struct eigrp_tlv_at_ext_t
{
188 u_int8_t origin_router
[4];
189 u_int8_t origin_as
[4];
195 u_int8_t bandwidth
[4];
198 u_int8_t reliability
;
200 u_int8_t reserved2
[2];
201 u_int8_t cable_start
[2];
202 u_int8_t cable_end
[2];
205 static const struct tok eigrp_ext_proto_id_values
[] = {
216 { 0x0b, "Connected" },
221 eigrp_print(register const u_char
*pptr
, register u_int len
) {
223 const struct eigrp_common_header
*eigrp_com_header
;
224 const struct eigrp_tlv_header
*eigrp_tlv_header
;
225 const u_char
*tptr
,*tlv_tptr
;
226 u_int tlen
,eigrp_tlv_len
,eigrp_tlv_type
,tlv_tlen
, byte_length
, bit_length
;
230 const struct eigrp_tlv_general_parm_t
*eigrp_tlv_general_parm
;
231 const struct eigrp_tlv_sw_version_t
*eigrp_tlv_sw_version
;
232 const struct eigrp_tlv_ip_int_t
*eigrp_tlv_ip_int
;
233 const struct eigrp_tlv_ip_ext_t
*eigrp_tlv_ip_ext
;
234 const struct eigrp_tlv_at_cable_setup_t
*eigrp_tlv_at_cable_setup
;
235 const struct eigrp_tlv_at_int_t
*eigrp_tlv_at_int
;
236 const struct eigrp_tlv_at_ext_t
*eigrp_tlv_at_ext
;
240 eigrp_com_header
= (const struct eigrp_common_header
*)pptr
;
241 TCHECK(*eigrp_com_header
);
244 * Sanity checking of the header.
246 if (eigrp_com_header
->version
!= EIGRP_VERSION
) {
247 printf("EIGRP version %u packet not supported",eigrp_com_header
->version
);
251 /* in non-verbose mode just lets print the basic Message Type*/
253 printf("EIGRP %s, length: %u",
254 tok2str(eigrp_opcode_values
, "unknown (%u)",eigrp_com_header
->opcode
),
259 /* ok they seem to want to know everything - lets fully decode it */
261 tlen
=len
-sizeof(struct eigrp_common_header
);
263 /* FIXME print other header info */
264 printf("\n\tEIGRP v%u, opcode: %s (%u), chksum: 0x%04x, Flags: [%s]\n\tseq: 0x%08x, ack: 0x%08x, AS: %u, length: %u",
265 eigrp_com_header
->version
,
266 tok2str(eigrp_opcode_values
, "unknown, type: %u",eigrp_com_header
->opcode
),
267 eigrp_com_header
->opcode
,
268 EXTRACT_16BITS(&eigrp_com_header
->checksum
),
269 tok2str(eigrp_common_header_flag_values
,
271 EXTRACT_32BITS(&eigrp_com_header
->flags
)),
272 EXTRACT_32BITS(&eigrp_com_header
->seq
),
273 EXTRACT_32BITS(&eigrp_com_header
->ack
),
274 EXTRACT_32BITS(&eigrp_com_header
->asn
),
277 tptr
+=sizeof(const struct eigrp_common_header
);
280 /* did we capture enough for fully decoding the object header ? */
281 TCHECK2(*tptr
, sizeof(struct eigrp_tlv_header
));
283 eigrp_tlv_header
= (const struct eigrp_tlv_header
*)tptr
;
284 eigrp_tlv_len
=EXTRACT_16BITS(&eigrp_tlv_header
->length
);
285 eigrp_tlv_type
=EXTRACT_16BITS(&eigrp_tlv_header
->type
);
288 if (eigrp_tlv_len
< sizeof(struct eigrp_tlv_header
) ||
289 eigrp_tlv_len
> tlen
) {
290 print_unknown_data(tptr
+sizeof(sizeof(struct eigrp_tlv_header
)),"\n\t ",tlen
);
294 printf("\n\t %s TLV (0x%04x), length: %u",
295 tok2str(eigrp_tlv_values
,
301 tlv_tptr
=tptr
+sizeof(struct eigrp_tlv_header
);
302 tlv_tlen
=eigrp_tlv_len
-sizeof(struct eigrp_tlv_header
);
304 /* did we capture enough for fully decoding the object ? */
305 TCHECK2(*tptr
, eigrp_tlv_len
);
307 switch(eigrp_tlv_type
) {
309 case EIGRP_TLV_GENERAL_PARM
:
310 tlv_ptr
.eigrp_tlv_general_parm
= (const struct eigrp_tlv_general_parm_t
*)tlv_tptr
;
312 printf("\n\t holdtime: %us, k1 %u, k2 %u, k3 %u, k4 %u, k5 %u",
313 EXTRACT_16BITS(tlv_ptr
.eigrp_tlv_general_parm
->holdtime
),
314 tlv_ptr
.eigrp_tlv_general_parm
->k1
,
315 tlv_ptr
.eigrp_tlv_general_parm
->k2
,
316 tlv_ptr
.eigrp_tlv_general_parm
->k3
,
317 tlv_ptr
.eigrp_tlv_general_parm
->k4
,
318 tlv_ptr
.eigrp_tlv_general_parm
->k5
);
321 case EIGRP_TLV_SW_VERSION
:
322 tlv_ptr
.eigrp_tlv_sw_version
= (const struct eigrp_tlv_sw_version_t
*)tlv_tptr
;
324 printf("\n\t IOS version: %u.%u, EIGRP version %u.%u",
325 tlv_ptr
.eigrp_tlv_sw_version
->ios_major
,
326 tlv_ptr
.eigrp_tlv_sw_version
->ios_minor
,
327 tlv_ptr
.eigrp_tlv_sw_version
->eigrp_major
,
328 tlv_ptr
.eigrp_tlv_sw_version
->eigrp_minor
);
331 case EIGRP_TLV_IP_INT
:
332 tlv_ptr
.eigrp_tlv_ip_int
= (const struct eigrp_tlv_ip_int_t
*)tlv_tptr
;
334 bit_length
= tlv_ptr
.eigrp_tlv_ip_int
->plen
;
335 if (bit_length
> 32) {
336 printf("\n\t illegal prefix length %u",bit_length
);
339 byte_length
= (bit_length
+ 7) / 8; /* variable length encoding */
340 memset(prefix
, 0, 4);
341 memcpy(prefix
,&tlv_ptr
.eigrp_tlv_ip_int
->destination
,byte_length
);
343 printf("\n\t IPv4 prefix: %15s/%u, nexthop: ",
344 ipaddr_string(prefix
),
346 if (EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_ip_int
->nexthop
) == 0)
349 printf("%s",ipaddr_string(&tlv_ptr
.eigrp_tlv_ip_int
->nexthop
));
351 printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
352 (EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_ip_int
->delay
)/100),
353 EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_ip_int
->bandwidth
),
354 EXTRACT_24BITS(&tlv_ptr
.eigrp_tlv_ip_int
->mtu
),
355 tlv_ptr
.eigrp_tlv_ip_int
->hopcount
,
356 tlv_ptr
.eigrp_tlv_ip_int
->reliability
,
357 tlv_ptr
.eigrp_tlv_ip_int
->load
);
360 case EIGRP_TLV_IP_EXT
:
361 tlv_ptr
.eigrp_tlv_ip_ext
= (const struct eigrp_tlv_ip_ext_t
*)tlv_tptr
;
363 bit_length
= tlv_ptr
.eigrp_tlv_ip_ext
->plen
;
364 if (bit_length
> 32) {
365 printf("\n\t illegal prefix length %u",bit_length
);
368 byte_length
= (bit_length
+ 7) / 8; /* variable length encoding */
369 memset(prefix
, 0, 4);
370 memcpy(prefix
,&tlv_ptr
.eigrp_tlv_ip_ext
->destination
,byte_length
);
372 printf("\n\t IPv4 prefix: %15s/%u, nexthop: ",
373 ipaddr_string(prefix
),
375 if (EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_ip_ext
->nexthop
) == 0)
378 printf("%s",ipaddr_string(&tlv_ptr
.eigrp_tlv_ip_ext
->nexthop
));
380 printf("\n\t origin-router %s, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u",
381 ipaddr_string(tlv_ptr
.eigrp_tlv_ip_ext
->origin_router
),
382 EXTRACT_32BITS(tlv_ptr
.eigrp_tlv_ip_ext
->origin_as
),
383 tok2str(eigrp_ext_proto_id_values
,"unknown",tlv_ptr
.eigrp_tlv_ip_ext
->proto_id
),
384 tlv_ptr
.eigrp_tlv_ip_ext
->flags
,
385 EXTRACT_32BITS(tlv_ptr
.eigrp_tlv_ip_ext
->tag
),
386 EXTRACT_32BITS(tlv_ptr
.eigrp_tlv_ip_ext
->metric
));
388 printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
389 (EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_ip_ext
->delay
)/100),
390 EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_ip_ext
->bandwidth
),
391 EXTRACT_24BITS(&tlv_ptr
.eigrp_tlv_ip_ext
->mtu
),
392 tlv_ptr
.eigrp_tlv_ip_ext
->hopcount
,
393 tlv_ptr
.eigrp_tlv_ip_ext
->reliability
,
394 tlv_ptr
.eigrp_tlv_ip_ext
->load
);
397 case EIGRP_TLV_AT_CABLE_SETUP
:
398 tlv_ptr
.eigrp_tlv_at_cable_setup
= (const struct eigrp_tlv_at_cable_setup_t
*)tlv_tptr
;
400 printf("\n\t Cable-range: %u-%u, Router-ID %u",
401 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_cable_setup
->cable_start
),
402 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_cable_setup
->cable_end
),
403 EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_at_cable_setup
->router_id
));
406 case EIGRP_TLV_AT_INT
:
407 tlv_ptr
.eigrp_tlv_at_int
= (const struct eigrp_tlv_at_int_t
*)tlv_tptr
;
409 printf("\n\t Cable-Range: %u-%u, nexthop: ",
410 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_int
->cable_start
),
411 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_int
->cable_end
));
413 if (EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_at_int
->nexthop
) == 0)
417 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_int
->nexthop
),
418 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_int
->nexthop
[2]));
420 printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
421 (EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_at_int
->delay
)/100),
422 EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_at_int
->bandwidth
),
423 EXTRACT_24BITS(&tlv_ptr
.eigrp_tlv_at_int
->mtu
),
424 tlv_ptr
.eigrp_tlv_at_int
->hopcount
,
425 tlv_ptr
.eigrp_tlv_at_int
->reliability
,
426 tlv_ptr
.eigrp_tlv_at_int
->load
);
429 case EIGRP_TLV_AT_EXT
:
430 tlv_ptr
.eigrp_tlv_at_ext
= (const struct eigrp_tlv_at_ext_t
*)tlv_tptr
;
432 printf("\n\t Cable-Range: %u-%u, nexthop: ",
433 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_ext
->cable_start
),
434 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_ext
->cable_end
));
436 if (EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_at_ext
->nexthop
) == 0)
440 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_ext
->nexthop
),
441 EXTRACT_16BITS(&tlv_ptr
.eigrp_tlv_at_ext
->nexthop
[2]));
443 printf("\n\t origin-router %u, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u",
444 EXTRACT_32BITS(tlv_ptr
.eigrp_tlv_at_ext
->origin_router
),
445 EXTRACT_32BITS(tlv_ptr
.eigrp_tlv_at_ext
->origin_as
),
446 tok2str(eigrp_ext_proto_id_values
,"unknown",tlv_ptr
.eigrp_tlv_at_ext
->proto_id
),
447 tlv_ptr
.eigrp_tlv_at_ext
->flags
,
448 EXTRACT_32BITS(tlv_ptr
.eigrp_tlv_at_ext
->tag
),
449 EXTRACT_16BITS(tlv_ptr
.eigrp_tlv_at_ext
->metric
));
451 printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
452 (EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_at_ext
->delay
)/100),
453 EXTRACT_32BITS(&tlv_ptr
.eigrp_tlv_at_ext
->bandwidth
),
454 EXTRACT_24BITS(&tlv_ptr
.eigrp_tlv_at_ext
->mtu
),
455 tlv_ptr
.eigrp_tlv_at_ext
->hopcount
,
456 tlv_ptr
.eigrp_tlv_at_ext
->reliability
,
457 tlv_ptr
.eigrp_tlv_at_ext
->load
);
461 * FIXME those are the defined TLVs that lack a decoder
462 * you are welcome to contribute code ;-)
467 case EIGRP_TLV_MCAST_SEQ
:
468 case EIGRP_TLV_IPX_INT
:
469 case EIGRP_TLV_IPX_EXT
:
473 print_unknown_data(tlv_tptr
,"\n\t ",tlv_tlen
);
476 /* do we want to see an additionally hexdump ? */
478 print_unknown_data(tptr
+sizeof(sizeof(struct eigrp_tlv_header
)),"\n\t ",
479 eigrp_tlv_len
-sizeof(struct eigrp_tlv_header
));
486 printf("\n\t\t packet exceeded snapshot");