Cope with different LWIP configurations

pull/4119/head
Kevin Bracey 2017-02-16 12:37:05 +02:00 committed by Hasnain Virk
parent 7f136d5a35
commit d0820d1ed3
3 changed files with 20 additions and 5 deletions

View File

@ -43,6 +43,8 @@
#include "mbed_interface.h" #include "mbed_interface.h"
#include <string.h> #include <string.h>
#if LWIP_ARP || LWIP_ETHERNET
#ifndef LPC_EMAC_RMII #ifndef LPC_EMAC_RMII
#error LPC_EMAC_RMII is not defined! #error LPC_EMAC_RMII is not defined!
#endif #endif
@ -1058,4 +1060,6 @@ void eth_arch_disable_interrupts(void) {
* @} * @}
*/ */
#endif /* LWIP_ARP || LWIP_ETHERNET */
/* --------------------------------- End Of File ------------------------------ */ /* --------------------------------- End Of File ------------------------------ */

View File

@ -35,6 +35,11 @@
#include <stdint.h> #include <stdint.h>
#include <stddef.h> /* for size_t */ #include <stddef.h> /* for size_t */
#if LWIP_USE_EXTERNAL_MBEDTLS
#include "mbedtls/md5.h"
#endif
/* ARM/LPC17xx is little endian only */ /* ARM/LPC17xx is little endian only */
#if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) #if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN)
#ifdef BYTE_ORDER #ifdef BYTE_ORDER

View File

@ -16,6 +16,7 @@
#include "nsapi.h" #include "nsapi.h"
#include "mbed_interface.h" #include "mbed_interface.h"
#include "mbed_assert.h"
#include <stdio.h> #include <stdio.h>
#include <stdbool.h> #include <stdbool.h>
#include <string.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); netif_set_up(&lwip_netif);
#if LWIP_IPV4 #if LWIP_DHCP
// Connect to the network // Connect to the network
lwip_dhcp = dhcp; lwip_dhcp = dhcp;
@ -563,7 +564,7 @@ nsapi_error_t mbed_lwip_bringdown(void)
return NSAPI_ERROR_PARAMETER; return NSAPI_ERROR_PARAMETER;
} }
#if LWIP_IPV4 #if LWIP_DHCP
// Disconnect from the network // Disconnect from the network
if (lwip_dhcp) { if (lwip_dhcp) {
dhcp_release(&lwip_netif); 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; struct lwip_socket *s = (struct lwip_socket *)handle;
ip_addr_t ip_addr; 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)) { (s->conn->type == NETCONN_UDP && s->conn->pcb.udp->local_port != 0)) {
return NSAPI_ERROR_PARAMETER; 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; struct lwip_socket *s = (struct lwip_socket *)handle;
switch (optname) { switch (optname) {
#if LWIP_TCP
case NSAPI_KEEPALIVE: case NSAPI_KEEPALIVE:
if (optlen != sizeof(int) || s->conn->type != NETCONN_TCP) { if (optlen != sizeof(int) || s->conn->type != NETCONN_TCP) {
return NSAPI_ERROR_UNSUPPORTED; 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; s->conn->pcb.tcp->keep_intvl = *(int*)optval;
return 0; return 0;
#endif
case NSAPI_REUSEADDR: case NSAPI_REUSEADDR:
if (optlen != sizeof(int)) { 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) { if (*(int *)optval) {
s->conn->pcb.tcp->so_options |= SOF_REUSEADDR; ip_set_option(s->conn->pcb.ip, SOF_REUSEADDR);
} else { } else {
s->conn->pcb.tcp->so_options &= ~SOF_REUSEADDR; ip_reset_option(s->conn->pcb.ip, SOF_REUSEADDR);
} }
return 0; return 0;