Ethereal-dev: [Ethereal-dev] RE: Installing Plugins (0.10.14)

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

Date Prev · Date Next · Thread Prev · Thread Next
From: "Jasim Tariq" <jasimtariqjt@xxxxxxxxxxx>
Date: Tue, 31 Jan 2006 12:46:15 -0800

So it is your plugin that makes ethereal crash. Without knowing the source
I can just give some general advices.

Do a complete clean build of ethereal *and* your plugin.
Use a debugger, if you are familiar with it.
Make plugin sources open to the public and ask for help. ;)

Best regards,
Lars


here is the source code for the dissector. this is just a basic dissector in which all I want to do right now is display the name and type of Protocol catched.

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

#include <stdio.h>

#include <string.h>
#include <glib.h>
#include <epan/packet.h>
#include "moduleinfo.h"
#include <gmodule.h>


/* Define version if we are not building ethereal statically */
/* Making it a Plugin */
#ifndef ENABLE_STATIC
G_MODULE_EXPORT const gchar version[] = "0.0";
#endif


static int proto_srp = -1;
static int hf_srp_request = -1;
static int hf_srp_response = -1;

static gint ett_srp = -1;

#define TCP_PORT_SRP			3101


static void
dissect_srp_request(proto_tree *tree, tvbuff_t *tvb, int offset, int linelen)
{
	proto_tree_add_item(tree, hf_srp_request, tvb, offset, linelen, TRUE);
}

static void
dissect_srp_response(proto_tree *tree, tvbuff_t *tvb, int offset, int linelen)
{
	proto_tree_add_item(tree, hf_srp_response, tvb, offset, linelen, TRUE);
}

static void
dissect_srp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
	/* check to see if the Protocol column is being displayed in the UI. */
	if (check_col(pinfo->cinfo, COL_PROTOCOL))
	{
		/* If it is, we set the text of this to our protocol, so everyone can see
		its been recognised. */
		col_set_str(pinfo->cinfo, COL_PROTOCOL, "SRP");
	}
	/* Clear out stuff in the info column if it is being displayed. */
	if(check_col(pinfo->cinfo,COL_INFO))
	{
		col_clear(pinfo->cinfo,COL_INFO);
	}
}




void
proto_register_srp(void)
{
	static hf_register_info hf[] = {
	  { &hf_srp_response,
	    { "Response",           "srp.response",
	      FT_STRING, BASE_NONE, NULL, 0x0,
	      "Line of response message", HFILL }},

	  { &hf_srp_request,
	    { "Request",            "srp.request",
	      FT_STRING, BASE_NONE, NULL, 0x0,
	      "Line of request message", HFILL }},
	};

	static gint *ett[] = {
		&ett_srp,
	};
	proto_srp = proto_register_protocol("Server Relay Protocol", "SRP", "srp");
	proto_register_field_array(proto_srp, hf, array_length(hf));
	proto_register_subtree_array(ett, array_length(ett));
}

void
proto_reg_handoff_srp(void)
{
	dissector_handle_t srp_handle;

	srp_handle = create_dissector_handle(dissect_srp, proto_srp);
	dissector_add("tcp.port", TCP_PORT_SRP, srp_handle);
}


#ifndef ENABLE_STATIC

/* The first plugin entry point. The function plugin_register() is called when the plugin is loaded and allows you to do some initialisation stuff, which will include communicating with the main program
what you're plugins capabilities are */
G_MODULE_EXPORT void
plugin_register(void)
{


	/* register the new protocol, protocol fields, and subtrees */
	if (proto_srp == -1)
	{ /* execute protocol initialization only once */
		proto_register_srp();
	}

}

/* The plugin_reg_handoff routine is used when dissecting sub protocols. As our hypothetical protocol will
be hypothetically carried over TCP then we will need to do this. */
G_MODULE_EXPORT void
plugin_reg_handoff(void)
{
	proto_reg_handoff_srp();
}
#endif
/*___________________________________________________________________________*/

Since it is a plugin, I have to use "G_MODULE_EXPORT void plugin_register(void) and viod plugin_reg_handoff(viod)" routines. The error appears when I include these functions in the source. If I dont include these, the program asks for these routines at the startup?