Skip to content

Commit 533e6f0

Browse files
authored
Merge pull request #4431 from kjbracey-arm/mbed_lwip_api_compat
Restore mbed OS 5.4 mbed_lwip_ function prototypes
2 parents 5f13881 + 284843f commit 533e6f0

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

features/FEATURE_LWIP/lwip-interface/EthernetInterface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ nsapi_error_t EthernetInterface::set_dhcp(bool dhcp)
4646

4747
nsapi_error_t EthernetInterface::connect()
4848
{
49-
return mbed_lwip_bringup(_dhcp, false,
49+
return mbed_lwip_bringup_2(_dhcp, false,
5050
_ip_address[0] ? _ip_address : 0,
5151
_netmask[0] ? _netmask : 0,
5252
_gateway[0] ? _gateway : 0);
5353
}
5454

5555
nsapi_error_t EthernetInterface::disconnect()
5656
{
57-
return mbed_lwip_bringdown(false);
57+
return mbed_lwip_bringdown_2(false);
5858
}
5959

6060
const char *EthernetInterface::get_mac_address()

features/FEATURE_LWIP/lwip-interface/lwip_stack.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <stdio.h>
2121
#include <stdbool.h>
2222
#include <string.h>
23+
#include "lwip_stack.h"
2324

2425
#include "eth_arch.h"
2526
#include "lwip/opt.h"
@@ -391,7 +392,7 @@ char *mbed_lwip_get_ip_address(char *buf, nsapi_size_t buflen)
391392
#endif
392393
}
393394

394-
const char *mbed_lwip_get_netmask(char *buf, nsapi_size_t buflen)
395+
char *mbed_lwip_get_netmask(char *buf, nsapi_size_t buflen)
395396
{
396397
#if LWIP_IPV4
397398
const ip4_addr_t *addr = netif_ip4_netmask(&lwip_netif);
@@ -481,7 +482,13 @@ nsapi_error_t mbed_lwip_init(emac_interface_t *emac)
481482
return mbed_lwip_emac_init(emac);
482483
}
483484

484-
nsapi_error_t mbed_lwip_bringup(bool dhcp, bool ppp, const char *ip, const char *netmask, const char *gw)
485+
// Backwards compatibility with people using DEVICE_EMAC
486+
nsapi_error_t mbed_lwip_bringup(bool dhcp, const char *ip, const char *netmask, const char *gw)
487+
{
488+
return mbed_lwip_bringup_2(dhcp, false, ip, netmask, gw);
489+
}
490+
491+
nsapi_error_t mbed_lwip_bringup_2(bool dhcp, bool ppp, const char *ip, const char *netmask, const char *gw)
485492
{
486493
// Check if we've already connected
487494
if (lwip_connected) {
@@ -624,7 +631,13 @@ void mbed_lwip_clear_ipv6_addresses(struct netif *lwip_netif)
624631
}
625632
#endif
626633

627-
nsapi_error_t mbed_lwip_bringdown(bool ppp)
634+
// Backwards compatibility with people using DEVICE_EMAC
635+
nsapi_error_t mbed_lwip_bringdown(void)
636+
{
637+
return mbed_lwip_bringdown_2(false);
638+
}
639+
640+
nsapi_error_t mbed_lwip_bringdown_2(bool ppp)
628641
{
629642
// Check if we've connected
630643
if (!lwip_connected) {

features/FEATURE_LWIP/lwip-interface/lwip_stack.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,19 @@
2424
extern "C" {
2525
#endif
2626

27-
// Access to lwip through the nsapi
27+
// Access to lwip through the nsapi - be wary of API changes as external 1st-generation EMAC
28+
// drivers attach through these.
2829
nsapi_error_t mbed_lwip_init(emac_interface_t *emac);
2930
nsapi_error_t mbed_lwip_emac_init(emac_interface_t *emac);
30-
nsapi_error_t mbed_lwip_bringup(bool dhcp, bool ppp, const char *ip, const char *netmask, const char *gw);
31-
nsapi_error_t mbed_lwip_bringdown(bool ppp);
31+
nsapi_error_t mbed_lwip_bringup(bool dhcp, const char *ip, const char *netmask, const char *gw);
32+
nsapi_error_t mbed_lwip_bringup_2(bool dhcp, bool ppp, const char *ip, const char *netmask, const char *gw);
33+
nsapi_error_t mbed_lwip_bringdown(void);
34+
nsapi_error_t mbed_lwip_bringdown_2(bool ppp);
3235

3336
const char *mbed_lwip_get_mac_address(void);
34-
char *mbed_lwip_get_ip_address(char *buf, int buflen);
35-
char *mbed_lwip_get_netmask(char *buf, int buflen);
36-
char *mbed_lwip_get_gateway(char *buf, int buflen);
37+
char *mbed_lwip_get_ip_address(char *buf, nsapi_size_t buflen);
38+
char *mbed_lwip_get_netmask(char *buf, nsapi_size_t buflen);
39+
char *mbed_lwip_get_gateway(char *buf, nsapi_size_t buflen);
3740

3841
extern nsapi_stack_t lwip_stack;
3942

features/FEATURE_LWIP/lwip-interface/ppp_lwip.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ nsapi_error_t nsapi_ppp_connect(FileHandle *stream, Callback<void(nsapi_error_t)
354354

355355
// mustn't start calling input until after connect -
356356
// attach deferred until ppp_lwip_connect, called from mbed_lwip_bringup
357-
nsapi_error_t retcode = mbed_lwip_bringup(false, true, NULL, NULL, NULL);
357+
nsapi_error_t retcode = mbed_lwip_bringup_2(false, true, NULL, NULL, NULL);
358358

359359
if (retcode != NSAPI_ERROR_OK && connect_error_code != NSAPI_ERROR_OK) {
360360
return connect_error_code;
@@ -365,7 +365,7 @@ nsapi_error_t nsapi_ppp_connect(FileHandle *stream, Callback<void(nsapi_error_t)
365365

366366
nsapi_error_t nsapi_ppp_disconnect(FileHandle *stream)
367367
{
368-
return mbed_lwip_bringdown(true);
368+
return mbed_lwip_bringdown_2(true);
369369
}
370370

371371
NetworkStack *nsapi_ppp_get_stack()

0 commit comments

Comments
 (0)