2004-09-23 18:48:11 +00:00
|
|
|
/* packet-loop.c
|
|
|
|
* Routines for Ethernet loopback/Configuration Test Protocol dissection
|
|
|
|
*
|
|
|
|
* See
|
|
|
|
*
|
2014-09-30 23:12:26 +00:00
|
|
|
* http://stuff.mit.edu/people/jhawk/ctp.html
|
2004-09-23 18:48:11 +00:00
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2004-09-23 18:48:11 +00:00
|
|
|
* 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.
|
2004-09-23 18:48:11 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2004-09-23 18:48:11 +00:00
|
|
|
|
|
|
|
#include <epan/packet.h>
|
2005-09-17 00:02:31 +00:00
|
|
|
#include <epan/etypes.h>
|
2004-09-23 18:48:11 +00:00
|
|
|
|
2013-12-14 12:45:57 +00:00
|
|
|
void proto_register_loop(void);
|
|
|
|
void proto_reg_handoff_loop(void);
|
|
|
|
|
2004-09-23 18:48:11 +00:00
|
|
|
static int proto_loop = -1;
|
|
|
|
static int hf_loop_skipcount = -1;
|
|
|
|
static int hf_loop_function = -1;
|
2014-08-13 12:56:22 +00:00
|
|
|
static int hf_loop_relevant_function = -1;
|
2004-09-23 18:54:39 +00:00
|
|
|
static int hf_loop_receipt_number = -1;
|
2004-09-23 18:48:11 +00:00
|
|
|
static int hf_loop_forwarding_address = -1;
|
|
|
|
|
|
|
|
static gint ett_loop = -1;
|
|
|
|
|
2014-09-30 23:12:26 +00:00
|
|
|
#define FUNC_REPLY 1
|
|
|
|
#define FUNC_FORWARD_DATA 2
|
2004-09-23 18:48:11 +00:00
|
|
|
|
|
|
|
static const value_string function_vals[] = {
|
|
|
|
{ FUNC_REPLY, "Reply" },
|
|
|
|
{ FUNC_FORWARD_DATA, "Forward Data" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
2015-11-15 21:51:45 +00:00
|
|
|
static int
|
|
|
|
dissect_loop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
2004-09-23 18:48:11 +00:00
|
|
|
{
|
|
|
|
proto_tree *loop_tree = NULL;
|
|
|
|
proto_item *ti;
|
|
|
|
guint16 function;
|
|
|
|
int offset = 0;
|
2006-03-16 17:47:45 +00:00
|
|
|
int skip_offset;
|
|
|
|
gboolean set_info = TRUE;
|
|
|
|
gboolean more_function;
|
2004-09-23 18:48:11 +00:00
|
|
|
tvbuff_t *next_tvb;
|
|
|
|
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "LOOP");
|
2009-08-09 07:36:13 +00:00
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2004-09-23 18:48:11 +00:00
|
|
|
|
|
|
|
if (tree) {
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_loop, tvb, offset, -1, ENC_NA);
|
2004-09-23 18:48:11 +00:00
|
|
|
loop_tree = proto_item_add_subtree(ti, ett_loop);
|
2006-03-16 17:47:45 +00:00
|
|
|
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(loop_tree, hf_loop_skipcount, tvb, offset, 2, ENC_LITTLE_ENDIAN);
|
2004-09-23 18:48:11 +00:00
|
|
|
}
|
2006-03-21 06:54:12 +00:00
|
|
|
skip_offset = 2 + tvb_get_letohs(tvb, offset);
|
2006-03-16 17:47:45 +00:00
|
|
|
offset += 2;
|
2004-09-23 18:48:11 +00:00
|
|
|
|
2006-03-16 17:47:45 +00:00
|
|
|
do {
|
2004-09-25 10:36:08 +00:00
|
|
|
function = tvb_get_letohs(tvb, offset);
|
2006-03-16 17:47:45 +00:00
|
|
|
if (offset == skip_offset) {
|
2013-06-14 17:49:53 +00:00
|
|
|
col_add_str(pinfo->cinfo, COL_INFO,
|
2004-09-23 18:48:11 +00:00
|
|
|
val_to_str(function, function_vals, "Unknown function (%u)"));
|
2013-06-14 17:49:53 +00:00
|
|
|
|
2014-08-13 12:56:22 +00:00
|
|
|
proto_tree_add_uint(loop_tree, hf_loop_relevant_function, tvb, offset, 2, function);
|
2006-03-16 17:47:45 +00:00
|
|
|
set_info = FALSE;
|
2004-09-23 18:48:11 +00:00
|
|
|
}
|
2014-08-13 12:56:22 +00:00
|
|
|
proto_tree_add_uint(loop_tree, hf_loop_function, tvb, offset, 2, function);
|
2004-09-23 18:48:11 +00:00
|
|
|
offset += 2;
|
|
|
|
switch (function) {
|
|
|
|
|
|
|
|
case FUNC_REPLY:
|
2014-08-13 12:56:22 +00:00
|
|
|
proto_tree_add_item(loop_tree, hf_loop_receipt_number, tvb, offset, 2,
|
2011-10-06 03:35:44 +00:00
|
|
|
ENC_LITTLE_ENDIAN);
|
2004-09-23 18:54:39 +00:00
|
|
|
offset += 2;
|
2006-03-16 17:47:45 +00:00
|
|
|
more_function = FALSE;
|
|
|
|
break;
|
2004-09-23 18:48:11 +00:00
|
|
|
|
|
|
|
case FUNC_FORWARD_DATA:
|
2014-08-13 12:56:22 +00:00
|
|
|
proto_tree_add_item(loop_tree, hf_loop_forwarding_address, tvb, offset,
|
2011-10-20 14:07:54 +00:00
|
|
|
6, ENC_NA);
|
2004-09-23 18:48:11 +00:00
|
|
|
offset += 6;
|
2006-03-16 17:47:45 +00:00
|
|
|
more_function = TRUE;
|
2004-09-23 18:48:11 +00:00
|
|
|
break;
|
2004-09-23 18:54:39 +00:00
|
|
|
|
|
|
|
default:
|
2006-03-16 17:47:45 +00:00
|
|
|
more_function = FALSE;
|
|
|
|
break;
|
2004-09-23 18:48:11 +00:00
|
|
|
}
|
2006-03-16 17:47:45 +00:00
|
|
|
} while (more_function);
|
|
|
|
|
2010-01-13 20:32:01 +00:00
|
|
|
if (set_info) {
|
2007-10-23 05:50:00 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "No valid function found");
|
2006-03-16 17:47:45 +00:00
|
|
|
}
|
|
|
|
|
2015-06-24 00:22:18 +00:00
|
|
|
if (tvb_reported_length_remaining(tvb, offset) > 0)
|
2006-03-16 17:47:45 +00:00
|
|
|
{
|
2009-08-16 12:36:22 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, offset);
|
2016-03-20 00:33:14 +00:00
|
|
|
call_data_dissector(next_tvb, pinfo, tree);
|
2004-09-23 18:48:11 +00:00
|
|
|
}
|
2015-11-15 21:51:45 +00:00
|
|
|
return tvb_captured_length(tvb);
|
2004-09-23 18:48:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_loop(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_loop_skipcount,
|
2014-09-30 23:12:26 +00:00
|
|
|
{ "skipCount", "loop.skipcount",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
2014-08-13 12:56:22 +00:00
|
|
|
NULL, HFILL }},
|
2004-09-23 18:48:11 +00:00
|
|
|
|
|
|
|
{ &hf_loop_function,
|
2014-09-30 23:12:26 +00:00
|
|
|
{ "Function", "loop.function",
|
|
|
|
FT_UINT16, BASE_DEC, VALS(function_vals), 0x0,
|
2014-08-13 12:56:22 +00:00
|
|
|
NULL, HFILL }},
|
|
|
|
|
|
|
|
{ &hf_loop_relevant_function,
|
2014-09-30 23:12:26 +00:00
|
|
|
{ "Relevant function", "loop.relevant_function",
|
|
|
|
FT_UINT16, BASE_DEC, VALS(function_vals), 0x0,
|
2014-08-13 12:56:22 +00:00
|
|
|
NULL, HFILL }},
|
2004-09-23 18:48:11 +00:00
|
|
|
|
2004-09-23 18:54:39 +00:00
|
|
|
{ &hf_loop_receipt_number,
|
2014-09-30 23:12:26 +00:00
|
|
|
{ "Receipt number", "loop.receipt_number",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
2014-08-13 12:56:22 +00:00
|
|
|
NULL, HFILL }},
|
2004-09-23 18:54:39 +00:00
|
|
|
|
2004-09-23 18:48:11 +00:00
|
|
|
{ &hf_loop_forwarding_address,
|
2014-09-30 23:12:26 +00:00
|
|
|
{ "Forwarding address", "loop.forwarding_address",
|
|
|
|
FT_ETHER, BASE_NONE, NULL, 0x0,
|
2014-08-13 12:56:22 +00:00
|
|
|
NULL, HFILL }},
|
2004-09-23 18:48:11 +00:00
|
|
|
};
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_loop,
|
|
|
|
};
|
|
|
|
|
|
|
|
proto_loop = proto_register_protocol("Configuration Test Protocol (loopback)",
|
2014-09-30 23:12:26 +00:00
|
|
|
"LOOP", "loop");
|
2004-09-23 18:48:11 +00:00
|
|
|
proto_register_field_array(proto_loop, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_loop(void)
|
|
|
|
{
|
|
|
|
dissector_handle_t loop_handle;
|
|
|
|
|
2015-12-09 03:49:44 +00:00
|
|
|
loop_handle = create_dissector_handle(dissect_loop, proto_loop);
|
2004-09-23 18:48:11 +00:00
|
|
|
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_add_uint("ethertype", ETHERTYPE_LOOP, loop_handle);
|
2004-09-23 18:48:11 +00:00
|
|
|
}
|
2014-09-30 23:12:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 2
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=2 tabstop=8 expandtab:
|
|
|
|
* :indentSize=2:tabSize=8:noTabs=true:
|
|
|
|
*/
|