Skip to content

Commit 483d921

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 24c6c4c commit 483d921

30 files changed

+2
-442
lines changed

UNITTESTS/features/netsocket/EthernetInterface/test_EthernetInterface.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,8 @@ class EmacNetworkStackMock : public OnboardNetworkStack {
9494
MOCK_CONST_METHOD0(get_connection_status, nsapi_connection_status_t());
9595
MOCK_METHOD2(get_mac_address, char *(char *buf, nsapi_size_t buflen));
9696
MOCK_METHOD1(get_ip_address, nsapi_error_t(SocketAddress *address));
97-
MOCK_METHOD2(get_ip_address, char *(char *buf, nsapi_size_t buflen));
9897
MOCK_METHOD1(get_netmask, nsapi_error_t(SocketAddress *address));
99-
MOCK_METHOD2(get_netmask, char *(char *buf, nsapi_size_t buflen));
10098
MOCK_METHOD1(get_gateway, nsapi_error_t(SocketAddress *address));
101-
MOCK_METHOD2(get_gateway, char *(char *buf, nsapi_size_t buflen));
10299
MOCK_METHOD1(get_ipv6_link_local_address, nsapi_error_t(SocketAddress *address));
103100
};
104101
};

UNITTESTS/stubs/AT_CellularContext_stub.cpp

Lines changed: 0 additions & 15 deletions
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
}
@@ -154,21 +149,11 @@ nsapi_error_t AT_CellularContext::get_netmask(SocketAddress *address)
154149
return NSAPI_ERROR_UNSUPPORTED;
155150
}
156151

157-
const char *AT_CellularContext::get_netmask()
158-
{
159-
return NULL;
160-
}
161-
162152
nsapi_error_t AT_CellularContext::get_gateway(SocketAddress *address)
163153
{
164154
return NSAPI_ERROR_UNSUPPORTED;
165155
}
166156

167-
const char *AT_CellularContext::get_gateway()
168-
{
169-
return NULL;
170-
}
171-
172157
AT_CellularBase::CellularProperty AT_CellularContext::pdp_type_t_to_cellular_property(pdp_type_t pdp_type)
173158
{
174159
AT_CellularBase::CellularProperty prop = PROPERTY_IPV4_PDP_TYPE;

UNITTESTS/stubs/NetworkInterface_stub.cpp

Lines changed: 0 additions & 19 deletions
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;

UNITTESTS/stubs/NetworkStack_stub.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ nsapi_error_t NetworkStack::get_ip_address(SocketAddress* address)
9494
return NSAPI_ERROR_UNSUPPORTED;
9595
}
9696

97-
const char *NetworkStack::get_ip_address()
98-
{
99-
return NULL;
100-
}
101-
10297
nsapi_error_t NetworkStack::get_ipv6_link_local_address(SocketAddress *address)
10398
{
10499
return NSAPI_ERROR_UNSUPPORTED;
@@ -108,8 +103,3 @@ nsapi_error_t NetworkStack::get_ip_address_if(SocketAddress* address, const char
108103
{
109104
return NSAPI_ERROR_UNSUPPORTED;
110105
}
111-
112-
const char *NetworkStack::get_ip_address_if(const char *interface_name)
113-
{
114-
return NULL;
115-
}

UNITTESTS/stubs/NetworkStack_stub.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ class NetworkStackstub : public NetworkStack {
3333
{
3434
}
3535

36-
virtual const char *get_ip_address()
37-
{
38-
return "127.0.0.1";
39-
}
4036
virtual nsapi_error_t get_ip_address(SocketAddress* address)
4137
{
4238
address->set_ip_address("127.0.0.1");

features/cellular/framework/API/CellularContext.h

Lines changed: 0 additions & 6 deletions
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
*
@@ -147,11 +145,7 @@ class CellularContext : public CellularInterface {
147145
const char *pwd = 0) = 0;
148146
virtual void set_credentials(const char *apn, const char *uname = 0, const char *pwd = 0) = 0;
149147
virtual nsapi_error_t get_netmask(SocketAddress *address) = 0;
150-
MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated")
151-
virtual const char *get_netmask() = 0;
152148
virtual nsapi_error_t get_gateway(SocketAddress *address) = 0;
153-
MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated")
154-
virtual const char *get_gateway() = 0;
155149
virtual bool is_connected() = 0;
156150

157151
/** Same as NetworkInterface::get_default_instance()

features/cellular/framework/AT/AT_CellularContext.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,11 @@ nsapi_error_t AT_CellularContext::get_netmask(SocketAddress *address)
219219
return NSAPI_ERROR_UNSUPPORTED;
220220
}
221221

222-
const char *AT_CellularContext::get_netmask()
223-
{
224-
return NULL;
225-
}
226-
227222
nsapi_error_t AT_CellularContext::get_gateway(SocketAddress *address)
228223
{
229224
return NSAPI_ERROR_UNSUPPORTED;
230225
}
231226

232-
const char *AT_CellularContext::get_gateway()
233-
{
234-
return NULL;
235-
}
236-
237227
nsapi_error_t AT_CellularContext::get_ip_address(SocketAddress *address)
238228
{
239229
if (!address) {
@@ -254,21 +244,6 @@ nsapi_error_t AT_CellularContext::get_ip_address(SocketAddress *address)
254244
#endif
255245
}
256246

257-
const char *AT_CellularContext::get_ip_address()
258-
{
259-
#if NSAPI_PPP_AVAILABLE
260-
return nsapi_ppp_get_ip_addr(_at.get_file_handle());
261-
#else
262-
if (!_stack) {
263-
_stack = get_stack();
264-
}
265-
if (_stack) {
266-
return _stack->get_ip_address();
267-
}
268-
return NULL;
269-
#endif
270-
}
271-
272247
char *AT_CellularContext::get_interface_name(char *interface_name)
273248
{
274249
if (_cid < 0) {

features/cellular/framework/AT/AT_CellularContext.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class AT_CellularContext : public CellularContext, public AT_CellularBase {
3636
virtual nsapi_error_t set_blocking(bool blocking);
3737
virtual NetworkStack *get_stack();
3838
virtual nsapi_error_t get_ip_address(SocketAddress *address);
39-
virtual const char *get_ip_address();
4039
virtual char *get_interface_name(char *interface_name);
4140
virtual void attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
4241
virtual nsapi_error_t connect();
@@ -50,9 +49,7 @@ class AT_CellularContext : public CellularContext, public AT_CellularBase {
5049
const char *pwd = 0);
5150
virtual void set_credentials(const char *apn, const char *uname = 0, const char *pwd = 0);
5251
virtual nsapi_error_t get_netmask(SocketAddress *address);
53-
virtual const char *get_netmask();
5452
virtual nsapi_error_t get_gateway(SocketAddress *address);
55-
virtual const char *get_gateway();
5653

5754
// from CellularContext
5855
virtual nsapi_error_t get_pdpcontext_params(pdpContextList_t &params_list);

features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,9 @@ void UBLOX_AT_CellularContext::get_next_credentials(char **config)
299299
}
300300
}
301301

302-
const char *UBLOX_AT_CellularContext::get_gateway()
302+
nsapi_error_t UBLOX_AT_CellularContext::get_gateway(SocketAddress *addr)
303303
{
304-
return get_ip_address();
304+
return get_ip_address(addr);
305305
}
306306

307307
nsapi_error_t UBLOX_AT_CellularContext::get_gateway(SocketAddress *addr)

features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularContext.h

Lines changed: 0 additions & 1 deletion
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);

features/netsocket/CellularInterface.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,12 @@ 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::get_netmask */
105102
virtual nsapi_error_t get_netmask(SocketAddress *address) = 0;
106103

107-
MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated")
108-
virtual const char *get_netmask() = 0;
109-
110104
/** @copydoc NetworkInterface::get_gateway */
111105
virtual nsapi_error_t get_gateway(SocketAddress *address) = 0;
112106

113-
MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated")
114-
virtual const char *get_gateway() = 0;
115-
116107
/** @copydoc NetworkInterface::cellularBase
117108
*/
118109
MBED_DEPRECATED_SINCE("mbed-os-5.12", "Migrated to CellularInterface")

features/netsocket/DTLSSocket.cpp

Lines changed: 0 additions & 25 deletions
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

features/netsocket/DTLSSocket.h

Lines changed: 0 additions & 13 deletions
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
};

features/netsocket/EMACInterface.cpp

Lines changed: 0 additions & 38 deletions
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) {

0 commit comments

Comments
 (0)