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
14 #define NEW_PROTO_TREE_API
18 #include <epan/packet.h>
20 void proto_register_daytime(void);
21 void proto_reg_handoff_daytime(void);
23 static dissector_handle_t daytime_handle;
25 static header_field_info *hfi_daytime = NULL;
27 #define DAYTIME_HFI_INIT HFI_INIT(proto_daytime)
29 static header_field_info hfi_daytime_string DAYTIME_HFI_INIT =
30 { "Daytime", "daytime.string",
31 FT_STRING, BASE_NONE, NULL, 0x0,
32 "String containing time and date", HFILL };
34 static header_field_info hfi_response_request DAYTIME_HFI_INIT =
35 { "Type", "daytime.response_request",
36 FT_BOOLEAN, 8, TFS(&tfs_response_request), 0x0,
39 static gint ett_daytime = -1;
41 /* This dissector works for TCP and UDP daytime packets */
42 #define DAYTIME_PORT 13
45 dissect_daytime(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
47 proto_tree *daytime_tree;
50 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DAYTIME");
52 col_add_fstr(pinfo->cinfo, COL_INFO, "DAYTIME %s",
53 pinfo->srcport == pinfo->match_uint ? "Response":"Request");
57 ti = proto_tree_add_item(tree, hfi_daytime, tvb, 0, -1, ENC_NA);
58 daytime_tree = proto_item_add_subtree(ti, ett_daytime);
60 proto_tree_add_boolean(daytime_tree, &hfi_response_request, tvb, 0, 0, pinfo->srcport==DAYTIME_PORT);
61 if (pinfo->srcport == DAYTIME_PORT) {
62 proto_tree_add_item(daytime_tree, &hfi_daytime_string, tvb, 0, -1, ENC_ASCII|ENC_NA);
65 return tvb_captured_length(tvb);
69 proto_register_daytime(void)
71 #ifndef HAVE_HFI_SECTION_INIT
72 static header_field_info *hfi[] = {
74 &hfi_response_request,
78 static gint *ett[] = {
84 proto_daytime = proto_register_protocol("Daytime Protocol", "DAYTIME", "daytime");
85 hfi_daytime = proto_registrar_get_nth(proto_daytime);
87 proto_register_fields(proto_daytime, hfi, array_length(hfi));
88 proto_register_subtree_array(ett, array_length(ett));
90 daytime_handle = create_dissector_handle(dissect_daytime, proto_daytime);
94 proto_reg_handoff_daytime(void)
96 dissector_add_uint_with_preference("udp.port", DAYTIME_PORT, daytime_handle);
97 dissector_add_uint_with_preference("tcp.port", DAYTIME_PORT, daytime_handle);
101 * Editor modelines - https://www.wireshark.org/tools/modelines.html
106 * indent-tabs-mode: nil
109 * ex: set shiftwidth=2 tabstop=8 expandtab:
110 * :indentSize=2:tabSize=8:noTabs=true: