diff options
author | Guy Harris <guy@alum.mit.edu> | 2017-04-11 19:53:48 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2017-04-12 04:31:19 +0000 |
commit | c0792555392f234ab96917e784d365b5de053836 (patch) | |
tree | 02c053696f2fbd0a6b05ae239b5460d1c551a64f /plugins/transum/packet-transum.c | |
parent | aa9a0b3bf831395dc1cfbaea7f467faed952dbf9 (diff) | |
download | wireshark-c0792555392f234ab96917e784d365b5de053836.tar.gz |
Add an API to let a postdissector specify fields whose values it needs.
Currently, this is only used to determine whether a protocol tree needs
to be built on the first pass or not - if there are postdissectors that
need fields, it does - but eventually we should be able to use it to
prime the dissection to deliver those fields in cases where we don't
need the *entire* protocol tree (rather than using a hack such as
cooking up a fake tap with a fake filter to do that).
Update MATE and TRANSUM to use it.
Clean up code to check whether we need a protocol tree, and add comments
before that code indicating, in each case, what the criteria are.
The array of postdissectors includes a length, so we don't need to
separately keep track of the number of postdissectors.
Clean up indentation while we're at it.
Change-Id: I71d4025848206d144bc54cc82941089a50e80ab7
Reviewed-on: https://code.wireshark.org/review/21029
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'plugins/transum/packet-transum.c')
-rw-r--r-- | plugins/transum/packet-transum.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/plugins/transum/packet-transum.c b/plugins/transum/packet-transum.c index cb06684393..79f4507e92 100644 --- a/plugins/transum/packet-transum.c +++ b/plugins/transum/packet-transum.c @@ -41,6 +41,8 @@ void proto_register_transum(void); void proto_reg_handoff_transum(void); +static dissector_handle_t transum_handle; + #define CAPTURE_CLIENT 0 #define CAPTURE_INTERMEDIATE 1 #define CAPTURE_SERVICE 2 @@ -142,6 +144,10 @@ static wmem_map_t *output_rrpd; */ static wmem_list_t *temp_rsp_rrpd_list = NULL; /* Reuse these for speed and efficient memory use - issue a warning if we run out */ +/* + * GArray of the hfids of all fields we're interested in. + */ +GArray *wanted_fields; static gint ett_transum = -1; static gint ett_transum_header = -1; @@ -715,6 +721,14 @@ static void init_globals(void) rrpd_list = wmem_list_new(wmem_file_scope()); temp_rsp_rrpd_list = wmem_list_new(wmem_file_scope()); + /* Indicate what fields we're interested in. */ + wanted_fields = g_array_new(FALSE, FALSE, (guint)sizeof(int)); + for (int i = 0; i < HF_INTEREST_END_OF_LIST; i++) + { + g_array_append_val(wanted_fields, hf_of_interest[i].hf); + } + set_postdissector_wanted_fields(transum_handle, wanted_fields); + GString* fake_tap_filter = g_string_new("frame || eth.type"); for (int i = 0; i < HF_INTEREST_END_OF_LIST; i++) @@ -1001,8 +1015,13 @@ static int dissect_transum(tvbuff_t *buffer, packet_info *pinfo, proto_tree *tre RRPD *rrpd = (RRPD*)wmem_map_lookup(output_rrpd, GUINT_TO_POINTER(pinfo->num)); if (rrpd) - /* Add the RTE data to the protocol decode tree if we output_flag is set */ - write_rte(rrpd, buffer, tree, NULL); + { + if (tree) + { + /* Add the RTE data to the protocol decode tree if we output_flag is set */ + write_rte(rrpd, buffer, tree, NULL); + } + } } else { @@ -1030,7 +1049,6 @@ void proto_register_transum(void) { module_t *transum_module; - dissector_handle_t transum_handle; static hf_register_info hf[] = { { &hf_tsum_status, |