Wireshark-dev: [Wireshark-dev] Simple Tap interface for dissector information

From: "Martin M." <SuperMotzi@xxxxxx>
Date: Fri, 03 Apr 2009 18:54:30 +0200


Hi everybody,

I just finished my protocol-dissector. But i got a big problem with the stastical information i want to get.

I decided to use the tap interface to get some interesting data. First of all some questions about the tap:

1. Where will the tap-Information be displayed ? I have no idea in which form it comes to the gui.

2. I just used the Developer Guide. So the questions are about the different parts of the tutorial:

a. "Initialising of the tap":
-----------------------------
Where do I have to put the struct "myprotocolTap"-Part in ? In the packet-myprotocol.h - Header file. right or somewhere else?

b. "Calling the protocol tap":
------------------------------
Did I have to use other variables then 'pinfo' ? Because my dissector gives me a weird error:

packet-ossdissector.c: In function ‘dissect_ossdissector’:
packet-ossdissector.c:422: error: ‘pinfo’ redeclared as different kind of symbol
packet-ossdissector.c:417: error: previous definition of ‘pinfo’ was here
packet-ossdissector.c:422: error: storage size of ‘pinfo’ isn’t known
cc1: warnings being treated as errors
packet-ossdissector.c:422: error: unused variable ‘pinfo’
make: *** [packet-ossdissector.lo] Error 1


So first i just want to realize the Tap Initailising.


Thank you for any answer.

Bye,
wireshark_noob





here the cuted protocol...(i just show the interesting parts):

/*1. Includes*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <epan/prefs.h>
#include <epan/packet.h>
#include <stdio.h>
#include <glib.h>
#include <string.h>
#include <epan/tap.h>			//  !!!IniTAP !!! (1/4)


/*2. Funktionsinitialisierung und -deklaration sowie Protokollinfos (Port, TCP)*/

void proto_register_myprot();
void proto_reg_handoff_myprot();
static void dissect_myprot(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
static int proto_myprot = -1;
static int global_myprot_port = 2000;
static dissector_handle_t myprot_handle;

static int myprot_tap = -1;			//  !!!IniTAP !!! (2/4)



/*-----Ende der Initialising und Deklaration / Programmbeginn-----*/

/*4. Dissector Initialising*/
void
proto_register_myprot(void) {

	if (proto_myprot == -1){
		proto_myprot = proto_register_protocol (
					"myprot-Protocol", /* name */
					"myprot", /* short name */
					"myprot" /* abbrev */
					);
		myprot_tap = register_tap("myprot"); //!!! IniTAP !!! (3/4)
	}
	proto_register_field_array(proto_myprot, hf, array_length(hf));
	proto_register_subtree_array(ett, array_length(ett));
}

/*5. Dissector Handoff*/			
...

/*6. Dissector function*/
static void
dissect_myprot(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
	
	static struct myprotTap pinfo;	//  !!!Ini TAP !!! (4/4)
	gint offset = 0;
	int i = 0;
	int art = 0;
	...
	
	pinfo.myprot_type			= tvb_get_guint8(tvb, 0);
	pinfo.myprot_subtype			= tvb_get_guint8(tvb, 1);
	pinfo.myprot_options			= tvb_get_guint8(tvb, 2);
	...
	
	if (check_col(pinfo->cinfo, COL_PROTOCOL))
	...
	if (check_col(pinfo->cinfo,COL_INFO))
	...
	if (check_col(pinfo->cinfo,COL_INFO))
	...

	if (tree)
	{
		...
		tap_queue_packet(myprot_tap, pinfo, &pinfo);				//  !!!IniTAP !!! (4/4)
	}
}

------------------------------------------------------------------------
------------------------------------------------------------------------

Header file


#include <glib.h>
#include <epan/packet.h>
#include <epan/conversation.h>


/* OSS Tap struct */


struct OssdissectorTap {
	gint myprot_type;
	gint myprot_subtype;
	gint myprot_options;
};


-- 
Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate + Telefonanschluss für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a