Changeset View
Changeset View
Standalone View
Standalone View
src/netaddress.h
Show First 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | public: | ||||
bool GetIn6Addr(struct in6_addr *pipv6Addr) const; | bool GetIn6Addr(struct in6_addr *pipv6Addr) const; | ||||
friend bool operator==(const CNetAddr &a, const CNetAddr &b); | friend bool operator==(const CNetAddr &a, const CNetAddr &b); | ||||
friend bool operator!=(const CNetAddr &a, const CNetAddr &b) { | friend bool operator!=(const CNetAddr &a, const CNetAddr &b) { | ||||
return !(a == b); | return !(a == b); | ||||
} | } | ||||
friend bool operator<(const CNetAddr &a, const CNetAddr &b); | friend bool operator<(const CNetAddr &a, const CNetAddr &b); | ||||
ADD_SERIALIZE_METHODS; | SERIALIZE_METHODS(CNetAddr, obj) { READWRITE(obj.ip); } | ||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
READWRITE(ip); | |||||
} | |||||
friend class CSubNet; | friend class CSubNet; | ||||
}; | }; | ||||
class CSubNet { | class CSubNet { | ||||
protected: | protected: | ||||
/// Network (base) address | /// Network (base) address | ||||
CNetAddr network; | CNetAddr network; | ||||
Show All 16 Lines | public: | ||||
bool IsValid() const; | bool IsValid() const; | ||||
friend bool operator==(const CSubNet &a, const CSubNet &b); | friend bool operator==(const CSubNet &a, const CSubNet &b); | ||||
friend bool operator!=(const CSubNet &a, const CSubNet &b) { | friend bool operator!=(const CSubNet &a, const CSubNet &b) { | ||||
return !(a == b); | return !(a == b); | ||||
} | } | ||||
friend bool operator<(const CSubNet &a, const CSubNet &b); | friend bool operator<(const CSubNet &a, const CSubNet &b); | ||||
ADD_SERIALIZE_METHODS; | SERIALIZE_METHODS(CSubNet, obj) { | ||||
READWRITE(obj.network, obj.netmask, obj.valid); | |||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
READWRITE(network); | |||||
READWRITE(netmask); | |||||
READWRITE(valid); | |||||
} | } | ||||
}; | }; | ||||
/** A combination of a network address (CNetAddr) and a (TCP) port */ | /** A combination of a network address (CNetAddr) and a (TCP) port */ | ||||
class CService : public CNetAddr { | class CService : public CNetAddr { | ||||
protected: | protected: | ||||
// host order | // host order | ||||
uint16_t port; | uint16_t port; | ||||
Show All 14 Lines | public: | ||||
std::vector<uint8_t> GetKey() const; | std::vector<uint8_t> GetKey() const; | ||||
std::string ToString() const; | std::string ToString() const; | ||||
std::string ToStringPort() const; | std::string ToStringPort() const; | ||||
std::string ToStringIPPort() const; | std::string ToStringIPPort() const; | ||||
CService(const struct in6_addr &ipv6Addr, unsigned short port); | CService(const struct in6_addr &ipv6Addr, unsigned short port); | ||||
explicit CService(const struct sockaddr_in6 &addr); | explicit CService(const struct sockaddr_in6 &addr); | ||||
ADD_SERIALIZE_METHODS; | SERIALIZE_METHODS(CService, obj) { | ||||
READWRITE(obj.ip, Using<BigEndianFormatter<2>>(obj.port)); | |||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
READWRITE(ip); | |||||
READWRITE(WrapBigEndian(port)); | |||||
} | } | ||||
}; | }; | ||||
bool SanityCheckASMap(const std::vector<bool> &asmap); | bool SanityCheckASMap(const std::vector<bool> &asmap); | ||||
#endif // BITCOIN_NETADDRESS_H | #endif // BITCOIN_NETADDRESS_H |