extcap: add command line debug function to extcap-base.

This function is helpful to debug the interaction between the
calling UI and the extcap itself.

All extcaps have been changed accordingly.

Change-Id: I358caf4c50797501672bf77fdd91f7276897078c
Reviewed-on: https://code.wireshark.org/review/22806
Reviewed-by: Roland Knall <rknall@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
This commit is contained in:
Dario Lombardo 2017-07-26 21:48:44 +02:00
parent f86f54eb90
commit 963707ab3c
7 changed files with 20 additions and 12 deletions

View File

@ -2753,6 +2753,8 @@ int main(int argc, char **argv) {
} }
#endif /* _WIN32 */ #endif /* _WIN32 */
extcap_cmdline_debug(argv, argc);
if (extcap_conf->do_list_interfaces) if (extcap_conf->do_list_interfaces)
register_interfaces(extcap_conf, adb_server_ip, adb_server_tcp_port); register_interfaces(extcap_conf, adb_server_ip, adb_server_tcp_port);

View File

@ -521,7 +521,6 @@ int main(int argc, char **argv)
{ {
int result; int result;
int option_idx = 0; int option_idx = 0;
int i;
char* remote_host = NULL; char* remote_host = NULL;
guint16 remote_port = 22; guint16 remote_port = 22;
char* remote_username = NULL; char* remote_username = NULL;
@ -580,9 +579,6 @@ int main(int argc, char **argv)
goto end; goto end;
} }
for (i = 0; i < argc; i++)
g_debug("%s ", argv[i]);
while ((result = getopt_long(argc, argv, ":", longopts, &option_idx)) != -1) { while ((result = getopt_long(argc, argv, ":", longopts, &option_idx)) != -1) {
switch (result) { switch (result) {
@ -660,6 +656,8 @@ int main(int argc, char **argv)
} }
} }
extcap_cmdline_debug(argv, argc);
if (optind != argc) { if (optind != argc) {
g_warning("Unexpected extra option: %s", argv[optind]); g_warning("Unexpected extra option: %s", argv[optind]);
goto end; goto end;

View File

@ -332,6 +332,16 @@ void extcap_help_add_header(extcap_parameters * extcap, char * help_header)
extcap_help_add_option(extcap, "--debug", "print additional messages"); extcap_help_add_option(extcap, "--debug", "print additional messages");
} }
void extcap_cmdline_debug(char** ar, const unsigned n)
{
GString* cmdline = g_string_new("cmdline: ");
unsigned i;
for (i = 0; i < n; i++)
g_string_append_printf(cmdline, "%s ", ar[i]);
g_debug("%s", cmdline->str);
g_string_free(cmdline, TRUE);
}
/* /*
* Editor modelines - https://www.wireshark.org/tools/modelines.html * Editor modelines - https://www.wireshark.org/tools/modelines.html
* *

View File

@ -105,7 +105,7 @@ void extcap_base_cleanup(extcap_parameters ** extcap);
void extcap_help_add_header(extcap_parameters * extcap, char * help_header); void extcap_help_add_header(extcap_parameters * extcap, char * help_header);
void extcap_help_add_option(extcap_parameters * extcap, const char * help_option_name, const char * help_optionn_desc); void extcap_help_add_option(extcap_parameters * extcap, const char * help_option_name, const char * help_optionn_desc);
void extcap_help_print(extcap_parameters * extcap); void extcap_help_print(extcap_parameters * extcap);
void extcap_cmdline_debug(char** ar, const unsigned n);
void extcap_base_help(void); void extcap_base_help(void);
#endif #endif

View File

@ -136,7 +136,6 @@ int main(int argc, char *argv[])
int produce_type = -1; int produce_type = -1;
randpkt_example *example; randpkt_example *example;
wtap_dumper* savedump; wtap_dumper* savedump;
int i;
int ret = EXIT_FAILURE; int ret = EXIT_FAILURE;
#ifdef _WIN32 #ifdef _WIN32
@ -180,9 +179,6 @@ int main(int argc, char *argv[])
attach_parent_console(); attach_parent_console();
#endif /* _WIN32 */ #endif /* _WIN32 */
for (i = 0; i < argc; i++)
g_debug("%s ", argv[i]);
while ((result = getopt_long(argc, argv, ":", longopts, &option_idx)) != -1) { while ((result = getopt_long(argc, argv, ":", longopts, &option_idx)) != -1) {
switch (result) { switch (result) {
case OPT_VERSION: case OPT_VERSION:
@ -242,6 +238,8 @@ int main(int argc, char *argv[])
} }
} }
extcap_cmdline_debug(argv, argc);
if (optind != argc) { if (optind != argc) {
g_warning("Invalid option: %s", argv[optind]); g_warning("Invalid option: %s", argv[optind]);
goto end; goto end;

View File

@ -330,7 +330,6 @@ int main(int argc, char **argv)
{ {
int result; int result;
int option_idx = 0; int option_idx = 0;
int i;
char* remote_host = NULL; char* remote_host = NULL;
guint16 remote_port = 22; guint16 remote_port = 22;
char* remote_username = NULL; char* remote_username = NULL;
@ -479,8 +478,7 @@ int main(int argc, char **argv)
} }
} }
for (i = 0; i < argc; i++) extcap_cmdline_debug(argv, argc);
g_debug("%s", argv[i]);
if (optind != argc) { if (optind != argc) {
g_warning("Unexpected extra option: %s", argv[optind]); g_warning("Unexpected extra option: %s", argv[optind]);

View File

@ -441,6 +441,8 @@ int main(int argc, char *argv[])
} }
} }
extcap_cmdline_debug(argv, argc);
if (optind != argc) { if (optind != argc) {
g_warning("Unexpected extra option: %s", argv[optind]); g_warning("Unexpected extra option: %s", argv[optind]);
goto end; goto end;