aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mate
diff options
context:
space:
mode:
authorLars Roland <Lars.Roland@gmx.net>2004-12-31 14:27:38 +0000
committerLars Roland <Lars.Roland@gmx.net>2004-12-31 14:27:38 +0000
commit2ce1e037f63e5faf344ea51c18cd41efb2c04f6b (patch)
tree4223795ecf6f5e65465bd8402a9d6c56d44e2d32 /plugins/mate
parentfd39b4ddcafbc5aa7b28698359a5ab1b7164ecb0 (diff)
From Luis Ontanon for Mate:
- moved gop and gog indexes into gopcfgs, which is a propedeutic change for upcoming changes in the way gops are to be grouped - changed the way gog-keys are kept in memory - every gopkey attribute is copied into the gop->extras to avoid redundancy in the configuration - added timers to gogs mate.gog_type.StartTime and mate.gog_type.Time - fixed a bug in scs_subscribe that mangled some strings - minor interface improvement to scs propedeutic to having types avp values in a future - changed medium and large into mate_medium and mate_large in the scs_collection - fixed Mode=Replace in Transforms, now it works - fixed a crash at reinit due to impropper initialization of mate_items svn path=/trunk/; revision=12902
Diffstat (limited to 'plugins/mate')
-rw-r--r--plugins/mate/mate.h33
-rw-r--r--plugins/mate/mate_runtime.c181
-rw-r--r--plugins/mate/mate_setup.c72
-rw-r--r--plugins/mate/mate_util.c87
-rw-r--r--plugins/mate/matelib/h225_ras.mate2
-rw-r--r--plugins/mate/matelib/isup.mate2
-rw-r--r--plugins/mate/packet-mate.c22
7 files changed, 265 insertions, 134 deletions
diff --git a/plugins/mate/mate.h b/plugins/mate/mate.h
index 0a4a3665a2..da816119ea 100644
--- a/plugins/mate/mate.h
+++ b/plugins/mate/mate.h
@@ -157,7 +157,7 @@ typedef struct _mate_cfg_item {
gint ett_attr;
gint ett_times;
gint ett_children;
-
+
/* pdu */
gboolean discard_pdu_attributes;
gboolean last_to_be_created;
@@ -170,19 +170,25 @@ typedef struct _mate_cfg_item {
int hfid_pdu_rel_time;
int hfid_pdu_time_in_gop;
+
+ /* common to gop and gog */
+ int hfid_start_time;
+ int hfid_stop_time;
+ int hfid_last_time;
+
/* gop */
AVPL* start; /* start candidate avpl */
AVPL* stop; /* stop candidate avpl */
AVPL* key; /* key candidate avpl */
gboolean show_pdu_tree;
- gboolean show_gop_times;
+ gboolean show_times;
gboolean drop_gop;
int hfid_gop_pdu;
- int hfid_gop_start_time;
- int hfid_gop_stop_time;
- int hfid_gop_last_time;
int hfid_gop_num_pdus;
+ GHashTable* gop_index;
+ GHashTable* gog_index;
+
/* gog */
LoAL* keys;
float expiration;
@@ -199,7 +205,7 @@ typedef struct _mate_config {
gboolean drop_gop; /* destroy the gop if not assign to a gog */
guint8* mate_lib_path; /* where to look for "Include" files first */
gboolean show_pdu_tree;
- gboolean show_gop_times;
+ gboolean show_times;
gboolean last_to_be_created;
avpl_match_mode match_mode;
avpl_replace_mode replace_mode;
@@ -240,9 +246,6 @@ typedef struct _mate_runtime_data {
guint highest_analyzed_frame;
GHashTable* frames; /* k=frame.num v=pdus */
- GHashTable* items; /* k=item->id v=item */
- GHashTable* gops; /* k=gop_key_match v=gop */
- GHashTable* gogs; /* k=gog_key_match v=gog */
} mate_runtime_data;
@@ -256,6 +259,14 @@ struct _mate_item {
mate_item* next; /* in pdu: next in gop; in gop: next in gog; in gog this doesn't make any sense yet */
+ float expiration; /* when will it expire after release (all gops releases if gog)? */
+ float idle_expiration; /* when will it expire if no new pdus are assigned to it */
+
+ /* on gop and gog: */
+ float start_time; /* time of start */
+ float release_time; /* when this gop/gog was released */
+ float last_time; /* the rel_time at which the last pdu has been added (to gop or gog's gop) */
+
/* union _payload { */
/* struct _pdu { */
guint32 frame; /* wich frame I belog to? */
@@ -275,16 +286,12 @@ struct _mate_item {
gboolean released; /* has this gop been released? */
int num_of_pdus; /* how many gops a gog has? */
int num_of_after_release_pdus; /* how many pdus have arrived since it's been released */
- float start_time; /* time of start */
- float release_time; /* when this gop was released */
- float last_time; /* the rel time at which the last pdu/gop has been added */
guint8* gop_key; /* used by gop */
mate_pdu* last_pdu; /* last pdu in pdu's list */
/* } gop; */
/* struct _gog { */
mate_gop* gops; /* gops that belong to a gog (NULL in gop) */
- float expiration; /* when will it expire once released? */
int num_of_gops; /* how many gops a gog has? */
int num_of_released_gops; /* how many of them have already been released */
guint last_n; /* the number of attributes the avpl had the last time we checked */
diff --git a/plugins/mate/mate_runtime.c b/plugins/mate/mate_runtime.c
index 10a6dd2f6f..3c5cac64ae 100644
--- a/plugins/mate/mate_runtime.c
+++ b/plugins/mate/mate_runtime.c
@@ -43,6 +43,7 @@ struct _mate_range {
guint end;
};
+
typedef struct _tmp_pdu_data {
GPtrArray* ranges;
GHashTable* interesting;
@@ -50,6 +51,12 @@ typedef struct _tmp_pdu_data {
} tmp_pdu_data;
+typedef struct _gogkey {
+ guint8* key;
+ mate_cfg_gop* cfg;
+} gogkey;
+
+
static mate_runtime_data* rd = NULL;
static mate_config* mc = NULL;
@@ -64,23 +71,50 @@ static FILE* dbg_facility = NULL;
static gboolean destroy_mate_items(gpointer k _U_, gpointer v, gpointer p _U_) {
mate_item* mi = (mate_item*) v;
-
+ gogkey* gog_key;
if (mi->gop_key) g_free(mi->gop_key);
- if (mi->gog_keys) g_ptr_array_free (mi->gog_keys,TRUE);
+
+
+ if (mi->gog_keys) {
+ while (mi->gog_keys->len) {
+ gog_key = g_ptr_array_remove_index_fast(mi->gog_keys,0);
+ g_free(gog_key->key);
+ g_free(gog_key);
+ }
+
+ g_ptr_array_free (mi->gog_keys,FALSE);
+ }
+
if (mi->avpl) delete_avpl(mi->avpl,TRUE);
return TRUE;
}
+
+static gboolean clean_index(gpointer k _U_, gpointer v _U_, gpointer p _U_) {
+ return TRUE;
+}
+
static gboolean destroy_items_in_cfg(gpointer k _U_, gpointer v, gpointer p _U_) {
- g_hash_table_foreach_remove(((mate_cfg_item*)v)->items,destroy_mate_items,NULL);
- ((mate_cfg_item*)v)->last_id = 0;
+ mate_cfg_item* c = v;
+
+
+ if (c->gop_index) {
+ g_hash_table_foreach_remove(c->gop_index,clean_index,NULL);
+ }
+
+ if (c->gog_index) {
+ g_hash_table_foreach_remove(c->gog_index,clean_index,NULL);
+ }
+
+ g_hash_table_foreach_remove(c->items,destroy_mate_items,NULL);
+
+ c->last_id = 0;
+
return TRUE;
}
static void delete_mate_runtime_data(mate_runtime_data* rdat) {
- g_hash_table_destroy(rdat->gops);
g_hash_table_destroy(rdat->frames);
- g_hash_table_destroy(rdat->gogs);
g_hash_table_foreach_remove(mc->pducfgs,destroy_items_in_cfg,NULL);
g_hash_table_foreach_remove(mc->gopcfgs,destroy_items_in_cfg,NULL);
@@ -106,8 +140,6 @@ extern void initialize_mate_runtime(void) {
rd->current_items = 0;
rd->now = -1.0;
rd->frames = g_hash_table_new(g_direct_hash,g_direct_equal);
- rd->gops = g_hash_table_new(g_str_hash,g_str_equal);
- rd->gogs = g_hash_table_new(g_str_hash,g_str_equal);
rd->mate_items = g_mem_chunk_new("mate_items",sizeof(mate_item),1024,G_ALLOC_AND_FREE);
rd->highest_analyzed_frame = 0;
@@ -126,19 +158,48 @@ extern void initialize_mate_runtime(void) {
static mate_item* new_mate_item(mate_cfg_item* cfg) {
mate_item* it = g_mem_chunk_alloc(rd->mate_items);
- it->cfg = cfg;
cfg->last_id++;
it->id = cfg->last_id;
+ it->cfg = cfg;
+
it->avpl = NULL ;
- it->frame = 0 ;
+
it->next = NULL ;
- it->released = FALSE ;
+
it->expiration = 0.0;
+ it->idle_expiration = 0.0;
- rd->current_items++;
+ it->start_time = 0.0;
+ it->release_time = 0.0;
+ it->last_time = 0.0;
+
+ it->frame = 0 ;
+ it->gop = NULL;
+ it->first = FALSE;
+ it->is_start = FALSE;
+ it->is_stop = FALSE;
+ it->after_release = FALSE;
+ it->rel_time = 0.0;
+ it->time_in_gop = -1.0;
+ it->next_in_frame = NULL;
+
+ it->gog = NULL;
+ it->pdus = NULL;
+ it->released = FALSE ;
+ it->num_of_pdus = 0;
+ it->num_of_after_release_pdus = 0;
+ it->gop_key = NULL;
+ it->gops = NULL;
+ it->num_of_gops = 0;
+ it->num_of_released_gops = 0;
+ it->last_n = 0;
+ it->gog_keys = NULL;
+ it->last_gop = NULL;
+ rd->current_items++;
+
g_hash_table_insert(cfg->items,GUINT_TO_POINTER(it->id),it);
return it;
}
@@ -150,14 +211,10 @@ static mate_gop* new_gop(mate_cfg_gop* cfg, mate_pdu* pdu, guint8* key) {
gop->avpl = new_avpl(cfg->name);
- gop->gog = NULL;
gop->pdus = pdu;
gop->last_pdu = pdu;
gop->gop_key = key;
- gop->next = NULL;
gop->start_time = rd->now;
- gop->release_time = 0.0;
- gop->last_time = 0.0;
pdu->gop = gop;
pdu->next = NULL;
@@ -193,14 +250,10 @@ static mate_gog* new_gog(mate_cfg_gog* cfg, mate_gop* gop) {
dbg_print (dbg_gog,1,dbg_facility,"new_gog: %s:d for %s:%d",gog->cfg->name,gog->id,gog->cfg->name,gop->id);
- gog->cfg = cfg;
gog->avpl = new_avpl(cfg->name);
- gog->gops = NULL;
- gog->last_n = 0;
- gog->gog_keys = g_ptr_array_new();
- gog->last_gop = NULL;
- gog->start_time = gop->rel_time;
+ gog->gog_keys = g_ptr_array_new();
+ gog->start_time = rd->now;
adopt_gop(gog,gop);
@@ -236,25 +289,34 @@ static void apply_extras(AVPL* from, AVPL* to, mate_cfg_item* cfg) {
}
static void gog_remove_keys (mate_gog* gog) {
- guint8* k;
-
+ gogkey* gog_key;
+
while (gog->gog_keys->len) {
- k = (guint8*) g_ptr_array_remove_index_fast(gog->gog_keys,0);
- g_hash_table_remove(rd->gogs,k);
- g_free(k);
+ gog_key = g_ptr_array_remove_index_fast(gog->gog_keys,0);
+
+ if (g_hash_table_lookup(gog_key->cfg->gog_index,gog_key->key)) {
+ g_hash_table_remove(gog_key->cfg->gog_index,gog_key->key);
+ }
+
+ g_free(gog_key->key);
+ g_free(gog_key);
}
+
}
static void reanalyze_gop(mate_gop* gop) {
LoAL* gog_keys = NULL;
AVPL* curr_gogkey = NULL;
+ mate_cfg_gop* gop_cfg = NULL;
void* cookie = NULL;
AVPL* gogkey_match = NULL;
mate_gog* gog = gop->gog;
- guint8* key;
+ gogkey* gog_key;
if ( ! gog ) return;
+ gog->last_time = rd->now;
+
dbg_print (dbg_gog,1,dbg_facility,"reanalize_gop: gop=%s gog=%s\n",gog->cfg->name,gog->id,gog->cfg->name,gop->id);
apply_extras(gop->avpl,gog->avpl,gog->cfg);
@@ -266,18 +328,34 @@ static void reanalyze_gop(mate_gop* gop) {
gog_keys = gog->cfg->keys;
while (( curr_gogkey = get_next_avpl(gog_keys,&cookie) )) {
- if (( gogkey_match = new_avpl_exact_match("",gog->avpl,curr_gogkey,FALSE) )) {
- key = avpl_to_str(gogkey_match);
- if ( g_hash_table_lookup(rd->gogs,key) ) {
- g_free(key);
+ gop_cfg = g_hash_table_lookup(mc->gopcfgs,curr_gogkey->name);
+
+ if (( gogkey_match = new_avpl_exact_match(gop_cfg->name,gog->avpl,curr_gogkey,FALSE) )) {
+
+ gog_key = g_malloc(sizeof(gogkey));
+
+ gog_key->key = avpl_to_str(gogkey_match);
+ delete_avpl(gogkey_match,FALSE);
+
+ gog_key->cfg = gop_cfg;
+
+ if (g_hash_table_lookup(gop_cfg->gog_index,gog_key->key)) {
+ g_free(gog_key->key);
+ g_free(gog_key);
+ gog_key = NULL;
+ }
+
+ if (! gog_key ) {
+ /* TODO: try mergeing the gogs */
} else {
- dbg_print (dbg_gog,1,dbg_facility,"analize_gop: new key for gog=%s:%d : %s\n",gog->cfg->name,gog->id,key);
- g_hash_table_insert(rd->gogs,key,gog);
- g_ptr_array_add(gog->gog_keys,key);
+ dbg_print (dbg_gog,1,dbg_facility,"analize_gop: new key for gog=%s:%d : %s\n",gog->cfg->name,gog->id,gog_key->key);
+ g_ptr_array_add(gog->gog_keys,gog_key);
+ g_hash_table_insert(gog_key->cfg->gog_index,gog_key->key,gog);
}
- delete_avpl(gogkey_match,FALSE);
+
}
}
+
gog->last_n = gog->avpl->len;
}
@@ -317,13 +395,13 @@ static void analize_gop(mate_gop* gop) {
dbg_print (dbg_gog,2,dbg_facility,"analize_gop: about to match\n");
- if (( gogkey_match = new_avpl_exact_match(curr_gogkey->name,gop->avpl,curr_gogkey,TRUE) )) {
+ if (( gogkey_match = new_avpl_exact_match(gop->cfg->name,gop->avpl,curr_gogkey,TRUE) )) {
key = avpl_to_str(gogkey_match);
dbg_print (dbg_gog,1,dbg_facility,"analize_gop: got gogkey_match: %s\n",key);
- if (( gog = g_hash_table_lookup(rd->gogs,key) )) {
+ if (( gog = g_hash_table_lookup(gop->cfg->gog_index,key) )) {
dbg_print (dbg_gog,1,dbg_facility,"analize_gop: got already a matching gog\n");
if (gog->num_of_gops == gog->num_of_released_gops && gog->expiration < rd->now) {
@@ -332,7 +410,6 @@ static void analize_gop(mate_gop* gop) {
gog_remove_keys(gog);
gog = new_gog(gog->cfg,gop);
- gog->num_of_gops = 1;
break;
} else {
@@ -348,9 +425,10 @@ static void analize_gop(mate_gop* gop) {
dbg_print (dbg_gog,1,dbg_facility,"analize_gop: no such gog in hash, let's create a new one\n");
cfg = g_hash_table_lookup(mc->gogcfgs,curr_gogkey->name);
-
- gog = new_gog(cfg,gop);
- gog->num_of_gops = 1;
+ if (cfg) {
+ gog = new_gog(cfg,gop);
+ gog->num_of_gops = 1;
+ }
}
delete_avpl(gogkey_match,TRUE);
@@ -415,7 +493,7 @@ static void analize_pdu(mate_pdu* pdu) {
delete_avpl(is_start,FALSE);
}
- g_hash_table_lookup_extended(rd->gops,gop_key,(gpointer*)&orig_gop_key,(gpointer*)&gop);
+ g_hash_table_lookup_extended(cfg->gop_index,gop_key,(gpointer*)&orig_gop_key,(gpointer*)&gop);
if ( gop ) {
g_free(gop_key);
@@ -426,13 +504,13 @@ static void analize_pdu(mate_pdu* pdu) {
if (is_start) {
if ( gop->released ) {
- g_hash_table_remove(rd->gops,gop_key);
+ dbg_print (dbg_gop,1,dbg_facility,"analize_pdu: start on released gop, a new gop\n");
+ g_hash_table_remove(cfg->gop_index,gop_key);
gop = new_gop(cfg,pdu,gop_key);
- g_hash_table_insert(rd->gops,gop_key,gop);
+ g_hash_table_insert(cfg->gop_index,gop_key,gop);
+ } else {
+ dbg_print (dbg_gop,1,dbg_facility,"analize_pdu: duplicate start on gop\n");
}
-
- dbg_print (dbg_gop,1,dbg_facility,"analize_pdu: duplicate start on gop\n");
-
}
pdu->gop = gop;
@@ -446,14 +524,13 @@ static void analize_pdu(mate_pdu* pdu) {
} else {
- dbg_print (dbg_gop,1,dbg_facility,"analize_pdu: no gop\n");
+ dbg_print (dbg_gop,1,dbg_facility,"analize_pdu: no gop already\n");
if (is_start) {
gop = new_gop(cfg,pdu,gop_key);
-
- g_hash_table_insert(rd->gops,gop_key,gop);
+ g_hash_table_insert(cfg->gop_index,gop_key,gop);
} else {
- dbg_print (dbg_gop,1,dbg_facility,"analize_pdu: an unassigned pdu\n");
+ dbg_print (dbg_gop,6,dbg_facility,"analize_pdu: an unassigned pdu\n");
pdu->gop = NULL;
pdu->next = NULL;
diff --git a/plugins/mate/mate_setup.c b/plugins/mate/mate_setup.c
index accbfe8708..d46680dae7 100644
--- a/plugins/mate/mate_setup.c
+++ b/plugins/mate/mate_setup.c
@@ -114,7 +114,7 @@ static mate_cfg_item* new_mate_cfg_item(guint8* name) {
new->drop_gop = matecfg->drop_gop;
new->expiration = matecfg->gog_expiration;
new->show_pdu_tree = matecfg->show_pdu_tree;
- new->show_gop_times = matecfg->show_gop_times;
+ new->show_times = matecfg->show_times;
new->last_id = 0;
new->hfid_ranges = NULL;
new->hfids_attr = NULL;
@@ -131,9 +131,9 @@ static mate_cfg_item* new_mate_cfg_item(guint8* name) {
new->items = g_hash_table_new(g_direct_hash,g_direct_equal);
new->hfid_gop_pdu = -1;
- new->hfid_gop_start_time = -1;
- new->hfid_gop_stop_time = -1;
- new->hfid_gop_last_time = -1;
+ new->hfid_start_time = -1;
+ new->hfid_stop_time = -1;
+ new->hfid_last_time = -1;
new->hfid_gop_num_pdus = -1;
new->hfid_gog_num_of_gops = -1;
@@ -144,6 +144,9 @@ static mate_cfg_item* new_mate_cfg_item(guint8* name) {
new->ett_times = -1;
new->ett_children = -1;
+ new->gop_index = NULL;
+ new->gog_index = NULL;
+
return new;
}
@@ -197,6 +200,9 @@ static mate_cfg_gop* new_gopcfg(guint8* name) {
g_hash_table_insert(matecfg->gopcfgs,(gpointer) new->name, (gpointer) new);
+ new->gop_index = g_hash_table_new(g_str_hash,g_str_equal);
+ new->gog_index = g_hash_table_new(g_str_hash,g_str_equal);
+
return new;
}
@@ -566,7 +572,7 @@ static gboolean config_settings(AVPL*avpl) {
matecfg->drop_pdu = extract_named_bool(avpl, KEYWORD_DROPPDU,matecfg->drop_pdu);
matecfg->drop_gop = extract_named_bool(avpl, KEYWORD_DROPGOP,matecfg->drop_gop);
matecfg->show_pdu_tree = extract_named_bool(avpl, KEYWORD_SHOWPDUTREE,matecfg->show_pdu_tree);
- matecfg->show_gop_times = extract_named_bool(avpl, KEYWORD_SHOWGOPTIMES,matecfg->show_gop_times);
+ matecfg->show_times = extract_named_bool(avpl, KEYWORD_SHOWGOPTIMES,matecfg->show_times);
if(( avp = extract_avp_by_name(avpl,KEYWORD_DEBUGFILENAME) )) {
matecfg->dbg_facility = dbg_facility = fopen(avp->v,"w");
@@ -721,7 +727,7 @@ static gboolean config_gop(AVPL* avpl) {
cfg->drop_gop = extract_named_bool(avpl, KEYWORD_DROPGOP,matecfg->drop_gop);
cfg->show_pdu_tree = extract_named_bool(avpl, KEYWORD_SHOWPDUTREE, matecfg->show_pdu_tree);
- cfg->show_gop_times = extract_named_bool(avpl, KEYWORD_SHOWGOPTIMES,matecfg->show_gop_times);
+ cfg->show_times = extract_named_bool(avpl, KEYWORD_SHOWGOPTIMES,matecfg->show_times);
cfg->key = avpl;
@@ -784,7 +790,7 @@ static gboolean config_gopextra(AVPL* avpl) {
cfg->drop_gop = extract_named_bool(avpl, KEYWORD_DROPGOP,cfg->drop_gop);
cfg->show_pdu_tree = extract_named_bool(avpl, KEYWORD_SHOWPDUTREE, cfg->show_pdu_tree);
- cfg->show_gop_times = extract_named_bool(avpl, KEYWORD_SHOWGOPTIMES,cfg->show_gop_times);
+ cfg->show_times = extract_named_bool(avpl, KEYWORD_SHOWGOPTIMES,cfg->show_times);
merge_avpl(cfg->extra,avpl,TRUE);
@@ -1235,7 +1241,7 @@ static void analyze_gop_config(gpointer k _U_, gpointer v, gpointer p _U_) {
g_array_append_val(matecfg->hfrs,hfri);
- hfri.p_id = &(cfg->hfid_gop_start_time);
+ hfri.p_id = &(cfg->hfid_start_time);
hfri.hfinfo.name = g_strdup_printf("%s start time",cfg->name);
hfri.hfinfo.abbrev = g_strdup_printf("mate.%s.StartTime",cfg->name);
hfri.hfinfo.type = FT_FLOAT;
@@ -1244,14 +1250,14 @@ static void analyze_gop_config(gpointer k _U_, gpointer v, gpointer p _U_) {
g_array_append_val(matecfg->hfrs,hfri);
- hfri.p_id = &(cfg->hfid_gop_stop_time);
+ hfri.p_id = &(cfg->hfid_stop_time);
hfri.hfinfo.name = g_strdup_printf("%s hold time",cfg->name);
hfri.hfinfo.abbrev = g_strdup_printf("mate.%s.Time",cfg->name);
hfri.hfinfo.blurb = g_strdup_printf("Duration in seconds from start to stop of this %s",cfg->name);
g_array_append_val(matecfg->hfrs,hfri);
- hfri.p_id = &(cfg->hfid_gop_last_time);
+ hfri.p_id = &(cfg->hfid_last_time);
hfri.hfinfo.name = g_strdup_printf("%s duration",cfg->name);
hfri.hfinfo.abbrev = g_strdup_printf("mate.%s.Duration",cfg->name);
hfri.hfinfo.blurb = g_strdup_printf("Time passed between the start of this %s and the last pdu assigned to it",cfg->name);
@@ -1324,6 +1330,7 @@ static void analyze_gog_config(gpointer k _U_, gpointer v, gpointer p _U_) {
void* avpl_cookie;
AVP* avp;
AVPL* avpl;
+ AVPL* key_avps;
hf_register_info hfri = { NULL, {NULL, NULL, FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL}};
gint* ett;
@@ -1335,16 +1342,32 @@ static void analyze_gog_config(gpointer k _U_, gpointer v, gpointer p _U_) {
hfri.hfinfo.display = BASE_DEC;
g_array_append_val(matecfg->hfrs,hfri);
-
+
hfri.p_id = &(cfg->hfid_gog_num_of_gops);
hfri.hfinfo.name = "number of GOPs";
hfri.hfinfo.abbrev = g_strdup_printf("mate.%s.NumOfGops",cfg->name);
hfri.hfinfo.type = FT_UINT32;
hfri.hfinfo.display = BASE_DEC;
hfri.hfinfo.blurb = g_strdup_printf("Number of GOPs assigned to this %s",cfg->name);
-
+
g_array_append_val(matecfg->hfrs,hfri);
-
+
+ hfri.p_id = &(cfg->hfid_start_time);
+ hfri.hfinfo.name = g_strdup_printf("%s start time",cfg->name);
+ hfri.hfinfo.abbrev = g_strdup_printf("mate.%s.StartTime",cfg->name);
+ hfri.hfinfo.type = FT_FLOAT;
+ hfri.hfinfo.blurb = g_strdup_printf("Seconds passed since the begining of caputre to the start of this %s",cfg->name);
+
+ g_array_append_val(matecfg->hfrs,hfri);
+
+ hfri.p_id = &(cfg->hfid_last_time);
+ hfri.hfinfo.name = g_strdup_printf("%s duration",cfg->name);
+ hfri.hfinfo.abbrev = g_strdup_printf("mate.%s.Duration",cfg->name);
+ hfri.hfinfo.blurb = g_strdup_printf("Time passed between the start of this %s and the last pdu assigned to it",cfg->name);
+
+ g_array_append_val(matecfg->hfrs,hfri);
+
+ /* this might become mate.gogname.gopname */
hfri.p_id = &(cfg->hfid_gog_gop);
hfri.hfinfo.name = "a GOP";
hfri.hfinfo.abbrev = g_strdup_printf("mate.%s.Gop",cfg->name);
@@ -1354,12 +1377,15 @@ static void analyze_gog_config(gpointer k _U_, gpointer v, gpointer p _U_) {
g_array_append_val(matecfg->hfrs,hfri);
+ key_avps = new_avpl("");
+
avpl_cookie = NULL;
while (( avpl = get_next_avpl(cfg->keys,&avpl_cookie) )) {
avp_cookie = NULL;
while (( avp = get_next_avp(avpl,&avp_cookie) )) {
if (! g_hash_table_lookup(cfg->my_hfids,avp->n)) {
new_attr_hfri(cfg,avp->n);
+ insert_avp(key_avps,avp);
}
}
}
@@ -1370,7 +1396,10 @@ static void analyze_gog_config(gpointer k _U_, gpointer v, gpointer p _U_) {
new_attr_hfri(cfg,avp->n);
}
}
-
+
+ merge_avpl(cfg->extra,key_avps,TRUE);
+ delete_avpl(key_avps,FALSE);
+
analyze_transform_hfrs(cfg);
ett = &cfg->ett;
@@ -1382,6 +1411,9 @@ static void analyze_gog_config(gpointer k _U_, gpointer v, gpointer p _U_) {
ett = &cfg->ett_children;
g_array_append_val(matecfg->ett,ett);
+ ett = &cfg->ett_times;
+ g_array_append_val(matecfg->ett,ett);
+
}
static size_t analyze_config() {
@@ -1499,17 +1531,7 @@ static void init_actions() {
}
-void reset_cfg(gpointer k _U_, gpointer v, gpointer p _U_) {
- mate_cfg_item* c = v;
- c->last_id = 0;
-}
-
extern mate_config* mate_cfg() {
-
- g_hash_table_foreach(matecfg->pducfgs,reset_cfg,NULL);
- g_hash_table_foreach(matecfg->gopcfgs,reset_cfg,NULL);
- g_hash_table_foreach(matecfg->gogcfgs,reset_cfg,NULL);
-
return matecfg;
}
@@ -1525,7 +1547,7 @@ extern mate_config* mate_make_config(guint8* filename) {
matecfg->drop_pdu = FALSE;
matecfg->drop_gop = FALSE;
matecfg->show_pdu_tree = TRUE;
- matecfg->show_gop_times = TRUE;
+ matecfg->show_times = TRUE;
matecfg->last_to_be_created = FALSE;
matecfg->match_mode = AVPL_STRICT;
matecfg->replace_mode = AVPL_INSERT;
diff --git a/plugins/mate/mate_util.c b/plugins/mate/mate_util.c
index 14c3658f8c..e79e3005a3 100644
--- a/plugins/mate/mate_util.c
+++ b/plugins/mate/mate_util.c
@@ -95,23 +95,22 @@ void dbg_print(const guint* which, guint how, FILE* where, guint8* fmt, ... ) {
*
* Initializes the scs hash.
**/
-
+
/* Don't call variables "small" or "huge". They are keywords for the MSVC compiler. Rename them to "mate_small" and "mate_huge"*/
struct _scs_collection {
GHashTable* hash; /* key: a string value: guint number of subscribers */
GMemChunk* ctrs;
GMemChunk* mate_small;
- GMemChunk* medium;
- GMemChunk* large;
+ GMemChunk* mate_medium;
+ GMemChunk* mate_large;
GMemChunk* mate_huge;
- guint8* buf;
};
extern void destroy_scs_collection(SCS_collection* c) {
if ( c->ctrs ) g_mem_chunk_destroy(c->ctrs);
if ( c->mate_small ) g_mem_chunk_destroy(c->mate_small);
- if ( c->medium ) g_mem_chunk_destroy(c->medium);
- if ( c->large ) g_mem_chunk_destroy(c->large);
+ if ( c->mate_medium ) g_mem_chunk_destroy(c->mate_medium);
+ if ( c->mate_large ) g_mem_chunk_destroy(c->mate_large);
if ( c->mate_huge ) g_mem_chunk_destroy(c->mate_huge);
if (c->hash) g_hash_table_destroy(c->hash);
@@ -128,17 +127,14 @@ extern SCS_collection* scs_init(void) {
c->mate_small = g_mem_chunk_new("small_scs_chunk", SCS_SMALL_SIZE,
SCS_SMALL_SIZE * SCS_SMALL_CHUNK_SIZE, G_ALLOC_AND_FREE);
- c->medium = g_mem_chunk_new("medium_scs_chunk", SCS_MEDIUM_SIZE,
+ c->mate_medium = g_mem_chunk_new("medium_scs_chunk", SCS_MEDIUM_SIZE,
SCS_MEDIUM_SIZE * SCS_MEDIUM_CHUNK_SIZE, G_ALLOC_AND_FREE);
- c->large = g_mem_chunk_new("large_scs_chunk", SCS_LARGE_SIZE,
+ c->mate_large = g_mem_chunk_new("large_scs_chunk", SCS_LARGE_SIZE,
SCS_LARGE_SIZE * SCS_LARGE_CHUNK_SIZE, G_ALLOC_AND_FREE);
c->mate_huge = g_mem_chunk_new("huge_scs_chunk", SCS_HUGE_SIZE,
SCS_HUGE_SIZE * SCS_HUGE_CHUNK_SIZE, G_ALLOC_AND_FREE);
-
- c->buf = g_mem_chunk_alloc0(c->mate_huge);
-
return c;
}
@@ -159,41 +155,43 @@ guint8* scs_subscribe(SCS_collection* c, guint8* s) {
guint8* orig = NULL;
guint* ip = NULL;
size_t len = 0;
- guint8* new = NULL;
GMemChunk* chunk = NULL;
g_hash_table_lookup_extended(c->hash,s,(gpointer*)&orig,(gpointer*)&ip);
if (ip) {
(*ip)++;
- new = orig;
} else {
ip = g_mem_chunk_alloc(c->ctrs);
*ip = 0;
len = strlen(s) + 1;
+
if (len <= SCS_SMALL_SIZE) {
chunk = c->mate_small;
+ len = SCS_SMALL_SIZE;
} else if (len <= SCS_MEDIUM_SIZE) {
- chunk = c->medium;
+ chunk = c->mate_medium;
+ len = SCS_MEDIUM_SIZE;
} else if (len <= SCS_LARGE_SIZE) {
- chunk = c->large;
+ chunk = c->mate_large;
+ len = SCS_LARGE_SIZE;
} else if (len < SCS_HUGE_SIZE) {
chunk = c->mate_huge;
+ len = SCS_HUGE_SIZE;
} else {
chunk = c->mate_huge;
len = SCS_HUGE_SIZE;
g_warning("mate SCS: string truncated to huge size");
}
- --len;
- new = g_mem_chunk_alloc(chunk);
- strncpy(new,s,len);
+ orig = g_mem_chunk_alloc(chunk);
+ strncpy(orig,s,len);
- g_hash_table_insert(c->hash,new,ip);
+ g_hash_table_insert(c->hash,orig,ip);
}
- return new;
+ return orig;
}
/**
@@ -221,9 +219,9 @@ void scs_unsubscribe(SCS_collection* c, guint8* s) {
if (len < SCS_SMALL_SIZE) {
chunk = c->mate_small;
} else if (len < SCS_MEDIUM_SIZE) {
- chunk = c->medium;
+ chunk = c->mate_medium;
} else if (len < SCS_LARGE_SIZE) {
- chunk = c->large;
+ chunk = c->mate_large;
} else {
chunk = c->mate_huge;
}
@@ -231,7 +229,9 @@ void scs_unsubscribe(SCS_collection* c, guint8* s) {
g_mem_chunk_free(chunk,orig);
g_mem_chunk_free(c->ctrs,ip);
}
- else (*ip)--;
+ else {
+ (*ip)--;
+ }
} else {
g_warning("unsusbcribe: already deleted: '%s'?",s);
}
@@ -248,14 +248,30 @@ void scs_unsubscribe(SCS_collection* c, guint8* s) {
**/
extern guint8* scs_subscribe_printf(SCS_collection* c, guint8* fmt, ...) {
va_list list;
-
+ static guint8 buf[SCS_HUGE_SIZE];
+
va_start( list, fmt );
- g_vsnprintf(c->buf, SCS_HUGE_SIZE-1 ,fmt, list);
+ g_vsnprintf(buf, SCS_HUGE_SIZE-1 ,fmt, list);
va_end( list );
- return scs_subscribe(c,c->buf);
+ return scs_subscribe(c,buf);
}
+extern guint8* scs_subscribe_int(SCS_collection* c, int i) {
+ static guint8 buf[SCS_SMALL_SIZE];
+
+ g_snprintf(buf, SCS_SMALL_SIZE-1 ,"%i", i);
+
+ return scs_subscribe(c,buf);
+}
+
+extern guint8* scs_subscribe_float(SCS_collection* c, float f) {
+ static guint8 buf[SCS_SMALL_SIZE];
+
+ g_snprintf(buf, SCS_SMALL_SIZE-1 ,"%f", f);
+
+ return scs_subscribe(c,buf);
+}
/***************************************************************************
* AVPs & Co.
@@ -357,22 +373,21 @@ extern void avp_init(void) {
extern AVP* new_avp_from_finfo(guint8* name, field_info* finfo) {
AVP* new = g_mem_chunk_alloc(avp_chunk);
guint8* value;
- guint8* str;
+
new->n = scs_subscribe(avp_strings, name);
if (finfo->value.ftype->get_value_integer) {
- value = scs_subscribe_printf(avp_strings, "%i",fvalue_get_integer(&finfo->value));
+ value = scs_subscribe_int(avp_strings, fvalue_get_integer(&finfo->value));
#ifdef _AVP_DEBUGGING
dbg_print (dbg_avp,2,dbg_fp,"new_avp_from_finfo: from integer: %s",value);
#endif
} else if (finfo->value.ftype->val_to_string_repr) {
- str = fvalue_to_string_repr(&finfo->value,FTREPR_DISPLAY,NULL);
- value = scs_subscribe(avp_strings, str);
+ value = scs_subscribe(avp_strings, fvalue_to_string_repr(&finfo->value,FTREPR_DISPLAY,NULL));
#ifdef _AVP_DEBUGGING
dbg_print (dbg_avp,2,dbg_fp,"new_avp_from_finfo: from string: %s",value);
#endif
} else if (finfo->value.ftype->get_value_floating) {
- value = scs_subscribe_printf(avp_strings, "%f",fvalue_get_floating(&finfo->value));
+ value = scs_subscribe_float(avp_strings, fvalue_get_floating(&finfo->value));
#ifdef _AVP_DEBUGGING
dbg_print (dbg_avp,2,dbg_fp,"new_avp_from_finfo: from float: %s",value);
#endif
@@ -380,7 +395,7 @@ extern AVP* new_avp_from_finfo(guint8* name, field_info* finfo) {
#ifdef _AVP_DEBUGGING
dbg_print (dbg_avp,2,dbg_fp,"new_avp_from_finfo: a proto: %s",finfo->hfinfo->abbrev);
#endif
- value = scs_subscribe(avp_strings, finfo->hfinfo->abbrev);
+ value = scs_subscribe(avp_strings, "");
}
new->v = value;
@@ -1420,7 +1435,7 @@ extern AVPL_Transf* new_avpl_transform(guint8* name, AVPL* mixed, avpl_match_mod
while (( avp = extract_first_avp(mixed) )) {
if (*(avp->n) == '.') {
- rename_avp(avp,(avp->n+1));
+ rename_avp(avp,((avp->n)+1));
insert_avp(t->replace, avp);
} else {
insert_avp(t->match, avp);
@@ -1476,7 +1491,6 @@ extern void avpl_transform(AVPL* src, AVPL_Transf* op) {
AVPN* cs;
AVPN* cm;
AVPN* n;
- gboolean d;
#ifdef _AVP_DEBUGGING
dbg_print(dbg_avpl_op,3,dbg_fp,"avpl_transform: src=%X op=%X",src,op);
@@ -1498,9 +1512,8 @@ extern void avpl_transform(AVPL* src, AVPL_Transf* op) {
case AVPL_REPLACE:
cs = src->null.next;
cm = avpl->null.next;
- d = FALSE;
while(cs->avp) {
- if (cs->avp == cm->avp) {
+ if (cm->avp && cs->avp->n == cm->avp->n && cs->avp->v == cm->avp->v) {
n = cs->next;
cs->prev->next = cs->next;
@@ -1514,7 +1527,7 @@ extern void avpl_transform(AVPL* src, AVPL_Transf* op) {
}
}
- merge_avpl(src,avpl,TRUE);
+ merge_avpl(src,op->replace,TRUE);
delete_avpl(avpl,TRUE);
return;
}
diff --git a/plugins/mate/matelib/h225_ras.mate b/plugins/mate/matelib/h225_ras.mate
index 6b40976cab..398325db58 100644
--- a/plugins/mate/matelib/h225_ras.mate
+++ b/plugins/mate/matelib/h225_ras.mate
@@ -1,7 +1,7 @@
# h225_ras.mate
# $Id$
-Action=PduDef; Name=ras_pdu; Proto=h225.RasMessage; Transport=udp/ip; addr=ip.addr; ras_sn=h225.RequestSeqNum; ras_msg=h225.RasMessage;
+Action=PduDef; Name=ras_pdu; Proto=h225.RasMessage; Transport=udp/ip; ras_sn=h225.RequestSeqNum; ras_msg=h225.RasMessage; addr=ip.addr;
Action=GopDef; Name=ras_leg; On=ras_pdu; addr; addr; ras_sn;
Action=GopStart; For=ras_leg; ras_msg|0|3|6|9|12|15|18|21|26|30;
Action=GopStop; For=ras_leg; ras_msg|1|2|4|5|7|8|10|11|13|14|16|17|19|20|22|24|27|28|29|31;
diff --git a/plugins/mate/matelib/isup.mate b/plugins/mate/matelib/isup.mate
index 7b3d400809..e7bad36835 100644
--- a/plugins/mate/matelib/isup.mate
+++ b/plugins/mate/matelib/isup.mate
@@ -1,6 +1,7 @@
# isup.mate
# $Id$
+
#Action=Transform; Name=isup_msg_type; Mode=Insert; Match=Strict; isup_msg=1; .isup_IAM=;
#Action=Transform; Name=isup_msg_type; Mode=Insert; Match=Strict; isup_msg=2; .isup_SAM=;
#Action=Transform; Name=isup_msg_type; Mode=Insert; Match=Strict; isup_msg=3; .isup_INR=;
@@ -21,3 +22,4 @@ Action=PduDef; Name=isup_pdu; Proto=isup; Transport=mtp3; mtp3pc=mtp3.dpc; mtp3p
Action=GopDef; Name=isup_leg; On=isup_pdu; ShowPduTree=TRUE; mtp3pc; mtp3pc; cic;
Action=GopStart; For=isup_leg; isup_msg=1;
Action=GopStop; For=isup_leg; isup_msg=16;
+
diff --git a/plugins/mate/packet-mate.c b/plugins/mate/packet-mate.c
index ce070730c6..28dbbdeeb4 100644
--- a/plugins/mate/packet-mate.c
+++ b/plugins/mate/packet-mate.c
@@ -67,6 +67,8 @@ void mate_gop_tree(proto_tree* pdu_tree, tvbuff_t *tvb, mate_gop* gop);
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_time_item;
+ proto_tree *gog_time_tree;
proto_item *gog_gop_item;
proto_tree *gog_gop_tree;
mate_gop* gog_gops;
@@ -81,6 +83,14 @@ void mate_gog_tree(proto_tree* tree, tvbuff_t *tvb, mate_gog* gog, mate_gop* gop
attrs_tree(gog_tree,tvb,gog);
+ if (gog->cfg->show_times) {
+ gog_time_item = proto_tree_add_text(gog_tree,tvb,0,0,"%s Times",gog->cfg->name);
+ gog_time_tree = proto_item_add_subtree(gog_time_item, gog->cfg->ett_times);
+
+ proto_tree_add_float(gog_time_tree, gog->cfg->hfid_start_time, tvb, 0, 0, gog->start_time);
+ proto_tree_add_float(gog_time_tree, gog->cfg->hfid_last_time, tvb, 0, 0, gog->last_time - gog->start_time);
+ }
+
gog_gop_item = proto_tree_add_uint(gog_tree, gog->cfg->hfid_gog_num_of_gops,
tvb, 0, 0, gog->num_of_gops);
@@ -115,17 +125,17 @@ void mate_gop_tree(proto_tree* tree, tvbuff_t *tvb, mate_gop* gop) {
attrs_tree(gop_tree,tvb,gop);
- if (gop->cfg->show_gop_times) {
+ if (gop->cfg->show_times) {
gop_time_item = proto_tree_add_text(gop_tree,tvb,0,0,"%s Times",gop->cfg->name);
gop_time_tree = proto_item_add_subtree(gop_time_item, gop->cfg->ett_times);
- proto_tree_add_float(gop_time_tree, gop->cfg->hfid_gop_start_time, tvb, 0, 0, gop->start_time);
+ proto_tree_add_float(gop_time_tree, gop->cfg->hfid_start_time, tvb, 0, 0, gop->start_time);
if (gop->released) {
- 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);
+ proto_tree_add_float(gop_time_tree, gop->cfg->hfid_stop_time, tvb, 0, 0, gop->release_time - gop->start_time);
+ proto_tree_add_float(gop_time_tree, gop->cfg->hfid_last_time, tvb, 0, 0, gop->last_time - gop->start_time);
} else {
- proto_tree_add_float(gop_time_tree, gop->cfg->hfid_gop_last_time, tvb, 0, 0, gop->last_time - gop->start_time);
+ proto_tree_add_float(gop_time_tree, gop->cfg->hfid_last_time, tvb, 0, 0, gop->last_time - gop->start_time);
}
}
@@ -212,7 +222,7 @@ extern void mate_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
mate_pdu* pdus;
proto_tree *mate_t;
- if ( ! (tree && mc) ) return;
+ if ( ! mc || ! tree ) return;
analyze_frame(pinfo,tree);