correct endianness

pull/42/head
Jeff Becker 6 years ago
parent 80b99d2efb
commit 11e2e565c3
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -80,8 +80,9 @@ namespace llarp
friend std::ostream&
operator<<(std::ostream& out, const huint32_t& a)
{
uint32_t n = htonl(a.h);
char tmp[INET_ADDRSTRLEN] = {0};
if(inet_ntop(AF_INET, (void*)&a.h, tmp, INET_ADDRSTRLEN))
if(inet_ntop(AF_INET, (void*)&n, tmp, sizeof(tmp)))
{
out << tmp;
}
@ -122,7 +123,7 @@ namespace llarp
operator<<(std::ostream& out, const nuint32_t& a)
{
char tmp[INET_ADDRSTRLEN] = {0};
if(inet_ntop(AF_INET, (void*)&a.n, tmp, INET_ADDRSTRLEN))
if(inet_ntop(AF_INET, (void*)&a.n, tmp, sizeof(tmp)))
{
out << tmp;
}
@ -159,12 +160,7 @@ namespace llarp
friend std::ostream&
operator<<(std::ostream& out, const huint16_t& a)
{
char tmp[INET_ADDRSTRLEN] = {0};
if(inet_ntop(AF_INET, (void*)&a.h, tmp, INET_ADDRSTRLEN))
{
out << tmp;
}
return out;
return out<< a.h;
}
struct Hash
@ -197,12 +193,7 @@ namespace llarp
friend std::ostream&
operator<<(std::ostream& out, const nuint16_t& a)
{
char tmp[INET_ADDRSTRLEN] = {0};
if(inet_ntop(AF_INET, (void*)&a.n, tmp, INET_ADDRSTRLEN))
{
out << tmp;
}
return out;
return out << ntohs(a.n);
}
struct Hash

Loading…
Cancel
Save