]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
pcap: output cleanups
authorVictor Julien <vjulien@oisf.net>
Sat, 17 Dec 2022 06:26:00 +0000 (07:26 +0100)
committerVictor Julien <vjulien@oisf.net>
Tue, 20 Dec 2022 07:51:33 +0000 (08:51 +0100)
src/source-pcap-file.c
src/suricata.c
src/util-debug.c

index 5730d4ae85c6ca185d11a0eed3326b2459e0fb89..870f8f2d09798266d19a80a72001c225004ebbd7 100644 (file)
@@ -385,8 +385,9 @@ void ReceivePcapFileThreadExitStats(ThreadVars *tv, void *data)
                 SCLogInfo("1/%" PRIu64 "th of packets have an invalid checksum",
                       chrate);
         }
-        SCLogNotice("read %" PRIu64 " files, %" PRIu64 " packets, %" PRIu64 " bytes",
-                ptv->shared.files, ptv->shared.pkts, ptv->shared.bytes);
+        SCLogNotice("read %" PRIu64 " file%s, %" PRIu64 " packets, %" PRIu64 " bytes",
+                ptv->shared.files, ptv->shared.files == 1 ? "" : "s", ptv->shared.pkts,
+                ptv->shared.bytes);
     }
 }
 
index 7de612e049cdd655ecd2a741ee3869cbcaee266b..e62d2357a13ca9006c04a675ed219673c050332b 100644 (file)
@@ -1422,7 +1422,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
             else if(strcmp((long_opts[option_index]).name , "pfring-cluster-id") == 0){
 #ifdef HAVE_PFRING
                 if (ConfSetFinal("pfring.cluster-id", optarg) != 1) {
-                    fprintf(stderr, "ERROR: Failed to set pfring.cluster-id.\n");
+                    SCLogError("failed to set pfring.cluster-id");
                     return TM_ECODE_FAILED;
                 }
 #else
@@ -1434,7 +1434,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
             else if(strcmp((long_opts[option_index]).name , "pfring-cluster-type") == 0){
 #ifdef HAVE_PFRING
                 if (ConfSetFinal("pfring.cluster-type", optarg) != 1) {
-                    fprintf(stderr, "ERROR: Failed to set pfring.cluster-type.\n");
+                    SCLogError("failed to set pfring.cluster-type");
                     return TM_ECODE_FAILED;
                 }
 #else
@@ -1637,7 +1637,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
             } else if (strcmp((long_opts[option_index]).name, "pcap-buffer-size") == 0) {
 #ifdef HAVE_PCAP_SET_BUFF
                 if (ConfSetFinal("pcap.buffer-size", optarg) != 1) {
-                    fprintf(stderr, "ERROR: Failed to set pcap-buffer-size.\n");
+                    SCLogError("failed to set pcap-buffer-size");
                     return TM_ECODE_FAILED;
                 }
 #else
@@ -1729,7 +1729,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
             }
             else if (strcmp((long_opts[option_index]).name, "pcap-file-recursive") == 0) {
                 if (ConfSetFinal("pcap-file.recursive", "true") != 1) {
-                    SCLogError("ERROR: Failed to set pcap-file.recursive");
+                    SCLogError("failed to set pcap-file.recursive");
                     return TM_ECODE_FAILED;
                 }
             }
@@ -1918,7 +1918,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
             struct stat buf;
             if (stat(optarg, &buf) != 0) {
 #endif /* OS_WIN32 */
-                SCLogError("ERROR: Pcap file does not exist\n");
+                SCLogError("pcap file '%s': %s", optarg, strerror(errno));
                 return TM_ECODE_FAILED;
             }
             if (ConfSetFinal("pcap-file.file", optarg) != 1) {
index c26710c6343d9deefb4cae442810064fbc261470..f6c602b0833cabdc085f93e0f44df9644c75c8f6 100644 (file)
@@ -295,6 +295,9 @@ static const char *SCTransformModule(const char *module_name, int *dn_len)
     } else if (strncmp("util-", module_name, 5) == 0) {
         *dn_len = strlen(module_name) - 5;
         return module_name + 5;
+    } else if (strncmp("source-pcap-file", module_name, 16) == 0) {
+        *dn_len = strlen("pcap");
+        return "pcap";
     } else if (strncmp("source-", module_name, 7) == 0) {
         *dn_len = strlen(module_name) - 7;
         return module_name + 7;