]>
The Tcpdump Group git mirrors - tcpdump/blob - print-eigrp.c
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.1 2004-04-30 22:22:04 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 struct eigrp_tlv_header
{
75 #define EIGRP_TLV_GENERAL_PARM 0x0001
76 #define EIGRP_TLV_SEQ 0x0003
77 #define EIGRP_TLV_SW_VERSION 0x0004
78 #define EIGRP_TLV_MCAST_SEQ 0x0005
79 #define EIGRP_TLV_IP_INT 0x0102
80 #define EIGRP_TLV_IP_EXT 0x0103
81 #define EIGRP_TLV_AT_INT 0x0202
82 #define EIGRP_TLV_AT_EXT 0x0203
83 #define EIGRP_TLV_AT_CABLE_SETUP 0x0204
84 #define EIGRP_TLV_IPX_INT 0x0302
85 #define EIGRP_TLV_IPX_EXT 0x0303
87 static const struct tok eigrp_tlv_values
[] = {
88 { EIGRP_TLV_GENERAL_PARM
, "General Parameters"},
89 { EIGRP_TLV_SEQ
, "Sequence"},
90 { EIGRP_TLV_SW_VERSION
, "Software Version"},
91 { EIGRP_TLV_MCAST_SEQ
, "Next Multicast Sequence"},
92 { EIGRP_TLV_IP_INT
, "IP Internal routes"},
93 { EIGRP_TLV_IP_EXT
, "IP External routes"},
94 { EIGRP_TLV_AT_INT
, "AppleTalk Internal routes"},
95 { EIGRP_TLV_AT_EXT
, "AppleTalk External routes"},
96 { EIGRP_TLV_AT_CABLE_SETUP
, "AppleTalk Cable setup"},
97 { EIGRP_TLV_IPX_INT
, "IPX Internal routes"},
98 { EIGRP_TLV_IPX_EXT
, "IPX External routes"},
103 eigrp_print(register const u_char
*pptr
, register u_int len
) {
105 const struct eigrp_common_header
*eigrp_com_header
;
106 const struct eigrp_tlv_header
*eigrp_tlv_header
;
107 const u_char
*tptr
,*obj_tptr
;
108 int tlen
,eigrp_tlv_len
,eigrp_tlv_type
,obj_tlen
;
111 eigrp_com_header
= (const struct eigrp_common_header
*)pptr
;
112 TCHECK(*eigrp_com_header
);
115 * Sanity checking of the header.
117 if (eigrp_com_header
->version
!= EIGRP_VERSION
) {
118 printf("EIGRP version %u packet not supported",eigrp_com_header
->version
);
122 /* in non-verbose mode just lets print the basic Message Type*/
124 printf("EIGRP %s, length: %u",
125 tok2str(eigrp_opcode_values
, "unknown (%u)",eigrp_com_header
->opcode
),
130 /* ok they seem to want to know everything - lets fully decode it */
132 tlen
=len
-sizeof(struct eigrp_common_header
);
134 /* FIXME print other header info */
135 printf("\n\tEIGRP v%u, opcode: %s (%u), chksum: 0x%04x, Flags: [0x%08x]\n\tseq: 0x%08x, ack: 0x%08x, AS: %u, length: %u",
136 eigrp_com_header
->version
,
137 tok2str(eigrp_opcode_values
, "unknown, type: %u",eigrp_com_header
->opcode
),
138 eigrp_com_header
->opcode
,
139 EXTRACT_16BITS(&eigrp_com_header
->checksum
),
140 EXTRACT_32BITS(&eigrp_com_header
->flags
),
141 EXTRACT_32BITS(&eigrp_com_header
->seq
),
142 EXTRACT_32BITS(&eigrp_com_header
->ack
),
143 EXTRACT_32BITS(&eigrp_com_header
->asn
),
146 tptr
+=sizeof(const struct eigrp_common_header
);
149 /* did we capture enough for fully decoding the object header ? */
150 if (!TTEST2(*tptr
, sizeof(struct eigrp_tlv_header
)))
153 eigrp_tlv_header
= (const struct eigrp_tlv_header
*)tptr
;
154 eigrp_tlv_len
=EXTRACT_16BITS(&eigrp_tlv_header
->length
);
155 eigrp_tlv_type
=EXTRACT_16BITS(&eigrp_tlv_header
->type
);
158 if (eigrp_tlv_len
== 0 || eigrp_tlv_len
> tlen
) {
159 print_unknown_data(tptr
+sizeof(sizeof(struct eigrp_tlv_header
)),"\n\t ",tlen
);
163 printf("\n\t %s TLV (0x%04x), length: %u",
164 tok2str(eigrp_tlv_values
,
170 obj_tptr
=tptr
+sizeof(struct eigrp_tlv_header
);
171 obj_tlen
=eigrp_tlv_len
-sizeof(struct eigrp_tlv_header
);
173 /* did we capture enough for fully decoding the object ? */
174 if (!TTEST2(*tptr
, eigrp_tlv_len
))
177 switch(eigrp_tlv_type
) {
180 * FIXME those are the defined TLVs that lack a decoder
181 * you are welcome to contribute code ;-)
184 case EIGRP_TLV_GENERAL_PARM
:
186 case EIGRP_TLV_SW_VERSION
:
187 case EIGRP_TLV_MCAST_SEQ
:
188 case EIGRP_TLV_IP_INT
:
189 case EIGRP_TLV_IP_EXT
:
190 case EIGRP_TLV_AT_INT
:
191 case EIGRP_TLV_AT_EXT
:
192 case EIGRP_TLV_AT_CABLE_SETUP
:
193 case EIGRP_TLV_IPX_INT
:
194 case EIGRP_TLV_IPX_EXT
:
198 print_unknown_data(obj_tptr
,"\n\t ",obj_tlen
);
201 /* do we want to see an additionally hexdump ? */
203 print_unknown_data(tptr
+sizeof(sizeof(struct eigrp_tlv_header
)),"\n\t ",
204 eigrp_tlv_len
-sizeof(struct eigrp_tlv_header
));
211 printf("\n\t\t packet exceeded snapshot");