Skip to content

Commit

Permalink
net: rename CNetAddr scopeId to m_scope_id, improve code doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatack committed Oct 2, 2020
1 parent 5cb5fd3 commit f36887f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/netaddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ CNetAddr::CNetAddr(const struct in_addr& ipv4Addr)
CNetAddr::CNetAddr(const struct in6_addr& ipv6Addr, const uint32_t scope)
{
SetLegacyIPv6(Span<const uint8_t>(reinterpret_cast<const uint8_t*>(&ipv6Addr), sizeof(ipv6Addr)));
scopeId = scope;
m_scope_id = scope;
}

bool CNetAddr::IsBindAny() const
Expand Down Expand Up @@ -918,7 +918,7 @@ bool CService::GetSockAddr(struct sockaddr* paddr, socklen_t *addrlen) const
memset(paddrin6, 0, *addrlen);
if (!GetIn6Addr(&paddrin6->sin6_addr))
return false;
paddrin6->sin6_scope_id = scopeId;
paddrin6->sin6_scope_id = m_scope_id;
paddrin6->sin6_family = AF_INET6;
paddrin6->sin6_port = htons(port);
return true;
Expand Down
8 changes: 6 additions & 2 deletions src/netaddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ class CNetAddr
*/
Network m_net{NET_IPV6};

uint32_t scopeId{0}; // for scoped/link-local ipv6 addresses
/**
* Scope id if scoped/link-local IPV6 address.
* See https://tools.ietf.org/html/rfc4007
*/
uint32_t m_scope_id{0};

public:
CNetAddr();
Expand Down Expand Up @@ -388,7 +392,7 @@ class CNetAddr
"Address too long: %u > %u", address_size, MAX_ADDRV2_SIZE));
}

scopeId = 0;
m_scope_id = 0;

if (SetNetFromBIP155Network(bip155_net, address_size)) {
m_addr.resize(address_size);
Expand Down

0 comments on commit f36887f

Please sign in to comment.