Commit d94e4de5 authored by Eli Lindsey's avatar Eli Lindsey Committed by Facebook Github Bot

add the getnameinfo error code and v6 scope id to exception text

Summary: Making the exception text more useful by adding getnameinfo's error code and the v6 scope id

Reviewed By: yangchi

Differential Revision: D5389137

fbshipit-source-id: e6b9b4edd7dd1859e0ed4d784b2f89a60a701955
parent e8527d2e
......@@ -405,10 +405,15 @@ IPAddressV6 IPAddressV6::mask(size_t numBits) const {
string IPAddressV6::str() const {
char buffer[INET6_ADDRSTRLEN] = {0};
sockaddr_in6 sock = toSockAddr();
if (!getnameinfo(
(sockaddr*)&sock, sizeof(sock),
buffer, INET6_ADDRSTRLEN,
nullptr, 0, NI_NUMERICHOST)) {
int error = getnameinfo(
(sockaddr*)&sock,
sizeof(sock),
buffer,
INET6_ADDRSTRLEN,
nullptr,
0,
NI_NUMERICHOST);
if (!error) {
string ip(buffer);
return ip;
} else {
......@@ -416,7 +421,11 @@ string IPAddressV6::str() const {
"Invalid address with hex ",
"'",
detail::Bytes::toHex(bytes(), 16),
"'"));
"%",
sock.sin6_scope_id,
"'",
" , with error ",
gai_strerror(error)));
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment