Adding Layer 2 Protocol Dissectors to Ethereal (aka WireShark)


Protocol Dissector Parameters:

Each Ethereal protocol dissector is passed the following parameters when its dissector function is called.

Data Type

Name

Description

tvbuff_t *

tvb

Pointer to a "Testy" Virtual Buffer. A buffer structure designed to throw an exception if any attempt is made to read outside its boundaries.

packet_info *

pinfo

Pointer to data structure containing information about the packet data contained in the buffer.

proto_tree *

tree

A pointer to a hierarchical data tree used to display dissected packet data on the user interface.

Local Data for Protocol Dissectors

This section outlines the data that is declared static at the top of a single file in this module. Local data defined by packet-my-layer2.c and packet-my-layer2-msg.c are integer values used as handles when creating hierarchical data trees for display. The following is only an example, your implementation may vary. Consult documentation on Ethereal's plugin API for further information on how hierarchical data tree displays are handled.

packet-my-layer2.c

/* Initialize the protocol and registered fields */

static int proto_my_l2 = -1;
static int hf_my_l2_msg_type = -1;
static int hf_my_l2_seq_num = -1;
static int hf_my_l2_data_item_0 = -1;
static int hf_my_l2_data_item_1 = -1;
static int hf_my_l2_data_item_2 = -1;

/* Initialize the subtree pointers */

static gint ett_my_l2 = -1;
static gint ett_my_l2_msg = -1;

 

packet-my-layer2-msg.c

/* Initialize the protocol handle */

static int proto_my_layer2_msg = -1;

These handles are registered with Ethereal and filled in with the correct values later during packet data dissection and display.

Continue....






© 2002 Kazimer Corp.
1010 University Ave. PMB #1862
San Diego, CA 92103-3395