diff options
author | Guy Harris <guy@alum.mit.edu> | 2017-04-16 19:37:00 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2017-04-17 02:37:31 +0000 |
commit | b9c6e2d3915bc41b04420fb1fa99b1b7d12b0a21 (patch) | |
tree | 05e10cecc28cd9d97a1a907ab924610208bb8b20 /plugins/mate | |
parent | acf349ea486799be4c28bc98fb674c145fbb66c6 (diff) |
Remove unnecessary tap.
The tap was just a trick to get fields and protocols registered as being
of interest. Now that we have mechanisms by which postdissectors can
explicitly register fields and protocols as being of interest, and are
using that, the trick is no longer needed.
Change-Id: Ib2620ff32c41ffa050203c1d4481c63535fb3f4b
Reviewed-on: https://code.wireshark.org/review/21156
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'plugins/mate')
-rw-r--r-- | plugins/mate/mate.h | 8 | ||||
-rw-r--r-- | plugins/mate/mate_grammar.lemon | 6 | ||||
-rw-r--r-- | plugins/mate/mate_setup.c | 26 | ||||
-rw-r--r-- | plugins/mate/packet-mate.c | 24 |
4 files changed, 7 insertions, 57 deletions
diff --git a/plugins/mate/mate.h b/plugins/mate/mate.h index 8278a6ca38..c9f7efdc76 100644 --- a/plugins/mate/mate.h +++ b/plugins/mate/mate.h @@ -47,7 +47,6 @@ #include <epan/prefs.h> #include <epan/proto.h> #include <epan/epan_dissect.h> -#include <epan/tap.h> #include <wsutil/filesystem.h> #include "mate_util.h" @@ -197,11 +196,8 @@ typedef struct _mate_config { int hfid_mate; - GArray *wanted_hfids; /* hfids of protocols and fields MATE needs */ - - GString* fields_filter; /* "ip.addr || dns.id || ... " for the tap */ - GString* protos_filter; /* "dns || ftp || ..." for the tap */ - gchar* tap_filter; + GArray *wanted_hfids; /* hfids of protocols and fields MATE needs */ + guint num_fields_wanted; /* number of fields MATE will look at */ FILE* dbg_facility; /* where to dump dbgprint output g_message if null */ diff --git a/plugins/mate/mate_grammar.lemon b/plugins/mate/mate_grammar.lemon index 1235a2dd3d..f40243789f 100644 --- a/plugins/mate/mate_grammar.lemon +++ b/plugins/mate/mate_grammar.lemon @@ -440,8 +440,6 @@ pdu_decl ::= */ mc->wanted_hfids = g_array_append_val(mc->wanted_hfids, Field->id); - g_string_append_printf(mc->protos_filter,"||%s",Field->abbrev); - /* flip the transport_stack */ for (i = Stack->len - 1; Stack->len; i--) { g_ptr_array_add(transport_stack,g_ptr_array_remove_index(Stack,i)); @@ -509,8 +507,6 @@ last_extracted_statement(A) ::= . { A = mc->defaults.pdu.last_extracted; } proto_stack(A) ::= proto_stack(B) SLASH field(C). { int* hfidp = (int *)g_malloc(sizeof(int)); - g_string_append_printf(mc->fields_filter,"||%s",C->abbrev); - *hfidp = C->id; g_ptr_array_add(B,hfidp); A = B; @@ -520,8 +516,6 @@ proto_stack(A) ::= field(B). { int* hfidp = (int *)g_malloc(sizeof(int)); *hfidp = B->id; - g_string_append_printf(mc->fields_filter,"||%s",B->abbrev); - A = g_ptr_array_new(); g_ptr_array_add(A,hfidp); } diff --git a/plugins/mate/mate_setup.c b/plugins/mate/mate_setup.c index c52001ddd0..f58309ad68 100644 --- a/plugins/mate/mate_setup.c +++ b/plugins/mate/mate_setup.c @@ -204,7 +204,6 @@ extern gchar* add_ranges(mate_config* mc, gchar* range,GPtrArray* range_ptr_arr) hfidp = (int *)g_malloc(sizeof(int)); *hfidp = hfi->id; g_ptr_array_add(range_ptr_arr,(gpointer)hfidp); - g_string_append_printf(mc->fields_filter, "||%s",ranges[i]); } else { g_strfreev(ranges); return g_strdup_printf("no such proto: '%s'",ranges[i]); @@ -239,14 +238,6 @@ static void new_attr_hfri(mate_config* mc, gchar* item_name, GHashTable* hfids, } -static const gchar* my_protoname(int proto_id) { - if (proto_id) { - return proto_registrar_get_abbrev(proto_id); - } else { - return "*"; - } -} - typedef struct { mate_config* mc; mate_cfg_pdu* cfg; @@ -262,8 +253,7 @@ static void analyze_pdu_hfids(gpointer k, gpointer v, gpointer p) { * Add this hfid to our table of wanted hfids. */ mc->wanted_hfids = g_array_append_val(mc->wanted_hfids, *(int *)k); - - g_string_append_printf(mc->fields_filter,"||%s",my_protoname(*(int*)k)); + mc->num_fields_wanted++; } static void analyze_transform_hfrs(mate_config* mc, gchar* name, GPtrArray* transforms, GHashTable* hfids) { @@ -595,9 +585,7 @@ extern mate_config* mate_make_config(const gchar* filename, int mate_hfid) { mc->hfid_mate = mate_hfid; mc->wanted_hfids = g_array_new(FALSE, FALSE, (guint)sizeof(int)); - - mc->fields_filter = g_string_new(""); - mc->protos_filter = g_string_new(""); + mc->num_fields_wanted = 0; mc->dbg_facility = NULL; @@ -658,17 +646,13 @@ extern mate_config* mate_make_config(const gchar* filename, int mate_hfid) { return NULL; } - if (mc->fields_filter->len > 1) { - g_string_erase(mc->fields_filter,0,2); - g_string_erase(mc->protos_filter,0,2); - } else { + if (mc->num_fields_wanted == 0) { + /* We have no interest in any fields, so we have no + work to do. */ /*destroy_mate_config(mc,FALSE);*/ - mc = NULL; return NULL; } - mc->tap_filter = g_strdup_printf("(%s) && (%s)",mc->protos_filter->str,mc->fields_filter->str); - return mc; } diff --git a/plugins/mate/packet-mate.c b/plugins/mate/packet-mate.c index cf30903eee..b23035a14d 100644 --- a/plugins/mate/packet-mate.c +++ b/plugins/mate/packet-mate.c @@ -35,7 +35,6 @@ void proto_register_mate(void); void proto_reg_handoff_mate(void); -static int mate_tap_data = 0; static mate_config* mc = NULL; static int proto_mate = -1; @@ -323,13 +322,6 @@ mate_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) return tvb_captured_length(tvb); } -static int -mate_packet(void *prs _U_, packet_info* tree _U_, epan_dissect_t *edt _U_, const void *dummy _U_) -{ - /* nothing to do yet */ - return 0; -} - static void initialize_mate(void) { @@ -340,8 +332,6 @@ extern void proto_reg_handoff_mate(void) { - GString* tap_error = NULL; - if ( *pref_mate_config_filename != '\0' ) { if (current_mate_config_filename) { @@ -365,20 +355,6 @@ proto_reg_handoff_mate(void) set_postdissector_wanted_hfids(mate_handle, mc->wanted_hfids); - tap_error = register_tap_listener("frame", &mate_tap_data, - (char*) mc->tap_filter, - 0, - (tap_reset_cb) NULL, - mate_packet, - (tap_draw_cb) NULL); - - if ( tap_error ) { - ws_g_warning("mate: couldn't (re)register tap: %s",tap_error->str); - g_string_free(tap_error, TRUE); - mate_tap_data = 0; - return; - } - initialize_mate_runtime(mc); } |