diff options
-rw-r--r-- | AUTHORS | 2 | ||||
-rw-r--r-- | packet-cdp.c | 50 |
2 files changed, 49 insertions, 3 deletions
@@ -22,7 +22,7 @@ Hannes R. Boehm <hannes@boehm.org> { OSPFv2 RIPv1, RIPv2 - started IPv6 support + started IPv6 support (help needed - I don't have IPv6) } Mike Hall <mlh@io.com>{ diff --git a/packet-cdp.c b/packet-cdp.c index e72ffeb265..a8c28a5070 100644 --- a/packet-cdp.c +++ b/packet-cdp.c @@ -1,8 +1,8 @@ /* packet-cdp.c - * Routines for + * Routines for the disassembly of the "Cisco Discovery Protocoll" * (c) Copyright Hannes R. Boehm <hannes@boehm.org> * - * $Id: packet-cdp.c,v 1.1 1998/12/19 00:12:21 hannes Exp $ + * $Id: packet-cdp.c,v 1.2 1999/01/04 20:07:28 hannes Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -41,9 +41,22 @@ #include "ethereal.h" #include "packet.h" + void dissect_cdp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) { GtkWidget *cdp_tree = NULL, *ti; + char *version; + char *hostname; + char *interface; + + typedef struct _e_tlv_struct{ + short type; + short length; + } e_tlv_struct; + + e_tlv_struct *tlv; + int i,j; + if (check_col(fd, COL_PROTOCOL)) col_add_str(fd, COL_PROTOCOL, "CDP"); @@ -55,6 +68,39 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) { "Cisco Discovery Protocoll"); cdp_tree = gtk_tree_new(); add_subtree(ti, cdp_tree, ETT_CDP); + + version=(char *) &pd[offset]; + hostname=(char *) &pd[offset+8]; + interface=(char *) &pd[offset+34]; + + add_item_to_tree(cdp_tree, offset, 0, "under development (hannes@boehm.org)"); + add_item_to_tree(cdp_tree, offset, 1, "Version: %d", *version); + add_item_to_tree(cdp_tree, offset+8, 1, "Chassis ID: %s", hostname); + add_item_to_tree(cdp_tree, offset+34, 1, "Interface: %s", interface); + + /* CVS -> exit here + dissect_data(pd, offset, fd, (GtkTree *) cdp_tree); + return; + */ + + i=4; + j=0; + while(i < 1500 ){ + tlv = (e_tlv_struct *) &pd[offset+i]; + add_item_to_tree(cdp_tree, offset+i, 2, "Type: %d", ntohs(tlv->type)); + add_item_to_tree(cdp_tree, offset+i+2, 2, "Length: %d", ntohs(tlv->length)); + if( (ntohs(tlv->type) == 0) && j==0) { + j=1; + i+= ntohs(tlv->length) + 4; + } else if( (ntohs(tlv->type) == 0) && j==1) { + j=0; + i+= 4; + } else { + i+= ntohs(tlv->length) + 4; + } + + } + dissect_data(pd, offset, fd, (GtkTree *) cdp_tree); } } |