From Alvaro Vega Garcia:
Support ZIOP and MIOP (specialized CORBA protocols). https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3238 svn path=/trunk/; revision=27589
This commit is contained in:
parent
d74b26303c
commit
c1e511b92e
|
@ -603,6 +603,7 @@ DISSECTOR_SRC = \
|
|||
packet-megaco.c \
|
||||
packet-mgcp.c \
|
||||
packet-mikey.c \
|
||||
packet-miop.c \
|
||||
packet-mip.c \
|
||||
packet-mip6.c \
|
||||
packet-ms-mms.c \
|
||||
|
@ -884,6 +885,7 @@ DISSECTOR_SRC = \
|
|||
packet-ypserv.c \
|
||||
packet-ypxfr.c \
|
||||
packet-zebra.c \
|
||||
packet-ziop.c \
|
||||
packet-zrtp.c
|
||||
|
||||
#
|
||||
|
@ -1065,6 +1067,7 @@ DISSECTOR_INCLUDES = \
|
|||
packet-mac-lte.h \
|
||||
packet-mgcp.h \
|
||||
packet-mikey.h \
|
||||
packet-miop.h \
|
||||
packet-mip6.h \
|
||||
packet-mms.h \
|
||||
packet-mount.h \
|
||||
|
@ -1208,6 +1211,7 @@ DISSECTOR_INCLUDES = \
|
|||
packet-yppasswd.h \
|
||||
packet-ypserv.h \
|
||||
packet-ypxfr.h \
|
||||
packet-ziop.h \
|
||||
rpc_defrag.h \
|
||||
$(GENERATED_HEADER_FILES) \
|
||||
$(CUSTOM_HEADER_FILES)
|
||||
|
|
|
@ -300,6 +300,7 @@
|
|||
#include <epan/prefs.h>
|
||||
|
||||
#include "packet-giop.h"
|
||||
#include "packet-ziop.h"
|
||||
#include "packet-tcp.h"
|
||||
#include <wsutil/file_util.h>
|
||||
|
||||
|
@ -587,8 +588,6 @@ static const value_string service_context_ids[] = {
|
|||
|
||||
|
||||
|
||||
#define GIOP_MAGIC "GIOP"
|
||||
|
||||
/*
|
||||
* TAGS for IOR Profiles
|
||||
*
|
||||
|
@ -4053,8 +4052,26 @@ get_giop_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
|
|||
return message_size + GIOP_HEADER_SIZE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
dissect_giop_heur (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree);
|
||||
|
||||
|
||||
gboolean dissect_giop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
|
||||
return dissect_giop_heur(tvb, pinfo, tree);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dissect_giop_tcp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) {
|
||||
|
||||
if ( tvb_memeql(tvb, 0, GIOP_MAGIC ,4) != 0) {
|
||||
|
||||
if ( tvb_memeql(tvb, 0, ZIOP_MAGIC ,4) == 0)
|
||||
dissect_ziop_heur(tvb, pinfo, tree);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
tcp_dissect_pdus(tvb, pinfo, tree, giop_desegment, GIOP_HEADER_SIZE,
|
||||
get_giop_pdu_len, dissect_giop_common);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
*/
|
||||
|
||||
#define GIOP_HEADER_SIZE 12
|
||||
#define GIOP_MAGIC "GIOP"
|
||||
|
||||
typedef struct Version {
|
||||
guint8 major;
|
||||
|
|
|
@ -0,0 +1,345 @@
|
|||
/* packet-miop.c
|
||||
* Routines for CORBA MIOP packet disassembly
|
||||
* Significantly based on packet-giop.c
|
||||
* Copyright 2009 Alvaro Vega Garcia <avega at tid dot es>
|
||||
*
|
||||
* According with Unreliable Multicast Draft Adopted Specification
|
||||
* 2001 October (OMG)
|
||||
* Chapter 29: Unreliable Multicast Inter-ORB Protocol (MIOP)
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.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 <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <glib.h>
|
||||
#include <math.h>
|
||||
#ifdef NEED_STRERROR_H
|
||||
#include "strerror.h"
|
||||
#endif
|
||||
|
||||
#include "isprint.h"
|
||||
|
||||
#include <epan/packet.h>
|
||||
#include <epan/emem.h>
|
||||
|
||||
#include "packet-miop.h"
|
||||
#include "packet-giop.h"
|
||||
#include "packet-tcp.h"
|
||||
|
||||
#ifdef NEED_G_ASCII_STRCASECMP_H
|
||||
#include "g_ascii_strcasecmp.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set to 1 for DEBUG output - TODO make this a runtime option
|
||||
*/
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------------------------------------------+
|
||||
* Data/Variables/Structs
|
||||
* ------------------------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
static int proto_miop = -1;
|
||||
|
||||
/*
|
||||
* (sub)Tree declares
|
||||
*/
|
||||
|
||||
|
||||
static gint hf_miop_magic = -1;
|
||||
static gint hf_miop_hdr_version = -1;
|
||||
static gint hf_miop_flags = -1;
|
||||
static gint hf_miop_packet_length = -1;
|
||||
static gint hf_miop_packet_number = -1;
|
||||
static gint hf_miop_number_of_packets = -1;
|
||||
static gint hf_miop_unique_id_len = -1;
|
||||
static gint hf_miop_unique_id = -1;
|
||||
|
||||
|
||||
static gint ett_miop_magic = -1;
|
||||
static gint ett_miop_hdr_version = -1;
|
||||
static gint ett_miop_flags = -1;
|
||||
static gint ett_miop_packet_length = -1;
|
||||
static gint ett_miop_packet_number = -1;
|
||||
static gint ett_miop_number_of_packets = -1;
|
||||
static gint ett_miop_unique_id_len = -1;
|
||||
static gint ett_miop_unique_id = -1;
|
||||
|
||||
|
||||
static dissector_handle_t miop_handle;
|
||||
|
||||
#define MIOP_MAGIC "MIOP"
|
||||
|
||||
|
||||
static gboolean
|
||||
dissect_miop_heur (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) {
|
||||
|
||||
guint tot_len;
|
||||
|
||||
/* check magic number and version */
|
||||
|
||||
|
||||
tot_len = tvb_length(tvb);
|
||||
|
||||
if (tot_len < MIOP_HEADER_SIZE) /* tot_len < 16 */
|
||||
{
|
||||
/* Not enough data captured to hold the GIOP header; don't try
|
||||
to interpret it as GIOP. */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( tvb_memeql(tvb, 0, MIOP_MAGIC ,4) != 0)
|
||||
return FALSE;
|
||||
|
||||
if (pinfo->ptype != PT_UDP)
|
||||
return FALSE;
|
||||
|
||||
dissect_miop (tvb, pinfo, tree);
|
||||
|
||||
/* TODO: make reasembly */
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Main entry point */
|
||||
static void dissect_miop (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) {
|
||||
guint offset = 0;
|
||||
PacketHeader header;
|
||||
UniqueId unique_id;
|
||||
|
||||
tvbuff_t *miop_header_tvb;
|
||||
tvbuff_t *unique_id_len_tvb;
|
||||
tvbuff_t *unique_id_tvb;
|
||||
tvbuff_t *payload_tvb;
|
||||
|
||||
proto_tree *clnp_tree = NULL;
|
||||
proto_item *ti;
|
||||
|
||||
guint version_major;
|
||||
guint version_minor;
|
||||
|
||||
guint16 packet_length;
|
||||
guint packet_number;
|
||||
guint number_of_packets;
|
||||
gboolean stream_is_big_endian;
|
||||
|
||||
miop_header_tvb = tvb_new_subset (tvb, 0, MIOP_HEADER_SIZE, -1);
|
||||
tvb_memcpy (miop_header_tvb, (guint8 *)&header, 0, MIOP_HEADER_SIZE );
|
||||
|
||||
unique_id_len_tvb = tvb_new_subset (tvb, MIOP_HEADER_SIZE, 4, -1);
|
||||
tvb_memcpy (unique_id_len_tvb, (guint32 *)&(unique_id.id_len), 0, 4);
|
||||
|
||||
unique_id_tvb = tvb_new_subset (tvb, MIOP_HEADER_SIZE + 4, unique_id.id_len, -1);
|
||||
/*unique_id.id = g_malloc(unique_id.id_len);*/
|
||||
unique_id.id = ep_alloc(unique_id.id_len);
|
||||
tvb_memcpy (unique_id_tvb, (guint8 *)(unique_id.id), 0, unique_id.id_len);
|
||||
|
||||
payload_tvb = tvb_new_subset (tvb, MIOP_HEADER_SIZE + 4 + unique_id.id_len, -1, -1);
|
||||
|
||||
|
||||
if (check_col (pinfo->cinfo, COL_PROTOCOL)) {
|
||||
col_set_str (pinfo->cinfo, COL_PROTOCOL, MIOP_MAGIC);
|
||||
}
|
||||
|
||||
/* Clear out stuff in the info column */
|
||||
if (check_col(pinfo->cinfo, COL_INFO)) {
|
||||
col_clear(pinfo->cinfo, COL_INFO);
|
||||
}
|
||||
|
||||
/* Extract major and minor version numbers */
|
||||
version_major = ((header.hdr_version & 0xf0) >> 4);
|
||||
version_minor = (header.hdr_version & 0x0f);
|
||||
|
||||
if (header.hdr_version != 16)
|
||||
{
|
||||
if (check_col (pinfo->cinfo, COL_INFO))
|
||||
{
|
||||
col_add_fstr (pinfo->cinfo, COL_INFO, "Version %u.%u",
|
||||
version_major, version_minor);
|
||||
}
|
||||
if (tree)
|
||||
{
|
||||
ti = proto_tree_add_item (tree, proto_miop, tvb, 0, -1, FALSE);
|
||||
clnp_tree = proto_item_add_subtree (ti, ett_miop_hdr_version);
|
||||
proto_tree_add_text (clnp_tree, miop_header_tvb, 0, -1,
|
||||
"Version %u.%u not supported",
|
||||
version_major, version_minor);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
stream_is_big_endian = ((header.flags & 0x01) == 0);
|
||||
|
||||
if (stream_is_big_endian) {
|
||||
packet_length = pntohs (&header.packet_length);
|
||||
packet_number = pntohl (&header.packet_number);
|
||||
number_of_packets = pntohl (&header.number_of_packets);
|
||||
}
|
||||
else {
|
||||
packet_length = pletohs (&header.packet_length);
|
||||
packet_number = pletohl (&header.packet_number);
|
||||
number_of_packets = pletohl (&header.number_of_packets);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (check_col (pinfo->cinfo, COL_INFO))
|
||||
{
|
||||
col_add_fstr (pinfo->cinfo, COL_INFO, "MIOP %u.%u Packet s=%d (%u of %u)",
|
||||
version_major, version_minor, header.packet_length,
|
||||
header.packet_number + 1,
|
||||
header.number_of_packets);
|
||||
}
|
||||
|
||||
if (tree)
|
||||
{
|
||||
ti = proto_tree_add_item (tree, proto_miop, tvb, 0, -1, FALSE);
|
||||
clnp_tree = proto_item_add_subtree (ti, ett_miop_magic);
|
||||
proto_tree_add_text (clnp_tree, miop_header_tvb, offset, 4,
|
||||
"Magic number: %s", MIOP_MAGIC);
|
||||
offset += 4;
|
||||
clnp_tree = proto_item_add_subtree (ti, ett_miop_hdr_version);
|
||||
proto_tree_add_text (clnp_tree, miop_header_tvb, offset, 1,
|
||||
"Version: %u.%u", version_major, version_minor);
|
||||
offset++;
|
||||
clnp_tree = proto_item_add_subtree (ti, ett_miop_flags);
|
||||
proto_tree_add_text (clnp_tree, miop_header_tvb, offset, 1,
|
||||
"Flags: 0x%02x (%s)", header.flags,
|
||||
(stream_is_big_endian) ? "big-endian" : "little-endian");
|
||||
offset++;
|
||||
clnp_tree = proto_item_add_subtree (ti, ett_miop_packet_length);
|
||||
proto_tree_add_text (clnp_tree, miop_header_tvb, offset, 2,
|
||||
"Packet length: %d", packet_length);
|
||||
offset += 2;
|
||||
clnp_tree = proto_item_add_subtree (ti, ett_miop_packet_number);
|
||||
proto_tree_add_text (clnp_tree, miop_header_tvb, offset, 4,
|
||||
"Packet number: %d", packet_number);
|
||||
offset += 4;
|
||||
clnp_tree = proto_item_add_subtree (ti, ett_miop_number_of_packets);
|
||||
proto_tree_add_text (clnp_tree, miop_header_tvb, offset, 4,
|
||||
"Number of packets: %d", number_of_packets);
|
||||
|
||||
offset = 0;
|
||||
clnp_tree = proto_item_add_subtree (ti, ett_miop_unique_id_len);
|
||||
proto_tree_add_text (clnp_tree, unique_id_len_tvb, offset, 4,
|
||||
"Unique Id length: %d", unique_id.id_len);
|
||||
|
||||
clnp_tree = proto_item_add_subtree (ti, ett_miop_unique_id);
|
||||
proto_tree_add_text (clnp_tree, unique_id_tvb, offset, unique_id.id_len,
|
||||
"Unique Id: (string) %s",
|
||||
make_printable_string(unique_id.id, unique_id.id_len));
|
||||
|
||||
if (header.packet_number == 0)
|
||||
/* It is the first packet of the collection
|
||||
We can call to GIOP dissector to show more about this first
|
||||
uncompleted GIOP message
|
||||
*/
|
||||
dissect_giop(payload_tvb, pinfo, tree);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void proto_register_miop (void) {
|
||||
|
||||
|
||||
/* A header field is something you can search/filter on.
|
||||
*
|
||||
* We create a structure to register our fields. It consists of an
|
||||
* array of hf_register_info structures, each of which are of the format
|
||||
* {&(field id), {name, abbrev, type, display, strings, bitmask, blurb, HFILL}}.
|
||||
*/
|
||||
static hf_register_info hf[] = {
|
||||
{ &hf_miop_magic,
|
||||
{ "Magic", "miop.magic", FT_UINT32, BASE_DEC, NULL, 0x0,
|
||||
"PacketHeader magic", HFILL }},
|
||||
{ &hf_miop_hdr_version,
|
||||
{ "Version", "miop.hdr_version", FT_UINT8, BASE_HEX, NULL, 0x0,
|
||||
"PacketHeader hdr_version", HFILL }},
|
||||
{ &hf_miop_flags,
|
||||
{ "Flags", "miop.flags", FT_UINT8, BASE_OCT, NULL, 0x0,
|
||||
"PacketHeader flags", HFILL }},
|
||||
{ &hf_miop_packet_length,
|
||||
{ "Length", "miop.packet_length", FT_UINT16, BASE_DEC, NULL, 0x0,
|
||||
"PacketHeader packet_length", HFILL }},
|
||||
{ &hf_miop_packet_number,
|
||||
{ "PacketNumber", "miop.packet_number", FT_UINT32, BASE_DEC, NULL, 0x0,
|
||||
"PacketHeader packet_number", HFILL }},
|
||||
{ &hf_miop_number_of_packets,
|
||||
{ "NumberOfPackets", "miop.number_of_packets", FT_UINT32, BASE_DEC, NULL, 0x0,
|
||||
"PacketHeader number_of_packets", HFILL }},
|
||||
{ &hf_miop_unique_id_len,
|
||||
{ "UniqueIdLength", "miop.unique_id_len", FT_UINT32, BASE_DEC, NULL, 0x0,
|
||||
"UniqueId length", HFILL }},
|
||||
{ &hf_miop_unique_id,
|
||||
{ "UniqueId", "miop.unique_id", FT_STRING, BASE_NONE, NULL, 0x0,
|
||||
"UniqueId id", HFILL }},
|
||||
};
|
||||
|
||||
|
||||
static gint *ett[] = {
|
||||
&ett_miop_magic,
|
||||
&ett_miop_hdr_version,
|
||||
&ett_miop_flags,
|
||||
&ett_miop_packet_length,
|
||||
&ett_miop_packet_number,
|
||||
&ett_miop_number_of_packets,
|
||||
&ett_miop_unique_id_len,
|
||||
&ett_miop_unique_id,
|
||||
};
|
||||
|
||||
proto_miop = proto_register_protocol("Unreliable Multicast Inter-ORB Protocol", "MIOP",
|
||||
"miop");
|
||||
proto_register_field_array (proto_miop, hf, array_length (ett));
|
||||
proto_register_subtree_array (ett, array_length (ett));
|
||||
|
||||
register_dissector("miop", dissect_miop, proto_miop);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void proto_reg_handoff_miop (void) {
|
||||
|
||||
static gboolean initialized = FALSE;
|
||||
|
||||
miop_handle = create_dissector_handle(dissect_miop, proto_miop);
|
||||
heur_dissector_add("udp", dissect_miop_heur, proto_miop);
|
||||
|
||||
dissector_add_handle("udp.port", miop_handle);
|
||||
initialized = TRUE;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/* packet-miop.h
|
||||
* Declaration of routines for CORBA MIOP dissection
|
||||
* Significantly based on packet-giop.h
|
||||
* Copyright 2009 Alvaro Vega Garcia <avega at tid dot es>
|
||||
*
|
||||
* Based on Unreliable Multicast Draft Adopted Specification
|
||||
* 2001 October (OMG)
|
||||
* Chapter 29: Unreliable Multicast Inter-ORB Protocol (MIOP)
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.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_MIOP_H
|
||||
#define PACKET_MIOP_H
|
||||
|
||||
/*
|
||||
* Useful visible data/structs
|
||||
*/
|
||||
|
||||
#define MIOP_HEADER_SIZE 16
|
||||
|
||||
typedef struct UniqueId {
|
||||
guint32 id_len; /* length < 252 */
|
||||
guint8 *id; /* ptr to id */
|
||||
} UniqueId;
|
||||
|
||||
typedef struct PacketHeader_1_0 {
|
||||
guint8 magic[4];
|
||||
guint8 hdr_version;
|
||||
guint8 flags;
|
||||
guint16 packet_length;
|
||||
guint32 packet_number;
|
||||
guint32 number_of_packets;
|
||||
/* UniqueId id; */
|
||||
} PacketHeader;
|
||||
|
||||
|
||||
static dissector_handle_t miop_handle;
|
||||
|
||||
static void dissect_miop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
|
||||
|
||||
void proto_register_miop();
|
||||
|
||||
void proto_reg_handoff_miop();
|
||||
|
||||
#endif /* PACKET_MIOP_H */
|
|
@ -0,0 +1,440 @@
|
|||
/* packet-ziop.c
|
||||
* Routines for CORBA ZIOP packet disassembly
|
||||
* Significantly based on packet-giop.c
|
||||
* Copyright 2009 Alvaro Vega Garcia <avega at tid dot es>
|
||||
*
|
||||
* According with GIOP Compression RFP revised submission
|
||||
* OMG mars/2008-12-20
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.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 <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <glib.h>
|
||||
#include <math.h>
|
||||
#ifdef NEED_STRERROR_H
|
||||
#include "strerror.h"
|
||||
#endif
|
||||
|
||||
#include "isprint.h"
|
||||
|
||||
#include <epan/packet.h>
|
||||
#include <epan/conversation.h>
|
||||
|
||||
#include "packet-ziop.h"
|
||||
#include "packet-giop.h"
|
||||
#include "packet-tcp.h"
|
||||
|
||||
#ifdef NEED_G_ASCII_STRCASECMP_H
|
||||
#include "g_ascii_strcasecmp.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set to 1 for DEBUG output - TODO make this a runtime option
|
||||
*/
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------------------------------------------+
|
||||
* Data/Variables/Structs
|
||||
* ------------------------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
static int proto_ziop = -1;
|
||||
|
||||
/*
|
||||
* (sub)Tree declares
|
||||
*/
|
||||
|
||||
|
||||
static gint hf_ziop_magic = -1;
|
||||
static gint hf_ziop_giop_version_major = -1;
|
||||
static gint hf_ziop_giop_version_minor = -1;
|
||||
static gint hf_ziop_flags = -1;
|
||||
static gint hf_ziop_message_type = -1;
|
||||
static gint hf_ziop_message_size = -1;
|
||||
static gint hf_ziop_compressor_id = -1;
|
||||
static gint hf_ziop_original_length = -1;
|
||||
|
||||
static gint ett_ziop_magic = -1;
|
||||
static gint ett_ziop_giop_version_major = -1;
|
||||
static gint ett_ziop_giop_version_minor = -1;
|
||||
static gint ett_ziop_flags = -1;
|
||||
static gint ett_ziop_message_type = -1;
|
||||
static gint ett_ziop_message_size = -1;
|
||||
static gint ett_ziop_compressor_id = -1;
|
||||
static gint ett_ziop_original_length = -1;
|
||||
|
||||
|
||||
static dissector_handle_t data_handle;
|
||||
static dissector_handle_t ziop_handle;
|
||||
|
||||
|
||||
static const value_string ziop_compressor_ids[] = {
|
||||
{ 0, "None" },
|
||||
{ 1, "GZIP"},
|
||||
{ 2, "PKZIP"},
|
||||
{ 3, "BZIP2"},
|
||||
{ 4, "ZLIB"},
|
||||
{ 5, "LZMA"},
|
||||
{ 6, "LZOP"},
|
||||
{ 7, "RZIP"},
|
||||
{ 8, "7X"},
|
||||
{ 9, "XAR"},
|
||||
{ 0, NULL}
|
||||
};
|
||||
|
||||
|
||||
static const value_string giop_message_types[] = {
|
||||
{ 0x0, "Request" },
|
||||
{ 0x1, "Reply"},
|
||||
{ 0x2, "CancelRequest"},
|
||||
{ 0x3, "LocateRequest"},
|
||||
{ 0x4, "LocateReply"},
|
||||
{ 0x5, "CloseConnection"},
|
||||
{ 0x6, "MessageError"},
|
||||
{ 0x7, "Fragment"},
|
||||
{ 0, NULL}
|
||||
};
|
||||
|
||||
|
||||
|
||||
gboolean ziop_desegment = TRUE;
|
||||
|
||||
|
||||
static guint
|
||||
get_ziop_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
|
||||
{
|
||||
|
||||
ZIOPHeader header;
|
||||
guint message_size;
|
||||
gboolean stream_is_big_endian;
|
||||
|
||||
if ( tvb_memeql(tvb, 0, ZIOP_MAGIC, 4) != 0)
|
||||
return 0;
|
||||
|
||||
tvb_memcpy (tvb, (guint8 *)&header, offset, ZIOP_HEADER_SIZE);
|
||||
|
||||
stream_is_big_endian = ((header.flags & 0x1) == 0);
|
||||
|
||||
if (stream_is_big_endian)
|
||||
message_size = pntohl (&header.message_size);
|
||||
else
|
||||
message_size = pletohl (&header.message_size);
|
||||
|
||||
return message_size + ZIOP_HEADER_SIZE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dissect_ziop_tcp (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) {
|
||||
|
||||
if ( tvb_memeql(tvb, 0, ZIOP_MAGIC ,4) != 0) {
|
||||
|
||||
if ( tvb_memeql(tvb, 0, GIOP_MAGIC ,4) == 0)
|
||||
dissect_giop(tvb, pinfo, tree);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
tcp_dissect_pdus(tvb, pinfo, tree, ziop_desegment, ZIOP_HEADER_SIZE,
|
||||
get_ziop_pdu_len, dissect_ziop);
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
dissect_ziop_heur (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) {
|
||||
|
||||
guint tot_len;
|
||||
|
||||
conversation_t *conversation;
|
||||
/* check magic number and version */
|
||||
|
||||
|
||||
tot_len = tvb_length(tvb);
|
||||
|
||||
|
||||
if (tot_len < ZIOP_HEADER_SIZE) /* tot_len < 12 */
|
||||
{
|
||||
/* Not enough data captured to hold the ZIOP header; don't try
|
||||
to interpret it as GIOP. */
|
||||
return FALSE;
|
||||
}
|
||||
if ( tvb_memeql(tvb, 0, ZIOP_MAGIC, 4) != 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( pinfo->ptype == PT_TCP )
|
||||
{
|
||||
/*
|
||||
* Make the ZIOP dissector the dissector for this conversation.
|
||||
*
|
||||
* If this isn't the first time this packet has been processed,
|
||||
* we've already done this work, so we don't need to do it
|
||||
* again.
|
||||
*/
|
||||
if (!pinfo->fd->flags.visited)
|
||||
{
|
||||
conversation = find_conversation(pinfo->fd->num, &pinfo->src,
|
||||
&pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
|
||||
if (conversation == NULL)
|
||||
{
|
||||
conversation = conversation_new(pinfo->fd->num, &pinfo->src,
|
||||
&pinfo->dst, pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
|
||||
}
|
||||
/* Set dissector */
|
||||
conversation_set_dissector(conversation, ziop_handle);
|
||||
}
|
||||
dissect_ziop_tcp (tvb, pinfo, tree);
|
||||
}
|
||||
else
|
||||
{
|
||||
dissect_ziop (tvb, pinfo, tree);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Main entry point */
|
||||
void dissect_ziop (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) {
|
||||
guint offset = 0;
|
||||
ZIOPHeader header;
|
||||
CompressionData compression_data;
|
||||
tvbuff_t *ziop_header_tvb;
|
||||
tvbuff_t *compression_data_tvb;
|
||||
tvbuff_t *payload_tvb;
|
||||
|
||||
proto_tree *clnp_tree = NULL;
|
||||
proto_item *ti;
|
||||
|
||||
gboolean stream_is_big_endian;
|
||||
guint32 message_size;
|
||||
guint32 original_len;
|
||||
guint16 compressor_id;
|
||||
|
||||
ziop_header_tvb = tvb_new_subset (tvb, 0, ZIOP_HEADER_SIZE, -1);
|
||||
tvb_memcpy (ziop_header_tvb, (guint8 *)&header, 0, ZIOP_HEADER_SIZE );
|
||||
|
||||
|
||||
compression_data_tvb = tvb_new_subset (tvb, ZIOP_HEADER_SIZE, 8 , -1);
|
||||
tvb_memcpy (compression_data_tvb, (guint8 *)&compression_data, 0, 8 );
|
||||
|
||||
payload_tvb = tvb_new_subset (tvb, ZIOP_HEADER_SIZE + 8, -1, -1);
|
||||
|
||||
|
||||
if (check_col (pinfo->cinfo, COL_PROTOCOL)) {
|
||||
col_set_str (pinfo->cinfo, COL_PROTOCOL, ZIOP_MAGIC);
|
||||
}
|
||||
|
||||
/* Clear out stuff in the info column */
|
||||
if (check_col(pinfo->cinfo, COL_INFO)) {
|
||||
col_clear(pinfo->cinfo, COL_INFO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ( (header.giop_version_major != 1) ||
|
||||
(header.giop_version_minor != 2) ) /* > 2?? */
|
||||
{
|
||||
if (check_col (pinfo->cinfo, COL_INFO))
|
||||
{
|
||||
col_add_fstr (pinfo->cinfo, COL_INFO, "Version %u.%u",
|
||||
header.giop_version_major, header.giop_version_minor);
|
||||
}
|
||||
if (tree)
|
||||
{
|
||||
ti = proto_tree_add_item (tree, proto_ziop, tvb, 0, -1, FALSE);
|
||||
clnp_tree = proto_item_add_subtree (ti, ett_ziop_giop_version_major);
|
||||
proto_tree_add_text (clnp_tree, ziop_header_tvb, 0, -1,
|
||||
"Version %u.%u not supported",
|
||||
header.giop_version_major,
|
||||
header.giop_version_minor);
|
||||
}
|
||||
call_dissector(data_handle, tvb, pinfo, tree);
|
||||
return;
|
||||
}
|
||||
|
||||
stream_is_big_endian = ((header.flags & 0x01) == 0);
|
||||
|
||||
if (stream_is_big_endian) {
|
||||
message_size = pntohl (&header.message_size);
|
||||
compressor_id = pntohs (&compression_data.compressor_id);
|
||||
original_len = pntohl (&compression_data.original_length);
|
||||
}
|
||||
else {
|
||||
message_size = pletohl (&header.message_size);
|
||||
compressor_id = pletohs (&compression_data.compressor_id);
|
||||
original_len = pletohl (&compression_data.original_length);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (check_col (pinfo->cinfo, COL_INFO))
|
||||
{
|
||||
col_add_fstr (pinfo->cinfo, COL_INFO, "ZIOP %u.%u %s",
|
||||
header.giop_version_major,
|
||||
header.giop_version_minor,
|
||||
val_to_str(header.message_type, giop_message_types,
|
||||
"Unknown message type (0x%02x)")
|
||||
);
|
||||
}
|
||||
|
||||
if (tree)
|
||||
{
|
||||
ti = proto_tree_add_item (tree, proto_ziop, tvb, 0, -1, FALSE);
|
||||
|
||||
clnp_tree = proto_item_add_subtree (ti, ett_ziop_magic);
|
||||
proto_tree_add_text (clnp_tree, ziop_header_tvb, offset, 4,
|
||||
"Magic number: %s", ZIOP_MAGIC);
|
||||
offset += 4;
|
||||
clnp_tree = proto_item_add_subtree (ti, ett_ziop_giop_version_major);
|
||||
proto_tree_add_text (clnp_tree, ziop_header_tvb, offset, 1,
|
||||
"Version major: %u", header.giop_version_major);
|
||||
offset++;
|
||||
clnp_tree = proto_item_add_subtree (ti, ett_ziop_giop_version_minor);
|
||||
proto_tree_add_text (clnp_tree, ziop_header_tvb, offset, 1,
|
||||
"Version minor: %u", header.giop_version_minor);
|
||||
offset++;
|
||||
clnp_tree = proto_item_add_subtree (ti, ett_ziop_flags);
|
||||
proto_tree_add_text (clnp_tree, ziop_header_tvb, offset, 1,
|
||||
"Flags: 0x%02x (%s)", header.flags,
|
||||
(stream_is_big_endian) ? "big-endian" : "little-endian");
|
||||
offset++;
|
||||
clnp_tree = proto_item_add_subtree (ti, ett_ziop_message_type);
|
||||
proto_tree_add_text (clnp_tree, ziop_header_tvb, offset, 1,
|
||||
"Type: %s",
|
||||
val_to_str(header.message_type, giop_message_types,
|
||||
"(0x%x)")
|
||||
);
|
||||
offset++;
|
||||
clnp_tree = proto_item_add_subtree (ti, ett_ziop_message_size);
|
||||
proto_tree_add_text (clnp_tree, ziop_header_tvb, offset, 4,
|
||||
"Size: %d", message_size);
|
||||
offset = 0;
|
||||
clnp_tree = proto_item_add_subtree (ti, ett_ziop_compressor_id);
|
||||
proto_tree_add_text (clnp_tree, compression_data_tvb, offset, 2,
|
||||
"Compressor Id: %s" ,
|
||||
val_to_str(compressor_id, ziop_compressor_ids,
|
||||
"(0x%x)")
|
||||
);
|
||||
offset += 4;
|
||||
clnp_tree = proto_item_add_subtree (ti, ett_ziop_original_length);
|
||||
proto_tree_add_text (clnp_tree, compression_data_tvb, offset, 4,
|
||||
"Original length: %d", original_len);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void proto_register_ziop (void) {
|
||||
|
||||
|
||||
/* A header field is something you can search/filter on.
|
||||
*
|
||||
* We create a structure to register our fields. It consists of an
|
||||
* array of hf_register_info structures, each of which are of the format
|
||||
* {&(field id), {name, abbrev, type, display, strings, bitmask, blurb, HFILL}}.
|
||||
*/
|
||||
static hf_register_info hf[] = {
|
||||
{ &hf_ziop_magic,
|
||||
{ "Header magic", "ziop.magic", FT_UINT32, BASE_DEC, NULL, 0x0,
|
||||
"ZIOPHeader magic", HFILL }},
|
||||
{ &hf_ziop_giop_version_major,
|
||||
{ "Header major version", "ziop.giop_version_major", FT_UINT8, BASE_OCT, NULL, 0x0,
|
||||
"ZIOPHeader giop_version", HFILL }},
|
||||
{ &hf_ziop_giop_version_minor,
|
||||
{ "Header minor version", "ziop.giop_version_minor", FT_UINT8, BASE_OCT, NULL, 0x0,
|
||||
"ZIOPHeader giop_version", HFILL }},
|
||||
{ &hf_ziop_flags,
|
||||
{ "Header flags", "ziop.flags", FT_UINT8, BASE_OCT, NULL, 0x0,
|
||||
"ZIOPHeader flags", HFILL }},
|
||||
{ &hf_ziop_message_type,
|
||||
{ "Header type", "ziop.message_type", FT_UINT8, BASE_OCT, NULL, 0x0,
|
||||
"ZIOPHeader message_type", HFILL }},
|
||||
{ &hf_ziop_message_size,
|
||||
{ "Header size", "ziop.message_size", FT_UINT32, BASE_DEC, NULL, 0x0,
|
||||
"ZIOPHeader message_size", HFILL }},
|
||||
{ &hf_ziop_compressor_id,
|
||||
{ "Header compressor id", "ziop.compressor_id", FT_UINT16, BASE_DEC, NULL, 0x0,
|
||||
"ZIOPHeader compressor_id", HFILL }},
|
||||
{ &hf_ziop_original_length,
|
||||
{ "Header original length", "ziop.original_length", FT_UINT32, BASE_DEC, NULL, 0x0,
|
||||
"ZIOP original_length", HFILL }},
|
||||
};
|
||||
|
||||
|
||||
static gint *ett[] = {
|
||||
&ett_ziop_magic,
|
||||
&ett_ziop_giop_version_major,
|
||||
&ett_ziop_giop_version_minor,
|
||||
&ett_ziop_flags,
|
||||
&ett_ziop_message_type,
|
||||
&ett_ziop_message_size,
|
||||
&ett_ziop_compressor_id,
|
||||
&ett_ziop_original_length
|
||||
};
|
||||
|
||||
proto_ziop = proto_register_protocol("Zipped Inter-ORB Protocol", "ZIOP",
|
||||
"ziop");
|
||||
proto_register_field_array (proto_ziop, hf, array_length (ett));
|
||||
proto_register_subtree_array (ett, array_length (ett));
|
||||
|
||||
register_dissector("ziop", dissect_ziop, proto_ziop);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void proto_reg_handoff_ziop (void) {
|
||||
|
||||
static gboolean initialized = FALSE;
|
||||
|
||||
data_handle = find_dissector("data");
|
||||
|
||||
ziop_handle = create_dissector_handle(dissect_ziop_tcp, proto_ziop);
|
||||
heur_dissector_add("tcp", dissect_ziop_heur, proto_ziop);
|
||||
|
||||
dissector_add_handle("udp.port", ziop_handle);
|
||||
initialized = TRUE;
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/* packet-ziop.h
|
||||
* Declaration of routines for ZIOP dissection
|
||||
* Significantly based on packet-giop.h
|
||||
* Copyright 2009 Alvaro Vega Garcia <avega at tid dot es>
|
||||
*
|
||||
* Based on GIOP Compression FTF Beta 1
|
||||
* OMG mars/2008-12-20
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.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_ZIOP_H
|
||||
#define PACKET_ZIOP_H
|
||||
|
||||
/*
|
||||
* Useful visible data/structs
|
||||
*/
|
||||
|
||||
#define ZIOP_HEADER_SIZE 12
|
||||
|
||||
#define ZIOP_MAGIC "ZIOP"
|
||||
|
||||
typedef struct ZIOPHeader_1_0 {
|
||||
guint8 magic[4];
|
||||
guint8 giop_version_major;
|
||||
guint8 giop_version_minor;
|
||||
guint8 flags;
|
||||
guint8 message_type;
|
||||
guint32 message_size;
|
||||
} ZIOPHeader;
|
||||
|
||||
|
||||
typedef struct ZIOP_CompressionData {
|
||||
guint16 compressor_id;
|
||||
guint16 padding; /* to be skipped due to CDR rules */
|
||||
guint32 original_length;
|
||||
/* Compression::Buffer data; */
|
||||
} CompressionData;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern void dissect_ziop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
|
||||
|
||||
gboolean
|
||||
dissect_ziop_heur (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree);
|
||||
|
||||
void proto_register_ziop();
|
||||
|
||||
void proto_reg_handoff_ziop();
|
||||
|
||||
#endif /* PACKET_ZIOP_H */
|
Loading…
Reference in New Issue