forked from osmocom/wireshark
GVRP dissector, from Kevin Shi.
svn path=/trunk/; revision=2721
This commit is contained in:
parent
8af1fc6550
commit
60b1bed605
4
AUTHORS
4
AUTHORS
|
@ -444,6 +444,10 @@ Frank Singleton <frank.singleton@ericsson.com> {
|
|||
Short integer CDR support for GIOP
|
||||
}
|
||||
|
||||
Kevin Shi <techishi@ms22.hinet.net> {
|
||||
GVRP support
|
||||
}
|
||||
|
||||
Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to
|
||||
give his permission to use his version of snprintf.c.
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Makefile.am
|
||||
# Automake file for Ethereal
|
||||
#
|
||||
# $Id: Makefile.am,v 1.255 2000/11/29 13:15:00 sharpe Exp $
|
||||
# $Id: Makefile.am,v 1.256 2000/11/30 09:31:50 guy Exp $
|
||||
#
|
||||
# Ethereal - Network traffic analyzer
|
||||
# By Gerald Combs <gerald@zing.org>
|
||||
|
@ -64,6 +64,7 @@ DISSECTOR_SOURCES = \
|
|||
packet-ftp.c \
|
||||
packet-giop.c \
|
||||
packet-gre.c \
|
||||
packet-gvrp.c \
|
||||
packet-h1.c \
|
||||
packet-h261.c \
|
||||
packet-hsrp.c \
|
||||
|
@ -199,6 +200,7 @@ noinst_HEADERS = \
|
|||
packet-eth.h \
|
||||
packet-fddi.h \
|
||||
packet-frame.h \
|
||||
packet-gvrp.h \
|
||||
packet-h261.h \
|
||||
packet-http.h \
|
||||
packet-ieee80211.h \
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
## Makefile for building ethereal.exe with Microsoft C and nmake
|
||||
## Use: nmake -f makefile.nmake
|
||||
#
|
||||
# $Id: Makefile.nmake,v 1.65 2000/11/29 13:20:06 gram Exp $
|
||||
# $Id: Makefile.nmake,v 1.66 2000/11/30 09:31:50 guy Exp $
|
||||
|
||||
include config.nmake
|
||||
|
||||
|
@ -51,6 +51,7 @@ DISSECTOR_SOURCES = \
|
|||
packet-ftp.c \
|
||||
packet-giop.c \
|
||||
packet-gre.c \
|
||||
packet-gvrp.c \
|
||||
packet-h1.c \
|
||||
packet-h261.c \
|
||||
packet-hsrp.c \
|
||||
|
|
|
@ -1005,6 +1005,7 @@ B<http://www.ethereal.com>.
|
|||
Ed Warnicke <hagbard@physics.rutgers.edu>
|
||||
Johan Jorgensen <johan.jorgensen@axis.com>
|
||||
Frank Singleton <frank.singleton@ericsson.com>
|
||||
Kevin Shi <techishi@ms22.hinet.net>
|
||||
|
||||
Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to give his
|
||||
permission to use his version of snprintf.c.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* packet-bpdu.c
|
||||
* Routines for BPDU (Spanning Tree Protocol) disassembly
|
||||
*
|
||||
* $Id: packet-bpdu.c,v 1.15 2000/11/19 08:53:55 guy Exp $
|
||||
* $Id: packet-bpdu.c,v 1.16 2000/11/30 09:31:50 guy Exp $
|
||||
*
|
||||
* Copyright 1999 Christophe Tronche <ch.tronche@computer.org>
|
||||
*
|
||||
|
@ -44,6 +44,9 @@
|
|||
#include "llcsaps.h"
|
||||
#include "resolv.h"
|
||||
|
||||
/* Include this for GVRP dissector */
|
||||
#include "packet-gvrp.h"
|
||||
|
||||
/* Offsets of fields within a BPDU */
|
||||
|
||||
#define BPDU_IDENTIFIER 0
|
||||
|
@ -99,6 +102,46 @@ dissect_bpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
|
|||
|
||||
CHECK_DISPLAY_AS_DATA(proto_bpdu, tvb, pinfo, tree);
|
||||
|
||||
/* GARP application frames require special interpretation of the
|
||||
destination address field; otherwise, they will be mistaken as
|
||||
BPDU frames.
|
||||
Fortunately, they can be recognized by checking the first 6 octets
|
||||
of the destination address, which are in the range from
|
||||
01-80-C2-00-00-20 to 01-80-C2-00-00-2F. */
|
||||
if (pinfo->dl_dst.data[0] == 0x01 && pinfo->dl_dst.data[1] == 0x80 &&
|
||||
pinfo->dl_dst.data[2] == 0xC2 && pinfo->dl_dst.data[3] == 0x00 &&
|
||||
pinfo->dl_dst.data[4] == 0x00 && ((pinfo->dl_dst.data[5] & 0x20) == 0x20)) {
|
||||
|
||||
protocol_identifier = tvb_get_ntohs(tvb, BPDU_IDENTIFIER);
|
||||
|
||||
switch (pinfo->dl_dst.data[5]) {
|
||||
|
||||
case 0x20:
|
||||
/* Future expansion for GMRP */
|
||||
break;
|
||||
|
||||
case 0x21:
|
||||
/* for GVRP */
|
||||
dissect_gvrp(tvb, pinfo, tree);
|
||||
return;
|
||||
}
|
||||
|
||||
pinfo->current_proto = "GARP";
|
||||
|
||||
if (check_col(pinfo->fd, COL_PROTOCOL)) {
|
||||
col_set_str(pinfo->fd, COL_PROTOCOL, "GARP");
|
||||
/* Generic Attribute Registration Protocol */
|
||||
}
|
||||
|
||||
if (check_col(pinfo->fd, COL_INFO)) {
|
||||
col_add_fstr(pinfo->fd, COL_INFO,
|
||||
"Unknown GARP application (0x%02X)",
|
||||
pinfo->dl_dst.data[5]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
pinfo->current_proto = "STP";
|
||||
|
||||
bpdu_type = tvb_get_guint8(tvb, BPDU_TYPE);
|
||||
|
@ -142,7 +185,8 @@ dissect_bpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
|
|||
BPDU_VERSION_IDENTIFIER, 1,
|
||||
protocol_version_identifier);
|
||||
if (protocol_version_identifier != 0)
|
||||
proto_tree_add_text(bpdu_tree, tvb, BPDU_VERSION_IDENTIFIER, 1, " (Warning: this version of packet-bpdu only knows about version = 0)");
|
||||
proto_tree_add_text(bpdu_tree, tvb, BPDU_VERSION_IDENTIFIER, 1,
|
||||
" (Warning: this version of Ethereal only knows about version = 0)");
|
||||
proto_tree_add_uint_format(bpdu_tree, hf_bpdu_type, tvb,
|
||||
BPDU_TYPE, 1,
|
||||
bpdu_type,
|
||||
|
|
|
@ -0,0 +1,346 @@
|
|||
/* packet-gvrp.c
|
||||
* Routines for GVRP (GARP VLAN Registration Protocol) dissection
|
||||
* Copyright 2000, Kevin Shi <techishi@ms22.hinet.net>
|
||||
*
|
||||
* $Id: packet-gvrp.c,v 1.1 2000/11/30 09:31:50 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef NEED_SNPRINTF_H
|
||||
# include "snprintf.h"
|
||||
#endif
|
||||
|
||||
#include "packet.h"
|
||||
#include "llcsaps.h"
|
||||
|
||||
/* Initialize the protocol and registered fields */
|
||||
static int proto_gvrp = -1;
|
||||
static int hf_gvrp_proto_id = -1;
|
||||
static int hf_gvrp_attribute_type = -1;
|
||||
static int hf_gvrp_attribute_length = -1;
|
||||
static int hf_gvrp_attribute_event = -1;
|
||||
static int hf_gvrp_attribute_value = -1;
|
||||
static int hf_gvrp_end_of_mark = -1;
|
||||
|
||||
/* Initialize the subtree pointers */
|
||||
static gint ett_gvrp = -1;
|
||||
static gint ett_gvrp_message = -1;
|
||||
static gint ett_gvrp_attribute_list = -1;
|
||||
static gint ett_gvrp_attribute = -1;
|
||||
|
||||
/* Constant definitions */
|
||||
#define GARP_DEFAULT_PROTOCOL_ID 0x0001
|
||||
#define GARP_END_OF_MARK 0x00
|
||||
|
||||
#define GVRP_ATTRIBUTE_TYPE 0x01
|
||||
|
||||
static const value_string attribute_type_vals[] = {
|
||||
{ GVRP_ATTRIBUTE_TYPE, "VID" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
/* The length of GVRP LeaveAll attribute should be 2 octets (one for length
|
||||
* and the other for event) */
|
||||
#define GVRP_LENGTH_LEAVEALL (sizeof(guint8)+sizeof(guint8))
|
||||
|
||||
/* The length of GVRP attribute other than LeaveAll should be 4 octets (one
|
||||
* for length, one for event, and the last two for VID value).
|
||||
*/
|
||||
#define GVRP_LENGTH_NON_LEAVEALL (sizeof(guint8)+sizeof(guint8)+sizeof(guint16))
|
||||
|
||||
/* Packet offset definitions */
|
||||
#define GARP_PROTOCOL_ID 0
|
||||
|
||||
/* Event definitions */
|
||||
#define GVRP_EVENT_LEAVEALL 0
|
||||
#define GVRP_EVENT_JOINEMPTY 1
|
||||
#define GVRP_EVENT_JOININ 2
|
||||
#define GVRP_EVENT_LEAVEEMPTY 3
|
||||
#define GVRP_EVENT_LEAVEIN 4
|
||||
#define GVRP_EVENT_EMPTY 5
|
||||
|
||||
static const value_string event_vals[] = {
|
||||
{ GVRP_EVENT_LEAVEALL, "Leave All" },
|
||||
{ GVRP_EVENT_JOINEMPTY, "Join Empty" },
|
||||
{ GVRP_EVENT_JOININ, "Join In" },
|
||||
{ GVRP_EVENT_LEAVEEMPTY, "Leave Empty" },
|
||||
{ GVRP_EVENT_LEAVEIN, "Leave In" },
|
||||
{ GVRP_EVENT_EMPTY, "Empty" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
/* Code to actually dissect the packets */
|
||||
void
|
||||
dissect_gvrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||
{
|
||||
proto_item *ti;
|
||||
proto_tree *gvrp_tree;
|
||||
guint16 protocol_id;
|
||||
guint8 octet;
|
||||
int msg_index, attr_index, offset = 0, length = tvb_reported_length(tvb);
|
||||
|
||||
CHECK_DISPLAY_AS_DATA(proto_gvrp, tvb, pinfo, tree);
|
||||
|
||||
pinfo->current_proto = "GVRP";
|
||||
|
||||
if (check_col(pinfo->fd, COL_PROTOCOL))
|
||||
col_set_str(pinfo->fd, COL_PROTOCOL, "GVRP");
|
||||
|
||||
if (check_col(pinfo->fd, COL_INFO))
|
||||
col_set_str(pinfo->fd, COL_INFO, "GVRP");
|
||||
|
||||
if (tree)
|
||||
{
|
||||
ti = proto_tree_add_item(tree, proto_gvrp, tvb, 0, length, FALSE);
|
||||
|
||||
gvrp_tree = proto_item_add_subtree(ti, ett_gvrp);
|
||||
|
||||
/* Read in GARP protocol ID */
|
||||
protocol_id = tvb_get_ntohs(tvb, GARP_PROTOCOL_ID);
|
||||
|
||||
proto_tree_add_uint_format(gvrp_tree, hf_gvrp_proto_id, tvb,
|
||||
GARP_PROTOCOL_ID, sizeof(guint16),
|
||||
protocol_id,
|
||||
"Protocol Identifier: 0x%04x (%s)",
|
||||
protocol_id,
|
||||
protocol_id == GARP_DEFAULT_PROTOCOL_ID ?
|
||||
"GARP VLAN Registration Protocol" :
|
||||
"Unknown Protocol");
|
||||
|
||||
/* Currently only one protocol ID is supported */
|
||||
if (protocol_id != GARP_DEFAULT_PROTOCOL_ID)
|
||||
{
|
||||
proto_tree_add_text(gvrp_tree, tvb, GARP_PROTOCOL_ID, sizeof(guint16),
|
||||
" (Warning: this version of Ethereal only knows about protocol id = 1)");
|
||||
dissect_data(tvb, GARP_PROTOCOL_ID + sizeof(guint16), pinfo, tree);
|
||||
return;
|
||||
}
|
||||
|
||||
offset += sizeof(guint16);
|
||||
length -= sizeof(guint16);
|
||||
|
||||
msg_index = 0;
|
||||
|
||||
/* Begin to parse GARP messages */
|
||||
while (length)
|
||||
{
|
||||
proto_item *msg_item;
|
||||
int msg_start = offset;
|
||||
|
||||
/* Read in attribute type. */
|
||||
octet = tvb_get_guint8(tvb, offset);
|
||||
|
||||
/* Check for end of mark */
|
||||
if (octet == GARP_END_OF_MARK)
|
||||
{
|
||||
/* End of GARP PDU */
|
||||
if (msg_index)
|
||||
{
|
||||
proto_tree_add_text(gvrp_tree, tvb, offset, sizeof(guint8),
|
||||
"End of mark");
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
dissect_data(tvb, offset, pinfo, tree);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
offset += sizeof(guint8);
|
||||
length -= sizeof(guint8);
|
||||
|
||||
msg_item = proto_tree_add_text(gvrp_tree, tvb, msg_start, 0,
|
||||
"Message %d", msg_index + 1);
|
||||
|
||||
proto_tree_add_uint(gvrp_tree, hf_gvrp_attribute_type, tvb,
|
||||
msg_start, sizeof(guint8), octet);
|
||||
|
||||
/* GVRP only supports one attribute type. */
|
||||
if (octet != GVRP_ATTRIBUTE_TYPE)
|
||||
{
|
||||
dissect_data(tvb, offset, pinfo, tree);
|
||||
return;
|
||||
}
|
||||
|
||||
attr_index = 0;
|
||||
|
||||
while (length)
|
||||
{
|
||||
int attr_start = offset;
|
||||
proto_item *attr_item;
|
||||
|
||||
/* Read in attribute length. */
|
||||
octet = tvb_get_guint8(tvb, offset);
|
||||
|
||||
/* Check for end of mark */
|
||||
if (octet == GARP_END_OF_MARK)
|
||||
{
|
||||
/* If at least one message has been already read,
|
||||
* check for another end of mark.
|
||||
*/
|
||||
if (attr_index)
|
||||
{
|
||||
proto_tree_add_text(gvrp_tree, tvb, offset,
|
||||
sizeof(guint8), " End of mark");
|
||||
|
||||
offset += sizeof(guint8);
|
||||
length -= sizeof(guint8);
|
||||
|
||||
proto_item_set_len(msg_item, offset - msg_start);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
dissect_data(tvb, offset, pinfo, tree);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
guint8 event;
|
||||
|
||||
offset += sizeof(guint8);
|
||||
length -= sizeof(guint8);
|
||||
|
||||
attr_item = proto_tree_add_text(gvrp_tree, tvb,
|
||||
attr_start, 0, " Attribute %d", attr_index + 1);
|
||||
|
||||
proto_tree_add_uint(gvrp_tree, hf_gvrp_attribute_length,
|
||||
tvb, attr_start, sizeof(guint8), octet);
|
||||
|
||||
/* Read in attribute event */
|
||||
event = tvb_get_guint8(tvb, offset);
|
||||
|
||||
proto_tree_add_uint(gvrp_tree, hf_gvrp_attribute_event,
|
||||
tvb, offset, sizeof(guint8), event);
|
||||
|
||||
offset += sizeof(guint8);
|
||||
length -= sizeof(guint8);
|
||||
|
||||
switch (event) {
|
||||
|
||||
case GVRP_EVENT_LEAVEALL:
|
||||
if (octet != GVRP_LENGTH_LEAVEALL)
|
||||
{
|
||||
dissect_data(tvb, offset, pinfo, tree);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case GVRP_EVENT_JOINEMPTY:
|
||||
case GVRP_EVENT_JOININ:
|
||||
case GVRP_EVENT_LEAVEEMPTY:
|
||||
case GVRP_EVENT_LEAVEIN:
|
||||
case GVRP_EVENT_EMPTY:
|
||||
if (octet != GVRP_LENGTH_NON_LEAVEALL)
|
||||
{
|
||||
dissect_data(tvb, offset, pinfo, tree);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Show attribute value */
|
||||
proto_tree_add_item(gvrp_tree, hf_gvrp_attribute_value,
|
||||
tvb, offset, sizeof(guint16), FALSE);
|
||||
|
||||
offset += sizeof(guint16);
|
||||
length -= sizeof(guint16);
|
||||
break;
|
||||
|
||||
default:
|
||||
dissect_data(tvb, offset, pinfo, tree);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
proto_item_set_len(attr_item, offset - attr_start);
|
||||
|
||||
attr_index++;
|
||||
}
|
||||
|
||||
msg_index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Register the protocol with Ethereal */
|
||||
void
|
||||
proto_register_gvrp(void)
|
||||
{
|
||||
static hf_register_info hf[] = {
|
||||
{ &hf_gvrp_proto_id,
|
||||
{ "Protocol ID", "garp.protocol_id",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
"" }
|
||||
},
|
||||
{ &hf_gvrp_attribute_type,
|
||||
{ "Type", "garp.attribute_type",
|
||||
FT_UINT8, BASE_HEX, VALS(attribute_type_vals), 0x0,
|
||||
"" }
|
||||
},
|
||||
{ &hf_gvrp_attribute_length,
|
||||
{ "Length", "garp.attribute_length",
|
||||
FT_UINT8, BASE_DEC, NULL, 0x0,
|
||||
"" }
|
||||
},
|
||||
{ &hf_gvrp_attribute_event,
|
||||
{ "Event", "garp.attribute_event",
|
||||
FT_UINT8, BASE_DEC, VALS(event_vals), 0x0,
|
||||
"" }
|
||||
},
|
||||
{ &hf_gvrp_attribute_value,
|
||||
{ "Value", "garp.attribute_value",
|
||||
FT_UINT16, BASE_DEC, NULL, 0x0,
|
||||
"" }
|
||||
}
|
||||
};
|
||||
|
||||
static gint *ett[] = {
|
||||
&ett_gvrp
|
||||
};
|
||||
|
||||
/* Register the protocol name and description for GVRP */
|
||||
proto_gvrp = proto_register_protocol("GARP VLAN Registration Protocol",
|
||||
"GVRP");
|
||||
|
||||
/* Required function calls to register the header fields and subtrees
|
||||
* used by GVRP */
|
||||
proto_register_field_array(proto_gvrp, hf, array_length(hf));
|
||||
proto_register_subtree_array(ett, array_length(ett));
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/* packet-gvrp.h
|
||||
* Declarations of routines for GVRP (GARP VLAN Registration Protocol)
|
||||
* dissection
|
||||
* Copyright 2000, Kevin Shi <techishi@ms22.hinet.net>
|
||||
*
|
||||
* $Id: packet-gvrp.h,v 1.1 2000/11/30 09:31:50 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __PACKET_GVRP_H__
|
||||
#define __PACKET_GVRP_H__
|
||||
|
||||
void dissect_gvrp(tvbuff_t *, packet_info *, proto_tree *);
|
||||
|
||||
#endif /* packet-gvrp.h */
|
||||
|
Loading…
Reference in New Issue