Skip to content

Commit

Permalink
Merge pull request #4431 from kjbracey-arm/mbed_lwip_api_compat
Browse files Browse the repository at this point in the history
Restore mbed OS 5.4 mbed_lwip_ function prototypes
  • Loading branch information
0xc0170 authored Jun 3, 2017
2 parents 5f13881 + 284843f commit 533e6f0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
4 changes: 2 additions & 2 deletions features/FEATURE_LWIP/lwip-interface/EthernetInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ nsapi_error_t EthernetInterface::set_dhcp(bool dhcp)

nsapi_error_t EthernetInterface::connect()
{
return mbed_lwip_bringup(_dhcp, false,
return mbed_lwip_bringup_2(_dhcp, false,
_ip_address[0] ? _ip_address : 0,
_netmask[0] ? _netmask : 0,
_gateway[0] ? _gateway : 0);
}

nsapi_error_t EthernetInterface::disconnect()
{
return mbed_lwip_bringdown(false);
return mbed_lwip_bringdown_2(false);
}

const char *EthernetInterface::get_mac_address()
Expand Down
19 changes: 16 additions & 3 deletions features/FEATURE_LWIP/lwip-interface/lwip_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include "lwip_stack.h"

#include "eth_arch.h"
#include "lwip/opt.h"
Expand Down Expand Up @@ -391,7 +392,7 @@ char *mbed_lwip_get_ip_address(char *buf, nsapi_size_t buflen)
#endif
}

const char *mbed_lwip_get_netmask(char *buf, nsapi_size_t buflen)
char *mbed_lwip_get_netmask(char *buf, nsapi_size_t buflen)
{
#if LWIP_IPV4
const ip4_addr_t *addr = netif_ip4_netmask(&lwip_netif);
Expand Down Expand Up @@ -481,7 +482,13 @@ nsapi_error_t mbed_lwip_init(emac_interface_t *emac)
return mbed_lwip_emac_init(emac);
}

nsapi_error_t mbed_lwip_bringup(bool dhcp, bool ppp, const char *ip, const char *netmask, const char *gw)
// Backwards compatibility with people using DEVICE_EMAC
nsapi_error_t mbed_lwip_bringup(bool dhcp, const char *ip, const char *netmask, const char *gw)
{
return mbed_lwip_bringup_2(dhcp, false, ip, netmask, gw);
}

nsapi_error_t mbed_lwip_bringup_2(bool dhcp, bool ppp, const char *ip, const char *netmask, const char *gw)
{
// Check if we've already connected
if (lwip_connected) {
Expand Down Expand Up @@ -624,7 +631,13 @@ void mbed_lwip_clear_ipv6_addresses(struct netif *lwip_netif)
}
#endif

nsapi_error_t mbed_lwip_bringdown(bool ppp)
// Backwards compatibility with people using DEVICE_EMAC
nsapi_error_t mbed_lwip_bringdown(void)
{
return mbed_lwip_bringdown_2(false);
}

nsapi_error_t mbed_lwip_bringdown_2(bool ppp)
{
// Check if we've connected
if (!lwip_connected) {
Expand Down
15 changes: 9 additions & 6 deletions features/FEATURE_LWIP/lwip-interface/lwip_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@
extern "C" {
#endif

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

const char *mbed_lwip_get_mac_address(void);
char *mbed_lwip_get_ip_address(char *buf, int buflen);
char *mbed_lwip_get_netmask(char *buf, int buflen);
char *mbed_lwip_get_gateway(char *buf, int buflen);
char *mbed_lwip_get_ip_address(char *buf, nsapi_size_t buflen);
char *mbed_lwip_get_netmask(char *buf, nsapi_size_t buflen);
char *mbed_lwip_get_gateway(char *buf, nsapi_size_t buflen);

extern nsapi_stack_t lwip_stack;

Expand Down
4 changes: 2 additions & 2 deletions features/FEATURE_LWIP/lwip-interface/ppp_lwip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ nsapi_error_t nsapi_ppp_connect(FileHandle *stream, Callback<void(nsapi_error_t)

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

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

nsapi_error_t nsapi_ppp_disconnect(FileHandle *stream)
{
return mbed_lwip_bringdown(true);
return mbed_lwip_bringdown_2(true);
}

NetworkStack *nsapi_ppp_get_stack()
Expand Down

0 comments on commit 533e6f0

Please sign in to comment.