]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Add error messages about -C, -G and -z options usage
authorFrancois-Xavier Le Bail <[email protected]>
Sun, 6 Apr 2025 07:25:35 +0000 (09:25 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Mon, 7 Apr 2025 10:22:27 +0000 (12:22 +0200)
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.

(cherry picked from commit 6ee6645b108a5285689672aa3257c207e6d769fa)

tcpdump.c

index 8b155ab293dc3129e8f9e4cbdf3766d84d5b2b05..9edeea74f387a8c383dd3c2b707e738530e3c640 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -2127,7 +2127,7 @@ main(int argc, char **argv)
 #if defined(HAVE_FORK) || defined(HAVE_VFORK)
                        zflag = optarg;
 #else
-                       warning("-z ignored. Fork subprocess not implemented.\n");
+                       error("-z cannot be used. Fork subprocess not implemented.\n");
 #endif
                        break;
 
@@ -2198,11 +2198,19 @@ main(int argc, char **argv)
                }
 
        if (ndo->ndo_Aflag && ndo->ndo_xflag)
-               warning("-A and -x[x] are mutually exclusive. -A ignored.");
+               error("-A and -x[x] are mutually exclusive.");
        if (ndo->ndo_Aflag && ndo->ndo_Xflag)
-               warning("-A and -X[X] are mutually exclusive. -A ignored.");
+               error("-A and -X[X] are mutually exclusive.");
        if (ndo->ndo_xflag && ndo->ndo_Xflag)
-               warning("-x[x] and -X[X] are mutually exclusive. -x[x] ignored.");
+               error("-x[x] and -X[X] are mutually exclusive.");
+       if (Cflag != 0 && WFileName == NULL)
+               error("-C cannot be used without -w.\n");
+       if (Gflag != 0 && WFileName == NULL)
+               error("-G cannot be used without -w.\n");
+#if defined(HAVE_FORK) || defined(HAVE_VFORK)
+       if (zflag != NULL && (WFileName == NULL || (Cflag == 0 && Gflag == 0)))
+               error("-z cannot be used without -w and (-C or -G).\n");
+#endif
 
 #ifdef HAVE_PCAP_FINDALLDEVS
        if (Dflag)
@@ -2229,7 +2237,7 @@ main(int argc, char **argv)
        }
 
        if (ndo->ndo_fflag != 0 && (VFileName != NULL || RFileName != NULL))
-               error("-f can not be used with -V or -r");
+               error("-f cannot be used with -V or -r.");
 
        if (VFileName != NULL && RFileName != NULL)
                error("-V and -r are mutually exclusive.");