2006-08-02 17:13:22 +00:00
|
|
|
/* packet-daytime.c
|
|
|
|
* Routines for Daytime Protocol (RFC 867) packet dissection
|
2009-05-31 05:55:15 +00:00
|
|
|
* Copyright 2006, Stephen Fisher (see AUTHORS file)
|
2006-08-02 17:13:22 +00:00
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* Copied from packet-time.c
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
2006-08-02 17:13:22 +00:00
|
|
|
*/
|
|
|
|
|
2013-08-22 20:54:50 +00:00
|
|
|
#define NEW_PROTO_TREE_API
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2006-08-02 17:13:22 +00:00
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
|
2013-03-16 08:52:09 +00:00
|
|
|
void proto_register_daytime(void);
|
|
|
|
void proto_reg_handoff_daytime(void);
|
|
|
|
|
2013-08-22 20:54:50 +00:00
|
|
|
static dissector_handle_t daytime_handle;
|
|
|
|
|
|
|
|
static header_field_info *hfi_daytime = NULL;
|
|
|
|
|
|
|
|
#define DAYTIME_HFI_INIT HFI_INIT(proto_daytime)
|
|
|
|
|
|
|
|
static header_field_info hfi_daytime_string DAYTIME_HFI_INIT =
|
2014-09-30 23:12:26 +00:00
|
|
|
{ "Daytime", "daytime.string",
|
|
|
|
FT_STRING, BASE_NONE, NULL, 0x0,
|
|
|
|
"String containing time and date", HFILL };
|
2006-08-02 17:13:22 +00:00
|
|
|
|
2014-08-04 01:10:24 +00:00
|
|
|
static header_field_info hfi_response_request DAYTIME_HFI_INIT =
|
2014-11-26 23:18:57 +00:00
|
|
|
{ "Type", "daytime.response_request",
|
2014-09-30 23:12:26 +00:00
|
|
|
FT_BOOLEAN, 8, TFS(&tfs_response_request), 0x0,
|
|
|
|
NULL, HFILL };
|
2014-08-04 01:10:24 +00:00
|
|
|
|
2006-08-02 17:13:22 +00:00
|
|
|
static gint ett_daytime = -1;
|
|
|
|
|
|
|
|
/* This dissector works for TCP and UDP daytime packets */
|
|
|
|
#define DAYTIME_PORT 13
|
|
|
|
|
2015-11-15 13:00:10 +00:00
|
|
|
static int
|
|
|
|
dissect_daytime(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
2006-08-02 17:13:22 +00:00
|
|
|
{
|
2014-09-30 23:12:26 +00:00
|
|
|
proto_tree *daytime_tree;
|
|
|
|
proto_item *ti;
|
2006-08-02 17:13:22 +00:00
|
|
|
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "DAYTIME");
|
2006-08-02 17:13:22 +00:00
|
|
|
|
2011-09-26 11:33:10 +00:00
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "DAYTIME %s",
|
|
|
|
pinfo->srcport == pinfo->match_uint ? "Response":"Request");
|
2006-08-02 17:13:22 +00:00
|
|
|
|
|
|
|
if (tree) {
|
|
|
|
|
2013-08-22 20:54:50 +00:00
|
|
|
ti = proto_tree_add_item(tree, hfi_daytime, tvb, 0, -1, ENC_NA);
|
2006-08-02 17:13:22 +00:00
|
|
|
daytime_tree = proto_item_add_subtree(ti, ett_daytime);
|
|
|
|
|
2014-08-04 01:10:24 +00:00
|
|
|
proto_tree_add_boolean(daytime_tree, &hfi_response_request, tvb, 0, 0, pinfo->srcport==DAYTIME_PORT);
|
2006-08-02 17:13:22 +00:00
|
|
|
if (pinfo->srcport == DAYTIME_PORT) {
|
2013-08-22 20:54:50 +00:00
|
|
|
proto_tree_add_item(daytime_tree, &hfi_daytime_string, tvb, 0, -1, ENC_ASCII|ENC_NA);
|
2006-08-02 17:13:22 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-15 13:00:10 +00:00
|
|
|
return tvb_captured_length(tvb);
|
2006-08-02 17:13:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_daytime(void)
|
|
|
|
{
|
2013-11-07 20:14:18 +00:00
|
|
|
#ifndef HAVE_HFI_SECTION_INIT
|
2013-08-22 20:54:50 +00:00
|
|
|
static header_field_info *hfi[] = {
|
|
|
|
&hfi_daytime_string,
|
2014-08-04 01:10:24 +00:00
|
|
|
&hfi_response_request,
|
2006-08-02 17:13:22 +00:00
|
|
|
};
|
2013-11-07 20:14:18 +00:00
|
|
|
#endif
|
2013-08-22 20:54:50 +00:00
|
|
|
|
2006-08-02 17:13:22 +00:00
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_daytime,
|
|
|
|
};
|
|
|
|
|
2013-08-22 20:54:50 +00:00
|
|
|
int proto_daytime;
|
|
|
|
|
2006-08-02 17:13:22 +00:00
|
|
|
proto_daytime = proto_register_protocol("Daytime Protocol", "DAYTIME", "daytime");
|
2013-08-22 20:54:50 +00:00
|
|
|
hfi_daytime = proto_registrar_get_nth(proto_daytime);
|
|
|
|
|
|
|
|
proto_register_fields(proto_daytime, hfi, array_length(hfi));
|
2006-08-02 17:13:22 +00:00
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2013-08-22 20:54:50 +00:00
|
|
|
|
2015-12-09 03:49:44 +00:00
|
|
|
daytime_handle = create_dissector_handle(dissect_daytime, proto_daytime);
|
2006-08-02 17:13:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_daytime(void)
|
|
|
|
{
|
2016-10-05 20:33:54 +00:00
|
|
|
dissector_add_uint_with_preference("udp.port", DAYTIME_PORT, daytime_handle);
|
2016-10-07 20:25:01 +00:00
|
|
|
dissector_add_uint_with_preference("tcp.port", DAYTIME_PORT, daytime_handle);
|
2006-08-02 17:13:22 +00:00
|
|
|
}
|
2014-09-30 23:12:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 2
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=2 tabstop=8 expandtab:
|
|
|
|
* :indentSize=2:tabSize=8:noTabs=true:
|
|
|
|
*/
|