From 222611b37728526d496a96c88cee5a3108547301 Mon Sep 17 00:00:00 2001 From: ceerrep Date: Wed, 24 Mar 2021 18:37:09 +0800 Subject: [PATCH] Fix wrong address endian Host endian has been implicitly converted to big endian in "IPv4Address::operator uint32_t()" --- include/tins/icmp.h | 4 ++-- src/icmp.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/tins/icmp.h b/include/tins/icmp.h index d25761a..d4b7d31 100644 --- a/include/tins/icmp.h +++ b/include/tins/icmp.h @@ -320,7 +320,7 @@ public: * \return Returns the gateway field value. */ address_type gateway() const { - return address_type(Endian::be_to_host(header_.un.gateway)); + return address_type(header_.un.gateway); } /** @@ -383,7 +383,7 @@ public: * \return Returns the address mask value. */ address_type address_mask() const { - return address_type(Endian::be_to_host(orig_timestamp_or_address_mask_)); + return address_type(orig_timestamp_or_address_mask_); } /** diff --git a/src/icmp.cpp b/src/icmp.cpp index e942034..2b1dd8b 100644 --- a/src/icmp.cpp +++ b/src/icmp.cpp @@ -98,7 +98,7 @@ void ICMP::sequence(uint16_t new_seq) { } void ICMP::gateway(address_type new_gw) { - header_.un.gateway = Endian::host_to_be(static_cast(new_gw)); + header_.un.gateway = static_cast(new_gw); } void ICMP::mtu(uint16_t new_mtu) { @@ -122,7 +122,7 @@ void ICMP::transmit_timestamp(uint32_t new_timestamp) { } void ICMP::address_mask(address_type new_mask) { - orig_timestamp_or_address_mask_ = Endian::host_to_be(static_cast(new_mask)); + orig_timestamp_or_address_mask_ = static_cast(new_mask); } uint32_t ICMP::header_size() const {