From ad6dbada716952c15623fbd4f823ddfcafe21158 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Tue, 5 May 2020 19:23:54 -0700 Subject: [PATCH] Migrate ARP analyzer to use IntrusivePtr --- src/analyzer/protocol/arp/ARP.cc | 28 ++++++++++++++-------------- src/analyzer/protocol/arp/ARP.h | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/analyzer/protocol/arp/ARP.cc b/src/analyzer/protocol/arp/ARP.cc index 25a48e45a8..ec5906bdde 100644 --- a/src/analyzer/protocol/arp/ARP.cc +++ b/src/analyzer/protocol/arp/ARP.cc @@ -192,10 +192,10 @@ void ARP_Analyzer::BadARP(const struct arp_pkthdr* hdr, const char* msg) return; mgr.Enqueue(bad_arp, - IntrusivePtr{AdoptRef{}, ConstructAddrVal(ar_spa(hdr))}, - IntrusivePtr{AdoptRef{}, EthAddrToStr((const u_char*) ar_sha(hdr))}, - IntrusivePtr{AdoptRef{}, ConstructAddrVal(ar_tpa(hdr))}, - IntrusivePtr{AdoptRef{}, EthAddrToStr((const u_char*) ar_tha(hdr))}, + ConstructAddrVal(ar_spa(hdr)), + EthAddrToStr((const u_char*) ar_sha(hdr)), + ConstructAddrVal(ar_tpa(hdr)), + EthAddrToStr((const u_char*) ar_tha(hdr)), make_intrusive(msg) ); } @@ -214,25 +214,25 @@ void ARP_Analyzer::RREvent(EventHandlerPtr e, return; mgr.Enqueue(e, - IntrusivePtr{AdoptRef{}, EthAddrToStr(src)}, - IntrusivePtr{AdoptRef{}, EthAddrToStr(dst)}, - IntrusivePtr{AdoptRef{}, ConstructAddrVal(spa)}, - IntrusivePtr{AdoptRef{}, EthAddrToStr((const u_char*) sha)}, - IntrusivePtr{AdoptRef{}, ConstructAddrVal(tpa)}, - IntrusivePtr{AdoptRef{}, EthAddrToStr((const u_char*) tha)} + EthAddrToStr(src), + EthAddrToStr(dst), + ConstructAddrVal(spa), + EthAddrToStr((const u_char*) sha), + ConstructAddrVal(tpa), + EthAddrToStr((const u_char*) tha) ); } -AddrVal* ARP_Analyzer::ConstructAddrVal(const void* addr) +IntrusivePtr ARP_Analyzer::ConstructAddrVal(const void* addr) { // ### For now, we only handle IPv4 addresses. - return new AddrVal(*(const uint32_t*) addr); + return make_intrusive(*(const uint32_t*) addr); } -StringVal* ARP_Analyzer::EthAddrToStr(const u_char* addr) +IntrusivePtr ARP_Analyzer::EthAddrToStr(const u_char* addr) { char buf[1024]; snprintf(buf, sizeof(buf), "%02x:%02x:%02x:%02x:%02x:%02x", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); - return new StringVal(buf); + return make_intrusive(buf); } diff --git a/src/analyzer/protocol/arp/ARP.h b/src/analyzer/protocol/arp/ARP.h index 9037a42b27..62e1fbd8bb 100644 --- a/src/analyzer/protocol/arp/ARP.h +++ b/src/analyzer/protocol/arp/ARP.h @@ -45,10 +45,10 @@ public: const char* tpa, const char* tha); protected: - AddrVal* ConstructAddrVal(const void* addr); - StringVal* EthAddrToStr(const u_char* addr); + IntrusivePtr ConstructAddrVal(const void* addr); + IntrusivePtr EthAddrToStr(const u_char* addr); void BadARP(const struct arp_pkthdr* hdr, const char* string); void Corrupted(const char* string); }; -} } // namespace analyzer::* +} } // namespace analyzer::*