forked from osmocom/wireshark
Okay. Please test the CVS code....
I think I figured out how CDP works :) ---- svn path=/trunk/; revision=155
This commit is contained in:
parent
5fdf1b9532
commit
e39752f194
79
packet-cdp.c
79
packet-cdp.c
|
@ -2,7 +2,7 @@
|
||||||
* Routines for the disassembly of the "Cisco Discovery Protocoll"
|
* Routines for the disassembly of the "Cisco Discovery Protocoll"
|
||||||
* (c) Copyright Hannes R. Boehm <hannes@boehm.org>
|
* (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
|
* Ethereal - Network traffic analyzer
|
||||||
* By Gerald Combs <gerald@zing.org>
|
* By Gerald Combs <gerald@zing.org>
|
||||||
|
@ -45,17 +45,20 @@
|
||||||
void
|
void
|
||||||
dissect_cdp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
|
dissect_cdp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
|
||||||
GtkWidget *cdp_tree = NULL, *ti;
|
GtkWidget *cdp_tree = NULL, *ti;
|
||||||
char *version;
|
|
||||||
char *hostname;
|
|
||||||
char *interface;
|
|
||||||
|
|
||||||
typedef struct _e_tlv_struct{
|
typedef struct _e_tlv_struct{
|
||||||
short type;
|
gint16 type;
|
||||||
short length;
|
gint16 length;
|
||||||
} e_tlv_struct;
|
} e_tlv_struct;
|
||||||
|
|
||||||
|
typedef struct _e_cdp_hdr{
|
||||||
|
char version;
|
||||||
|
char flags;
|
||||||
|
gint16 ttl;
|
||||||
|
} e_cdp_hdr;
|
||||||
|
|
||||||
e_tlv_struct *tlv;
|
e_tlv_struct *tlv;
|
||||||
int i,j;
|
e_cdp_hdr *cdp_hdr;
|
||||||
|
|
||||||
|
|
||||||
if (check_col(fd, COL_PROTOCOL))
|
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();
|
cdp_tree = gtk_tree_new();
|
||||||
add_subtree(ti, cdp_tree, ETT_CDP);
|
add_subtree(ti, cdp_tree, ETT_CDP);
|
||||||
|
|
||||||
version=(char *) &pd[offset];
|
/* CDP header */
|
||||||
hostname=(char *) &pd[offset+8];
|
cdp_hdr = (e_cdp_hdr *) &pd[offset];
|
||||||
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, 0, "under development (hannes@boehm.org)");
|
||||||
add_item_to_tree(cdp_tree, offset, 1, "Version: %d", *version);
|
add_item_to_tree(cdp_tree, offset, 1, "Version: %d", cdp_hdr->version);
|
||||||
add_item_to_tree(cdp_tree, offset+8, 1, "Chassis ID: %s", hostname);
|
add_item_to_tree(cdp_tree, offset+1, 1, "Flags (unknown)");
|
||||||
add_item_to_tree(cdp_tree, offset+34, 1, "Interface: %s", interface);
|
add_item_to_tree(cdp_tree, offset+2, 2, "TTL (unknown)");
|
||||||
|
offset+=4;
|
||||||
|
|
||||||
/* CVS -> exit here
|
/* CVS -> exit here
|
||||||
dissect_data(pd, offset, fd, (GtkTree *) cdp_tree);
|
dissect_data(pd, offset, fd, (GtkTree *) cdp_tree);
|
||||||
return;
|
return;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
i=4;
|
while( offset <= fd->cap_len ){
|
||||||
j=0;
|
tlv = (e_tlv_struct *) &pd[offset];
|
||||||
while(i < 1500 ){
|
switch( ntohs(tlv->type) ){
|
||||||
tlv = (e_tlv_struct *) &pd[offset+i];
|
case 1: /* ??? Chasis ID */
|
||||||
add_item_to_tree(cdp_tree, offset+i, 2, "Type: %d", ntohs(tlv->type));
|
add_item_to_tree(cdp_tree, offset + 4, ntohs(tlv->length) - 4, "Chassis ID: %s", &pd[offset+4] );
|
||||||
add_item_to_tree(cdp_tree, offset+i+2, 2, "Length: %d", ntohs(tlv->length));
|
offset+=ntohs(tlv->length);
|
||||||
if( (ntohs(tlv->type) == 0) && j==0) {
|
break;
|
||||||
j=1;
|
case 3: /* ??? Port */
|
||||||
i+= ntohs(tlv->length) + 4;
|
add_item_to_tree(cdp_tree, offset + 4, ntohs(tlv->length) - 4, "Interface: %s", &pd[offset+4] );
|
||||||
} else if( (ntohs(tlv->type) == 0) && j==1) {
|
offset+=ntohs(tlv->length);
|
||||||
j=0;
|
break;
|
||||||
i+= 4;
|
case 5: /* ??? IOS Version */
|
||||||
} else {
|
add_item_to_tree(cdp_tree, offset + 4, ntohs(tlv->length) - 4, "IOS: %s", &pd[offset+4] );
|
||||||
i+= ntohs(tlv->length) + 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue