aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include/net/local_ip.h
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-05-13 15:42:05 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-09-04 14:53:56 +0000
commitbdda0846519e3c8dfbe0fbd4527354151228a506 (patch)
treefdcbfaac7f988000e80707a16343994999580984 /contrib/epee/include/net/local_ip.h
parentdifficulty: fix check_hash on big endian (diff)
downloadmonero-bdda0846519e3c8dfbe0fbd4527354151228a506.tar.xz
epee: fix local/loopback checks on big endian
IPv4 addresses are kept in network byte order in memory
Diffstat (limited to 'contrib/epee/include/net/local_ip.h')
-rw-r--r--contrib/epee/include/net/local_ip.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/contrib/epee/include/net/local_ip.h b/contrib/epee/include/net/local_ip.h
index ce74e1cd3..246cf6ad8 100644
--- a/contrib/epee/include/net/local_ip.h
+++ b/contrib/epee/include/net/local_ip.h
@@ -30,6 +30,11 @@
#include <string>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/asio/ip/address_v6.hpp>
+#include "int-util.h"
+
+// IP addresses are kept in network byte order
+// Masks below are little endian
+// -> convert from network byte order to host byte order before comparing
namespace epee
{
@@ -62,6 +67,7 @@ namespace epee
inline
bool is_ip_local(uint32_t ip)
{
+ ip = SWAP32LE(ip);
/*
local ip area
10.0.0.0 — 10.255.255.255
@@ -85,6 +91,7 @@ namespace epee
inline
bool is_ip_loopback(uint32_t ip)
{
+ ip = SWAP32LE(ip);
if( (ip | 0xffffff00) == 0xffffff7f)
return true;
//MAKE_IP