Skip to content

Commit 6ee6645

Browse files
committed
Add error messages about -C, -G and -z options usage
Also: Replace warning by error messages about -A, -x[x] and -x[x] usage for consistency with those on -f, -r and -V. Update an error message about -f.
1 parent b87e23e commit 6ee6645

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

tcpdump.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,7 +2019,7 @@ main(int argc, char **argv)
20192019
#if defined(HAVE_FORK) || defined(HAVE_VFORK)
20202020
zflag = optarg;
20212021
#else
2022-
warning("-z ignored. Fork subprocess not implemented.\n");
2022+
error("-z cannot be used. Fork subprocess not implemented.\n");
20232023
#endif
20242024
break;
20252025

@@ -2106,11 +2106,19 @@ main(int argc, char **argv)
21062106
}
21072107

21082108
if (ndo->ndo_Aflag && ndo->ndo_xflag)
2109-
warning("-A and -x[x] are mutually exclusive. -A ignored.");
2109+
error("-A and -x[x] are mutually exclusive.");
21102110
if (ndo->ndo_Aflag && ndo->ndo_Xflag)
2111-
warning("-A and -X[X] are mutually exclusive. -A ignored.");
2111+
error("-A and -X[X] are mutually exclusive.");
21122112
if (ndo->ndo_xflag && ndo->ndo_Xflag)
2113-
warning("-x[x] and -X[X] are mutually exclusive. -x[x] ignored.");
2113+
error("-x[x] and -X[X] are mutually exclusive.");
2114+
if (Cflag != 0 && WFileName == NULL)
2115+
error("-C cannot be used without -w.\n");
2116+
if (Gflag != 0 && WFileName == NULL)
2117+
error("-G cannot be used without -w.\n");
2118+
#if defined(HAVE_FORK) || defined(HAVE_VFORK)
2119+
if (zflag != NULL && (WFileName == NULL || (Cflag == 0 && Gflag == 0)))
2120+
error("-z cannot be used without -w and (-C or -G).\n");
2121+
#endif
21142122

21152123
if (cnt != -1)
21162124
if ((int)packets_to_skip > (INT_MAX - cnt))
@@ -2141,7 +2149,7 @@ main(int argc, char **argv)
21412149
}
21422150

21432151
if (ndo->ndo_fflag != 0 && (VFileName != NULL || RFileName != NULL))
2144-
error("-f can not be used with -V or -r");
2152+
error("-f cannot be used with -V or -r.");
21452153

21462154
if (VFileName != NULL && RFileName != NULL)
21472155
error("-V and -r are mutually exclusive.");

0 commit comments

Comments
 (0)