2008-09-30 21:00:12 +00:00
|
|
|
/* packet-lanforge.c
|
|
|
|
* Routines for "LANforge traffic generator IP protocol" dissection
|
|
|
|
* Copyright 2008
|
|
|
|
* Ben Greear <greearb@candelatech.com>
|
|
|
|
*
|
|
|
|
* Based on pktgen dissectory by:
|
|
|
|
* Francesco Fondelli <francesco dot fondelli, gmail dot com>
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
2010-03-28 18:27:40 +00:00
|
|
|
*
|
2008-09-30 21:00:12 +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.
|
2010-03-28 18:27:40 +00:00
|
|
|
*
|
2008-09-30 21:00:12 +00:00
|
|
|
* 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.
|
2010-03-28 18:27:40 +00:00
|
|
|
*
|
2008-09-30 21:00:12 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* LANforge generates network traffic for load & performance testing.
|
|
|
|
* See http://www.candelatech.com for more info.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
|
|
|
|
/* magic num used for heuristic */
|
|
|
|
static const guint8 lanforge_magic[] = { 0x1a, 0x2b, 0x3c, 0x4d };
|
|
|
|
|
|
|
|
/* Initialize the protocol and registered fields */
|
|
|
|
static int proto_lanforge = -1;
|
|
|
|
|
|
|
|
/* lanforge header */
|
|
|
|
static int hf_lanforge_crc = -1;
|
|
|
|
static int hf_lanforge_magic = -1;
|
|
|
|
static int hf_lanforge_src_session = -1;
|
|
|
|
static int hf_lanforge_dst_session = -1;
|
2010-03-28 18:27:40 +00:00
|
|
|
static int hf_lanforge_pld_len_l = -1;
|
|
|
|
static int hf_lanforge_pld_len_h = -1;
|
2008-09-30 21:00:12 +00:00
|
|
|
static int hf_lanforge_pld_len = -1;
|
|
|
|
static int hf_lanforge_pld_pattern = -1;
|
|
|
|
static int hf_lanforge_seq = -1;
|
|
|
|
static int hf_lanforge_tx_time_s = -1;
|
|
|
|
static int hf_lanforge_tx_time_ns = -1;
|
|
|
|
static int hf_lanforge_timestamp = -1;
|
|
|
|
|
|
|
|
/* Initialize the subtree pointer */
|
|
|
|
static gint ett_lanforge = -1;
|
|
|
|
|
|
|
|
/* data dissector handle */
|
2008-10-05 23:08:54 +00:00
|
|
|
static dissector_handle_t data_handle;
|
2008-09-30 21:00:12 +00:00
|
|
|
|
|
|
|
/* entry point */
|
|
|
|
static gboolean dissect_lanforge(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
2010-03-28 18:27:40 +00:00
|
|
|
proto_item *ti;
|
|
|
|
proto_item *tmp;
|
|
|
|
proto_tree *lanforge_tree;
|
2008-09-30 21:00:12 +00:00
|
|
|
guint32 offset = 0;
|
|
|
|
nstime_t tstamp;
|
|
|
|
guint32 tss;
|
2010-03-28 18:27:40 +00:00
|
|
|
guint32 tmpi;
|
|
|
|
guint32 pld_len;
|
2008-09-30 21:00:12 +00:00
|
|
|
|
|
|
|
/* check for min size */
|
2010-03-28 18:27:40 +00:00
|
|
|
if(tvb_length(tvb) < 28) { /* Not a LANforge packet. */
|
|
|
|
return FALSE;
|
2008-09-30 21:00:12 +00:00
|
|
|
}
|
2010-03-28 18:27:40 +00:00
|
|
|
|
2008-09-30 21:00:12 +00:00
|
|
|
/* check for magic number */
|
|
|
|
if(tvb_memeql(tvb, 4, lanforge_magic, 4) == -1) { /* Not a LANforge packet. */
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-03-28 18:27:40 +00:00
|
|
|
|
2008-09-30 21:00:12 +00:00
|
|
|
/* Make entries in Protocol column and Info column on summary display */
|
2010-03-28 18:27:40 +00:00
|
|
|
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "LANforge");
|
2010-03-28 18:27:40 +00:00
|
|
|
|
2008-09-30 21:00:12 +00:00
|
|
|
if(check_col(pinfo->cinfo, COL_INFO)) {
|
2010-03-28 18:27:40 +00:00
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "Seq: %u", tvb_get_ntohl(tvb, 16));
|
2008-09-30 21:00:12 +00:00
|
|
|
}
|
2010-03-28 18:27:40 +00:00
|
|
|
|
2008-09-30 21:00:12 +00:00
|
|
|
if(tree) {
|
2010-03-28 18:27:40 +00:00
|
|
|
|
|
|
|
/* create display subtree for the protocol */
|
|
|
|
|
|
|
|
ti = proto_tree_add_item(tree, proto_lanforge, tvb, 0, -1, FALSE);
|
|
|
|
|
|
|
|
lanforge_tree = proto_item_add_subtree(ti, ett_lanforge);
|
|
|
|
|
|
|
|
/* add items to the subtree */
|
|
|
|
|
|
|
|
proto_tree_add_item(lanforge_tree, hf_lanforge_crc, tvb, offset, 4, FALSE);
|
|
|
|
offset+=4;
|
2008-09-30 21:00:12 +00:00
|
|
|
|
|
|
|
proto_tree_add_item(lanforge_tree, hf_lanforge_magic, tvb, offset, 4, FALSE);
|
2010-03-28 18:27:40 +00:00
|
|
|
offset+=4;
|
2008-09-30 21:00:12 +00:00
|
|
|
|
2010-03-28 18:27:40 +00:00
|
|
|
proto_tree_add_item(lanforge_tree, hf_lanforge_src_session, tvb, offset, 2, FALSE);
|
|
|
|
offset+=2;
|
2008-09-30 21:00:12 +00:00
|
|
|
|
2010-03-28 18:27:40 +00:00
|
|
|
proto_tree_add_item(lanforge_tree, hf_lanforge_dst_session, tvb, offset, 2, FALSE);
|
2008-09-30 21:00:12 +00:00
|
|
|
offset+=2;
|
|
|
|
|
2010-03-28 18:27:40 +00:00
|
|
|
pld_len = tvb_get_ntohs(tvb, offset);
|
|
|
|
tmp = proto_tree_add_item(lanforge_tree, hf_lanforge_pld_len_l, tvb, offset, 2, FALSE);
|
|
|
|
PROTO_ITEM_SET_GENERATED(tmp);
|
2008-09-30 21:00:12 +00:00
|
|
|
offset+=2;
|
|
|
|
|
2010-03-28 18:27:40 +00:00
|
|
|
tmpi = tvb_get_guint8(tvb, offset);
|
|
|
|
tmp = proto_tree_add_item(lanforge_tree, hf_lanforge_pld_len_h, tvb, offset, 1, FALSE);
|
|
|
|
PROTO_ITEM_SET_GENERATED(tmp);
|
|
|
|
offset+=1;
|
|
|
|
pld_len |= (tmpi << 16);
|
|
|
|
|
|
|
|
proto_tree_add_uint(lanforge_tree, hf_lanforge_pld_len, tvb, offset-3, 3, pld_len);
|
|
|
|
|
|
|
|
proto_tree_add_item(lanforge_tree, hf_lanforge_pld_pattern, tvb, offset, 1, FALSE);
|
|
|
|
offset+=1;
|
|
|
|
|
2008-09-30 21:00:12 +00:00
|
|
|
proto_tree_add_item(lanforge_tree, hf_lanforge_seq, tvb, offset, 4, FALSE);
|
2010-03-28 18:27:40 +00:00
|
|
|
offset+=4;
|
2008-09-30 21:00:12 +00:00
|
|
|
|
|
|
|
tss = tvb_get_ntohl(tvb, offset);
|
2010-03-28 18:27:40 +00:00
|
|
|
tstamp.secs = tss;
|
|
|
|
tmp = proto_tree_add_item(lanforge_tree, hf_lanforge_tx_time_s, tvb, offset, 4, FALSE);
|
|
|
|
PROTO_ITEM_SET_GENERATED(tmp);
|
|
|
|
offset+=4;
|
2008-09-30 21:00:12 +00:00
|
|
|
|
|
|
|
tss = tvb_get_ntohl(tvb, offset);
|
2010-03-28 18:27:40 +00:00
|
|
|
tstamp.nsecs = tss;
|
|
|
|
tmp = proto_tree_add_item(lanforge_tree, hf_lanforge_tx_time_ns, tvb, offset, 4, FALSE);
|
|
|
|
PROTO_ITEM_SET_GENERATED(tmp);
|
|
|
|
offset+=4;
|
|
|
|
|
|
|
|
proto_tree_add_time(lanforge_tree, hf_lanforge_timestamp, tvb, offset - 8, 8, &tstamp);
|
2008-09-30 21:00:12 +00:00
|
|
|
|
|
|
|
#if 0
|
2010-03-28 18:27:40 +00:00
|
|
|
if(tvb_reported_length_remaining(tvb, offset) > 0) /* random data */
|
|
|
|
proto_tree_add_text(lanforge_tree, tvb, offset, -1, "Data (%u bytes)",
|
|
|
|
tvb_length_remaining(tvb, offset));
|
2008-09-30 21:00:12 +00:00
|
|
|
#else
|
2010-03-28 18:27:40 +00:00
|
|
|
if(tvb_reported_length_remaining(tvb, offset) > 0) /* random data */
|
|
|
|
call_dissector(data_handle, tvb_new_subset_remaining(tvb, offset), pinfo,
|
|
|
|
lanforge_tree);
|
2008-09-30 21:00:12 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Register the protocol with Wireshark */
|
|
|
|
void proto_register_lanforge(void)
|
2010-03-28 18:27:40 +00:00
|
|
|
{
|
2008-09-30 21:00:12 +00:00
|
|
|
/* Setup list of header fields */
|
2010-03-28 18:27:40 +00:00
|
|
|
|
2008-09-30 21:00:12 +00:00
|
|
|
static hf_register_info hf[] = {
|
2010-03-28 18:27:40 +00:00
|
|
|
|
|
|
|
{ &hf_lanforge_crc,
|
|
|
|
{
|
2011-05-23 00:00:53 +00:00
|
|
|
"CRC", "lanforge.CRC",
|
2010-03-28 18:27:40 +00:00
|
|
|
FT_UINT32, BASE_HEX, NULL, 0x0,
|
|
|
|
"The LANforge CRC number", HFILL
|
|
|
|
}
|
|
|
|
},
|
2008-09-30 21:00:12 +00:00
|
|
|
|
|
|
|
{ &hf_lanforge_magic,
|
2010-03-28 18:27:40 +00:00
|
|
|
{
|
2011-05-23 00:00:53 +00:00
|
|
|
"Magic number", "lanforge.magic",
|
2010-03-28 18:27:40 +00:00
|
|
|
FT_UINT32, BASE_HEX, NULL, 0x0,
|
|
|
|
"The LANforge magic number", HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_lanforge_src_session,
|
|
|
|
{
|
2011-05-23 00:00:53 +00:00
|
|
|
"Source session ID", "lanforge.source-session-id",
|
2010-03-28 18:27:40 +00:00
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"The LANforge source session ID", HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_lanforge_dst_session,
|
|
|
|
{
|
2011-05-23 00:00:53 +00:00
|
|
|
"Dest session ID", "lanforge.dest-session-id",
|
2010-03-28 18:27:40 +00:00
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"The LANforge dest session ID", HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_lanforge_pld_len_l,
|
|
|
|
{
|
2011-05-23 00:00:53 +00:00
|
|
|
"Payload Length(L)", "lanforge.pld-len-L",
|
2010-03-28 18:27:40 +00:00
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"The LANforge payload length (low bytes)", HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_lanforge_pld_len_h,
|
|
|
|
{
|
2011-05-23 00:00:53 +00:00
|
|
|
"Payload Length(H)", "lanforge.pld-len-H",
|
2010-03-28 18:27:40 +00:00
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
|
|
|
"The LANforge payload length (high byte)", HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_lanforge_pld_len,
|
|
|
|
{
|
2011-05-23 00:00:53 +00:00
|
|
|
"Payload Length", "lanforge.pld-length",
|
2010-03-28 18:27:40 +00:00
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0,
|
|
|
|
"The LANforge payload length", HFILL
|
|
|
|
}
|
|
|
|
},
|
2008-09-30 21:00:12 +00:00
|
|
|
|
|
|
|
{ &hf_lanforge_pld_pattern,
|
2010-03-28 18:27:40 +00:00
|
|
|
{
|
2011-05-23 00:00:53 +00:00
|
|
|
"Payload Pattern", "lanforge.pld-pattern",
|
2010-03-28 18:27:40 +00:00
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"The LANforge payload pattern", HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_lanforge_seq,
|
|
|
|
{
|
2011-05-23 00:00:53 +00:00
|
|
|
"Sequence Number", "lanforge.seqno",
|
2010-03-28 18:27:40 +00:00
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0,
|
|
|
|
"The LANforge Sequence Number", HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_lanforge_tx_time_s,
|
|
|
|
{
|
2011-05-23 00:00:53 +00:00
|
|
|
"Timestamp Secs", "lanforge.ts-secs",
|
2010-03-28 18:27:40 +00:00
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0,
|
2010-09-23 21:46:31 +00:00
|
|
|
NULL, HFILL
|
2010-03-28 18:27:40 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_lanforge_tx_time_ns,
|
|
|
|
{
|
2011-05-23 00:00:53 +00:00
|
|
|
"Timestamp nsecs", "lanforge.ts-nsecs",
|
2010-03-28 18:27:40 +00:00
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0,
|
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_lanforge_timestamp,
|
|
|
|
{
|
2011-05-23 00:00:53 +00:00
|
|
|
"Timestamp", "lanforge.timestamp",
|
2010-03-28 18:27:40 +00:00
|
|
|
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0,
|
|
|
|
NULL, HFILL
|
|
|
|
}
|
|
|
|
}
|
2008-09-30 21:00:12 +00:00
|
|
|
};
|
2010-03-28 18:27:40 +00:00
|
|
|
|
2008-09-30 21:00:12 +00:00
|
|
|
/* Setup protocol subtree array */
|
2010-03-28 18:27:40 +00:00
|
|
|
|
2008-09-30 21:00:12 +00:00
|
|
|
static gint *ett[] = {
|
2010-03-28 18:27:40 +00:00
|
|
|
&ett_lanforge
|
2008-09-30 21:00:12 +00:00
|
|
|
};
|
2010-03-28 18:27:40 +00:00
|
|
|
|
2008-09-30 21:00:12 +00:00
|
|
|
/* Register the protocol name and description */
|
2010-03-28 18:27:40 +00:00
|
|
|
|
2008-09-30 21:00:12 +00:00
|
|
|
proto_lanforge = proto_register_protocol("LANforge Traffic Generator", "LANforge", "lanforge");
|
2010-03-28 18:27:40 +00:00
|
|
|
|
2008-09-30 21:00:12 +00:00
|
|
|
/* Required function calls to register the header fields and subtrees used */
|
2010-03-28 18:27:40 +00:00
|
|
|
|
2008-09-30 21:00:12 +00:00
|
|
|
proto_register_field_array(proto_lanforge, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void proto_reg_handoff_lanforge(void)
|
|
|
|
{
|
|
|
|
/* Register as a heuristic UDP dissector */
|
|
|
|
heur_dissector_add("udp", dissect_lanforge, proto_lanforge);
|
2010-03-28 18:27:40 +00:00
|
|
|
heur_dissector_add("tcp", dissect_lanforge, proto_lanforge);
|
2008-09-30 21:00:12 +00:00
|
|
|
|
|
|
|
/* Find data dissector handle */
|
|
|
|
data_handle = find_dissector("data");
|
|
|
|
}
|