diff options
author | Guy Harris <guy@alum.mit.edu> | 2017-04-12 13:52:07 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2017-04-12 23:33:37 +0000 |
commit | 847c25c5a7e7c5653870c4bd60625da1c64c86f1 (patch) | |
tree | 386b51025493bda76c077334293d931eded5afdf /epan | |
parent | 74f9b279e9888b0449b569a1c474351ccc991d5e (diff) | |
download | wireshark-847c25c5a7e7c5653870c4bd60625da1c64c86f1.tar.gz |
Prime the epan_dissect_t with postdissector wanted fields if necessary.
This makes sure that postdissectors that indicate that they need certain
fields in the first pass will get them.
While we're at it:
Fix the field-fetching code in TRANSUM not to assume it got any
instances of the field being fetched.
Rename process_packet_first_pass() in sharkd to process_packet(), as
it's the only routine in sharkd that processes packets.
Rename process_packet() in tshark and tfshark to
process_packet_single_pass(), as it's what's used if we're only doing
one-pass analysis.
Clean up comments and whitespace.
Change-Id: I3769af952c66f5ca4b68002ad6213858ab9cab9b
Reviewed-on: https://code.wireshark.org/review/21063
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/epan.c | 11 | ||||
-rw-r--r-- | epan/epan.h | 5 | ||||
-rw-r--r-- | epan/packet.c | 19 | ||||
-rw-r--r-- | epan/packet.h | 10 |
4 files changed, 42 insertions, 3 deletions
diff --git a/epan/epan.c b/epan/epan.c index 726d2f558c..75ff54214b 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -541,6 +541,17 @@ epan_dissect_prime_with_hfid(epan_dissect_t *edt, int hfid) proto_tree_prime_with_hfid(edt->tree, hfid); } +void +epan_dissect_prime_with_hfid_array(epan_dissect_t *edt, GArray *hfids) +{ + guint i; + + for (i = 0; i < hfids->len; i++) { + proto_tree_prime_with_hfid(edt->tree, + g_array_index(hfids, int, i)); + } +} + /* ----------------------- */ const gchar * epan_custom_set(epan_dissect_t *edt, GSList *field_ids, diff --git a/epan/epan.h b/epan/epan.h index 65fca37988..91c7c1c24f 100644 --- a/epan/epan.h +++ b/epan/epan.h @@ -225,6 +225,11 @@ WS_DLL_PUBLIC void epan_dissect_prime_with_hfid(epan_dissect_t *edt, int hfid); +/** Prime an epan_dissect_t's proto_tree with a set of fields/protocols specified by their hfids in a GArray */ +WS_DLL_PUBLIC +void +epan_dissect_prime_with_hfid_array(epan_dissect_t *edt, GArray *hfids); + /** fill the dissect run output into the packet list columns */ WS_DLL_PUBLIC void diff --git a/epan/packet.c b/epan/packet.c index 4a3b5cbd64..bb43449d7f 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -3350,6 +3350,25 @@ postdissectors_want_fields(void) return FALSE; } +void +prime_epan_dissect_with_postdissector_wanted_fields(epan_dissect_t *edt) +{ + guint i; + + if (postdissectors == NULL) { + /* + * No postdissector expressed an interest in any fields. + */ + return; + } + for (i = 0; i < postdissectors->len; i++) { + if (POSTDISSECTORS(i).wanted_fields != NULL && + POSTDISSECTORS(i).wanted_fields->len != 0) + epan_dissect_prime_with_hfid_array(edt, + POSTDISSECTORS(i).wanted_fields); + } +} + /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * diff --git a/epan/packet.h b/epan/packet.h index 47eed6fe33..e0625ae226 100644 --- a/epan/packet.h +++ b/epan/packet.h @@ -25,6 +25,7 @@ #include "proto.h" #include "tvbuff.h" +#include "epan.h" #include "value_string.h" #include "frame_data.h" #include "packet_info.h" @@ -803,12 +804,15 @@ extern void call_all_postdissectors(tvbuff_t *tvb, packet_info *pinfo, proto_tre /* * Return TRUE if at least one postdissector wants fields, FALSE otherwise. - * XXX - at some point this should return a bag of all fields requested by - * all postdissectors, so we can prime the epan_dissect_t with them rather - * than constructing a bogus tap with a bogus filter. */ WS_DLL_PUBLIC gboolean postdissectors_want_fields(void); +/* + * Prime an epan_dissect_t with all the fields wanted by postdissectors. + */ +WS_DLL_PUBLIC void +prime_epan_dissect_with_postdissector_wanted_fields(epan_dissect_t *edt); + /** @} */ #ifdef __cplusplus |