diff --git a/UNITTESTS/stubs/AT_CellularContext_stub.cpp b/UNITTESTS/stubs/AT_CellularContext_stub.cpp index f597601fe2..a99ea5e46b 100644 --- a/UNITTESTS/stubs/AT_CellularContext_stub.cpp +++ b/UNITTESTS/stubs/AT_CellularContext_stub.cpp @@ -116,11 +116,6 @@ nsapi_error_t AT_CellularContext::get_ip_address(SocketAddress *address) return NSAPI_ERROR_UNSUPPORTED; } -const char *AT_CellularContext::get_ip_address() -{ - return NULL; -} - void AT_CellularContext::attach(Callback status_cb) { } diff --git a/UNITTESTS/stubs/NetworkInterface_stub.cpp b/UNITTESTS/stubs/NetworkInterface_stub.cpp index 0a849d2497..a038c39d52 100644 --- a/UNITTESTS/stubs/NetworkInterface_stub.cpp +++ b/UNITTESTS/stubs/NetworkInterface_stub.cpp @@ -31,10 +31,6 @@ nsapi_error_t NetworkInterface::get_ip_address(SocketAddress *) return NSAPI_ERROR_UNSUPPORTED; } -const char *NetworkInterface::get_ip_address() -{ - return nullptr; -} nsapi_error_t NetworkInterface::get_ipv6_link_local_address(SocketAddress *address) { return NSAPI_ERROR_UNSUPPORTED; @@ -45,31 +41,16 @@ nsapi_error_t NetworkInterface::get_netmask(SocketAddress *) return NSAPI_ERROR_UNSUPPORTED; } -const char *NetworkInterface::get_netmask() -{ - return nullptr; -} - nsapi_error_t NetworkInterface::get_gateway(SocketAddress *) { return NSAPI_ERROR_UNSUPPORTED; } -const char *NetworkInterface::get_gateway() -{ - return nullptr; -} - nsapi_error_t NetworkInterface::set_network(const SocketAddress &ip_address, const SocketAddress &netmask, const SocketAddress &gateway) { return NSAPI_ERROR_UNSUPPORTED; } -nsapi_error_t NetworkInterface::set_network(const char *ip_address, const char *netmask, const char *gateway) -{ - return NSAPI_ERROR_UNSUPPORTED; -} - nsapi_error_t NetworkInterface::set_dhcp(bool dhcp) { return NSAPI_ERROR_UNSUPPORTED; diff --git a/UNITTESTS/stubs/NetworkStack_stub.cpp b/UNITTESTS/stubs/NetworkStack_stub.cpp index e6b7a431c7..664a8a60dd 100644 --- a/UNITTESTS/stubs/NetworkStack_stub.cpp +++ b/UNITTESTS/stubs/NetworkStack_stub.cpp @@ -104,11 +104,6 @@ nsapi_error_t NetworkStack::get_ip_address(SocketAddress* address) return NSAPI_ERROR_UNSUPPORTED; } -const char *NetworkStack::get_ip_address() -{ - return NULL; -} - nsapi_error_t NetworkStack::get_ipv6_link_local_address(SocketAddress *address) { return NSAPI_ERROR_UNSUPPORTED; @@ -118,8 +113,3 @@ nsapi_error_t NetworkStack::get_ip_address_if(SocketAddress* address, const char { return NSAPI_ERROR_UNSUPPORTED; } - -const char *NetworkStack::get_ip_address_if(const char *interface_name) -{ - return NULL; -} diff --git a/UNITTESTS/stubs/NetworkStack_stub.h b/UNITTESTS/stubs/NetworkStack_stub.h index 2c5ffac236..916937e645 100644 --- a/UNITTESTS/stubs/NetworkStack_stub.h +++ b/UNITTESTS/stubs/NetworkStack_stub.h @@ -40,10 +40,6 @@ public: { } - virtual const char *get_ip_address() - { - return "127.0.0.1"; - } virtual nsapi_error_t get_ip_address(SocketAddress* address) { address->set_ip_address("127.0.0.1"); diff --git a/components/wifi/esp8266-driver/ESP8266Interface.cpp b/components/wifi/esp8266-driver/ESP8266Interface.cpp index ce31c41a39..b9be381f93 100644 --- a/components/wifi/esp8266-driver/ESP8266Interface.cpp +++ b/components/wifi/esp8266-driver/ESP8266Interface.cpp @@ -507,22 +507,6 @@ int ESP8266Interface::disconnect() } } -const char *ESP8266Interface::get_ip_address() -{ - if (_software_conn_stat == IFACE_STATUS_DISCONNECTED) { - _esp.uart_enable_input(true); - } - - const char *ip_buff = _esp.ip_addr(); - if (!ip_buff || strcmp(ip_buff, "0.0.0.0") == 0) { - ip_buff = NULL; - } - if (_software_conn_stat == IFACE_STATUS_DISCONNECTED) { - _esp.uart_enable_input(false); - } - return ip_buff; -} - nsapi_error_t ESP8266Interface::get_ip_address(SocketAddress *address) { if (_software_conn_stat == IFACE_STATUS_DISCONNECTED) { diff --git a/components/wifi/esp8266-driver/ESP8266Interface.h b/components/wifi/esp8266-driver/ESP8266Interface.h index 0d20ed704e..764081da05 100644 --- a/components/wifi/esp8266-driver/ESP8266Interface.h +++ b/components/wifi/esp8266-driver/ESP8266Interface.h @@ -141,9 +141,6 @@ public: */ virtual nsapi_error_t get_ip_address(SocketAddress *address); - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - virtual const char *get_ip_address(); - /** Get the internally stored MAC address * @return MAC address of the interface */ diff --git a/features/cellular/framework/API/CellularContext.h b/features/cellular/framework/API/CellularContext.h index 1f3b4a7522..03569215f4 100644 --- a/features/cellular/framework/API/CellularContext.h +++ b/features/cellular/framework/API/CellularContext.h @@ -122,8 +122,6 @@ public: // from NetworkInterface virtual nsapi_error_t set_blocking(bool blocking) = 0; virtual NetworkStack *get_stack() = 0; virtual nsapi_error_t get_ip_address(SocketAddress *address) = 0; - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - virtual const char *get_ip_address() = 0; /** Register callback for status reporting. * diff --git a/features/cellular/framework/AT/AT_CellularContext.cpp b/features/cellular/framework/AT/AT_CellularContext.cpp index 575094de16..dd9fa678d9 100644 --- a/features/cellular/framework/AT/AT_CellularContext.cpp +++ b/features/cellular/framework/AT/AT_CellularContext.cpp @@ -233,21 +233,6 @@ nsapi_error_t AT_CellularContext::get_ip_address(SocketAddress *address) #endif } -const char *AT_CellularContext::get_ip_address() -{ -#if NSAPI_PPP_AVAILABLE - return nsapi_ppp_get_ip_addr(_at.get_file_handle()); -#else - if (!_stack) { - _stack = get_stack(); - } - if (_stack) { - return _stack->get_ip_address(); - } - return NULL; -#endif -} - char *AT_CellularContext::get_interface_name(char *interface_name) { if (_cid < 0) { diff --git a/features/cellular/framework/AT/AT_CellularContext.h b/features/cellular/framework/AT/AT_CellularContext.h index 49c425ca83..72c0d0f931 100644 --- a/features/cellular/framework/AT/AT_CellularContext.h +++ b/features/cellular/framework/AT/AT_CellularContext.h @@ -35,7 +35,6 @@ public: virtual nsapi_error_t set_blocking(bool blocking); virtual NetworkStack *get_stack(); virtual nsapi_error_t get_ip_address(SocketAddress *address); - virtual const char *get_ip_address(); virtual char *get_interface_name(char *interface_name); virtual void attach(mbed::Callback status_cb); virtual nsapi_error_t connect(); diff --git a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp index 309589d22e..77c1cb7d10 100644 --- a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp +++ b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp @@ -299,11 +299,6 @@ void UBLOX_AT_CellularContext::get_next_credentials(char **config) } } -const char *UBLOX_AT_CellularContext::get_gateway() -{ - return get_ip_address(); -} - nsapi_error_t UBLOX_AT_CellularContext::get_gateway(SocketAddress *addr) { return get_ip_address(addr); diff --git a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.h b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.h index 10198a26e5..4e2272d42f 100644 --- a/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.h +++ b/features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.h @@ -28,7 +28,6 @@ public: virtual ~UBLOX_AT_CellularContext(); virtual void do_connect(); - virtual const char *get_gateway(); virtual nsapi_error_t get_gateway(SocketAddress *addr); const char *get_apn(void); diff --git a/features/netsocket/CellularInterface.h b/features/netsocket/CellularInterface.h index d77c532bc7..647a523b84 100644 --- a/features/netsocket/CellularInterface.h +++ b/features/netsocket/CellularInterface.h @@ -98,9 +98,6 @@ public: /** @copydoc NetworkInterface::get_ip_address */ virtual nsapi_error_t get_ip_address(SocketAddress *address) = 0; - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - virtual const char *get_ip_address() = 0; - /** @copydoc NetworkInterface::cellularInterface */ virtual CellularInterface *cellularInterface() diff --git a/features/netsocket/DTLSSocket.cpp b/features/netsocket/DTLSSocket.cpp index 5bb2f3d811..eaf6dc559f 100644 --- a/features/netsocket/DTLSSocket.cpp +++ b/features/netsocket/DTLSSocket.cpp @@ -23,31 +23,6 @@ // This class requires Mbed TLS SSL/TLS client code #if defined(MBEDTLS_SSL_CLI_C) -nsapi_error_t DTLSSocket::connect(const char *host, uint16_t port) -{ - SocketAddress addr; - nsapi_error_t ret; - - ret = _udp_socket.getpeername(&addr); - if (ret != NSAPI_ERROR_NO_CONNECTION) { - return ret; - } - - if (!addr || ret == NSAPI_ERROR_NO_CONNECTION) { - nsapi_error_t err = _udp_socket._stack->gethostbyname(host, &addr); - if (err) { - return NSAPI_ERROR_DNS_FAILURE; - } - - addr.set_port(port); - - set_hostname(host); - _udp_socket.connect(addr); // UDPSocket::connect() cannot fail - } - - return connect(addr); -} - DTLSSocket::~DTLSSocket() { // Make sure that DTLSSocketWrapper::close() is called before the transport is diff --git a/features/netsocket/DTLSSocket.h b/features/netsocket/DTLSSocket.h index 66252a6cff..45de541ae4 100644 --- a/features/netsocket/DTLSSocket.h +++ b/features/netsocket/DTLSSocket.h @@ -87,19 +87,6 @@ public: using DTLSSocketWrapper::connect; - /** Connects TCP socket to a remote host. - * - * Initiates a connection to a remote server specified by either - * a domain name or an IP address and a port. - * - * @param host Hostname of the remote host. - * @param port Port of the remote host. - * @return NSAPI_ERROR_OK on success, negative error code on failure. - * See @ref TLSSocketWrapper::connect. - */ - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - nsapi_error_t connect(const char *host, uint16_t port); - private: UDPSocket _udp_socket; }; diff --git a/features/netsocket/EMACInterface.cpp b/features/netsocket/EMACInterface.cpp index 275ac601bf..240ca754a3 100644 --- a/features/netsocket/EMACInterface.cpp +++ b/features/netsocket/EMACInterface.cpp @@ -31,20 +31,6 @@ EMACInterface::EMACInterface(EMAC &emac, OnboardNetworkStack &stack) : { } -nsapi_error_t EMACInterface::set_network(const char *ip_address, const char *netmask, const char *gateway) -{ - _dhcp = false; - - strncpy(_ip_address, ip_address ? ip_address : "", sizeof(_ip_address)); - _ip_address[sizeof(_ip_address) - 1] = '\0'; - strncpy(_netmask, netmask ? netmask : "", sizeof(_netmask)); - _netmask[sizeof(_netmask) - 1] = '\0'; - strncpy(_gateway, gateway ? gateway : "", sizeof(_gateway)); - _gateway[sizeof(_gateway) - 1] = '\0'; - - return NSAPI_ERROR_OK; -} - nsapi_error_t EMACInterface::set_network(const SocketAddress &ip_address, const SocketAddress &netmask, const SocketAddress &gateway) { _dhcp = false; @@ -110,14 +96,6 @@ nsapi_error_t EMACInterface::get_ip_address(SocketAddress *address) return NSAPI_ERROR_NO_CONNECTION; } -const char *EMACInterface::get_ip_address() -{ - if (_interface && _interface->get_ip_address(_ip_address, sizeof(_ip_address))) { - return _ip_address; - } - return nullptr; -} - nsapi_error_t EMACInterface::get_ipv6_link_local_address(SocketAddress *address) { if (_interface) { @@ -137,14 +115,6 @@ nsapi_error_t EMACInterface::get_netmask(SocketAddress *address) return NSAPI_ERROR_NO_CONNECTION; } -const char *EMACInterface::get_netmask() -{ - if (_interface && _interface->get_netmask(_netmask, sizeof(_netmask))) { - return _netmask; - } - return nullptr; -} - nsapi_error_t EMACInterface::get_gateway(SocketAddress *address) { if (_interface && _interface->get_gateway(address) == NSAPI_ERROR_OK) { @@ -156,14 +126,6 @@ nsapi_error_t EMACInterface::get_gateway(SocketAddress *address) return NSAPI_ERROR_NO_CONNECTION; } -const char *EMACInterface::get_gateway() -{ - if (_interface && _interface->get_gateway(_gateway, sizeof(_gateway))) { - return _gateway; - } - return nullptr; -} - char *EMACInterface::get_interface_name(char *interface_name) { if (_interface) { diff --git a/features/netsocket/EMACInterface.h b/features/netsocket/EMACInterface.h index 70e6aef12a..d021daa6ed 100644 --- a/features/netsocket/EMACInterface.h +++ b/features/netsocket/EMACInterface.h @@ -66,9 +66,6 @@ public: */ virtual nsapi_error_t set_network(const SocketAddress &ip_address, const SocketAddress &netmask, const SocketAddress &gateway); - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - virtual nsapi_error_t set_network(const char *ip_address, const char *netmask, const char *gateway); - /** Enable or disable DHCP on the network * * Requires that the network is disconnected @@ -91,25 +88,15 @@ public: /** @copydoc NetworkInterface::get_ip_address */ virtual nsapi_error_t get_ip_address(SocketAddress *address); - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - virtual const char *get_ip_address(); - /** @copydoc NetworkInterface::get_ipv6_link_local_address */ virtual nsapi_error_t get_ipv6_link_local_address(SocketAddress *address); /** @copydoc NetworkInterface::get_netmask */ virtual nsapi_error_t get_netmask(SocketAddress *address); - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - virtual const char *get_netmask(); - /** @copydoc NetworkInterface::get_gateway */ virtual nsapi_error_t get_gateway(SocketAddress *address); - /** @copydoc NetworkInterface::get_gateway */ - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - virtual const char *get_gateway(); - /** @copydoc NetworkInterface::get_interface_name */ virtual char *get_interface_name(char *interface_name); diff --git a/features/netsocket/InternetDatagramSocket.cpp b/features/netsocket/InternetDatagramSocket.cpp index 7526a5e86c..3a6685d860 100644 --- a/features/netsocket/InternetDatagramSocket.cpp +++ b/features/netsocket/InternetDatagramSocket.cpp @@ -26,27 +26,6 @@ nsapi_error_t InternetDatagramSocket::connect(const SocketAddress &address) return NSAPI_ERROR_OK; } -nsapi_size_or_error_t InternetDatagramSocket::sendto(const char *host, uint16_t port, const void *data, nsapi_size_t size) -{ - SocketAddress address; - nsapi_size_or_error_t err; - - if (!strcmp(_interface_name, "")) { - err = _stack->gethostbyname(host, &address); - } else { - err = _stack->gethostbyname(host, &address, NSAPI_UNSPEC, _interface_name); - } - - if (err) { - return NSAPI_ERROR_DNS_FAILURE; - } - - address.set_port(port); - - // sendto is thread safe - return sendto(address, data, size); -} - nsapi_size_or_error_t InternetDatagramSocket::sendto(const SocketAddress &address, const void *data, nsapi_size_t size) { _lock.lock(); diff --git a/features/netsocket/InternetDatagramSocket.h b/features/netsocket/InternetDatagramSocket.h index cc9e40197f..3f8d3a5104 100644 --- a/features/netsocket/InternetDatagramSocket.h +++ b/features/netsocket/InternetDatagramSocket.h @@ -29,29 +29,6 @@ */ class InternetDatagramSocket : public InternetSocket { public: - - /** Send data to the specified host and port. - * - * By default, sendto blocks until data is sent. If socket is set to - * nonblocking or times out, NSAPI_ERROR_WOULD_BLOCK is returned - * immediately. - * - * @param host Domain name of the remote host or a dotted notation IP address. - * @param port Port of the remote host. - * @param data Buffer of data to send to the host. - * @param size Size of the buffer in bytes. - * @retval int Number of sent bytes on success. - * @retval NSAPI_ERROR_NO_SOCKET in case socket was not created correctly. - * @retval NSAPI_ERROR_DNS_FAILURE if the DNS address of host could not be resolved - * @retval NSAPI_ERROR_WOULD_BLOCK in case non-blocking mode is enabled - * and send cannot be performed immediately. - * @retval int Other negative error codes for stack-related failures. - * See @ref NetworkStack::socket_send. - */ - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - virtual nsapi_size_or_error_t sendto(const char *host, uint16_t port, - const void *data, nsapi_size_t size); - /** Send data to the specified address. * * By default, sendto blocks until data is sent. If socket is set to diff --git a/features/netsocket/InternetSocket.cpp b/features/netsocket/InternetSocket.cpp index 926ba8b335..2d3f06f7a3 100644 --- a/features/netsocket/InternetSocket.cpp +++ b/features/netsocket/InternetSocket.cpp @@ -127,13 +127,6 @@ nsapi_error_t InternetSocket::bind(uint16_t port) return bind(addr); } -nsapi_error_t InternetSocket::bind(const char *address, uint16_t port) -{ - // Underlying bind is thread safe - SocketAddress addr(address, port); - return bind(addr); -} - nsapi_error_t InternetSocket::bind(const SocketAddress &address) { _lock.lock(); diff --git a/features/netsocket/InternetSocket.h b/features/netsocket/InternetSocket.h index 3d803ef0f6..cc5e335f8a 100644 --- a/features/netsocket/InternetSocket.h +++ b/features/netsocket/InternetSocket.h @@ -96,19 +96,6 @@ public: */ nsapi_error_t bind(uint16_t port); - /** Bind the socket to a specific address and port on which to receive - * data. If the IP address is zeroed, only the port is bound. - * - * @param address Null-terminated local address to bind. - * @param port Local port to bind. - * @retval NSAPI_ERROR_OK on success. - * @retval NSAPI_ERROR_NO_SOCKET if socket is not open. - * @retval int negative error codes for stack-related failures. - * See @ref NetworkStack::socket_bind. - */ - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - nsapi_error_t bind(const char *address, uint16_t port); - /** @copydoc Socket::bind */ virtual nsapi_error_t bind(const SocketAddress &address); diff --git a/features/netsocket/NetworkInterface.cpp b/features/netsocket/NetworkInterface.cpp index 276a24fdc0..9a682904bb 100644 --- a/features/netsocket/NetworkInterface.cpp +++ b/features/netsocket/NetworkInterface.cpp @@ -37,11 +37,6 @@ nsapi_error_t NetworkInterface::get_ip_address(SocketAddress *) return NSAPI_ERROR_UNSUPPORTED; } -const char *NetworkInterface::get_ip_address() -{ - return nullptr; -} - nsapi_error_t NetworkInterface::get_ipv6_link_local_address(SocketAddress *address) { return NSAPI_ERROR_UNSUPPORTED; @@ -52,31 +47,16 @@ nsapi_error_t NetworkInterface::get_netmask(SocketAddress *) return NSAPI_ERROR_UNSUPPORTED; } -const char *NetworkInterface::get_netmask() -{ - return nullptr; -} - nsapi_error_t NetworkInterface::get_gateway(SocketAddress *) { return NSAPI_ERROR_UNSUPPORTED; } -const char *NetworkInterface::get_gateway() -{ - return nullptr; -} - char *NetworkInterface::get_interface_name(char *interface_name) { return 0; } -nsapi_error_t NetworkInterface::set_network(const char *ip_address, const char *netmask, const char *gateway) -{ - return NSAPI_ERROR_UNSUPPORTED; -} - nsapi_error_t NetworkInterface::set_network(const SocketAddress &ip_address, const SocketAddress &netmask, const SocketAddress &gateway) { return NSAPI_ERROR_UNSUPPORTED; diff --git a/features/netsocket/NetworkInterface.h b/features/netsocket/NetworkInterface.h index a31f3ca65e..3ba5d46eac 100644 --- a/features/netsocket/NetworkInterface.h +++ b/features/netsocket/NetworkInterface.h @@ -110,9 +110,6 @@ public: */ virtual nsapi_error_t get_ip_address(SocketAddress *address); - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - virtual const char *get_ip_address(); - /** Get the IPv6 link local address * * @param address SocketAddress representation of the link local IPv6 address @@ -132,9 +129,6 @@ public: */ virtual nsapi_error_t get_netmask(SocketAddress *address); - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - virtual const char *get_netmask(); - /** Get the local gateway. * * @param address SocketAddress representation of gateway address @@ -145,9 +139,6 @@ public: */ virtual nsapi_error_t get_gateway(SocketAddress *address); - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - virtual const char *get_gateway(); - /** Get the network interface name * * @return Null-terminated representation of the network interface name @@ -167,9 +158,6 @@ public: */ virtual nsapi_error_t set_network(const SocketAddress &ip_address, const SocketAddress &netmask, const SocketAddress &gateway); - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - virtual nsapi_error_t set_network(const char *ip_address, const char *netmask, const char *gateway); - /** Enable or disable DHCP on connecting the network. * * Enabled by default unless a static IP address has been assigned. Requires diff --git a/features/netsocket/NetworkStack.cpp b/features/netsocket/NetworkStack.cpp index 3c115e5060..ee34f0f950 100644 --- a/features/netsocket/NetworkStack.cpp +++ b/features/netsocket/NetworkStack.cpp @@ -29,11 +29,6 @@ nsapi_error_t NetworkStack::get_ip_address(SocketAddress *address) return NSAPI_ERROR_UNSUPPORTED; } -const char *NetworkStack::get_ip_address() -{ - return nullptr; -} - nsapi_error_t NetworkStack::get_ipv6_link_local_address(SocketAddress *address) { return NSAPI_ERROR_UNSUPPORTED; @@ -44,11 +39,6 @@ nsapi_error_t NetworkStack::get_ip_address_if(SocketAddress *address, const char return NSAPI_ERROR_UNSUPPORTED; } -const char *NetworkStack::get_ip_address_if(const char *interface_name) -{ - return nullptr; -} - nsapi_error_t NetworkStack::gethostbyname(const char *name, SocketAddress *address, nsapi_version_t version, const char *interface_name) { if (name[0] == '\0') { diff --git a/features/netsocket/NetworkStack.h b/features/netsocket/NetworkStack.h index 0184cd83be..b0d50a7013 100644 --- a/features/netsocket/NetworkStack.h +++ b/features/netsocket/NetworkStack.h @@ -51,9 +51,6 @@ public: */ virtual nsapi_error_t get_ip_address(SocketAddress *address); - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - virtual const char *get_ip_address(); - /** Get the IPv6 link local address * * @param address SocketAddress representation of the link local IPv6 address @@ -74,9 +71,6 @@ public: */ virtual nsapi_error_t get_ip_address_if(SocketAddress *address, const char *interface_name); - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - virtual const char *get_ip_address_if(const char *interface_name); - /** Translates a hostname to an IP address with specific version * * The hostname may be either a domain name or an IP address. If the diff --git a/features/netsocket/OnboardNetworkStack.h b/features/netsocket/OnboardNetworkStack.h index cf1c7aa47f..78a5484084 100644 --- a/features/netsocket/OnboardNetworkStack.h +++ b/features/netsocket/OnboardNetworkStack.h @@ -112,9 +112,6 @@ public: /** @copydoc NetworkStack::get_ip_address */ virtual nsapi_error_t get_ip_address(SocketAddress *address) = 0; - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - virtual char *get_ip_address(char *buf, nsapi_size_t buflen) = 0; - /** @copydoc NetworkStack::get_ipv6_link_local_address */ virtual nsapi_error_t get_ipv6_link_local_address(SocketAddress *address) { @@ -124,14 +121,8 @@ public: /** @copydoc NetworkStack::get_netmask */ virtual nsapi_error_t get_netmask(SocketAddress *address) = 0; - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - virtual char *get_netmask(char *buf, nsapi_size_t buflen) = 0; - /** @copydoc NetworkStack::get_gateway */ virtual nsapi_error_t get_gateway(SocketAddress *address) = 0; - - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - virtual char *get_gateway(char *buf, nsapi_size_t buflen) = 0; }; /** Register a network interface with the IP stack diff --git a/features/netsocket/PPPInterface.cpp b/features/netsocket/PPPInterface.cpp index e66321d780..9cd55716a5 100644 --- a/features/netsocket/PPPInterface.cpp +++ b/features/netsocket/PPPInterface.cpp @@ -83,15 +83,6 @@ nsapi_error_t PPPInterface::disconnect() return NSAPI_ERROR_NO_CONNECTION; } -const char *PPPInterface::get_ip_address() -{ - if (_interface && _interface->get_ip_address(_ip_address, sizeof(_ip_address))) { - return _ip_address; - } - - return NULL; -} - nsapi_error_t PPPInterface::get_ip_address(SocketAddress *address) { if (_interface && _interface->get_ip_address(address) == NSAPI_ERROR_OK) { @@ -123,24 +114,6 @@ nsapi_error_t PPPInterface::get_gateway(SocketAddress *address) return NSAPI_ERROR_NO_CONNECTION; } -const char *PPPInterface::get_netmask() -{ - if (_interface && _interface->get_netmask(_netmask, sizeof(_netmask))) { - return _netmask; - } - - return 0; -} - -const char *PPPInterface::get_gateway() -{ - if (_interface && _interface->get_gateway(_gateway, sizeof(_gateway))) { - return _gateway; - } - - return 0; -} - char *PPPInterface::get_interface_name(char *interface_name) { if (_interface) { diff --git a/features/netsocket/PPPInterface.h b/features/netsocket/PPPInterface.h index a98c409d93..58189efc58 100644 --- a/features/netsocket/PPPInterface.h +++ b/features/netsocket/PPPInterface.h @@ -59,9 +59,6 @@ public: /** @copydoc NetworkInterface::disconnect */ virtual nsapi_error_t disconnect(); - /** @copydoc NetworkInterface::get_ip_address */ - virtual const char *get_ip_address(); - /** @copydoc NetworkInterface::get_ip_address */ virtual nsapi_error_t get_ip_address(SocketAddress *address); @@ -71,12 +68,6 @@ public: /** @copydoc NetworkInterface::get_gateway */ virtual nsapi_error_t get_gateway(SocketAddress *address); - /** @copydoc NetworkInterface::get_netmask */ - virtual const char *get_netmask(); - - /** @copydoc NetworkInterface::get_gateway */ - virtual const char *get_gateway(); - /** @copydoc NetworkInterface::get_interface_name */ virtual char *get_interface_name(char *interface_name); diff --git a/features/netsocket/TCPSocket.cpp b/features/netsocket/TCPSocket.cpp index 02c29095f8..662021104d 100644 --- a/features/netsocket/TCPSocket.cpp +++ b/features/netsocket/TCPSocket.cpp @@ -104,28 +104,6 @@ nsapi_error_t TCPSocket::connect(const SocketAddress &address) return ret; } -nsapi_error_t TCPSocket::connect(const char *host, uint16_t port) -{ - SocketAddress address; - if (!_socket) { - return NSAPI_ERROR_NO_SOCKET; - } - nsapi_error_t err; - if (!strcmp(_interface_name, "")) { - err = _stack->gethostbyname(host, &address); - } else { - err = _stack->gethostbyname(host, &address, NSAPI_UNSPEC, _interface_name); - } - if (err) { - return NSAPI_ERROR_DNS_FAILURE; - } - - address.set_port(port); - - // connect is thread safe - return connect(address); -} - nsapi_size_or_error_t TCPSocket::send(const void *data, nsapi_size_t size) { _lock.lock(); diff --git a/features/netsocket/TCPSocket.h b/features/netsocket/TCPSocket.h index 113581190c..87df0d960f 100644 --- a/features/netsocket/TCPSocket.h +++ b/features/netsocket/TCPSocket.h @@ -70,24 +70,6 @@ public: return NSAPI_ERROR_UNSUPPORTED; } - /** Connects TCP socket to a remote host - * - * Initiates a connection to a remote server specified by either - * a domain name or an IP address and a port. - * - * @param host Hostname of the remote host - * @param port Port of the remote host - * @retval NSAPI_ERROR_OK on success - * @retval NSAPI_ERROR_IN_PROGRESS if the operation is ongoing - * @retval NSAPI_ERROR_NO_SOCKET if the socket has not been allocated - * @retval NSAPI_ERROR_DNS_FAILURE if the DNS address of host could not be resolved - * @retval NSAPI_ERROR_IS_CONNECTED if the connection is already established - * @retval int Other negative error codes for stack-related failures. - * See NetworkStack::socket_connect(). - */ - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - nsapi_error_t connect(const char *host, uint16_t port); - /** Connects TCP socket to a remote host * * Initiates a connection to a remote server specified by the diff --git a/features/netsocket/TLSSocket.cpp b/features/netsocket/TLSSocket.cpp index 359613a98b..87ee46fa55 100644 --- a/features/netsocket/TLSSocket.cpp +++ b/features/netsocket/TLSSocket.cpp @@ -25,21 +25,6 @@ // This class requires Mbed TLS SSL/TLS client code #if defined(MBEDTLS_SSL_CLI_C) -nsapi_error_t TLSSocket::connect(const char *host, uint16_t port) -{ - nsapi_error_t ret = NSAPI_ERROR_OK; - if (!is_handshake_started()) { - ret = tcp_socket.connect(host, port); - if (ret == NSAPI_ERROR_OK || ret == NSAPI_ERROR_IN_PROGRESS) { - set_hostname(host); - } - if (ret != NSAPI_ERROR_OK && ret != NSAPI_ERROR_IS_CONNECTED) { - return ret; - } - } - return TLSSocketWrapper::start_handshake(ret == NSAPI_ERROR_OK); -} - TLSSocket::~TLSSocket() { /* Transport is a member of TLSSocket which is derived from TLSSocketWrapper. @@ -91,15 +76,6 @@ nsapi_error_t TLSSocket::set_client_cert_key(const char *client_cert_pem, const return set_client_cert_key(client_cert_pem, strlen(client_cert_pem), client_private_key_pem, strlen(client_private_key_pem)); } -nsapi_error_t TLSSocket::connect(const char *host, uint16_t port) -{ - nsapi_error_t ret = enable_tlssocket(); - if (ret == NSAPI_ERROR_OK) { - ret = TCPSocket::connect(host, port); - } - return ret; -} - nsapi_error_t TLSSocket::connect(const SocketAddress &address) { nsapi_error_t ret = enable_tlssocket(); diff --git a/features/netsocket/TLSSocket.h b/features/netsocket/TLSSocket.h index 4fde00379a..c40cb34100 100644 --- a/features/netsocket/TLSSocket.h +++ b/features/netsocket/TLSSocket.h @@ -80,22 +80,6 @@ public: using TLSSocketWrapper::connect; - /** Connects TCP socket to a remote host. - * - * Initiates a connection to a remote server specified by either - * a domain name or an IP address and port. - * - * @note: In case connect() returns NSAPI_ERROR_AUTH_FAILURE, - * the socket must be freed either by calling close() or destroying it. - * - * @param host Hostname of the remote host. - * @param port Port of the remote host. - * @return NSAPI_ERROR_OK on success, negative error code on failure. - * See @ref TLSSocketWrapper::connect. - */ - MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated") - nsapi_error_t connect(const char *host, uint16_t port); - private: TCPSocket tcp_socket; }; diff --git a/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/CyDhcpServer.cpp b/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/CyDhcpServer.cpp index 89464bd0d2..ca84423ff9 100644 --- a/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/CyDhcpServer.cpp +++ b/features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_WHD/interface/CyDhcpServer.cpp @@ -168,8 +168,9 @@ static void sendPacket(UDPSocket *socket, dhcp_packet_t *dhcp, uint32_t size) uint32_t broadcast_ip = 0xFFFFFFFF; char string_addr[16]; ipv4_to_string(string_addr, htonl(broadcast_ip)); + SocketAddress sock_addr(string_addr, IP_PORT_DHCP_CLIENT); - err = socket->sendto(string_addr, IP_PORT_DHCP_CLIENT, reinterpret_cast(dhcp), size); + err = socket->sendto(sock_addr, reinterpret_cast(dhcp), size); if (err < 0) { printf("DHCP ERROR: Packet send failure with error %d.", err); } else if (err != (int)size) { @@ -352,8 +353,11 @@ void CyDhcpServer::runServer(void) _socket.bind((uint16_t)IP_PORT_DHCP_SERVER); /* Save the current netmask to be sent in DHCP packets as the 'subnet mask option' */ - _server_addr.addrv4.addr = string_to_ipv4(_niface->get_ip_address()); - _netmask.addrv4.addr = string_to_ipv4(_niface->get_netmask()); + SocketAddress sock_addr; + _niface->get_ip_address(&sock_addr); + _server_addr.addrv4.addr = string_to_ipv4(sock_addr.get_ip_address()); + _niface->get_netmask(&sock_addr); + _netmask.addrv4.addr = string_to_ipv4(sock_addr.get_ip_address()); #ifdef DHCP_EXTENSIVE_DEBUG printf("DHCP Server started.\n"); diff --git a/features/netsocket/ppp/ppp_nsapi.cpp b/features/netsocket/ppp/ppp_nsapi.cpp index e02617da55..d7ad910d32 100644 --- a/features/netsocket/ppp/ppp_nsapi.cpp +++ b/features/netsocket/ppp/ppp_nsapi.cpp @@ -133,7 +133,9 @@ const char *nsapi_ppp_get_ip_addr(FileHandle *stream) static char ip_addr[IPADDR_STRLEN_MAX]; if (stream == my_stream) { - if (my_interface->get_ip_address(ip_addr, IPADDR_STRLEN_MAX)) { + SocketAddress addr; + if (my_interface->get_ip_address(&addr) == NSAPI_ERROR_OK) { + strncpy(ip_addr, addr.get_ip_address(), IPADDR_STRLEN_MAX); return ip_addr; } } @@ -148,7 +150,9 @@ const char *nsapi_ppp_get_netmask(FileHandle *stream) static char netmask[IPADDR_STRLEN_MAX]; if (stream == my_stream) { - if (my_interface->get_netmask(netmask, IPADDR_STRLEN_MAX)) { + SocketAddress addr; + if (my_interface->get_netmask(&addr)) { + strncpy(netmask, addr.get_ip_address(), IPADDR_STRLEN_MAX); return netmask; } } @@ -163,7 +167,9 @@ const char *nsapi_ppp_get_gw_addr(FileHandle *stream) static char gwaddr[IPADDR_STRLEN_MAX]; if (stream == my_stream) { - if (my_interface->get_gateway(gwaddr, IPADDR_STRLEN_MAX)) { + SocketAddress addr; + if (my_interface->get_gateway(&addr)) { + strncpy(gwaddr, addr.get_ip_address(), IPADDR_STRLEN_MAX); return gwaddr; } }