Ethereal-dev: [Ethereal-dev] Problem with rdate
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Joerg Mayer <jmayer@xxxxxxxxx>
Date: Sun, 22 Feb 2004 08:21:49 +0100
As a small exercise, I've tried to write a dissector for the rdate protocol - and failed: When I start tethereal, it dies with the following message: ** ERROR **: file proto.c: line 2227 (proto_register_protocol): assertion failed: (g_list_find_custom(protocols, name, proto_match_name) == NULL) aborting... I've attached packet-rdate.c. There is one other thing to look at: A time request is just a udp packet to port 37 without any payload. Is the code I wrote valid for that case? Thanks Jï¿œrg -- Joerg Mayer <jmayer@xxxxxxxxx> We are stuck with technology when what we really want is just stuff that works. Some say that should read Microsoft instead of technology.
/* packet-rdate.c * Routines for Time Protocol dissection * Copyright 2004, Joerg Mayer (email see AUTHORS file) * * $Id: README.developer,v 1.90 2004/02/14 10:37:22 obiot Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@xxxxxxxxxxxx> * Copyright 1998 Gerald Combs * * 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 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include <glib.h> #include <epan/packet.h> #define RDATE_PORT 37 /* Initialize the protocol and registered fields */ static int proto_rdate = -1; static int hf_rdate_seconds = -1; /* Initialize the subtree pointers */ static gint ett_rdate = -1; /* Code to actually dissect the packets */ static void dissect_rdate(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_item *ti; proto_tree *rdate_tree; char *datestring = "Todo"; guint32 seconds; guint32 length = 0; if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "rdate"); if (check_col(pinfo->cinfo, COL_INFO)) col_clear(pinfo->cinfo, COL_INFO); if (tree) { length = tvb_length_remaining (tvb, 0); if (length) { seconds = tvb_get_ntohl(tvb, 0); if (check_col(pinfo->cinfo, COL_INFO)) col_add_fstr(pinfo->cinfo, COL_INFO, "Reply: %u secs (%s)", seconds, datestring); ti = proto_tree_add_item(tree, proto_rdate, tvb, 0, 4, FALSE); rdate_tree = proto_item_add_subtree(ti, ett_rdate); proto_tree_add_protocol_format(rdate_tree, hf_rdate_seconds, tvb, 0, length, "Rdate Reply: %u secs (%s)", seconds, datestring); } else { if (check_col(pinfo->cinfo, COL_INFO)) col_set_str(pinfo->cinfo, COL_INFO, "Request"); proto_tree_add_protocol_format(rdate_tree, hf_rdate_seconds, tvb, 0, 0, "Rdate Request"); } } } void proto_register_rdate(void) { static hf_register_info hf[] = { { &hf_rdate_seconds, { "Seconds", "rdate.seconds", FT_UINT32, BASE_DEC, NULL, 0x0, "Seconds since 1.1.1900 0:00", HFILL } }, }; static gint *ett[] = { &ett_rdate }; proto_rdate = proto_register_protocol("Time Protocol", "RDATE", "rdate"); proto_register_field_array(proto_rdate, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); } void proto_reg_handoff_rdate(void) { dissector_handle_t rdate_handle; rdate_handle = create_dissector_handle(dissect_rdate, proto_rdate); dissector_add("tcp.port", RDATE_PORT, rdate_handle); dissector_add("udp.port", RDATE_PORT, rdate_handle); }
- Follow-Ups:
- Re: [Ethereal-dev] Problem with rdate
- From: Martin Regner
- Re: [Ethereal-dev] Problem with rdate
- Prev by Date: Re: [Ethereal-dev] Did anyone succeed on building the plugins on cygwin?
- Next by Date: Re: [Ethereal-dev] trying to make the Makefile.common really common between win32 and unix
- Previous by thread: Re: [Ethereal-dev] Did anyone succeed on building the pluginsoncygwin?
- Next by thread: Re: [Ethereal-dev] Problem with rdate
- Index(es):