2012-01-24 20:29:32 +00:00
|
|
|
/* packet-at.c
|
|
|
|
* Dissector for AT Commands
|
2011-05-10 17:04:05 +00:00
|
|
|
*
|
|
|
|
* Copyright 2011, Tyson Key <tyson.key@gmail.com>
|
|
|
|
*
|
2011-05-10 17:06:20 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2011-05-10 17:04:05 +00:00
|
|
|
* 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.
|
2011-05-10 17:04:05 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
|
2013-03-14 07:37:13 +00:00
|
|
|
void proto_register_at_command(void);
|
|
|
|
void proto_reg_handoff_at_command(void);
|
2013-03-13 21:14:20 +00:00
|
|
|
|
2011-05-10 17:04:05 +00:00
|
|
|
static int proto_at = -1;
|
|
|
|
static int hf_at_command = -1;
|
|
|
|
|
|
|
|
/* Subtree handles: set by register_subtree_array */
|
|
|
|
static gint ett_at = -1;
|
|
|
|
|
|
|
|
static gboolean allowed_chars(tvbuff_t *tvb)
|
|
|
|
{
|
|
|
|
gint offset, len;
|
|
|
|
guint8 val;
|
|
|
|
|
2016-06-02 14:20:12 +00:00
|
|
|
len = tvb_captured_length(tvb);
|
2011-05-10 17:04:05 +00:00
|
|
|
for (offset = 0; offset < len; offset++) {
|
|
|
|
val = tvb_get_guint8(tvb, offset);
|
2014-05-13 12:44:47 +00:00
|
|
|
if (!(g_ascii_isprint(val) || (val == 0x0a) || (val == 0x0d)))
|
2011-05-10 17:04:05 +00:00
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The dissector itself */
|
2015-11-10 04:01:28 +00:00
|
|
|
static int dissect_at(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
2011-05-10 17:04:05 +00:00
|
|
|
{
|
|
|
|
proto_item *item;
|
|
|
|
proto_tree *at_tree;
|
2016-06-02 14:20:12 +00:00
|
|
|
gchar *string;
|
2011-05-10 17:04:05 +00:00
|
|
|
|
2017-01-29 23:51:00 +00:00
|
|
|
string = tvb_format_text_wsp(wmem_packet_scope(), tvb, 0, tvb_captured_length(tvb));
|
2014-05-01 11:31:56 +00:00
|
|
|
col_append_sep_str(pinfo->cinfo, COL_PROTOCOL, "/", "AT");
|
2016-06-02 14:20:12 +00:00
|
|
|
col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "AT Command: %s", string);
|
2011-05-10 17:04:05 +00:00
|
|
|
|
2016-06-01 11:49:28 +00:00
|
|
|
/* Start with a top-level item to add everything else to */
|
|
|
|
item = proto_tree_add_item(tree, proto_at, tvb, 0, -1, ENC_NA);
|
2016-06-02 14:20:12 +00:00
|
|
|
proto_item_append_text(item, ": %s", string);
|
2016-06-01 11:49:28 +00:00
|
|
|
at_tree = proto_item_add_subtree(item, ett_at);
|
|
|
|
|
|
|
|
/* Command */
|
2016-06-02 14:20:12 +00:00
|
|
|
proto_tree_add_item(at_tree, hf_at_command, tvb, 0, tvb_reported_length(tvb), ENC_ASCII|ENC_NA);
|
2016-06-01 11:49:28 +00:00
|
|
|
|
2015-11-10 04:01:28 +00:00
|
|
|
return tvb_captured_length(tvb);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Experimental approach based upon the one used for PPP */
|
Fix some warnings/errors of type
git/epan/dissectors/packet-a21.c:478:25: error: 'item' was marked unused but was used
[-Werror,-Wused-but-marked-unused]
proto_item_append_text(item, "%s", val_to_str_const(event_id, a21_event_vals, "Unknown"));
^
Added manual change id because file-jpeg.c forced the use of commit -n
Change-Id: Iffff53d6253758c8454d9583f0a11f317c8390cb
Fix warnings/errors of type:
git/epan/dissectors/packet-ax25-kiss.c:205:52: error: 'pseudo_header' was marked unused but was
used [-Werror,-Wused-but-marked-unused]
return capture_ax25( pd, l_offset, len, cpinfo, pseudo_header );
Fix checkhf warnings:
Unused entry: epan/dissectors/packet-artnet.c, hf_artnet_address_netswitch
Unused entry: epan/dissectors/packet-artnet.c, hf_artnet_address_subswitch
Unused entry: epan/dissectors/packet-artnet.c, hf_artnet_poll_reply_trailer
Unused entry: epan/dissectors/packet-artnet.c, hf_artnet_rdm_universe
Unused entry: epan/dissectors/packet-artnet.c, hf_artnet_tod_data_universe
Change-Id: Id1fa12afb97a8e9cd4ed0ea25351c3b2639c930e
Reviewed-on: https://code.wireshark.org/review/14667
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
2016-03-28 11:37:24 +00:00
|
|
|
static gboolean heur_dissect_at(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
2015-11-10 04:01:28 +00:00
|
|
|
{
|
|
|
|
const gchar at_magic1[2] = {0x0d, 0x0a};
|
|
|
|
const gchar at_magic2[3] = {0x0d, 0x0d, 0x0a};
|
|
|
|
const gchar at_magic3[2] = {'A', 'T'};
|
|
|
|
|
|
|
|
if (((tvb_memeql(tvb, 0, at_magic1, sizeof(at_magic1)) == 0) ||
|
|
|
|
(tvb_memeql(tvb, 0, at_magic2, sizeof(at_magic2)) == 0) ||
|
|
|
|
(tvb_memeql(tvb, 0, at_magic3, sizeof(at_magic3)) == 0)) &&
|
|
|
|
allowed_chars(tvb)) {
|
|
|
|
dissect_at(tvb, pinfo, tree, data);
|
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
return (FALSE);
|
2011-05-10 17:04:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_at_command(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_at_command,
|
|
|
|
{ "AT Command", "at.command", FT_STRING, BASE_NONE,
|
|
|
|
NULL, 0x0, NULL, HFILL }}
|
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_at
|
|
|
|
};
|
|
|
|
|
|
|
|
proto_at = proto_register_protocol("AT Command", "AT", "at");
|
|
|
|
proto_register_field_array(proto_at, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2015-12-09 04:04:01 +00:00
|
|
|
register_dissector("at", dissect_at, proto_at);
|
2011-05-10 17:04:05 +00:00
|
|
|
}
|
|
|
|
|
2011-05-11 13:36:17 +00:00
|
|
|
/* Handler registration */
|
|
|
|
void
|
|
|
|
proto_reg_handoff_at_command(void)
|
|
|
|
{
|
2015-07-13 00:40:31 +00:00
|
|
|
heur_dissector_add("usb.bulk", heur_dissect_at, "AT Command USB bulk endpoint", "at_usb_bulk", proto_at, HEURISTIC_ENABLE);
|
|
|
|
heur_dissector_add("usb.control", heur_dissect_at, "AT Command USB control endpoint", "at_usb_control", proto_at, HEURISTIC_ENABLE);
|
2011-05-11 13:36:17 +00:00
|
|
|
}
|
|
|
|
|
2014-09-29 18:07:49 +00:00
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|