Ethereal-dev: [Ethereal-dev] Error while starting ethereal (0.10.14)

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

From: "Jasim Tariq" <jasimtariqjt@xxxxxxxxxxx>
Date: Wed, 01 Feb 2006 10:10:33 -0800
Hi,
I am trying to capture a protocol under TCP. When I build the basic plugin code given in the ethereal developement guide (PDF) and install it, ethereal gives an error at the startup: "unspecified fatal error encountered, aborting" and "Runtime Error Program: C:\Program files\ethereal-0.10.14\ethereal-gtk2.exe This application has requested a runtime to terminate it in an an unusual way. Please contact the application's support team for more information."

The Basic Plugin code is given below:


/*****************************************************************************
*****************************Basic Plugin Setup*******************************
*****************************************************************************/

/* Include Files: Pretty constant to start with */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gmodule.h>
#include <epan/packet.h>
#include <epan/prefs.h>
#include "moduleinfo.h"


/* forward reference: Pre-declaling some functions */
void proto_register_xxx();
void proto_reg_handoff_xxx();
void dissect_xxx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);



/* 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


/* for registering pusposes */
static int proto_xxx = -1;




/* dissector raference that we will innitiate later */
static dissector_handle_t xxx_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_xxx == -1)
	{ /* execute protocol initialization only once */
		proto_register_xxx();
	}

}

/* 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_xxx();
}
#endif
/*___________________________________________________________________________*/



/******************************************************************************
******************************Plugin Initialization****************************
******************************************************************************/

void proto_register_xxx(void)
{
	module_t *xxx_module;
	if (proto_xxx == -1)
	{
/* A call to proto_register_protocol that registers the protocol. We can give it three names that will be
       used in various places to display it. */
		proto_xxx = proto_register_protocol (
		"XXXXX Name of Protocol", /* name */
		"XXX", /* short name */
		"xxx" /* abbrev */);
	}

/* call the preference register function. At the moment we have no specific protocol preferences so this will be all that we need. This takes a function parameter which is our handoff function. */
	xxx_module = prefs_register_protocol(proto_xxx, proto_reg_handoff_xxx);
}
/*_____________________________________________________________________________*/



/********************************************************************************
*********************************Plugin Handoff**********************************
********************************************************************************/

void proto_reg_handoff_xxx(void)
{
	static int Initialized=FALSE;

	/* Initialising the dissector if it hasn't been initialised yet. */
	if (!Initialized)
	{
		/* Creating the dissector. This registers a routine to be called
		to do the actual dissecting. */
		xxx_handle = create_dissector_handle(dissect_xxx, proto_xxx);

		/* Then we associate it with a
		tcp port number so that the main program will know to call us when it
		gets TCP traffic on that port. */
		dissector_add("tcp.port", 1234, xxx_handle);
	}
}
/*______________________________________________________________________________*/




/*********************************************************************************
******************************Plugin Dissection***********************************
*********************************************************************************/


/* This function is called to dissect the packets presented to it. The packet data
is held in a special buffer referenced here as tvb. We shall become fairly
familiar with this as we get deeper into the details of the protocol. The packet info structure contains general data about the protocol, and we can update information
here. The tree parameter is where the detail dissection takes place. */
static void dissect_xxx(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, "XXX");
	}

}
/*________________________________________________________________________________*/



For now I just want to capture some packets of the protocol; no details. Am I following the right procedure?

Jasim