2014-06-14 21:06:20 +00:00
|
|
|
/* packet-chargen.c
|
|
|
|
* Routines for chargen packet dissection
|
|
|
|
* Copyright 2014, Dario Lombardo <lomato@gmail.com>
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* Chargen specs taken from RFC 864
|
2020-04-13 11:06:37 +00:00
|
|
|
* https://tools.ietf.org/html/rfc864
|
2014-06-14 21:06:20 +00:00
|
|
|
*
|
2018-02-12 11:23:27 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2014-06-14 21:06:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
#define CHARGEN_PORT_UDP 19
|
|
|
|
#define CHARGEN_PORT_TCP 19
|
|
|
|
|
|
|
|
void proto_register_chargen(void);
|
|
|
|
void proto_reg_handoff_chargen(void);
|
|
|
|
|
|
|
|
static int proto_chargen = -1;
|
|
|
|
|
|
|
|
static int hf_chargen_data = -1;
|
|
|
|
|
|
|
|
static gint ett_chargen = -1;
|
|
|
|
|
|
|
|
/* dissect_chargen - dissects chargen packet data
|
|
|
|
* tvb - tvbuff for packet data (IN)
|
|
|
|
* pinfo - packet info
|
|
|
|
* proto_tree - resolved protocol tree
|
|
|
|
*/
|
2015-11-15 13:00:10 +00:00
|
|
|
static int
|
|
|
|
dissect_chargen(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dissector_data _U_)
|
2014-06-14 21:06:20 +00:00
|
|
|
{
|
|
|
|
proto_tree* chargen_tree;
|
2015-01-21 20:49:12 +00:00
|
|
|
proto_item* ti;
|
2014-06-14 21:06:20 +00:00
|
|
|
guint8* data;
|
|
|
|
guint32 len;
|
|
|
|
|
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Chargen");
|
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "Chargen");
|
|
|
|
|
|
|
|
ti = proto_tree_add_item(tree, proto_chargen, tvb, 0, -1, ENC_NA);
|
|
|
|
chargen_tree = proto_item_add_subtree(ti, ett_chargen);
|
|
|
|
|
|
|
|
len = tvb_reported_length(tvb);
|
2021-07-16 15:36:34 +00:00
|
|
|
data = tvb_get_string_enc(pinfo->pool, tvb, 0, len, ENC_ASCII);
|
2014-06-14 21:06:20 +00:00
|
|
|
|
|
|
|
proto_tree_add_string_format(chargen_tree, hf_chargen_data, tvb, 0,
|
|
|
|
len, "Data", "Data (%u): %s", len, data);
|
|
|
|
|
2014-09-18 14:35:48 +00:00
|
|
|
/* proto_tree_add_item(chargen_tree, hf_chargen_data, tvb, 0, -1, ENC_ASCII|ENC_NA); */
|
2015-11-15 13:00:10 +00:00
|
|
|
return tvb_captured_length(tvb);
|
2014-06-14 21:06:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_chargen(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_chargen_data, {
|
|
|
|
"Data", "chargen.data", FT_STRING, BASE_NONE,
|
|
|
|
NULL, 0, NULL, HFILL }}
|
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_chargen,
|
|
|
|
};
|
|
|
|
|
2018-01-08 08:26:25 +00:00
|
|
|
proto_chargen = proto_register_protocol("Character Generator Protocol", "Chargen",
|
2014-06-14 21:06:20 +00:00
|
|
|
"chargen");
|
|
|
|
proto_register_field_array(proto_chargen, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_chargen(void)
|
|
|
|
{
|
|
|
|
dissector_handle_t chargen_handle;
|
|
|
|
|
2015-12-09 03:49:44 +00:00
|
|
|
chargen_handle = create_dissector_handle(dissect_chargen, proto_chargen);
|
2016-10-05 20:33:54 +00:00
|
|
|
dissector_add_uint_with_preference("udp.port", CHARGEN_PORT_UDP, chargen_handle);
|
2016-10-07 20:25:01 +00:00
|
|
|
dissector_add_uint_with_preference("tcp.port", CHARGEN_PORT_TCP, chargen_handle);
|
2014-06-14 21:06:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2019-07-26 18:43:17 +00:00
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
2014-06-14 21:06:20 +00:00
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
* :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
*/
|