Changeset View
Changeset View
Standalone View
Standalone View
src/netaddress.h
// 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. | ||||
#ifndef BITCOIN_NETADDRESS_H | #ifndef BITCOIN_NETADDRESS_H | ||||
#define BITCOIN_NETADDRESS_H | #define BITCOIN_NETADDRESS_H | ||||
#if defined(HAVE_CONFIG_H) | #if defined(HAVE_CONFIG_H) | ||||
#include <config/bitcoin-config.h> | #include <config/bitcoin-config.h> | ||||
#endif | #endif | ||||
#include <compat.h> | #include <compat.h> | ||||
#include <serialize.h> | #include <serialize.h> | ||||
#include <span.h> | |||||
#include <cstdint> | #include <cstdint> | ||||
#include <string> | #include <string> | ||||
#include <vector> | #include <vector> | ||||
enum Network { | enum Network { | ||||
NET_UNROUTABLE = 0, | NET_UNROUTABLE = 0, | ||||
NET_IPV4, | NET_IPV4, | ||||
▲ Show 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | public: | ||||
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(ip); | READWRITE(ip); | ||||
unsigned short portN = htons(port); | unsigned short portN = htons(port); | ||||
READWRITE(FLATDATA(portN)); | READWRITE(Span<uint8_t>((uint8_t *)&portN, 2)); | ||||
if (ser_action.ForRead()) { | if (ser_action.ForRead()) { | ||||
port = ntohs(portN); | port = ntohs(portN); | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
#endif // BITCOIN_NETADDRESS_H | #endif // BITCOIN_NETADDRESS_H |