]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
decode/ipv4: unittest to show parsing issue
authorVictor Julien <victor@inliniac.net>
Wed, 18 Sep 2019 10:21:04 +0000 (12:21 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 23 Sep 2019 13:42:13 +0000 (15:42 +0200)
src/decode-ipv4.c

index 09faae8a87123fa5ef7c59fbb3f310d8356bb3e8..8a0bee951cca2091eae1743cfd4224d150e7dc15 100644 (file)
@@ -1631,6 +1631,36 @@ end:
     return result;
 }
 
+/**
+ */
+static int DecodeEthernetTestIPv4Opt(void)
+{
+    uint8_t raw_eth[] = {
+        0xae, 0x71, 0x00, 0x00, 0x00, 0x4b, 0x06, 0x90, 0x61, 0x02, 0x00, 0xcd, 0x88, 0x64, 0x11, 0x00,
+        0x15, 0x00, 0x80, 0x64, 0x00, 0x21, 0x4c, 0x00, 0x00, 0x30, 0x42, 0xd6, 0xff, 0xff, 0xbd, 0x2f,
+        0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+        0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+        0x01, 0x44, 0x05, 0x22, 0x02, 0x01
+    };
+
+    DefragInit();
+
+    Packet *p = SCMalloc(SIZE_OF_PACKET);
+    FAIL_IF_NULL(p);
+    ThreadVars tv;
+    DecodeThreadVars dtv;
+
+    memset(&dtv, 0, sizeof(DecodeThreadVars));
+    memset(&tv,  0, sizeof(ThreadVars));
+    memset(p, 0, SIZE_OF_PACKET);
+
+    DecodeEthernet(&tv, &dtv, p, raw_eth, sizeof(raw_eth), NULL);
+
+    SCFree(p);
+    DefragDestroy();
+    PASS;
+}
+
 #endif /* UNITTESTS */
 
 void DecodeIPV4RegisterTests(void)
@@ -1674,6 +1704,7 @@ void DecodeIPV4RegisterTests(void)
     UtRegisterTest("DecodeIPV4DefragTest01", DecodeIPV4DefragTest01);
     UtRegisterTest("DecodeIPV4DefragTest02", DecodeIPV4DefragTest02);
     UtRegisterTest("DecodeIPV4DefragTest03", DecodeIPV4DefragTest03);
+    UtRegisterTest("DecodeEthernetTestIPv4Opt", DecodeEthernetTestIPv4Opt);
 #endif /* UNITTESTS */
 }
 /**