Don't guard col_set_str (COL_PROTOCOL) with col_check
[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   col_set_str(pinfo->cinfo, COL_PROTOCOL, "EIGRP");
151   if (check_col(pinfo->cinfo, COL_INFO))
152     col_clear(pinfo->cinfo, COL_INFO);
153
154   opcode_tmp=opcode=tvb_get_guint8(tvb,1);
155   ack = tvb_get_ntohl(tvb,12);
156   if (opcode==EIGRP_HELLO) { if (ack == 0) opcode_tmp=EIGRP_HI; else opcode_tmp=EIGRP_ACK; }
157
158   if (check_col(pinfo->cinfo, COL_INFO))
159     col_add_str(pinfo->cinfo, COL_INFO,
160         val_to_str(opcode_tmp , eigrp_opcode_vals, "Unknown (0x%04x)"));
161
162
163
164
165   if (tree) {
166
167      ti = proto_tree_add_protocol_format(tree, proto_eigrp, tvb, 0, -1,
168               "Cisco EIGRP");
169
170      eigrp_tree = proto_item_add_subtree(ti, ett_eigrp);
171
172      proto_tree_add_text (eigrp_tree, tvb, 0,1,"Version    = %u",tvb_get_guint8(tvb,0)) ;
173      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")) ;
174      proto_tree_add_text (eigrp_tree, tvb, 2,2,"Checksum   = 0x%04x",tvb_get_ntohs(tvb,2)) ;
175      proto_tree_add_text (eigrp_tree, tvb, 4,4,"Flags      = 0x%08x",tvb_get_ntohl(tvb,4)) ;
176      proto_tree_add_text (eigrp_tree, tvb, 8,4,"Sequence   = %u",tvb_get_ntohl(tvb,8)) ;
177      proto_tree_add_text (eigrp_tree, tvb, 12,4,"Acknowledge  = %u",tvb_get_ntohl(tvb,12)) ;
178      proto_tree_add_uint (eigrp_tree, hf_eigrp_as, tvb, 16,4,tvb_get_ntohl(tvb,16)) ;
179
180      if (opcode==EIGRP_SAP)
181         {
182         call_dissector(ipxsap_handle, tvb_new_subset(tvb, EIGRP_HEADER_LENGTH, -1, -1), pinfo, eigrp_tree);
183         return;
184         }
185
186      while ( tvb_reported_length_remaining(tvb,offset)>0 ) {
187
188              tlv = tvb_get_ntohs(tvb,offset);
189              size =  tvb_get_ntohs(tvb,offset+2);
190              if ( size == 0 )
191                 {
192                 proto_tree_add_text(eigrp_tree,tvb,offset,-1,"Unknown data (maybe authentication)");
193                 return;
194                 }
195
196              ti = proto_tree_add_text (eigrp_tree, tvb, offset,size,
197                  "%s",val_to_str(tlv, eigrp_tlv_vals, "Unknown (0x%04x)"));
198
199              tlv_tree = proto_item_add_subtree (ti, ett_tlv);
200              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")) ;
201              proto_tree_add_text (tlv_tree,tvb,offset+2,2,"Size = %u bytes",size) ;
202
203
204              switch (tlv){
205                 case TLV_PAR:
206                         dissect_eigrp_par(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree);
207                         break;
208                 case TLV_SEQ:
209                         dissect_eigrp_seq(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree);
210                         break;
211                 case TLV_SV:
212                         dissect_eigrp_sv(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree, ti);
213                         break;
214                 case TLV_NMS:
215                         dissect_eigrp_nms(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree, ti);
216                         break;
217
218                 case TLV_IP_INT:
219                         dissect_eigrp_ip_int(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree, ti);
220                         break;
221                 case TLV_IP_EXT:
222                         dissect_eigrp_ip_ext(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree, ti);
223                         break;
224
225                 case TLV_IPX_INT:
226                         dissect_eigrp_ipx_int(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree, ti);
227                         break;
228                 case TLV_IPX_EXT:
229                         dissect_eigrp_ipx_ext(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree, ti);
230                         break;
231
232                 case TLV_AT_CBL:
233                         dissect_eigrp_at_cbl(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree, ti);
234                         break;
235                 case TLV_AT_INT:
236                         dissect_eigrp_at_int(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree, ti);
237                         break;
238                 case TLV_AT_EXT:
239                         dissect_eigrp_at_ext(tvb_new_subset(tvb, offset+4, size-4, -1), tlv_tree, ti);
240                         break;
241                 case TLV_AUTH:
242                         proto_tree_add_text(tlv_tree,tvb,offset+4,size-4,"Authentication data");
243                         break;
244              }
245
246              offset+=size;
247      }
248
249    }
250 }
251
252
253
254 static void dissect_eigrp_par (tvbuff_t *tvb, proto_tree *tree) {
255         proto_tree_add_text (tree,tvb,0,1,"K1 = %u",tvb_get_guint8(tvb,0));
256         proto_tree_add_text (tree,tvb,1,1,"K2 = %u",tvb_get_guint8(tvb,1));
257         proto_tree_add_text (tree,tvb,2,1,"K3 = %u",tvb_get_guint8(tvb,2));
258         proto_tree_add_text (tree,tvb,3,1,"K4 = %u",tvb_get_guint8(tvb,3));
259         proto_tree_add_text (tree,tvb,4,1,"K5 = %u",tvb_get_guint8(tvb,4));
260         proto_tree_add_text (tree,tvb,5,1,"Reserved");
261         proto_tree_add_text (tree,tvb,6,2,"Hold Time = %u",tvb_get_ntohs(tvb,6));
262 }
263
264 static void dissect_eigrp_seq (tvbuff_t *tvb, proto_tree *tree)
265 {       guint8 addr_len;
266         addr_len=tvb_get_guint8(tvb,0);
267         proto_tree_add_text (tree,tvb,0,1,"Address length = %u",addr_len);
268         switch (addr_len){
269                 case 4:
270                         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));
271                         break;
272                 case 10:
273                         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));
274                         break;
275                 default:
276                         /* nothing */
277                         ;
278                 }
279 }
280
281 static void dissect_eigrp_sv (tvbuff_t *tvb, proto_tree *tree, proto_item *ti)
282 {
283         guint8 ios_rel_major, ios_rel_minor;
284         guint8 eigrp_rel_major, eigrp_rel_minor;
285
286         ios_rel_major = tvb_get_guint8(tvb,0);
287         ios_rel_minor = tvb_get_guint8(tvb,1);
288         proto_tree_add_text (tree,tvb,0,2," IOS  release version = %u.%u",
289                              ios_rel_major, ios_rel_minor);
290         proto_item_append_text (ti,": IOS=%u.%u", ios_rel_major, ios_rel_minor);
291
292         eigrp_rel_major = tvb_get_guint8(tvb,2);
293         eigrp_rel_minor = tvb_get_guint8(tvb,3);
294         proto_tree_add_text (tree,tvb,2,2,"EIGRP release version = %u.%u",
295                              eigrp_rel_major, eigrp_rel_minor);
296         proto_item_append_text (ti,", EIGRP=%u.%u",
297                                 eigrp_rel_major, eigrp_rel_minor);
298 }
299
300 static void dissect_eigrp_nms (tvbuff_t *tvb, proto_tree *tree, proto_item *ti)
301 {
302         proto_tree_add_text (tree,tvb,0,4,"Next Multicast Sequence = %u",tvb_get_ntohl(tvb,0));
303         proto_item_append_text (ti,": %u",tvb_get_ntohl(tvb,0));
304 }
305
306
307
308 static void dissect_eigrp_ip_int (tvbuff_t *tvb, proto_tree *tree, proto_item *ti)
309 {
310         guint8 ip_addr[4],length;
311         int addr_len,offset;
312
313         tvb_memcpy(tvb,ip_addr,0,4);
314         proto_tree_add_text (tree,tvb,0,4, "Next Hop    = %s",ip_to_str(ip_addr));
315         proto_tree_add_text (tree,tvb,4,4, "Delay       = %u",tvb_get_ntohl(tvb,4));
316         proto_tree_add_text (tree,tvb,8,4, "Bandwidth   = %u",tvb_get_ntohl(tvb,8));
317         proto_tree_add_text (tree,tvb,12,3,"MTU         = %u",tvb_get_ntoh24(tvb,12));
318         proto_tree_add_text (tree,tvb,15,1,"Hop Count   = %u",tvb_get_guint8(tvb,15));
319         proto_tree_add_text (tree,tvb,16,1,"Reliability = %u",tvb_get_guint8(tvb,16));
320         proto_tree_add_text (tree,tvb,17,1,"Load        = %u",tvb_get_guint8(tvb,17));
321         proto_tree_add_text (tree,tvb,18,2,"Reserved ");
322
323         for (offset = 20; tvb_length_remaining(tvb, offset) > 0; offset += (1+addr_len))
324         {
325                 length=tvb_get_guint8(tvb,offset);
326                 addr_len=ipv4_addr_and_mask (tvb,offset+1,ip_addr,length);
327                 if (addr_len < 0) {
328                     proto_tree_add_text (tree,tvb,offset,1,"Prefix length = %u (invalid, must be <= 32)",length);
329                     proto_item_append_text (ti,"  [Invalid prefix length %u > 32]",length);
330                     addr_len = 4; /* assure we can exit the loop */
331                 } else {
332                     proto_tree_add_text (tree,tvb,offset,1,"Prefix Length = %u",length);
333                     proto_tree_add_text (tree,tvb,offset+1,addr_len,"Destination = %s",ip_to_str(ip_addr));
334                     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":""));
335                 }
336         }
337 }
338
339 static void dissect_eigrp_ip_ext (tvbuff_t *tvb, proto_tree *tree, proto_item *ti)
340 {
341         guint8 ip_addr[4],length;
342         int addr_len,offset;
343
344         tvb_memcpy(tvb,ip_addr,0,4);
345         proto_tree_add_text (tree,tvb,0,4,"Next Hop = %s",ip_to_str(ip_addr));
346         tvb_memcpy(tvb,ip_addr,4,4);
347         proto_tree_add_text (tree,tvb,4,4,"Originating router = %s",ip_to_str(ip_addr));
348         proto_tree_add_text (tree,tvb,8,4,"Originating A.S. = %u",tvb_get_ntohl(tvb,8));
349         proto_tree_add_text (tree,tvb,12,4,"Arbitrary tag = %u",tvb_get_ntohl(tvb,12));
350         proto_tree_add_text (tree,tvb,16,4,"External protocol metric = %u",tvb_get_ntohl(tvb,16));
351         proto_tree_add_text (tree,tvb,20,2,"Reserved");
352         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"));
353         proto_tree_add_text (tree,tvb,23,1,"Flags = 0x%0x",tvb_get_guint8(tvb,23));
354
355         proto_tree_add_text (tree,tvb,24,4,"Delay     = %u",tvb_get_ntohl(tvb,24));
356         proto_tree_add_text (tree,tvb,28,4,"Bandwidth = %u",tvb_get_ntohl(tvb,28));
357         proto_tree_add_text (tree,tvb,32,3,"MTU    = %u",tvb_get_ntoh24(tvb,32));
358         proto_tree_add_text (tree,tvb,35,1,"Hop Count = %u",tvb_get_guint8(tvb,35));
359         proto_tree_add_text (tree,tvb,36,1,"Reliability = %u",tvb_get_guint8(tvb,36));
360         proto_tree_add_text (tree,tvb,37,1,"Load = %u",tvb_get_guint8(tvb,37));
361         proto_tree_add_text (tree,tvb,38,2,"Reserved ");
362
363         for (offset = 40; tvb_length_remaining(tvb, offset) > 0; offset += (1+addr_len))
364         {
365                 length=tvb_get_guint8(tvb,offset);
366                 addr_len=ipv4_addr_and_mask (tvb,offset+1,ip_addr,length);
367                 if (addr_len < 0) {
368                     proto_tree_add_text (tree,tvb,offset,1,"Prefix length = %u (invalid, must be <= 32)",length);
369                     proto_item_append_text (ti,"  [Invalid prefix length %u > 32]",length);
370                     addr_len = 4; /* assure we can exit the loop */
371                 } else {
372                     proto_tree_add_text (tree,tvb,offset,1,"Prefix Length = %u",length);
373                     proto_tree_add_text (tree,tvb,offset+1,addr_len,"Destination = %s",ip_to_str(ip_addr));
374                     proto_item_append_text (ti,"  %c   %s/%u%s",offset==40?'=':',',ip_to_str(ip_addr),length,((tvb_get_ntohl(tvb,24)==0xffffffff)?" - Destination unreachable":""));
375                 }
376         }
377 }
378
379
380
381 static void dissect_eigrp_ipx_int (tvbuff_t *tvb, proto_tree *tree, proto_item *ti)
382 {
383         proto_tree_add_text (tree,tvb,0,4,"Next Hop Address = %08x",tvb_get_ntohl(tvb,4));
384         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));
385         proto_tree_add_text (tree,tvb,10,4,"Delay     = %u",tvb_get_ntohl(tvb,10));
386         proto_tree_add_text (tree,tvb,14,4,"Bandwidth = %u",tvb_get_ntohl(tvb,14));
387         proto_tree_add_text (tree,tvb,18,3,"MTU    = %u",tvb_get_ntoh24(tvb,18));
388         proto_tree_add_text (tree,tvb,21,1,"Hop Count = %u",tvb_get_guint8(tvb,21));
389         proto_tree_add_text (tree,tvb,22,1,"Reliability = %u",tvb_get_guint8(tvb,22));
390         proto_tree_add_text (tree,tvb,23,1,"Load = %u",tvb_get_guint8(tvb,23));
391         proto_tree_add_text (tree,tvb,24,2,"Reserved ");
392         proto_tree_add_text (tree,tvb,26,4,"Destination Address =  %08x",tvb_get_ntohl(tvb,26));
393         proto_item_append_text (ti,"  =   %08x%s",tvb_get_ntohl(tvb,26),((tvb_get_ntohl(tvb,10)==0xffffffff)?" - Destination unreachable":""));
394 }
395
396 static void dissect_eigrp_ipx_ext (tvbuff_t *tvb, proto_tree *tree, proto_item *ti)
397 {
398         proto_tree_add_text (tree,tvb,0,4,"Next Hop Address = %08x",tvb_get_ntohl(tvb,4));
399         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));
400
401         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));
402         proto_tree_add_text (tree,tvb,16,4,"Originating A.S. = %u",tvb_get_ntohl(tvb,16));
403         proto_tree_add_text (tree,tvb,20,4,"Arbitrary tag = %u",tvb_get_ntohl(tvb,20));
404         proto_tree_add_text (tree,tvb,24,1,"External protocol  = %u",tvb_get_guint8(tvb,24));
405         proto_tree_add_text (tree,tvb,25,1,"Reserved");
406         proto_tree_add_text (tree,tvb,26,2,"External metric = %u ",tvb_get_ntohs(tvb,26));
407         proto_tree_add_text (tree,tvb,28,2,"External delay  = %u ",tvb_get_ntohs(tvb,28));
408
409         proto_tree_add_text (tree,tvb,30,4,"Delay     = %u",tvb_get_ntohl(tvb,30));
410         proto_tree_add_text (tree,tvb,34,4,"Bandwidth = %u",tvb_get_ntohl(tvb,34));
411         proto_tree_add_text (tree,tvb,38,3,"MTU    = %u",tvb_get_ntoh24(tvb,38));
412         proto_tree_add_text (tree,tvb,41,1,"Hop Count = %u",tvb_get_guint8(tvb,41));
413         proto_tree_add_text (tree,tvb,42,1,"Reliability = %u",tvb_get_guint8(tvb,42));
414         proto_tree_add_text (tree,tvb,43,1,"Load = %u",tvb_get_guint8(tvb,43));
415         proto_tree_add_text (tree,tvb,44,2,"Reserved ");
416         proto_tree_add_text (tree,tvb,46,4,"Destination Address =  %08x",tvb_get_ntohl(tvb,46));
417         proto_item_append_text (ti,"  =   %08x%s",tvb_get_ntohl(tvb,46),((tvb_get_ntohl(tvb,30)==0xffffffff)?" - Destination unreachable":""));
418
419 }
420
421
422
423 static void dissect_eigrp_at_cbl (tvbuff_t *tvb, proto_tree *tree, proto_item *ti)
424 {
425         proto_tree_add_text (tree,tvb,0,4,"AppleTalk Cable Range = %u-%u",tvb_get_ntohs(tvb,0),tvb_get_ntohs(tvb,2));
426         proto_tree_add_text (tree,tvb,4,4,"AppleTalk Router ID   = %u",tvb_get_ntohl(tvb,4));
427         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));
428
429 }
430
431 static void dissect_eigrp_at_int (tvbuff_t *tvb, proto_tree *tree, proto_item *ti)
432 {
433         proto_tree_add_text (tree,tvb,0,4,"Next Hop Address = %u.%u",tvb_get_ntohs(tvb,0),tvb_get_ntohs(tvb,2));
434
435         proto_tree_add_text (tree,tvb,4,4,"Delay     = %u",tvb_get_ntohl(tvb,4));
436         proto_tree_add_text (tree,tvb,8,4,"Bandwidth = %u",tvb_get_ntohl(tvb,8));
437         proto_tree_add_text (tree,tvb,12,3,"MTU    = %u",tvb_get_ntoh24(tvb,12));
438         proto_tree_add_text (tree,tvb,15,1,"Hop Count = %u",tvb_get_guint8(tvb,15));
439         proto_tree_add_text (tree,tvb,16,1,"Reliability = %u",tvb_get_guint8(tvb,16));
440         proto_tree_add_text (tree,tvb,17,1,"Load = %u",tvb_get_guint8(tvb,17));
441         proto_tree_add_text (tree,tvb,18,2,"Reserved ");
442         proto_tree_add_text (tree,tvb,20,4,"Cable range = %u-%u",tvb_get_ntohs(tvb,20),tvb_get_ntohs(tvb,22));
443
444         proto_item_append_text (ti,": %u-%u",tvb_get_ntohs(tvb,20),tvb_get_ntohs(tvb,22));
445
446 }
447
448 static void dissect_eigrp_at_ext (tvbuff_t *tvb, proto_tree *tree, proto_item *ti)
449 {
450         proto_tree_add_text (tree,tvb,0,4,"Next Hop Address = %u.%u",tvb_get_ntohs(tvb,0),tvb_get_ntohs(tvb,2));
451         proto_tree_add_text (tree,tvb,4,4,"Originating router ID = %u",tvb_get_ntohl(tvb,4));
452         proto_tree_add_text (tree,tvb,8,4,"Originating A.S. = %u",tvb_get_ntohl(tvb,8));
453         proto_tree_add_text (tree,tvb,12,4,"Arbitrary tag = %u",tvb_get_ntohl(tvb,12));
454         proto_tree_add_text (tree,tvb,16,1,"External protocol ID = %u ",tvb_get_guint8(tvb,16));
455         proto_tree_add_text (tree,tvb,17,1,"Flags = 0x%0x",tvb_get_guint8(tvb,17));
456         proto_tree_add_text (tree,tvb,18,2,"External protocol metric = %u",tvb_get_ntohs(tvb,18));
457
458         proto_tree_add_text (tree,tvb,20,4,"Delay     = %u",tvb_get_ntohl(tvb,20));
459         proto_tree_add_text (tree,tvb,24,4,"Bandwidth = %u",tvb_get_ntohl(tvb,24));
460         proto_tree_add_text (tree,tvb,28,3,"MTU    = %u",tvb_get_ntoh24(tvb,28));
461         proto_tree_add_text (tree,tvb,31,1,"Hop Count = %u",tvb_get_guint8(tvb,31));
462         proto_tree_add_text (tree,tvb,32,1,"Reliability = %u",tvb_get_guint8(tvb,32));
463         proto_tree_add_text (tree,tvb,33,1,"Load = %u",tvb_get_guint8(tvb,33));
464         proto_tree_add_text (tree,tvb,34,2,"Reserved ");
465         proto_tree_add_text (tree,tvb,36,4,"Cable range = %u-%u",tvb_get_ntohs(tvb,36),tvb_get_ntohs(tvb,38));
466
467         proto_item_append_text (ti,": %u-%u",tvb_get_ntohs(tvb,36),tvb_get_ntohs(tvb,38));
468 }
469
470
471
472
473 void
474 proto_register_eigrp(void)
475 {
476   static hf_register_info hf[] = {
477    { &hf_eigrp_opcode,
478     { "Opcode", "eigrp.opcode",
479      FT_UINT8, BASE_DEC, NULL, 0x0 ,
480      "Opcode number", HFILL }
481      },
482    { &hf_eigrp_as,
483     { "Autonomous System", "eigrp.as",
484       FT_UINT16, BASE_DEC, NULL, 0x0 ,
485      "Autonomous System number", HFILL }
486     },
487    { &hf_eigrp_tlv,
488     { "Entry",           "eigrp.tlv",
489       FT_UINT16, BASE_DEC, NULL, 0x0 ,
490      "Type/Length/Value", HFILL }
491     },
492    };
493
494    static gint *ett[] = {
495      &ett_eigrp,
496      &ett_tlv,
497    };
498    proto_eigrp = proto_register_protocol("Enhanced Interior Gateway Routing Protocol",
499                                          "EIGRP", "eigrp");
500    proto_register_field_array(proto_eigrp, hf, array_length(hf));
501    proto_register_subtree_array(ett, array_length(ett));
502 }
503
504 void
505 proto_reg_handoff_eigrp(void)
506 {
507     dissector_handle_t eigrp_handle;
508
509     ipxsap_handle = find_dissector("ipxsap");
510     eigrp_handle = create_dissector_handle(dissect_eigrp, proto_eigrp);
511     dissector_add("ip.proto", IP_PROTO_EIGRP, eigrp_handle);
512     dissector_add("ddp.type", DDP_EIGRP, eigrp_handle);
513     dissector_add("ipx.socket", IPX_SOCKET_EIGRP, eigrp_handle);
514 }