Changeset View
Changeset View
Standalone View
Standalone View
src/netaddress.h
Show First 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | 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; | ADD_SERIALIZE_METHODS; | ||||
template <typename Stream, typename Operation> | template <typename Stream, typename Operation> | ||||
inline void SerializationOp(Stream &s, Operation ser_action) { | inline void SerializationOp(Stream &s, Operation ser_action) { | ||||
READWRITE(FLATDATA(ip)); | READWRITE(ip); | ||||
} | } | ||||
friend class CSubNet; | friend class CSubNet; | ||||
}; | }; | ||||
class CSubNet { | class CSubNet { | ||||
protected: | protected: | ||||
/// Network (base) address | /// Network (base) address | ||||
Show All 22 Lines | public: | ||||
} | } | ||||
friend bool operator<(const CSubNet &a, const CSubNet &b); | friend bool operator<(const CSubNet &a, const CSubNet &b); | ||||
ADD_SERIALIZE_METHODS; | ADD_SERIALIZE_METHODS; | ||||
template <typename Stream, typename Operation> | template <typename Stream, typename Operation> | ||||
inline void SerializationOp(Stream &s, Operation ser_action) { | inline void SerializationOp(Stream &s, Operation ser_action) { | ||||
READWRITE(network); | READWRITE(network); | ||||
READWRITE(FLATDATA(netmask)); | READWRITE(netmask); | ||||
READWRITE(FLATDATA(valid)); | 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 | ||||
unsigned short port; | unsigned short port; | ||||
Show All 18 Lines | public: | ||||
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; | ADD_SERIALIZE_METHODS; | ||||
template <typename Stream, typename Operation> | template <typename Stream, typename Operation> | ||||
inline void SerializationOp(Stream &s, Operation ser_action) { | inline void SerializationOp(Stream &s, Operation ser_action) { | ||||
READWRITE(FLATDATA(ip)); | READWRITE(ip); | ||||
unsigned short portN = htons(port); | unsigned short portN = htons(port); | ||||
READWRITE(FLATDATA(portN)); | READWRITE(FLATDATA(portN)); | ||||
if (ser_action.ForRead()) { | if (ser_action.ForRead()) { | ||||
port = ntohs(portN); | port = ntohs(portN); | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
#endif // BITCOIN_NETADDRESS_H | #endif // BITCOIN_NETADDRESS_H |