################################################################################
# Sources
################################################################################
-LIBLWIP_ZIPNAME=lwip-2.1.2
-LIBLWIP_URL=http://download.savannah.nongnu.org/releases/lwip/$(LIBLWIP_ZIPNAME).zip
+LIBLWIP_TAG=STABLE-2_1_2_RELEASE
+LIBLWIP_ZIPNAME=fork-lwip-$(LIBLWIP_TAG)
+LIBLWIP_URL=https://github.com/unikraft/fork-lwip/archive/refs/tags/$(LIBLWIP_TAG).zip
+LIBLWIP_ORIGIN_SHA256=8f0ae46e2702720ce852b00de5d304adb2809b0203741f299876594bb8be7890
+
LIBLWIP_PATCHDIR=$(LIBLWIP_BASE)/patches
$(eval $(call fetch,liblwip,$(LIBLWIP_URL)))
$(eval $(call patch,liblwip,$(LIBLWIP_PATCHDIR),$(LIBLWIP_ZIPNAME)))
LIBLWIP_CFLAGS-$(CONFIG_LWIP_DEBUG) += -DUK_DEBUG
LIBLWIP_CFLAGS-y += -D__IN_LIBLWIP__
LIBLWIP_CXXFLAGS-y += -D__IN_LIBLWIP__
-
+
################################################################################
# Core
################################################################################
--- a/src/api/sockets.c 2018-03-05 16:12:39.917974880 +0100
+++ b/src/api/sockets.c 2018-03-05 16:12:24.577997842 +0100
@@ -44,6 +44,8 @@
- *\r
- */\r
- \r
-+#include <sys/time.h>\r
-+\r
- #include "lwip/opt.h"\r
- \r
- #if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */\r
+ *
+ */
+
++#include <sys/time.h>
++
+ #include "lwip/opt.h"
+
+ #if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
--- a/src/include/lwip/sockets.h
+++ b/src/include/lwip/sockets.h
@@ -39,6 +39,8 @@
- #ifndef LWIP_HDR_SOCKETS_H\r
- #define LWIP_HDR_SOCKETS_H\r
- \r
-+#include <uk/config.h>\r
-+\r
- #include "lwip/opt.h"\r
- \r
- #if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */\r
-@@ -438,6 +440,7 @@ typedef struct ipv6_mreq {\r
- #define F_SETFL 4\r
- #endif\r
- \r
-+#ifndef CONFIG_HAVE_LIBC\r
- /* File status flags and file access modes for fnctl,\r
- these are bits in an int. */\r
- #ifndef O_NONBLOCK\r
-@@ -455,6 +458,7 @@ typedef struct ipv6_mreq {\r
- #ifndef O_RDWR\r
- #define O_RDWR (O_RDONLY|O_WRONLY)\r
- #endif\r
-+#endif /* CONFIG_HAVE_LIBC */\r
- \r
- #ifndef SHUT_RD\r
- #define SHUT_RD 0\r
+ #ifndef LWIP_HDR_SOCKETS_H
+ #define LWIP_HDR_SOCKETS_H
+
++#include <uk/config.h>
++
+ #include "lwip/opt.h"
+
+ #if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
+@@ -447,6 +449,7 @@ typedef struct ipv6_mreq {
+ #define F_SETFL 4
+ #endif
+
++#ifndef CONFIG_HAVE_LIBC
+ /* File status flags and file access modes for fnctl,
+ these are bits in an int. */
+ #ifndef O_NONBLOCK
+@@ -464,6 +467,7 @@ typedef struct ipv6_mreq {
+ #ifndef O_RDWR
+ #define O_RDWR (O_RDONLY|O_WRONLY)
+ #endif
++#endif /* CONFIG_HAVE_LIBC */
+
+ #ifndef SHUT_RD
+ #define SHUT_RD 0
--
2.21.0
--- a/src/include/lwip/mem.h
+++ b/src/include/lwip/mem.h
@@ -69,11 +69,13 @@
- #endif /* MEM_SIZE > 64000 */\r
- #endif\r
- \r
-+#ifdef __IN_LIBLWIP__\r
- void mem_init(void);\r
- void *mem_trim(void *mem, mem_size_t size);\r
- void *mem_malloc(mem_size_t size);\r
- void *mem_calloc(mem_size_t count, mem_size_t size);\r
- void mem_free(void *mem);\r
-+#endif\r
- \r
- #ifdef __cplusplus\r
- }\r
+ #endif /* MEM_SIZE > 64000 */
+ #endif
+
++#ifdef __IN_LIBLWIP__
+ void mem_init(void);
+ void *mem_trim(void *mem, mem_size_t size);
+ void *mem_malloc(mem_size_t size);
+ void *mem_calloc(mem_size_t count, mem_size_t size);
+ void mem_free(void *mem);
++#endif
+
+ #ifdef __cplusplus
+ }
--- a/src/include/lwip/sockets.h
+++ b/src/include/lwip/sockets.h
@@ -327,6 +327,7 @@ typedef struct ip_mreq {
- #if LWIP_IPV4\r
- struct in_pktinfo {\r
- unsigned int ipi_ifindex; /* Interface index */\r
+ #if LWIP_IPV4
+ struct in_pktinfo {
+ unsigned int ipi_ifindex; /* Interface index */
+ struct in_addr ipi_spec_dst; /* Routing destination address */
- struct in_addr ipi_addr; /* Destination (from header) address */\r
- };\r
- #endif /* LWIP_IPV4 */\r
+ struct in_addr ipi_addr; /* Destination (from header) address */
+ };
+ #endif /* LWIP_IPV4 */
--- a/src/include/lwip/sockets.h
+++ b/src/include/lwip/sockets.h
@@ -184,8 +184,38 @@ will need to increase long long */
- #define IFNAMSIZ NETIF_NAMESIZE\r
- struct ifreq {\r
- char ifr_name[IFNAMSIZ]; /* Interface name */\r
+ #define IFNAMSIZ NETIF_NAMESIZE
+ struct ifreq {
+ char ifr_name[IFNAMSIZ]; /* Interface name */
+ union {
+ struct sockaddr ifru_addr;
+ struct sockaddr ifru_dstaddr;
+ char ifru_newname[IFNAMSIZ];
+ char *ifru_data;
+ } ifr_ifru;
- };\r
- \r
+ };
+
+#define ifr_hwaddr ifr_ifru.ifru_hwaddr
+#define ifr_addr ifr_ifru.ifru_addr
+#define ifr_dstaddr ifr_ifru.ifru_dstaddr
+#define ifr_qlen ifr_ifru.ifru_ivalue
+#define ifr_newname ifr_ifru.ifru_newname
+
- /* Socket protocol types (TCP/UDP/RAW) */\r
- #define SOCK_STREAM 1\r
- #define SOCK_DGRAM 2\r
+ /* Socket protocol types (TCP/UDP/RAW) */
+ #define SOCK_STREAM 1
+ #define SOCK_DGRAM 2