diff --git a/Common++/header/pcapplusplus/IpAddress.h b/Common++/header/pcapplusplus/IpAddress.h index 48db6f722e..243dae0ef9 100644 --- a/Common++/header/pcapplusplus/IpAddress.h +++ b/Common++/header/pcapplusplus/IpAddress.h @@ -40,7 +40,7 @@ namespace pcpp * A constructor that creates an instance of the class out of 4-byte integer value. * @param[in] addrAsInt The address as 4-byte integer in network byte order */ - explicit IPv4Address(const uint32_t addrAsInt) + IPv4Address(const uint32_t addrAsInt) { memcpy(m_Bytes.data(), &addrAsInt, sizeof(addrAsInt)); } @@ -49,7 +49,7 @@ namespace pcpp * A constructor that creates an instance of the class out of 4-byte array. * @param[in] bytes The address as 4-byte array in network byte order */ - explicit IPv4Address(const uint8_t bytes[4]) + IPv4Address(const uint8_t bytes[4]) { memcpy(m_Bytes.data(), bytes, 4 * sizeof(uint8_t)); } @@ -58,7 +58,7 @@ namespace pcpp * A constructor that creates an instance of the class out of a 4-byte standard array. * @param[in] bytes The address as 4-byte standard array in network byte order */ - explicit IPv4Address(const std::array& bytes) : m_Bytes(bytes) + IPv4Address(const std::array& bytes) : m_Bytes(bytes) {} /** @@ -67,7 +67,7 @@ namespace pcpp * @param[in] addrAsString The std::string representation of the address * @throws std::invalid_argument The provided string does not represent a valid IPv4 address. */ - explicit IPv4Address(const std::string& addrAsString); + IPv4Address(const std::string& addrAsString); /** * @return A 4-byte integer in network byte order representing the IPv4 address @@ -207,7 +207,7 @@ namespace pcpp * A constructor that creates an instance of the class out of 16-byte array. * @param[in] bytes The address as 16-byte array in network byte order */ - explicit IPv6Address(const uint8_t bytes[16]) + IPv6Address(const uint8_t bytes[16]) { memcpy(m_Bytes.data(), bytes, 16 * sizeof(uint8_t)); } @@ -216,7 +216,7 @@ namespace pcpp * A constructor that creates an instance of the class out of a 16-byte standard array. * @param[in] bytes The address as 16-byte standard array in network byte order */ - explicit IPv6Address(const std::array& bytes) : m_Bytes(bytes) + IPv6Address(const std::array& bytes) : m_Bytes(bytes) {} /** @@ -225,7 +225,7 @@ namespace pcpp * @param[in] addrAsString The std::string representation of the address * @throws std::invalid_argument The provided string does not represent a valid IPv6 address. */ - explicit IPv6Address(const std::string& addrAsString); + IPv6Address(const std::string& addrAsString); /** * Returns a view of the IPv6 address as a 16-byte raw C-style array @@ -382,14 +382,14 @@ namespace pcpp * A constructor that creates an instance of the class out of IPv4Address. * @param[in] addr A const reference to instance of IPv4Address */ - explicit IPAddress(const IPv4Address& addr) : m_Type(IPv4AddressType), m_IPv4(addr) + IPAddress(const IPv4Address& addr) : m_Type(IPv4AddressType), m_IPv4(addr) {} /** * A constructor that creates an instance of the class out of IPv6Address. * @param[in] addr A const reference to instance of IPv6Address */ - explicit IPAddress(const IPv6Address& addr) : m_Type(IPv6AddressType), m_IPv6(addr) + IPAddress(const IPv6Address& addr) : m_Type(IPv6AddressType), m_IPv6(addr) {} /** @@ -596,7 +596,7 @@ namespace pcpp * a valid netmask * @throws std::invalid_argument The provided string does not represent a valid address and netmask format. */ - explicit IPv4Network(const std::string& addressAndNetmask); + IPv4Network(const std::string& addressAndNetmask); /** * @return The prefix length, for example: the prefix length of 10.10.10.10/255.0.0.0 is 8 @@ -713,7 +713,7 @@ namespace pcpp * and IPV6_NETMASK is a valid IPv6 netmask * @throws std::invalid_argument The provided string does not represent a valid address and netmask format. */ - explicit IPv6Network(const std::string& addressAndNetmask); + IPv6Network(const std::string& addressAndNetmask); /** * @return The prefix length, for example: the prefix length of 3546::/ffff:: is 16 @@ -852,7 +852,7 @@ namespace pcpp * is a valid netmask for this type of network (IPv4 or IPv6 network) * @throws std::invalid_argument The provided string does not represent a valid address and netmask format. */ - explicit IPNetwork(const std::string& addressAndNetmask) + IPNetwork(const std::string& addressAndNetmask) { try { diff --git a/Common++/header/pcapplusplus/MacAddress.h b/Common++/header/pcapplusplus/MacAddress.h index 4e46602b13..29333aa02d 100644 --- a/Common++/header/pcapplusplus/MacAddress.h +++ b/Common++/header/pcapplusplus/MacAddress.h @@ -54,7 +54,7 @@ namespace pcpp * @param[in] addr the string representing the MAC address in format "00:00:00:00:00:00" */ template ::value>::type> - explicit MacAddress(const T& addr) : MacAddress(static_cast(addr)) + MacAddress(const T& addr) : MacAddress(static_cast(addr)) {} /** diff --git a/Common++/src/IpAddress.cpp b/Common++/src/IpAddress.cpp index 6558e5f403..281d6a675e 100644 --- a/Common++/src/IpAddress.cpp +++ b/Common++/src/IpAddress.cpp @@ -285,14 +285,14 @@ namespace pcpp IPv4Address IPv4Network::getLowestAddress() const { std::bitset<32> bitset(m_Mask); - return bitset.count() < 32 ? IPv4Address(m_NetworkPrefix + htobe32(1)) : IPv4Address(m_NetworkPrefix); + return bitset.count() < 32 ? m_NetworkPrefix + htobe32(1) : m_NetworkPrefix; } IPv4Address IPv4Network::getHighestAddress() const { auto tempAddress = static_cast(m_NetworkPrefix | ~m_Mask); std::bitset<32> bitset(m_Mask); - return bitset.count() < 32 ? IPv4Address(tempAddress - htobe32(1)) : IPv4Address(tempAddress); + return bitset.count() < 32 ? tempAddress - htobe32(1) : tempAddress; } uint64_t IPv4Network::getTotalAddressCount() const @@ -496,13 +496,13 @@ namespace pcpp { if (getPrefixLen() == 128) { - return IPv6Address(m_NetworkPrefix); + return m_NetworkPrefix; } uint8_t lowestAddress[IPV6_ADDR_SIZE]; memcpy(lowestAddress, m_NetworkPrefix, IPV6_ADDR_SIZE); lowestAddress[IPV6_ADDR_SIZE - 1]++; - return IPv6Address(lowestAddress); + return lowestAddress; } IPv6Address IPv6Network::getHighestAddress() const @@ -514,7 +514,7 @@ namespace pcpp result[byteIndex] = m_NetworkPrefix[byteIndex] | ~m_Mask[byteIndex]; } - return IPv6Address(result); + return result; } uint64_t IPv6Network::getTotalAddressCount() const diff --git a/Packet++/header/pcapplusplus/ArpLayer.h b/Packet++/header/pcapplusplus/ArpLayer.h index 1ef9b2d097..d2293f3f5d 100644 --- a/Packet++/header/pcapplusplus/ArpLayer.h +++ b/Packet++/header/pcapplusplus/ArpLayer.h @@ -119,7 +119,7 @@ namespace pcpp */ inline IPv4Address getSenderIpAddr() const { - return IPv4Address(getArpHeader()->senderIpAddr); + return getArpHeader()->senderIpAddr; } /** @@ -128,7 +128,7 @@ namespace pcpp */ inline IPv4Address getTargetIpAddr() const { - return IPv4Address(getArpHeader()->targetIpAddr); + return getArpHeader()->targetIpAddr; } // implement abstract methods diff --git a/Packet++/header/pcapplusplus/DhcpLayer.h b/Packet++/header/pcapplusplus/DhcpLayer.h index d90f7a3e63..fc37911601 100644 --- a/Packet++/header/pcapplusplus/DhcpLayer.h +++ b/Packet++/header/pcapplusplus/DhcpLayer.h @@ -416,7 +416,7 @@ namespace pcpp */ IPv4Address getValueAsIpAddr() const { - return IPv4Address(getValueAs()); + return getValueAs(); } /** @@ -669,7 +669,7 @@ namespace pcpp */ IPv4Address getClientIpAddress() const { - return IPv4Address(getDhcpHeader()->clientIpAddress); + return getDhcpHeader()->clientIpAddress; } /** @@ -687,7 +687,7 @@ namespace pcpp */ IPv4Address getServerIpAddress() const { - return IPv4Address(getDhcpHeader()->serverIpAddress); + return getDhcpHeader()->serverIpAddress; } /** @@ -704,7 +704,7 @@ namespace pcpp */ IPv4Address getYourIpAddress() const { - return IPv4Address(getDhcpHeader()->yourIpAddress); + return getDhcpHeader()->yourIpAddress; } /** @@ -721,7 +721,7 @@ namespace pcpp */ IPv4Address getGatewayIpAddress() const { - return IPv4Address(getDhcpHeader()->gatewayIpAddress); + return getDhcpHeader()->gatewayIpAddress; } /** diff --git a/Packet++/header/pcapplusplus/IPv4Layer.h b/Packet++/header/pcapplusplus/IPv4Layer.h index 732f45886a..72ffadc2c9 100644 --- a/Packet++/header/pcapplusplus/IPv4Layer.h +++ b/Packet++/header/pcapplusplus/IPv4Layer.h @@ -514,7 +514,7 @@ namespace pcpp */ IPAddress getSrcIPAddress() const override { - return IPAddress(getSrcIPv4Address()); + return getSrcIPv4Address(); } /** @@ -523,7 +523,7 @@ namespace pcpp */ IPv4Address getSrcIPv4Address() const { - return IPv4Address(getIPv4Header()->ipSrc); + return getIPv4Header()->ipSrc; } /** @@ -542,7 +542,7 @@ namespace pcpp */ IPAddress getDstIPAddress() const override { - return IPAddress(getDstIPv4Address()); + return getDstIPv4Address(); } /** @@ -551,7 +551,7 @@ namespace pcpp */ IPv4Address getDstIPv4Address() const { - return IPv4Address(getIPv4Header()->ipDst); + return getIPv4Header()->ipDst; } /** diff --git a/Packet++/header/pcapplusplus/IPv6Layer.h b/Packet++/header/pcapplusplus/IPv6Layer.h index 37d11f1deb..7f80dfd094 100644 --- a/Packet++/header/pcapplusplus/IPv6Layer.h +++ b/Packet++/header/pcapplusplus/IPv6Layer.h @@ -108,7 +108,7 @@ namespace pcpp */ IPAddress getSrcIPAddress() const override { - return IPAddress(getSrcIPv6Address()); + return getSrcIPv6Address(); } /** @@ -117,7 +117,7 @@ namespace pcpp */ IPv6Address getSrcIPv6Address() const { - return IPv6Address(getIPv6Header()->ipSrc); + return getIPv6Header()->ipSrc; } /** @@ -145,7 +145,7 @@ namespace pcpp */ IPAddress getDstIPAddress() const override { - return IPAddress(getDstIPv6Address()); + return getDstIPv6Address(); } /** @@ -154,7 +154,7 @@ namespace pcpp */ IPv6Address getDstIPv6Address() const { - return IPv6Address(getIPv6Header()->ipDst); + return getIPv6Header()->ipDst; } /** diff --git a/Packet++/header/pcapplusplus/IcmpLayer.h b/Packet++/header/pcapplusplus/IcmpLayer.h index 824e7b23fb..9c9166516d 100644 --- a/Packet++/header/pcapplusplus/IcmpLayer.h +++ b/Packet++/header/pcapplusplus/IcmpLayer.h @@ -274,7 +274,7 @@ namespace pcpp */ IPv4Address getAddress() const { - return IPv4Address(routerAddress); + return routerAddress; } }; #pragma pack(pop) diff --git a/Packet++/header/pcapplusplus/IgmpLayer.h b/Packet++/header/pcapplusplus/IgmpLayer.h index 8005119ada..321c46366a 100644 --- a/Packet++/header/pcapplusplus/IgmpLayer.h +++ b/Packet++/header/pcapplusplus/IgmpLayer.h @@ -95,7 +95,7 @@ namespace pcpp */ IPv4Address getMulticastAddress() const { - return IPv4Address(multicastAddress); + return multicastAddress; } /** @@ -189,7 +189,7 @@ namespace pcpp */ IPv4Address getGroupAddress() const { - return IPv4Address(getIgmpHeader()->groupAddress); + return getIgmpHeader()->groupAddress; } /** diff --git a/Packet++/src/TcpLayer.cpp b/Packet++/src/TcpLayer.cpp index d494395aa7..d53041dec9 100644 --- a/Packet++/src/TcpLayer.cpp +++ b/Packet++/src/TcpLayer.cpp @@ -281,7 +281,7 @@ namespace pcpp checksumRes = pcpp::computePseudoHdrChecksum(reinterpret_cast(tcpHdr), getDataLen(), - IPAddress::IPv4AddressType, PACKETPP_IPPROTO_TCP, IPAddress(srcIP), IPAddress(dstIP)); + IPAddress::IPv4AddressType, PACKETPP_IPPROTO_TCP, srcIP, dstIP); PCPP_LOG_DEBUG("calculated IPv4 TCP checksum = 0x" << std::uppercase << std::hex << checksumRes); } @@ -291,7 +291,7 @@ namespace pcpp const IPv6Address dstIP = static_cast(m_PrevLayer)->getDstIPv6Address(); checksumRes = computePseudoHdrChecksum(reinterpret_cast(tcpHdr), getDataLen(), - IPAddress::IPv6AddressType, PACKETPP_IPPROTO_TCP, IPAddress(srcIP), IPAddress(dstIP)); + IPAddress::IPv6AddressType, PACKETPP_IPPROTO_TCP, srcIP, dstIP); PCPP_LOG_DEBUG("calculated IPv6 TCP checksum = 0xX" << std::uppercase << std::hex << checksumRes); } diff --git a/Packet++/src/UdpLayer.cpp b/Packet++/src/UdpLayer.cpp index 981a621c1e..34b4f46c1b 100644 --- a/Packet++/src/UdpLayer.cpp +++ b/Packet++/src/UdpLayer.cpp @@ -62,7 +62,7 @@ namespace pcpp IPv4Address dstIP = ((IPv4Layer*)m_PrevLayer)->getDstIPv4Address(); checksumRes = pcpp::computePseudoHdrChecksum((uint8_t*)udpHdr, getDataLen(), IPAddress::IPv4AddressType, - PACKETPP_IPPROTO_UDP, IPAddress(srcIP), IPAddress(dstIP)); + PACKETPP_IPPROTO_UDP, srcIP, dstIP); PCPP_LOG_DEBUG("calculated IPv4 UDP checksum = 0x" << std::uppercase << std::hex << checksumRes); } @@ -72,7 +72,7 @@ namespace pcpp IPv6Address dstIP = ((IPv6Layer*)m_PrevLayer)->getDstIPv6Address(); checksumRes = computePseudoHdrChecksum((uint8_t*)udpHdr, getDataLen(), IPAddress::IPv6AddressType, - PACKETPP_IPPROTO_UDP, IPAddress(srcIP), IPAddress(dstIP)); + PACKETPP_IPPROTO_UDP, srcIP, dstIP); PCPP_LOG_DEBUG("calculated IPv6 UDP checksum = 0xX" << std::uppercase << std::hex << checksumRes); } diff --git a/Packet++/src/VrrpLayer.cpp b/Packet++/src/VrrpLayer.cpp index e5c49e03ac..e42fe02d4b 100644 --- a/Packet++/src/VrrpLayer.cpp +++ b/Packet++/src/VrrpLayer.cpp @@ -351,10 +351,10 @@ namespace pcpp { if (getAddressType() == IPAddress::IPv4AddressType) { - return IPAddress(IPv4Address(*((uint32_t*)data))); + return IPv4Address(*((uint32_t*)data)); } - return IPAddress(IPv6Address(data)); + return IPv6Address(data); } bool VrrpLayer::isIPAddressValid(IPAddress& ipAddress) const diff --git a/Pcap++/header/pcapplusplus/PcapFileDevice.h b/Pcap++/header/pcapplusplus/PcapFileDevice.h index a10e6adc7f..8f48787388 100644 --- a/Pcap++/header/pcapplusplus/PcapFileDevice.h +++ b/Pcap++/header/pcapplusplus/PcapFileDevice.h @@ -451,7 +451,7 @@ namespace pcpp * @param[in] nanosecondsPrecision A boolean indicating whether to write timestamps in nano-precision. If set to * false, timestamps will be written in micro-precision */ - explicit PcapFileWriterDevice(const std::string& fileName, LinkLayerType linkLayerType = LINKTYPE_ETHERNET, + PcapFileWriterDevice(const std::string& fileName, LinkLayerType linkLayerType = LINKTYPE_ETHERNET, bool nanosecondsPrecision = false); /**