Changeset View
Changeset View
Standalone View
Standalone View
src/netaddress.h
Show First 20 Lines • Show All 503 Lines • ▼ Show 20 Lines | |||||
/** 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; | ||||
public: | public: | ||||
CService(); | CService(); | ||||
CService(const CNetAddr &ip, unsigned short port); | CService(const CNetAddr &ip, uint16_t port); | ||||
CService(const struct in_addr &ipv4Addr, unsigned short port); | CService(const struct in_addr &ipv4Addr, uint16_t port); | ||||
explicit CService(const struct sockaddr_in &addr); | explicit CService(const struct sockaddr_in &addr); | ||||
unsigned short GetPort() const; | uint16_t GetPort() const; | ||||
bool GetSockAddr(struct sockaddr *paddr, socklen_t *addrlen) const; | bool GetSockAddr(struct sockaddr *paddr, socklen_t *addrlen) const; | ||||
bool SetSockAddr(const struct sockaddr *paddr); | bool SetSockAddr(const struct sockaddr *paddr); | ||||
friend bool operator==(const CService &a, const CService &b); | friend bool operator==(const CService &a, const CService &b); | ||||
friend bool operator!=(const CService &a, const CService &b) { | friend bool operator!=(const CService &a, const CService &b) { | ||||
return !(a == b); | return !(a == b); | ||||
} | } | ||||
friend bool operator<(const CService &a, const CService &b); | friend bool operator<(const CService &a, const CService &b); | ||||
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, uint16_t port); | ||||
explicit CService(const struct sockaddr_in6 &addr); | explicit CService(const struct sockaddr_in6 &addr); | ||||
SERIALIZE_METHODS(CService, obj) { | SERIALIZE_METHODS(CService, obj) { | ||||
READWRITEAS(CNetAddr, obj); | READWRITEAS(CNetAddr, obj); | ||||
READWRITE(Using<BigEndianFormatter<2>>(obj.port)); | READWRITE(Using<BigEndianFormatter<2>>(obj.port)); | ||||
} | } | ||||
}; | }; | ||||
bool SanityCheckASMap(const std::vector<bool> &asmap); | bool SanityCheckASMap(const std::vector<bool> &asmap); | ||||
#endif // BITCOIN_NETADDRESS_H | #endif // BITCOIN_NETADDRESS_H |