From 77368c3668ee6d2a802eb9cf4d0a639f7ebf16e6 Mon Sep 17 00:00:00 2001 From: Jakub Zawadzki Date: Sat, 20 Oct 2012 19:27:24 +0000 Subject: Introduce epan_dissect_run_with_taps() which run dissection with taps. unexport tap_queue_init, tap_push_tapped_queue svn path=/trunk/; revision=45670 --- epan/epan.c | 12 ++++++++++++ epan/epan.h | 4 ++++ epan/libwireshark.def | 3 +-- file.c | 8 ++------ rawshark.c | 6 +----- tshark.c | 12 ++---------- ui/gtk/rlc_lte_graph.c | 4 +--- ui/gtk/tcp_graph.c | 4 +--- 8 files changed, 24 insertions(+), 29 deletions(-) diff --git a/epan/epan.c b/epan/epan.c index 5d1292e5f3..8647a5c78e 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -198,6 +198,18 @@ epan_dissect_run(epan_dissect_t *edt, struct wtap_pkthdr *phdr, dissect_packet(edt, phdr, data, fd, cinfo); } +void +epan_dissect_run_with_taps(epan_dissect_t *edt, struct wtap_pkthdr *phdr, + const guint8* data, frame_data *fd, column_info *cinfo) +{ + /* free all memory allocated during previous packet */ + ep_free_all(); + + tap_queue_init(edt); + dissect_packet(edt, phdr, data, fd, cinfo); + tap_push_tapped_queue(edt); +} + void epan_dissect_reset(epan_dissect_t *edt) { diff --git a/epan/epan.h b/epan/epan.h index e618b33a64..122111f7cd 100644 --- a/epan/epan.h +++ b/epan/epan.h @@ -154,6 +154,10 @@ void epan_dissect_run(epan_dissect_t *edt, struct wtap_pkthdr *phdr, const guint8* data, frame_data *fd, column_info *cinfo); +void +epan_dissect_run_with_taps(epan_dissect_t *edt, struct wtap_pkthdr *phdr, + const guint8* data, frame_data *fd, column_info *cinfo); + /** Prime a proto_tree using the fields/protocols used in a dfilter. */ void epan_dissect_prime_dfilter(epan_dissect_t *edt, const dfilter_t *dfcode); diff --git a/epan/libwireshark.def b/epan/libwireshark.def index 7f5e918cc8..6de632af9c 100644 --- a/epan/libwireshark.def +++ b/epan/libwireshark.def @@ -411,6 +411,7 @@ epan_dissect_init epan_dissect_new epan_dissect_prime_dfilter epan_dissect_run +epan_dissect_run_with_taps epan_dissect_reset epan_get_compiled_version_info epan_get_runtime_version_info @@ -1050,9 +1051,7 @@ t38_T30_data_vals DATA t38_T30_indicator_vals DATA t38_add_address T_h323_message_body_vals DATA -tap_push_tapped_queue tap_build_interesting -tap_queue_init tap_queue_packet tcp_dissect_pdus tap_listeners_require_dissection diff --git a/file.c b/file.c index 554fa5f85f..b77b7732de 100644 --- a/file.c +++ b/file.c @@ -1121,9 +1121,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, &first_ts, prev_dis, prev_cap); prev_cap = fdata; - tap_queue_init(edt); - epan_dissect_run(edt, phdr, buf, fdata, cinfo); - tap_push_tapped_queue(edt); + epan_dissect_run_with_taps(edt, phdr, buf, fdata, cinfo); /* If we don't have a display filter, set "passed_dfilter" to 1. */ if (dfcode != NULL) { @@ -2286,9 +2284,7 @@ retap_packet(capture_file *cf _U_, frame_data *fdata, epan_dissect_t edt; epan_dissect_init(&edt, args->construct_protocol_tree, FALSE); - tap_queue_init(&edt); - epan_dissect_run(&edt, phdr, pd, fdata, args->cinfo); - tap_push_tapped_queue(&edt); + epan_dissect_run_with_taps(&edt, phdr, pd, fdata, args->cinfo); epan_dissect_cleanup(&edt); return TRUE; diff --git a/rawshark.c b/rawshark.c index ed36951066..687d2b763a 100644 --- a/rawshark.c +++ b/rawshark.c @@ -1057,8 +1057,6 @@ process_packet(capture_file *cf, gint64 offset, struct wtap_pkthdr *whdr, } } - tap_queue_init(&edt); - printf("%lu", (unsigned long int) cf->count); frame_data_set_before_dissect(&fdata, &cf->elapsed_time, @@ -1067,9 +1065,7 @@ process_packet(capture_file *cf, gint64 offset, struct wtap_pkthdr *whdr, /* We only need the columns if we're printing packet info but we're *not* verbose; in verbose mode, we print the protocol tree, not the protocol summary. */ - epan_dissect_run(&edt, whdr, pd, &fdata, &cf->cinfo); - - tap_push_tapped_queue(&edt); + epan_dissect_run_with_taps(&edt, whdr, pd, &fdata, &cf->cinfo); frame_data_set_after_dissect(&fdata, &cum_bytes); prev_dis_frame = fdata; diff --git a/tshark.c b/tshark.c index 46b7f451bb..cc2e92a67a 100644 --- a/tshark.c +++ b/tshark.c @@ -2632,8 +2632,6 @@ process_packet_second_pass(capture_file *cf, frame_data *fdata, col_custom_prime_edt(&edt, &cf->cinfo); - tap_queue_init(&edt); - /* We only need the columns if either 1) some tap needs the columns @@ -2647,9 +2645,7 @@ process_packet_second_pass(capture_file *cf, frame_data *fdata, else cinfo = NULL; - epan_dissect_run(&edt, phdr, pd, fdata, cinfo); - - tap_push_tapped_queue(&edt); + epan_dissect_run_with_taps(&edt, phdr, pd, fdata, cinfo); /* Run the read filter if we have one. */ if (cf->rfcode) @@ -3083,8 +3079,6 @@ process_packet(capture_file *cf, gint64 offset, struct wtap_pkthdr *whdr, col_custom_prime_edt(&edt, &cf->cinfo); - tap_queue_init(&edt); - /* We only need the columns if either 1) some tap needs the columns @@ -3101,9 +3095,7 @@ process_packet(capture_file *cf, gint64 offset, struct wtap_pkthdr *whdr, frame_data_set_before_dissect(&fdata, &cf->elapsed_time, &first_ts, prev_dis, prev_cap); - epan_dissect_run(&edt, whdr, pd, &fdata, cinfo); - - tap_push_tapped_queue(&edt); + epan_dissect_run_with_taps(&edt, whdr, pd, &fdata, cinfo); /* Run the read filter if we have one. */ if (cf->rfcode) diff --git a/ui/gtk/rlc_lte_graph.c b/ui/gtk/rlc_lte_graph.c index 33510c1355..76dfd60fda 100644 --- a/ui/gtk/rlc_lte_graph.c +++ b/ui/gtk/rlc_lte_graph.c @@ -927,9 +927,7 @@ static rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf, struct segment epan_dissect_init(&edt, TRUE, FALSE); epan_dissect_prime_dfilter(&edt, sfcode); - tap_queue_init(&edt); - epan_dissect_run(&edt, &cf->phdr, cf->pd, fdata, NULL); - tap_push_tapped_queue(&edt); + epan_dissect_run_with_taps(&edt, &cf->phdr, cf->pd, fdata, NULL); epan_dissect_cleanup(&edt); remove_tap_listener(&th); diff --git a/ui/gtk/tcp_graph.c b/ui/gtk/tcp_graph.c index eb53152a49..b080708284 100644 --- a/ui/gtk/tcp_graph.c +++ b/ui/gtk/tcp_graph.c @@ -1935,9 +1935,7 @@ static struct tcpheader *select_tcpip_session (capture_file *cf, struct segment epan_dissect_init(&edt, TRUE, FALSE); epan_dissect_prime_dfilter(&edt, sfcode); - tap_queue_init(&edt); - epan_dissect_run(&edt, &cf->phdr, cf->pd, fdata, NULL); - tap_push_tapped_queue(&edt); + epan_dissect_run_with_taps(&edt, &cf->phdr, cf->pd, fdata, NULL); epan_dissect_cleanup(&edt); remove_tap_listener(&th); -- cgit v1.2.3