mirror of https://github.com/ARMmbed/mbed-os.git
Correct LWIP::get_ip_address
Previous change that removed string-based APIs missed `LWIP::get_ip_address`. Remove string-based method (which is not overriding anything in `NetworkInterface`) and add missing binary form to implement `NetworkInterface::get_ip_address`.pull/12489/head
parent
8f1bf967d3
commit
b4c1f7f3da
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue