2008-08-14 20:41:55 +00:00
|
|
|
/* packet-wsmp.c
|
|
|
|
* Routines for WAVE Short Message dissection (WSMP)
|
|
|
|
* Copyright 2008, Arada Systems (http://www.aradasystems.com) (email: siva@aradasystems.com)
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* Copied from README.developer
|
|
|
|
*
|
|
|
|
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <epan/etypes.h>
|
|
|
|
|
|
|
|
static dissector_handle_t data_handle;
|
|
|
|
|
|
|
|
/* Initialize the protocol and registered fields */
|
|
|
|
static int proto_wsmp = -1;
|
|
|
|
static int hf_wsmp_version = -1;
|
|
|
|
static int hf_wsmp_security = -1;
|
|
|
|
static int hf_wsmp_rate = -1;
|
|
|
|
static int hf_wsmp_channel = -1;
|
|
|
|
static int hf_wsmp_txpower = -1;
|
|
|
|
static int hf_wsmp_appclass = -1;
|
|
|
|
static int hf_wsmp_acmlength = -1;
|
|
|
|
static int hf_wsmp_acm = -1;
|
|
|
|
static int hf_wsmp_wsmlength = -1;
|
|
|
|
|
|
|
|
/* Initialize the subtree pointers */
|
|
|
|
static gint ett_wsmp = -1;
|
|
|
|
static gint ett_wsmdata = -1;
|
|
|
|
|
|
|
|
/* Code to actually dissect the packets */
|
|
|
|
static void
|
|
|
|
dissect_wsmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Set up structures needed to add the protocol subtree and manage it */
|
|
|
|
proto_item *ti, *wsmdata_item;
|
|
|
|
proto_tree *wsmp_tree, *wsmdata_tree;
|
2008-08-25 19:25:40 +00:00
|
|
|
tvbuff_t *wsmdata_tvb;
|
2008-08-14 20:41:55 +00:00
|
|
|
guint16 acmlength, wsmlength, offset;
|
|
|
|
|
|
|
|
/* Make entries in Protocol column and Info column on summary display */
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "WSMP");
|
2008-08-14 20:41:55 +00:00
|
|
|
|
2009-08-09 07:01:26 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "WAVE Short Message Protocol IEEE P1609.3");
|
2008-08-14 20:41:55 +00:00
|
|
|
|
|
|
|
if (tree) {
|
|
|
|
|
|
|
|
/* create display subtree for the protocol */
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_wsmp, tvb, 0, -1, ENC_NA);
|
2008-08-14 20:41:55 +00:00
|
|
|
|
|
|
|
wsmp_tree = proto_item_add_subtree(ti, ett_wsmp);
|
|
|
|
|
|
|
|
offset = 0;
|
|
|
|
proto_tree_add_item(wsmp_tree,
|
2011-10-06 03:35:44 +00:00
|
|
|
hf_wsmp_version, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2008-08-14 20:41:55 +00:00
|
|
|
offset ++;
|
|
|
|
|
|
|
|
proto_tree_add_item(wsmp_tree,
|
2011-10-06 03:35:44 +00:00
|
|
|
hf_wsmp_security, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2008-08-14 20:41:55 +00:00
|
|
|
offset ++;
|
|
|
|
|
|
|
|
proto_tree_add_item(wsmp_tree,
|
2011-10-06 03:35:44 +00:00
|
|
|
hf_wsmp_channel, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2008-08-14 20:41:55 +00:00
|
|
|
offset ++;
|
|
|
|
|
|
|
|
proto_tree_add_item(wsmp_tree,
|
2011-10-06 03:35:44 +00:00
|
|
|
hf_wsmp_rate, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2008-08-14 20:41:55 +00:00
|
|
|
offset ++;
|
|
|
|
|
|
|
|
proto_tree_add_item(wsmp_tree,
|
2011-10-06 03:35:44 +00:00
|
|
|
hf_wsmp_txpower, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2008-08-14 20:41:55 +00:00
|
|
|
offset ++;
|
|
|
|
|
|
|
|
proto_tree_add_item(wsmp_tree,
|
2011-10-06 03:35:44 +00:00
|
|
|
hf_wsmp_appclass, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2008-08-14 20:41:55 +00:00
|
|
|
offset ++;
|
|
|
|
|
|
|
|
acmlength = tvb_get_guint8(tvb,offset);
|
|
|
|
proto_tree_add_item(wsmp_tree,
|
2011-10-06 03:35:44 +00:00
|
|
|
hf_wsmp_acmlength, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2008-08-14 20:41:55 +00:00
|
|
|
offset ++;
|
2011-10-21 02:10:19 +00:00
|
|
|
|
2011-10-15 18:46:26 +00:00
|
|
|
proto_tree_add_item(wsmp_tree, hf_wsmp_acm, tvb, offset, acmlength, ENC_ASCII|ENC_NA);
|
2008-08-14 20:41:55 +00:00
|
|
|
offset +=acmlength;
|
|
|
|
|
|
|
|
wsmlength = tvb_get_letohs( tvb, offset);
|
|
|
|
proto_tree_add_item(wsmp_tree,
|
2011-10-06 03:35:44 +00:00
|
|
|
hf_wsmp_wsmlength, tvb, offset, 2, ENC_LITTLE_ENDIAN);
|
2011-10-21 02:10:19 +00:00
|
|
|
offset += 2;
|
|
|
|
|
2008-08-25 19:25:40 +00:00
|
|
|
wsmdata_item = proto_tree_add_text (wsmp_tree, tvb, offset, wsmlength,
|
|
|
|
"Wave Short Message");
|
|
|
|
wsmdata_tree = proto_item_add_subtree(wsmdata_item, ett_wsmdata);
|
|
|
|
|
2011-10-21 02:10:19 +00:00
|
|
|
/* TODO: Branch on the application context and display accordingly
|
2008-08-25 19:25:40 +00:00
|
|
|
* Default call the data dissector
|
|
|
|
*/
|
|
|
|
wsmdata_tvb = tvb_new_subset(tvb, offset,wsmlength, wsmlength);
|
|
|
|
call_dissector(data_handle, wsmdata_tvb, pinfo, wsmdata_tree);
|
2008-08-14 20:41:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Register the protocol with Wireshark */
|
|
|
|
|
|
|
|
/* this format is require because a script is used to build the C function
|
|
|
|
that calls all the protocol registration.
|
|
|
|
*/
|
|
|
|
|
2008-08-25 19:25:40 +00:00
|
|
|
void
|
2008-08-14 20:41:55 +00:00
|
|
|
proto_register_wsmp(void)
|
2011-10-21 02:10:19 +00:00
|
|
|
{
|
2008-08-14 20:41:55 +00:00
|
|
|
/* Setup list of header fields See Section 1.6.1 for details*/
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_wsmp_version,
|
2011-10-21 02:10:19 +00:00
|
|
|
{ "Version", "wsmp.version", FT_UINT8, BASE_DEC, NULL, 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }},
|
2008-08-14 20:41:55 +00:00
|
|
|
|
|
|
|
{ &hf_wsmp_security,
|
2011-10-21 02:10:19 +00:00
|
|
|
{ "Security", "wsmp.security", FT_UINT8, BASE_DEC, NULL, 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }},
|
2008-08-14 20:41:55 +00:00
|
|
|
|
|
|
|
{ &hf_wsmp_channel,
|
2011-10-21 02:10:19 +00:00
|
|
|
{ "Channel", "wsmp.channel", FT_UINT8, BASE_DEC, NULL, 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }},
|
2008-08-14 20:41:55 +00:00
|
|
|
|
|
|
|
{ &hf_wsmp_rate,
|
2011-10-21 02:10:19 +00:00
|
|
|
{ "Rate", "wsmp.rate", FT_UINT8, BASE_DEC, NULL, 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }},
|
2008-08-14 20:41:55 +00:00
|
|
|
|
|
|
|
{ &hf_wsmp_txpower,
|
2011-10-21 02:10:19 +00:00
|
|
|
{ "Transmit power", "wsmp.txpower", FT_UINT8, BASE_DEC, NULL, 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }},
|
2008-08-14 20:41:55 +00:00
|
|
|
|
|
|
|
{ &hf_wsmp_appclass,
|
2011-10-21 02:10:19 +00:00
|
|
|
{ "App class", "wsmp.appclass", FT_UINT8, BASE_DEC, NULL, 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }},
|
2008-08-14 20:41:55 +00:00
|
|
|
|
|
|
|
{ &hf_wsmp_acmlength,
|
2011-10-21 02:10:19 +00:00
|
|
|
{ "Acm Length", "wsmp.acmlength", FT_UINT8, BASE_DEC, NULL, 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }},
|
2008-08-14 20:41:55 +00:00
|
|
|
|
|
|
|
{ &hf_wsmp_acm,
|
|
|
|
{ "Application Context Data", "wsmp.acm", FT_STRING,
|
|
|
|
BASE_NONE, NULL, 0x0, "Acm", HFILL }},
|
|
|
|
{ &hf_wsmp_wsmlength,
|
2011-10-21 02:10:19 +00:00
|
|
|
{ "WSM Length", "wsmp.wsmlength", FT_UINT16, BASE_DEC, NULL, 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }},
|
2008-08-14 20:41:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Setup protocol subtree array */
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_wsmp,
|
|
|
|
&ett_wsmdata,
|
|
|
|
};
|
|
|
|
|
2011-10-21 02:10:19 +00:00
|
|
|
/* Register the protocol name and description */
|
2008-08-14 20:41:55 +00:00
|
|
|
proto_wsmp = proto_register_protocol("Wave Short Message Protocol(IEEE P1609.3)",
|
|
|
|
"WSMP", "wsmp");
|
|
|
|
|
|
|
|
/* Required function calls to register the header fields and subtrees used */
|
|
|
|
proto_register_field_array(proto_wsmp, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If this dissector uses sub-dissector registration add a registration routine.
|
2011-10-21 02:10:19 +00:00
|
|
|
This exact format is required because a script is used to find these routines
|
2008-08-14 20:41:55 +00:00
|
|
|
and create the code that calls these routines.
|
|
|
|
*/
|
2008-08-25 19:25:40 +00:00
|
|
|
|
|
|
|
void
|
2008-08-14 20:41:55 +00:00
|
|
|
proto_reg_handoff_wsmp(void)
|
|
|
|
{
|
2008-08-25 19:25:40 +00:00
|
|
|
dissector_handle_t wsmp_handle;
|
2008-08-14 20:41:55 +00:00
|
|
|
|
2008-08-25 19:25:40 +00:00
|
|
|
wsmp_handle = create_dissector_handle(dissect_wsmp, proto_wsmp);
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_add_uint("ethertype", ETHERTYPE_WSMP, wsmp_handle);
|
2008-08-25 19:25:40 +00:00
|
|
|
data_handle = find_dissector("data");
|
2008-08-14 20:41:55 +00:00
|
|
|
return;
|
|
|
|
}
|