2004-09-23 18:48:11 +00:00
|
|
|
/* packet-loop.c
|
|
|
|
* Routines for Ethernet loopback/Configuration Test Protocol dissection
|
|
|
|
*
|
|
|
|
* See
|
|
|
|
*
|
|
|
|
* http://stuff.mit.edu/people/jhawk/ctp.html
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <epan/packet.h>
|
2005-09-17 00:02:31 +00:00
|
|
|
#include <epan/etypes.h>
|
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;
|
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;
|
|
|
|
|
|
|
|
static dissector_handle_t data_handle;
|
|
|
|
|
|
|
|
#define FUNC_REPLY 1
|
|
|
|
#define FUNC_FORWARD_DATA 2
|
|
|
|
|
|
|
|
static const value_string function_vals[] = {
|
|
|
|
{ FUNC_REPLY, "Reply" },
|
|
|
|
{ FUNC_FORWARD_DATA, "Forward Data" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_loop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
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) {
|
2006-03-16 17:47:45 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_loop, tvb, offset, -1, FALSE);
|
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
|
|
|
|
|
|
|
proto_tree_add_item(loop_tree, hf_loop_skipcount, tvb, offset, 2, TRUE);
|
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) {
|
2004-09-23 18:48:11 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO)) {
|
|
|
|
col_add_str(pinfo->cinfo, COL_INFO,
|
|
|
|
val_to_str(function, function_vals, "Unknown function (%u)"));
|
|
|
|
}
|
2006-03-16 17:47:45 +00:00
|
|
|
if (tree)
|
|
|
|
proto_tree_add_text(loop_tree, tvb, offset, 2, "Relevant function:");
|
|
|
|
set_info = FALSE;
|
2004-09-23 18:48:11 +00:00
|
|
|
}
|
|
|
|
if (tree)
|
|
|
|
proto_tree_add_uint(loop_tree, hf_loop_function, tvb, offset, 2, function);
|
|
|
|
offset += 2;
|
|
|
|
switch (function) {
|
|
|
|
|
|
|
|
case FUNC_REPLY:
|
2004-09-23 18:54:39 +00:00
|
|
|
if (tree)
|
|
|
|
proto_tree_add_item(loop_tree, hf_loop_receipt_number, tvb, offset, 2,
|
2004-09-25 09:17:12 +00:00
|
|
|
TRUE);
|
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:
|
|
|
|
if (tree)
|
|
|
|
proto_tree_add_item(loop_tree, hf_loop_forwarding_address, tvb, offset,
|
|
|
|
6, FALSE);
|
|
|
|
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);
|
|
|
|
|
|
|
|
if (set_info && check_col(pinfo->cinfo, COL_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
|
|
|
}
|
|
|
|
|
|
|
|
if (tvb_length_remaining(tvb, offset) > 0)
|
|
|
|
{
|
2009-08-16 12:36:22 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, offset);
|
2006-03-16 17:47:45 +00:00
|
|
|
call_dissector(data_handle, next_tvb, pinfo, tree);
|
2004-09-23 18:48:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_loop(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_loop_skipcount,
|
|
|
|
{ "skipCount", "loop.skipcount",
|
|
|
|
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 }},
|
2004-09-23 18:48:11 +00:00
|
|
|
|
|
|
|
{ &hf_loop_function,
|
2004-09-23 18:54:39 +00:00
|
|
|
{ "Function", "loop.function",
|
2004-09-23 18:48:11 +00:00
|
|
|
FT_UINT16, BASE_DEC, VALS(function_vals), 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 }},
|
2004-09-23 18:48:11 +00:00
|
|
|
|
2004-09-23 18:54:39 +00:00
|
|
|
{ &hf_loop_receipt_number,
|
|
|
|
{ "Receipt number", "loop.receipt_number",
|
|
|
|
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 }},
|
2004-09-23 18:54:39 +00:00
|
|
|
|
2004-09-23 18:48:11 +00:00
|
|
|
{ &hf_loop_forwarding_address,
|
2004-09-23 18:54:39 +00:00
|
|
|
{ "Forwarding address", "loop.forwarding_address",
|
2004-09-23 18:48:11 +00:00
|
|
|
FT_ETHER, BASE_NONE, 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 }},
|
2004-09-23 18:48:11 +00:00
|
|
|
};
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_loop,
|
|
|
|
};
|
|
|
|
|
|
|
|
proto_loop = proto_register_protocol("Configuration Test Protocol (loopback)",
|
|
|
|
"LOOP", "loop");
|
|
|
|
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;
|
|
|
|
|
|
|
|
loop_handle = create_dissector_handle(dissect_loop, proto_loop);
|
|
|
|
|
|
|
|
dissector_add("ethertype", ETHERTYPE_LOOP, loop_handle);
|
2004-09-25 08:01:00 +00:00
|
|
|
|
|
|
|
data_handle = find_dissector("data");
|
2004-09-23 18:48:11 +00:00
|
|
|
}
|