]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2404 in SNORT/snort3 from ~MMATIRKO/snort3:rna_cov to master
authorMasud Hasan (mashasan) <mashasan@cisco.com>
Mon, 21 Sep 2020 13:46:44 +0000 (13:46 +0000)
committerMasud Hasan (mashasan) <mashasan@cisco.com>
Mon, 21 Sep 2020 13:46:44 +0000 (13:46 +0000)
Squashed commit of the following:

commit f777a2f58edf5204ea4fa470d1220e80095fcdb9
Author: Michael Matirko <mmatirko@cisco.com>
Date:   Mon Aug 17 12:11:33 2020 -0400

    rna: add unit test to validate VLAN handling

src/network_inspectors/rna/rna_mac_cache.cc

index 06fe2dee32c66b22194c30505f08e57113c88a2d..2195fd512920a415ad3ff7926ed98450b1e30b67 100644 (file)
@@ -96,9 +96,10 @@ void HostTrackerMac::stringify(string& str)
 #ifdef UNIT_TEST
 TEST_CASE("RNA Mac Cache", "[rna_mac_cache]")
 {
+    uint8_t a_mac[6] = {0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6};
+
     SECTION("HostCacheMac: store, retrieve")
     {
-        uint8_t a_mac[6] = {0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6};
         uint8_t b_mac[6] = {0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6};
         uint8_t c_mac[6] = {0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6};
 
@@ -141,9 +142,28 @@ TEST_CASE("RNA Mac Cache", "[rna_mac_cache]")
 
     SECTION("HostCacheMac: MAC Hashing")
     {
-        uint8_t a_mac[6] = {0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6};
         uint64_t hash = hash_mac(a_mac);
         CHECK(hash == 0xA1A2A3A4A5A6);
     }
+
+    SECTION("HostCacheMac: VLAN Tag Details")
+    {
+        MacKey a(a_mac);
+        auto a_ptr = host_cache_mac.find_else_create(a, nullptr);
+
+        a_ptr->update_vlan(12345, 54321);
+        uint8_t cfi, priority;
+        uint16_t vid;
+        uint16_t vth_pri_cfi_vlan = a_ptr->get_vlan();
+
+        a_ptr->get_vlan_details(cfi, priority, vid);
+
+        CHECK(a_ptr->has_vlan());
+        CHECK(cfi == (ntohs(vth_pri_cfi_vlan) & 0x1000) >> 12);
+        CHECK(priority == (ntohs(vth_pri_cfi_vlan)) >> 13);
+        CHECK(vid == (ntohs(vth_pri_cfi_vlan) & 0x0FFF));
+
+    }
 }
 #endif
+