regen pidl all: rm epan/dissectors/pidl/*-stamp; pushd epan/dissectors/pidl/ && make...
[wireshark-sm.git] / plugins / epan / mate / mate_setup.c
blob03ad154378bde15eae0c169cfd47caf635d3b15c
1 /* mate_setup.c
2 * MATE -- Meta Analysis Tracing Engine
4 * Copyright 2004, Luis E. Garcia Ontanon <luis@ontanon.org>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include "config.h"
15 #include "mate.h"
17 /* appends the formatted string to the current error log */
18 static void report_error(mate_config* mc, const char* fmt, ...) {
19 static char error_buffer[DEBUG_BUFFER_SIZE];
21 va_list list;
23 va_start( list, fmt );
24 vsnprintf(error_buffer,DEBUG_BUFFER_SIZE,fmt,list);
25 va_end( list );
27 g_string_append(mc->config_error,error_buffer);
28 g_string_append_c(mc->config_error,'\n');
32 /* creates a blank pdu config
33 is going to be called only by the grammar
34 which will set all those elements that aren't set here */
35 extern mate_cfg_pdu* new_pducfg(mate_config* mc, char* name) {
36 mate_cfg_pdu* cfg = g_new(mate_cfg_pdu, 1);
38 cfg->name = g_strdup(name);
39 cfg->last_id = 0;
41 cfg->items = g_hash_table_new(g_direct_hash,g_direct_equal);
42 cfg->transforms = NULL;
44 cfg->hfid = -1;
46 cfg->hfid_pdu_rel_time = -1;
47 cfg->hfid_pdu_time_in_gop = -1;
49 cfg->my_hfids = g_hash_table_new(g_str_hash,g_str_equal);
51 cfg->ett = -1;
52 cfg->ett_attr = -1;
54 cfg->criterium = NULL;
55 cfg->criterium_match_mode = AVPL_NO_MATCH;
56 cfg->criterium_accept_mode = ACCEPT_MODE;
58 g_ptr_array_add(mc->pducfglist,(void *) cfg);
59 g_hash_table_insert(mc->pducfgs,(void *) cfg->name,(void *) cfg);
61 cfg->hfids_attr = g_hash_table_new(g_int_hash,g_int_equal);
63 return cfg;
66 extern mate_cfg_gop* new_gopcfg(mate_config* mc, char* name) {
67 mate_cfg_gop* cfg = g_new(mate_cfg_gop, 1);
69 cfg->name = g_strdup(name);
70 cfg->last_id = 0;
72 cfg->items = g_hash_table_new(g_direct_hash,g_direct_equal);
73 cfg->transforms = NULL;
75 cfg->extra = new_avpl("extra");
77 cfg->hfid = -1;
79 cfg->ett = -1;
80 cfg->ett_attr = -1;
81 cfg->ett_times = -1;
82 cfg->ett_children = -1;
84 cfg->hfid_start_time = -1;
85 cfg->hfid_stop_time = -1;
86 cfg->hfid_last_time = -1;
88 cfg->hfid_gop_pdu = -1;
89 cfg->hfid_gop_num_pdus = -1;
91 cfg->my_hfids = g_hash_table_new(g_str_hash,g_str_equal);
93 cfg->gop_index = g_hash_table_new(g_str_hash,g_str_equal);
94 cfg->gog_index = g_hash_table_new(g_str_hash,g_str_equal);
96 g_hash_table_insert(mc->gopcfgs,(void *) cfg->name, (void *) cfg);
98 return cfg;
101 extern mate_cfg_gog* new_gogcfg(mate_config* mc, char* name) {
102 mate_cfg_gog* cfg = g_new(mate_cfg_gog, 1);
104 cfg->name = g_strdup(name);
105 cfg->last_id = 0;
107 cfg->items = g_hash_table_new(g_direct_hash,g_direct_equal);
108 cfg->transforms = NULL;
110 cfg->extra = new_avpl("extra");
112 cfg->my_hfids = g_hash_table_new(g_str_hash,g_str_equal);
113 cfg->hfid = -1;
115 cfg->ett = -1;
116 cfg->ett_attr = -1;
117 cfg->ett_times = -1;
118 cfg->ett_children = -1;
119 cfg->ett_gog_gop = -1;
121 cfg->hfid_gog_num_of_gops = -1;
122 cfg->hfid_gog_gop = -1;
123 cfg->hfid_gog_gopstart = -1;
124 cfg->hfid_gog_gopstop = -1;
126 cfg->hfid_start_time = -1;
127 cfg->hfid_stop_time = -1;
128 cfg->hfid_last_time = -1;
130 g_hash_table_insert(mc->gogcfgs,(void *) cfg->name, (void *) cfg);
132 return cfg;
135 extern bool add_hfid(mate_config* mc, header_field_info* hfi, char* how, GHashTable* where) {
136 header_field_info* first_hfi = NULL;
137 bool exists = false;
138 char* as;
139 char* h;
140 int* ip;
142 while(hfi) {
143 first_hfi = hfi;
144 hfi = (hfi->same_name_prev_id != -1) ? proto_registrar_get_nth(hfi->same_name_prev_id) : NULL;
147 hfi = first_hfi;
149 while (hfi) {
150 exists = true;
151 ip = g_new(int, 1);
153 *ip = hfi->id;
155 if (( as = (char *)g_hash_table_lookup(where,ip) )) {
156 g_free(ip);
157 if (! g_str_equal(as,how)) {
158 report_error(mc,
159 "MATE Error: add field to Pdu: attempt to add %s(%i) as %s"
160 " failed: field already added as '%s'",hfi->abbrev,hfi->id,how,as);
161 return false;
163 } else {
164 h = g_strdup(how);
165 g_hash_table_insert(where,ip,h);
168 hfi = hfi->same_name_next;
172 if (! exists) {
173 report_error(mc, "MATE Error: cannot find field for attribute %s",how);
175 return exists;
178 #if 0
180 * XXX - where is this supposed to be used?
182 extern char* add_ranges(mate_config* mc, char* range,GPtrArray* range_ptr_arr) {
183 char** ranges;
184 unsigned i;
185 header_field_info* hfi;
186 int* hfidp;
188 ranges = g_strsplit(range,"/",0);
190 if (ranges) {
191 for (i=0; ranges[i]; i++) {
192 hfi = proto_registrar_get_byname(ranges[i]);
193 if (hfi) {
194 hfidp = g_new(int, 1);
195 *hfidp = hfi->id;
196 g_ptr_array_add(range_ptr_arr,(void *)hfidp);
197 } else {
198 g_strfreev(ranges);
199 return ws_strdup_printf("no such proto: '%s'",ranges[i]);
203 g_strfreev(ranges);
206 return NULL;
208 #endif
210 static void new_attr_hfri(mate_config* mc, char* item_name, GHashTable* hfids, char* name) {
211 int* p_id = g_new(int, 1);
212 hf_register_info hfri;
214 memset(&hfri, 0, sizeof hfri);
215 *p_id = -1;
216 hfri.p_id = p_id;
217 hfri.hfinfo.name = g_strdup(name);
218 hfri.hfinfo.abbrev = ws_strdup_printf("mate.%s.%s",item_name,name);
219 hfri.hfinfo.type = FT_STRING;
220 hfri.hfinfo.display = BASE_NONE;
221 hfri.hfinfo.strings = NULL;
222 hfri.hfinfo.bitmask = 0;
223 hfri.hfinfo.blurb = ws_strdup_printf("%s attribute of %s",name,item_name);
225 *p_id = -1;
226 g_hash_table_insert(hfids,name,p_id);
227 g_array_append_val(mc->hfrs,hfri);
231 typedef struct {
232 mate_config* mc;
233 mate_cfg_pdu* cfg;
234 } analyze_pdu_hfids_arg;
236 static void analyze_pdu_hfids(void *k, void *v, void *p) {
237 analyze_pdu_hfids_arg* argp = (analyze_pdu_hfids_arg*)p;
238 mate_config* mc = argp->mc;
239 mate_cfg_pdu* cfg = argp->cfg;
240 new_attr_hfri(mc, cfg->name,cfg->my_hfids,(char*) v);
243 * Add this hfid to our table of wanted hfids.
245 mc->wanted_hfids = g_array_append_val(mc->wanted_hfids, *(int *)k);
246 mc->num_fields_wanted++;
249 static void analyze_transform_hfrs(mate_config* mc, char* name, GPtrArray* transforms, GHashTable* hfids) {
250 unsigned i;
251 void* cookie = NULL;
252 AVPL_Transf* t;
253 AVP* avp;
255 for (i=0; i < transforms->len;i++) {
256 for (t = (AVPL_Transf *)g_ptr_array_index(transforms,i); t; t=t->next ) {
257 cookie = NULL;
258 while(( avp = get_next_avp(t->replace,&cookie) )) {
259 if (! g_hash_table_lookup(hfids,avp->n)) {
260 new_attr_hfri(mc, name,hfids,avp->n);
267 static void analyze_pdu_config(mate_config* mc, mate_cfg_pdu* cfg) {
268 hf_register_info hfri = { NULL, {NULL, NULL, FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL}};
269 int* ett;
270 analyze_pdu_hfids_arg arg;
272 hfri.p_id = &(cfg->hfid);
273 hfri.hfinfo.name = g_strdup(cfg->name);
274 hfri.hfinfo.abbrev = ws_strdup_printf("mate.%s",cfg->name);
275 hfri.hfinfo.blurb = ws_strdup_printf("%s id",cfg->name);
276 hfri.hfinfo.type = FT_UINT32;
277 hfri.hfinfo.display = BASE_DEC;
279 g_array_append_val(mc->hfrs,hfri);
281 hfri.p_id = &(cfg->hfid_pdu_rel_time);
282 hfri.hfinfo.name = ws_strdup_printf("%s time",cfg->name);
283 hfri.hfinfo.abbrev = ws_strdup_printf("mate.%s.RelativeTime",cfg->name);
284 hfri.hfinfo.type = FT_DOUBLE;
285 hfri.hfinfo.display = BASE_NONE;
286 hfri.hfinfo.blurb = "Seconds passed since the start of capture";
288 g_array_append_val(mc->hfrs,hfri);
290 hfri.p_id = &(cfg->hfid_pdu_time_in_gop);
291 hfri.hfinfo.name = ws_strdup_printf("%s time since beginning of Gop",cfg->name);
292 hfri.hfinfo.abbrev = ws_strdup_printf("mate.%s.TimeInGop",cfg->name);
293 hfri.hfinfo.type = FT_DOUBLE;
294 hfri.hfinfo.display = BASE_NONE;
295 hfri.hfinfo.blurb = "Seconds passed since the start of the GOP";
297 g_array_append_val(mc->hfrs,hfri);
299 arg.mc = mc;
300 arg.cfg = cfg;
301 g_hash_table_foreach(cfg->hfids_attr,analyze_pdu_hfids,&arg);
303 /* Add the hfids of transport protocols as wanted hfids */
304 for (unsigned i = 0; i < cfg->transport_ranges->len; i++) {
305 int hfid = *((int*)g_ptr_array_index(cfg->transport_ranges,i));
306 mc->wanted_hfids = g_array_append_val(mc->wanted_hfids, hfid);
307 mc->num_fields_wanted++;
310 ett = &cfg->ett;
311 g_array_append_val(mc->ett,ett);
313 ett = &cfg->ett_attr;
314 g_array_append_val(mc->ett,ett);
316 analyze_transform_hfrs(mc, cfg->name,cfg->transforms,cfg->my_hfids);
319 static void analyze_gop_config(void *k _U_, void *v, void *p) {
320 mate_config* mc = (mate_config*)p;
321 mate_cfg_gop* cfg = (mate_cfg_gop *)v;
322 void* cookie = NULL;
323 AVP* avp;
324 int* ett;
325 hf_register_info hfri = { NULL, {NULL, NULL, FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL}};
327 hfri.p_id = &(cfg->hfid);
328 hfri.hfinfo.name = g_strdup(cfg->name);
329 hfri.hfinfo.abbrev = ws_strdup_printf("mate.%s",cfg->name);
330 hfri.hfinfo.blurb = ws_strdup_printf("%s id",cfg->name);
331 hfri.hfinfo.type = FT_UINT32;
332 hfri.hfinfo.display = BASE_DEC;
334 g_array_append_val(mc->hfrs,hfri);
336 hfri.p_id = &(cfg->hfid_start_time);
337 hfri.hfinfo.name = ws_strdup_printf("%s start time",cfg->name);
338 hfri.hfinfo.abbrev = ws_strdup_printf("mate.%s.StartTime",cfg->name);
339 hfri.hfinfo.type = FT_DOUBLE;
340 hfri.hfinfo.display = BASE_NONE;
341 hfri.hfinfo.blurb = ws_strdup_printf("Seconds passed since the beginning of capture to the start of this %s",cfg->name);
343 g_array_append_val(mc->hfrs,hfri);
345 hfri.p_id = &(cfg->hfid_stop_time);
346 hfri.hfinfo.name = ws_strdup_printf("%s hold time",cfg->name);
347 hfri.hfinfo.abbrev = ws_strdup_printf("mate.%s.Time",cfg->name);
348 hfri.hfinfo.blurb = ws_strdup_printf("Duration in seconds from start to stop of this %s",cfg->name);
350 g_array_append_val(mc->hfrs,hfri);
352 hfri.p_id = &(cfg->hfid_last_time);
353 hfri.hfinfo.name = ws_strdup_printf("%s duration",cfg->name);
354 hfri.hfinfo.abbrev = ws_strdup_printf("mate.%s.Duration",cfg->name);
355 hfri.hfinfo.blurb = ws_strdup_printf("Time passed between the start of this %s and the last pdu assigned to it",cfg->name);
357 g_array_append_val(mc->hfrs,hfri);
359 hfri.p_id = &(cfg->hfid_gop_num_pdus);
360 hfri.hfinfo.name = ws_strdup_printf("%s number of PDUs",cfg->name);
361 hfri.hfinfo.abbrev = ws_strdup_printf("mate.%s.NumOfPdus",cfg->name);
362 hfri.hfinfo.blurb = ws_strdup_printf("Number of PDUs assigned to this %s",cfg->name);
363 hfri.hfinfo.type = FT_UINT32;
364 hfri.hfinfo.display = BASE_DEC;
366 g_array_append_val(mc->hfrs,hfri);
368 hfri.p_id = &(cfg->hfid_gop_pdu);
369 hfri.hfinfo.name = ws_strdup_printf("A PDU of %s",cfg->name);
370 hfri.hfinfo.abbrev = ws_strdup_printf("mate.%s.Pdu",cfg->name);
371 hfri.hfinfo.blurb = ws_strdup_printf("A PDU assigned to this %s",cfg->name);
373 if (cfg->pdu_tree_mode == GOP_FRAME_TREE) {
374 hfri.hfinfo.type = FT_FRAMENUM;
375 hfri.hfinfo.display = BASE_NONE;
376 g_array_append_val(mc->hfrs,hfri);
377 } else if (cfg->pdu_tree_mode == GOP_PDU_TREE) {
378 hfri.hfinfo.type = FT_UINT32;
379 g_array_append_val(mc->hfrs,hfri);
380 } else {
381 cfg->pdu_tree_mode = GOP_NO_TREE;
384 while(( avp = get_next_avp(cfg->key,&cookie) )) {
385 if (! g_hash_table_lookup(cfg->my_hfids,avp->n)) {
386 new_attr_hfri(mc, cfg->name,cfg->my_hfids,avp->n);
390 if(cfg->start) {
391 cookie = NULL;
392 while(( avp = get_next_avp(cfg->start,&cookie) )) {
393 if (! g_hash_table_lookup(cfg->my_hfids,avp->n)) {
394 new_attr_hfri(mc, cfg->name,cfg->my_hfids,avp->n);
399 if (cfg->stop) {
400 cookie = NULL;
401 while(( avp = get_next_avp(cfg->stop,&cookie) )) {
402 if (! g_hash_table_lookup(cfg->my_hfids,avp->n)) {
403 new_attr_hfri(mc, cfg->name,cfg->my_hfids,avp->n);
408 cookie = NULL;
409 while(( avp = get_next_avp(cfg->extra,&cookie) )) {
410 if (! g_hash_table_lookup(cfg->my_hfids,avp->n)) {
411 new_attr_hfri(mc, cfg->name,cfg->my_hfids,avp->n);
415 analyze_transform_hfrs(mc, cfg->name,cfg->transforms,cfg->my_hfids);
417 ett = &cfg->ett;
418 g_array_append_val(mc->ett,ett);
420 ett = &cfg->ett_attr;
421 g_array_append_val(mc->ett,ett);
423 ett = &cfg->ett_times;
424 g_array_append_val(mc->ett,ett);
426 ett = &cfg->ett_children;
427 g_array_append_val(mc->ett,ett);
429 g_hash_table_insert(mc->gops_by_pduname,cfg->name,cfg);
432 static void analyze_gog_config(void *k _U_, void *v, void *p) {
433 mate_config* mc = (mate_config*)p;
434 mate_cfg_gog* cfg = (mate_cfg_gog *)v;
435 void* avp_cookie;
436 void* avpl_cookie;
437 AVP* avp;
438 AVPL* avpl;
439 AVPL* gopkey_avpl;
440 AVPL* key_avps;
441 LoAL* gog_keys = NULL;
442 hf_register_info hfri = { NULL, {NULL, NULL, FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL}};
443 int* ett;
445 /* create the hf array for this gog */
446 hfri.p_id = &(cfg->hfid);
447 hfri.hfinfo.name = g_strdup(cfg->name);
448 hfri.hfinfo.abbrev = ws_strdup_printf("mate.%s",cfg->name);
449 hfri.hfinfo.blurb = ws_strdup_printf("%s Id",cfg->name);
450 hfri.hfinfo.type = FT_UINT32;
451 hfri.hfinfo.display = BASE_DEC;
453 g_array_append_val(mc->hfrs,hfri);
455 hfri.p_id = &(cfg->hfid_gog_num_of_gops);
456 hfri.hfinfo.name = "number of GOPs";
457 hfri.hfinfo.abbrev = ws_strdup_printf("mate.%s.NumOfGops",cfg->name);
458 hfri.hfinfo.type = FT_UINT32;
459 hfri.hfinfo.display = BASE_DEC;
460 hfri.hfinfo.blurb = ws_strdup_printf("Number of GOPs assigned to this %s",cfg->name);
462 g_array_append_val(mc->hfrs,hfri);
464 hfri.p_id = &(cfg->hfid_gog_gopstart);
465 hfri.hfinfo.name = "GopStart frame";
466 hfri.hfinfo.abbrev = ws_strdup_printf("mate.%s.GopStart",cfg->name);
467 hfri.hfinfo.type = FT_FRAMENUM;
468 hfri.hfinfo.display = BASE_NONE;
469 hfri.hfinfo.blurb = g_strdup("The start frame of a GOP");
471 g_array_append_val(mc->hfrs,hfri);
473 hfri.p_id = &(cfg->hfid_gog_gopstop);
474 hfri.hfinfo.name = "GopStop frame";
475 hfri.hfinfo.abbrev = ws_strdup_printf("mate.%s.GopStop",cfg->name);
476 hfri.hfinfo.type = FT_FRAMENUM;
477 hfri.hfinfo.display = BASE_NONE;
478 hfri.hfinfo.blurb = g_strdup("The stop frame of a GOP");
480 g_array_append_val(mc->hfrs,hfri);
482 hfri.p_id = &(cfg->hfid_start_time);
483 hfri.hfinfo.name = ws_strdup_printf("%s start time",cfg->name);
484 hfri.hfinfo.abbrev = ws_strdup_printf("mate.%s.StartTime",cfg->name);
485 hfri.hfinfo.type = FT_DOUBLE;
486 hfri.hfinfo.blurb = ws_strdup_printf("Seconds passed since the beginning of capture to the start of this %s",cfg->name);
488 g_array_append_val(mc->hfrs,hfri);
490 hfri.p_id = &(cfg->hfid_last_time);
491 hfri.hfinfo.name = ws_strdup_printf("%s duration",cfg->name);
492 hfri.hfinfo.abbrev = ws_strdup_printf("mate.%s.Duration",cfg->name);
493 hfri.hfinfo.blurb = ws_strdup_printf("Time passed between the start of this %s and the last pdu assigned to it",cfg->name);
495 g_array_append_val(mc->hfrs,hfri);
497 /* this might become mate.gogname.gopname */
498 hfri.p_id = &(cfg->hfid_gog_gop);
499 hfri.hfinfo.name = "a GOP";
500 hfri.hfinfo.abbrev = ws_strdup_printf("mate.%s.Gop",cfg->name);
501 hfri.hfinfo.type = FT_STRING;
502 hfri.hfinfo.display = BASE_NONE;
503 hfri.hfinfo.blurb = ws_strdup_printf("a GOPs assigned to this %s",cfg->name);
505 g_array_append_val(mc->hfrs,hfri);
507 /* index the keys of gog for every gop
508 and insert the avps of the keys to the hfarray */
509 key_avps = new_avpl("");
511 avpl_cookie = NULL;
512 while (( avpl = get_next_avpl(cfg->keys,&avpl_cookie) )) {
514 if (! ( gog_keys = (LoAL *)g_hash_table_lookup(mc->gogs_by_gopname,avpl->name))) {
515 gog_keys = new_loal(avpl->name);
516 g_hash_table_insert(mc->gogs_by_gopname,gog_keys->name,gog_keys);
519 gopkey_avpl = new_avpl_from_avpl(cfg->name, avpl, true);
520 loal_append(gog_keys,gopkey_avpl);
522 avp_cookie = NULL;
523 while (( avp = get_next_avp(avpl,&avp_cookie) )) {
524 if (! g_hash_table_lookup(cfg->my_hfids,avp->n)) {
525 new_attr_hfri(mc, cfg->name,cfg->my_hfids,avp->n);
526 insert_avp(key_avps,avp);
531 /* insert the extra avps to the hfarray */
532 avp_cookie = NULL;
533 while (( avp = get_next_avp(cfg->extra,&avp_cookie) )) {
534 if (! g_hash_table_lookup(cfg->my_hfids,avp->n)) {
535 new_attr_hfri(mc, cfg->name,cfg->my_hfids,avp->n);
539 /* every key_avp ios an extra as well.
540 one day every Member will have its own extras */
541 merge_avpl(cfg->extra,key_avps,true);
544 analyze_transform_hfrs(mc, cfg->name,cfg->transforms,cfg->my_hfids);
546 ett = &cfg->ett;
547 g_array_append_val(mc->ett,ett);
549 ett = &cfg->ett_attr;
550 g_array_append_val(mc->ett,ett);
552 ett = &cfg->ett_children;
553 g_array_append_val(mc->ett,ett);
555 ett = &cfg->ett_times;
556 g_array_append_val(mc->ett,ett);
558 ett = &cfg->ett_gog_gop;
559 g_array_append_val(mc->ett,ett);
563 static void analyze_config(mate_config* mc) {
564 unsigned i;
566 for (i=0; i < mc->pducfglist->len; i++) {
567 analyze_pdu_config(mc, (mate_cfg_pdu*) g_ptr_array_index(mc->pducfglist,i));
570 g_hash_table_foreach(mc->gopcfgs,analyze_gop_config,mc);
571 g_hash_table_foreach(mc->gogcfgs,analyze_gog_config,mc);
575 extern mate_config* mate_make_config(const char* filename, int mate_hfid) {
576 mate_config* mc;
577 int* ett;
578 avp_init();
580 mc = g_new(mate_config, 1);
582 mc->hfid_mate = mate_hfid;
584 mc->wanted_hfids = g_array_new(false, false, (unsigned)sizeof(int));
585 mc->num_fields_wanted = 0;
587 mc->dbg_facility = NULL;
589 mc->mate_lib_path = ws_strdup_printf("%s%c%s%c",get_datafile_dir(),DIR_SEP,DEFAULT_MATE_LIB_PATH,DIR_SEP);
591 mc->pducfgs = g_hash_table_new(g_str_hash,g_str_equal);
592 mc->gopcfgs = g_hash_table_new(g_str_hash,g_str_equal);
593 mc->gogcfgs = g_hash_table_new(g_str_hash,g_str_equal);
594 mc->transfs = g_hash_table_new(g_str_hash,g_str_equal);
596 mc->pducfglist = g_ptr_array_new();
597 mc->gops_by_pduname = g_hash_table_new(g_str_hash,g_str_equal);
598 mc->gogs_by_gopname = g_hash_table_new(g_str_hash,g_str_equal);
600 mc->ett_root = -1;
602 mc->hfrs = g_array_new(false,false,sizeof(hf_register_info));
603 mc->ett = g_array_new(false,false,sizeof(int*));
605 mc->defaults.pdu.drop_unassigned = false;
606 mc->defaults.pdu.discard = false;
607 mc->defaults.pdu.last_extracted = false;
608 mc->defaults.pdu.match_mode = AVPL_STRICT;
609 mc->defaults.pdu.replace_mode = AVPL_INSERT;
611 /* gop prefs */
612 mc->defaults.gop.expiration = -1.0f;
613 mc->defaults.gop.idle_timeout = -1.0f;
614 mc->defaults.gop.lifetime = -1.0f;
615 mc->defaults.gop.pdu_tree_mode = GOP_FRAME_TREE;
616 mc->defaults.gop.show_times = true;
617 mc->defaults.gop.drop_unassigned = false;
619 /* gog prefs */
620 mc->defaults.gog.expiration = 5.0f;
621 mc->defaults.gog.show_times = true;
622 mc->defaults.gog.gop_tree_mode = GOP_BASIC_TREE;
624 /* what to dbgprint */
625 mc->dbg_lvl = 0;
626 mc->dbg_pdu_lvl = 0;
627 mc->dbg_gop_lvl = 0;
628 mc->dbg_gog_lvl = 0;
630 mc->config_error = g_string_new("");
632 ett = &mc->ett_root;
633 g_array_append_val(mc->ett,ett);
635 if ( mate_load_config(filename,mc) ) {
636 analyze_config(mc);
637 } else {
638 report_failure("MATE failed to configure!\n"
639 "It is recommended that you fix your config and restart Wireshark.\n"
640 "The reported error is:\n%s\n",mc->config_error->str);
642 /* if (mc) destroy_mate_config(mc,false); */
643 return NULL;
646 if (mc->num_fields_wanted == 0) {
647 /* We have no interest in any fields, so we have no
648 work to do. */
649 /*destroy_mate_config(mc,false);*/
650 return NULL;
653 return mc;
657 * Editor modelines - https://www.wireshark.org/tools/modelines.html
659 * Local variables:
660 * c-basic-offset: 8
661 * tab-width: 8
662 * indent-tabs-mode: t
663 * End:
665 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
666 * :indentSize=8:tabSize=8:noTabs=false: