diff --git a/features/lwipstack/LWIPStack.cpp b/features/lwipstack/LWIPStack.cpp index ab6b00a1ed..350387083a 100644 --- a/features/lwipstack/LWIPStack.cpp +++ b/features/lwipstack/LWIPStack.cpp @@ -191,30 +191,13 @@ LWIP::call_in_callback_cb_t LWIP::get_call_in_callback() return cb; } -const char *LWIP::get_ip_address() +nsapi_error_t LWIP::get_ip_address(SocketAddress *address) { if (!default_interface) { - return NULL; + return NSAPI_ERROR_NO_ADDRESS; } - const ip_addr_t *addr = get_ip_addr(true, &default_interface->netif); - - if (!addr) { - return NULL; - } -#if LWIP_IPV6 - if (IP_IS_V6(addr)) { - return ip6addr_ntoa_r(ip_2_ip6(addr), ip_address, sizeof(ip_address)); - } -#endif -#if LWIP_IPV4 - if (IP_IS_V4(addr)) { - return ip4addr_ntoa_r(ip_2_ip4(addr), ip_address, sizeof(ip_address)); - } -#endif -#if LWIP_IPV6 && LWIP_IPV4 - return NULL; -#endif + return get_ip_address_if(address, nullptr); } nsapi_error_t LWIP::get_ip_address_if(SocketAddress *address, const char *interface_name) diff --git a/features/lwipstack/LWIPStack.h b/features/lwipstack/LWIPStack.h index b0fe021729..7f4f025e2b 100644 --- a/features/lwipstack/LWIPStack.h +++ b/features/lwipstack/LWIPStack.h @@ -93,7 +93,7 @@ public: */ virtual char *get_mac_address(char *buf, nsapi_size_t buflen); - /** @copydoc NetworkStack::get_ip_address */ + /** @copydoc OnboardNetworkStack::Interface::get_ip_address */ virtual nsapi_error_t get_ip_address(SocketAddress *address); /** Get the IPv6 link local address in SocketAddress representation @@ -304,19 +304,10 @@ public: */ virtual nsapi_error_t add_dns_server(const SocketAddress &address, const char *interface_name); - /** Get the local IP address - * - * @return Null-terminated representation of the local IP address - * or null if not yet connected - */ - virtual const char *get_ip_address(); + /** @copydoc NetworkStack::get_ip_address */ + virtual nsapi_error_t get_ip_address(SocketAddress *address); - /** Copies IP address of the name based network interface to user supplied buffer - * - * @param address SocketAddress object pointer to store the address - * @param interface_name name of the interface - * @return Pointer to a buffer, or NULL if the buffer is too small - */ + /** @copydoc NetworkStack::get_ip_address_if */ virtual nsapi_error_t get_ip_address_if(SocketAddress *address, const char *interface_name); /** Set the network interface as default one