forked from osmocom/wireshark
epan: Initialize wiretap
Clients of libwireshark should not be required to initialize explicitly wiretap, if they don't use it themselves.
This commit is contained in:
parent
ba85d8ef4d
commit
c15f2aadc1
9
dftest.c
9
dftest.c
|
@ -31,8 +31,6 @@
|
|||
#include <wsutil/report_message.h>
|
||||
#include <wsutil/wslog.h>
|
||||
|
||||
#include <wiretap/wtap.h>
|
||||
|
||||
#include "ui/util.h"
|
||||
#include "ui/cmdarg_err.h"
|
||||
#include "ui/failure_message.h"
|
||||
|
@ -89,13 +87,6 @@ main(int argc, char **argv)
|
|||
timestamp_set_type(TS_RELATIVE);
|
||||
timestamp_set_seconds_type(TS_SECONDS_DEFAULT);
|
||||
|
||||
/*
|
||||
* Libwiretap must be initialized before libwireshark is, so that
|
||||
* dissection-time handlers for file-type-dependent blocks can
|
||||
* register using the file type/subtype value for the file type.
|
||||
*/
|
||||
wtap_init(TRUE);
|
||||
|
||||
/* Register all dissectors; we must do this before checking for the
|
||||
"-g" flag, as the "-g" flag dumps a list of fields registered
|
||||
by the dissectors, and we must do it before we read the preferences,
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <wsutil/report_message.h>
|
||||
|
||||
#include <wiretap/wtap.h>
|
||||
#include <epan/exceptions.h>
|
||||
|
||||
#include "epan.h"
|
||||
|
@ -246,6 +247,8 @@ epan_init(register_cb cb, gpointer client_data, gboolean load_plugins)
|
|||
wireshark_abort_on_too_many_items = FALSE;
|
||||
}
|
||||
|
||||
wtap_init(load_plugins);
|
||||
|
||||
/*
|
||||
* proto_init -> register_all_protocols -> g_async_queue_new which
|
||||
* requires threads to be initialized. This happens automatically with
|
||||
|
@ -428,6 +431,8 @@ epan_cleanup(void)
|
|||
}
|
||||
|
||||
wmem_cleanup_scopes();
|
||||
|
||||
wtap_cleanup();
|
||||
}
|
||||
|
||||
struct epan_session {
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include <wsutil/plugins.h>
|
||||
#endif
|
||||
|
||||
static gboolean wiretap_initialized = FALSE;
|
||||
|
||||
#ifdef HAVE_PLUGINS
|
||||
static plugins_t *libwiretap_plugins = NULL;
|
||||
#endif
|
||||
|
@ -1838,6 +1840,9 @@ wtap_full_file_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf,
|
|||
void
|
||||
wtap_init(gboolean load_wiretap_plugins)
|
||||
{
|
||||
if (wiretap_initialized)
|
||||
return;
|
||||
|
||||
init_open_routines();
|
||||
wtap_opttypes_initialize();
|
||||
wtap_init_encap_types();
|
||||
|
@ -1848,6 +1853,7 @@ wtap_init(gboolean load_wiretap_plugins)
|
|||
#endif
|
||||
g_slist_foreach(wtap_plugins, call_plugin_register_wtap_module, NULL);
|
||||
}
|
||||
wiretap_initialized = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1856,6 +1862,9 @@ wtap_init(gboolean load_wiretap_plugins)
|
|||
void
|
||||
wtap_cleanup(void)
|
||||
{
|
||||
if (!wiretap_initialized)
|
||||
return;
|
||||
|
||||
wtap_cleanup_encap_types();
|
||||
wtap_opttypes_cleanup();
|
||||
ws_buffer_cleanup();
|
||||
|
@ -1866,6 +1875,7 @@ wtap_cleanup(void)
|
|||
plugins_cleanup(libwiretap_plugins);
|
||||
libwiretap_plugins = NULL;
|
||||
#endif
|
||||
wiretap_initialized = FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue