]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
Introduce LiveGetDevice function
authorEric Leblond <eric@regit.org>
Tue, 3 Jan 2012 09:48:44 +0000 (10:48 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 5 Jan 2012 15:50:27 +0000 (16:50 +0100)
src/util-device.c
src/util-device.h

index 94d48df9a7e902406ec8a42076d877056ae2bcda..7549f3a89a80958154833976ba9249c153abae7b 100644 (file)
@@ -93,6 +93,34 @@ char *LiveGetDeviceName(int number) {
     return NULL;
 }
 
+/**
+ *  \brief Get a pointer to the device at idx
+ *
+ *  \param number idx of the device in our list
+ *
+ *  \retval ptr pointer to the string containing the device
+ *  \retval NULL on error
+ */
+LiveDevice *LiveGetDevice(char *name) {
+    int i = 0;
+    LiveDevice *pd;
+
+    if (name == NULL) {
+        SCLogWarning(SC_ERR_INVALID_VALUE, "Name of device should not be null");
+        return NULL;
+    }
+
+    TAILQ_FOREACH(pd, &live_devices, next) {
+        if (!strcmp(name, pd->dev)) {
+            return pd;
+        }
+
+        i++;
+    }
+
+    return NULL;
+}
+
 
 
 int LiveBuildDeviceList(char * runmode)
index 77b99bd23c6acb575f669fc604660d8462069c5f..ce6997f3b9ac219569eb422bfdba53fd5a80fc19 100644 (file)
@@ -30,6 +30,7 @@ typedef struct LiveDevice_ {
 int LiveRegisterDevice(char *dev);
 int LiveGetDeviceCount(void);
 char *LiveGetDeviceName(int number);
+LiveDevice *LiveGetDevice(char *dev);
 int LiveBuildDeviceList(char * base);
 
 #endif /* __UTIL_DEVICE_H__ */