Ethereal-dev: [Ethereal-dev] fail to register a new protocol

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: "David Francois" <davidfrancois19@xxxxxxxxxxx>
Date: Mon, 13 Jun 2005 21:15:34 -0400
Hi,

The following is my packet-dspmsg.c. I created this file according
to packet-frame.c. The code is not completed for dissector, but it should works for protocol registration. After creating packet-dspmsg.c and packet-dspmsg.h under \epan\dissectors folder,
I added name of packet-dspmsg.c and packet-dspmsg.h in Makefile.common.

After compilation,I can see proto_register_dspmsg(void) in register_all_protocols(void) in register.c (see register.c below) but when I debug proto_register_dspmsg() with Visual C++ compiler, the code never enter proto_register_dspmsg()?

In register.c file, Visual C++ calls proto_register_dsi(), then skip proto_register_dspmsg (), then call proto_register_dtp ().

Could you tell if I missed some steps and how to fix this problem?

Thanks a lot for help.

David.



The following are register.c,packet-dspmsg.c and packet-dspmsg.h file



----------------------------- Cut Here --------------------
// register.c

void register_all_protocols(void) {
.....
 {extern void proto_register_dsi (void); proto_register_dsi ();}
 {extern void proto_register_dspmsg (void); proto_register_dspmsg ();}
 {extern void proto_register_dtp (void); proto_register_dtp ();}

.....
}


----------------------------- Cut Here --------------------

//packet-dspmsg.c

//Routines for dspmsg packet disassembly


#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <glib.h>
#include <epan/packet.h>
#include <epan/prefs.h>
#include "etypes.h"
#include <epan/addr_resolv.h>
#include "packet-dspmsg.h"
#include "packet-ieee8023.h"
#include "packet-ipx.h"
#include "packet-isl.h"
#include "packet-llc.h"
#include <epan/crc32.h>
#include <epan/tap.h>



/* protocols and header fields */
static int proto_dspmsg = -1;
static int hf_dspmsg_len = -1;
static int hf_dspmsg_num_record = -1;
static int hf_dspmsg_records = -1;

static gint ett_dspmsg2 = -1;

static int dspmsg_tap = -1;

static heur_dissector_list_t heur_subdissector_list;



static void
dissect_dspmsg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
	int fcs_len)
{
 int test = 5; // add something later here
 return;
}

void
proto_register_dspmsg(void)
{
	static hf_register_info hf[] = {

		{ &hf_dspmsg_len,
		{ "dspmsg_len",		"dspmsg.len", FT_UINT16, BASE_DEC, NULL, 0x0,
			"Source Hardware Address", HFILL }},

		{ &hf_dspmsg_num_record,
{ "record_number", "dspmsg.record_number", FT_UINT16, BASE_DEC, NULL, 0x0,
			"", HFILL }},

		/* registered here but handled in ethertype.c */
		{ &hf_dspmsg_records,
{ "records", "dspmsg.records", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0,
			"", HFILL }},

	};

	static gint *ett[] = {
		&ett_dspmsg2,
	};
	module_t *dspmsg_module;

	proto_dspmsg = proto_register_protocol("dspmsg", "dspmsg", "dspmsg");
	proto_register_field_array(proto_dspmsg, hf, array_length(hf));
	proto_register_subtree_array(ett, array_length(ett));

	/* subdissector code */
	register_heur_dissector_list("dspmsg", &heur_subdissector_list);

	/* Register configuration preferences */
	dspmsg_module = prefs_register_protocol(proto_dspmsg, NULL);

	register_dissector("dspmsg", dissect_dspmsg, proto_dspmsg);
	dspmsg_tap = register_tap("dspmsg");

}


void
proto_reg_handoff_dspmsg(void)
{
	dissector_handle_t dspmsg_handle;

	dspmsg_handle = create_dissector_handle(dissect_dspmsg,
	    proto_dspmsg);
	dissector_add("wtap_encap", WTAP_ENCAP_DSPMSG, dspmsg_handle);

}


----------------------------------- Cut Here -----------------

// packet-dspmsg.h


#ifndef __PACKET_DSPMSG_H__
#define __PACKET_DSPMSG_H__

typedef struct _dspmsg_hdr {
	guint8 dsp_id;
	guint16 msg_len;
	guint8 record_num;
} dspmsg_hdr;

#endif


----------------------------End---------------------------------

_________________________________________________________________
Take advantage of powerful junk e-mail filters built on patented Microsoft® SmartScreen Technology. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*.