]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
suricata: fix computing of default packet size
authorEric Leblond <eric@regit.org>
Sat, 7 Dec 2019 09:43:28 +0000 (10:43 +0100)
committerVictor Julien <victor@inliniac.net>
Mon, 9 Dec 2019 10:12:40 +0000 (11:12 +0100)
Update the default packet size computation to use LiveDeviceName
instead of LiveDevice as the LiveDevice list is not built when
the default packet size is built.

src/suricata.c
src/util-device.c
src/util-device.h

index 886bcba2bbe054c1ada6dca256f896109478125a..f61ab4ad8a9929a8e8de975290b40e834aba6fb3 100644 (file)
@@ -2531,9 +2531,9 @@ static int ConfigGetCaptureValue(SCInstance *suri)
             case RUNMODE_PCAP_DEV:
             case RUNMODE_AFP_DEV:
             case RUNMODE_PFRING:
-                nlive = LiveGetDeviceCount();
+                nlive = LiveGetDeviceNameCount();
                 for (lthread = 0; lthread < nlive; lthread++) {
-                    const char *live_dev = LiveGetDeviceName(lthread);
+                    const char *live_dev = LiveGetDeviceNameName(lthread);
                     char dev[128]; /* need to be able to support GUID names on Windows */
                     (void)strlcpy(dev, live_dev, sizeof(dev));
 
index d6cc5b6b941442ba226655a595a9136ff1449002..4c0779ea6307ed079928c903c6e40103fc0e50ef 100644 (file)
@@ -190,6 +190,49 @@ const char *LiveGetDeviceName(int number)
     return NULL;
 }
 
+/**
+ *  \brief Get the number of pre registered devices
+ *
+ *  \retval cnt the number of pre registered devices
+ */
+int LiveGetDeviceNameCount(void)
+{
+    int i = 0;
+    LiveDeviceName *pd;
+
+    TAILQ_FOREACH(pd, &pre_live_devices, next) {
+        i++;
+    }
+
+    return i;
+}
+
+/**
+ *  \brief Get a pointer to the pre device name at idx
+ *
+ *  \param number idx of the pre device in our list
+ *
+ *  \retval ptr pointer to the string containing the device
+ *  \retval NULL on error
+ */
+const char *LiveGetDeviceNameName(int number)
+{
+    int i = 0;
+    LiveDeviceName *pd;
+
+    TAILQ_FOREACH(pd, &pre_live_devices, next) {
+        if (i == number) {
+            return pd->dev;
+        }
+
+        i++;
+    }
+
+    return NULL;
+}
+
+
+
 /** \internal
  *  \brief Shorten a device name that is to long
  *
index bbb02048f58c72bedd69c6bd1f138a061e03f976..229d00245fa0c65cc9d0a2a434d736e2c490016e 100644 (file)
@@ -63,6 +63,8 @@ typedef struct LiveDeviceName_ {
 void LiveDevRegisterExtension(void);
 
 int LiveRegisterDeviceName(const char *dev);
+int LiveGetDeviceNameCount(void);
+const char *LiveGetDeviceNameName(int number);
 int LiveRegisterDevice(const char *dev);
 int LiveDevUseBypass(LiveDevice *dev);
 void LiveDevSetBypassStats(LiveDevice *dev, uint64_t cnt, int family);