Skip to content

Commit 458957d

Browse files
IPCore deprecated string-based API removal
String-based functions should be replaced with an explicit DNS hostname resolution and a SocketAddress-based API.
1 parent 8dc15ee commit 458957d

33 files changed

+16
-416
lines changed

Diff for: UNITTESTS/stubs/AT_CellularContext_stub.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,6 @@ nsapi_error_t AT_CellularContext::get_ip_address(SocketAddress *address)
116116
return NSAPI_ERROR_UNSUPPORTED;
117117
}
118118

119-
const char *AT_CellularContext::get_ip_address()
120-
{
121-
return NULL;
122-
}
123-
124119
void AT_CellularContext::attach(Callback<void(nsapi_event_t, intptr_t)> status_cb)
125120
{
126121
}

Diff for: UNITTESTS/stubs/NetworkInterface_stub.cpp

-19
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ nsapi_error_t NetworkInterface::get_ip_address(SocketAddress *)
3131
return NSAPI_ERROR_UNSUPPORTED;
3232
}
3333

34-
const char *NetworkInterface::get_ip_address()
35-
{
36-
return nullptr;
37-
}
3834
nsapi_error_t NetworkInterface::get_ipv6_link_local_address(SocketAddress *address)
3935
{
4036
return NSAPI_ERROR_UNSUPPORTED;
@@ -45,31 +41,16 @@ nsapi_error_t NetworkInterface::get_netmask(SocketAddress *)
4541
return NSAPI_ERROR_UNSUPPORTED;
4642
}
4743

48-
const char *NetworkInterface::get_netmask()
49-
{
50-
return nullptr;
51-
}
52-
5344
nsapi_error_t NetworkInterface::get_gateway(SocketAddress *)
5445
{
5546
return NSAPI_ERROR_UNSUPPORTED;
5647
}
5748

58-
const char *NetworkInterface::get_gateway()
59-
{
60-
return nullptr;
61-
}
62-
6349
nsapi_error_t NetworkInterface::set_network(const SocketAddress &ip_address, const SocketAddress &netmask, const SocketAddress &gateway)
6450
{
6551
return NSAPI_ERROR_UNSUPPORTED;
6652
}
6753

68-
nsapi_error_t NetworkInterface::set_network(const char *ip_address, const char *netmask, const char *gateway)
69-
{
70-
return NSAPI_ERROR_UNSUPPORTED;
71-
}
72-
7354
nsapi_error_t NetworkInterface::set_dhcp(bool dhcp)
7455
{
7556
return NSAPI_ERROR_UNSUPPORTED;

Diff for: UNITTESTS/stubs/NetworkStack_stub.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,6 @@ nsapi_error_t NetworkStack::get_ip_address(SocketAddress* address)
104104
return NSAPI_ERROR_UNSUPPORTED;
105105
}
106106

107-
const char *NetworkStack::get_ip_address()
108-
{
109-
return NULL;
110-
}
111-
112107
nsapi_error_t NetworkStack::get_ipv6_link_local_address(SocketAddress *address)
113108
{
114109
return NSAPI_ERROR_UNSUPPORTED;
@@ -118,8 +113,3 @@ nsapi_error_t NetworkStack::get_ip_address_if(SocketAddress* address, const char
118113
{
119114
return NSAPI_ERROR_UNSUPPORTED;
120115
}
121-
122-
const char *NetworkStack::get_ip_address_if(const char *interface_name)
123-
{
124-
return NULL;
125-
}

Diff for: UNITTESTS/stubs/NetworkStack_stub.h

-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ class NetworkStackstub : public NetworkStack {
4040
{
4141
}
4242

43-
virtual const char *get_ip_address()
44-
{
45-
return "127.0.0.1";
46-
}
4743
virtual nsapi_error_t get_ip_address(SocketAddress* address)
4844
{
4945
address->set_ip_address("127.0.0.1");

Diff for: components/wifi/esp8266-driver/ESP8266Interface.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -507,22 +507,6 @@ int ESP8266Interface::disconnect()
507507
}
508508
}
509509

510-
const char *ESP8266Interface::get_ip_address()
511-
{
512-
if (_software_conn_stat == IFACE_STATUS_DISCONNECTED) {
513-
_esp.uart_enable_input(true);
514-
}
515-
516-
const char *ip_buff = _esp.ip_addr();
517-
if (!ip_buff || strcmp(ip_buff, "0.0.0.0") == 0) {
518-
ip_buff = NULL;
519-
}
520-
if (_software_conn_stat == IFACE_STATUS_DISCONNECTED) {
521-
_esp.uart_enable_input(false);
522-
}
523-
return ip_buff;
524-
}
525-
526510
nsapi_error_t ESP8266Interface::get_ip_address(SocketAddress *address)
527511
{
528512
if (_software_conn_stat == IFACE_STATUS_DISCONNECTED) {

Diff for: components/wifi/esp8266-driver/ESP8266Interface.h

-3
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,6 @@ class ESP8266Interface : public NetworkStack, public WiFiInterface {
141141
*/
142142
virtual nsapi_error_t get_ip_address(SocketAddress *address);
143143

144-
MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated")
145-
virtual const char *get_ip_address();
146-
147144
/** Get the internally stored MAC address
148145
* @return MAC address of the interface
149146
*/

Diff for: features/cellular/framework/API/CellularContext.h

-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ class CellularContext : public CellularInterface {
122122
virtual nsapi_error_t set_blocking(bool blocking) = 0;
123123
virtual NetworkStack *get_stack() = 0;
124124
virtual nsapi_error_t get_ip_address(SocketAddress *address) = 0;
125-
MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated")
126-
virtual const char *get_ip_address() = 0;
127125

128126
/** Register callback for status reporting.
129127
*

Diff for: features/cellular/framework/AT/AT_CellularContext.cpp

-15
Original file line numberDiff line numberDiff line change
@@ -233,21 +233,6 @@ nsapi_error_t AT_CellularContext::get_ip_address(SocketAddress *address)
233233
#endif
234234
}
235235

236-
const char *AT_CellularContext::get_ip_address()
237-
{
238-
#if NSAPI_PPP_AVAILABLE
239-
return nsapi_ppp_get_ip_addr(_at.get_file_handle());
240-
#else
241-
if (!_stack) {
242-
_stack = get_stack();
243-
}
244-
if (_stack) {
245-
return _stack->get_ip_address();
246-
}
247-
return NULL;
248-
#endif
249-
}
250-
251236
char *AT_CellularContext::get_interface_name(char *interface_name)
252237
{
253238
if (_cid < 0) {

Diff for: features/cellular/framework/AT/AT_CellularContext.h

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class AT_CellularContext : public CellularContext {
3535
virtual nsapi_error_t set_blocking(bool blocking);
3636
virtual NetworkStack *get_stack();
3737
virtual nsapi_error_t get_ip_address(SocketAddress *address);
38-
virtual const char *get_ip_address();
3938
virtual char *get_interface_name(char *interface_name);
4039
virtual void attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
4140
virtual nsapi_error_t connect();

Diff for: features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,6 @@ void UBLOX_AT_CellularContext::get_next_credentials(char **config)
299299
}
300300
}
301301

302-
const char *UBLOX_AT_CellularContext::get_gateway()
303-
{
304-
return get_ip_address();
305-
}
306-
307302
nsapi_error_t UBLOX_AT_CellularContext::get_gateway(SocketAddress *addr)
308303
{
309304
return get_ip_address(addr);

Diff for: features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.h

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class UBLOX_AT_CellularContext: public AT_CellularContext {
2828
virtual ~UBLOX_AT_CellularContext();
2929

3030
virtual void do_connect();
31-
virtual const char *get_gateway();
3231
virtual nsapi_error_t get_gateway(SocketAddress *addr);
3332

3433
const char *get_apn(void);

Diff for: features/netsocket/CellularInterface.h

-3
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ class CellularInterface: public NetworkInterface {
9898
/** @copydoc NetworkInterface::get_ip_address */
9999
virtual nsapi_error_t get_ip_address(SocketAddress *address) = 0;
100100

101-
MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated")
102-
virtual const char *get_ip_address() = 0;
103-
104101
/** @copydoc NetworkInterface::cellularInterface
105102
*/
106103
virtual CellularInterface *cellularInterface()

Diff for: features/netsocket/DTLSSocket.cpp

-25
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,6 @@
2323
// This class requires Mbed TLS SSL/TLS client code
2424
#if defined(MBEDTLS_SSL_CLI_C)
2525

26-
nsapi_error_t DTLSSocket::connect(const char *host, uint16_t port)
27-
{
28-
SocketAddress addr;
29-
nsapi_error_t ret;
30-
31-
ret = _udp_socket.getpeername(&addr);
32-
if (ret != NSAPI_ERROR_NO_CONNECTION) {
33-
return ret;
34-
}
35-
36-
if (!addr || ret == NSAPI_ERROR_NO_CONNECTION) {
37-
nsapi_error_t err = _udp_socket._stack->gethostbyname(host, &addr);
38-
if (err) {
39-
return NSAPI_ERROR_DNS_FAILURE;
40-
}
41-
42-
addr.set_port(port);
43-
44-
set_hostname(host);
45-
_udp_socket.connect(addr); // UDPSocket::connect() cannot fail
46-
}
47-
48-
return connect(addr);
49-
}
50-
5126
DTLSSocket::~DTLSSocket()
5227
{
5328
// Make sure that DTLSSocketWrapper::close() is called before the transport is

Diff for: features/netsocket/DTLSSocket.h

-13
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,6 @@ class DTLSSocket : public DTLSSocketWrapper {
8787

8888
using DTLSSocketWrapper::connect;
8989

90-
/** Connects TCP socket to a remote host.
91-
*
92-
* Initiates a connection to a remote server specified by either
93-
* a domain name or an IP address and a port.
94-
*
95-
* @param host Hostname of the remote host.
96-
* @param port Port of the remote host.
97-
* @return NSAPI_ERROR_OK on success, negative error code on failure.
98-
* See @ref TLSSocketWrapper::connect.
99-
*/
100-
MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated")
101-
nsapi_error_t connect(const char *host, uint16_t port);
102-
10390
private:
10491
UDPSocket _udp_socket;
10592
};

Diff for: features/netsocket/EMACInterface.cpp

-38
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,6 @@ EMACInterface::EMACInterface(EMAC &emac, OnboardNetworkStack &stack) :
3131
{
3232
}
3333

34-
nsapi_error_t EMACInterface::set_network(const char *ip_address, const char *netmask, const char *gateway)
35-
{
36-
_dhcp = false;
37-
38-
strncpy(_ip_address, ip_address ? ip_address : "", sizeof(_ip_address));
39-
_ip_address[sizeof(_ip_address) - 1] = '\0';
40-
strncpy(_netmask, netmask ? netmask : "", sizeof(_netmask));
41-
_netmask[sizeof(_netmask) - 1] = '\0';
42-
strncpy(_gateway, gateway ? gateway : "", sizeof(_gateway));
43-
_gateway[sizeof(_gateway) - 1] = '\0';
44-
45-
return NSAPI_ERROR_OK;
46-
}
47-
4834
nsapi_error_t EMACInterface::set_network(const SocketAddress &ip_address, const SocketAddress &netmask, const SocketAddress &gateway)
4935
{
5036
_dhcp = false;
@@ -110,14 +96,6 @@ nsapi_error_t EMACInterface::get_ip_address(SocketAddress *address)
11096
return NSAPI_ERROR_NO_CONNECTION;
11197
}
11298

113-
const char *EMACInterface::get_ip_address()
114-
{
115-
if (_interface && _interface->get_ip_address(_ip_address, sizeof(_ip_address))) {
116-
return _ip_address;
117-
}
118-
return nullptr;
119-
}
120-
12199
nsapi_error_t EMACInterface::get_ipv6_link_local_address(SocketAddress *address)
122100
{
123101
if (_interface) {
@@ -137,14 +115,6 @@ nsapi_error_t EMACInterface::get_netmask(SocketAddress *address)
137115
return NSAPI_ERROR_NO_CONNECTION;
138116
}
139117

140-
const char *EMACInterface::get_netmask()
141-
{
142-
if (_interface && _interface->get_netmask(_netmask, sizeof(_netmask))) {
143-
return _netmask;
144-
}
145-
return nullptr;
146-
}
147-
148118
nsapi_error_t EMACInterface::get_gateway(SocketAddress *address)
149119
{
150120
if (_interface && _interface->get_gateway(address) == NSAPI_ERROR_OK) {
@@ -156,14 +126,6 @@ nsapi_error_t EMACInterface::get_gateway(SocketAddress *address)
156126
return NSAPI_ERROR_NO_CONNECTION;
157127
}
158128

159-
const char *EMACInterface::get_gateway()
160-
{
161-
if (_interface && _interface->get_gateway(_gateway, sizeof(_gateway))) {
162-
return _gateway;
163-
}
164-
return nullptr;
165-
}
166-
167129
char *EMACInterface::get_interface_name(char *interface_name)
168130
{
169131
if (_interface) {

Diff for: features/netsocket/EMACInterface.h

-13
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ class EMACInterface : public virtual NetworkInterface {
6666
*/
6767
virtual nsapi_error_t set_network(const SocketAddress &ip_address, const SocketAddress &netmask, const SocketAddress &gateway);
6868

69-
MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated")
70-
virtual nsapi_error_t set_network(const char *ip_address, const char *netmask, const char *gateway);
71-
7269
/** Enable or disable DHCP on the network
7370
*
7471
* Requires that the network is disconnected
@@ -91,25 +88,15 @@ class EMACInterface : public virtual NetworkInterface {
9188
/** @copydoc NetworkInterface::get_ip_address */
9289
virtual nsapi_error_t get_ip_address(SocketAddress *address);
9390

94-
MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated")
95-
virtual const char *get_ip_address();
96-
9791
/** @copydoc NetworkInterface::get_ipv6_link_local_address */
9892
virtual nsapi_error_t get_ipv6_link_local_address(SocketAddress *address);
9993

10094
/** @copydoc NetworkInterface::get_netmask */
10195
virtual nsapi_error_t get_netmask(SocketAddress *address);
10296

103-
MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated")
104-
virtual const char *get_netmask();
105-
10697
/** @copydoc NetworkInterface::get_gateway */
10798
virtual nsapi_error_t get_gateway(SocketAddress *address);
10899

109-
/** @copydoc NetworkInterface::get_gateway */
110-
MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated")
111-
virtual const char *get_gateway();
112-
113100
/** @copydoc NetworkInterface::get_interface_name */
114101
virtual char *get_interface_name(char *interface_name);
115102

Diff for: features/netsocket/InternetDatagramSocket.cpp

-21
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,6 @@ nsapi_error_t InternetDatagramSocket::connect(const SocketAddress &address)
2626
return NSAPI_ERROR_OK;
2727
}
2828

29-
nsapi_size_or_error_t InternetDatagramSocket::sendto(const char *host, uint16_t port, const void *data, nsapi_size_t size)
30-
{
31-
SocketAddress address;
32-
nsapi_size_or_error_t err;
33-
34-
if (!strcmp(_interface_name, "")) {
35-
err = _stack->gethostbyname(host, &address);
36-
} else {
37-
err = _stack->gethostbyname(host, &address, NSAPI_UNSPEC, _interface_name);
38-
}
39-
40-
if (err) {
41-
return NSAPI_ERROR_DNS_FAILURE;
42-
}
43-
44-
address.set_port(port);
45-
46-
// sendto is thread safe
47-
return sendto(address, data, size);
48-
}
49-
5029
nsapi_size_or_error_t InternetDatagramSocket::sendto(const SocketAddress &address, const void *data, nsapi_size_t size)
5130
{
5231
_lock.lock();

0 commit comments

Comments
 (0)