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