2 * Routines for Daytime Protocol (RFC 867) packet dissection
3 * Copyright 2006, Stephen Fisher (see AUTHORS file)
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * Copied from packet-time.c
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #include <epan/packet.h>
34 static int proto_daytime = -1;
35 static int hf_daytime_string = -1;
37 static gint ett_daytime = -1;
39 /* This dissector works for TCP and UDP daytime packets */
40 #define DAYTIME_PORT 13
43 dissect_daytime(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
45 proto_tree *daytime_tree;
48 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DAYTIME");
50 if (check_col(pinfo->cinfo, COL_INFO)) {
51 col_add_fstr(pinfo->cinfo, COL_INFO, "DAYTIME %s",
52 pinfo->srcport == pinfo->match_port ? "Response":"Request");
57 ti = proto_tree_add_item(tree, proto_daytime, tvb, 0, -1, FALSE);
58 daytime_tree = proto_item_add_subtree(ti, ett_daytime);
60 proto_tree_add_text(daytime_tree, tvb, 0, 0,
61 pinfo->srcport==DAYTIME_PORT ? "Type: Response":"Type: Request");
62 if (pinfo->srcport == DAYTIME_PORT) {
63 proto_tree_add_item(daytime_tree, hf_daytime_string, tvb, 0, -1, FALSE);
69 proto_register_daytime(void)
72 static hf_register_info hf[] = {
74 { "Daytime", "daytime.string",
75 FT_STRING, BASE_NONE, NULL, 0x0,
76 "String containing time and date", HFILL }}
78 static gint *ett[] = {
82 proto_daytime = proto_register_protocol("Daytime Protocol", "DAYTIME", "daytime");
83 proto_register_field_array(proto_daytime, hf, array_length(hf));
84 proto_register_subtree_array(ett, array_length(ett));
88 proto_reg_handoff_daytime(void)
90 dissector_handle_t daytime_handle;
92 daytime_handle = create_dissector_handle(dissect_daytime, proto_daytime);
93 dissector_add("udp.port", DAYTIME_PORT, daytime_handle);
94 dissector_add("tcp.port", DAYTIME_PORT, daytime_handle);