Skip to content

Commit 8f1bf96

Browse files
authored
Merge pull request #11942 from michalpasztamobica/remove_deprecated_apis
IPCore String-based API removal
2 parents 72b2fcf + 2cb2c41 commit 8f1bf96

File tree

60 files changed

+98
-664
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+98
-664
lines changed

UNITTESTS/features/netsocket/PPPInterface/test_PPPInterface.cpp

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,21 @@ TEST_F(TestPPPInterface, disconnect)
178178

179179
TEST_F(TestPPPInterface, set_network)
180180
{
181-
char ipAddress[NSAPI_IPv4_SIZE] = "127.0.0.1";
182-
char netmask[NSAPI_IPv4_SIZE] = "255.255.0.0";
183-
char gateway[NSAPI_IPv4_SIZE] = "127.0.0.2";
181+
SocketAddress ipAddress("127.0.0.1");
182+
SocketAddress netmask("255.255.0.0");
183+
SocketAddress gateway("127.0.0.2");
184184

185185
const char *ipAddressArg;
186186
const char *netmaskArg;
187187
const char *gatewayArg;
188188

189-
EXPECT_EQ(0, iface->get_ip_address());
190-
EXPECT_EQ(0, iface->get_netmask());
191-
EXPECT_EQ(0, iface->get_gateway());
189+
SocketAddress ipAddr;
190+
SocketAddress netmaskAddr;
191+
SocketAddress gatewayAddr;
192+
193+
EXPECT_EQ(NSAPI_ERROR_NO_CONNECTION, iface->get_ip_address(&ipAddr));
194+
EXPECT_EQ(NSAPI_ERROR_NO_CONNECTION, iface->get_netmask(&netmaskAddr));
195+
EXPECT_EQ(NSAPI_ERROR_NO_CONNECTION, iface->get_gateway(&gatewayAddr));
192196

193197
EXPECT_CALL(*pppMock, set_stream(_));
194198
EXPECT_CALL(*pppMock, set_ip_stack(_));
@@ -213,25 +217,28 @@ TEST_F(TestPPPInterface, set_network)
213217
Return(NSAPI_ERROR_OK)));
214218
EXPECT_EQ(NSAPI_ERROR_OK, iface->connect());
215219
// Check the contents of the stored pointer arguments.
216-
EXPECT_TRUE(0 == strcmp(ipAddress, ipAddressArg));
217-
EXPECT_TRUE(0 == strcmp(netmask, netmaskArg));
218-
EXPECT_TRUE(0 == strcmp(gateway, gatewayArg));
220+
EXPECT_TRUE(0 == strcmp(ipAddress.get_ip_address(), ipAddressArg));
221+
EXPECT_TRUE(0 == strcmp(netmask.get_ip_address(), netmaskArg));
222+
EXPECT_TRUE(0 == strcmp(gateway.get_ip_address(), gatewayArg));
219223

220224
// Testing the getters makes sense now.
221-
EXPECT_CALL(*netStackIface, get_ip_address(_, _))
225+
EXPECT_CALL(*netStackIface, get_ip_address(_))
222226
.Times(1)
223-
.WillOnce(DoAll(SetArgPointee<0>(*ipAddress), Return(ipAddress)));
224-
EXPECT_EQ(std::string(ipAddress), std::string(iface->get_ip_address()));
227+
.WillOnce(DoAll(SetArgPointee<0>(ipAddress), Return(NSAPI_ERROR_OK)));
228+
EXPECT_EQ(NSAPI_ERROR_OK, iface->get_ip_address(&ipAddr));
229+
EXPECT_EQ(ipAddress, ipAddr);
225230

226-
EXPECT_CALL(*netStackIface, get_netmask(_, _))
231+
EXPECT_CALL(*netStackIface, get_netmask(_))
227232
.Times(1)
228-
.WillOnce(DoAll(SetArgPointee<0>(*netmask), Return(netmask)));
229-
EXPECT_EQ(std::string(netmask), std::string(iface->get_netmask()));
233+
.WillOnce(DoAll(SetArgPointee<0>(netmask), Return(NSAPI_ERROR_OK)));
234+
EXPECT_EQ(NSAPI_ERROR_OK, iface->get_netmask(&netmaskAddr));
235+
EXPECT_EQ(netmask, netmaskAddr);
230236

231-
EXPECT_CALL(*netStackIface, get_gateway(_, _))
237+
EXPECT_CALL(*netStackIface, get_gateway(_))
232238
.Times(1)
233-
.WillOnce(DoAll(SetArgPointee<0>(*gateway), Return(gateway)));
234-
EXPECT_EQ(std::string(gateway), std::string(iface->get_gateway()));
239+
.WillOnce(DoAll(SetArgPointee<0>(gateway), Return(NSAPI_ERROR_OK)));
240+
EXPECT_EQ(NSAPI_ERROR_OK, iface->get_gateway(&gatewayAddr));
241+
EXPECT_EQ(gateway, gatewayAddr);
235242
}
236243

237244
TEST_F(TestPPPInterface, get_connection_status)

UNITTESTS/features/netsocket/PPPInterface/unittest.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ set(unittest-test-sources
3232
stubs/mbed_shared_queues_stub.cpp
3333
stubs/nsapi_dns_stub.cpp
3434
stubs/EventFlags_stub.cpp
35-
stubs/stoip4_stub.c
36-
stubs/ip4tos_stub.c
3735
stubs/NetworkStack_stub.cpp
3836
stubs/NetworkInterfaceDefaults_stub.cpp
3937
stubs/SocketStats_Stub.cpp

UNITTESTS/stubs/AT_CellularContext_stub.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,6 @@ nsapi_error_t AT_CellularContext::get_ip_address(SocketAddress *address)
114114
return NSAPI_ERROR_UNSUPPORTED;
115115
}
116116

117-
const char *AT_CellularContext::get_ip_address()
118-
{
119-
return NULL;
120-
}
121-
122117
void AT_CellularContext::attach(Callback<void(nsapi_event_t, intptr_t)> status_cb)
123118
{
124119
}

UNITTESTS/stubs/AT_CellularStack_stub.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ nsapi_error_t AT_CellularStack::get_ip_address(SocketAddress* address)
3636
return NSAPI_ERROR_UNSUPPORTED;
3737
}
3838

39-
const char *AT_CellularStack::get_ip_address()
40-
{
41-
return NULL;
42-
}
43-
4439
nsapi_error_t AT_CellularStack::socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto)
4540
{
4641
return NSAPI_ERROR_OK;

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
@@ -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-
}

UNITTESTS/stubs/NetworkStack_stub.h

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

UNITTESTS/stubs/OnboardNetworkStack_mock.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ class OnboardNetworkStackMock : public OnboardNetworkStack {
8282
MOCK_CONST_METHOD0(get_connection_status, nsapi_connection_status_t());
8383
MOCK_METHOD1(get_interface_name, char *(char *buf));
8484
MOCK_METHOD2(get_mac_address, char *(char *buf, nsapi_size_t buflen));
85-
MOCK_METHOD2(get_ip_address, char *(char *buf, nsapi_size_t buflen));
8685
MOCK_METHOD1(get_ip_address, nsapi_error_t (SocketAddress *address));
8786
MOCK_METHOD1(get_ipv6_link_local_address, nsapi_error_t(SocketAddress *address));
8887
MOCK_METHOD2(get_netmask, char *(char *buf, nsapi_size_t buflen));

components/wifi/esp8266-driver/ESP8266Interface.cpp

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

components/wifi/esp8266-driver/ESP8266Interface.h

Lines changed: 0 additions & 3 deletions
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
*/

features/cellular/framework/API/CellularContext.h

Lines changed: 0 additions & 2 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
*

features/cellular/framework/AT/AT_CellularContext.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -224,21 +224,6 @@ nsapi_error_t AT_CellularContext::get_ip_address(SocketAddress *address)
224224
#endif
225225
}
226226

227-
const char *AT_CellularContext::get_ip_address()
228-
{
229-
#if NSAPI_PPP_AVAILABLE
230-
return nsapi_ppp_get_ip_addr(_at.get_file_handle());
231-
#else
232-
if (!_stack) {
233-
_stack = get_stack();
234-
}
235-
if (_stack) {
236-
return _stack->get_ip_address();
237-
}
238-
return NULL;
239-
#endif
240-
}
241-
242227
char *AT_CellularContext::get_interface_name(char *interface_name)
243228
{
244229
if (_cid < 0) {

features/cellular/framework/AT/AT_CellularContext.h

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

features/cellular/framework/AT/AT_CellularStack.cpp

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -104,49 +104,6 @@ nsapi_error_t AT_CellularStack::get_ip_address(SocketAddress *address)
104104
return (ipv4 || ipv6) ? NSAPI_ERROR_OK : NSAPI_ERROR_NO_ADDRESS;
105105
}
106106

107-
const char *AT_CellularStack::get_ip_address()
108-
{
109-
_at.lock();
110-
111-
bool ipv4 = false, ipv6 = false;
112-
113-
_at.cmd_start_stop("+CGPADDR", "=", "%d", _cid);
114-
_at.resp_start("+CGPADDR:");
115-
116-
if (_at.info_resp()) {
117-
_at.skip_param();
118-
119-
if (_at.read_string(_ip, PDP_IPV6_SIZE) != -1) {
120-
convert_ipv6(_ip);
121-
SocketAddress address;
122-
address.set_ip_address(_ip);
123-
124-
ipv4 = (address.get_ip_version() == NSAPI_IPv4);
125-
ipv6 = (address.get_ip_version() == NSAPI_IPv6);
126-
127-
// Try to look for second address ONLY if modem has support for dual stack(can handle both IPv4 and IPv6 simultaneously).
128-
// Otherwise assumption is that second address is not reliable, even if network provides one.
129-
if ((_device.get_property(AT_CellularDevice::PROPERTY_IPV4V6_PDP_TYPE) && (_at.read_string(_ip, PDP_IPV6_SIZE) != -1))) {
130-
convert_ipv6(_ip);
131-
address.set_ip_address(_ip);
132-
ipv6 = (address.get_ip_version() == NSAPI_IPv6);
133-
}
134-
}
135-
}
136-
_at.resp_stop();
137-
_at.unlock();
138-
139-
if (ipv4 && ipv6) {
140-
_stack_type = IPV4V6_STACK;
141-
} else if (ipv4) {
142-
_stack_type = IPV4_STACK;
143-
} else if (ipv6) {
144-
_stack_type = IPV6_STACK;
145-
}
146-
147-
return (ipv4 || ipv6) ? _ip : NULL;
148-
}
149-
150107
void AT_CellularStack::set_cid(int cid)
151108
{
152109
_cid = cid;

features/cellular/framework/AT/AT_CellularStack.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ class AT_CellularStack : public NetworkStack {
4646

4747
virtual nsapi_error_t get_ip_address(SocketAddress *address);
4848

49-
MBED_DEPRECATED_SINCE("mbed-os-5.15", "String-based APIs are deprecated")
50-
virtual const char *get_ip_address();
51-
5249
/**
5350
* Set PDP context ID for this stack
5451
*

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

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

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/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularStack.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -398,15 +398,6 @@ void UBLOX_AT_CellularStack::clear_socket(CellularSocket *socket)
398398
}
399399

400400
#ifndef UBX_MDM_SARA_R41XM
401-
const char *UBLOX_AT_CellularStack::get_ip_address()
402-
{
403-
SocketAddress address;
404-
405-
get_ip_address(&address);
406-
407-
return (address.get_ip_version()) ? (address.get_ip_address()) : NULL;
408-
}
409-
410401
nsapi_error_t UBLOX_AT_CellularStack::get_ip_address(SocketAddress *address)
411402
{
412403
if (!address) {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ class UBLOX_AT_CellularStack : public AT_CellularStack {
3131
virtual ~UBLOX_AT_CellularStack();
3232

3333
#ifndef UBX_MDM_SARA_R41XM
34-
virtual const char *get_ip_address();
35-
3634
virtual nsapi_error_t get_ip_address(SocketAddress *address);
3735
#endif
3836

0 commit comments

Comments
 (0)