diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2018-01-09 09:55:37 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-01-09 21:25:06 +0000 |
commit | fc9af81a13ec53ca15cbd28ce1896d407ab2bf8a (patch) | |
tree | 30ff801215a7f4b8133aa83e65fe22e98fb3fe90 | |
parent | a7e29d8b66dd7c1cb691966938404dafc6b89689 (diff) |
wiretap: add a parameter to wtap_init() indicating whether plugins must be loaded
g995812c5f1 moved wiretap plugins registration from applications to
wiretap library init function.
As we do not want to load plugins for all users of libwiretap, let's
make it configurable.
Bug: 14314
Change-Id: Id8fdcc484e2d0d31d3ab0bd357d3a6678570f700
Reviewed-on: https://code.wireshark.org/review/25194
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r-- | capinfos.c | 2 | ||||
-rw-r--r-- | captype.c | 2 | ||||
-rw-r--r-- | dftest.c | 2 | ||||
-rw-r--r-- | editcap.c | 2 | ||||
-rw-r--r-- | extcap/androiddump.c | 2 | ||||
-rw-r--r-- | extcap/randpktdump.c | 2 | ||||
-rw-r--r-- | mergecap.c | 2 | ||||
-rw-r--r-- | randpkt.c | 2 | ||||
-rw-r--r-- | randpkt_core/randpkt_core.c | 2 | ||||
-rw-r--r-- | rawshark.c | 2 | ||||
-rw-r--r-- | reordercap.c | 2 | ||||
-rw-r--r-- | sharkd.c | 2 | ||||
-rw-r--r-- | tfshark.c | 2 | ||||
-rw-r--r-- | tools/oss-fuzzshark/fuzzshark.c | 2 | ||||
-rw-r--r-- | tshark.c | 2 | ||||
-rw-r--r-- | ui/gtk/main.c | 2 | ||||
-rw-r--r-- | wireshark-qt.cpp | 2 | ||||
-rw-r--r-- | wiretap/wtap.c | 10 | ||||
-rw-r--r-- | wiretap/wtap.h | 8 |
19 files changed, 29 insertions, 23 deletions
diff --git a/capinfos.c b/capinfos.c index e51d6eaf15..c3b0a7e501 100644 --- a/capinfos.c +++ b/capinfos.c @@ -1467,7 +1467,7 @@ main(int argc, char *argv[]) init_report_message(failure_warning_message, failure_warning_message, NULL, NULL, NULL); - wtap_init(); + wtap_init(TRUE); /* Process the options */ while ((opt = getopt_long(argc, argv, "abcdehiklmoqrstuvxyzABCEFHIKLMNQRST", long_options, NULL)) !=-1) { @@ -145,7 +145,7 @@ main(int argc, char *argv[]) init_report_message(failure_warning_message, failure_warning_message, NULL, NULL, NULL); - wtap_init(); + wtap_init(TRUE); /* Process the options */ while ((opt = getopt_long(argc, argv, "hv", long_options, NULL)) !=-1) { @@ -72,7 +72,7 @@ main(int argc, char **argv) timestamp_set_type(TS_RELATIVE); timestamp_set_seconds_type(TS_SECONDS_DEFAULT); - wtap_init(); + 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 @@ -1030,7 +1030,7 @@ main(int argc, char *argv[]) init_report_message(failure_warning_message, failure_warning_message, NULL, NULL, NULL); - wtap_init(); + wtap_init(TRUE); /* Process the options */ while ((opt = getopt_long(argc, argv, ":a:A:B:c:C:dD:E:F:hi:I:Lo:rs:S:t:T:vVw:", long_options, NULL)) != -1) { diff --git a/extcap/androiddump.c b/extcap/androiddump.c index dd5617d081..04c838f6ad 100644 --- a/extcap/androiddump.c +++ b/extcap/androiddump.c @@ -432,7 +432,7 @@ static struct extcap_dumper extcap_dumper_open(char *fifo, int encap) { #else int err = 0; - wtap_init(); + wtap_init(FALSE); extcap_dumper.dumper.wtap = wtap_dump_open(fifo, WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC, encap, PACKET_LENGTH, FALSE, &err); if (!extcap_dumper.dumper.wtap) { diff --git a/extcap/randpktdump.c b/extcap/randpktdump.c index cbcab16170..b45ea75645 100644 --- a/extcap/randpktdump.c +++ b/extcap/randpktdump.c @@ -272,6 +272,8 @@ int main(int argc, char *argv[]) goto end; } + wtap_init(FALSE); + if (!all_random) { produce_type = randpkt_parse_type(type); diff --git a/mergecap.c b/mergecap.c index e59a16d364..ba95059d17 100644 --- a/mergecap.c +++ b/mergecap.c @@ -299,7 +299,7 @@ main(int argc, char *argv[]) init_report_message(failure_warning_message, failure_warning_message, NULL, NULL, NULL); - wtap_init(); + wtap_init(TRUE); /* Process the options first */ while ((opt = getopt_long(argc, argv, "aF:hI:s:vVw:", long_options, NULL)) != -1) { @@ -138,7 +138,7 @@ main(int argc, char **argv) init_report_message(failure_warning_message, failure_warning_message, NULL, NULL, NULL); - wtap_init(); + wtap_init(TRUE); cmdarg_err_init(failure_warning_message, failure_message_cont); diff --git a/randpkt_core/randpkt_core.c b/randpkt_core/randpkt_core.c index f35077b7b4..04cf8a14e6 100644 --- a/randpkt_core/randpkt_core.c +++ b/randpkt_core/randpkt_core.c @@ -661,8 +661,6 @@ int randpkt_example_init(randpkt_example* example, char* produce_filename, int p pkt_rand = g_rand_new(); } - wtap_init(); - if (strcmp(produce_filename, "-") == 0) { /* Write to the standard output. */ example->dump = wtap_dump_open_stdout(WTAP_FILE_TYPE_SUBTYPE_PCAP, diff --git a/rawshark.c b/rawshark.c index 19982787c5..d8a1d1917c 100644 --- a/rawshark.c +++ b/rawshark.c @@ -514,7 +514,7 @@ main(int argc, char *argv[]) timestamp_set_precision(TS_PREC_AUTO); timestamp_set_seconds_type(TS_SECONDS_DEFAULT); - wtap_init(); + wtap_init(FALSE); /* Register all dissectors; we must do this before checking for the "-G" flag, as the "-G" flag dumps information registered by the diff --git a/reordercap.c b/reordercap.c index f1207b8e3e..8570726cfc 100644 --- a/reordercap.c +++ b/reordercap.c @@ -233,7 +233,7 @@ main(int argc, char *argv[]) init_report_message(failure_warning_message, failure_warning_message, NULL, NULL, NULL); - wtap_init(); + wtap_init(TRUE); /* Process the options first */ while ((opt = getopt_long(argc, argv, "hnv", long_options, NULL)) != -1) { @@ -161,7 +161,7 @@ main(int argc, char *argv[]) timestamp_set_precision(TS_PREC_AUTO); timestamp_set_seconds_type(TS_SECONDS_DEFAULT); - wtap_init(); + wtap_init(TRUE); /* Register all dissectors; we must do this before checking for the "-G" flag, as the "-G" flag dumps information registered by the @@ -487,7 +487,7 @@ main(int argc, char *argv[]) timestamp_set_precision(TS_PREC_AUTO); timestamp_set_seconds_type(TS_SECONDS_DEFAULT); - wtap_init(); + wtap_init(TRUE); /* Register all dissectors; we must do this before checking for the "-G" flag, as the "-G" flag dumps information registered by the diff --git a/tools/oss-fuzzshark/fuzzshark.c b/tools/oss-fuzzshark/fuzzshark.c index 53560d9ef9..a700d5f039 100644 --- a/tools/oss-fuzzshark/fuzzshark.c +++ b/tools/oss-fuzzshark/fuzzshark.c @@ -219,7 +219,7 @@ fuzz_init(int argc _U_, char **argv) timestamp_set_precision(TS_PREC_AUTO); timestamp_set_seconds_type(TS_SECONDS_DEFAULT); - wtap_init(); + wtap_init(TRUE); /* Register all dissectors; we must do this before checking for the "-G" flag, as the "-G" flag dumps information registered by the @@ -893,7 +893,7 @@ main(int argc, char *argv[]) timestamp_set_precision(TS_PREC_AUTO); timestamp_set_seconds_type(TS_SECONDS_DEFAULT); - wtap_init(); + wtap_init(TRUE); /* Register all dissectors; we must do this before checking for the "-G" flag, as the "-G" flag dumps information registered by the diff --git a/ui/gtk/main.c b/ui/gtk/main.c index 872f4effa4..e76fa72100 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -2192,7 +2192,7 @@ main(int argc, char *argv[]) g_free(init_progfile_dir_error); } - wtap_init(); + wtap_init(TRUE); splash_update(RA_DISSECTORS, NULL, (gpointer)splash_win); diff --git a/wireshark-qt.cpp b/wireshark-qt.cpp index f8fb41becb..05d9400565 100644 --- a/wireshark-qt.cpp +++ b/wireshark-qt.cpp @@ -625,7 +625,7 @@ int main(int argc, char *qt_argv[]) open_failure_alert_box, read_failure_alert_box, write_failure_alert_box); - wtap_init(); + wtap_init(TRUE); splash_update(RA_DISSECTORS, NULL, NULL); #ifdef DEBUG_STARTUP_TIME diff --git a/wiretap/wtap.c b/wiretap/wtap.c index 58fd2c1d7b..bfff86786c 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -38,7 +38,7 @@ #ifdef HAVE_PLUGINS -static plugins_t *libwiretap_plugins; +static plugins_t *libwiretap_plugins = NULL; static GSList *wtap_plugins = NULL; void @@ -1427,14 +1427,16 @@ wtap_seek_read(wtap *wth, gint64 seek_off, * Initialize the library. */ void -wtap_init(void) +wtap_init(gboolean load_wiretap_plugins) { init_open_routines(); wtap_opttypes_initialize(); wtap_init_encap_types(); #ifdef HAVE_PLUGINS - libwiretap_plugins = plugins_init("wiretap"); - g_slist_foreach(wtap_plugins, call_plugin_register_wtap_module, NULL); + if (load_wiretap_plugins) { + libwiretap_plugins = plugins_init("wiretap"); + g_slist_foreach(wtap_plugins, call_plugin_register_wtap_module, NULL); + } #endif } diff --git a/wiretap/wtap.h b/wiretap/wtap.h index 8fd101d098..29f1527d60 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -1562,9 +1562,13 @@ struct file_type_subtype_info { #define WTAP_TYPE_AUTO 0 -/** Initialize the Wiretap library. */ +/** + * @brief Initialize the Wiretap library. + * + * @param load_wiretap_plugins Load Wiretap plugins when initializing library. +*/ WS_DLL_PUBLIC -void wtap_init(void); +void wtap_init(gboolean load_wiretap_plugins); /** On failure, "wtap_open_offline()" returns NULL, and puts into the * "int" pointed to by its second argument: |