Okay. Please test the CVS code....

I think I figured out how CDP works :) ----

svn path=/trunk/; revision=155
This commit is contained in:
hannes 1999-01-04 21:08:45 +00:00
parent 5fdf1b9532
commit e39752f194
1 changed files with 46 additions and 33 deletions

View File

@ -2,7 +2,7 @@
* Routines for the disassembly of the "Cisco Discovery Protocoll"
* (c) Copyright Hannes R. Boehm <hannes@boehm.org>
*
* $Id: packet-cdp.c,v 1.2 1999/01/04 20:07:28 hannes Exp $
* $Id: packet-cdp.c,v 1.3 1999/01/04 21:08:45 hannes Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -45,17 +45,20 @@
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;
gint16 type;
gint16 length;
} e_tlv_struct;
typedef struct _e_cdp_hdr{
char version;
char flags;
gint16 ttl;
} e_cdp_hdr;
e_tlv_struct *tlv;
int i,j;
e_cdp_hdr *cdp_hdr;
if (check_col(fd, COL_PROTOCOL))
@ -69,39 +72,49 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
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];
/* CDP header */
cdp_hdr = (e_cdp_hdr *) &pd[offset];
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);
add_item_to_tree(cdp_tree, offset, 1, "Version: %d", cdp_hdr->version);
add_item_to_tree(cdp_tree, offset+1, 1, "Flags (unknown)");
add_item_to_tree(cdp_tree, offset+2, 2, "TTL (unknown)");
offset+=4;
/* CVS -> exit here
dissect_data(pd, offset, fd, (GtkTree *) cdp_tree);
return;
*/
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;
while( offset <= fd->cap_len ){
tlv = (e_tlv_struct *) &pd[offset];
switch( ntohs(tlv->type) ){
case 1: /* ??? Chasis ID */
add_item_to_tree(cdp_tree, offset + 4, ntohs(tlv->length) - 4, "Chassis ID: %s", &pd[offset+4] );
offset+=ntohs(tlv->length);
break;
case 3: /* ??? Port */
add_item_to_tree(cdp_tree, offset + 4, ntohs(tlv->length) - 4, "Interface: %s", &pd[offset+4] );
offset+=ntohs(tlv->length);
break;
case 5: /* ??? IOS Version */
add_item_to_tree(cdp_tree, offset + 4, ntohs(tlv->length) - 4, "IOS: %s", &pd[offset+4] );
offset+=ntohs(tlv->length);
break;
case 0x01cc: /* ??? Mgmt Addr
offset+=ntohs(tlv->length);
break;
*/
default:
/*
add_item_to_tree(cdp_tree, offset, 2, "Type: %d", ntohs(tlv->type));
add_item_to_tree(cdp_tree, offset + 2, 2, "Length: %d", ntohs(tlv->length));
add_item_to_tree(cdp_tree, offset + 4, ntohs(tlv->length), "Data");
*/
offset+=ntohs(tlv->length);
}
}
dissect_data(pd, offset, fd, (GtkTree *) cdp_tree);
}
dissect_data(pd, offset, fd, (GtkTree *) cdp_tree);
}
}