Skip to content

Commit 9b3eb17

Browse files
committed
Avoid -E and -M options inconsistencies with no libcrypto
The inconsistencies were: -E tcpdump: option requires an argument -- 'E' -E xxx tcpdump: WARNING: crypto code not compiled in -M tcpdump: option requires an argument -- 'M' -M xxx tcpdump: WARNING: crypto code not compiled in
1 parent 1e5d317 commit 9b3eb17

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

tcpdump.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,19 @@ show_remote_devices_and_exit(void)
624624
#define z_FLAG_USAGE
625625
#endif
626626

627-
#define SHORTOPTS "aAbB:c:C:dDeE:fF:G:hHi:I" j_FLAG J_FLAG "KlLm:M:nNOpqQ:r:s:StT:uUvV:w:W:xXy:Y" z_FLAG "Z:#"
627+
#ifdef HAVE_LIBCRYPTO
628+
#define E_FLAG "E:"
629+
#define E_FLAG_USAGE "[ -E algo:secret ] "
630+
#define M_FLAG "M:"
631+
#define M_FLAG_USAGE "[ -M secret ] "
632+
#else
633+
#define E_FLAG
634+
#define E_FLAG_USAGE
635+
#define M_FLAG
636+
#define M_FLAG_USAGE
637+
#endif
638+
639+
#define SHORTOPTS "aAbB:c:C:dDe" E_FLAG "fF:G:hHi:I" j_FLAG J_FLAG "KlLm:" M_FLAG "nNOpqQ:r:s:StT:uUvV:w:W:xXy:Y" z_FLAG "Z:#"
628640

629641
/*
630642
* Long options.
@@ -1775,12 +1787,11 @@ main(int argc, char **argv)
17751787
++ndo->ndo_eflag;
17761788
break;
17771789

1790+
#ifdef HAVE_LIBCRYPTO
17781791
case 'E':
1779-
#ifndef HAVE_LIBCRYPTO
1780-
warning("crypto code not compiled in");
1781-
#endif
17821792
ndo->ndo_espsecret = optarg;
17831793
break;
1794+
#endif
17841795

17851796
case 'f':
17861797
++ndo->ndo_fflag;
@@ -1866,13 +1877,12 @@ main(int argc, char **argv)
18661877
}
18671878
break;
18681879

1880+
#ifdef HAVE_LIBCRYPTO
18691881
case 'M':
18701882
/* TCP-MD5 shared secret */
1871-
#ifndef HAVE_LIBCRYPTO
1872-
warning("crypto code not compiled in");
1873-
#endif
18741883
ndo->ndo_sigsecret = optarg;
18751884
break;
1885+
#endif
18761886

18771887
case 'n':
18781888
++ndo->ndo_nflag;
@@ -3469,7 +3479,7 @@ print_usage(FILE *f)
34693479
(void)fprintf(f,
34703480
"Usage: %s [-AbdDefhHI" J_FLAG "KlLnNOpqStuUvxX#] [ -B size ] [ -c count ] [--count]\n", program_name);
34713481
(void)fprintf(f,
3472-
"\t\t[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]\n");
3482+
"\t\t[ -C file_size ] " E_FLAG_USAGE "[ -F file ] [ -G seconds ]\n");
34733483
(void)fprintf(f,
34743484
"\t\t[ -i interface ]" IMMEDIATE_MODE_USAGE j_FLAG_USAGE "\n");
34753485
(void)fprintf(f,
@@ -3479,7 +3489,7 @@ print_usage(FILE *f)
34793489
"\t\t" m_FLAG_USAGE "\n");
34803490
#endif
34813491
(void)fprintf(f,
3482-
"\t\t[ -M secret ] [ --number ] [ --print ]\n");
3492+
"\t\t" M_FLAG_USAGE "[ --number ] [ --print ]\n");
34833493
(void)fprintf(f,
34843494
"\t\t[ --print-sampling nth ] [ -Q in|out|inout ] [ -r file ]\n");
34853495
(void)fprintf(f,

0 commit comments

Comments
 (0)