diff options
author | Kovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com> | 2009-08-13 19:42:46 +0000 |
---|---|---|
committer | Kovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com> | 2009-08-13 19:42:46 +0000 |
commit | 80a6d3fbcf1d8ee469fbdb6c2d6423f942cbe712 (patch) | |
tree | 41a0430751c01d746062340b6b29c96147592b9f | |
parent | 97fda7386c87b840410a1804feee134ab0572276 (diff) |
Introduce epan_dissect_init()/epan_dissect_cleanup(). These are used to initialise/cleanup stack allocated 'edt' structures. This should speed up dissection since we avoid some malloc traffic.
svn path=/trunk/; revision=29404
-rw-r--r-- | epan/epan.c | 26 | ||||
-rw-r--r-- | epan/epan.h | 8 | ||||
-rw-r--r-- | epan/libwireshark.def | 2 | ||||
-rw-r--r-- | file.c | 140 | ||||
-rw-r--r-- | gtk/iax2_analysis.c | 32 | ||||
-rw-r--r-- | gtk/main.c | 12 | ||||
-rw-r--r-- | gtk/new_packet_list.c | 16 | ||||
-rw-r--r-- | gtk/rtp_analysis.c | 34 | ||||
-rw-r--r-- | gtk/sctp_assoc_analyse.c | 24 | ||||
-rw-r--r-- | gtk/tcp_graph.c | 14 | ||||
-rw-r--r-- | proto_hier_stats.c | 12 | ||||
-rw-r--r-- | rawshark.c | 16 | ||||
-rw-r--r-- | tshark.c | 24 |
13 files changed, 193 insertions, 167 deletions
diff --git a/epan/epan.c b/epan/epan.c index 7c088914d3..623865e561 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -145,11 +145,9 @@ epan_circuit_init(void) } epan_dissect_t* -epan_dissect_new(gboolean create_proto_tree, gboolean proto_tree_visible) +epan_dissect_init(epan_dissect_t *edt, gboolean create_proto_tree, gboolean proto_tree_visible) { - epan_dissect_t *edt; - - edt = g_new(epan_dissect_t, 1); + g_assert(edt); if (create_proto_tree) { edt->tree = proto_tree_create_root(); @@ -162,6 +160,16 @@ epan_dissect_new(gboolean create_proto_tree, gboolean proto_tree_visible) return edt; } +epan_dissect_t* +epan_dissect_new(gboolean create_proto_tree, gboolean proto_tree_visible) +{ + epan_dissect_t *edt; + + edt = g_new(epan_dissect_t, 1); + + return epan_dissect_init(edt, create_proto_tree, proto_tree_visible); +} + void epan_dissect_fake_protocols(epan_dissect_t *edt, gboolean fake_protocols) { @@ -179,10 +187,11 @@ epan_dissect_run(epan_dissect_t *edt, void* pseudo_header, dissect_packet(edt, pseudo_header, data, fd, cinfo); } - void -epan_dissect_free(epan_dissect_t* edt) +epan_dissect_cleanup(epan_dissect_t* edt) { + g_assert(edt); + /* Free the data sources list. */ free_data_sources(&edt->pi); @@ -194,7 +203,12 @@ epan_dissect_free(epan_dissect_t* edt) if (edt->tree) { proto_tree_free(edt->tree); } +} +void +epan_dissect_free(epan_dissect_t* edt) +{ + epan_dissect_cleanup(edt); g_free(edt); } diff --git a/epan/epan.h b/epan/epan.h index 2d5396f4cd..299818081f 100644 --- a/epan/epan.h +++ b/epan/epan.h @@ -85,6 +85,10 @@ epan_free(epan_t*); extern gchar* epan_get_version(void); +/* initialize an existing single packet dissection */ +epan_dissect_t* +epan_dissect_init(epan_dissect_t *edt, gboolean create_proto_tree, gboolean proto_tree_visible); + /* get a new single packet dissection */ /* should be freed using epan_dissect_free() after packet dissection completed */ epan_dissect_t* @@ -107,6 +111,10 @@ epan_dissect_prime_dfilter(epan_dissect_t *edt, const dfilter_t *dfcode); void epan_dissect_fill_in_columns(epan_dissect_t *edt, gboolean fill_fd_colums); +/* releases resources attached to the packet dissection. DOES NOT free the actual pointer */ +void +epan_dissect_cleanup(epan_dissect_t* edt); + /* free a single packet dissection */ void epan_dissect_free(epan_dissect_t* edt); diff --git a/epan/libwireshark.def b/epan/libwireshark.def index 1b52d42651..b6d48f451e 100644 --- a/epan/libwireshark.def +++ b/epan/libwireshark.def @@ -353,9 +353,11 @@ ep_strsplit ep_tvb_memdup epan_base64_decode epan_cleanup +epan_dissect_cleanup epan_dissect_fake_protocols epan_dissect_fill_in_columns epan_dissect_free +epan_dissect_init epan_dissect_new epan_dissect_prime_dfilter epan_dissect_run @@ -1002,7 +1002,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, { gint row; gboolean create_proto_tree = FALSE; - epan_dissect_t *edt; + epan_dissect_t edt; column_info *cinfo; #ifdef NEW_PACKET_LIST @@ -1073,21 +1073,21 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, create_proto_tree = TRUE; /* Dissect the frame. */ - edt = epan_dissect_new(create_proto_tree, FALSE); + epan_dissect_init(&edt, create_proto_tree, FALSE); if (dfcode != NULL && refilter) { - epan_dissect_prime_dfilter(edt, dfcode); + epan_dissect_prime_dfilter(&edt, dfcode); } /* prepare color filters */ #ifndef NEW_PACKET_LIST - color_filters_prime_edt(edt); - col_custom_prime_edt(edt, cinfo); + color_filters_prime_edt(&edt); + col_custom_prime_edt(&edt, cinfo); #endif - tap_queue_init(edt); - epan_dissect_run(edt, pseudo_header, buf, fdata, cinfo); - tap_push_tapped_queue(edt); + tap_queue_init(&edt); + epan_dissect_run(&edt, pseudo_header, buf, fdata, cinfo); + tap_push_tapped_queue(&edt); /* If we have a display filter, apply it if we're refiltering, otherwise leave the "passed_dfilter" flag alone. @@ -1095,16 +1095,16 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, If we don't have a display filter, set "passed_dfilter" to 1. */ if (dfcode != NULL) { if (refilter) { - fdata->flags.passed_dfilter = dfilter_apply_edt(dfcode, edt) ? 1 : 0; + fdata->flags.passed_dfilter = dfilter_apply_edt(dfcode, &edt) ? 1 : 0; } } else fdata->flags.passed_dfilter = 1; - if( (fdata->flags.passed_dfilter) || (edt->pi.fd->flags.ref_time) ){ + if( (fdata->flags.passed_dfilter) || (edt.pi.fd->flags.ref_time) ){ /* This frame either passed the display filter list or is marked as a time reference frame. All time reference frames are displayed even if they dont pass the display filter */ - if(edt->pi.fd->flags.ref_time){ + if(edt.pi.fd->flags.ref_time){ /* if this was a TIME REF frame we should reset the cul bytes field */ cum_bytes = fdata->pkt_len; fdata->cum_bytes = cum_bytes; @@ -1114,9 +1114,9 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, } #ifdef NEW_PACKET_LIST - epan_dissect_fill_in_columns(edt, FALSE); + epan_dissect_fill_in_columns(&edt, FALSE); #else - epan_dissect_fill_in_columns(edt, TRUE); + epan_dissect_fill_in_columns(&edt, TRUE); #endif /* If we haven't yet seen the first frame, this is it. @@ -1139,7 +1139,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, cf->last_displayed = fdata; #ifdef NEW_PACKET_LIST - row = new_packet_list_append(cinfo, fdata, &edt->pi); + row = new_packet_list_append(cinfo, fdata, &edt.pi); #else row = packet_list_append(cinfo->col_data, fdata); @@ -1148,7 +1148,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, * we do both to make sure that when a packet gets un-marked, the * color will be correctly set (fixes bug 2038) */ - fdata->color_filter = color_filters_colorize_packet(row, edt); + fdata->color_filter = color_filters_colorize_packet(row, &edt); if (fdata->flags.marked) { packet_list_set_colors(row, &prefs.gui_marked_fg, &prefs.gui_marked_bg); } @@ -1164,7 +1164,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, to the clist, and thus has no row. */ row = -1; } - epan_dissect_free(edt); + epan_dissect_cleanup(&edt); return row; } @@ -1180,7 +1180,6 @@ read_packet(capture_file *cf, dfilter_t *dfcode, frame_data *fdata; int passed; frame_data *plist_end; - epan_dissect_t *edt; int row = -1; /* Allocate the next list entry, and add it to the list. @@ -1216,11 +1215,12 @@ read_packet(capture_file *cf, dfilter_t *dfcode, passed = TRUE; if (cf->rfcode) { - edt = epan_dissect_new(TRUE, FALSE); - epan_dissect_prime_dfilter(edt, cf->rfcode); - epan_dissect_run(edt, pseudo_header, buf, fdata, NULL); - passed = dfilter_apply_edt(cf->rfcode, edt); - epan_dissect_free(edt); + epan_dissect_t edt; + epan_dissect_init(&edt, TRUE, FALSE); + epan_dissect_prime_dfilter(&edt, cf->rfcode); + epan_dissect_run(&edt, pseudo_header, buf, fdata, NULL); + passed = dfilter_apply_edt(cf->rfcode, &edt); + epan_dissect_cleanup(&edt); } if (passed) { plist_end = cf->plist_end; @@ -2113,13 +2113,13 @@ retap_packet(capture_file *cf _U_, frame_data *fdata, void *argsp) { retap_callback_args_t *args = argsp; - epan_dissect_t *edt; + epan_dissect_t edt; - edt = epan_dissect_new(args->construct_protocol_tree, FALSE); - tap_queue_init(edt); - epan_dissect_run(edt, pseudo_header, pd, fdata, args->cinfo); - tap_push_tapped_queue(edt); - epan_dissect_free(edt); + epan_dissect_init(&edt, args->construct_protocol_tree, FALSE); + tap_queue_init(&edt); + epan_dissect_run(&edt, pseudo_header, pd, fdata, args->cinfo); + tap_push_tapped_queue(&edt); + epan_dissect_cleanup(&edt); return TRUE; } @@ -2191,7 +2191,7 @@ print_packet(capture_file *cf, frame_data *fdata, void *argsp) { print_callback_args_t *args = argsp; - epan_dissect_t *edt; + epan_dissect_t edt; int i; char *cp; int line_len; @@ -2206,15 +2206,15 @@ print_packet(capture_file *cf, frame_data *fdata, XXX - do we need it if we're just printing the hex data? */ proto_tree_needed = args->print_args->print_dissections != print_dissections_none || args->print_args->print_hex || have_custom_cols(&cf->cinfo); - edt = epan_dissect_new(proto_tree_needed, proto_tree_needed); + epan_dissect_init(&edt, proto_tree_needed, proto_tree_needed); /* Fill in the column information if we're printing the summary information. */ if (args->print_args->print_summary) { - epan_dissect_run(edt, pseudo_header, pd, fdata, &cf->cinfo); - epan_dissect_fill_in_columns(edt, TRUE); + epan_dissect_run(&edt, pseudo_header, pd, fdata, &cf->cinfo); + epan_dissect_fill_in_columns(&edt, TRUE); } else - epan_dissect_run(edt, pseudo_header, pd, fdata, NULL); + epan_dissect_run(&edt, pseudo_header, pd, fdata, NULL); if (args->print_formfeed) { if (!new_page(args->print_args->stream)) @@ -2295,7 +2295,7 @@ print_packet(capture_file *cf, frame_data *fdata, } /* Print the information in that tree. */ - if (!proto_tree_print(args->print_args, edt, args->print_args->stream)) + if (!proto_tree_print(args->print_args, &edt, args->print_args->stream)) goto fail; /* Print a blank line if we print anything after this (aka more than one packet). */ @@ -2307,7 +2307,7 @@ print_packet(capture_file *cf, frame_data *fdata, if (args->print_args->print_hex) { /* Print the full packet data as hex. */ - if (!print_hex_data(args->print_args->stream, edt)) + if (!print_hex_data(args->print_args->stream, &edt)) goto fail; /* Print a blank line if we print anything after this (aka more than one packet). */ @@ -2317,7 +2317,7 @@ print_packet(capture_file *cf, frame_data *fdata, args->print_header_line = TRUE; } /* if (args->print_args->print_dissections != print_dissections_none) */ - epan_dissect_free(edt); + epan_dissect_cleanup(&edt); /* do we want to have a formfeed between each packet from now on? */ if(args->print_args->print_formfeed) { @@ -2327,7 +2327,7 @@ print_packet(capture_file *cf, frame_data *fdata, return TRUE; fail: - epan_dissect_free(edt); + epan_dissect_cleanup(&edt); return FALSE; } @@ -2466,16 +2466,16 @@ write_pdml_packet(capture_file *cf _U_, frame_data *fdata, void *argsp) { FILE *fh = argsp; - epan_dissect_t *edt; + epan_dissect_t edt; /* Create the protocol tree, but don't fill in the column information. */ - edt = epan_dissect_new(TRUE, TRUE); - epan_dissect_run(edt, pseudo_header, pd, fdata, NULL); + epan_dissect_init(&edt, TRUE, TRUE); + epan_dissect_run(&edt, pseudo_header, pd, fdata, NULL); /* Write out the information in that tree. */ - proto_tree_write_pdml(edt, fh); + proto_tree_write_pdml(&edt, fh); - epan_dissect_free(edt); + epan_dissect_cleanup(&edt); return !ferror(fh); } @@ -2536,20 +2536,20 @@ write_psml_packet(capture_file *cf, frame_data *fdata, void *argsp) { FILE *fh = argsp; - epan_dissect_t *edt; + epan_dissect_t edt; gboolean proto_tree_needed; /* Fill in the column information, only create the protocol tree if having custom columns. */ proto_tree_needed = have_custom_cols(&cf->cinfo); - edt = epan_dissect_new(proto_tree_needed, proto_tree_needed); - epan_dissect_run(edt, pseudo_header, pd, fdata, &cf->cinfo); - epan_dissect_fill_in_columns(edt, TRUE); + epan_dissect_init(&edt, proto_tree_needed, proto_tree_needed); + epan_dissect_run(&edt, pseudo_header, pd, fdata, &cf->cinfo); + epan_dissect_fill_in_columns(&edt, TRUE); /* Write out the information in that tree. */ - proto_tree_write_psml(edt, fh); + proto_tree_write_psml(&edt, fh); - epan_dissect_free(edt); + epan_dissect_cleanup(&edt); return !ferror(fh); } @@ -2610,20 +2610,20 @@ write_csv_packet(capture_file *cf, frame_data *fdata, void *argsp) { FILE *fh = argsp; - epan_dissect_t *edt; + epan_dissect_t edt; gboolean proto_tree_needed; /* Fill in the column information, only create the protocol tree if having custom columns. */ proto_tree_needed = have_custom_cols(&cf->cinfo); - edt = epan_dissect_new(proto_tree_needed, proto_tree_needed); - epan_dissect_run(edt, pseudo_header, pd, fdata, &cf->cinfo); - epan_dissect_fill_in_columns(edt, TRUE); + epan_dissect_init(&edt, proto_tree_needed, proto_tree_needed); + epan_dissect_run(&edt, pseudo_header, pd, fdata, &cf->cinfo); + epan_dissect_fill_in_columns(&edt, TRUE); /* Write out the information in that tree. */ - proto_tree_write_csv(edt, fh); + proto_tree_write_csv(&edt, fh); - epan_dissect_free(edt); + epan_dissect_cleanup(&edt); return !ferror(fh); } @@ -2950,18 +2950,18 @@ static gboolean match_protocol_tree(capture_file *cf, frame_data *fdata, void *criterion) { match_data *mdata = criterion; - epan_dissect_t *edt; + epan_dissect_t edt; /* Construct the protocol tree, including the displayed text */ - edt = epan_dissect_new(TRUE, TRUE); + epan_dissect_init(&edt, TRUE, TRUE); /* We don't need the column information */ - epan_dissect_run(edt, &cf->pseudo_header, cf->pd, fdata, NULL); + epan_dissect_run(&edt, &cf->pseudo_header, cf->pd, fdata, NULL); /* Iterate through all the nodes, seeing if they have text that matches. */ mdata->cf = cf; mdata->frame_matched = FALSE; - proto_tree_children_foreach(edt->tree, match_subtree_text, mdata); - epan_dissect_free(edt); + proto_tree_children_foreach(edt.tree, match_subtree_text, mdata); + epan_dissect_cleanup(&edt); return mdata->frame_matched; } @@ -3036,7 +3036,7 @@ match_summary_line(capture_file *cf, frame_data *fdata, void *criterion) match_data *mdata = criterion; const gchar *string = mdata->string; size_t string_len = mdata->string_len; - epan_dissect_t *edt; + epan_dissect_t edt; const char *info_column; size_t info_column_len; gboolean frame_matched = FALSE; @@ -3046,15 +3046,15 @@ match_summary_line(capture_file *cf, frame_data *fdata, void *criterion) size_t c_match = 0; /* Don't bother constructing the protocol tree */ - edt = epan_dissect_new(FALSE, FALSE); + epan_dissect_init(&edt, FALSE, FALSE); /* Get the column information */ - epan_dissect_run(edt, &cf->pseudo_header, cf->pd, fdata, &cf->cinfo); + epan_dissect_run(&edt, &cf->pseudo_header, cf->pd, fdata, &cf->cinfo); /* Find the Info column */ for (colx = 0; colx < cf->cinfo.num_cols; colx++) { if (cf->cinfo.fmt_matx[colx][COL_INFO]) { /* Found it. See if we match. */ - info_column = edt->pi.cinfo->col_data[colx]; + info_column = edt.pi.cinfo->col_data[colx]; info_column_len = strlen(info_column); for (i = 0; i < info_column_len; i++) { c_char = info_column[i]; @@ -3072,7 +3072,7 @@ match_summary_line(capture_file *cf, frame_data *fdata, void *criterion) break; } } - epan_dissect_free(edt); + epan_dissect_cleanup(&edt); return frame_matched; } @@ -3248,14 +3248,14 @@ static gboolean match_dfilter(capture_file *cf, frame_data *fdata, void *criterion) { dfilter_t *sfcode = criterion; - epan_dissect_t *edt; + epan_dissect_t edt; gboolean frame_matched; - edt = epan_dissect_new(TRUE, FALSE); - epan_dissect_prime_dfilter(edt, sfcode); - epan_dissect_run(edt, &cf->pseudo_header, cf->pd, fdata, NULL); - frame_matched = dfilter_apply_edt(sfcode, edt); - epan_dissect_free(edt); + epan_dissect_init(&edt, TRUE, FALSE); + epan_dissect_prime_dfilter(&edt, sfcode); + epan_dissect_run(&edt, &cf->pseudo_header, cf->pd, fdata, NULL); + frame_matched = dfilter_apply_edt(sfcode, &edt); + epan_dissect_cleanup(&edt); return frame_matched; } diff --git a/gtk/iax2_analysis.c b/gtk/iax2_analysis.c index 46e2dbfd19..37c64e427c 100644 --- a/gtk/iax2_analysis.c +++ b/gtk/iax2_analysis.c @@ -3524,7 +3524,7 @@ static void iax2_analysis_cb(GtkWidget *w _U_, gpointer data _U_) gchar filter_text[256]; dfilter_t *sfcode; capture_file *cf; - epan_dissect_t *edt; + epan_dissect_t edt; gint err; gchar *err_info; gboolean frame_matched; @@ -3555,15 +3555,15 @@ static void iax2_analysis_cb(GtkWidget *w _U_, gpointer data _U_) cf_read_error_message(err, err_info), cf->filename); return; } - edt = epan_dissect_new(TRUE, FALSE); - epan_dissect_prime_dfilter(edt, sfcode); - epan_dissect_run(edt, &cf->pseudo_header, cf->pd, fdata, NULL); - frame_matched = dfilter_apply_edt(sfcode, edt); + epan_dissect_init(&edt, TRUE, FALSE); + epan_dissect_prime_dfilter(&edt, sfcode); + epan_dissect_run(&edt, &cf->pseudo_header, cf->pd, fdata, NULL); + frame_matched = dfilter_apply_edt(sfcode, &edt); /* if it is not an iax2 frame, show an error dialog */ - frame_matched = dfilter_apply_edt(sfcode, edt); + frame_matched = dfilter_apply_edt(sfcode, &edt); if (frame_matched != 1) { - epan_dissect_free(edt); + epan_dissect_cleanup(&edt); simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "You didn't choose a IAX2 packet!"); return; @@ -3576,23 +3576,23 @@ static void iax2_analysis_cb(GtkWidget *w _U_, gpointer data _U_) } */ /* check if it is part of a Call */ - if (edt->pi.circuit_id == 0) { + if (edt.pi.circuit_id == 0) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Please select a Call packet!"); return; } /* ok, it is a IAX2 frame, so let's get the ip and port values */ - COPY_ADDRESS(&(ip_src_fwd), &(edt->pi.src)) - COPY_ADDRESS(&(ip_dst_fwd), &(edt->pi.dst)) - port_src_fwd = edt->pi.srcport; - port_dst_fwd = edt->pi.destport; + COPY_ADDRESS(&(ip_src_fwd), &(edt.pi.src)) + COPY_ADDRESS(&(ip_dst_fwd), &(edt.pi.dst)) + port_src_fwd = edt.pi.srcport; + port_dst_fwd = edt.pi.destport; /* assume the inverse ip/port combination for the reverse direction */ - COPY_ADDRESS(&(ip_src_rev), &(edt->pi.dst)) - COPY_ADDRESS(&(ip_dst_rev), &(edt->pi.src)) - port_src_rev = edt->pi.destport; - port_dst_rev = edt->pi.srcport; + COPY_ADDRESS(&(ip_src_rev), &(edt.pi.dst)) + COPY_ADDRESS(&(ip_dst_rev), &(edt.pi.src)) + port_src_rev = edt.pi.destport; + port_dst_rev = edt.pi.srcport; /* Scan for rtpstream */ rtpstream_scan(); diff --git a/gtk/main.c b/gtk/main.c index 3d3a0fbaa2..67c008107c 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -501,7 +501,7 @@ get_filter_from_packet_list_row_and_column(gpointer data) gint row = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(data), E_MPACKET_LIST_ROW_KEY)); gint column = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(data), E_MPACKET_LIST_COL_KEY)); frame_data *fdata = (frame_data *)packet_list_get_row_data(row); - epan_dissect_t *edt; + epan_dissect_t edt; gchar *buf=NULL; int err; gchar *err_info; @@ -514,12 +514,12 @@ get_filter_from_packet_list_row_and_column(gpointer data) return NULL; } /* proto tree, visible. We need a proto tree if there's custom columns */ - edt = epan_dissect_new(have_custom_cols(&cfile.cinfo), FALSE); - col_custom_prime_edt(edt, &cfile.cinfo); + epan_dissect_init(&edt, have_custom_cols(&cfile.cinfo), FALSE); + col_custom_prime_edt(&edt, &cfile.cinfo); - epan_dissect_run(edt, &cfile.pseudo_header, cfile.pd, fdata, + epan_dissect_run(&edt, &cfile.pseudo_header, cfile.pd, fdata, &cfile.cinfo); - epan_dissect_fill_in_columns(edt, TRUE); + epan_dissect_fill_in_columns(&edt, TRUE); if (strlen(cfile.cinfo.col_expr.col_expr[column]) != 0 && strlen(cfile.cinfo.col_expr.col_expr_val[column]) != 0) { @@ -528,7 +528,7 @@ get_filter_from_packet_list_row_and_column(gpointer data) cfile.cinfo.col_expr.col_expr_val[column]); } - epan_dissect_free(edt); + epan_dissect_cleanup(&edt); } return buf; diff --git a/gtk/new_packet_list.c b/gtk/new_packet_list.c index 59039d3eb8..8dd8541762 100644 --- a/gtk/new_packet_list.c +++ b/gtk/new_packet_list.c @@ -482,7 +482,7 @@ iter_from_row(GtkTreeIter *iter, guint row) static void new_packet_list_dissect(frame_data *fdata, gboolean col_text_present) { - epan_dissect_t *edt; + epan_dissect_t edt; int err; gchar *err_info; column_info *cinfo; @@ -501,17 +501,17 @@ new_packet_list_dissect(frame_data *fdata, gboolean col_text_present) return; } - edt = epan_dissect_new(TRUE /* create_proto_tree */, FALSE /* proto_tree_visible */); - color_filters_prime_edt(edt); - col_custom_prime_edt(edt, &cfile.cinfo); - epan_dissect_run(edt, &cfile.pseudo_header, cfile.pd, fdata, cinfo); - fdata->color_filter = color_filters_colorize_packet(0 /* row - unused */, edt); + epan_dissect_init(&edt, TRUE /* create_proto_tree */, FALSE /* proto_tree_visible */); + color_filters_prime_edt(&edt); + col_custom_prime_edt(&edt, &cfile.cinfo); + epan_dissect_run(&edt, &cfile.pseudo_header, cfile.pd, fdata, cinfo); + fdata->color_filter = color_filters_colorize_packet(0 /* row - unused */, &edt); /* "Stringify" non frame_data vals */ if (!col_text_present) - epan_dissect_fill_in_columns(edt, FALSE /* fill_fd_colums */); + epan_dissect_fill_in_columns(&edt, FALSE /* fill_fd_colums */); - epan_dissect_free(edt); + epan_dissect_cleanup(&edt); } static void diff --git a/gtk/rtp_analysis.c b/gtk/rtp_analysis.c index 0813a0cc46..7279109ec9 100644 --- a/gtk/rtp_analysis.c +++ b/gtk/rtp_analysis.c @@ -3670,7 +3670,7 @@ static void rtp_analysis_cb(GtkWidget *w _U_, gpointer data _U_) gchar filter_text[256]; dfilter_t *sfcode; capture_file *cf; - epan_dissect_t *edt; + epan_dissect_t edt; gint err; gchar *err_info; gboolean frame_matched; @@ -3701,41 +3701,41 @@ static void rtp_analysis_cb(GtkWidget *w _U_, gpointer data _U_) cf_read_error_message(err, err_info), cf->filename); return; } - edt = epan_dissect_new(TRUE, FALSE); - epan_dissect_prime_dfilter(edt, sfcode); - epan_dissect_run(edt, &cf->pseudo_header, cf->pd, fdata, NULL); - frame_matched = dfilter_apply_edt(sfcode, edt); + epan_dissect_init(&edt, TRUE, FALSE); + epan_dissect_prime_dfilter(&edt, sfcode); + epan_dissect_run(&edt, &cf->pseudo_header, cf->pd, fdata, NULL); + frame_matched = dfilter_apply_edt(sfcode, &edt); /* if it is not an rtp frame, show the rtpstream dialog */ - frame_matched = dfilter_apply_edt(sfcode, edt); + frame_matched = dfilter_apply_edt(sfcode, &edt); if (frame_matched != 1) { - epan_dissect_free(edt); + epan_dissect_cleanup(&edt); simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "You didn't choose a RTP packet!"); return; } /* ok, it is a RTP frame, so let's get the ip and port values */ - COPY_ADDRESS(&(ip_src_fwd), &(edt->pi.src)) - COPY_ADDRESS(&(ip_dst_fwd), &(edt->pi.dst)) - port_src_fwd = edt->pi.srcport; - port_dst_fwd = edt->pi.destport; + COPY_ADDRESS(&(ip_src_fwd), &(edt.pi.src)) + COPY_ADDRESS(&(ip_dst_fwd), &(edt.pi.dst)) + port_src_fwd = edt.pi.srcport; + port_dst_fwd = edt.pi.destport; /* assume the inverse ip/port combination for the reverse direction */ - COPY_ADDRESS(&(ip_src_rev), &(edt->pi.dst)) - COPY_ADDRESS(&(ip_dst_rev), &(edt->pi.src)) - port_src_rev = edt->pi.destport; - port_dst_rev = edt->pi.srcport; + COPY_ADDRESS(&(ip_src_rev), &(edt.pi.dst)) + COPY_ADDRESS(&(ip_dst_rev), &(edt.pi.src)) + port_src_rev = edt.pi.destport; + port_dst_rev = edt.pi.srcport; /* check if it is RTP Version 2 */ - if (!get_int_value_from_proto_tree(edt->tree, "rtp", "rtp.version", &version_fwd) || version_fwd != 2) { + if (!get_int_value_from_proto_tree(edt.tree, "rtp", "rtp.version", &version_fwd) || version_fwd != 2) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "RTP Version != 2 isn't supported!"); return; } /* now we need the SSRC value of the current frame */ - if (!get_int_value_from_proto_tree(edt->tree, "rtp", "rtp.ssrc", &ssrc_fwd)) { + if (!get_int_value_from_proto_tree(edt.tree, "rtp", "rtp.ssrc", &ssrc_fwd)) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "SSRC value couldn't be found!"); return; diff --git a/gtk/sctp_assoc_analyse.c b/gtk/sctp_assoc_analyse.c index 9cc6618b86..4d7fe853d0 100644 --- a/gtk/sctp_assoc_analyse.c +++ b/gtk/sctp_assoc_analyse.c @@ -823,7 +823,7 @@ static void sctp_analyse_cb(struct sctp_analyse* u_data, gboolean ext) GList *list, *framelist; dfilter_t *sfcode; capture_file *cf; - epan_dissect_t *edt; + epan_dissect_t edt; gint err; gchar *err_info; gboolean frame_matched, frame_found = FALSE; @@ -854,26 +854,26 @@ static void sctp_analyse_cb(struct sctp_analyse* u_data, gboolean ext) return; } - edt = epan_dissect_new(TRUE, FALSE); - epan_dissect_prime_dfilter(edt, sfcode); - epan_dissect_run(edt, &cf->pseudo_header, cf->pd, fdata, NULL); - frame_matched = dfilter_apply_edt(sfcode, edt); + epan_dissect_init(&edt, TRUE, FALSE); + epan_dissect_prime_dfilter(&edt, sfcode); + epan_dissect_run(&edt, &cf->pseudo_header, cf->pd, fdata, NULL); + frame_matched = dfilter_apply_edt(sfcode, &edt); /* if it is not an sctp frame, show the dialog */ if (frame_matched != 1) { - epan_dissect_free(edt); + epan_dissect_cleanup(&edt); simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Please choose an SCTP packet!"); return; } - ip_src = g_malloc(edt->pi.net_src.len); - memcpy(ip_src, edt->pi.net_src.data, edt->pi.net_src.len); - ip_dst = g_malloc(edt->pi.net_dst.len); - memcpy(ip_dst, edt->pi.net_dst.data, edt->pi.net_dst.len); - srcport = edt->pi.srcport; - dstport = edt->pi.destport; + ip_src = g_malloc(edt.pi.net_src.len); + memcpy(ip_src, edt.pi.net_src.data, edt.pi.net_src.len); + ip_dst = g_malloc(edt.pi.net_dst.len); + memcpy(ip_dst, edt.pi.net_dst.data, edt.pi.net_dst.len); + srcport = edt.pi.srcport; + dstport = edt.pi.destport; list = g_list_first(sctp_stat_get_info()->assoc_info_list); while (list) diff --git a/gtk/tcp_graph.c b/gtk/tcp_graph.c index 77d50766fc..e63cfe7e97 100644 --- a/gtk/tcp_graph.c +++ b/gtk/tcp_graph.c @@ -1794,7 +1794,7 @@ static struct tcpheader *select_tcpip_session (capture_file *cf, struct segment frame_data *fdata; gint err; gchar *err_info; - epan_dissect_t *edt; + epan_dissect_t edt; dfilter_t *sfcode; GString *error_string; th_t th = {0, NULL}; @@ -1824,12 +1824,12 @@ static struct tcpheader *select_tcpip_session (capture_file *cf, struct segment exit(1); } - edt = epan_dissect_new(TRUE, FALSE); - epan_dissect_prime_dfilter(edt, sfcode); - tap_queue_init(edt); - epan_dissect_run(edt, &cf->pseudo_header, cf->pd, fdata, NULL); - tap_push_tapped_queue(edt); - epan_dissect_free(edt); + epan_dissect_init(&edt, TRUE, FALSE); + epan_dissect_prime_dfilter(&edt, sfcode); + tap_queue_init(&edt); + epan_dissect_run(&edt, &cf->pseudo_header, cf->pd, fdata, NULL); + tap_push_tapped_queue(&edt); + epan_dissect_cleanup(&edt); remove_tap_listener(&th); if(th.num_hdrs==0){ diff --git a/proto_hier_stats.c b/proto_hier_stats.c index 8e6b58acff..edbad8c265 100644 --- a/proto_hier_stats.c +++ b/proto_hier_stats.c @@ -138,7 +138,7 @@ process_tree(proto_tree *protocol_tree, ph_stats_t* ps, guint pkt_len) static gboolean process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps) { - epan_dissect_t *edt; + epan_dissect_t edt; union wtap_pseudo_header phdr; guint8 pd[WTAP_MAX_PACKET_SIZE]; int err; @@ -154,13 +154,13 @@ process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps) } /* Dissect the frame tree not visible */ - edt = epan_dissect_new(TRUE, FALSE); + epan_dissect_init(&edt, TRUE, FALSE); /* Don't fake protocols. We need them for the protocol hierarchy */ - epan_dissect_fake_protocols(edt, FALSE); - epan_dissect_run(edt, &phdr, pd, frame, cinfo); + epan_dissect_fake_protocols(&edt, FALSE); + epan_dissect_run(&edt, &phdr, pd, frame, cinfo); /* Get stats from this protocol tree */ - process_tree(edt->tree, ps, frame->pkt_len); + process_tree(edt.tree, ps, frame->pkt_len); /* Update times */ cur_time = nstime_to_sec(&frame->abs_ts); @@ -172,7 +172,7 @@ process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps) } /* Free our memory. */ - epan_dissect_free(edt); + epan_dissect_cleanup(&edt); return TRUE; /* success */ } diff --git a/rawshark.c b/rawshark.c index cad73de744..97e0de4f7d 100644 --- a/rawshark.c +++ b/rawshark.c @@ -1086,7 +1086,7 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr, { frame_data fdata; gboolean create_proto_tree; - epan_dissect_t *edt; + epan_dissect_t edt; gboolean passed; union wtap_pseudo_header pseudo_header; int i; @@ -1121,31 +1121,31 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr, /* The protocol tree will be "visible", i.e., printed, only if we're printing packet details, which is true if we're in verbose mode ("verbose" is true). */ - edt = epan_dissect_new(create_proto_tree, FALSE); + epan_dissect_init(&edt, create_proto_tree, FALSE); /* If we're running a read filter, prime the epan_dissect_t with that filter. */ if (n_rfilters > 0) { for(i = 0; i < n_rfcodes; i++) { - epan_dissect_prime_dfilter(edt, rfcodes[i]); + epan_dissect_prime_dfilter(&edt, rfcodes[i]); } } - tap_queue_init(edt); + tap_queue_init(&edt); printf("%lu", (unsigned long int)cf->count); /* 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, &pseudo_header, pd, &fdata, &cf->cinfo); + epan_dissect_run(&edt, &pseudo_header, pd, &fdata, &cf->cinfo); - tap_push_tapped_queue(edt); + tap_push_tapped_queue(&edt); for(i = 0; i < n_rfilters; i++) { /* Run the read filter if we have one. */ if (rfcodes[i]) - passed = dfilter_apply_edt(rfcodes[i], edt); + passed = dfilter_apply_edt(rfcodes[i], &edt); else passed = TRUE; @@ -1183,7 +1183,7 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr, exit(2); } - epan_dissect_free(edt); + epan_dissect_cleanup(&edt); clear_fdata(&fdata); return passed; @@ -2461,7 +2461,7 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr, frame_data fdata; gboolean create_proto_tree; column_info *cinfo; - epan_dissect_t *edt; + epan_dissect_t edt; gboolean passed; /* Count this packet. */ @@ -2491,16 +2491,16 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr, printing packet details, which is true if we're printing stuff ("print_packet_info" is true) and we're in verbose mode ("verbose" is true). */ - edt = epan_dissect_new(create_proto_tree, print_packet_info && verbose); + epan_dissect_init(&edt, create_proto_tree, print_packet_info && verbose); /* If we're running a read filter, prime the epan_dissect_t with that filter. */ if (cf->rfcode) - epan_dissect_prime_dfilter(edt, cf->rfcode); + epan_dissect_prime_dfilter(&edt, cf->rfcode); - col_custom_prime_edt(edt, &cf->cinfo); + col_custom_prime_edt(&edt, &cf->cinfo); - tap_queue_init(edt); + tap_queue_init(&edt); /* We only need the columns if either @@ -2514,20 +2514,19 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr, cinfo = &cf->cinfo; else cinfo = NULL; - epan_dissect_run(edt, pseudo_header, pd, &fdata, cinfo); + epan_dissect_run(&edt, pseudo_header, pd, &fdata, cinfo); - tap_push_tapped_queue(edt); + tap_push_tapped_queue(&edt); /* Run the read filter if we have one. */ if (cf->rfcode) - passed = dfilter_apply_edt(cf->rfcode, edt); + passed = dfilter_apply_edt(cf->rfcode, &edt); else passed = TRUE; } else { /* We're not running a display filter and we're not printing any packet information, so we don't need to do a dissection, and all packets are processed. */ - edt = NULL; passed = TRUE; } @@ -2541,7 +2540,10 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr, if (print_packet_info) { /* We're printing packet information; print the information for this packet. */ - print_packet(cf, edt); + if (do_dissection) + print_packet(cf, &edt); + else + print_packet(cf, NULL); /* The ANSI C standard does not appear to *require* that a line-buffered stream be flushed to the host environment whenever a newline is @@ -2574,7 +2576,7 @@ process_packet(capture_file *cf, gint64 offset, const struct wtap_pkthdr *whdr, } if (do_dissection) { - epan_dissect_free(edt); + epan_dissect_cleanup(&edt); clear_fdata(&fdata); } return passed; |