Changeset View
Changeset View
Standalone View
Standalone View
src/netaddress.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <cstdint> | |||||
Fabien: dito | |||||
#include <netaddress.h> | #include <netaddress.h> | ||||
#include <crypto/common.h> | #include <crypto/common.h> | ||||
#include <crypto/sha3.h> | #include <crypto/sha3.h> | ||||
#include <hash.h> | #include <hash.h> | ||||
#include <prevector.h> | #include <prevector.h> | ||||
#include <util/asmap.h> | #include <util/asmap.h> | ||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
▲ Show 20 Lines • Show All 888 Lines • ▼ Show 20 Lines | switch (theirNet) { | ||||
case NET_ONION: | case NET_ONION: | ||||
return REACH_PRIVATE; | return REACH_PRIVATE; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
CService::CService() : port(0) {} | CService::CService() : port(0) {} | ||||
CService::CService(const CNetAddr &cip, unsigned short portIn) | CService::CService(const CNetAddr &cip, uint16_t portIn) | ||||
: CNetAddr(cip), port(portIn) {} | : CNetAddr(cip), port(portIn) {} | ||||
CService::CService(const struct in_addr &ipv4Addr, unsigned short portIn) | CService::CService(const struct in_addr &ipv4Addr, uint16_t portIn) | ||||
: CNetAddr(ipv4Addr), port(portIn) {} | : CNetAddr(ipv4Addr), port(portIn) {} | ||||
CService::CService(const struct in6_addr &ipv6Addr, unsigned short portIn) | CService::CService(const struct in6_addr &ipv6Addr, uint16_t portIn) | ||||
: CNetAddr(ipv6Addr), port(portIn) {} | : CNetAddr(ipv6Addr), port(portIn) {} | ||||
CService::CService(const struct sockaddr_in &addr) | CService::CService(const struct sockaddr_in &addr) | ||||
: CNetAddr(addr.sin_addr), port(ntohs(addr.sin_port)) { | : CNetAddr(addr.sin_addr), port(ntohs(addr.sin_port)) { | ||||
assert(addr.sin_family == AF_INET); | assert(addr.sin_family == AF_INET); | ||||
} | } | ||||
CService::CService(const struct sockaddr_in6 &addr) | CService::CService(const struct sockaddr_in6 &addr) | ||||
Show All 12 Lines | switch (paddr->sa_family) { | ||||
*this = | *this = | ||||
CService(*reinterpret_cast<const struct sockaddr_in6 *>(paddr)); | CService(*reinterpret_cast<const struct sockaddr_in6 *>(paddr)); | ||||
return true; | return true; | ||||
default: | default: | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
unsigned short CService::GetPort() const { | uint16_t CService::GetPort() const { | ||||
return port; | return port; | ||||
} | } | ||||
bool operator==(const CService &a, const CService &b) { | bool operator==(const CService &a, const CService &b) { | ||||
return static_cast<CNetAddr>(a) == static_cast<CNetAddr>(b) && | return static_cast<CNetAddr>(a) == static_cast<CNetAddr>(b) && | ||||
a.port == b.port; | a.port == b.port; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 244 Lines • Show Last 20 Lines |
dito