aboutsummaryrefslogtreecommitdiffstats
path: root/extcap
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2020-07-15 19:24:09 -0700
committerGuy Harris <gharris@sonic.net>2020-07-16 02:48:45 +0000
commite4835191cb72d3235b8e4fb3b7f66c09edb7aa44 (patch)
treeaf585d09e8147af9202a9977f1d78f9c43e11dd0 /extcap
parent44ca0af5dff96f56d59a8240785b97aff1b1b097 (diff)
extcap: clean up the version number handling.
Have the version parameter be just the version number; other code expects it to be that. Have additional parameters for the "compiled with" and "running with" information. Add a extcap_version_print() routine to show the version message, printing {exename} version {version} and then printing Compiled with {compiled_with} if "compiled with" information is supplied and printing Running with {running_with} if "running with" information is supplied. This fixes some messages, as well as fixing the display of extcap modules in the About dialog. Change-Id: I3d298d30e83bd363abd599d75adfc780a90f34fd Reviewed-on: https://code.wireshark.org/review/37877 Petri-Dish: Guy Harris <gharris@sonic.net> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net>
Diffstat (limited to 'extcap')
-rw-r--r--extcap/androiddump.c2
-rw-r--r--extcap/ciscodump.c8
-rw-r--r--extcap/dpauxmon.c2
-rw-r--r--extcap/extcap-base.c32
-rw-r--r--extcap/extcap-base.h6
-rw-r--r--extcap/randpktdump.c2
-rw-r--r--extcap/sdjournal.c2
-rw-r--r--extcap/sshdump.c8
-rw-r--r--extcap/udpdump.c2
9 files changed, 41 insertions, 23 deletions
diff --git a/extcap/androiddump.c b/extcap/androiddump.c
index 91c9f8093c..7009679092 100644
--- a/extcap/androiddump.c
+++ b/extcap/androiddump.c
@@ -2583,7 +2583,7 @@ int main(int argc, char *argv[]) {
switch (result) {
case OPT_VERSION:
- printf("%s\n", extcap_conf->version);
+ extcap_version_print(extcap_conf);
ret = EXIT_CODE_SUCCESS;
goto end;
case OPT_HELP:
diff --git a/extcap/ciscodump.c b/extcap/ciscodump.c
index b50944d038..fed926428f 100644
--- a/extcap/ciscodump.c
+++ b/extcap/ciscodump.c
@@ -551,11 +551,11 @@ int main(int argc, char *argv[])
help_url = data_file_url("ciscodump.html");
extcap_base_set_util_info(extcap_conf, argv[0], CISCODUMP_VERSION_MAJOR, CISCODUMP_VERSION_MINOR,
CISCODUMP_VERSION_RELEASE, help_url);
- extcap_base_add_info(extcap_conf, "Compiled with libssh version %s", LIBSSH_VERSION_STRING);
+ extcap_base_set_compiled_with(extcap_conf, "libssh version %s", LIBSSH_VERSION_STRING);
#ifdef HAVE_SSH_VERSION
- extcap_base_add_info(extcap_conf, "Running with libssh version %s", ssh_version(0));
+ extcap_base_set_running_with(extcap_conf, "libssh version %s", ssh_version(0));
#else
- extcap_base_add_info(extcap_conf, "Running with libssh (unknown version)");
+ extcap_base_set_running_with(extcap_conf, "libssh (unknown version)");
#endif
g_free(help_url);
extcap_base_register_interface(extcap_conf, CISCODUMP_EXTCAP_INTERFACE, "Cisco remote capture", 147, "Remote capture dependent DLT");
@@ -603,7 +603,7 @@ int main(int argc, char *argv[])
goto end;
case OPT_VERSION:
- printf("%s\n", extcap_conf->version);
+ extcap_version_print(extcap_conf);
goto end;
case OPT_REMOTE_HOST:
diff --git a/extcap/dpauxmon.c b/extcap/dpauxmon.c
index 2058f96477..0ab4f576cc 100644
--- a/extcap/dpauxmon.c
+++ b/extcap/dpauxmon.c
@@ -536,7 +536,7 @@ int main(int argc, char *argv[])
goto end;
case OPT_VERSION:
- printf("%s\n", extcap_conf->version);
+ extcap_version_print(extcap_conf);
goto end;
case OPT_INTERFACE_ID:
diff --git a/extcap/extcap-base.c b/extcap/extcap-base.c
index 629e9e759f..68c15ae57d 100644
--- a/extcap/extcap-base.c
+++ b/extcap/extcap-base.c
@@ -83,8 +83,7 @@ void extcap_base_set_util_info(extcap_parameters * extcap, const char * exename,
if (!minor)
g_assert(!release);
- extcap->version = g_strdup_printf("%s version %s%s%s%s%s",
- extcap->exename,
+ extcap->version = g_strdup_printf("%s%s%s%s%s",
major,
minor ? "." : "",
minor ? minor : "",
@@ -93,18 +92,22 @@ void extcap_base_set_util_info(extcap_parameters * extcap, const char * exename,
extcap->helppage = g_strdup(helppage);
}
-void extcap_base_add_info(extcap_parameters * extcap, const char *fmt, ...)
+void extcap_base_set_compiled_with(extcap_parameters * extcap, const char *fmt, ...)
{
- gchar * old_version = extcap->version;
va_list ap;
- gchar * info;
va_start(ap, fmt);
- info = g_strdup_vprintf(fmt, ap);
+ extcap->compiled_with = g_strdup_vprintf(fmt, ap);
+ va_end(ap);
+}
+
+void extcap_base_set_running_with(extcap_parameters * extcap, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ extcap->running_with = g_strdup_vprintf(fmt, ap);
va_end(ap);
- extcap->version = g_strdup_printf("%s\n%s", old_version, info);
- g_free(old_version);
- g_free(info);
}
static void extcap_custom_log(const gchar *log_domain,
@@ -266,6 +269,8 @@ void extcap_base_cleanup(extcap_parameters ** extcap)
g_free((*extcap)->fifo);
g_free((*extcap)->interface);
g_free((*extcap)->version);
+ g_free((*extcap)->compiled_with);
+ g_free((*extcap)->running_with);
g_free((*extcap)->helppage);
g_free((*extcap)->help_header);
g_free((*extcap)->ws_version);
@@ -280,6 +285,15 @@ static void extcap_print_option(gpointer option, gpointer user_data _U_)
printf("\t%s: %s\n", o->optname, o->optdesc);
}
+void extcap_version_print(extcap_parameters * extcap)
+{
+ printf("%s version %s\n", extcap->exename, extcap->version);
+ if (extcap->compiled_with != NULL)
+ printf("Compiled with %s\n", extcap->compiled_with);
+ if (extcap->running_with != NULL)
+ printf("Running with %s\n", extcap->running_with);
+}
+
void extcap_help_print(extcap_parameters * extcap)
{
printf("\nWireshark - %s v%s\n\n", extcap->exename, extcap->version);
diff --git a/extcap/extcap-base.h b/extcap/extcap-base.h
index 8fa6d872c6..11c4431093 100644
--- a/extcap/extcap-base.h
+++ b/extcap/extcap-base.h
@@ -66,6 +66,8 @@ typedef struct _extcap_parameters
char * capture_filter;
char * version;
+ char * compiled_with;
+ char * running_with;
char * helppage;
uint8_t capture;
uint8_t show_config;
@@ -87,12 +89,14 @@ typedef struct _extcap_parameters
void extcap_base_register_interface(extcap_parameters * extcap, const char * interface, const char * ifdescription, uint16_t dlt, const char * dltdescription );
void extcap_base_register_interface_ext(extcap_parameters * extcap, const char * interface, const char * ifdescription, uint16_t dlt, const char * dltname, const char * dltdescription );
void extcap_base_set_util_info(extcap_parameters * extcap, const char * exename, const char * major, const char * minor, const char * release, const char * helppage);
-void extcap_base_add_info(extcap_parameters * extcap, const char *fmt, ...);
+void extcap_base_set_compiled_with(extcap_parameters * extcap, const char *fmt, ...);
+void extcap_base_set_running_with(extcap_parameters * extcap, const char *fmt, ...);
uint8_t extcap_base_parse_options(extcap_parameters * extcap, int result, char * optargument);
uint8_t extcap_base_handle_interface(extcap_parameters * extcap);
void extcap_base_cleanup(extcap_parameters ** extcap);
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_version_print(extcap_parameters * extcap);
void extcap_help_print(extcap_parameters * extcap);
void extcap_cmdline_debug(char** ar, const unsigned n);
void extcap_init_custom_log(const char* filename);
diff --git a/extcap/randpktdump.c b/extcap/randpktdump.c
index 659e829be9..50ef15fc56 100644
--- a/extcap/randpktdump.c
+++ b/extcap/randpktdump.c
@@ -201,7 +201,7 @@ int main(int argc, char *argv[])
while ((result = getopt_long(argc, argv, ":", longopts, &option_idx)) != -1) {
switch (result) {
case OPT_VERSION:
- printf("%s\n", extcap_conf->version);
+ extcap_version_print(extcap_conf);
ret = EXIT_SUCCESS;
goto end;
diff --git a/extcap/sdjournal.c b/extcap/sdjournal.c
index b2a2d5d9e5..fd1b9a8f74 100644
--- a/extcap/sdjournal.c
+++ b/extcap/sdjournal.c
@@ -395,7 +395,7 @@ int main(int argc, char **argv)
goto end;
case OPT_VERSION:
- printf("%s\n", extcap_conf->version);
+ extcap_version_print(extcap_conf);
ret = EXIT_SUCCESS;
goto end;
diff --git a/extcap/sshdump.c b/extcap/sshdump.c
index 76f38e3bf4..9d60b97989 100644
--- a/extcap/sshdump.c
+++ b/extcap/sshdump.c
@@ -373,11 +373,11 @@ int main(int argc, char *argv[])
extcap_base_set_util_info(extcap_conf, argv[0], SSHDUMP_VERSION_MAJOR, SSHDUMP_VERSION_MINOR,
SSHDUMP_VERSION_RELEASE, help_url);
g_free(help_url);
- extcap_base_add_info(extcap_conf, "Compiled with libssh version %s", LIBSSH_VERSION_STRING);
+ extcap_base_set_compiled_with(extcap_conf, "libssh version %s", LIBSSH_VERSION_STRING);
#ifdef HAVE_SSH_VERSION
- extcap_base_add_info(extcap_conf, "Running with libssh version %s", ssh_version(0));
+ extcap_base_set_running_with(extcap_conf, "libssh version %s", ssh_version(0));
#else
- extcap_base_add_info(extcap_conf, "Running with libssh (unknown version)");
+ extcap_base_set_running_with(extcap_conf, "libssh (unknown version)");
#endif
extcap_base_register_interface(extcap_conf, SSH_EXTCAP_INTERFACE, "SSH remote capture", 147, "Remote capture dependent DLT");
@@ -426,7 +426,7 @@ int main(int argc, char *argv[])
goto end;
case OPT_VERSION:
- printf("%s\n", extcap_conf->version);
+ extcap_version_print(extcap_conf);
ret = EXIT_SUCCESS;
goto end;
diff --git a/extcap/udpdump.c b/extcap/udpdump.c
index 28ba761708..18b68739c2 100644
--- a/extcap/udpdump.c
+++ b/extcap/udpdump.c
@@ -419,7 +419,7 @@ int main(int argc, char *argv[])
goto end;
case OPT_VERSION:
- printf("%s\n", extcap_conf->version);
+ extcap_version_print(extcap_conf);
goto end;
case OPT_PORT: