Skip to content

Commit 3d5962d

Browse files
author
Seppo Takalo
committed
Return localhost from NanostackInterface::get_ip_address()
For NetworkStack::gethostbyname() to properly validate the IP address version, we must return a valid address from Networkstack::get_ip_address().
1 parent 9f8fe89 commit 3d5962d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

features/nanostack/FEATURE_NANOSTACK/nanostack-interface/NanostackInterface.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,10 @@ NanostackInterface * NanostackInterface::get_stack()
457457

458458
const char * NanostackInterface::get_ip_address()
459459
{
460-
// Unsupported
461-
return NULL;
460+
// Must result a valid IPv6 address
461+
// For gethostbyname() to detect IP version.
462+
static const char localhost[] = "::";
463+
return localhost;
462464
}
463465

464466
nsapi_error_t NanostackInterface::socket_open(void **handle, nsapi_protocol_t protocol)

0 commit comments

Comments
 (0)