mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Read IPv6 address from mDNS record.
PiperOrigin-RevId: 822743670
This commit is contained in:
committed by
Copybara-Service
parent
7e8cbfc140
commit
bd21843464
@@ -17,6 +17,7 @@
|
||||
#include <winsock2.h>
|
||||
#include <ws2ipdef.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
@@ -201,4 +202,22 @@ std::string SocketAddress::ToString() const {
|
||||
return address_string;
|
||||
}
|
||||
|
||||
bool SocketAddress::IsV6LinkLocal() const {
|
||||
if (address_.ss_family != AF_INET6) {
|
||||
return false;
|
||||
}
|
||||
const sockaddr_in6* v6_address =
|
||||
reinterpret_cast<const sockaddr_in6*>(&address_);
|
||||
return IN6_IS_ADDR_LINKLOCAL(&v6_address->sin6_addr);
|
||||
}
|
||||
|
||||
bool SocketAddress::SetScopeId(uint32_t scope_id) {
|
||||
if (address_.ss_family != AF_INET6) {
|
||||
return false;
|
||||
}
|
||||
sockaddr_in6* v6_address = reinterpret_cast<sockaddr_in6*>(&address_);
|
||||
v6_address->sin6_scope_id = scope_id;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace nearby::windows
|
||||
|
||||
Reference in New Issue
Block a user