Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-chargen.c
blob3da18edf5a1559e62d237e1ea84e5982b8182e4b
1 /* packet-chargen.c
2 * Routines for chargen packet dissection
3 * Copyright 2014, Dario Lombardo <lomato@gmail.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * Chargen specs taken from RFC 864
10 * https://tools.ietf.org/html/rfc864
12 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include "config.h"
17 #include <epan/packet.h>
18 #define CHARGEN_PORT_UDP 19
19 #define CHARGEN_PORT_TCP 19
21 void proto_register_chargen(void);
22 void proto_reg_handoff_chargen(void);
24 static dissector_handle_t chargen_handle;
26 static int proto_chargen;
28 static int hf_chargen_data;
30 static int ett_chargen;
32 /* dissect_chargen - dissects chargen packet data
33 * tvb - tvbuff for packet data (IN)
34 * pinfo - packet info
35 * proto_tree - resolved protocol tree
37 static int
38 dissect_chargen(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dissector_data _U_)
40 proto_tree* chargen_tree;
41 proto_item* ti;
42 uint8_t* data;
43 uint32_t len;
45 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Chargen");
46 col_set_str(pinfo->cinfo, COL_INFO, "Chargen");
48 ti = proto_tree_add_item(tree, proto_chargen, tvb, 0, -1, ENC_NA);
49 chargen_tree = proto_item_add_subtree(ti, ett_chargen);
51 len = tvb_reported_length(tvb);
52 data = tvb_get_string_enc(pinfo->pool, tvb, 0, len, ENC_ASCII);
54 proto_tree_add_string_format(chargen_tree, hf_chargen_data, tvb, 0,
55 len, "Data", "Data (%u): %s", len, data);
57 /* proto_tree_add_item(chargen_tree, hf_chargen_data, tvb, 0, -1, ENC_ASCII); */
58 return tvb_captured_length(tvb);
61 void
62 proto_register_chargen(void)
64 static hf_register_info hf[] = {
65 { &hf_chargen_data, {
66 "Data", "chargen.data", FT_STRING, BASE_NONE,
67 NULL, 0, NULL, HFILL }}
70 static int *ett[] = {
71 &ett_chargen,
74 proto_chargen = proto_register_protocol("Character Generator Protocol", "Chargen",
75 "chargen");
76 proto_register_field_array(proto_chargen, hf, array_length(hf));
77 proto_register_subtree_array(ett, array_length(ett));
79 chargen_handle = register_dissector("chargen", dissect_chargen, proto_chargen);
82 void
83 proto_reg_handoff_chargen(void)
85 dissector_add_uint_with_preference("udp.port", CHARGEN_PORT_UDP, chargen_handle);
86 dissector_add_uint_with_preference("tcp.port", CHARGEN_PORT_TCP, chargen_handle);
90 * Editor modelines - https://www.wireshark.org/tools/modelines.html
92 * Local variables:
93 * c-basic-offset: 8
94 * tab-width: 8
95 * indent-tabs-mode: t
96 * End:
98 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
99 * :indentSize=8:tabSize=8:noTabs=false: