diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-06-20 13:59:45 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-06-20 21:00:16 +0000 |
commit | 26bbee3fadc68237801e4ed65b87c97b3cdf3156 (patch) | |
tree | 9fe9f9e7c11733a34797c1c0694f363d060ed696 | |
parent | 312ed10900df878ef8476febe72c8f1308aba106 (diff) | |
download | wireshark-26bbee3fadc68237801e4ed65b87c97b3cdf3156.tar.gz |
Add some long options for capture short options.
The names match tcpdump trunk's names for the corresponding options.
Also have capture_opts.h provide a #define for the part of the short
option string that corresponds to the capture short options that all our
programs that take capture short options take (those are largely the
ones we have in common with tcpdump).
Change-Id: Ia209425959c801725850b56a7d63441ee99b5001
Reviewed-on: https://code.wireshark.org/review/2492
Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r-- | capture_opts.h | 56 | ||||
-rw-r--r-- | dumpcap.c | 23 | ||||
-rw-r--r-- | tshark.c | 22 | ||||
-rw-r--r-- | ui/qt/main.cpp | 3 |
4 files changed, 63 insertions, 41 deletions
diff --git a/capture_opts.h b/capture_opts.h index a48635d68b..afc402e2bc 100644 --- a/capture_opts.h +++ b/capture_opts.h @@ -65,6 +65,62 @@ extern "C" { */ #define MIN_NON_CAPTURE_LONGOPT 129 +/* + * Long options for capturing common to all capturing programs. + */ +#if defined(_WIN32) || defined(HAVE_PCAP_CREATE) +#define LONGOPT_BUFFER_SIZE \ + {(char *)"buffer-size", required_argument, NULL, 'B'}, +#else +#define LONGOPT_BUFFER_SIZE +#endif + +#ifdef HAVE_PCAP_CREATE +#define LONGOPT_MONITOR_MODE {(char *)"monitor-mode", no_argument, NULL, 'I'}, +#else +#define LONGOPT_MONITOR_MODE +#endif + +#define LONGOPT_CAPTURE_COMMON \ + LONGOPT_BUFFER_SIZE \ + {(char *)"list-interfaces", no_argument, NULL, 'D'}, \ + {(char *)"interface", required_argument, NULL, 'i'}, \ + LONGOPT_MONITOR_MODE \ + {(char *)"list-data-link-types", no_argument, NULL, 'L'}, \ + {(char *)"snapshot-length", required_argument, NULL, 's'}, \ + {(char *)"linktype", required_argument, NULL, 'y'} + +/* + * Short options for capturing common to all capturing programs. + */ + +#ifdef HAVE_PCAP_REMOTE +#define OPTSTRING_A "A:" +#else +#define OPTSTRING_A "" +#endif + +#if defined(_WIN32) || defined(HAVE_PCAP_CREATE) +#define OPTSTRING_B "B:" +#else +#define OPTSTRING_B "" +#endif /* _WIN32 or HAVE_PCAP_CREATE */ + +#ifdef HAVE_PCAP_CREATE +#define OPTSTRING_I "I" +#else +#define OPTSTRING_I "" +#endif + +#ifdef HAVE_BPF_IMAGE +#define OPTSTRING_d "d" +#else +#define OPTSTRING_d "" +#endif + +#define OPTSTRING_CAPTURE_COMMON \ + "a:" OPTSTRING_A "b:" OPTSTRING_B "c:Df:i:" OPTSTRING_I "Lps:y:" + #ifdef HAVE_PCAP_REMOTE /* Type of capture source */ typedef enum { @@ -4180,6 +4180,7 @@ main(int argc, char *argv[]) {(char *)"capture-comment", required_argument, NULL, LONGOPT_NUM_CAP_COMMENT }, {(char *)"help", no_argument, NULL, 'h'}, {(char *)"version", no_argument, NULL, 'v'}, + LONGOPT_CAPTURE_COMMON, {0, 0, 0, 0 } }; @@ -4240,11 +4241,9 @@ main(int argc, char *argv[]) #endif #ifdef HAVE_PCAP_REMOTE -#define OPTSTRING_A "A:" #define OPTSTRING_r "r" #define OPTSTRING_u "u" #else -#define OPTSTRING_A "" #define OPTSTRING_r "" #define OPTSTRING_u "" #endif @@ -4255,25 +4254,7 @@ main(int argc, char *argv[]) #define OPTSTRING_m "" #endif -#if defined(_WIN32) || defined(HAVE_PCAP_CREATE) -#define OPTSTRING_B "B:" -#else -#define OPTSTRING_B "" -#endif /* _WIN32 or HAVE_PCAP_CREATE */ - -#ifdef HAVE_PCAP_CREATE -#define OPTSTRING_I "I" -#else -#define OPTSTRING_I "" -#endif - -#ifdef HAVE_BPF_IMAGE -#define OPTSTRING_d "d" -#else -#define OPTSTRING_d "" -#endif - -#define OPTSTRING "a:" OPTSTRING_A "b:" OPTSTRING_B "C:c:" OPTSTRING_d "Df:ghi:" OPTSTRING_I "k:L" OPTSTRING_m "MN:npPq" OPTSTRING_r "Ss:t" OPTSTRING_u "vw:y:Z:" +#define OPTSTRING OPTSTRING_CAPTURE_COMMON "C:" OPTSTRING_d "gh" "k:" OPTSTRING_m "MN:nPq" OPTSTRING_r "St" OPTSTRING_u "vw:Z:" #ifdef DEBUG_CHILD_DUMPCAP if ((debug_log = ws_fopen("dumpcap_debug_log.tmp","w")) == NULL) { @@ -926,6 +926,7 @@ main(int argc, char *argv[]) {(char *)"capture-comment", required_argument, NULL, LONGOPT_NUM_CAP_COMMENT }, {(char *)"help", no_argument, NULL, 'h'}, {(char *)"version", no_argument, NULL, 'v'}, + LONGOPT_CAPTURE_COMMON, {0, 0, 0, 0 } }; gboolean arg_error = FALSE; @@ -973,31 +974,14 @@ main(int argc, char *argv[]) int optind_initial; gchar *output_only = NULL; -#ifdef HAVE_PCAP_REMOTE -#define OPTSTRING_A "A:" -#else -#define OPTSTRING_A "" -#endif -#ifdef HAVE_LIBPCAP -#if defined(_WIN32) || defined(HAVE_PCAP_CREATE) -#define OPTSTRING_B "B:" -#else -#define OPTSTRING_B "" -#endif /* _WIN32 or HAVE_PCAP_CREATE */ -#else /* HAVE_LIBPCAP */ +#ifndef HAVE_LIBPCAP #define OPTSTRING_B "" #endif /* HAVE_LIBPCAP */ -#ifdef HAVE_PCAP_CREATE -#define OPTSTRING_I "I" -#else -#define OPTSTRING_I "" -#endif - /* the leading - ensures that getopt() does not permute the argv[] entries we have to make sure that the first getopt() preserves the content of argv[] for the subsequent getopt_long() call */ -#define OPTSTRING "-2a:" OPTSTRING_A "b:" OPTSTRING_B "c:C:d:De:E:f:F:gG:hH:i:" OPTSTRING_I "K:lLnN:o:O:pPqQr:R:s:S:t:T:u:vVw:W:xX:y:Y:z:" +#define OPTSTRING "-2" OPTSTRING_CAPTURE_COMMON "C:d:e:E:F:gG:hH:" "K:lnN:o:O:PqQr:R:S:t:T:u:vVw:W:xX:Y:z:" static const char optstring[] = OPTSTRING; diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index c91937e846..b0d9fafb7d 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -515,11 +515,12 @@ int main(int argc, char *argv[]) #define OPTSTRING_I "" #endif -#define OPTSTRING "a:b:" OPTSTRING_B "c:C:Df:g:Hhi:" OPTSTRING_I "jJ:kK:lLm:nN:o:P:pQr:R:Ss:t:u:vw:X:y:z:" +#define OPTSTRING OPTSTRING_CAPTURE_COMMON "C:g:Hh" "jJ:kK:lm:nN:o:P:Qr:R:St:u:vw:X:z:" static const struct option long_options[] = { {(char *)"help", no_argument, NULL, 'h'}, {(char *)"read-file", required_argument, NULL, 'r' }, {(char *)"version", no_argument, NULL, 'v'}, + LONGOPT_CAPTURE_COMMON, {0, 0, 0, 0 } }; static const char optstring[] = OPTSTRING; |