diff options
author | Guy Harris <gharris@sonic.net> | 2021-03-15 11:29:43 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2021-03-15 12:17:59 -0700 |
commit | c33e2f7b51f9e14f99f6b6d9018ac41b7e97d5a6 (patch) | |
tree | 4e02fee80e16cfd08afc9d555e4612399c72d69b /extcap/androiddump.c | |
parent | 89ae76d3008719f6b797eb201794dfe0de294640 (diff) | |
download | wireshark-c33e2f7b51f9e14f99f6b6d9018ac41b7e97d5a6.tar.gz wireshark-c33e2f7b51f9e14f99f6b6d9018ac41b7e97d5a6.tar.bz2 wireshark-c33e2f7b51f9e14f99f6b6d9018ac41b7e97d5a6.zip |
Add more error-reporting routines that call through a function pointer.
Have routines to report capture-file errors, using libwireshark error
codes and strings, that call through a pointer, so they can pop up
dialogs in GUI apps, print a message to the standard error on
command-line apps, and possibly do something different on server
programs.
Have init_report_message() take a pointer to structure containing those
function pointers, rather than the function pointers themselves, as
arguments.
Make other API changes to make that work.
Diffstat (limited to 'extcap/androiddump.c')
-rw-r--r-- | extcap/androiddump.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/extcap/androiddump.c b/extcap/androiddump.c index f999161aef..6011345385 100644 --- a/extcap/androiddump.c +++ b/extcap/androiddump.c @@ -21,6 +21,7 @@ #include <wsutil/strtoi.h> #include <wsutil/filesystem.h> #include <wsutil/privileges.h> +#include <wsutil/report_message.h> #include <wsutil/please_report_bug.h> #include <ui/cmdarg_err.h> #include <wsutil/inet_addr.h> @@ -359,7 +360,7 @@ static const char* interface_to_logbuf(char* interface) * g_logv() with the appropriate arguments. */ static void -failure_warning_message(const char *msg_format, va_list ap) +androiddump_cmdarg_err(const char *msg_format, va_list ap) { g_logv(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, msg_format, ap); } @@ -459,12 +460,12 @@ static struct extcap_dumper extcap_dumper_open(char *fifo, int encap) { file_type_subtype = wtap_pcap_nsec_file_type_subtype(); extcap_dumper.dumper.wtap = wtap_dump_open(fifo, file_type_subtype, WTAP_UNCOMPRESSED, ¶ms, &err, &err_info); if (!extcap_dumper.dumper.wtap) { - cfile_dump_open_failure_message("androiddump", fifo, err, err_info, file_type_subtype); + cfile_dump_open_failure_message(fifo, err, err_info, file_type_subtype); exit(EXIT_CODE_CANNOT_SAVE_WIRETAP_DUMP); } extcap_dumper.encap = encap; if (!wtap_dump_flush(extcap_dumper.dumper.wtap, &err)) { - cfile_dump_open_failure_message("androiddump", fifo, err, NULL, file_type_subtype); + cfile_dump_open_failure_message(fifo, err, NULL, file_type_subtype); exit(EXIT_CODE_CANNOT_SAVE_WIRETAP_DUMP); } #endif @@ -522,13 +523,13 @@ static gboolean extcap_dumper_dump(struct extcap_dumper extcap_dumper, rec.rec_header.packet_header.pkt_encap = extcap_dumper.encap; if (!wtap_dump(extcap_dumper.dumper.wtap, &rec, (const guint8 *) buffer, &err, &err_info)) { - cfile_write_failure_message("androiddump", NULL, fifo, err, err_info, 0, + cfile_write_failure_message(NULL, fifo, err, err_info, 0, wtap_dump_file_type_subtype(extcap_dumper.dumper.wtap)); return FALSE; } if (!wtap_dump_flush(extcap_dumper.dumper.wtap, &err)) { - cfile_write_failure_message("androiddump", NULL, fifo, err, NULL, 0, + cfile_write_failure_message(NULL, fifo, err, NULL, 0, wtap_dump_file_type_subtype(extcap_dumper.dumper.wtap)); return FALSE; } @@ -2490,6 +2491,18 @@ static int capture_android_tcpdump(char *interface, char *fifo, int main(int argc, char *argv[]) { char *err_msg; + static const struct report_message_routines androiddummp_report_routines = { + failure_message, + failure_message, + open_failure_message, + read_failure_message, + write_failure_message, + cfile_open_failure_message, + cfile_dump_open_failure_message, + cfile_read_failure_message, + cfile_write_failure_message, + cfile_close_failure_message + }; int ret = EXIT_CODE_GENERIC; int option_idx = 0; int result; @@ -2514,7 +2527,7 @@ int main(int argc, char *argv[]) { char *help_url; char *help_header = NULL; - cmdarg_err_init(failure_warning_message, failure_warning_message); + cmdarg_err_init(androiddump_cmdarg_err, androiddump_cmdarg_err); /* * Get credential information for later use. @@ -2532,6 +2545,8 @@ int main(int argc, char *argv[]) { g_free(err_msg); } + init_report_message("androiddump", &androiddummp_report_routines); + extcap_conf = g_new0(extcap_parameters, 1); help_url = data_file_url("androiddump.html"); |