2009-03-03 19:51:08 +00:00
|
|
|
/* 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>
|
|
|
|
*
|
2011-04-21 22:26:27 +00:00
|
|
|
* According with Unreliable Multicast Draft Adopted Specification
|
2009-03-03 19:51:08 +00:00
|
|
|
* 2001 October (OMG)
|
|
|
|
* Chapter 29: Unreliable Multicast Inter-ORB Protocol (MIOP)
|
2009-07-06 20:23:32 +00:00
|
|
|
* http://www.omg.org/technology/documents/specialized_corba.htm
|
2009-03-03 19:51:08 +00:00
|
|
|
*
|
|
|
|
* $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
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2009-03-03 19:51:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2009-03-03 19:51:08 +00:00
|
|
|
|
|
|
|
#include <epan/packet.h>
|
2011-05-20 15:44:25 +00:00
|
|
|
|
2009-03-03 19:51:08 +00:00
|
|
|
#include <epan/emem.h>
|
2009-07-06 20:23:32 +00:00
|
|
|
#include <epan/expert.h>
|
2009-03-03 19:51:08 +00:00
|
|
|
|
|
|
|
#include "packet-giop.h"
|
|
|
|
#include "packet-tcp.h"
|
|
|
|
|
2009-07-06 20:23:32 +00:00
|
|
|
/*
|
|
|
|
* Useful visible data/structs
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MIOP_MAX_UNIQUE_ID_LENGTH 252
|
|
|
|
|
|
|
|
#define MIOP_HEADER_SIZE 16
|
|
|
|
|
2009-03-03 19:51:08 +00:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
|
2009-07-06 20:23:32 +00:00
|
|
|
static gint ett_miop = -1;
|
2009-03-03 19:51:08 +00:00
|
|
|
|
2011-04-21 22:26:27 +00:00
|
|
|
#define MIOP_MAGIC "MIOP"
|
2009-03-03 19:51:08 +00:00
|
|
|
|
2009-03-05 16:41:50 +00:00
|
|
|
static void dissect_miop (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree);
|
2009-03-03 19:51:08 +00:00
|
|
|
|
|
|
|
static gboolean
|
2012-09-10 21:40:21 +00:00
|
|
|
dissect_miop_heur (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void * data _U_) {
|
2009-03-03 19:51:08 +00:00
|
|
|
|
|
|
|
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;
|
2011-04-21 22:26:27 +00:00
|
|
|
|
2009-03-03 19:51:08 +00:00
|
|
|
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;
|
|
|
|
|
2009-07-06 20:23:32 +00:00
|
|
|
proto_tree *miop_tree = NULL;
|
2009-03-03 19:51:08 +00:00
|
|
|
proto_item *ti;
|
|
|
|
|
2009-07-06 20:23:32 +00:00
|
|
|
guint8 hdr_version;
|
2009-03-03 19:51:08 +00:00
|
|
|
guint version_major;
|
|
|
|
guint version_minor;
|
2011-04-21 22:26:27 +00:00
|
|
|
|
2009-07-06 20:23:32 +00:00
|
|
|
guint8 flags;
|
2009-03-03 19:51:08 +00:00
|
|
|
|
|
|
|
guint16 packet_length;
|
|
|
|
guint packet_number;
|
|
|
|
guint number_of_packets;
|
2012-05-12 20:27:35 +00:00
|
|
|
guint byte_order;
|
2011-04-21 22:26:27 +00:00
|
|
|
|
2009-07-06 20:23:32 +00:00
|
|
|
guint32 unique_id_len;
|
2011-04-21 22:26:27 +00:00
|
|
|
|
2009-07-06 20:23:32 +00:00
|
|
|
emem_strbuf_t *flags_strbuf = ep_strbuf_new_label("none");
|
2009-03-03 19:51:08 +00:00
|
|
|
|
2009-07-06 20:23:32 +00:00
|
|
|
col_set_str (pinfo->cinfo, COL_PROTOCOL, MIOP_MAGIC);
|
2009-03-03 19:51:08 +00:00
|
|
|
/* Clear out stuff in the info column */
|
2009-07-06 20:23:32 +00:00
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2009-03-03 19:51:08 +00:00
|
|
|
|
2009-07-06 20:23:32 +00:00
|
|
|
/* Extract major and minor version numbers */
|
|
|
|
hdr_version = tvb_get_guint8(tvb, 4);
|
|
|
|
version_major = ((hdr_version & 0xf0) >> 4);
|
|
|
|
version_minor = (hdr_version & 0x0f);
|
2009-03-03 19:51:08 +00:00
|
|
|
|
2009-07-06 20:23:32 +00:00
|
|
|
if (hdr_version != 16)
|
2009-03-03 19:51:08 +00:00
|
|
|
{
|
2009-07-06 20:23:32 +00:00
|
|
|
col_add_fstr (pinfo->cinfo, COL_INFO, "Version %u.%u",
|
2011-04-21 22:26:27 +00:00
|
|
|
version_major, version_minor);
|
2009-03-03 19:51:08 +00:00
|
|
|
if (tree)
|
2011-04-21 22:26:27 +00:00
|
|
|
{
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item (tree, proto_miop, tvb, 0, -1, ENC_NA);
|
2011-04-21 22:26:27 +00:00
|
|
|
miop_tree = proto_item_add_subtree (ti, ett_miop);
|
|
|
|
proto_tree_add_text (miop_tree, tvb, 0, -1,
|
|
|
|
"Version %u.%u",
|
|
|
|
version_major, version_minor);
|
|
|
|
expert_add_info_format(pinfo, ti, PI_UNDECODED, PI_WARN,
|
|
|
|
"MIOP version %u.%u not supported",
|
|
|
|
version_major, version_minor);
|
|
|
|
}
|
2009-03-03 19:51:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-06 20:23:32 +00:00
|
|
|
flags = tvb_get_guint8(tvb, 5);
|
2012-05-12 20:27:35 +00:00
|
|
|
byte_order = (flags & 0x01) ? ENC_LITTLE_ENDIAN : ENC_BIG_ENDIAN;
|
2009-03-03 19:51:08 +00:00
|
|
|
|
2012-05-12 20:27:35 +00:00
|
|
|
if (byte_order == ENC_BIG_ENDIAN) {
|
2009-07-06 20:23:32 +00:00
|
|
|
packet_length = tvb_get_ntohs(tvb, 6);
|
|
|
|
packet_number = tvb_get_ntohl(tvb, 8);
|
|
|
|
number_of_packets = tvb_get_ntohl(tvb, 12);
|
|
|
|
unique_id_len = tvb_get_ntohl(tvb, 16);
|
2009-03-03 19:51:08 +00:00
|
|
|
}
|
2012-05-12 20:27:35 +00:00
|
|
|
else {
|
|
|
|
packet_length = tvb_get_letohs(tvb, 6);
|
|
|
|
packet_number = tvb_get_letohl(tvb, 8);
|
|
|
|
number_of_packets = tvb_get_letohl(tvb, 12);
|
|
|
|
unique_id_len = tvb_get_letohl(tvb, 16);
|
|
|
|
}
|
2009-03-03 19:51:08 +00:00
|
|
|
|
2009-07-06 20:23:32 +00:00
|
|
|
col_add_fstr (pinfo->cinfo, COL_INFO, "MIOP %u.%u Packet s=%d (%u of %u)",
|
2011-04-21 22:26:27 +00:00
|
|
|
version_major, version_minor, packet_length,
|
|
|
|
packet_number + 1,
|
|
|
|
number_of_packets);
|
2009-03-03 19:51:08 +00:00
|
|
|
|
|
|
|
if (tree)
|
|
|
|
{
|
2011-04-21 22:26:27 +00:00
|
|
|
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item (tree, proto_miop, tvb, 0, -1, ENC_NA);
|
2009-07-06 20:23:32 +00:00
|
|
|
miop_tree = proto_item_add_subtree (ti, ett_miop);
|
|
|
|
|
|
|
|
/* XXX - Should we bail out if we don't have the right magic number? */
|
2011-10-15 18:46:26 +00:00
|
|
|
proto_tree_add_item(miop_tree, hf_miop_magic, tvb, offset, 4, ENC_ASCII|ENC_NA);
|
2009-03-03 19:51:08 +00:00
|
|
|
offset += 4;
|
2009-07-06 20:23:32 +00:00
|
|
|
proto_tree_add_uint_format(miop_tree, hf_miop_hdr_version, tvb, offset, 1, hdr_version,
|
2011-04-21 22:26:27 +00:00
|
|
|
"Version: %u.%u", version_major, version_minor);
|
2009-03-03 19:51:08 +00:00
|
|
|
offset++;
|
2009-07-06 20:23:32 +00:00
|
|
|
if (flags & 0x01) {
|
2011-04-21 22:26:27 +00:00
|
|
|
ep_strbuf_printf(flags_strbuf, "little-endian");
|
2009-07-06 20:23:32 +00:00
|
|
|
}
|
|
|
|
if (flags & 0x02) {
|
2011-04-21 22:26:27 +00:00
|
|
|
ep_strbuf_append_printf(flags_strbuf, "%s%s",
|
|
|
|
flags_strbuf->len ? ", " : "", "last message");
|
2009-07-06 20:23:32 +00:00
|
|
|
}
|
2011-05-20 15:44:25 +00:00
|
|
|
proto_tree_add_uint_format_value(miop_tree, hf_miop_flags, tvb, offset, 1,
|
|
|
|
flags, "0x%02x (%s)", flags, flags_strbuf->str);
|
2009-03-03 19:51:08 +00:00
|
|
|
offset++;
|
2012-05-12 20:27:35 +00:00
|
|
|
proto_tree_add_item(miop_tree, hf_miop_packet_length, tvb, offset, 2, byte_order);
|
2009-03-03 19:51:08 +00:00
|
|
|
offset += 2;
|
2012-05-12 20:27:35 +00:00
|
|
|
proto_tree_add_item(miop_tree, hf_miop_packet_number, tvb, offset, 4, byte_order);
|
2009-03-03 19:51:08 +00:00
|
|
|
offset += 4;
|
2012-05-12 20:27:35 +00:00
|
|
|
proto_tree_add_item(miop_tree, hf_miop_number_of_packets, tvb, offset, 4, byte_order);
|
2009-03-03 19:51:08 +00:00
|
|
|
|
2009-07-06 20:23:32 +00:00
|
|
|
offset += 4;
|
2012-05-12 20:27:35 +00:00
|
|
|
ti = proto_tree_add_item(miop_tree, hf_miop_unique_id_len, tvb, offset, 4, byte_order);
|
2009-07-06 20:23:32 +00:00
|
|
|
|
|
|
|
if (unique_id_len >= MIOP_MAX_UNIQUE_ID_LENGTH) {
|
|
|
|
expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_WARN,
|
|
|
|
"Unique Id length (%u) exceeds max value (%u)",
|
|
|
|
unique_id_len, MIOP_MAX_UNIQUE_ID_LENGTH);
|
|
|
|
return;
|
|
|
|
}
|
2009-03-03 19:51:08 +00:00
|
|
|
|
2009-07-06 20:23:32 +00:00
|
|
|
offset += 4;
|
|
|
|
proto_tree_add_item(miop_tree, hf_miop_unique_id, tvb, offset, unique_id_len,
|
2012-05-12 20:27:35 +00:00
|
|
|
byte_order);
|
2009-03-03 19:51:08 +00:00
|
|
|
|
2009-07-06 20:23:32 +00:00
|
|
|
if (packet_number == 0) {
|
2009-03-03 19:51:08 +00:00
|
|
|
/* It is the first packet of the collection
|
2011-04-21 22:26:27 +00:00
|
|
|
We can call to GIOP dissector to show more about this first
|
|
|
|
uncompleted GIOP message
|
2009-03-03 19:51:08 +00:00
|
|
|
*/
|
2009-07-06 20:23:32 +00:00
|
|
|
tvbuff_t *payload_tvb;
|
2011-04-21 22:26:27 +00:00
|
|
|
|
2009-07-06 20:23:32 +00:00
|
|
|
offset += unique_id_len;
|
2009-08-16 12:36:22 +00:00
|
|
|
payload_tvb = tvb_new_subset_remaining (tvb, offset);
|
2009-03-03 19:51:08 +00:00
|
|
|
dissect_giop(payload_tvb, pinfo, tree);
|
2009-07-06 20:23:32 +00:00
|
|
|
}
|
2009-03-03 19:51:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void proto_register_miop (void) {
|
|
|
|
|
|
|
|
|
|
|
|
/* A header field is something you can search/filter on.
|
2011-04-21 22:26:27 +00:00
|
|
|
*
|
2009-03-03 19:51:08 +00:00
|
|
|
* 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,
|
2009-07-06 20:23:32 +00:00
|
|
|
{ "Magic", "miop.magic", FT_STRING, BASE_NONE, NULL, 0x0,
|
2009-03-03 19:51:08 +00:00
|
|
|
"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,
|
2009-07-06 20:23:32 +00:00
|
|
|
{ "UniqueId", "miop.unique_id", FT_BYTES, BASE_NONE, NULL, 0x0,
|
2009-03-03 19:51:08 +00:00
|
|
|
"UniqueId id", HFILL }},
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static gint *ett[] = {
|
2009-07-06 20:23:32 +00:00
|
|
|
&ett_miop
|
2009-03-03 19:51:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
proto_miop = proto_register_protocol("Unreliable Multicast Inter-ORB Protocol", "MIOP",
|
2011-04-21 22:26:27 +00:00
|
|
|
"miop");
|
2009-07-06 20:23:32 +00:00
|
|
|
proto_register_field_array (proto_miop, hf, array_length (hf));
|
2009-03-03 19:51:08 +00:00
|
|
|
proto_register_subtree_array (ett, array_length (ett));
|
|
|
|
|
|
|
|
register_dissector("miop", dissect_miop, proto_miop);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void proto_reg_handoff_miop (void) {
|
|
|
|
|
2009-03-05 04:14:01 +00:00
|
|
|
dissector_handle_t miop_handle;
|
|
|
|
|
|
|
|
miop_handle = find_dissector("miop");
|
|
|
|
dissector_add_handle("udp.port", miop_handle); /* for 'Decode As' */
|
|
|
|
|
2009-03-03 19:51:08 +00:00
|
|
|
heur_dissector_add("udp", dissect_miop_heur, proto_miop);
|
2011-04-21 22:26:27 +00:00
|
|
|
|
2009-03-03 19:51:08 +00:00
|
|
|
}
|