]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1946 in SNORT/snort3 from ~SELYSENK/snort3:bug/362106 to master
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Tue, 21 Jan 2020 03:04:07 +0000 (03:04 +0000)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Tue, 21 Jan 2020 03:04:07 +0000 (03:04 +0000)
Squashed commit of the following:

commit 47f108c7be1b3aca7ff8a0b238ca997c469ffbde
Author: Serhii Lysenko <selysenk@cisco.com>
Date:   Fri Jan 17 15:18:21 2020 +0200

    cip: explicitly include sys/time.h header

commit 51d311de1b4f34931b017529ff382ae2a79b7cba
Author: Serhii Lysenko <selysenk@cisco.com>
Date:   Fri Jan 17 18:24:31 2020 +0200

    rna: use standard uint8_t type instead of u_int8_t

src/host_tracker/host_tracker.cc
src/host_tracker/host_tracker.h
src/host_tracker/test/host_tracker_test.cc
src/network_inspectors/rna/rna_logger.cc
src/network_inspectors/rna/rna_logger.h
src/network_inspectors/rna/rna_pnd.cc
src/network_inspectors/rna/rna_pnd.h
src/service_inspectors/cip/cip_definitions.h

index ecf9d784389dcd217a749591a3b873047953d250..012408225cdf4b56d043ab5ea12c0de2025a9272 100644 (file)
@@ -46,7 +46,7 @@ void HostTracker::update_last_event(uint32_t time)
     last_event = time ? time : last_seen;
 }
 
-bool HostTracker::add_mac(const u_int8_t* mac, u_int8_t ttl, u_int8_t primary)
+bool HostTracker::add_mac(const uint8_t* mac, uint8_t ttl, uint8_t primary)
 {
     if ( !mac or !memcmp(mac, zero_mac, MAC_SIZE) )
         return false;
@@ -130,7 +130,7 @@ static inline string to_time_string(uint32_t p_time)
     return buffer;
 }
 
-static inline string to_mac_string(const u_int8_t* mac)
+static inline string to_mac_string(const uint8_t* mac)
 {
     char mac_addr[18];
     snprintf(mac_addr, 18, "%02X:%02X:%02X:%02X:%02X:%02X",
index 60d6ce30984af30cf3e6775cf0899624be1008be..149283686a53e8ce25ce7c287e5afef1585a3e20 100644 (file)
@@ -53,13 +53,13 @@ extern const uint8_t zero_mac[MAC_SIZE];
 
 struct HostMac
 {
-    HostMac(u_int8_t p_ttl, const u_int8_t* p_mac, u_int8_t p_primary, uint32_t p_last_seen)
+    HostMac(uint8_t p_ttl, const uint8_t* p_mac, uint8_t p_primary, uint32_t p_last_seen)
         : ttl(p_ttl), primary(p_primary), last_seen (p_last_seen) { memcpy(mac, p_mac, MAC_SIZE); }
 
     // the type and order below should match logger's serialization
-    u_int8_t ttl;
-    u_int8_t mac[MAC_SIZE];
-    u_int8_t primary;
+    uint8_t ttl;
+    uint8_t mac[MAC_SIZE];
+    uint8_t primary;
     uint32_t last_seen;
 };
 
@@ -98,7 +98,7 @@ public:
     }
 
     // Returns true if a new mac entry is added, false otherwise
-    bool add_mac(const u_int8_t* mac, u_int8_t ttl, u_int8_t primary);
+    bool add_mac(const uint8_t* mac, uint8_t ttl, uint8_t primary);
 
     // The caller owns and deletes the copied list of mac addresses
     void copy_data(uint8_t& p_hops, uint32_t& p_last_seen, std::list<HostMac>*& p_macs);
index 9ac2b1fe3c43cf38a7bb241cc0204bad4e0fcacb..01b05129da4cce2bd359a8f8d6e4207c9b35ffc6 100644 (file)
@@ -81,7 +81,7 @@ TEST(host_tracker, copy_data_test)
 {
     test_time = 1562198400;
     HostTracker ht;
-    u_int8_t mac[6] = {254, 237, 222, 173, 190, 239};
+    uint8_t mac[6] = {254, 237, 222, 173, 190, 239};
     ht.add_mac(mac, 50, 1);
 
     uint8_t p_hops = 0;
@@ -107,8 +107,8 @@ TEST(host_tracker, stringify)
     test_time = 1562198400; // this time will be updated and should not be seen in stringify
     HostTracker ht;
 
-    u_int8_t mac1[6] = {254, 237, 222, 173, 190, 239};
-    u_int8_t mac2[6] = {202, 254, 192, 255, 238, 0};
+    uint8_t mac1[6] = {254, 237, 222, 173, 190, 239};
+    uint8_t mac2[6] = {202, 254, 192, 255, 238, 0};
     test_time = 1562198404; // this time should be the time of the first mac address
     ht.update_last_seen();
     ht.add_mac(mac1, 9, 0);
index bd1708ddb92e989a3a459031441b87692bbb9be0..fe750c9d6148dc411f768aa6d554bc2dc3d151fd 100644 (file)
@@ -36,7 +36,7 @@
 using namespace snort;
 
 bool RnaLogger::log(uint16_t type, uint16_t subtype, const Packet* p, RnaTracker* ht,
-    const struct in6_addr* src_ip, const u_int8_t* src_mac, uint32_t event_time,
+    const struct in6_addr* src_ip, const uint8_t* src_mac, uint32_t event_time,
     void* cond_var)
 {
     if ( !enabled )
index 0b72de6af09723a488448cf1101f57da7cf0da5d..a8e984e09a733902b21b835594456ceff38a3a6c 100644 (file)
@@ -34,11 +34,11 @@ using RnaTracker = std::shared_ptr<snort::HostTracker>;
 struct RnaLoggerEvent : public Event
 {
     RnaLoggerEvent(uint16_t p_type, uint16_t p_subtype, const RnaTracker* p_ht,
-        const u_int8_t* p_mac) : type(p_type), subtype(p_subtype), ht(p_ht), mac(p_mac) { }
+        const uint8_t* p_mac) : type(p_type), subtype(p_subtype), ht(p_ht), mac(p_mac) { }
     uint16_t type;
     uint16_t subtype;
     const RnaTracker* ht;
-    const u_int8_t* mac;
+    const uint8_t* mac;
     const struct in6_addr* ip;
     void* cond_var = nullptr;
 };
@@ -48,7 +48,7 @@ class RnaLogger
 public:
     RnaLogger(const bool enable) : enabled(enable) { }
     bool log(uint16_t type, uint16_t subtype, const snort::Packet* p, RnaTracker* ht,
-       const struct in6_addr* src_ip, const u_int8_t* src_mac,
+       const struct in6_addr* src_ip, const uint8_t* src_mac,
        uint32_t event_time = 0, void* cond_var = nullptr);
 
 private:
index 1dd6c5ecdf054eba65a6e53218770da4c87a4491..f74ac4c9c1ad1a924d9482e7f58e70955c6db9b5 100644 (file)
@@ -141,7 +141,7 @@ void RnaPnd::discover_network_udp(const Packet* p)
         discover_network(p, ip_api.ttl());
 }
 
-void RnaPnd::discover_network(const Packet* p, u_int8_t ttl)
+void RnaPnd::discover_network(const Packet* p, uint8_t ttl)
 {
     bool new_host = false;
     const auto& src_ip = p->ptrs.ip_api.get_src();
index 5abe5d6b1d90123049fe6ed5688d8bcfee43fea5..e00bf1520747b5aa9e20ec3d98718c6d10dfd16c 100644 (file)
@@ -62,7 +62,7 @@ private:
     void discover_network_non_ip(const snort::Packet* p);
     void discover_network_tcp(const snort::Packet* p);
     void discover_network_udp(const snort::Packet* p);
-    void discover_network(const snort::Packet* p, u_int8_t ttl);
+    void discover_network(const snort::Packet* p, uint8_t ttl);
 
     RnaLogger logger;
     DiscoveryFilter filter;
index b9bba15f9aaf13de34842577d03fb17680ad68b2..0cda06ca20080960fea3aec293d68cb24026d2d4 100644 (file)
@@ -23,6 +23,8 @@
 #ifndef CIP_DEFINITIONS_H
 #define CIP_DEFINITIONS_H
 
+#include <sys/time.h>
+
 namespace snort
 {
 struct Packet;