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
15 #include <epan/packet.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
34 dissect_daytime(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
36 proto_tree
*daytime_tree
;
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");
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
);
58 proto_register_daytime(void)
60 static hf_register_info hf
[] = {
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,
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
);
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
97 * indent-tabs-mode: nil
100 * ex: set shiftwidth=2 tabstop=8 expandtab:
101 * :indentSize=2:tabSize=8:noTabs=true: