]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
xbits: hostbits use xbits type
authorVictor Julien <victor@inliniac.net>
Sat, 20 Dec 2014 09:06:30 +0000 (10:06 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 16 Apr 2015 08:12:39 +0000 (10:12 +0200)
Make hostbits use xbits type.

src/host-bit.c
src/host-bit.h
src/util-var.c

index a70d15bf6e884d16025caa6dc12981e49222f088..ed07e2ffa8941ce70ed913bfd28eb9ee4266789a 100644 (file)
@@ -63,12 +63,12 @@ int HostHasHostBits(Host *host)
 }
 
 /* get the bit with idx from the host */
-static HostBit *HostBitGet(Host *h, uint16_t idx)
+static XBit *HostBitGet(Host *h, uint16_t idx)
 {
     GenericVar *gv = HostGetStorageById(h, host_bit_id);
     for ( ; gv != NULL; gv = gv->next) {
-        if (gv->type == DETECT_HOSTBITS && gv->idx == idx) {
-            return (HostBit *)gv;
+        if (gv->type == DETECT_XBITS && gv->idx == idx) {
+            return (XBit *)gv;
         }
     }
 
@@ -78,13 +78,13 @@ static HostBit *HostBitGet(Host *h, uint16_t idx)
 /* add a flowbit to the flow */
 static void HostBitAdd(Host *h, uint16_t idx)
 {
-    HostBit *fb = HostBitGet(h, idx);
+    XBit *fb = HostBitGet(h, idx);
     if (fb == NULL) {
-        fb = SCMalloc(sizeof(HostBit));
+        fb = SCMalloc(sizeof(XBit));
         if (unlikely(fb == NULL))
             return;
 
-        fb->type = DETECT_HOSTBITS;
+        fb->type = DETECT_XBITS;
         fb->idx = idx;
         fb->next = NULL;
 
@@ -96,7 +96,7 @@ static void HostBitAdd(Host *h, uint16_t idx)
 
 static void HostBitRemove(Host *h, uint16_t idx)
 {
-    HostBit *fb = HostBitGet(h, idx);
+    XBit *fb = HostBitGet(h, idx);
     if (fb == NULL)
         return;
 
@@ -109,7 +109,7 @@ static void HostBitRemove(Host *h, uint16_t idx)
 
 void HostBitSet(Host *h, uint16_t idx)
 {
-    HostBit *fb = HostBitGet(h, idx);
+    XBit *fb = HostBitGet(h, idx);
     if (fb == NULL) {
         HostBitAdd(h, idx);
     }
@@ -117,7 +117,7 @@ void HostBitSet(Host *h, uint16_t idx)
 
 void HostBitUnset(Host *h, uint16_t idx)
 {
-    HostBit *fb = HostBitGet(h, idx);
+    XBit *fb = HostBitGet(h, idx);
     if (fb != NULL) {
         HostBitRemove(h, idx);
     }
@@ -125,7 +125,7 @@ void HostBitUnset(Host *h, uint16_t idx)
 
 void HostBitToggle(Host *h, uint16_t idx)
 {
-    HostBit *fb = HostBitGet(h, idx);
+    XBit *fb = HostBitGet(h, idx);
     if (fb != NULL) {
         HostBitRemove(h, idx);
     } else {
@@ -137,7 +137,7 @@ int HostBitIsset(Host *h, uint16_t idx)
 {
     int r = 0;
 
-    HostBit *fb = HostBitGet(h, idx);
+    XBit *fb = HostBitGet(h, idx);
     if (fb != NULL) {
         r = 1;
     }
@@ -148,7 +148,7 @@ int HostBitIsnotset(Host *h, uint16_t idx)
 {
     int r = 0;
 
-    HostBit *fb = HostBitGet(h, idx);
+    XBit *fb = HostBitGet(h, idx);
     if (fb == NULL) {
         r = 1;
     }
@@ -156,15 +156,6 @@ int HostBitIsnotset(Host *h, uint16_t idx)
     return r;
 }
 
-void HostBitFree(HostBit *fb)
-{
-    if (fb == NULL)
-        return;
-
-    SCFree(fb);
-}
-
-
 /* TESTS */
 #ifdef UNITTESTS
 static int HostBitTest01 (void)
@@ -178,7 +169,7 @@ static int HostBitTest01 (void)
 
     HostBitAdd(h, 0);
 
-    HostBit *fb = HostBitGet(h,0);
+    XBit *fb = HostBitGet(h,0);
     if (fb != NULL)
         ret = 1;
 
@@ -197,7 +188,7 @@ static int HostBitTest02 (void)
     if (h == NULL)
         goto end;
 
-    HostBit *fb = HostBitGet(h,0);
+    XBit *fb = HostBitGet(h,0);
     if (fb == NULL)
         ret = 1;
 
@@ -218,7 +209,7 @@ static int HostBitTest03 (void)
 
     HostBitAdd(h, 0);
 
-    HostBit *fb = HostBitGet(h,0);
+    XBit *fb = HostBitGet(h,0);
     if (fb == NULL) {
         printf("fb == NULL although it was just added: ");
         goto end;
@@ -254,7 +245,7 @@ static int HostBitTest04 (void)
     HostBitAdd(h, 2);
     HostBitAdd(h, 3);
 
-    HostBit *fb = HostBitGet(h,0);
+    XBit *fb = HostBitGet(h,0);
     if (fb != NULL)
         ret = 1;
 
@@ -278,7 +269,7 @@ static int HostBitTest05 (void)
     HostBitAdd(h, 2);
     HostBitAdd(h, 3);
 
-    HostBit *fb = HostBitGet(h,1);
+    XBit *fb = HostBitGet(h,1);
     if (fb != NULL)
         ret = 1;
 
@@ -302,7 +293,7 @@ static int HostBitTest06 (void)
     HostBitAdd(h, 2);
     HostBitAdd(h, 3);
 
-    HostBit *fb = HostBitGet(h,2);
+    XBit *fb = HostBitGet(h,2);
     if (fb != NULL)
         ret = 1;
 
@@ -326,7 +317,7 @@ static int HostBitTest07 (void)
     HostBitAdd(h, 2);
     HostBitAdd(h, 3);
 
-    HostBit *fb = HostBitGet(h,3);
+    XBit *fb = HostBitGet(h,3);
     if (fb != NULL)
         ret = 1;
 
@@ -350,7 +341,7 @@ static int HostBitTest08 (void)
     HostBitAdd(h, 2);
     HostBitAdd(h, 3);
 
-    HostBit *fb = HostBitGet(h,0);
+    XBit *fb = HostBitGet(h,0);
     if (fb == NULL)
         goto end;
 
@@ -383,7 +374,7 @@ static int HostBitTest09 (void)
     HostBitAdd(h, 2);
     HostBitAdd(h, 3);
 
-    HostBit *fb = HostBitGet(h,1);
+    XBit *fb = HostBitGet(h,1);
     if (fb == NULL)
         goto end;
 
@@ -416,7 +407,7 @@ static int HostBitTest10 (void)
     HostBitAdd(h, 2);
     HostBitAdd(h, 3);
 
-    HostBit *fb = HostBitGet(h,2);
+    XBit *fb = HostBitGet(h,2);
     if (fb == NULL)
         goto end;
 
@@ -449,7 +440,7 @@ static int HostBitTest11 (void)
     HostBitAdd(h, 2);
     HostBitAdd(h, 3);
 
-    HostBit *fb = HostBitGet(h,3);
+    XBit *fb = HostBitGet(h,3);
     if (fb == NULL)
         goto end;
 
index c10a4fecf0087007c73d969941eaf39bb96173ae..884ae3b1a5807164cc5c56d147e187ce121f0190 100644 (file)
 #include "host.h"
 #include "util-var.h"
 
-typedef struct HostBit_ {
-    uint8_t type; /* type, DETECT_HOSTBITS in this case */
-    uint16_t idx; /* name idx */
-    GenericVar *next; /* right now just implement this as a list,
-                       * in the long run we have think of something
-                       * faster. */
-} HostBit;
-
 void HostBitInitCtx(void);
-void HostBitFree(HostBit *);
 void HostBitRegisterTests(void);
 
 int HostHasHostBits(Host *host);
index 0ba93deb45010b8cac42fb6f4caf4bd1ce18d5fc..e4e9689b35d9b04bdffcc600dace8e0b9aa265b5 100644 (file)
@@ -60,13 +60,6 @@ void GenericVarFree(GenericVar *gv)
             FlowBitFree(fb);
             break;
         }
-        case DETECT_HOSTBITS:
-        {
-            HostBit *fb = (HostBit *)gv;
-            //printf("GenericVarFree: fb %p, removing\n", fb);
-            HostBitFree(fb);
-            break;
-        }
         case DETECT_XBITS:
         {
             XBit *fb = (XBit *)gv;