2004-12-11 01:00:17 +00:00
|
|
|
/* packet-mate.c
|
|
|
|
* Routines for the mate Facility's Pseudo-Protocol dissection
|
|
|
|
*
|
|
|
|
* Copyright 2004, Luis E. Garcia Ontanon <gopo@webflies.org>
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* This is the pseudo protocol dissector for the mate module. ***
|
|
|
|
* It is intended for this to be just the user interface to the module. ***
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
#include "mate.h"
|
|
|
|
|
|
|
|
static int mate_tap_data = 0;
|
|
|
|
static mate_config* mc = NULL;
|
|
|
|
|
|
|
|
static int proto_mate = -1;
|
|
|
|
|
|
|
|
static char* pref_mate_config_filename = "config.mate";
|
|
|
|
|
|
|
|
static proto_item *mate_i = NULL;
|
|
|
|
|
|
|
|
void attrs_tree(proto_tree* tree, tvbuff_t *tvb,mate_item* item) {
|
|
|
|
AVPN* c;
|
|
|
|
proto_item *avpl_i;
|
|
|
|
proto_tree *avpl_t;
|
|
|
|
int* hfi_p;
|
|
|
|
|
|
|
|
avpl_i = proto_tree_add_text(tree,tvb,0,0,"%s Attributes",item->cfg->name);
|
2004-12-16 19:36:23 +00:00
|
|
|
avpl_t = proto_item_add_subtree(avpl_i, item->cfg->ett_attr);
|
2004-12-11 01:00:17 +00:00
|
|
|
|
|
|
|
for ( c = item->avpl->null.next; c->avp; c = c->next) {
|
|
|
|
hfi_p = g_hash_table_lookup(item->cfg->my_hfids,c->avp->n);
|
|
|
|
|
|
|
|
if (hfi_p) {
|
|
|
|
proto_tree_add_string(avpl_t,*hfi_p,tvb,0,0,c->avp->v);
|
|
|
|
} else {
|
|
|
|
g_warning("MATE: error: undefined attribute: mate.%s.%s",item->cfg->name,c->avp->n);
|
|
|
|
proto_tree_add_text(avpl_t,tvb,0,0,"Undefined attribute: %s=%s",c->avp->n, c->avp->v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-16 19:36:23 +00:00
|
|
|
void mate_gop_tree(proto_tree* pdu_tree, tvbuff_t *tvb, mate_gop* gop);
|
2004-12-11 01:00:17 +00:00
|
|
|
|
|
|
|
void mate_gog_tree(proto_tree* tree, tvbuff_t *tvb, mate_gog* gog, mate_gop* gop) {
|
|
|
|
proto_item *gog_item;
|
|
|
|
proto_tree *gog_tree;
|
|
|
|
proto_item *gog_gop_item;
|
|
|
|
proto_tree *gog_gop_tree;
|
|
|
|
mate_gop* gog_gops;
|
|
|
|
#ifdef _MATE_DEBUGGING
|
|
|
|
proto_item* gog_key_item;
|
|
|
|
proto_tree* gog_key_tree;
|
|
|
|
guint i;
|
|
|
|
#endif
|
|
|
|
|
2004-12-12 16:58:59 +00:00
|
|
|
gog_item = proto_tree_add_uint(tree,gog->cfg->hfid,tvb,0,0,gog->id);
|
2004-12-16 19:36:23 +00:00
|
|
|
gog_tree = proto_item_add_subtree(gog_item,gog->cfg->ett);
|
2004-12-11 01:00:17 +00:00
|
|
|
|
|
|
|
attrs_tree(gog_tree,tvb,gog);
|
|
|
|
|
|
|
|
gog_gop_item = proto_tree_add_uint(gog_tree, gog->cfg->hfid_gog_num_of_gops,
|
|
|
|
tvb, 0, 0, gog->num_of_gops);
|
|
|
|
|
2004-12-16 19:36:23 +00:00
|
|
|
gog_gop_tree = proto_item_add_subtree(gog_gop_item, gog->cfg->ett_children);
|
2004-12-11 01:00:17 +00:00
|
|
|
|
|
|
|
for (gog_gops = gog->gops; gog_gops; gog_gops = gog_gops->next) {
|
|
|
|
|
|
|
|
if (gop != gog_gops) {
|
2004-12-16 19:36:23 +00:00
|
|
|
mate_gop_tree(gog_gop_tree, tvb, gog_gops);
|
2004-12-11 01:00:17 +00:00
|
|
|
} else {
|
2004-12-12 16:58:59 +00:00
|
|
|
proto_tree_add_uint_format(gog_gop_tree,gop->cfg->hfid,tvb,0,0,gop->id,"%s of current frame: %d",gop->cfg->name,gop->id);
|
2004-12-11 01:00:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-12-16 19:36:23 +00:00
|
|
|
void mate_gop_tree(proto_tree* tree, tvbuff_t *tvb, mate_gop* gop) {
|
2004-12-11 01:00:17 +00:00
|
|
|
proto_item *gop_item;
|
|
|
|
proto_tree *gop_time_tree;
|
|
|
|
proto_item *gop_time_item;
|
|
|
|
proto_tree *gop_tree;
|
|
|
|
proto_item *gop_pdu_item;
|
|
|
|
proto_tree *gop_pdu_tree;
|
|
|
|
mate_pdu* gop_pdus;
|
|
|
|
float rel_time;
|
|
|
|
float gop_time;
|
|
|
|
|
2004-12-12 16:58:59 +00:00
|
|
|
gop_item = proto_tree_add_uint(tree,gop->cfg->hfid,tvb,0,0,gop->id);
|
2004-12-16 19:36:23 +00:00
|
|
|
gop_tree = proto_item_add_subtree(gop_item, gop->cfg->ett);
|
2004-12-11 01:00:17 +00:00
|
|
|
|
|
|
|
if (gop->gop_key) proto_tree_add_text(gop_tree,tvb,0,0,"GOP Key: %s",gop->gop_key);
|
|
|
|
|
|
|
|
attrs_tree(gop_tree,tvb,gop);
|
|
|
|
|
|
|
|
if (gop->cfg->show_gop_times) {
|
|
|
|
gop_time_item = proto_tree_add_text(gop_tree,tvb,0,0,"%s Times",gop->cfg->name);
|
2004-12-16 19:36:23 +00:00
|
|
|
gop_time_tree = proto_item_add_subtree(gop_time_item, gop->cfg->ett_times);
|
2004-12-11 01:00:17 +00:00
|
|
|
|
|
|
|
proto_tree_add_float(gop_time_tree, gop->cfg->hfid_gop_start_time, tvb, 0, 0, gop->start_time);
|
|
|
|
|
|
|
|
if (gop->released) {
|
2004-12-23 08:27:30 +00:00
|
|
|
proto_tree_add_float(gop_time_tree, gop->cfg->hfid_gop_stop_time, tvb, 0, 0, gop->release_time - gop->start_time);
|
|
|
|
proto_tree_add_float(gop_time_tree, gop->cfg->hfid_gop_last_time, tvb, 0, 0, gop->last_time - gop->start_time);
|
2004-12-11 01:00:17 +00:00
|
|
|
} else {
|
2004-12-23 08:27:30 +00:00
|
|
|
proto_tree_add_float(gop_time_tree, gop->cfg->hfid_gop_last_time, tvb, 0, 0, gop->last_time - gop->start_time);
|
2004-12-11 01:00:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rel_time = gop_time = gop->start_time;
|
|
|
|
|
|
|
|
gop_pdu_item = proto_tree_add_uint(gop_tree, gop->cfg->hfid_gop_num_pdus, tvb, 0, 0,gop->num_of_pdus);
|
2004-12-16 19:36:23 +00:00
|
|
|
gop_pdu_tree = proto_item_add_subtree(gop_pdu_item, gop->cfg->ett_children);
|
2004-12-11 01:00:17 +00:00
|
|
|
|
|
|
|
if (gop->cfg->show_pdu_tree) {
|
|
|
|
for (gop_pdus = gop->pdus; gop_pdus; gop_pdus = gop_pdus->next) {
|
|
|
|
if (gop_pdus->is_start) {
|
|
|
|
proto_tree_add_uint_format(gop_pdu_tree,gop->cfg->hfid_gop_pdu,
|
|
|
|
tvb,0,0,gop_pdus->frame,
|
|
|
|
"Start PDU: in frame %i",
|
|
|
|
gop_pdus->frame);
|
|
|
|
} else if (gop_pdus->is_stop) {
|
|
|
|
proto_tree_add_uint_format(gop_pdu_tree,gop->cfg->hfid_gop_pdu,
|
|
|
|
tvb,0,0,gop_pdus->frame,
|
|
|
|
"Stop PDU: in frame %i (%f : %f)",
|
|
|
|
gop_pdus->frame,
|
2004-12-23 08:27:30 +00:00
|
|
|
gop_pdus->time_in_gop,
|
|
|
|
gop_pdus->time_in_gop-rel_time);
|
2004-12-11 01:00:17 +00:00
|
|
|
|
|
|
|
} else if (gop_pdus->after_release) {
|
|
|
|
proto_tree_add_uint_format(gop_pdu_tree,gop->cfg->hfid_gop_pdu,
|
|
|
|
tvb,0,0,gop_pdus->frame,
|
|
|
|
"After stop PDU: in frame %i (%f : %f)",
|
|
|
|
gop_pdus->frame,
|
2004-12-23 08:27:30 +00:00
|
|
|
gop_pdus->time_in_gop,
|
|
|
|
gop_pdus->time_in_gop-rel_time);
|
2004-12-11 01:00:17 +00:00
|
|
|
} else {
|
|
|
|
proto_tree_add_uint_format(gop_pdu_tree,gop->cfg->hfid_gop_pdu,
|
|
|
|
tvb,0,0,gop_pdus->frame,
|
|
|
|
"PDU: in frame %i (%f : %f)",
|
|
|
|
gop_pdus->frame,
|
2004-12-23 08:27:30 +00:00
|
|
|
gop_pdus->time_in_gop,
|
|
|
|
gop_pdus->time_in_gop-rel_time);
|
2004-12-11 01:00:17 +00:00
|
|
|
}
|
|
|
|
|
2004-12-23 08:27:30 +00:00
|
|
|
rel_time = gop_pdus->time_in_gop;
|
2004-12-11 01:00:17 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void mate_pdu_tree(mate_pdu *pdu, tvbuff_t *tvb, proto_tree* tree) {
|
|
|
|
proto_item *pdu_item;
|
|
|
|
proto_tree *pdu_tree;
|
|
|
|
|
|
|
|
if ( ! pdu ) return;
|
|
|
|
|
|
|
|
if (pdu->gop && pdu->gop->gog) {
|
2004-12-12 16:58:59 +00:00
|
|
|
proto_item_append_text(mate_i," %s:%d->%s:%d->%s:%d",
|
|
|
|
pdu->cfg->name,pdu->id,
|
|
|
|
pdu->gop->cfg->name,pdu->gop->id,
|
|
|
|
pdu->gop->gog->cfg->name,pdu->gop->gog->id);
|
2004-12-11 01:00:17 +00:00
|
|
|
} else if (pdu->gop) {
|
2004-12-12 16:58:59 +00:00
|
|
|
proto_item_append_text(mate_i," %s:%d->%s:%d",
|
|
|
|
pdu->cfg->name,pdu->id,
|
|
|
|
pdu->gop->cfg->name,pdu->gop->id);
|
2004-12-11 01:00:17 +00:00
|
|
|
} else {
|
2004-12-12 16:58:59 +00:00
|
|
|
proto_item_append_text(mate_i," %s:%d",pdu->cfg->name,pdu->id);
|
2004-12-11 01:00:17 +00:00
|
|
|
}
|
|
|
|
|
2004-12-23 08:27:30 +00:00
|
|
|
pdu_item = proto_tree_add_uint(tree,pdu->cfg->hfid,tvb,0,0,pdu->id);
|
2004-12-16 19:36:23 +00:00
|
|
|
pdu_tree = proto_item_add_subtree(pdu_item, pdu->cfg->ett);
|
2004-12-11 01:00:17 +00:00
|
|
|
proto_tree_add_float(pdu_tree,pdu->cfg->hfid_pdu_rel_time, tvb, 0, 0, pdu->rel_time);
|
|
|
|
|
|
|
|
if (pdu->gop) {
|
2004-12-23 08:27:30 +00:00
|
|
|
proto_tree_add_float(pdu_tree,pdu->cfg->hfid_pdu_time_in_gop, tvb, 0, 0, pdu->time_in_gop);
|
2004-12-16 19:36:23 +00:00
|
|
|
mate_gop_tree(pdu_tree,tvb,pdu->gop);
|
2004-12-11 01:00:17 +00:00
|
|
|
|
|
|
|
if (pdu->gop->gog)
|
|
|
|
mate_gog_tree(pdu_tree,tvb,pdu->gop->gog,pdu->gop);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pdu->avpl) {
|
|
|
|
attrs_tree(pdu_tree,tvb,pdu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extern void mate_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
|
|
|
|
mate_pdu* pdus;
|
|
|
|
proto_tree *mate_t;
|
|
|
|
|
2004-12-16 19:36:23 +00:00
|
|
|
if ( ! (tree && mc) ) return;
|
|
|
|
|
|
|
|
analyze_frame(pinfo,tree);
|
2004-12-11 01:00:17 +00:00
|
|
|
|
|
|
|
if (( pdus = mate_get_pdus(pinfo->fd->num) )) {
|
|
|
|
for ( ; pdus; pdus = pdus->next_in_frame) {
|
2004-12-23 08:27:30 +00:00
|
|
|
mate_i = proto_tree_add_text(tree,tvb,0,0,"mate");
|
|
|
|
mate_t = proto_item_add_subtree(mate_i, mc->ett_root);
|
|
|
|
mate_pdu_tree(pdus,tvb,mate_t);
|
2004-12-11 01:00:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void init_mate(void) {
|
|
|
|
GString* tap_error = NULL;
|
|
|
|
|
|
|
|
tap_error = register_tap_listener("frame", &mate_tap_data,
|
|
|
|
mc->tap_filter,
|
|
|
|
NULL,
|
|
|
|
mate_packet,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if ( tap_error ) {
|
|
|
|
g_warning("mate: couldn't (re)register tap: %s",tap_error->str);
|
|
|
|
g_string_free(tap_error, TRUE);
|
|
|
|
mate_tap_data = 0;
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
mate_tap_data = 1;
|
|
|
|
}
|
|
|
|
|
2004-12-16 19:36:23 +00:00
|
|
|
initialize_mate_runtime();
|
2004-12-11 01:00:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extern
|
|
|
|
void
|
|
|
|
proto_reg_handoff_mate(void)
|
|
|
|
{
|
2004-12-16 19:36:23 +00:00
|
|
|
mc = mate_make_config(pref_mate_config_filename);
|
|
|
|
|
|
|
|
if (mc) {
|
|
|
|
proto_register_field_array(proto_mate, (hf_register_info*) mc->hfrs->data, mc->hfrs->len );
|
|
|
|
proto_register_subtree_array((gint**) mc->ett->data, mc->ett->len);
|
|
|
|
register_init_routine(init_mate);
|
|
|
|
}
|
|
|
|
|
2004-12-11 01:00:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern
|
|
|
|
void
|
|
|
|
proto_register_mate(void)
|
2004-12-16 19:36:23 +00:00
|
|
|
{
|
|
|
|
module_t *mate_module;
|
|
|
|
|
|
|
|
proto_mate = proto_register_protocol("Meta Analysis Tracing Engine", "mate", "mate");
|
|
|
|
register_dissector("mate",mate_tree,proto_mate);
|
|
|
|
mate_module = prefs_register_protocol(proto_mate, proto_reg_handoff_mate);
|
|
|
|
prefs_register_string_preference(mate_module, "config_filename",
|
|
|
|
"Configuration Filename",
|
|
|
|
"The name of the file containing the mate module's configuration",
|
|
|
|
&pref_mate_config_filename);
|
2004-12-11 01:00:17 +00:00
|
|
|
}
|
|
|
|
|