#include "ui/filter_files.h"
#include "ui/tap_export_pdu.h"
#include "ui/failure_message.h"
-#include "epan/register.h"
#include <epan/epan_dissect.h>
#include <epan/tap.h>
+#include <epan/uat-int.h>
#include <codecs/codecs.h>
"-G" flag, as the "-G" flag dumps information registered by the
dissectors, and we must do it before we read the preferences, in
case any dissectors register preferences. */
- if (!epan_init(register_all_protocols, register_all_protocol_handoffs, NULL,
- NULL)) {
+ if (!epan_init(NULL, NULL, TRUE)) {
ret = EPAN_INIT_FAIL;
goto clean_exit;
}
/* Build the column format array */
build_column_format_array(&cfile.cinfo, prefs_p->num_cols, TRUE);
+#ifdef HAVE_MAXMINDDB
+ /* mmdbresolve is started from mmdb_resolve_start(), which is called from epan_load_settings via: read_prefs -> (...) uat_load_all -> maxmind_db_post_update_cb.
+ * Need to stop it, otherwise all sharkd will have same mmdbresolve process, including pipe descriptors to read and write. */
+ uat_clear(uat_get_table_by_name("MaxMind Database Paths"));
+#endif
+
ret = sharkd_loop();
clean_exit:
col_cleanup(&cfile.cinfo);
/* The open succeeded. Fill in the information for this file. */
- /* Create new epan session for dissection. */
- epan_free(cf->epan);
- cf->epan = sharkd_epan_new(cf);
-
cf->provider.wth = wth;
cf->f_datalen = 0; /* not used, but set it anyway */
cf->provider.prev_dis = NULL;
cf->provider.prev_cap = NULL;
+ /* Create new epan session for dissection. */
+ epan_free(cf->epan);
+ cf->epan = sharkd_epan_new(cf);
+
cf->state = FILE_READ_IN_PROGRESS;
wtap_set_cb_new_ipv4(cf->provider.wth, add_ipv4_name);
}
int
-sharkd_dissect_request(guint32 framenum, guint32 frame_ref_num, guint32 prev_dis_num, sharkd_dissect_func_t cb, int dissect_bytes, int dissect_columns, int dissect_tree, void *data)
+sharkd_dissect_request(guint32 framenum, guint32 frame_ref_num, guint32 prev_dis_num, sharkd_dissect_func_t cb, guint32 dissect_flags, void *data)
{
frame_data *fdata;
- column_info *cinfo = (dissect_columns) ? &cfile.cinfo : NULL;
+ column_info *cinfo = (dissect_flags & SHARKD_DISSECT_FLAG_COLUMNS) ? &cfile.cinfo : NULL;
epan_dissect_t edt;
gboolean create_proto_tree;
wtap_rec rec; /* Record metadata */
ws_buffer_init(&buf, 1500);
if (!wtap_seek_read(cfile.provider.wth, fdata->file_off, &rec, &buf, &err, &err_info)) {
+ wtap_rec_cleanup(&rec);
ws_buffer_free(&buf);
return -1; /* error reading the record */
}
- create_proto_tree = (dissect_tree) || (cinfo && have_custom_cols(cinfo));
- epan_dissect_init(&edt, cfile.epan, create_proto_tree, dissect_tree);
+ create_proto_tree = ((dissect_flags & SHARKD_DISSECT_FLAG_PROTO_TREE) ||
+ ((dissect_flags & SHARKD_DISSECT_FLAG_COLOR) && color_filters_used()) ||
+ (cinfo && have_custom_cols(cinfo)));
+ epan_dissect_init(&edt, cfile.epan, create_proto_tree, (dissect_flags & SHARKD_DISSECT_FLAG_PROTO_TREE));
+
+ if (dissect_flags & SHARKD_DISSECT_FLAG_COLOR) {
+ color_filters_prime_edt(&edt);
+ fdata->flags.need_colorize = 1;
+ }
if (cinfo)
col_custom_prime_edt(&edt, cinfo);
epan_dissect_fill_in_columns(&edt, FALSE, TRUE/* fill_fd_columns */);
}
- cb(&edt, dissect_tree ? edt.tree : NULL, cinfo, dissect_bytes ? edt.pi.data_src : NULL, data);
+ cb(&edt, (dissect_flags & SHARKD_DISSECT_FLAG_PROTO_TREE) ? edt.tree : NULL,
+ cinfo, (dissect_flags & SHARKD_DISSECT_FLAG_BYTES) ? edt.pi.data_src : NULL,
+ data);
epan_dissect_cleanup(&edt);
wtap_rec_cleanup(&rec);
if (!wtap_seek_read(cfile.provider.wth, fdata->file_off, &rec, &buf, &err, &err_info)) {
col_fill_in_error(cinfo, fdata, FALSE, FALSE /* fill_fd_columns */);
+ wtap_rec_cleanup(&rec);
ws_buffer_free(&buf);
return -1; /* error reading the record */
}
return -1;
}
+ /* if dfilter_compile() success, but (dfcode == NULL) all frames are matching */
+ if (dfcode == NULL) {
+ *result = NULL;
+ return 0;
+ }
+
frames_count = cfile.count;
wtap_rec_init(&rec);