2 * Routines for time packet dissection
4 * Richard Sharpe <rsharpe@ns.aus.com>
5 * Craig Newell <CraigN@cheque.uq.edu.au>
6 * RFC2347 TIME Option Extension
8 * $Id: packet-time.c,v 1.10 2001/01/03 06:55:34 guy Exp $
10 * Ethereal - Network traffic analyzer
11 * By Gerald Combs <gerald@zing.org>
12 * Copyright 1998 Gerald Combs
14 * Copied from packet-tftp.c
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
37 static int proto_time = -1;
38 static int hf_time_time = -1;
40 static gint ett_time = -1;
42 #define UDP_PORT_TIME 37
45 dissect_time(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
47 proto_tree *time_tree;
50 OLD_CHECK_DISPLAY_AS_DATA(proto_time, pd, offset, fd, tree);
52 if (check_col(fd, COL_PROTOCOL))
53 col_set_str(fd, COL_PROTOCOL, "TIME");
55 if (check_col(fd, COL_INFO)) {
56 col_add_fstr(fd, COL_INFO, "TIME %s", pi.srcport == UDP_PORT_TIME? "Response":"Request");
61 ti = proto_tree_add_item(tree, proto_time, NullTVB, offset, END_OF_FRAME, FALSE);
62 time_tree = proto_item_add_subtree(ti, ett_time);
64 proto_tree_add_text(time_tree, NullTVB, offset, 0,
65 pi.srcport==37? "Type: Response":"Type: Request");
66 if (pi.srcport == 37) {
67 guint32 delta_seconds = pntohl(pd+offset);
68 proto_tree_add_text(time_tree, NullTVB, offset, 4,
69 " %u seconds since midnight 1 January 1900 GMT",
76 proto_register_time(void)
79 static hf_register_info hf[] = {
81 { "Time", "time.time",
82 FT_UINT32, BASE_DEC, NULL, 0x0,
83 "Seconds since 00:00 (midnight) 1 January 1900 GMT" }}
85 static gint *ett[] = {
89 proto_time = proto_register_protocol("Time Protocol", "TIME", "time");
90 proto_register_field_array(proto_time, hf, array_length(hf));
91 proto_register_subtree_array(ett, array_length(ett));
95 proto_reg_handoff_time(void)
97 old_dissector_add("udp.port", UDP_PORT_TIME, dissect_time);