Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-daytime.c
blob895ee786e89394ee7de0970d074971066cbe8585
1 /* packet-daytime.c
2 * Routines for Daytime Protocol (RFC 867) packet dissection
3 * Copyright 2006, Stephen Fisher (see AUTHORS file)
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * Copied from packet-time.c
11 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include "config.h"
15 #include <epan/packet.h>
16 #include <epan/tfs.h>
18 void proto_register_daytime(void);
19 void proto_reg_handoff_daytime(void);
21 static dissector_handle_t daytime_handle;
23 static int proto_daytime;
25 static int hf_daytime_string;
26 static int hf_response_request;
28 static int ett_daytime;
30 /* This dissector works for TCP and UDP daytime packets */
31 #define DAYTIME_PORT 13
33 static int
34 dissect_daytime(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
36 proto_tree *daytime_tree;
37 proto_item *ti;
39 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DAYTIME");
41 col_add_fstr(pinfo->cinfo, COL_INFO, "DAYTIME %s",
42 pinfo->srcport == pinfo->match_uint ? "Response":"Request");
44 if (tree) {
46 ti = proto_tree_add_item(tree, proto_daytime, tvb, 0, -1, ENC_NA);
47 daytime_tree = proto_item_add_subtree(ti, ett_daytime);
49 proto_tree_add_boolean(daytime_tree, hf_response_request, tvb, 0, 0, pinfo->srcport==DAYTIME_PORT);
50 if (pinfo->srcport == DAYTIME_PORT) {
51 proto_tree_add_item(daytime_tree, hf_daytime_string, tvb, 0, -1, ENC_ASCII);
54 return tvb_captured_length(tvb);
57 void
58 proto_register_daytime(void)
60 static hf_register_info hf[] = {
61 { &hf_daytime_string,
62 { "Daytime", "daytime.string",
63 FT_STRING, BASE_NONE, NULL, 0x0,
64 "String containing time and date", HFILL }
66 { &hf_response_request,
67 { "Type", "daytime.response_request",
68 FT_BOOLEAN, BASE_NONE, TFS(&tfs_response_request), 0x0,
69 NULL, HFILL }
73 static int *ett[] = {
74 &ett_daytime,
77 proto_daytime = proto_register_protocol("Daytime Protocol", "DAYTIME", "daytime");
78 proto_register_field_array(proto_daytime, hf, array_length(hf));
79 proto_register_subtree_array(ett, array_length(ett));
81 daytime_handle = register_dissector("daytime", dissect_daytime, proto_daytime);
84 void
85 proto_reg_handoff_daytime(void)
87 dissector_add_uint_with_preference("udp.port", DAYTIME_PORT, daytime_handle);
88 dissector_add_uint_with_preference("tcp.port", DAYTIME_PORT, daytime_handle);
92 * Editor modelines - https://www.wireshark.org/tools/modelines.html
94 * Local Variables:
95 * c-basic-offset: 2
96 * tab-width: 8
97 * indent-tabs-mode: nil
98 * End:
100 * ex: set shiftwidth=2 tabstop=8 expandtab:
101 * :indentSize=2:tabSize=8:noTabs=true: