mirror of https://github.com/ARMmbed/mbed-os.git
Cope with different LWIP configurations
parent
7f136d5a35
commit
d0820d1ed3
|
@ -43,6 +43,8 @@
|
|||
#include "mbed_interface.h"
|
||||
#include <string.h>
|
||||
|
||||
#if LWIP_ARP || LWIP_ETHERNET
|
||||
|
||||
#ifndef LPC_EMAC_RMII
|
||||
#error LPC_EMAC_RMII is not defined!
|
||||
#endif
|
||||
|
@ -1058,4 +1060,6 @@ void eth_arch_disable_interrupts(void) {
|
|||
* @}
|
||||
*/
|
||||
|
||||
#endif /* LWIP_ARP || LWIP_ETHERNET */
|
||||
|
||||
/* --------------------------------- End Of File ------------------------------ */
|
||||
|
|
|
@ -35,6 +35,11 @@
|
|||
#include <stdint.h>
|
||||
#include <stddef.h> /* for size_t */
|
||||
|
||||
#if LWIP_USE_EXTERNAL_MBEDTLS
|
||||
#include "mbedtls/md5.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* ARM/LPC17xx is little endian only */
|
||||
#if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN)
|
||||
#ifdef BYTE_ORDER
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "nsapi.h"
|
||||
#include "mbed_interface.h"
|
||||
#include "mbed_assert.h"
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
@ -513,7 +514,7 @@ nsapi_error_t mbed_lwip_bringup(bool dhcp, const char *ip, const char *netmask,
|
|||
|
||||
netif_set_up(&lwip_netif);
|
||||
|
||||
#if LWIP_IPV4
|
||||
#if LWIP_DHCP
|
||||
// Connect to the network
|
||||
lwip_dhcp = dhcp;
|
||||
|
||||
|
@ -563,7 +564,7 @@ nsapi_error_t mbed_lwip_bringdown(void)
|
|||
return NSAPI_ERROR_PARAMETER;
|
||||
}
|
||||
|
||||
#if LWIP_IPV4
|
||||
#if LWIP_DHCP
|
||||
// Disconnect from the network
|
||||
if (lwip_dhcp) {
|
||||
dhcp_release(&lwip_netif);
|
||||
|
@ -727,7 +728,10 @@ static nsapi_error_t mbed_lwip_socket_bind(nsapi_stack_t *stack, nsapi_socket_t
|
|||
struct lwip_socket *s = (struct lwip_socket *)handle;
|
||||
ip_addr_t ip_addr;
|
||||
|
||||
if ((s->conn->type == NETCONN_TCP && s->conn->pcb.tcp->local_port != 0) ||
|
||||
if (
|
||||
#if LWIP_TCP
|
||||
(s->conn->type == NETCONN_TCP && s->conn->pcb.tcp->local_port != 0) ||
|
||||
#endif
|
||||
(s->conn->type == NETCONN_UDP && s->conn->pcb.udp->local_port != 0)) {
|
||||
return NSAPI_ERROR_PARAMETER;
|
||||
}
|
||||
|
@ -876,6 +880,7 @@ static nsapi_error_t mbed_lwip_setsockopt(nsapi_stack_t *stack, nsapi_socket_t h
|
|||
struct lwip_socket *s = (struct lwip_socket *)handle;
|
||||
|
||||
switch (optname) {
|
||||
#if LWIP_TCP
|
||||
case NSAPI_KEEPALIVE:
|
||||
if (optlen != sizeof(int) || s->conn->type != NETCONN_TCP) {
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
|
@ -899,6 +904,7 @@ static nsapi_error_t mbed_lwip_setsockopt(nsapi_stack_t *stack, nsapi_socket_t h
|
|||
|
||||
s->conn->pcb.tcp->keep_intvl = *(int*)optval;
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
case NSAPI_REUSEADDR:
|
||||
if (optlen != sizeof(int)) {
|
||||
|
@ -906,9 +912,9 @@ static nsapi_error_t mbed_lwip_setsockopt(nsapi_stack_t *stack, nsapi_socket_t h
|
|||
}
|
||||
|
||||
if (*(int *)optval) {
|
||||
s->conn->pcb.tcp->so_options |= SOF_REUSEADDR;
|
||||
ip_set_option(s->conn->pcb.ip, SOF_REUSEADDR);
|
||||
} else {
|
||||
s->conn->pcb.tcp->so_options &= ~SOF_REUSEADDR;
|
||||
ip_reset_option(s->conn->pcb.ip, SOF_REUSEADDR);
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue