mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
epee: fix local/loopback checks on big endian
IPv4 addresses are kept in network byte order in memory
This commit is contained in:
parent
d046ca1db0
commit
bdda084651
1 changed files with 7 additions and 0 deletions
|
@ -30,6 +30,11 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
#include <boost/asio/ip/address_v6.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
|
namespace epee
|
||||||
{
|
{
|
||||||
|
@ -62,6 +67,7 @@ namespace epee
|
||||||
inline
|
inline
|
||||||
bool is_ip_local(uint32_t ip)
|
bool is_ip_local(uint32_t ip)
|
||||||
{
|
{
|
||||||
|
ip = SWAP32LE(ip);
|
||||||
/*
|
/*
|
||||||
local ip area
|
local ip area
|
||||||
10.0.0.0 — 10.255.255.255
|
10.0.0.0 — 10.255.255.255
|
||||||
|
@ -85,6 +91,7 @@ namespace epee
|
||||||
inline
|
inline
|
||||||
bool is_ip_loopback(uint32_t ip)
|
bool is_ip_loopback(uint32_t ip)
|
||||||
{
|
{
|
||||||
|
ip = SWAP32LE(ip);
|
||||||
if( (ip | 0xffffff00) == 0xffffff7f)
|
if( (ip | 0xffffff00) == 0xffffff7f)
|
||||||
return true;
|
return true;
|
||||||
//MAKE_IP
|
//MAKE_IP
|
||||||
|
|
Loading…
Reference in a new issue