2010-06-04 12:14:18 +00:00
|
|
|
/* packet-nwmtp.c
|
|
|
|
* Routines for NexusWare MTP3 over UDP transport
|
|
|
|
* Copyright 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
|
|
|
|
* Copyright 2010 by On-Waves
|
|
|
|
*
|
|
|
|
* 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 23:18:38 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2010-06-04 12:14:18 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2010-06-04 12:14:18 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
|
2013-12-14 16:09:57 +00:00
|
|
|
void proto_register_mwmtp(void);
|
|
|
|
void proto_reg_handoff_nwmtp(void);
|
2010-06-04 12:14:18 +00:00
|
|
|
|
|
|
|
static dissector_handle_t mtp_handle;
|
|
|
|
static gint proto_nwmtp = -1;
|
|
|
|
|
|
|
|
static int hf_nwmtp_transp_type = -1;
|
|
|
|
static int hf_nwmtp_user_context = -1;
|
|
|
|
static int hf_nwmtp_data_type = -1;
|
|
|
|
static int hf_nwmtp_data_index = -1;
|
|
|
|
static int hf_nwmtp_data_length = -1;
|
|
|
|
|
|
|
|
/* subtree pointer */
|
|
|
|
static gint ett_mwmtp = -1;
|
|
|
|
|
2013-08-05 19:09:44 +00:00
|
|
|
static dissector_handle_t nwmtp_handle;
|
|
|
|
|
2010-06-04 12:14:18 +00:00
|
|
|
static const value_string nwmtp_transport_type_vals[] = {
|
|
|
|
{ 2, "UDP" },
|
|
|
|
{ 3, "TCP" },
|
|
|
|
{ 0, NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string nwmtp_data_type_vals[] = {
|
|
|
|
{ 0, "MSU Prio 0" },
|
|
|
|
{ 1, "MSU Prio 1" },
|
|
|
|
{ 2, "MSU Prio 2" },
|
|
|
|
{ 3, "MSU Prio 3" },
|
|
|
|
{16, "Retrieved MSU Prio 0" },
|
|
|
|
{17, "Retrieved MSU Prio 0" },
|
|
|
|
{18, "Retrieved MSU Prio 0" },
|
|
|
|
{32, "Retrieval complete" },
|
|
|
|
{33, "Retrieval impossible" },
|
2011-02-20 18:56:52 +00:00
|
|
|
{34, "Link in service" },
|
|
|
|
{35, "Link out of service" },
|
2010-06-04 12:14:18 +00:00
|
|
|
{ 0, NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
static void dissect_nwmtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
2013-01-07 20:24:19 +00:00
|
|
|
gint offset = 0;
|
2010-06-04 12:14:18 +00:00
|
|
|
|
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "NW MTP");
|
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
|
|
|
|
|
|
|
while (tvb_reported_length_remaining(tvb, offset) > 0) {
|
2011-02-20 18:56:52 +00:00
|
|
|
const gchar *type;
|
2010-06-04 12:14:18 +00:00
|
|
|
proto_item *ti;
|
|
|
|
proto_item *nwmtp_tree;
|
2013-01-07 22:12:38 +00:00
|
|
|
guint32 len;
|
2010-06-04 12:14:18 +00:00
|
|
|
tvbuff_t *next_tvb;
|
|
|
|
|
2011-02-20 18:56:52 +00:00
|
|
|
/* update the info column */
|
|
|
|
type = val_to_str_const(tvb_get_guint8(tvb, offset + 1),
|
|
|
|
nwmtp_data_type_vals, "Unknown");
|
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, type);
|
|
|
|
|
2010-06-04 12:14:18 +00:00
|
|
|
len = tvb_get_ntohl(tvb, offset + 8);
|
|
|
|
|
|
|
|
if (tree) {
|
|
|
|
ti = proto_tree_add_protocol_format(tree, proto_nwmtp,
|
|
|
|
tvb, offset, len + 12,
|
|
|
|
"NexusWare C7 UDP Protocol");
|
|
|
|
|
|
|
|
nwmtp_tree = proto_item_add_subtree(ti, ett_mwmtp);
|
|
|
|
proto_tree_add_item(nwmtp_tree, hf_nwmtp_transp_type,
|
2011-10-06 03:35:44 +00:00
|
|
|
tvb, offset, 1, ENC_BIG_ENDIAN);
|
2010-06-04 12:14:18 +00:00
|
|
|
proto_tree_add_item(nwmtp_tree, hf_nwmtp_data_type,
|
2011-10-06 03:35:44 +00:00
|
|
|
tvb, offset + 1, 1, ENC_BIG_ENDIAN);
|
2010-06-04 12:14:18 +00:00
|
|
|
proto_tree_add_item(nwmtp_tree, hf_nwmtp_data_index,
|
2011-10-06 03:35:44 +00:00
|
|
|
tvb, offset + 2, 2, ENC_BIG_ENDIAN);
|
2010-06-04 12:14:18 +00:00
|
|
|
proto_tree_add_item(nwmtp_tree, hf_nwmtp_user_context,
|
2011-10-06 03:35:44 +00:00
|
|
|
tvb, offset + 4, 4, ENC_BIG_ENDIAN);
|
2010-06-04 12:14:18 +00:00
|
|
|
proto_tree_add_item(nwmtp_tree, hf_nwmtp_data_length,
|
2011-10-06 03:35:44 +00:00
|
|
|
tvb, offset + 8, 4, ENC_BIG_ENDIAN);
|
2010-06-04 12:14:18 +00:00
|
|
|
}
|
|
|
|
|
2014-06-06 14:35:50 +00:00
|
|
|
next_tvb = tvb_new_subset_length(tvb, offset + 12, len);
|
2014-06-19 17:18:16 +00:00
|
|
|
if (tvb_length(next_tvb) > 0)
|
2011-02-20 18:56:52 +00:00
|
|
|
call_dissector(mtp_handle, next_tvb, pinfo, tree);
|
2013-01-07 20:24:19 +00:00
|
|
|
/* Check for overflows, which probably can't happen, but better
|
|
|
|
* safe than sorry. See
|
|
|
|
* https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8169
|
|
|
|
*/
|
2013-01-07 22:12:38 +00:00
|
|
|
DISSECTOR_ASSERT(len < G_MAXUINT32 - 11);
|
|
|
|
DISSECTOR_ASSERT((guint64)offset + len + 12 < G_MAXINT);
|
2010-09-23 21:46:31 +00:00
|
|
|
offset += len + 12;
|
2010-06-04 12:14:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void proto_register_mwmtp(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{&hf_nwmtp_transp_type,
|
|
|
|
{"Transport Type", "nwmtp.transp_type",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(nwmtp_transport_type_vals), 0x0,
|
|
|
|
"The Transport Type", HFILL}
|
|
|
|
},
|
|
|
|
{&hf_nwmtp_data_type,
|
|
|
|
{"Data Type", "nwmtp.data_type",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(nwmtp_data_type_vals), 0x0,
|
|
|
|
"The Data Type", HFILL}
|
|
|
|
},
|
|
|
|
{&hf_nwmtp_data_index,
|
|
|
|
{"Link Index", "nwmtp.link_index",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
2010-09-23 21:46:31 +00:00
|
|
|
NULL, HFILL}
|
2010-06-04 12:14:18 +00:00
|
|
|
},
|
|
|
|
{&hf_nwmtp_user_context,
|
|
|
|
{"User Context", "nwmtp.user_context",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0,
|
|
|
|
"Use Context", HFILL}
|
|
|
|
},
|
|
|
|
{&hf_nwmtp_data_length,
|
|
|
|
{"Length", "nwmtp.data_length",
|
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0,
|
|
|
|
"Data Length", HFILL}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_mwmtp,
|
|
|
|
};
|
|
|
|
|
|
|
|
proto_nwmtp =
|
|
|
|
proto_register_protocol("NexusWare C7 MTP", "MTP over NW UDP", "nw_mtp");
|
|
|
|
|
|
|
|
proto_register_field_array(proto_nwmtp, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2013-08-05 19:09:44 +00:00
|
|
|
|
|
|
|
nwmtp_handle = register_dissector("nw_mtp", dissect_nwmtp, proto_nwmtp);
|
2010-06-04 12:14:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void proto_reg_handoff_nwmtp(void)
|
|
|
|
{
|
2014-06-20 16:43:28 +00:00
|
|
|
dissector_add_for_decode_as("udp.port", nwmtp_handle);
|
2010-06-04 12:14:18 +00:00
|
|
|
mtp_handle = find_dissector("mtp3");
|
|
|
|
}
|
2013-01-07 20:00:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
* :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
*/
|