forked from osmocom/wireshark
Make --help and --version information a bit more uniform.
Have --version print the version number, the copyright information, the "compiled with" information, the "running on/with" information, and the compiler information. Have --help print the version number, a one-line summary of what the program does, a reference to http://www.wireshark.org for more information, a Usage: line, and a list of command-line options. This means programs doing that don't need to include version.h; that's left up to get_ws_vcs_version_info() to do. Change-Id: Idac641bc10e4dfd04c9914d379b3a3e0cc5ca8cb Reviewed-on: https://code.wireshark.org/review/2794 Reviewed-by: Guy Harris <guy@alum.mit.edu>daniel/osmux
parent
d70e56a733
commit
b4ce352539
|
@ -921,7 +921,6 @@ set(SHARK_COMMON_SRC
|
|||
capture-pcap-util.c
|
||||
cfile.c
|
||||
frame_tvbuff.c
|
||||
${CMAKE_BINARY_DIR}/version.h
|
||||
sync_pipe_write.c
|
||||
version_info.c
|
||||
)
|
||||
|
@ -1221,6 +1220,7 @@ if(BUILD_text2pcap)
|
|||
set(text2pcap_CLEAN_FILES
|
||||
text2pcap.c
|
||||
pcapio.c
|
||||
version_info.c
|
||||
)
|
||||
set(text2pcap_FILES
|
||||
${text2pcap_CLEAN_FILES}
|
||||
|
@ -1245,7 +1245,7 @@ if(BUILD_mergecap)
|
|||
)
|
||||
set(mergecap_FILES
|
||||
mergecap.c
|
||||
${CMAKE_BINARY_DIR}/version.h
|
||||
version_info.c
|
||||
image/mergecap.rc
|
||||
)
|
||||
add_executable(mergecap ${mergecap_FILES})
|
||||
|
@ -1264,7 +1264,7 @@ if(BUILD_reordercap)
|
|||
)
|
||||
set(reordercap_FILES
|
||||
reordercap.c
|
||||
${CMAKE_BINARY_DIR}/version.h
|
||||
version_info.c
|
||||
image/reordercap.rc
|
||||
)
|
||||
add_executable(reordercap ${reordercap_FILES})
|
||||
|
@ -1285,6 +1285,7 @@ if(BUILD_capinfos)
|
|||
)
|
||||
set(capinfos_FILES
|
||||
capinfos.c
|
||||
version_info.c
|
||||
image/capinfos.rc
|
||||
)
|
||||
add_executable(capinfos ${capinfos_FILES})
|
||||
|
@ -1322,6 +1323,7 @@ if(BUILD_editcap)
|
|||
)
|
||||
set(editcap_FILES
|
||||
editcap.c
|
||||
version_info.c
|
||||
image/editcap.rc
|
||||
)
|
||||
add_executable(editcap ${editcap_FILES})
|
||||
|
@ -1347,7 +1349,6 @@ if(BUILD_dumpcap AND PCAP_FOUND)
|
|||
${NL_LIBRARIES}
|
||||
)
|
||||
set(dumpcap_FILES
|
||||
${CMAKE_BINARY_DIR}/version.h
|
||||
capture_opts.c
|
||||
capture-pcap-util.c
|
||||
capture_stop_conditions.c
|
||||
|
|
|
@ -50,7 +50,6 @@ SHARK_COMMON_SRC = \
|
|||
|
||||
# corresponding headers
|
||||
SHARK_COMMON_INCLUDES = \
|
||||
version.h \
|
||||
capture-pcap-util.h \
|
||||
capture-pcap-util-int.h \
|
||||
cfile.h \
|
||||
|
@ -107,9 +106,10 @@ rawshark_SOURCES = \
|
|||
|
||||
# text2pcap specifics
|
||||
text2pcap_SOURCES = \
|
||||
pcapio.c \
|
||||
text2pcap.c \
|
||||
text2pcap-scanner.l
|
||||
pcapio.c \
|
||||
text2pcap.c \
|
||||
text2pcap-scanner.l \
|
||||
version_info.c
|
||||
|
||||
text2pcap_INCLUDES = \
|
||||
pcapio.h \
|
||||
|
@ -117,20 +117,23 @@ text2pcap_INCLUDES = \
|
|||
|
||||
# mergecap specifics
|
||||
mergecap_SOURCES = \
|
||||
mergecap.c
|
||||
mergecap.c \
|
||||
version_info.c
|
||||
|
||||
# editcap specifics
|
||||
editcap_SOURCES = \
|
||||
editcap.c
|
||||
editcap.c \
|
||||
version_info.c
|
||||
|
||||
# reordercap specifics
|
||||
reordercap_SOURCES = \
|
||||
reordercap.c \
|
||||
version.h
|
||||
reordercap.c \
|
||||
version_info.c
|
||||
|
||||
# capinfos specifics
|
||||
capinfos_SOURCES = \
|
||||
capinfos.c
|
||||
capinfos.c \
|
||||
version_info.c
|
||||
|
||||
# captype specifics
|
||||
captype_SOURCES = \
|
||||
|
|
|
@ -551,13 +551,6 @@ text2pcap-scanner.c : text2pcap-scanner.l
|
|||
text2pcap-scanner.obj : text2pcap-scanner.c
|
||||
$(CC) $(GENERATED_CFLAGS) -Fd.\ -c $?
|
||||
|
||||
#
|
||||
# The following targets will rebuild their respective objs
|
||||
# if and when version.h should change.
|
||||
#
|
||||
text2pcap.obj mergecap.obj capinfos.obj captype.obj editcap.obj reordercap.obj: version.h
|
||||
|
||||
|
||||
clean-local:
|
||||
rm -f $(wireshark_OBJECTS) $(tshark_OBJECTS) $(tfshark_OBJECTS) $(dumpcap_OBJECTS) $(rawshark_OBJECTS) \
|
||||
$(EXECUTABLES) *.pdb *.sbr *.exe.manifest \
|
||||
|
|
100
capinfos.c
100
capinfos.c
|
@ -77,8 +77,16 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
#include <zlib.h> /* to get the libz version number */
|
||||
#endif
|
||||
|
||||
#include <wsutil/privileges.h>
|
||||
#include <wsutil/filesystem.h>
|
||||
#include <wsutil/crash_info.h>
|
||||
#include <wsutil/copyright_info.h>
|
||||
#include <wsutil/os_version_info.h>
|
||||
#include <wsutil/ws_version_info.h>
|
||||
|
||||
#ifdef HAVE_PLUGINS
|
||||
#include <wsutil/plugins.h>
|
||||
|
@ -86,7 +94,6 @@
|
|||
|
||||
#include "wtap.h"
|
||||
#include <wsutil/report_err.h>
|
||||
#include <wsutil/privileges.h>
|
||||
#include <wsutil/str_util.h>
|
||||
#include <wsutil/file_util.h>
|
||||
|
||||
|
@ -102,7 +109,7 @@
|
|||
#include <wsutil/unicode-utils.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include "version.h"
|
||||
#include "version_info.h"
|
||||
|
||||
/*
|
||||
* By default capinfos now continues processing
|
||||
|
@ -996,31 +1003,22 @@ process_cap_file(wtap *wth, const char *filename)
|
|||
}
|
||||
|
||||
static void
|
||||
print_version(FILE *output)
|
||||
show_version(GString *comp_info_str, GString *runtime_info_str)
|
||||
{
|
||||
fprintf(output, "Capinfos %s"
|
||||
#ifdef GITVERSION
|
||||
" (" GITVERSION " from " GITBRANCH ")"
|
||||
#endif
|
||||
"\n", VERSION);
|
||||
printf("Capinfos (Wireshark) %s\n"
|
||||
"\n"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s",
|
||||
get_ws_vcs_version_info(), get_copyright_info(),
|
||||
comp_info_str->str, runtime_info_str->str);
|
||||
}
|
||||
|
||||
static void
|
||||
usage(gboolean is_error)
|
||||
print_usage(FILE *output)
|
||||
{
|
||||
FILE *output;
|
||||
|
||||
if (!is_error) {
|
||||
output = stdout;
|
||||
/* XXX - add capinfos header info here */
|
||||
}
|
||||
else {
|
||||
output = stderr;
|
||||
}
|
||||
|
||||
print_version(output);
|
||||
fprintf(output, "Prints various information (infos) about capture files.\n");
|
||||
fprintf(output, "See http://www.wireshark.org for more information.\n");
|
||||
fprintf(output, "\n");
|
||||
fprintf(output, "Usage: capinfos [options] <infile> ...\n");
|
||||
fprintf(output, "\n");
|
||||
|
@ -1107,9 +1105,37 @@ hash_to_str(const unsigned char *hash, size_t length, char *str) {
|
|||
}
|
||||
#endif /* HAVE_LIBGCRYPT */
|
||||
|
||||
static void
|
||||
get_capinfos_compiled_info(GString *str)
|
||||
{
|
||||
/* LIBZ */
|
||||
g_string_append(str, ", ");
|
||||
#ifdef HAVE_LIBZ
|
||||
g_string_append(str, "with libz ");
|
||||
#ifdef ZLIB_VERSION
|
||||
g_string_append(str, ZLIB_VERSION);
|
||||
#else /* ZLIB_VERSION */
|
||||
g_string_append(str, "(version unknown)");
|
||||
#endif /* ZLIB_VERSION */
|
||||
#else /* HAVE_LIBZ */
|
||||
g_string_append(str, "without libz");
|
||||
#endif /* HAVE_LIBZ */
|
||||
}
|
||||
|
||||
static void
|
||||
get_capinfos_runtime_info(GString *str)
|
||||
{
|
||||
/* zlib */
|
||||
#if defined(HAVE_LIBZ) && !defined(_WIN32)
|
||||
g_string_append_printf(str, ", with libz %s", zlibVersion());
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
GString *comp_info_str;
|
||||
GString *runtime_info_str;
|
||||
wtap *wth;
|
||||
int err;
|
||||
gchar *err_info;
|
||||
|
@ -1132,6 +1158,22 @@ main(int argc, char *argv[])
|
|||
size_t hash_bytes;
|
||||
#endif
|
||||
|
||||
/* Assemble the compile-time version information string */
|
||||
comp_info_str = g_string_new("Compiled ");
|
||||
get_compiled_version_info(comp_info_str, NULL, get_capinfos_compiled_info);
|
||||
|
||||
/* Assemble the run-time version information string */
|
||||
runtime_info_str = g_string_new("Running ");
|
||||
get_runtime_version_info(runtime_info_str, get_capinfos_runtime_info);
|
||||
|
||||
/* Add it to the information to be reported on a crash. */
|
||||
ws_add_crash_info("Capinfos (Wireshark) %s\n"
|
||||
"\n"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s",
|
||||
get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str);
|
||||
|
||||
#ifdef _WIN32
|
||||
arg_list_utf_16to8(argc, argv);
|
||||
create_app_running_mutex();
|
||||
|
@ -1363,17 +1405,23 @@ main(int argc, char *argv[])
|
|||
break;
|
||||
|
||||
case 'h':
|
||||
usage(FALSE);
|
||||
printf("Capinfos (Wireshark) %s\n"
|
||||
"Print various information (infos) about capture files.\n"
|
||||
"See http://www.wireshark.org for more information.\n",
|
||||
get_ws_vcs_version_info());
|
||||
print_usage(stdout);
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
print_version(stdout);
|
||||
show_version(comp_info_str, runtime_info_str);
|
||||
g_string_free(comp_info_str, TRUE);
|
||||
g_string_free(runtime_info_str, TRUE);
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
case '?': /* Bad flag - print usage message */
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
|
@ -1383,7 +1431,7 @@ main(int argc, char *argv[])
|
|||
setlocale(LC_ALL, "");
|
||||
|
||||
if ((argc - optind) < 1) {
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
66
dumpcap.c
66
dumpcap.c
|
@ -556,14 +556,12 @@ print_usage(FILE *output)
|
|||
static void
|
||||
show_version(GString *comp_info_str, GString *runtime_info_str)
|
||||
{
|
||||
printf(
|
||||
"Dumpcap (Wireshark) %s\n"
|
||||
"\n"
|
||||
"%s\n"
|
||||
"%s\n"
|
||||
"%s\n"
|
||||
"See http://www.wireshark.org for more information.\n",
|
||||
get_ws_vcs_version_info(), get_copyright_info(), comp_info_str->str, runtime_info_str->str);
|
||||
printf("Dumpcap (Wireshark) %s\n"
|
||||
"\n"
|
||||
"%s\n"
|
||||
"%s\n"
|
||||
"%s",
|
||||
get_ws_vcs_version_info(), get_copyright_info(), comp_info_str->str, runtime_info_str->str);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4156,6 +4154,56 @@ out:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
get_dumpcap_compiled_info(GString *str)
|
||||
{
|
||||
/* Libpcap */
|
||||
g_string_append(str, ", ");
|
||||
get_compiled_pcap_version(str);
|
||||
|
||||
/* LIBZ */
|
||||
g_string_append(str, ", ");
|
||||
#ifdef HAVE_LIBZ
|
||||
g_string_append(str, "with libz ");
|
||||
#ifdef ZLIB_VERSION
|
||||
g_string_append(str, ZLIB_VERSION);
|
||||
#else /* ZLIB_VERSION */
|
||||
g_string_append(str, "(version unknown)");
|
||||
#endif /* ZLIB_VERSION */
|
||||
#else /* HAVE_LIBZ */
|
||||
g_string_append(str, "without libz");
|
||||
#endif /* HAVE_LIBZ */
|
||||
|
||||
#ifndef _WIN32
|
||||
/* This is UN*X-only. */
|
||||
/* LIBCAP */
|
||||
g_string_append(str, ", ");
|
||||
#ifdef HAVE_LIBCAP
|
||||
g_string_append(str, "with POSIX capabilities");
|
||||
#ifdef _LINUX_CAPABILITY_VERSION
|
||||
g_string_append(str, " (Linux)");
|
||||
#endif /* _LINUX_CAPABILITY_VERSION */
|
||||
#else /* HAVE_LIBCAP */
|
||||
g_string_append(str, "without POSIX capabilities");
|
||||
#endif /* HAVE_LIBCAP */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifdef __linux__
|
||||
/* This is a Linux-specific library. */
|
||||
/* LIBNL */
|
||||
g_string_append(str, ", ");
|
||||
#if defined(HAVE_LIBNL1)
|
||||
g_string_append(str, "with libnl 1");
|
||||
#elif defined(HAVE_LIBNL2)
|
||||
g_string_append(str, "with libnl 2");
|
||||
#elif defined(HAVE_LIBNL3)
|
||||
g_string_append(str, "with libnl 3");
|
||||
#else /* no libnl */
|
||||
g_string_append(str, "without libnl");
|
||||
#endif /* libnl version */
|
||||
#endif /* __linux__ */
|
||||
}
|
||||
|
||||
static void
|
||||
get_dumpcap_runtime_info(GString *str)
|
||||
{
|
||||
|
@ -4216,7 +4264,7 @@ main(int argc, char *argv[])
|
|||
|
||||
/* Assemble the compile-time version information string */
|
||||
comp_info_str = g_string_new("Compiled ");
|
||||
get_compiled_version_info(comp_info_str, NULL, NULL);
|
||||
get_compiled_version_info(comp_info_str, NULL, get_dumpcap_compiled_info);
|
||||
|
||||
/* Assemble the run-time version information string */
|
||||
runtime_info_str = g_string_new("Running ");
|
||||
|
|
102
editcap.c
102
editcap.c
|
@ -58,6 +58,10 @@
|
|||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
#include <zlib.h> /* to get the libz version number */
|
||||
#endif
|
||||
|
||||
#include "wtap.h"
|
||||
|
||||
#ifndef HAVE_GETOPT
|
||||
|
@ -83,8 +87,12 @@
|
|||
#include <wsutil/strnatcmp.h>
|
||||
#include <wsutil/md5.h>
|
||||
#include <wsutil/plugins.h>
|
||||
#include <wsutil/crash_info.h>
|
||||
#include <wsutil/copyright_info.h>
|
||||
#include <wsutil/os_version_info.h>
|
||||
#include <wsutil/ws_version_info.h>
|
||||
|
||||
#include "version.h"
|
||||
#include "version_info.h"
|
||||
|
||||
#include "ringbuffer.h" /* For RINGBUFFER_MAX_NUM_FILES */
|
||||
|
||||
|
@ -662,28 +670,22 @@ is_duplicate_rel_time(guint8* fd, guint32 len, const nstime_t *current) {
|
|||
}
|
||||
|
||||
static void
|
||||
print_version(FILE *output)
|
||||
show_version(GString *comp_info_str, GString *runtime_info_str)
|
||||
{
|
||||
fprintf(output, "Editcap %s"
|
||||
#ifdef GITVERSION
|
||||
" (" GITVERSION " from " GITBRANCH ")"
|
||||
#endif
|
||||
"\n", VERSION);
|
||||
printf("Editcap (Wireshark) %s\n"
|
||||
"\n"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s",
|
||||
get_ws_vcs_version_info(), get_copyright_info(),
|
||||
comp_info_str->str, runtime_info_str->str);
|
||||
}
|
||||
|
||||
static void
|
||||
usage(gboolean is_error)
|
||||
print_usage(FILE *output)
|
||||
{
|
||||
FILE *output;
|
||||
|
||||
if (!is_error)
|
||||
output = stdout;
|
||||
else
|
||||
output = stderr;
|
||||
|
||||
print_version(output);
|
||||
fprintf(output, "Edit and/or translate the format of capture files.\n");
|
||||
fprintf(output, "See http://www.wireshark.org for more information.\n");
|
||||
fprintf(output, "\n");
|
||||
fprintf(output, "Usage: editcap [options] ... <infile> <outfile> [ <packet#>[-<packet#>] ... ]\n");
|
||||
fprintf(output, "\n");
|
||||
|
@ -839,9 +841,37 @@ failure_message(const char *msg_format _U_, va_list ap _U_)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
get_editcap_compiled_info(GString *str)
|
||||
{
|
||||
/* LIBZ */
|
||||
g_string_append(str, ", ");
|
||||
#ifdef HAVE_LIBZ
|
||||
g_string_append(str, "with libz ");
|
||||
#ifdef ZLIB_VERSION
|
||||
g_string_append(str, ZLIB_VERSION);
|
||||
#else /* ZLIB_VERSION */
|
||||
g_string_append(str, "(version unknown)");
|
||||
#endif /* ZLIB_VERSION */
|
||||
#else /* HAVE_LIBZ */
|
||||
g_string_append(str, "without libz");
|
||||
#endif /* HAVE_LIBZ */
|
||||
}
|
||||
|
||||
static void
|
||||
get_editcap_runtime_info(GString *str)
|
||||
{
|
||||
/* zlib */
|
||||
#if defined(HAVE_LIBZ) && !defined(_WIN32)
|
||||
g_string_append_printf(str, ", with libz %s", zlibVersion());
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
GString *comp_info_str;
|
||||
GString *runtime_info_str;
|
||||
wtap *wth;
|
||||
int i, j, err;
|
||||
gchar *err_info;
|
||||
|
@ -887,9 +917,25 @@ main(int argc, char *argv[])
|
|||
create_app_running_mutex();
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/*
|
||||
* Get credential information for later use.
|
||||
*/
|
||||
/* Assemble the compile-time version information string */
|
||||
comp_info_str = g_string_new("Compiled ");
|
||||
get_compiled_version_info(comp_info_str, NULL, get_editcap_compiled_info);
|
||||
|
||||
/* Assemble the run-time version information string */
|
||||
runtime_info_str = g_string_new("Running ");
|
||||
get_runtime_version_info(runtime_info_str, get_editcap_runtime_info);
|
||||
|
||||
/* Add it to the information to be reported on a crash. */
|
||||
ws_add_crash_info("Editcap (Wireshark) %s\n"
|
||||
"\n"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s",
|
||||
get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str);
|
||||
|
||||
/*
|
||||
* Get credential information for later use.
|
||||
*/
|
||||
init_process_policies();
|
||||
init_open_routines();
|
||||
|
||||
|
@ -1045,7 +1091,11 @@ main(int argc, char *argv[])
|
|||
break;
|
||||
|
||||
case 'h':
|
||||
usage(FALSE);
|
||||
printf("Editcap (Wireshark) %s\n"
|
||||
"Edit and/or translate the format of capture files.\n"
|
||||
"See http://www.wireshark.org for more information.\n",
|
||||
get_ws_vcs_version_info());
|
||||
print_usage(stdout);
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
|
@ -1099,7 +1149,9 @@ main(int argc, char *argv[])
|
|||
break;
|
||||
|
||||
case 'V':
|
||||
print_version(stdout);
|
||||
show_version(comp_info_str, runtime_info_str);
|
||||
g_string_free(comp_info_str, TRUE);
|
||||
g_string_free(runtime_info_str, TRUE);
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
|
@ -1119,7 +1171,7 @@ main(int argc, char *argv[])
|
|||
list_encap_types();
|
||||
break;
|
||||
default:
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
break;
|
||||
}
|
||||
exit(1);
|
||||
|
@ -1132,7 +1184,7 @@ main(int argc, char *argv[])
|
|||
#endif
|
||||
|
||||
if ((argc - optind) < 1) {
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
96
mergecap.c
96
mergecap.c
|
@ -42,6 +42,10 @@
|
|||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
#include <zlib.h> /* to get the libz version number */
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include "wtap.h"
|
||||
|
||||
|
@ -51,10 +55,14 @@
|
|||
|
||||
#include <wsutil/strnatcmp.h>
|
||||
#include <wsutil/file_util.h>
|
||||
#include <wsutil/crash_info.h>
|
||||
#include <wsutil/copyright_info.h>
|
||||
#include <wsutil/os_version_info.h>
|
||||
#include <wsutil/ws_version_info.h>
|
||||
|
||||
#include <wiretap/merge.h>
|
||||
|
||||
#include "version.h"
|
||||
#include "version_info.h"
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
|
@ -104,33 +112,25 @@ get_positive_int(const char *string, const char *name)
|
|||
}
|
||||
|
||||
static void
|
||||
print_version(FILE *output)
|
||||
show_version(GString *comp_info_str, GString *runtime_info_str)
|
||||
{
|
||||
fprintf(output, "Mergecap %s"
|
||||
#ifdef GITVERSION
|
||||
" (" GITVERSION " from " GITBRANCH ")"
|
||||
#endif
|
||||
"\n", VERSION);
|
||||
printf("Mergecap (Wireshark) %s\n"
|
||||
"\n"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s",
|
||||
get_ws_vcs_version_info(), get_copyright_info(),
|
||||
comp_info_str->str, runtime_info_str->str);
|
||||
}
|
||||
|
||||
/*
|
||||
* Show the usage
|
||||
*/
|
||||
static void
|
||||
usage(gboolean is_error)
|
||||
print_usage(FILE *output)
|
||||
{
|
||||
FILE *output;
|
||||
|
||||
if (!is_error) {
|
||||
output = stdout;
|
||||
}
|
||||
else {
|
||||
output = stderr;
|
||||
}
|
||||
|
||||
print_version(output);
|
||||
fprintf(output, "Merge two or more capture files into one.\n");
|
||||
fprintf(output, "See http://www.wireshark.org for more information.\n");
|
||||
fprintf(output, "\n");
|
||||
fprintf(output, "Usage: mergecap [options] -w <outfile>|- <infile> [<infile> ...]\n");
|
||||
fprintf(output, "\n");
|
||||
|
@ -217,9 +217,37 @@ list_encap_types(void) {
|
|||
g_free(encaps);
|
||||
}
|
||||
|
||||
static void
|
||||
get_mergecap_compiled_info(GString *str)
|
||||
{
|
||||
/* LIBZ */
|
||||
g_string_append(str, ", ");
|
||||
#ifdef HAVE_LIBZ
|
||||
g_string_append(str, "with libz ");
|
||||
#ifdef ZLIB_VERSION
|
||||
g_string_append(str, ZLIB_VERSION);
|
||||
#else /* ZLIB_VERSION */
|
||||
g_string_append(str, "(version unknown)");
|
||||
#endif /* ZLIB_VERSION */
|
||||
#else /* HAVE_LIBZ */
|
||||
g_string_append(str, "without libz");
|
||||
#endif /* HAVE_LIBZ */
|
||||
}
|
||||
|
||||
static void
|
||||
get_mergecap_runtime_info(GString *str)
|
||||
{
|
||||
/* zlib */
|
||||
#if defined(HAVE_LIBZ) && !defined(_WIN32)
|
||||
g_string_append_printf(str, ", with libz %s", zlibVersion());
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
GString *comp_info_str;
|
||||
GString *runtime_info_str;
|
||||
int opt;
|
||||
static const struct option long_options[] = {
|
||||
{(char *)"help", no_argument, NULL, 'h'},
|
||||
|
@ -253,6 +281,22 @@ main(int argc, char *argv[])
|
|||
create_app_running_mutex();
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/* Assemble the compile-time version information string */
|
||||
comp_info_str = g_string_new("Compiled ");
|
||||
get_compiled_version_info(comp_info_str, NULL, get_mergecap_compiled_info);
|
||||
|
||||
/* Assemble the run-time version information string */
|
||||
runtime_info_str = g_string_new("Running ");
|
||||
get_runtime_version_info(runtime_info_str, get_mergecap_runtime_info);
|
||||
|
||||
/* Add it to the information to be reported on a crash. */
|
||||
ws_add_crash_info("Mergecap (Wireshark) %s\n"
|
||||
"\n"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s",
|
||||
get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str);
|
||||
|
||||
/* Process the options first */
|
||||
while ((opt = getopt_long(argc, argv, "aF:hs:T:vVw:", long_options, NULL)) != -1) {
|
||||
|
||||
|
@ -272,7 +316,11 @@ main(int argc, char *argv[])
|
|||
break;
|
||||
|
||||
case 'h':
|
||||
usage(FALSE);
|
||||
printf("Mergecap (Wireshark) %s\n"
|
||||
"Merge two or more capture files into one.\n"
|
||||
"See http://www.wireshark.org for more information.\n",
|
||||
get_ws_vcs_version_info());
|
||||
print_usage(stdout);
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
|
@ -295,7 +343,9 @@ main(int argc, char *argv[])
|
|||
break;
|
||||
|
||||
case 'V':
|
||||
print_version(stdout);
|
||||
show_version(comp_info_str, runtime_info_str);
|
||||
g_string_free(comp_info_str, TRUE);
|
||||
g_string_free(runtime_info_str, TRUE);
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
|
@ -312,7 +362,7 @@ main(int argc, char *argv[])
|
|||
list_encap_types();
|
||||
break;
|
||||
default:
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
}
|
||||
exit(1);
|
||||
break;
|
||||
|
|
100
reordercap.c
100
reordercap.c
|
@ -36,40 +36,43 @@
|
|||
#include <getopt.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
#include <zlib.h> /* to get the libz version number */
|
||||
#endif
|
||||
|
||||
#include "wtap.h"
|
||||
|
||||
#ifndef HAVE_GETOPT
|
||||
#include "wsutil/wsgetopt.h"
|
||||
#endif
|
||||
|
||||
#include "version.h"
|
||||
#include <wsutil/strnatcmp.h>
|
||||
#include <wsutil/file_util.h>
|
||||
#include <wsutil/crash_info.h>
|
||||
#include <wsutil/copyright_info.h>
|
||||
#include <wsutil/os_version_info.h>
|
||||
#include <wsutil/ws_version_info.h>
|
||||
|
||||
#include "version_info.h"
|
||||
|
||||
static void
|
||||
print_version(FILE *output)
|
||||
show_version(GString *comp_info_str, GString *runtime_info_str)
|
||||
{
|
||||
fprintf(output, "Reordercap %s"
|
||||
#ifdef GITVERSION
|
||||
" (" GITVERSION " from " GITBRANCH ")"
|
||||
#endif
|
||||
"\n", VERSION);
|
||||
printf("Reordercap (Wireshark) %s\n"
|
||||
"\n"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s",
|
||||
get_ws_vcs_version_info(), get_copyright_info(),
|
||||
comp_info_str->str, runtime_info_str->str);
|
||||
}
|
||||
|
||||
/* Show command-line usage */
|
||||
static void
|
||||
usage(gboolean is_error)
|
||||
print_usage(FILE *output)
|
||||
{
|
||||
FILE *output;
|
||||
|
||||
if (!is_error) {
|
||||
output = stdout;
|
||||
}
|
||||
else {
|
||||
output = stderr;
|
||||
}
|
||||
|
||||
print_version(output);
|
||||
fprintf(output, "Reorder timestamps of input file frames into output file.\n");
|
||||
fprintf(output, "See http://www.wireshark.org for more information.\n");
|
||||
fprintf(output, "\n");
|
||||
fprintf(output, "Usage: reordercap [options] <infile> <outfile>\n");
|
||||
fprintf(output, "\n");
|
||||
|
@ -164,6 +167,31 @@ frames_compare(gconstpointer a, gconstpointer b)
|
|||
return nstime_cmp(time1, time2);
|
||||
}
|
||||
|
||||
static void
|
||||
get_reordercap_compiled_info(GString *str)
|
||||
{
|
||||
/* LIBZ */
|
||||
g_string_append(str, ", ");
|
||||
#ifdef HAVE_LIBZ
|
||||
g_string_append(str, "with libz ");
|
||||
#ifdef ZLIB_VERSION
|
||||
g_string_append(str, ZLIB_VERSION);
|
||||
#else /* ZLIB_VERSION */
|
||||
g_string_append(str, "(version unknown)");
|
||||
#endif /* ZLIB_VERSION */
|
||||
#else /* HAVE_LIBZ */
|
||||
g_string_append(str, "without libz");
|
||||
#endif /* HAVE_LIBZ */
|
||||
}
|
||||
|
||||
static void
|
||||
get_reordercap_runtime_info(GString *str)
|
||||
{
|
||||
/* zlib */
|
||||
#if defined(HAVE_LIBZ) && !defined(_WIN32)
|
||||
g_string_append_printf(str, ", with libz %s", zlibVersion());
|
||||
#endif
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
/* Main function. */
|
||||
|
@ -171,6 +199,8 @@ frames_compare(gconstpointer a, gconstpointer b)
|
|||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
GString *comp_info_str;
|
||||
GString *runtime_info_str;
|
||||
wtap *wth = NULL;
|
||||
wtap_dumper *pdh = NULL;
|
||||
Buffer buf;
|
||||
|
@ -197,6 +227,22 @@ main(int argc, char *argv[])
|
|||
char *infile;
|
||||
char *outfile;
|
||||
|
||||
/* Assemble the compile-time version information string */
|
||||
comp_info_str = g_string_new("Compiled ");
|
||||
get_compiled_version_info(comp_info_str, NULL, get_reordercap_compiled_info);
|
||||
|
||||
/* Assemble the run-time version information string */
|
||||
runtime_info_str = g_string_new("Running ");
|
||||
get_runtime_version_info(runtime_info_str, get_reordercap_runtime_info);
|
||||
|
||||
/* Add it to the information to be reported on a crash. */
|
||||
ws_add_crash_info("Reordercap (Wireshark) %s\n"
|
||||
"\n"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s",
|
||||
get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str);
|
||||
|
||||
/* Process the options first */
|
||||
while ((opt = getopt_long(argc, argv, "hnv", long_options, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
|
@ -204,13 +250,19 @@ main(int argc, char *argv[])
|
|||
write_output_regardless = FALSE;
|
||||
break;
|
||||
case 'h':
|
||||
usage(FALSE);
|
||||
printf("Reordercap (Wireshark) %s\n"
|
||||
"Reorder timestamps of input file frames into output file.\n"
|
||||
"See http://www.wireshark.org for more information.\n",
|
||||
get_ws_vcs_version_info());
|
||||
print_usage(stdout);
|
||||
exit(0);
|
||||
case 'v':
|
||||
print_version(stdout);
|
||||
show_version(comp_info_str, runtime_info_str);
|
||||
g_string_free(comp_info_str, TRUE);
|
||||
g_string_free(runtime_info_str, TRUE);
|
||||
exit(0);
|
||||
case '?':
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +274,7 @@ main(int argc, char *argv[])
|
|||
outfile = argv[optind+1];
|
||||
}
|
||||
else {
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
180
text2pcap.c
180
text2pcap.c
|
@ -112,6 +112,10 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wsutil/file_util.h>
|
||||
#include <wsutil/crash_info.h>
|
||||
#include <wsutil/copyright_info.h>
|
||||
#include <wsutil/os_version_info.h>
|
||||
#include <wsutil/ws_version_info.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <glib.h>
|
||||
|
@ -127,6 +131,10 @@
|
|||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
#include <zlib.h> /* to get the libz version number */
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETOPT
|
||||
#include "wsutil/wsgetopt.h"
|
||||
#endif
|
||||
|
@ -137,7 +145,7 @@
|
|||
|
||||
#include "pcapio.h"
|
||||
#include "text2pcap.h"
|
||||
#include "version.h"
|
||||
#include "version_info.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <wsutil/unicode-utils.h>
|
||||
|
@ -1425,34 +1433,26 @@ fail_null_str:
|
|||
}
|
||||
|
||||
static void
|
||||
print_version(FILE *output)
|
||||
show_version(GString *comp_info_str, GString *runtime_info_str)
|
||||
{
|
||||
fprintf(output, "Text2pcap %s"
|
||||
#ifdef GITVERSION
|
||||
" (" GITVERSION " from " GITBRANCH ")"
|
||||
#endif
|
||||
"\n", VERSION);
|
||||
printf("Text2pcap (Wireshark) %s\n"
|
||||
"\n"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s",
|
||||
get_ws_vcs_version_info(), get_copyright_info(),
|
||||
comp_info_str->str, runtime_info_str->str);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Print usage string and exit
|
||||
*/
|
||||
static void
|
||||
usage (gboolean is_error)
|
||||
print_usage (FILE *output)
|
||||
{
|
||||
FILE *output;
|
||||
|
||||
if (!is_error) {
|
||||
output = stdout;
|
||||
}
|
||||
else {
|
||||
output = stderr;
|
||||
}
|
||||
|
||||
print_version(output);
|
||||
fprintf(output,
|
||||
"Generate a capture file from an ASCII hexdump of packets.\n"
|
||||
"See http://www.wireshark.org for more information.\n"
|
||||
"\n"
|
||||
"Usage: text2pcap [options] <infile> <outfile>\n"
|
||||
"\n"
|
||||
|
@ -1531,8 +1531,32 @@ usage (gboolean is_error)
|
|||
" -n use PCAP-NG instead of PCAP as output format.\n"
|
||||
"",
|
||||
MAX_PACKET);
|
||||
}
|
||||
|
||||
exit(is_error ? 1 : 0);
|
||||
static void
|
||||
get_text2pcap_compiled_info(GString *str)
|
||||
{
|
||||
/* LIBZ */
|
||||
g_string_append(str, ", ");
|
||||
#ifdef HAVE_LIBZ
|
||||
g_string_append(str, "with libz ");
|
||||
#ifdef ZLIB_VERSION
|
||||
g_string_append(str, ZLIB_VERSION);
|
||||
#else /* ZLIB_VERSION */
|
||||
g_string_append(str, "(version unknown)");
|
||||
#endif /* ZLIB_VERSION */
|
||||
#else /* HAVE_LIBZ */
|
||||
g_string_append(str, "without libz");
|
||||
#endif /* HAVE_LIBZ */
|
||||
}
|
||||
|
||||
static void
|
||||
get_text2pcap_runtime_info(GString *str)
|
||||
{
|
||||
/* zlib */
|
||||
#if defined(HAVE_LIBZ) && !defined(_WIN32)
|
||||
g_string_append_printf(str, ", with libz %s", zlibVersion());
|
||||
#endif
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
|
@ -1541,6 +1565,8 @@ usage (gboolean is_error)
|
|||
static void
|
||||
parse_options (int argc, char *argv[])
|
||||
{
|
||||
GString *comp_info_str;
|
||||
GString *runtime_info_str;
|
||||
int c;
|
||||
char *p;
|
||||
static const struct option long_options[] = {
|
||||
|
@ -1554,11 +1580,33 @@ parse_options (int argc, char *argv[])
|
|||
create_app_running_mutex();
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/* Assemble the compile-time version information string */
|
||||
comp_info_str = g_string_new("Compiled ");
|
||||
get_compiled_version_info(comp_info_str, NULL, get_text2pcap_compiled_info);
|
||||
|
||||
/* Assemble the run-time version information string */
|
||||
runtime_info_str = g_string_new("Running ");
|
||||
get_runtime_version_info(runtime_info_str, get_text2pcap_runtime_info);
|
||||
|
||||
/* Add it to the information to be reported on a crash. */
|
||||
ws_add_crash_info("Text2pcap (Wireshark) %s\n"
|
||||
"\n"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s",
|
||||
get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str);
|
||||
|
||||
/* Scan CLI parameters */
|
||||
while ((c = getopt_long(argc, argv, "aDdhqe:i:l:m:no:u:s:S:t:T:v4:6:", long_options, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case '?': usage(TRUE); break;
|
||||
case 'h': usage(FALSE); break;
|
||||
case 'h':
|
||||
printf("Text2pcap (Wireshark) %s\n"
|
||||
"Generate a capture file from an ASCII hexdump of packets.\n"
|
||||
"See http://www.wireshark.org for more information.\n",
|
||||
get_ws_vcs_version_info());
|
||||
print_usage(stdout);
|
||||
exit(0);
|
||||
break;
|
||||
case 'd': if (!quiet) debug++; break;
|
||||
case 'D': has_direction = TRUE; break;
|
||||
case 'q': quiet = TRUE; debug = FALSE; break;
|
||||
|
@ -1568,7 +1616,8 @@ parse_options (int argc, char *argv[])
|
|||
case 'o':
|
||||
if (optarg[0] != 'h' && optarg[0] != 'o' && optarg[0] != 'd') {
|
||||
fprintf(stderr, "Bad argument for '-o': %s\n", optarg);
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
switch (optarg[0]) {
|
||||
case 'o': offset_base = 8; break;
|
||||
|
@ -1580,7 +1629,8 @@ parse_options (int argc, char *argv[])
|
|||
hdr_ethernet = TRUE;
|
||||
if (sscanf(optarg, "%x", &hdr_ethernet_proto) < 1) {
|
||||
fprintf(stderr, "Bad argument for '-e': %s\n", optarg);
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1590,7 +1640,8 @@ parse_options (int argc, char *argv[])
|
|||
if (p == optarg || *p != '\0' || hdr_ip_proto < 0 ||
|
||||
hdr_ip_proto > 255) {
|
||||
fprintf(stderr, "Bad argument for '-i': %s\n", optarg);
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
hdr_ethernet = TRUE;
|
||||
hdr_ethernet_proto = 0x800;
|
||||
|
@ -1604,29 +1655,34 @@ parse_options (int argc, char *argv[])
|
|||
hdr_sctp_src = (guint32)strtol(optarg, &p, 10);
|
||||
if (p == optarg || (*p != ',' && *p != '\0')) {
|
||||
fprintf(stderr, "Bad src port for '-%c'\n", c);
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
if (*p == '\0') {
|
||||
fprintf(stderr, "No dest port specified for '-%c'\n", c);
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
p++;
|
||||
optarg = p;
|
||||
hdr_sctp_dest = (guint32)strtol(optarg, &p, 10);
|
||||
if (p == optarg || (*p != ',' && *p != '\0')) {
|
||||
fprintf(stderr, "Bad dest port for '-s'\n");
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
if (*p == '\0') {
|
||||
fprintf(stderr, "No tag specified for '-%c'\n", c);
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
p++;
|
||||
optarg = p;
|
||||
hdr_sctp_tag = (guint32)strtol(optarg, &p, 10);
|
||||
if (p == optarg || *p != '\0') {
|
||||
fprintf(stderr, "Bad tag for '-%c'\n", c);
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
hdr_ip = TRUE;
|
||||
|
@ -1642,29 +1698,34 @@ parse_options (int argc, char *argv[])
|
|||
hdr_sctp_src = (guint32)strtol(optarg, &p, 10);
|
||||
if (p == optarg || (*p != ',' && *p != '\0')) {
|
||||
fprintf(stderr, "Bad src port for '-%c'\n", c);
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
if (*p == '\0') {
|
||||
fprintf(stderr, "No dest port specified for '-%c'\n", c);
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
p++;
|
||||
optarg = p;
|
||||
hdr_sctp_dest = (guint32)strtol(optarg, &p, 10);
|
||||
if (p == optarg || (*p != ',' && *p != '\0')) {
|
||||
fprintf(stderr, "Bad dest port for '-s'\n");
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
if (*p == '\0') {
|
||||
fprintf(stderr, "No ppi specified for '-%c'\n", c);
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
p++;
|
||||
optarg = p;
|
||||
hdr_data_chunk_ppid = (guint32)strtoul(optarg, &p, 10);
|
||||
if (p == optarg || *p != '\0') {
|
||||
fprintf(stderr, "Bad ppi for '-%c'\n", c);
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
hdr_ip = TRUE;
|
||||
|
@ -1685,18 +1746,21 @@ parse_options (int argc, char *argv[])
|
|||
hdr_src_port = (guint32)strtol(optarg, &p, 10);
|
||||
if (p == optarg || (*p != ',' && *p != '\0')) {
|
||||
fprintf(stderr, "Bad src port for '-u'\n");
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
if (*p == '\0') {
|
||||
fprintf(stderr, "No dest port specified for '-u'\n");
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
p++;
|
||||
optarg = p;
|
||||
hdr_dest_port = (guint32)strtol(optarg, &p, 10);
|
||||
if (p == optarg || *p != '\0') {
|
||||
fprintf(stderr, "Bad dest port for '-u'\n");
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
hdr_ip = TRUE;
|
||||
hdr_ip_proto = 17;
|
||||
|
@ -1712,18 +1776,21 @@ parse_options (int argc, char *argv[])
|
|||
hdr_src_port = (guint32)strtol(optarg, &p, 10);
|
||||
if (p == optarg || (*p != ',' && *p != '\0')) {
|
||||
fprintf(stderr, "Bad src port for '-T'\n");
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
if (*p == '\0') {
|
||||
fprintf(stderr, "No dest port specified for '-u'\n");
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
p++;
|
||||
optarg = p;
|
||||
hdr_dest_port = (guint32)strtol(optarg, &p, 10);
|
||||
if (p == optarg || *p != '\0') {
|
||||
fprintf(stderr, "Bad dest port for '-T'\n");
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
hdr_ip = TRUE;
|
||||
hdr_ip_proto = 6;
|
||||
|
@ -1736,7 +1803,9 @@ parse_options (int argc, char *argv[])
|
|||
break;
|
||||
|
||||
case 'v':
|
||||
print_version(stdout);
|
||||
show_version(comp_info_str, runtime_info_str);
|
||||
g_string_free(comp_info_str, TRUE);
|
||||
g_string_free(runtime_info_str, TRUE);
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
|
@ -1746,7 +1815,8 @@ parse_options (int argc, char *argv[])
|
|||
|
||||
if (!p) {
|
||||
fprintf(stderr, "Bad source param addr for '-%c'\n", c);
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
*p = '\0';
|
||||
|
@ -1765,43 +1835,51 @@ parse_options (int argc, char *argv[])
|
|||
if (hdr_ipv6 == TRUE) {
|
||||
if (inet_pton( AF_INET6, optarg, hdr_ipv6_src_addr) <= 0) {
|
||||
fprintf(stderr, "Bad src addr -%c '%s'\n", c, p);
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
if (inet_pton( AF_INET, optarg, &hdr_ip_src_addr) <= 0) {
|
||||
fprintf(stderr, "Bad src addr -%c '%s'\n", c, p);
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
p++;
|
||||
if (*p == '\0') {
|
||||
fprintf(stderr, "No dest addr specified for '-%c'\n", c);
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (hdr_ipv6 == TRUE) {
|
||||
if (inet_pton( AF_INET6, p, hdr_ipv6_dest_addr) <= 0) {
|
||||
fprintf(stderr, "Bad dest addr for -%c '%s'\n", c, p);
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
if (inet_pton( AF_INET, p, &hdr_ip_dest_addr) <= 0) {
|
||||
fprintf(stderr, "Bad dest addr for -%c '%s'\n", c, p);
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case '?':
|
||||
default:
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind >= argc || argc-optind < 2) {
|
||||
fprintf(stderr, "Must specify input and output filename\n");
|
||||
usage(TRUE);
|
||||
print_usage(stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (strcmp(argv[optind], "-")) {
|
||||
|
|
37
tfshark.c
37
tfshark.c
|
@ -50,6 +50,10 @@
|
|||
# include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
#include <zlib.h> /* to get the libz version number */
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETOPT
|
||||
#include "wsutil/wsgetopt.h"
|
||||
#endif
|
||||
|
@ -745,6 +749,34 @@ show_version(GString *comp_info_str, GString *runtime_info_str)
|
|||
runtime_info_str->str);
|
||||
}
|
||||
|
||||
static void
|
||||
get_tfshark_compiled_version_info(GString *str)
|
||||
{
|
||||
/* LIBZ */
|
||||
#ifdef HAVE_LIBZ
|
||||
g_string_append(str, "with libz ");
|
||||
#ifdef ZLIB_VERSION
|
||||
g_string_append(str, ZLIB_VERSION);
|
||||
#else /* ZLIB_VERSION */
|
||||
g_string_append(str, "(version unknown)");
|
||||
#endif /* ZLIB_VERSION */
|
||||
#else /* HAVE_LIBZ */
|
||||
g_string_append(str, "without libz");
|
||||
#endif /* HAVE_LIBZ */
|
||||
}
|
||||
|
||||
static void
|
||||
get_tfshark_runtime_version_info(GString *str)
|
||||
{
|
||||
/* zlib */
|
||||
#if defined(HAVE_LIBZ) && !defined(_WIN32)
|
||||
g_string_append_printf(str, ", with libz %s", zlibVersion());
|
||||
#endif
|
||||
|
||||
/* stuff used by libwireshark */
|
||||
epan_get_runtime_version_info(str);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -817,11 +849,12 @@ main(int argc, char *argv[])
|
|||
|
||||
/* Assemble the compile-time version information string */
|
||||
comp_info_str = g_string_new("Compiled ");
|
||||
get_compiled_version_info(comp_info_str, NULL, epan_get_compiled_version_info);
|
||||
get_compiled_version_info(comp_info_str, get_tfshark_compiled_version_info,
|
||||
epan_get_compiled_version_info);
|
||||
|
||||
/* Assemble the run-time version information string */
|
||||
runtime_info_str = g_string_new("Running ");
|
||||
get_runtime_version_info(runtime_info_str, NULL);
|
||||
get_runtime_version_info(runtime_info_str, get_tfshark_runtime_version_info);
|
||||
|
||||
/* Add it to the information to be reported on a crash. */
|
||||
ws_add_crash_info("TFShark (Wireshark) %s\n"
|
||||
|
|