2000-02-09 17:17:00 +00:00
|
|
|
/* packet-time.c
|
2004-05-12 19:23:08 +00:00
|
|
|
* Routines for Time Protocol (RFC 868) packet dissection
|
2000-02-09 17:17:00 +00:00
|
|
|
*
|
|
|
|
* Richard Sharpe <rsharpe@ns.aus.com>
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2000-02-09 17:17:00 +00:00
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2000-02-09 17:17:00 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* Copied from packet-tftp.c
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2000-02-09 17:17:00 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2000-02-09 17:17:00 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
2000-02-09 17:17:00 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2000-02-09 17:17:00 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2000-02-09 17:17:00 +00:00
|
|
|
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
2011-07-05 15:22:28 +00:00
|
|
|
#include <epan/prefs.h>
|
|
|
|
|
|
|
|
|
2012-11-29 20:15:37 +00:00
|
|
|
static const enum_val_t time_display_types[] = {
|
2011-07-05 15:22:28 +00:00
|
|
|
{ "UTC", "UTC", ABSOLUTE_TIME_UTC },
|
|
|
|
{ "Local", "Local", ABSOLUTE_TIME_LOCAL},
|
|
|
|
{ NULL, NULL, 0 }
|
|
|
|
};
|
2000-02-09 17:17:00 +00:00
|
|
|
|
|
|
|
static int proto_time = -1;
|
|
|
|
static int hf_time_time = -1;
|
|
|
|
|
|
|
|
static gint ett_time = -1;
|
2011-07-05 15:22:28 +00:00
|
|
|
static gint time_display_type = ABSOLUTE_TIME_LOCAL;
|
2000-02-09 17:17:00 +00:00
|
|
|
|
2006-08-02 17:01:38 +00:00
|
|
|
/* This dissector works for TCP and UDP time packets */
|
|
|
|
#define TIME_PORT 37
|
2000-04-08 07:07:42 +00:00
|
|
|
|
|
|
|
static void
|
2001-01-06 09:42:10 +00:00
|
|
|
dissect_time(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
2000-02-09 17:17:00 +00:00
|
|
|
{
|
|
|
|
proto_tree *time_tree;
|
|
|
|
proto_item *ti;
|
Add the "Edit:Protocols..." feature which currently only implements
the following:
It is now possible to enable/disable a particular protocol decoding
(i.e. the protocol dissector is void or not). When a protocol
is disabled, it is displayed as Data and of course, all linked
sub-protocols are disabled as well.
Disabling a protocol could be interesting:
- in case of buggy dissectors
- in case of wrong heuristics
- for performance reasons
- to decode the data as another protocol (TODO)
Currently (if I am not wrong), all dissectors but NFS can be disabled
(and dissectors that do not register protocols :-)
I do not like the way the RPC sub-dissectors are disabled (in the
sub-dissectors) since this could be done in the RPC dissector itself,
knowing the sub-protocol hfinfo entry (this is why, I've not modified
the NFS one yet).
Two functions are added in proto.c :
gboolean proto_is_protocol_enabled(int n);
void proto_set_decoding(int n, gboolean enabled);
and two MACROs which can be used in dissectors:
OLD_CHECK_DISPLAY_AS_DATA(index, pd, offset, fd, tree)
CHECK_DISPLAY_AS_DATA(index, tvb, pinfo, tree)
See also the XXX in proto_dlg.c and proto.c around the new functions.
svn path=/trunk/; revision=2267
2000-08-13 14:09:15 +00:00
|
|
|
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "TIME");
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO)) {
|
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "TIME %s",
|
2010-12-20 05:35:29 +00:00
|
|
|
pinfo->srcport == pinfo->match_uint ? "Response":"Request");
|
2000-02-09 17:17:00 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-02-09 17:17:00 +00:00
|
|
|
if (tree) {
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_time, tvb, 0, -1, ENC_NA);
|
2000-02-09 17:17:00 +00:00
|
|
|
time_tree = proto_item_add_subtree(ti, ett_time);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-01-06 09:42:10 +00:00
|
|
|
proto_tree_add_text(time_tree, tvb, 0, 0,
|
2006-08-02 17:01:38 +00:00
|
|
|
pinfo->srcport==TIME_PORT ? "Type: Response":"Type: Request");
|
|
|
|
if (pinfo->srcport == TIME_PORT) {
|
2004-05-12 19:23:08 +00:00
|
|
|
/* seconds since 1900-01-01 00:00:00 GMT, *not* 1970 */
|
2001-01-06 09:42:10 +00:00
|
|
|
guint32 delta_seconds = tvb_get_ntohl(tvb, 0);
|
2004-05-12 19:23:08 +00:00
|
|
|
proto_tree_add_uint_format(time_tree, hf_time_time, tvb, 0, 4,
|
|
|
|
delta_seconds, "%s",
|
2011-07-05 15:22:28 +00:00
|
|
|
abs_time_secs_to_str(delta_seconds-2208988800U, time_display_type, TRUE));
|
2000-02-09 17:17:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_time(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_time_time,
|
2000-03-20 22:52:48 +00:00
|
|
|
{ "Time", "time.time",
|
2000-02-09 17:17:00 +00:00
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0,
|
2001-06-18 02:18:27 +00:00
|
|
|
"Seconds since 00:00 (midnight) 1 January 1900 GMT", HFILL }}
|
2000-02-09 17:17:00 +00:00
|
|
|
};
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_time,
|
|
|
|
};
|
|
|
|
|
2011-07-05 15:22:28 +00:00
|
|
|
module_t *time_pref ;
|
|
|
|
|
2001-01-03 06:56:03 +00:00
|
|
|
proto_time = proto_register_protocol("Time Protocol", "TIME", "time");
|
2000-02-09 17:17:00 +00:00
|
|
|
proto_register_field_array(proto_time, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2011-07-05 15:22:28 +00:00
|
|
|
|
|
|
|
time_pref = prefs_register_protocol(proto_time, NULL);
|
|
|
|
prefs_register_enum_preference(time_pref,
|
|
|
|
"display_time_type",
|
|
|
|
"Time Display",
|
|
|
|
"Time display type",
|
|
|
|
&time_display_type,
|
|
|
|
time_display_types,
|
|
|
|
FALSE);
|
|
|
|
|
2000-02-09 17:17:00 +00:00
|
|
|
}
|
2000-04-08 07:07:42 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_time(void)
|
|
|
|
{
|
2001-12-03 04:00:26 +00:00
|
|
|
dissector_handle_t time_handle;
|
|
|
|
|
|
|
|
time_handle = create_dissector_handle(dissect_time, proto_time);
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_add_uint("udp.port", TIME_PORT, time_handle);
|
|
|
|
dissector_add_uint("tcp.port", TIME_PORT, time_handle);
|
2000-04-08 07:07:42 +00:00
|
|
|
}
|