FIx for bug 2381:
[obnox/wireshark/wip.git] / epan / dissectors / packet-eigrp.c
1 /* packet-eigrp.c
2  * Routines for EIGRP dissection
3  * Copyright 2000, Paul Ionescu <paul@acorp.ro>
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #include <glib.h>
31 #include <epan/packet.h>
32 #include <epan/addr_resolv.h>
33
34 #include <epan/atalk-utils.h>
35 #include <epan/addr_and_mask.h>
36 #include <epan/ipproto.h>
37 #include "packet-ipx.h"
38
39 /*
40  * See
41  *
42  *      http://www.rhyshaden.com/eigrp.htm
43  */
44
45 #define EIGRP_UPDATE    0x01
46 #define EIGRP_REQUEST   0x02
47 #define EIGRP_QUERY     0x03
48 #define EIGRP_REPLY     0x04
49 #define EIGRP_HELLO     0x05
50 #define EIGRP_SAP       0x06
51 #define EIGRP_HI        0x20  /* This value is for my own need to make a difference between Hello and Ack */
52 #define EIGRP_ACK       0x40  /* This value is for my own need to make a difference between Hello and Ack */
53
54 #define TLV_PAR         0x0001
55 #define TLV_AUTH        0x0002
56 #define TLV_SEQ         0x0003
57 #define TLV_SV          0x0004
58 #define TLV_NMS         0x0005
59 #define TLV_IP_INT      0x0102
60 #define TLV_IP_EXT      0x0103
61 #define TLV_AT_INT      0x0202
62 #define TLV_AT_EXT      0x0203
63 #define TLV_AT_CBL      0x0204
64 #define TLV_IPX_INT     0x0302
65 #define TLV_IPX_EXT     0x0303
66
67 #define EIGRP_HEADER_LENGTH     20
68
69 static gint proto_eigrp = -1;
70
71 static gint hf_eigrp_opcode = -1;
72 static gint hf_eigrp_as = -1;
73 static gint hf_eigrp_tlv = -1;
74
75 static gint ett_eigrp = -1;
76 static gint ett_tlv = -1;
77
78 static dissector_handle_t ipxsap_handle;
79
80
81 static const value_string eigrp_opcode_vals[] = {
82         { EIGRP_HELLO,          "Hello/Ack" },
83         { EIGRP_UPDATE,         "Update" },
84         { EIGRP_REPLY,          "Reply" },
85         { EIGRP_QUERY,          "Query" },
86         { EIGRP_REQUEST,        "Request" },
87         { EIGRP_SAP,            "IPX/SAP Update" },
88         { EIGRP_HI,             "Hello" },
89         { EIGRP_ACK,            "Acknowledge" },
90         { 0,                            NULL }
91 };
92
93 static const value_string eigrp_tlv_vals[] = {
94         { TLV_PAR,     "EIGRP Parameters"},
95         { TLV_AUTH,    "Authentication data"},
96         { TLV_SEQ ,    "Sequence"},
97         { TLV_SV,      "Software Version"},
98         { TLV_NMS   ,  "Next multicast sequence"},
99         { TLV_IP_INT,  "IP internal route"},
100         { TLV_IP_EXT,  "IP external route"},
101         { TLV_AT_INT,  "AppleTalk internal route"},
102         { TLV_AT_EXT,  "AppleTalk external route"},
103         { TLV_AT_CBL,  "AppleTalk cable configuration"},
104         { TLV_IPX_INT, "IPX internal route"},
105         { TLV_IPX_EXT, "IPX external route"},
106         { 0,            NULL}
107 };
108
109 static const value_string eigrp_pid_vals[] = {
110         { 1,    "IGRP"},
111         { 2,    "EIGRP"},
112         { 3,    "Static Route"},
113         { 4,    "RIP"},
114         { 5,    "Hello"},
115         { 6,    "OSPF"},
116         { 7,    "IS-IS"},
117         { 8,    "EGP"},
118         { 9,    "BGP"},
119         { 10,   "IDRP"},
120         { 11,   "Connected link"},
121         { 0,    NULL}
122 };
123
124
125 static void dissect_eigrp_par (tvbuff_t *tvb, proto_tree *tree);
126 static void dissect_eigrp_seq (tvbuff_t *tvb, proto_tree *tree);
127 static void dissect_eigrp_sv  (tvbuff_t *tvb, proto_tree *tree, proto_item *ti);
128 static void dissect_eigrp_nms (tvbuff_t *tvb, proto_tree *tree, proto_item *ti);
129
130 static void dissect_eigrp_ip_int (tvbuff_t *tvb, proto_tree *tree, proto_item *ti);
131 static void dissect_eigrp_ip_ext (tvbuff_t *tvb, proto_tree *tree, proto_item *ti);
132
133 static void dissect_eigrp_ipx_int (tvbuff_t *tvb, proto_tree *tree, proto_item *ti);
134 static void dissect_eigrp_ipx_ext (tvbuff_t *tvb, proto_tree *tree, proto_item *ti);
135
136 static void dissect_eigrp_at_cbl (tvbuff_t *tvb, proto_tree *tree, proto_item *ti);
137 static void dissect_eigrp_at_int (tvbuff_t *tvb, proto_tree *tree, proto_item *ti);
138 static void dissect_eigrp_at_ext (tvbuff_t *tvb, proto_tree *tree, proto_item *ti);
139
140 static void
141 dissect_eigrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
142
143   proto_tree *eigrp_tree,*tlv_tree;
144   proto_item *ti;
145
146   guint opcode,opcode_tmp;
147   guint16 tlv;
148   guint32 ack, size, offset = EIGRP_HEADER_LENGTH;
149
150   if (check_col(pinfo->cinfo, COL_PROTOCOL))
151     col_set_str(pinfo->cinfo, COL_PROTOCOL, "EIGRP");
152   if (check_col(pinfo->cinfo, COL_INFO))
153     col_clear(pinfo->cinfo, COL_INFO);
154
155   opcode_tmp=opcode=tvb_get_guint8(tvb,1);
156   ack = tvb_get_ntohl(tvb,12);
157   if (opcode==EIGRP_HELLO) { if (ack == 0) opcode_tmp=EIGRP_HI; else opcode_tmp=EIGRP_ACK; }
158
159   if (check_col(pinfo->cinfo, COL_INFO))
160     col_add_str(pinfo->cinfo, COL_INFO,
161         val_to_str(opcode_tmp , eigrp_opcode_vals, "Unknown (0x%04x)"));
162
163
164
165
166   if (tree) {
167
168      ti = proto_tree_add_protocol_format(tree, proto_eigrp, tvb, 0, -1,
169               "Cisco EIGRP");
170
171      eigrp_tree = proto_item_add_subtree(ti, ett_eigrp);
172
173      proto_tree_add_text (eigrp_tree, tvb, 0,1,"Version    = %u",tvb_get_guint8(tvb,0)) ;
174      proto_tree_add_uint_format (eigrp_tree, hf_eigrp_opcode, tvb, 1,1,opcode,"Opcode = %u (%s)",opcode,val_to_str(opcode_tmp,eigrp_opcode_vals, "Unknown")) ;
175      proto_tree_add_text (eigrp_tree, tvb, 2,2,"Checksum   = 0x%04x",tvb_get_ntohs(tvb,2)) ;
176      proto_tree_add_text (eigrp_tree, tvb, 4,4,"Flags      = 0x%08x",tvb_get_ntohl(tvb,4)) ;
177      proto_tree_add_text (eigrp_tree, tvb, 8,4,"Sequence   = %u",tvb_get_ntohl(tvb,8)) ;
178      proto_tree_add_text (eigrp_tree, tvb, 12,4,"Acknowledge  = %u",tvb_get_ntohl(tvb,12)) ;
179      proto_tree_add_uint (eigrp_tree, hf_eigrp_as, tvb, 16,4,tvb_get_ntohl(tvb,16)) ;
180
181      if (opcode==EIGRP_SAP)
182         {
183         call_dissector(ipxsap_handle, tvb_new_subset(tvb, EIGRP_HEADER_LENGTH, -1, -1), pinfo, eigrp_tree);
184         return;
185         }
186
187      while ( tvb_reported_length_remaining(tvb,offset)>0 ) {
188
189              tlv = tvb_get_ntohs(tvb,offset);
190              size =  tvb_get_ntohs(tvb,offset+2);
191              if ( size == 0 )
192                 {
193                 proto_tree_add_text(eigrp_tree,tvb,offset,-1,"Unknown data (maybe authentication)");
194                 return;
195                 }
196
197              ti = proto_tree_add_text (eigrp_tree, tvb, offset,size,
198                  "%s",val_to_str(tlv, eigrp_tlv_vals, "Unknown (0x%04x)"));
199
200              tlv_tree = proto_item_add_subtree (ti, ett_tlv);
201              proto_tree_add_uint_format (tlv_tree,hf_eigrp_tlv, tvb,offset,2,tlv,"Type = 0x%04x (%s)",tlv,val_to_str(tlv,eigrp_tlv_vals, "Unknown")) ;
202              proto_tree_add_text (tlv_tree,tvb,offset+2,2,"Size = %u bytes",size) ;
203
204
205              switch (tlv){
206                 case TLV_PAR:
207                         dissect_eigrp_par(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree);
208                         break;
209                 case TLV_SEQ:
210                         dissect_eigrp_seq(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree);
211                         break;
212                 case TLV_SV:
213                         dissect_eigrp_sv(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree, ti);
214                         break;
215                 case TLV_NMS:
216                         dissect_eigrp_nms(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree, ti);
217                         break;
218
219                 case TLV_IP_INT:
220                         dissect_eigrp_ip_int(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree, ti);
221                         break;
222                 case TLV_IP_EXT:
223                         dissect_eigrp_ip_ext(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree, ti);
224                         break;
225
226                 case TLV_IPX_INT:
227                         dissect_eigrp_ipx_int(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree, ti);
228                         break;
229                 case TLV_IPX_EXT:
230                         dissect_eigrp_ipx_ext(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree, ti);
231                         break;
232
233                 case TLV_AT_CBL:
234                         dissect_eigrp_at_cbl(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree, ti);
235                         break;
236                 case TLV_AT_INT:
237                         dissect_eigrp_at_int(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree, ti);
238                         break;
239                 case TLV_AT_EXT:
240                         dissect_eigrp_at_ext(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree, ti);
241                         break;
242                 case TLV_AUTH:
243                         proto_tree_add_text(tlv_tree,tvb,offset+4,size-4,"Authentication data");
244                         break;
245              }
246
247              offset+=size;
248      }
249
250    }
251 }
252
253
254
255 static void dissect_eigrp_par (tvbuff_t *tvb, proto_tree *tree) {
256         proto_tree_add_text (tree,tvb,0,1,"K1 = %u",tvb_get_guint8(tvb,0));
257         proto_tree_add_text (tree,tvb,1,1,"K2 = %u",tvb_get_guint8(tvb,1));
258         proto_tree_add_text (tree,tvb,2,1,"K3 = %u",tvb_get_guint8(tvb,2));
259         proto_tree_add_text (tree,tvb,3,1,"K4 = %u",tvb_get_guint8(tvb,3));
260         proto_tree_add_text (tree,tvb,4,1,"K5 = %u",tvb_get_guint8(tvb,4));
261         proto_tree_add_text (tree,tvb,5,1,"Reserved");
262         proto_tree_add_text (tree,tvb,6,2,"Hold Time = %u",tvb_get_ntohs(tvb,6));
263 }
264
265 static void dissect_eigrp_seq (tvbuff_t *tvb, proto_tree *tree)
266 {       guint8 addr_len;
267         addr_len=tvb_get_guint8(tvb,0);
268         proto_tree_add_text (tree,tvb,0,1,"Address length = %u",addr_len);
269         switch (addr_len){
270                 case 4:
271                         proto_tree_add_text (tree,tvb,1,addr_len,"IP Address = %u.%u.%u.%u",tvb_get_guint8(tvb,1),tvb_get_guint8(tvb,2),tvb_get_guint8(tvb,3),tvb_get_guint8(tvb,4));
272                         break;
273                 case 10:
274                         proto_tree_add_text (tree,tvb,1,addr_len,"IPX Address = %08x.%04x.%04x.%04x",tvb_get_ntohl(tvb,1),tvb_get_ntohs(tvb,5),tvb_get_ntohs(tvb,7),tvb_get_ntohs(tvb,9));
275                         break;
276                 default:
277                         /* nothing */
278                         ;
279                 }
280 }
281
282 static void dissect_eigrp_sv (tvbuff_t *tvb, proto_tree *tree, proto_item *ti)
283 {
284         guint8 ios_rel_major, ios_rel_minor;
285         guint8 eigrp_rel_major, eigrp_rel_minor;
286
287         ios_rel_major = tvb_get_guint8(tvb,0);
288         ios_rel_minor = tvb_get_guint8(tvb,1);
289         proto_tree_add_text (tree,tvb,0,2," IOS  release version = %u.%u",
290                              ios_rel_major, ios_rel_minor);
291         proto_item_append_text (ti,": IOS=%u.%u", ios_rel_major, ios_rel_minor);
292
293         eigrp_rel_major = tvb_get_guint8(tvb,2);
294         eigrp_rel_minor = tvb_get_guint8(tvb,3);
295         proto_tree_add_text (tree,tvb,2,2,"EIGRP release version = %u.%u",
296                              eigrp_rel_major, eigrp_rel_minor);
297         proto_item_append_text (ti,", EIGRP=%u.%u",
298                                 eigrp_rel_major, eigrp_rel_minor);
299 }
300
301 static void dissect_eigrp_nms (tvbuff_t *tvb, proto_tree *tree, proto_item *ti)
302 {
303         proto_tree_add_text (tree,tvb,0,4,"Next Multicast Sequence = %u",tvb_get_ntohl(tvb,0));
304         proto_item_append_text (ti,": %u",tvb_get_ntohl(tvb,0));
305 }
306
307
308
309 static void dissect_eigrp_ip_int (tvbuff_t *tvb, proto_tree *tree, proto_item *ti)
310 {
311         guint8 ip_addr[4],length;
312         int addr_len,offset;
313
314         tvb_memcpy(tvb,ip_addr,0,4);
315         proto_tree_add_text (tree,tvb,0,4, "Next Hop    = %s",ip_to_str(ip_addr));
316         proto_tree_add_text (tree,tvb,4,4, "Delay       = %u",tvb_get_ntohl(tvb,4));
317         proto_tree_add_text (tree,tvb,8,4, "Bandwidth   = %u",tvb_get_ntohl(tvb,8));
318         proto_tree_add_text (tree,tvb,12,3,"MTU         = %u",tvb_get_ntoh24(tvb,12));
319         proto_tree_add_text (tree,tvb,15,1,"Hop Count   = %u",tvb_get_guint8(tvb,15));
320         proto_tree_add_text (tree,tvb,16,1,"Reliability = %u",tvb_get_guint8(tvb,16));
321         proto_tree_add_text (tree,tvb,17,1,"Load        = %u",tvb_get_guint8(tvb,17));
322         proto_tree_add_text (tree,tvb,18,2,"Reserved ");
323
324         for (offset = 20; tvb_length_remaining(tvb, offset) > 0; offset += (1+addr_len))
325         {
326                 length=tvb_get_guint8(tvb,offset);
327                 addr_len=ipv4_addr_and_mask (tvb,offset+1,ip_addr,length);
328                 if (addr_len < 0) {
329                     proto_tree_add_text (tree,tvb,offset,1,"Prefix length = %u (invalid, must be <= 32)",length);
330                     proto_item_append_text (ti,"  [Invalid prefix length %u > 32]",length);
331                     addr_len = 4; /* assure we can exit the loop */
332                 } else {
333                     proto_tree_add_text (tree,tvb,offset,1,"Prefix Length = %u",length);
334                     proto_tree_add_text (tree,tvb,offset+1,addr_len,"Destination = %s",ip_to_str(ip_addr));
335                     proto_item_append_text (ti,"  %c   %s/%u%s",offset==20?'=':',',ip_to_str(ip_addr),length,((tvb_get_ntohl(tvb,4)==0xffffffff)?" - Destination unreachable":""));
336                 }
337         }
338 }
339
340 static void dissect_eigrp_ip_ext (tvbuff_t *tvb, proto_tree *tree, proto_item *ti)
341 {
342         guint8 ip_addr[4],length;
343         int addr_len,offset;
344
345         tvb_memcpy(tvb,ip_addr,0,4);
346         proto_tree_add_text (tree,tvb,0,4,"Next Hop = %s",ip_to_str(ip_addr));
347         tvb_memcpy(tvb,ip_addr,4,4);
348         proto_tree_add_text (tree,tvb,4,4,"Originating router = %s",ip_to_str(ip_addr));
349         proto_tree_add_text (tree,tvb,8,4,"Originating A.S. = %u",tvb_get_ntohl(tvb,8));
350         proto_tree_add_text (tree,tvb,12,4,"Arbitrary tag = %u",tvb_get_ntohl(tvb,12));
351         proto_tree_add_text (tree,tvb,16,4,"External protocol metric = %u",tvb_get_ntohl(tvb,16));
352         proto_tree_add_text (tree,tvb,20,2,"Reserved");
353         proto_tree_add_text (tree,tvb,22,1,"External protocol ID = %u (%s)",tvb_get_guint8(tvb,22),val_to_str(tvb_get_guint8(tvb,22),eigrp_pid_vals, "Unknown"));
354         proto_tree_add_text (tree,tvb,23,1,"Flags = 0x%0x",tvb_get_guint8(tvb,23));
355
356         proto_tree_add_text (tree,tvb,24,4,"Delay     = %u",tvb_get_ntohl(tvb,24));
357         proto_tree_add_text (tree,tvb,28,4,"Bandwidth = %u",tvb_get_ntohl(tvb,28));
358         proto_tree_add_text (tree,tvb,32,3,"MTU    = %u",tvb_get_ntoh24(tvb,32));
359         proto_tree_add_text (tree,tvb,35,1,"Hop Count = %u",tvb_get_guint8(tvb,35));
360         proto_tree_add_text (tree,tvb,36,1,"Reliability = %u",tvb_get_guint8(tvb,36));
361         proto_tree_add_text (tree,tvb,37,1,"Load = %u",tvb_get_guint8(tvb,37));
362         proto_tree_add_text (tree,tvb,38,2,"Reserved ");
363
364         for (offset = 40; tvb_length_remaining(tvb, offset) > 0; offset += (1+addr_len))
365         {
366                 length=tvb_get_guint8(tvb,offset);
367                 addr_len=ipv4_addr_and_mask (tvb,offset+1,ip_addr,length);
368                 if (addr_len < 0) {
369                     proto_tree_add_text (tree,tvb,offset,1,"Prefix length = %u (invalid, must be <= 32)",length);
370                     proto_item_append_text (ti,"  [Invalid prefix length %u > 32]",length);
371                     addr_len = 4; /* assure we can exit the loop */
372                 } else {
373                     proto_tree_add_text (tree,tvb,offset,1,"Prefix Length = %u",length);
374                     proto_tree_add_text (tree,tvb,offset+1,addr_len,"Destination = %s",ip_to_str(ip_addr));
375                     proto_item_append_text (ti,"  %c   %s/%u%s",offset==40?'=':',',ip_to_str(ip_addr),length,((tvb_get_ntohl(tvb,4)==0xffffffff)?" - Destination unreachable":""));
376                 }
377         }
378 }
379
380
381
382 static void dissect_eigrp_ipx_int (tvbuff_t *tvb, proto_tree *tree, proto_item *ti)
383 {
384         proto_tree_add_text (tree,tvb,0,4,"Next Hop Address = %08x",tvb_get_ntohl(tvb,4));
385         proto_tree_add_text (tree,tvb,4,6,"Next Hop ID      = %04x:%04x:%04x",tvb_get_ntohs(tvb,4),tvb_get_ntohs(tvb,6),tvb_get_ntohs(tvb,8));
386         proto_tree_add_text (tree,tvb,10,4,"Delay     = %u",tvb_get_ntohl(tvb,10));
387         proto_tree_add_text (tree,tvb,14,4,"Bandwidth = %u",tvb_get_ntohl(tvb,14));
388         proto_tree_add_text (tree,tvb,18,3,"MTU    = %u",tvb_get_ntoh24(tvb,18));
389         proto_tree_add_text (tree,tvb,21,1,"Hop Count = %u",tvb_get_guint8(tvb,21));
390         proto_tree_add_text (tree,tvb,22,1,"Reliability = %u",tvb_get_guint8(tvb,22));
391         proto_tree_add_text (tree,tvb,23,1,"Load = %u",tvb_get_guint8(tvb,23));
392         proto_tree_add_text (tree,tvb,24,2,"Reserved ");
393         proto_tree_add_text (tree,tvb,26,4,"Destination Address =  %08x",tvb_get_ntohl(tvb,26));
394         proto_item_append_text (ti,"  =   %08x%s",tvb_get_ntohl(tvb,26),((tvb_get_ntohl(tvb,10)==0xffffffff)?" - Destination unreachable":""));
395 }
396
397 static void dissect_eigrp_ipx_ext (tvbuff_t *tvb, proto_tree *tree, proto_item *ti)
398 {
399         proto_tree_add_text (tree,tvb,0,4,"Next Hop Address = %08x",tvb_get_ntohl(tvb,4));
400         proto_tree_add_text (tree,tvb,4,6,"Next Hop ID      = %04x:%04x:%04x",tvb_get_ntohs(tvb,4),tvb_get_ntohs(tvb,6),tvb_get_ntohs(tvb,8));
401
402         proto_tree_add_text (tree,tvb,10,6,"Originating router ID = %04x:%04x:%04x",tvb_get_ntohs(tvb,10),tvb_get_ntohs(tvb,12),tvb_get_ntohs(tvb,14));
403         proto_tree_add_text (tree,tvb,16,4,"Originating A.S. = %u",tvb_get_ntohl(tvb,16));
404         proto_tree_add_text (tree,tvb,20,4,"Arbitrary tag = %u",tvb_get_ntohl(tvb,20));
405         proto_tree_add_text (tree,tvb,24,1,"External protocol  = %u",tvb_get_guint8(tvb,24));
406         proto_tree_add_text (tree,tvb,25,1,"Reserved");
407         proto_tree_add_text (tree,tvb,26,2,"External metric = %u ",tvb_get_ntohs(tvb,26));
408         proto_tree_add_text (tree,tvb,28,2,"External delay  = %u ",tvb_get_ntohs(tvb,28));
409
410         proto_tree_add_text (tree,tvb,30,4,"Delay     = %u",tvb_get_ntohl(tvb,30));
411         proto_tree_add_text (tree,tvb,34,4,"Bandwidth = %u",tvb_get_ntohl(tvb,34));
412         proto_tree_add_text (tree,tvb,38,3,"MTU    = %u",tvb_get_ntoh24(tvb,38));
413         proto_tree_add_text (tree,tvb,41,1,"Hop Count = %u",tvb_get_guint8(tvb,41));
414         proto_tree_add_text (tree,tvb,42,1,"Reliability = %u",tvb_get_guint8(tvb,42));
415         proto_tree_add_text (tree,tvb,43,1,"Load = %u",tvb_get_guint8(tvb,43));
416         proto_tree_add_text (tree,tvb,44,2,"Reserved ");
417         proto_tree_add_text (tree,tvb,46,4,"Destination Address =  %08x",tvb_get_ntohl(tvb,46));
418         proto_item_append_text (ti,"  =   %08x%s",tvb_get_ntohl(tvb,46),((tvb_get_ntohl(tvb,30)==0xffffffff)?" - Destination unreachable":""));
419
420 }
421
422
423
424 static void dissect_eigrp_at_cbl (tvbuff_t *tvb, proto_tree *tree, proto_item *ti)
425 {
426         proto_tree_add_text (tree,tvb,0,4,"AppleTalk Cable Range = %u-%u",tvb_get_ntohs(tvb,0),tvb_get_ntohs(tvb,2));
427         proto_tree_add_text (tree,tvb,4,4,"AppleTalk Router ID   = %u",tvb_get_ntohl(tvb,4));
428         proto_item_append_text (ti,": Cable range= %u-%u, Router ID= %u",tvb_get_ntohs(tvb,0),tvb_get_ntohs(tvb,2),tvb_get_ntohl(tvb,4));
429
430 }
431
432 static void dissect_eigrp_at_int (tvbuff_t *tvb, proto_tree *tree, proto_item *ti)
433 {
434         proto_tree_add_text (tree,tvb,0,4,"Next Hop Address = %u.%u",tvb_get_ntohs(tvb,0),tvb_get_ntohs(tvb,2));
435
436         proto_tree_add_text (tree,tvb,4,4,"Delay     = %u",tvb_get_ntohl(tvb,4));
437         proto_tree_add_text (tree,tvb,8,4,"Bandwidth = %u",tvb_get_ntohl(tvb,8));
438         proto_tree_add_text (tree,tvb,12,3,"MTU    = %u",tvb_get_ntoh24(tvb,12));
439         proto_tree_add_text (tree,tvb,15,1,"Hop Count = %u",tvb_get_guint8(tvb,15));
440         proto_tree_add_text (tree,tvb,16,1,"Reliability = %u",tvb_get_guint8(tvb,16));
441         proto_tree_add_text (tree,tvb,17,1,"Load = %u",tvb_get_guint8(tvb,17));
442         proto_tree_add_text (tree,tvb,18,2,"Reserved ");
443         proto_tree_add_text (tree,tvb,20,4,"Cable range = %u-%u",tvb_get_ntohs(tvb,20),tvb_get_ntohs(tvb,22));
444
445         proto_item_append_text (ti,": %u-%u",tvb_get_ntohs(tvb,20),tvb_get_ntohs(tvb,22));
446
447 }
448
449 static void dissect_eigrp_at_ext (tvbuff_t *tvb, proto_tree *tree, proto_item *ti)
450 {
451         proto_tree_add_text (tree,tvb,0,4,"Next Hop Address = %u.%u",tvb_get_ntohs(tvb,0),tvb_get_ntohs(tvb,2));
452         proto_tree_add_text (tree,tvb,4,4,"Originating router ID = %u",tvb_get_ntohl(tvb,4));
453         proto_tree_add_text (tree,tvb,8,4,"Originating A.S. = %u",tvb_get_ntohl(tvb,8));
454         proto_tree_add_text (tree,tvb,12,4,"Arbitrary tag = %u",tvb_get_ntohl(tvb,12));
455         proto_tree_add_text (tree,tvb,16,1,"External protocol ID = %u ",tvb_get_guint8(tvb,16));
456         proto_tree_add_text (tree,tvb,17,1,"Flags = 0x%0x",tvb_get_guint8(tvb,17));
457         proto_tree_add_text (tree,tvb,18,2,"External protocol metric = %u",tvb_get_ntohs(tvb,18));
458
459         proto_tree_add_text (tree,tvb,20,4,"Delay     = %u",tvb_get_ntohl(tvb,20));
460         proto_tree_add_text (tree,tvb,24,4,"Bandwidth = %u",tvb_get_ntohl(tvb,24));
461         proto_tree_add_text (tree,tvb,28,3,"MTU    = %u",tvb_get_ntoh24(tvb,28));
462         proto_tree_add_text (tree,tvb,31,1,"Hop Count = %u",tvb_get_guint8(tvb,31));
463         proto_tree_add_text (tree,tvb,32,1,"Reliability = %u",tvb_get_guint8(tvb,32));
464         proto_tree_add_text (tree,tvb,33,1,"Load = %u",tvb_get_guint8(tvb,33));
465         proto_tree_add_text (tree,tvb,34,2,"Reserved ");
466         proto_tree_add_text (tree,tvb,36,4,"Cable range = %u-%u",tvb_get_ntohs(tvb,36),tvb_get_ntohs(tvb,38));
467
468         proto_item_append_text (ti,": %u-%u",tvb_get_ntohs(tvb,36),tvb_get_ntohs(tvb,38));
469 }
470
471
472
473
474 void
475 proto_register_eigrp(void)
476 {
477   static hf_register_info hf[] = {
478    { &hf_eigrp_opcode,
479     { "Opcode", "eigrp.opcode",
480      FT_UINT8, BASE_DEC, NULL, 0x0 ,
481      "Opcode number", HFILL }
482      },
483    { &hf_eigrp_as,
484     { "Autonomous System  ", "eigrp.as",
485       FT_UINT16, BASE_DEC, NULL, 0x0 ,
486      "Autonomous System number", HFILL }
487     },
488    { &hf_eigrp_tlv,
489     { "Entry  ",           "eigrp.tlv",
490       FT_UINT16, BASE_DEC, NULL, 0x0 ,
491      "Type/Length/Value", HFILL }
492     },
493    };
494
495    static gint *ett[] = {
496      &ett_eigrp,
497      &ett_tlv,
498    };
499    proto_eigrp = proto_register_protocol("Enhanced Interior Gateway Routing Protocol",
500                                          "EIGRP", "eigrp");
501    proto_register_field_array(proto_eigrp, hf, array_length(hf));
502    proto_register_subtree_array(ett, array_length(ett));
503 }
504
505 void
506 proto_reg_handoff_eigrp(void)
507 {
508     dissector_handle_t eigrp_handle;
509
510     ipxsap_handle = find_dissector("ipxsap");
511     eigrp_handle = create_dissector_handle(dissect_eigrp, proto_eigrp);
512     dissector_add("ip.proto", IP_PROTO_EIGRP, eigrp_handle);
513     dissector_add("ddp.type", DDP_EIGRP, eigrp_handle);
514     dissector_add("ipx.socket", IPX_SOCKET_EIGRP, eigrp_handle);
515 }