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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/packet.h>
|
2000-02-09 17:17:00 +00:00
|
|
|
|
|
|
|
static int proto_time = -1;
|
|
|
|
static int hf_time_time = -1;
|
|
|
|
|
|
|
|
static gint ett_time = -1;
|
|
|
|
|
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",
|
Remove more "CHECK_DISPLAY_AS_DATA()" calls and "pinfo->current_proto ="
statements.
Move the setting of the Protocol column in various dissectors before
anything is fetched from the packet, and also clear the Info column at
that point in those and some other dissectors, so that if an exception
is thrown, the columns don't reflect the previous protocol.
"Tvbuffify" the Mobile IP dissector (it took old-style arguments, and
then converted them into tvbuff arguments, so there wasn't much to do,
other than to fix references to "fd" to refer to "pinfo->fd").
In the SCTP dissector, refer to the port type and source and destination
ports through "pinfo" rather than through the global "pi", as it's a
tvbuffified dissector.
In the SMTP and Time Protocol dissectors, use "pinfo->match_port" rather
than "TCP_PORT_SMTP" when checking whether the packet is a request or
reply, just in case somebody makes a non-standard port be dissected as
SMTP or Time. (Also, remove a bogus comment from the Time dissector; it
was probably cut-and-pasted from the TFTP dissector.)
svn path=/trunk/; revision=2938
2001-01-25 06:14:14 +00:00
|
|
|
pinfo->srcport == pinfo->match_port ? "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
|
|
|
|
2002-01-24 09:20:54 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_time, tvb, 0, -1, FALSE);
|
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",
|
2009-12-10 22:19:29 +00:00
|
|
|
abs_time_secs_to_str(delta_seconds-2208988800U, FALSE));
|
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,
|
|
|
|
};
|
|
|
|
|
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));
|
|
|
|
}
|
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);
|
2006-08-02 17:01:38 +00:00
|
|
|
dissector_add("udp.port", TIME_PORT, time_handle);
|
|
|
|
dissector_add("tcp.port", TIME_PORT, time_handle);
|
2000-04-08 07:07:42 +00:00
|
|
|
}
|