diff --git a/Makefile.dep b/Makefile.dep index e083323e1b..cc60f4681d 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -445,10 +445,6 @@ ifneq (,$(filter lwip_sock_udp,$(USEMODULE))) endif ifneq (,$(filter lwip_%,$(USEMODULE))) - USEMODULE += lwip -endif - -ifneq (,$(filter lwip,$(USEMODULE))) USEPKG += lwip USEMODULE += core_mbox USEMODULE += lwip_api diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index 9a3b449159..8c13111f20 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -36,19 +36,6 @@ PSEUDOMODULES += lis2dh12_spi PSEUDOMODULES += log PSEUDOMODULES += log_printfnoformat PSEUDOMODULES += lora -PSEUDOMODULES += lwip_arp -PSEUDOMODULES += lwip_autoip -PSEUDOMODULES += lwip_dhcp -PSEUDOMODULES += lwip_ethernet -PSEUDOMODULES += lwip_igmp -PSEUDOMODULES += lwip_ipv6_autoconfig -PSEUDOMODULES += lwip_ipv6_mld -PSEUDOMODULES += lwip_raw -PSEUDOMODULES += lwip_sixlowpan -PSEUDOMODULES += lwip_stats -PSEUDOMODULES += lwip_tcp -PSEUDOMODULES += lwip_udp -PSEUDOMODULES += lwip_udplite PSEUDOMODULES += mpu_stack_guard PSEUDOMODULES += nanocoap_% PSEUDOMODULES += netdev_default diff --git a/pkg/lwip/Makefile b/pkg/lwip/Makefile index 0477137300..379093a031 100644 --- a/pkg/lwip/Makefile +++ b/pkg/lwip/Makefile @@ -1,11 +1,44 @@ PKG_NAME=lwip PKG_URL=git://git.savannah.nongnu.org/lwip.git -PKG_VERSION=STABLE-2_0_3_RELEASE +# lwIP v2.1.0 +PKG_VERSION=e6a8415df332ee34d7af02255b2aa1e8ee74348f PKG_LICENSE=BSD-3-Clause -.PHONY: all +LWIP_MODULES = lwip_api lwip_core lwip_ipv4 lwip_ipv6 \ + lwip_netif lwip_netif_ppp lwip_polarssl +LWIP_USEMODULE = $(filter $(LWIP_MODULES),$(USEMODULE)) +LWIP_MODULE_MAKEFILE = $(RIOTBASE)/Makefile.base -all: git-download - "$(MAKE)" -C $(PKG_BUILDDIR) +.PHONY: all $(LWIP_MODULES) + +CFLAGS += -Wno-address + +make_module = "$(MAKE)" -f $(LWIP_MODULE_MAKEFILE) MODULE=$(1) -C $(2) + +all: git-download lwip + +lwip: $(LWIP_USEMODULE) + $(call make_module,$@,$(PKG_BUILDDIR)) + +lwip_api: + $(call make_module,$@,$(PKG_BUILDDIR)/src/api) + +lwip_core: + $(call make_module,$@,$(PKG_BUILDDIR)/src/core) + +lwip_ipv4: + $(call make_module,$@,$(PKG_BUILDDIR)/src/core/ipv4) + +lwip_ipv6: + $(call make_module,$@,$(PKG_BUILDDIR)/src/core/ipv6) + +lwip_netif: + $(call make_module,$@,$(PKG_BUILDDIR)/src/netif) + +lwip_netif_ppp: + $(call make_module,$@,$(PKG_BUILDDIR)/src/netif/ppp) + +lwip_polarssl: + $(call make_module,$@,$(PKG_BUILDDIR)/src/netif/ppp/polarssl) include $(RIOTBASE)/pkg/pkg.mk diff --git a/pkg/lwip/Makefile.include b/pkg/lwip/Makefile.include index 2d6f97bb2c..a51c7b94df 100644 --- a/pkg/lwip/Makefile.include +++ b/pkg/lwip/Makefile.include @@ -1,6 +1,20 @@ INCLUDES += -I$(RIOTBASE)/pkg/lwip/include \ -I$(PKGDIRBASE)/lwip/src/include +PSEUDOMODULES += lwip_arp +PSEUDOMODULES += lwip_autoip +PSEUDOMODULES += lwip_dhcp +PSEUDOMODULES += lwip_ethernet +PSEUDOMODULES += lwip_igmp +PSEUDOMODULES += lwip_ipv6_autoconfig +PSEUDOMODULES += lwip_ipv6_mld +PSEUDOMODULES += lwip_raw +PSEUDOMODULES += lwip_sixlowpan +PSEUDOMODULES += lwip_stats +PSEUDOMODULES += lwip_tcp +PSEUDOMODULES += lwip_udp +PSEUDOMODULES += lwip_udplite + ifneq (,$(filter lwip_contrib,$(USEMODULE))) DIRS += $(RIOTBASE)/pkg/lwip/contrib endif diff --git a/pkg/lwip/contrib/netdev/lwip_netdev.c b/pkg/lwip/contrib/netdev/lwip_netdev.c index 14aa6d751e..73ec8190c6 100644 --- a/pkg/lwip/contrib/netdev/lwip_netdev.c +++ b/pkg/lwip/contrib/netdev/lwip_netdev.c @@ -131,7 +131,7 @@ err_t lwip_netdev_init(struct netif *netif) case NETDEV_TYPE_IEEE802154: { u16_t val; - ipv6_addr_t *addr; + ip6_addr_t *addr; if (netdev->driver->get(netdev, NETOPT_NID, &val, sizeof(val)) < 0) { return ERR_IF; @@ -154,11 +154,13 @@ err_t lwip_netdev_init(struct netif *netif) } /* netif_create_ip6_linklocal_address() does weird byte-swapping * with full IIDs, so let's do it ourselves */ - addr = (ipv6_addr_t *)&(netif->ip6_addr[0]); - if (netdev->driver->get(netdev, NETOPT_IPV6_IID, &addr->u8[8], sizeof(eui64_t)) < 0) { + addr = &(netif->ip6_addr[0]); + /* addr->addr is a uint32_t array */ + if (netdev->driver->get(netdev, NETOPT_IPV6_IID, &addr->addr[2], sizeof(eui64_t)) < 0) { return ERR_IF; } - ipv6_addr_set_link_local_prefix(addr); + ipv6_addr_set_link_local_prefix((ipv6_addr_t *)&addr->addr[0]); + ip6_addr_assign_zone(addr, IP6_UNICAST, netif); /* Set address state. */ #if LWIP_IPV6_DUP_DETECT_ATTEMPTS /* Will perform duplicate address detection (DAD). */ diff --git a/pkg/lwip/contrib/sock/ip/lwip_sock_ip.c b/pkg/lwip/contrib/sock/ip/lwip_sock_ip.c index 0a8d6b32f6..fde43b4d43 100644 --- a/pkg/lwip/contrib/sock/ip/lwip_sock_ip.c +++ b/pkg/lwip/contrib/sock/ip/lwip_sock_ip.c @@ -92,7 +92,7 @@ static uint16_t _ip6_addr_to_netif(const ip6_addr_p_t *_addr) ip6_addr_t addr; assert(_addr != NULL); - ip6_addr_copy(addr, *_addr); + ip6_addr_copy_from_packed(addr, *_addr); if (!ip6_addr_isany_val(addr)) { for (struct netif *netif = netif_list; netif != NULL; netif = netif->next) { if (netif_get_ip6_addr_match(netif, &addr) >= 0) { diff --git a/pkg/lwip/contrib/sock/lwip_sock.c b/pkg/lwip/contrib/sock/lwip_sock.c index dba775c17d..40b4a10305 100644 --- a/pkg/lwip/contrib/sock/lwip_sock.c +++ b/pkg/lwip/contrib/sock/lwip_sock.c @@ -151,6 +151,23 @@ static bool _addr_on_netif(int family, int netif_num, const ip_addr_t *addr) p = (ep)->port; #endif +static void _convert_ip_addr(ip_addr_t *lwip_addr, int family, + const void *sock_addr, size_t sock_addr_size) +{ + memcpy(lwip_addr, sock_addr, sock_addr_size); +#if LWIP_IPV6 && LWIP_IPV4 + if (family == AF_INET6) { + ip6_addr_clear_zone(&lwip_addr->u_addr.ip6); + } + lwip_addr->type = lwip_af_to_ip_addr_type(family); +#elif LWIP_IPV6 + (void)family; + ip6_addr_clear_zone(lwip_addr); +#else + (void)family; +#endif +} + static int _sock_ep_to_netconn_pars(const struct _sock_tl_ep *local, const struct _sock_tl_ep *remote, ip_addr_t *local_addr, u16_t *local_port, @@ -193,10 +210,8 @@ static int _sock_ep_to_netconn_pars(const struct _sock_tl_ep *local, netif = remote->netif; } family = remote->family; - memcpy(remote_addr, &remote->addr, sizeof(remote->addr)); -#if LWIP_IPV6 && LWIP_IPV4 - remote_addr->type = lwip_af_to_ip_addr_type(family); -#endif + _convert_ip_addr(remote_addr, family, &remote->addr, + sizeof(remote->addr)); if (ip_addr_isany(remote_addr)) { return -EINVAL; } @@ -224,7 +239,8 @@ static int _sock_ep_to_netconn_pars(const struct _sock_tl_ep *local, /* case (local == NULL) is included in _ep_isany() */ /* cast to ip_addr_t alright, since type field is never used */ else if (_addr_on_netif(family, netif, (ip_addr_t *)&local->addr)) { - memcpy(local_addr, &local->addr, sizeof(local->addr)); + _convert_ip_addr(local_addr, family, &local->addr, + sizeof(local->addr)); res = 1; } else { @@ -232,14 +248,9 @@ static int _sock_ep_to_netconn_pars(const struct _sock_tl_ep *local, } } else if (local != NULL) { - memcpy(local_addr, &local->addr, sizeof(local->addr)); + _convert_ip_addr(local_addr, family, &local->addr, sizeof(local->addr)); res = 1; } -#if LWIP_IPV6 && LWIP_IPV4 - if (local_addr != NULL) { - local_addr->type = lwip_af_to_ip_addr_type(family); - } -#endif return res; } diff --git a/pkg/lwip/patches/0001-Fix-warnings.patch b/pkg/lwip/patches/0001-Fix-warnings.patch deleted file mode 100644 index c90f306ba7..0000000000 --- a/pkg/lwip/patches/0001-Fix-warnings.patch +++ /dev/null @@ -1,39 +0,0 @@ -From f732fca2cd91553aa6f14ed851f84572d374aaa6 Mon Sep 17 00:00:00 2001 -From: Martine Lenders -Date: Thu, 12 Nov 2015 16:36:00 +0100 -Subject: [PATCH 1/2] Fix warnings - ---- - src/core/ipv6/nd6.c | 2 +- - src/core/netif.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/core/ipv6/nd6.c b/src/core/ipv6/nd6.c -index 0b36718..b63a9b5 100644 ---- a/src/core/ipv6/nd6.c -+++ b/src/core/ipv6/nd6.c -@@ -635,7 +635,7 @@ nd6_input(struct pbuf *p, struct netif *inp) - if (i >= 0) { - neighbor_cache[i].netif = inp; - MEMCPY(neighbor_cache[i].lladdr, lladdr_opt->addr, inp->hwaddr_len); -- ip6_addr_set(&(neighbor_cache[i].next_hop_address), &tmp); -+ ip6_addr_copy(neighbor_cache[i].next_hop_address, tmp); - - /* Receiving a message does not prove reachability: only in one direction. - * Delay probe in case we get confirmation of reachability from upper layer (TCP). */ -diff --git a/src/core/netif.c b/src/core/netif.c -index 428b148..f7c18e9 100644 ---- a/src/core/netif.c -+++ b/src/core/netif.c -@@ -1042,7 +1042,7 @@ netif_ip6_addr_set_parts(struct netif *netif, s8_t addr_idx, u32_t i0, u32_t i1, - LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_ip6_addr_set: netif address being changed\n")); - - if (netif_ip6_addr_state(netif, addr_idx) & IP6_ADDR_VALID) { --#if LWIP_TCP || LWIP_UDP -+#if LWIP_TCP || LWIP_UDP || LWIP_RAW - ip_addr_t new_ipaddr; - IP_ADDR6(&new_ipaddr, i0, i1, i2, i3); - #endif /* LWIP_TCP || LWIP_UDP */ --- -2.7.4 - diff --git a/pkg/lwip/patches/0001-lowpan6.c-Fix-IEEE-802.15.4-address-setting.patch b/pkg/lwip/patches/0001-lowpan6.c-Fix-IEEE-802.15.4-address-setting.patch new file mode 100644 index 0000000000..793da70f4e --- /dev/null +++ b/pkg/lwip/patches/0001-lowpan6.c-Fix-IEEE-802.15.4-address-setting.patch @@ -0,0 +1,38 @@ +From ae1128a138dbf7b14886853bd149757b03859cdb Mon Sep 17 00:00:00 2001 +From: Martine Lenders +Date: Thu, 27 Sep 2018 21:21:18 +0200 +Subject: [PATCH] lowpan6.c: Fix IEEE 802.15.4 address setting + +Reverts a regression introduced in +3a8af612b3b818a89de5846cc9b046756af184cc: + +Use hardware address fetched from neighbor cache *not* the hardware +address of the interface as destination address. +--- + src/netif/lowpan6.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/src/netif/lowpan6.c b/src/netif/lowpan6.c +index 5769522..7f0d276 100644 +--- a/src/netif/lowpan6.c ++++ b/src/netif/lowpan6.c +@@ -630,11 +630,11 @@ lowpan6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr) + } + + /* Send out the packet using the returned hardware address. */ +- result = lowpan6_hwaddr_to_addr(netif, &dest); +- if (result != ERR_OK) { +- MIB2_STATS_NETIF_INC(netif, ifoutdiscards); +- return result; +- } ++ dest.addr_len = netif->hwaddr_len; ++ /* XXX: Inferring the length of the source address from the destination address ++ * is not correct for IEEE 802.15.4, but currently we don't get this information ++ * from the neighbor cache */ ++ SMEMCPY(dest.addr, hwaddr, netif->hwaddr_len); + MIB2_STATS_NETIF_INC(netif, ifoutucastpkts); + return lowpan6_frag(netif, q, &src, &dest); + } +-- +2.7.4 + diff --git a/pkg/lwip/patches/0002-Add-RIOT-Makefiles.patch b/pkg/lwip/patches/0002-Add-RIOT-Makefiles.patch deleted file mode 100644 index d6e0000b72..0000000000 --- a/pkg/lwip/patches/0002-Add-RIOT-Makefiles.patch +++ /dev/null @@ -1,119 +0,0 @@ -From 1111daabb54619247649a5d065ce031edd3a968f Mon Sep 17 00:00:00 2001 -From: Martine Lenders -Date: Thu, 12 Nov 2015 15:43:31 +0100 -Subject: [PATCH 2/2] Add RIOT Makefiles - ---- - Makefile | 23 +++++++++++++++++++++++ - src/api/Makefile | 3 +++ - src/core/Makefile | 3 +++ - src/core/ipv4/Makefile | 3 +++ - src/core/ipv6/Makefile | 3 +++ - src/netif/Makefile | 3 +++ - src/netif/ppp/Makefile | 3 +++ - src/netif/ppp/polarssl/Makefile | 3 +++ - 8 files changed, 44 insertions(+) - create mode 100644 Makefile - create mode 100644 src/api/Makefile - create mode 100644 src/core/Makefile - create mode 100644 src/core/ipv4/Makefile - create mode 100644 src/core/ipv6/Makefile - create mode 100644 src/netif/Makefile - create mode 100644 src/netif/ppp/Makefile - create mode 100644 src/netif/ppp/polarssl/Makefile - -diff --git a/Makefile b/Makefile -new file mode 100644 -index 0000000..dbfb087 ---- /dev/null -+++ b/Makefile -@@ -0,0 +1,23 @@ -+ifneq (,$(filter lwip_api,$(USEMODULE))) -+ DIRS += src/api -+endif -+ifneq (,$(filter lwip_core,$(USEMODULE))) -+ DIRS += src/core -+endif -+ifneq (,$(filter lwip_ipv4,$(USEMODULE))) -+ DIRS += src/core/ipv4 -+endif -+ifneq (,$(filter lwip_ipv6,$(USEMODULE))) -+ DIRS += src/core/ipv6 -+endif -+ifneq (,$(filter lwip_netif,$(USEMODULE))) -+ DIRS += src/netif -+endif -+ifneq (,$(filter lwip_netif_ppp,$(USEMODULE))) -+ DIRS += src/netif/ppp -+endif -+ifneq (,$(filter lwip_polarssl,$(USEMODULE))) -+ DIRS += src/netif/ppp/polarssl -+endif -+ -+include $(RIOTBASE)/Makefile.base -diff --git a/src/api/Makefile b/src/api/Makefile -new file mode 100644 -index 0000000..84b4323 ---- /dev/null -+++ b/src/api/Makefile -@@ -0,0 +1,3 @@ -+MODULE := lwip_api -+ -+include $(RIOTBASE)/Makefile.base -diff --git a/src/core/Makefile b/src/core/Makefile -new file mode 100644 -index 0000000..2943234 ---- /dev/null -+++ b/src/core/Makefile -@@ -0,0 +1,3 @@ -+MODULE := lwip_core -+ -+include $(RIOTBASE)/Makefile.base -diff --git a/src/core/ipv4/Makefile b/src/core/ipv4/Makefile -new file mode 100644 -index 0000000..b3a7a5e ---- /dev/null -+++ b/src/core/ipv4/Makefile -@@ -0,0 +1,3 @@ -+MODULE := lwip_ipv4 -+ -+include $(RIOTBASE)/Makefile.base -diff --git a/src/core/ipv6/Makefile b/src/core/ipv6/Makefile -new file mode 100644 -index 0000000..e26e51f ---- /dev/null -+++ b/src/core/ipv6/Makefile -@@ -0,0 +1,3 @@ -+MODULE := lwip_ipv6 -+ -+include $(RIOTBASE)/Makefile.base -diff --git a/src/netif/Makefile b/src/netif/Makefile -new file mode 100644 -index 0000000..bb86d8f ---- /dev/null -+++ b/src/netif/Makefile -@@ -0,0 +1,3 @@ -+MODULE := lwip_netif -+ -+include $(RIOTBASE)/Makefile.base -diff --git a/src/netif/ppp/Makefile b/src/netif/ppp/Makefile -new file mode 100644 -index 0000000..bd21288 ---- /dev/null -+++ b/src/netif/ppp/Makefile -@@ -0,0 +1,3 @@ -+MODULE := lwip_netif_ppp -+ -+include $(RIOTBASE)/Makefile.base -diff --git a/src/netif/ppp/polarssl/Makefile b/src/netif/ppp/polarssl/Makefile -new file mode 100644 -index 0000000..6030171 ---- /dev/null -+++ b/src/netif/ppp/polarssl/Makefile -@@ -0,0 +1,3 @@ -+MODULE := lwip_polarssl -+ -+include $(RIOTBASE)/Makefile.base --- -2.7.4 - diff --git a/tests/lwip_sock_ip/stack.c b/tests/lwip_sock_ip/stack.c index e4c91671eb..7dfd18879e 100644 --- a/tests/lwip_sock_ip/stack.c +++ b/tests/lwip_sock_ip/stack.c @@ -235,6 +235,8 @@ void _prepare_send_checks(void) if (nc->state == ND6_NO_ENTRY) { nc->state = ND6_REACHABLE; memcpy(&nc->next_hop_address, remote6, sizeof(ip6_addr_t)); + ip6_addr_assign_zone(&nc->next_hop_address, + IP6_UNICAST, &netif); memcpy(&nc->lladdr, mac, 6); nc->netif = &netif; nc->counter.reachable_time = UINT32_MAX; diff --git a/tests/lwip_sock_tcp/Makefile b/tests/lwip_sock_tcp/Makefile index f14f945617..499e61386e 100644 --- a/tests/lwip_sock_tcp/Makefile +++ b/tests/lwip_sock_tcp/Makefile @@ -5,7 +5,8 @@ include ../Makefile.tests_common BOARD_BLACKLIST := arduino-uno arduino-duemilanove arduino-mega2560 chronos \ msb-430 msb-430h telosb waspmote-pro wsn430-v1_3b \ wsn430-v1_4 z1 jiminy-mega256rfr2 mega-xplained -BOARD_INSUFFICIENT_MEMORY = nucleo-f031k6 nucleo-f042k6 nucleo-l031k6 nucleo-f030r8 \ +BOARD_INSUFFICIENT_MEMORY = blackpill bluepill nucleo-f031k6 nucleo-f042k6 \ + nucleo-l031k6 nucleo-f030r8 nucleo-f302r8 \ nucleo-f303k8 nucleo-f334r8 nucleo-l053r8 \ stm32f0discovery diff --git a/tests/lwip_sock_udp/stack.c b/tests/lwip_sock_udp/stack.c index 4ac890b6e3..d4a08c43af 100644 --- a/tests/lwip_sock_udp/stack.c +++ b/tests/lwip_sock_udp/stack.c @@ -39,7 +39,7 @@ #include "constants.h" #include "stack.h" -#define _MSG_QUEUE_SIZE (1) +#define _MSG_QUEUE_SIZE (4) #define _SEND_DONE (0x92d7) #define _NETDEV_BUFFER_SIZE (128) @@ -237,6 +237,8 @@ void _prepare_send_checks(void) if (nc->state == ND6_NO_ENTRY) { nc->state = ND6_REACHABLE; memcpy(&nc->next_hop_address, remote6, sizeof(ip6_addr_t)); + ip6_addr_assign_zone(&nc->next_hop_address, + IP6_UNICAST, &netif); memcpy(&nc->lladdr, mac, 6); nc->netif = &netif; nc->counter.reachable_time = UINT32_MAX;