#include "config.h"
-#ifdef HAVE_LIBGCRYPT
+#include <stdarg.h>
+
#include <wsutil/wsgcrypt.h>
-#endif /* HAVE_LIBGCRYPT */
#ifdef HAVE_LIBGNUTLS
#include <gnutls/gnutls.h>
#include <glib.h>
+#include <wsutil/report_err.h>
+
+#include <epan/exceptions.h>
+
#include "epan-int.h"
#include "epan.h"
#include "dfilter/dfilter.h"
#include "tap.h"
#include "addr_resolv.h"
#include "oids.h"
-#include "emem.h"
#include "wmem/wmem.h"
#include "expert.h"
+#include "print.h"
#ifdef HAVE_LUA
#include <lua.h>
#endif
}
-void
+gboolean
epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_data),
void (*register_all_handoffs_func)(register_cb cb, gpointer client_data),
register_cb cb,
gpointer client_data)
{
- /* initialize memory allocation subsystems */
- emem_init();
+ volatile gboolean status = TRUE;
+
+ /* initialize memory allocation subsystem */
wmem_init();
/* initialize the GUID to name mapping table */
guids_init();
- /* initialize name resolution (addr_resolv.c) */
- addr_resolv_init();
+ /* initialize name resolution (addr_resolv.c) */
+ addr_resolv_init();
except_init();
#ifdef HAVE_LIBGCRYPT
#ifdef HAVE_LIBGNUTLS
gnutls_global_init();
#endif
- tap_init();
- prefs_init();
- expert_init();
- packet_init();
- proto_init(register_all_protocols_func, register_all_handoffs_func,
- cb, client_data);
- packet_cache_proto_handles();
- dfilter_init();
- final_registration_all_protocols();
- expert_packet_init();
+ TRY {
+ tap_init();
+ prefs_init();
+ expert_init();
+ packet_init();
+ proto_init(register_all_protocols_func, register_all_handoffs_func,
+ cb, client_data);
+ packet_cache_proto_handles();
+ dfilter_init();
+ final_registration_all_protocols();
+ print_cache_field_handles();
+ expert_packet_init();
#ifdef HAVE_LUA
- wslua_init(cb, client_data);
+ wslua_init(cb, client_data);
#endif
+ }
+ CATCH(DissectorError) {
+ /*
+ * This is probably a dissector, or something it calls,
+ * calling REPORT_DISSECTOR_ERROR() in a registration
+ * routine or something else outside the normal dissection
+ * code path.
+ */
+ const char *exception_message = GET_MESSAGE;
+ static const char dissector_error_nomsg[] =
+ "Dissector writer didn't bother saying what the error was";
+
+ report_failure("Dissector bug: %s",
+ exception_message == NULL ?
+ dissector_error_nomsg : exception_message);
+ if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)
+ abort();
+ status = FALSE;
+ }
+ ENDTRY;
+ return status;
}
void
void
epan_dissect_run(epan_dissect_t *edt, int file_type_subtype,
- struct wtap_pkthdr *phdr, tvbuff_t *tvb, frame_data *fd,
- column_info *cinfo)
+ struct wtap_pkthdr *phdr, tvbuff_t *tvb, frame_data *fd,
+ column_info *cinfo)
{
#ifdef HAVE_LUA
wslua_prime_dfilter(edt); /* done before entering wmem scope */
dissect_record(edt, file_type_subtype, phdr, tvb, fd, cinfo);
/* free all memory allocated */
- ep_free_all();
wmem_leave_packet_scope();
}
void
epan_dissect_run_with_taps(epan_dissect_t *edt, int file_type_subtype,
- struct wtap_pkthdr *phdr, tvbuff_t *tvb, frame_data *fd,
- column_info *cinfo)
+ struct wtap_pkthdr *phdr, tvbuff_t *tvb, frame_data *fd,
+ column_info *cinfo)
{
wmem_enter_packet_scope();
tap_queue_init(edt);
tap_push_tapped_queue(edt);
/* free all memory allocated */
- ep_free_all();
wmem_leave_packet_scope();
}
void
epan_dissect_file_run(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
- tvbuff_t *tvb, frame_data *fd, column_info *cinfo)
+ tvbuff_t *tvb, frame_data *fd, column_info *cinfo)
{
#ifdef HAVE_LUA
wslua_prime_dfilter(edt); /* done before entering wmem scope */
dissect_file(edt, phdr, tvb, fd, cinfo);
/* free all memory allocated */
- ep_free_all();
wmem_leave_packet_scope();
}
void
epan_dissect_file_run_with_taps(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
- tvbuff_t *tvb, frame_data *fd, column_info *cinfo)
+ tvbuff_t *tvb, frame_data *fd, column_info *cinfo)
{
wmem_enter_packet_scope();
tap_queue_init(edt);
tap_push_tapped_queue(edt);
/* free all memory allocated */
- ep_free_all();
wmem_leave_packet_scope();
}
/* ----------------------- */
const gchar *
-epan_custom_set(epan_dissect_t *edt, int field_id,
- gint occurrence,
- gchar *result,
- gchar *expr, const int size )
+epan_custom_set(epan_dissect_t *edt, GSList *field_ids,
+ gint occurrence,
+ gchar *result,
+ gchar *expr, const int size )
{
- return proto_custom_set(edt->tree, field_id, occurrence, result, expr, size);
+ return proto_custom_set(edt->tree, field_ids, occurrence, result, expr, size);
}
void
epan_dissect_fill_in_columns(epan_dissect_t *edt, const gboolean fill_col_exprs, const gboolean fill_fd_colums)
{
- col_custom_set_edt(edt, edt->pi.cinfo);
- col_fill_in(&edt->pi, fill_col_exprs, fill_fd_colums);
+ col_custom_set_edt(edt, edt->pi.cinfo);
+ col_fill_in(&edt->pi, fill_col_exprs, fill_fd_colums);
}
gboolean
epan_dissect_packet_contains_field(epan_dissect_t* edt,
- const char *field_name)
+ const char *field_name)
{
- GPtrArray* array;
- int field_id;
- gboolean contains_field;
-
- if (!edt || !edt->tree)
- return FALSE;
- field_id = proto_get_id_by_filter_name(field_name);
- if (field_id < 0)
- return FALSE;
- array = proto_find_finfo(edt->tree, field_id);
- contains_field = (array->len > 0) ? TRUE : FALSE;
- g_ptr_array_free(array, TRUE);
- return contains_field;
+ GPtrArray* array;
+ int field_id;
+ gboolean contains_field;
+
+ if (!edt || !edt->tree)
+ return FALSE;
+ field_id = proto_get_id_by_filter_name(field_name);
+ if (field_id < 0)
+ return FALSE;
+ array = proto_find_finfo(edt->tree, field_id);
+ contains_field = (array->len > 0) ? TRUE : FALSE;
+ g_ptr_array_free(array, TRUE);
+ return contains_field;
}
/*
void
epan_get_compiled_version_info(GString *str)
{
- /* SNMP */
+ /* SNMP */
g_string_append(str, ", ");
#ifdef HAVE_LIBSMI
g_string_append(str, "with SMI " SMI_VERSION_STRING);
#endif /* HAVE_GNU_ADNS */
#endif /* HAVE_C_ARES */
- /* LUA */
+ /* LUA */
g_string_append(str, ", ");
#ifdef HAVE_LUA
g_string_append(str, "with ");
g_string_append(str, "without Lua");
#endif /* HAVE_LUA */
- /* GnuTLS */
+ /* GnuTLS */
g_string_append(str, ", ");
#ifdef HAVE_LIBGNUTLS
g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
g_string_append(str, "without GnuTLS");
#endif /* HAVE_LIBGNUTLS */
- /* Gcrypt */
+ /* Gcrypt */
g_string_append(str, ", ");
#ifdef HAVE_LIBGCRYPT
g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
g_string_append(str, "without Gcrypt");
#endif /* HAVE_LIBGCRYPT */
- /* Kerberos */
- /* XXX - I don't see how to get the version number, at least for KfW */
+ /* Kerberos */
+ /* XXX - I don't see how to get the version number, at least for KfW */
g_string_append(str, ", ");
#ifdef HAVE_KERBEROS
#ifdef HAVE_MIT_KERBEROS
g_string_append(str, "with MIT Kerberos");
#else
- /* HAVE_HEIMDAL_KERBEROS */
+ /* HAVE_HEIMDAL_KERBEROS */
g_string_append(str, "with Heimdal Kerberos");
#endif
#else
#endif
)
{
- /* GnuTLS */
+ /* GnuTLS */
#ifdef HAVE_LIBGNUTLS
g_string_append_printf(str, ", with GnuTLS %s", gnutls_check_version(NULL));
#endif /* HAVE_LIBGNUTLS */
- /* Gcrypt */
+ /* Gcrypt */
#ifdef HAVE_LIBGCRYPT
g_string_append_printf(str, ", with Gcrypt %s", gcry_check_version(NULL));
#endif /* HAVE_LIBGCRYPT */