Upgraded lwIP stack to 2.1.2
This commit is contained in:
@@ -1,3 +1,41 @@
|
||||
diff --git a/node/RingBuffer.hpp b/node/RingBuffer.hpp
|
||||
index dab81b9e..0d90152b 100644
|
||||
--- a/node/RingBuffer.hpp
|
||||
+++ b/node/RingBuffer.hpp
|
||||
@@ -72,6 +72,11 @@ public:
|
||||
memset(buf, 0, sizeof(T) * size);
|
||||
}
|
||||
|
||||
+ ~RingBuffer()
|
||||
+ {
|
||||
+ delete [] buf;
|
||||
+ }
|
||||
+
|
||||
/**
|
||||
* @return A pointer to the underlying buffer
|
||||
*/
|
||||
diff --git a/node/Switch.cpp b/node/Switch.cpp
|
||||
index 74c22d33..58979e26 100644
|
||||
--- a/node/Switch.cpp
|
||||
+++ b/node/Switch.cpp
|
||||
@@ -532,7 +532,7 @@ void Switch::aqm_enqueue(void *tPtr, const SharedPtr<Network> &network, Packet &
|
||||
TXQueueEntry *txEntry = new TXQueueEntry(dest,RR->node->now(),packet,encrypt);
|
||||
|
||||
ManagedQueue *selectedQueue = nullptr;
|
||||
- for (int i=0; i<ZT_QOS_NUM_BUCKETS; i++) {
|
||||
+ for (size_t i=0; i<ZT_QOS_NUM_BUCKETS; i++) {
|
||||
if (i < nqcb->oldQueues.size()) { // search old queues first (I think this is best since old would imply most recent usage of the queue)
|
||||
if (nqcb->oldQueues[i]->id == qosBucket) {
|
||||
selectedQueue = nqcb->oldQueues[i];
|
||||
@@ -568,7 +568,7 @@ void Switch::aqm_enqueue(void *tPtr, const SharedPtr<Network> &network, Packet &
|
||||
{
|
||||
// DEBUG_INFO("too many enqueued packets (%d), finding packet to drop", nqcb->_currEnqueuedPackets);
|
||||
int maxQueueLength = 0;
|
||||
- for (int i=0; i<ZT_QOS_NUM_BUCKETS; i++) {
|
||||
+ for (size_t i=0; i<ZT_QOS_NUM_BUCKETS; i++) {
|
||||
if (i < nqcb->oldQueues.size()) {
|
||||
if (nqcb->oldQueues[i]->byteLength > maxQueueLength) {
|
||||
maxQueueLength = nqcb->oldQueues[i]->byteLength;
|
||||
diff --git a/service/OneService.cpp b/service/OneService.cpp
|
||||
index a1c53764..757863a8 100644
|
||||
--- a/service/OneService.cpp
|
||||
|
||||
2
ext/lwip
2
ext/lwip
Submodule ext/lwip updated: 92f23d6ca0...159e31b689
Submodule ext/lwip-contrib updated: 4d1838043e...35b011d4cf
@@ -1,17 +1,17 @@
|
||||
diff --git a/ports/unix/port/include/arch/cc.h b/ports/unix/port/include/arch/cc.h
|
||||
index a3dac04..424285e 100644
|
||||
index 80b37d8..ae46d76 100644
|
||||
--- a/ports/unix/port/include/arch/cc.h
|
||||
+++ b/ports/unix/port/include/arch/cc.h
|
||||
@@ -32,6 +32,8 @@
|
||||
#ifndef LWIP_ARCH_CC_H
|
||||
#define LWIP_ARCH_CC_H
|
||||
|
||||
+#include "include/Debug.hpp"
|
||||
+#include "include/Debug.hpp" // libzt
|
||||
+
|
||||
/* see https://sourceforge.net/p/predef/wiki/OperatingSystems/ */
|
||||
#if defined __ANDROID__
|
||||
#define LWIP_UNIX_ANDROID
|
||||
@@ -55,7 +57,7 @@
|
||||
@@ -65,7 +67,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(LWIP_UNIX_ANDROID) && defined(FD_SET)
|
||||
@@ -19,27 +19,14 @@ index a3dac04..424285e 100644
|
||||
+//typedef __kernel_fd_set fd_set;
|
||||
#endif
|
||||
|
||||
struct sio_status_s;
|
||||
@@ -63,4 +65,7 @@ typedef struct sio_status_s sio_status_t;
|
||||
#if defined(LWIP_UNIX_MACH)
|
||||
@@ -81,6 +83,9 @@ typedef struct sio_status_s sio_status_t;
|
||||
#define sio_fd_t sio_status_t*
|
||||
#define __sio_fd_t_defined
|
||||
|
||||
+// Comment out the following line to use lwIP's default diagnostic printing routine
|
||||
+#define LWIP_PLATFORM_DIAG(x) do {DEBUG_INFO x;} while(0)
|
||||
+
|
||||
typedef unsigned int sys_prot_t;
|
||||
|
||||
#endif /* LWIP_ARCH_CC_H */
|
||||
diff --git a/ports/win32/include/arch/cc.h b/ports/win32/include/arch/cc.h
|
||||
index 334be07..9384b70 100644
|
||||
--- a/ports/win32/include/arch/cc.h
|
||||
+++ b/ports/win32/include/arch/cc.h
|
||||
@@ -78,8 +78,8 @@ typedef int sys_prot_t;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* C runtime functions redefined */
|
||||
-#define snprintf _snprintf
|
||||
-#define strdup _strdup
|
||||
+//#define snprintf _snprintf
|
||||
+//#define strdup _strdup
|
||||
#endif
|
||||
|
||||
#define PPP_INCLUDE_SETTINGS_HEADER
|
||||
|
||||
232
ext/lwip.patch
232
ext/lwip.patch
@@ -1,232 +0,0 @@
|
||||
diff --git a/src/api/sockets.c b/src/api/sockets.c
|
||||
index b7632489..786a294e 100644
|
||||
--- a/src/api/sockets.c
|
||||
+++ b/src/api/sockets.c
|
||||
@@ -44,6 +44,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
+//#include <errno.h>
|
||||
+
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
|
||||
diff --git a/src/api/tcpip.c b/src/api/tcpip.c
|
||||
index 07b2f984..f10136e2 100644
|
||||
--- a/src/api/tcpip.c
|
||||
+++ b/src/api/tcpip.c
|
||||
@@ -150,6 +150,11 @@ tcpip_thread(void *arg)
|
||||
msg->msg.cb.function(msg->msg.cb.ctx);
|
||||
break;
|
||||
|
||||
+ case TCPIP_MSG_SHUTDOWN:
|
||||
+ LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: SHUTDOWN %p\n", (void *)msg));
|
||||
+ sys_sem_signal(msg->msg.api_call.sem);
|
||||
+ return;
|
||||
+
|
||||
default:
|
||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: invalid message: %d\n", msg->type));
|
||||
LWIP_ASSERT("tcpip_thread: invalid message", 0);
|
||||
@@ -158,6 +163,49 @@ tcpip_thread(void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
+err_t
|
||||
+tcpip_shutdown(void)
|
||||
+{
|
||||
+ //struct tcpip_msg msg;
|
||||
+ sys_sem_t sem;
|
||||
+
|
||||
+ /* If there is no tcpip mailbox, leave */
|
||||
+ if (mbox == SYS_MBOX_NULL)
|
||||
+ return ERR_OK;
|
||||
+
|
||||
+ /* Create semaphore for message */
|
||||
+ sys_sem_new(&sem, 0);
|
||||
+ LWIP_ASSERT("tcpip_terminate: failed to create semaphore\n",
|
||||
+ sem != SYS_SEM_NULL);
|
||||
+ if (sem == SYS_SEM_NULL) {
|
||||
+ return ERR_MEM;
|
||||
+ }
|
||||
+
|
||||
+ /* TODO: do we need to stop the timers? if so, how? */
|
||||
+
|
||||
+ struct tcpip_msg *msg;
|
||||
+ LWIP_ASSERT("Invalid mbox", sys_mbox_valid_val(mbox));
|
||||
+ msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_INPKT);
|
||||
+
|
||||
+ /* Tell tcpip thread to exit, and wait */
|
||||
+ msg->msg.api_call.sem = &sem;
|
||||
+ msg->type = TCPIP_MSG_SHUTDOWN;
|
||||
+
|
||||
+ if (sys_mbox_trypost(&mbox, msg) != ERR_OK) {
|
||||
+ memp_free(MEMP_TCPIP_MSG_INPKT, msg);
|
||||
+ return ERR_MEM;
|
||||
+ }
|
||||
+
|
||||
+ sys_arch_sem_wait(&sem, 0);
|
||||
+
|
||||
+ /* clean up tcpip thread resources */
|
||||
+
|
||||
+ //sys_mbox_free(&mbox);
|
||||
+ sys_sem_free(&sem);
|
||||
+ mbox = SYS_MBOX_NULL;
|
||||
+ return ERR_OK;
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* Pass a received packet to tcpip_thread for input processing
|
||||
*
|
||||
diff --git a/src/core/ipv6/ip6.c b/src/core/ipv6/ip6.c
|
||||
index f14e3342..facd3b21 100644
|
||||
--- a/src/core/ipv6/ip6.c
|
||||
+++ b/src/core/ipv6/ip6.c
|
||||
@@ -264,6 +264,17 @@ ip6_select_source_address(struct netif *netif, const ip6_addr_t *dest)
|
||||
}
|
||||
}
|
||||
|
||||
+ /* Choose a ZeroTier adhoc with matching prefix. */
|
||||
+ if (ip6_addr_is_zt_adhoc(dest)) {
|
||||
+ for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
|
||||
+ if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) &&
|
||||
+ ip6_addr_is_zt_adhoc(netif_ip6_addr(netif, i)) &&
|
||||
+ ip6_addr_6plane_cmp(dest, netif_ip6_addr(netif, i))) {
|
||||
+ return netif_ip_addr6(netif, i);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
/* Last resort: see if arbitrary prefix matches. */
|
||||
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
|
||||
if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) &&
|
||||
diff --git a/src/core/ipv6/nd6.c b/src/core/ipv6/nd6.c
|
||||
index 0b367181..2a5b77d4 100644
|
||||
--- a/src/core/ipv6/nd6.c
|
||||
+++ b/src/core/ipv6/nd6.c
|
||||
@@ -1361,8 +1361,13 @@ nd6_is_prefix_in_netif(const ip6_addr_t *ip6addr, struct netif *netif)
|
||||
}
|
||||
/* Check to see if address prefix matches a (manually?) configured address. */
|
||||
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
|
||||
- if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) &&
|
||||
- ip6_addr_netcmp(ip6addr, netif_ip6_addr(netif, i))) {
|
||||
+ int prefix_match = 0;
|
||||
+ if (ip6_addr_is_zt_6plane(ip6addr) || ip6_addr_is_zt_adhoc(ip6addr)) {
|
||||
+ prefix_match = ip6_addr_6plane_cmp(ip6addr, netif_ip6_addr(netif, i));
|
||||
+ } else {
|
||||
+ prefix_match = ip6_addr_netcmp(ip6addr, netif_ip6_addr(netif, i));
|
||||
+ }
|
||||
+ if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && prefix_match) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
diff --git a/src/core/timeouts.c b/src/core/timeouts.c
|
||||
index 8bf209a5..cf4e556a 100644
|
||||
--- a/src/core/timeouts.c
|
||||
+++ b/src/core/timeouts.c
|
||||
@@ -186,6 +186,19 @@ void sys_timeouts_init(void)
|
||||
timeouts_last_time = sys_now();
|
||||
}
|
||||
|
||||
+/** Remove all timeouts */
|
||||
+void sys_timeouts_free(void)
|
||||
+{
|
||||
+ size_t i;
|
||||
+ for (i = (LWIP_TCP ? 1 : 0); i < LWIP_ARRAYSIZE(lwip_cyclic_timers); i++) {
|
||||
+ /* we have to cast via size_t to get rid of const warning
|
||||
+ (this is OK as cyclic_timer() casts back to const* */
|
||||
+ sys_untimeout(cyclic_timer, LWIP_CONST_CAST(void*, &lwip_cyclic_timers[i]));
|
||||
+ }
|
||||
+ /* Initialise timestamp for sys_check_timeouts */
|
||||
+ timeouts_last_time = sys_now();
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* Create a one-shot timer (aka timeout). Timeouts are processed in the
|
||||
* following cases:
|
||||
diff --git a/src/include/lwip/errno.h b/src/include/lwip/errno.h
|
||||
index 641cffb0..cec43f7f 100644
|
||||
--- a/src/include/lwip/errno.h
|
||||
+++ b/src/include/lwip/errno.h
|
||||
@@ -174,7 +174,11 @@ extern "C" {
|
||||
#define EMEDIUMTYPE 124 /* Wrong medium type */
|
||||
|
||||
#ifndef errno
|
||||
-extern int errno;
|
||||
+#if defined(__linux__) && !defined(__ANDROID__)
|
||||
+ #include <errno.h>
|
||||
+#else
|
||||
+ extern int errno;
|
||||
+#endif
|
||||
#endif
|
||||
|
||||
#else /* LWIP_PROVIDE_ERRNO */
|
||||
diff --git a/src/include/lwip/ip6_addr.h b/src/include/lwip/ip6_addr.h
|
||||
index ee381aeb..b879f212 100644
|
||||
--- a/src/include/lwip/ip6_addr.h
|
||||
+++ b/src/include/lwip/ip6_addr.h
|
||||
@@ -133,6 +133,14 @@ typedef struct ip6_addr ip6_addr_t;
|
||||
#define ip6_addr_netcmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \
|
||||
((addr1)->addr[1] == (addr2)->addr[1]))
|
||||
|
||||
+#define ip6_addr_is_zt_6plane(addr1) (((addr1)->addr[0] & PP_HTONL(0xffffffffUL)) == PP_HTONL(0xfc937e7fUL) && \
|
||||
+ ((addr1)->addr[1] & PP_HTONL(0xff000000UL)) == PP_HTONL(0x72000000UL))
|
||||
+
|
||||
+#define ip6_addr_is_zt_adhoc(addr1) (((addr1)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xfce90000UL))
|
||||
+
|
||||
+#define ip6_addr_6plane_cmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \
|
||||
+ ((addr1)->addr[1] & PP_HTONL(0xff000000UL)) == ((addr2)->addr[1] & PP_HTONL(0xff000000UL)))
|
||||
+
|
||||
#define ip6_addr_cmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \
|
||||
((addr1)->addr[1] == (addr2)->addr[1]) && \
|
||||
((addr1)->addr[2] == (addr2)->addr[2]) && \
|
||||
diff --git a/src/include/lwip/priv/tcpip_priv.h b/src/include/lwip/priv/tcpip_priv.h
|
||||
index 630efb14..41fb3e60 100644
|
||||
--- a/src/include/lwip/priv/tcpip_priv.h
|
||||
+++ b/src/include/lwip/priv/tcpip_priv.h
|
||||
@@ -117,7 +117,8 @@ enum tcpip_msg_type {
|
||||
TCPIP_MSG_UNTIMEOUT,
|
||||
#endif /* LWIP_TCPIP_TIMEOUT && LWIP_TIMERS */
|
||||
TCPIP_MSG_CALLBACK,
|
||||
- TCPIP_MSG_CALLBACK_STATIC
|
||||
+ TCPIP_MSG_CALLBACK_STATIC,
|
||||
+ TCPIP_MSG_SHUTDOWN
|
||||
};
|
||||
|
||||
struct tcpip_msg {
|
||||
diff --git a/src/include/lwip/sockets.h b/src/include/lwip/sockets.h
|
||||
index 2522056d..1af0c989 100644
|
||||
--- a/src/include/lwip/sockets.h
|
||||
+++ b/src/include/lwip/sockets.h
|
||||
@@ -104,7 +104,7 @@ struct sockaddr_storage {
|
||||
|
||||
/* If your port already typedef's socklen_t, define SOCKLEN_T_DEFINED
|
||||
to prevent this code from redefining it. */
|
||||
-#if !defined(socklen_t) && !defined(SOCKLEN_T_DEFINED)
|
||||
+#if !defined(socklen_t) && !defined(SOCKLEN_T_DEFINED) && !defined(__ANDROID__)
|
||||
typedef u32_t socklen_t;
|
||||
#endif
|
||||
|
||||
diff --git a/src/include/lwip/tcpip.h b/src/include/lwip/tcpip.h
|
||||
index f2f6b469..60d3578b 100644
|
||||
--- a/src/include/lwip/tcpip.h
|
||||
+++ b/src/include/lwip/tcpip.h
|
||||
@@ -73,6 +73,7 @@ typedef void (*tcpip_callback_fn)(void *ctx);
|
||||
struct tcpip_callback_msg;
|
||||
|
||||
void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg);
|
||||
+err_t tcpip_shutdown();
|
||||
|
||||
err_t tcpip_inpkt(struct pbuf *p, struct netif *inp, netif_input_fn input_fn);
|
||||
err_t tcpip_input(struct pbuf *p, struct netif *inp);
|
||||
diff --git a/src/include/lwip/timeouts.h b/src/include/lwip/timeouts.h
|
||||
index c9b93aa0..74385dd4 100644
|
||||
--- a/src/include/lwip/timeouts.h
|
||||
+++ b/src/include/lwip/timeouts.h
|
||||
@@ -94,6 +94,7 @@ struct sys_timeo {
|
||||
};
|
||||
|
||||
void sys_timeouts_init(void);
|
||||
+void sys_timeouts_free(void);
|
||||
|
||||
#if LWIP_DEBUG_TIMERNAMES
|
||||
void sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name);
|
||||
@@ -102,6 +102,23 @@ void lwip_dns_init();
|
||||
*/
|
||||
void lwip_start_dhcp(void *netif);
|
||||
|
||||
/**
|
||||
* @brief Called when the status of a netif changes:
|
||||
* - Interface is up/down (ZTS_EVENT_NETIF_UP, ZTS_EVENT_NETIF_DOWN)
|
||||
* - Address changes while up (ZTS_EVENT_NETIF_NEW_ADDRESS)
|
||||
*/
|
||||
static void netif_status_callback(struct netif *netif);
|
||||
|
||||
/**
|
||||
* @brief Called when a netif is removed (ZTS_EVENT_NETIF_INTERFACE_REMOVED)
|
||||
*/
|
||||
static void netif_remove_callback(struct netif *netif);
|
||||
|
||||
/**
|
||||
* @brief Called when a link is brought up or down (ZTS_EVENT_NETIF_LINK_UP, ZTS_EVENT_NETIF_LINK_DOWN)
|
||||
*/
|
||||
static void netif_link_callback(struct netif *netif);
|
||||
|
||||
/**
|
||||
* @brief Set up an interface in the network stack for the VirtualTap.
|
||||
*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -82,21 +82,30 @@ int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_
|
||||
int lwip_close(int s);
|
||||
int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen);
|
||||
int lwip_listen(int s, int backlog);
|
||||
int lwip_recv(int s, void *mem, size_t len, int flags);
|
||||
int lwip_read(int s, void *mem, size_t len);
|
||||
int lwip_recvfrom(int s, void *mem, size_t len, int flags,
|
||||
ssize_t lwip_recv(int s, void *mem, size_t len, int flags);
|
||||
ssize_t lwip_read(int s, void *mem, size_t len);
|
||||
ssize_t lwip_readv(int s, const struct iovec *iov, int iovcnt);
|
||||
ssize_t lwip_recvfrom(int s, void *mem, size_t len, int flags,
|
||||
struct sockaddr *from, socklen_t *fromlen);
|
||||
int lwip_send(int s, const void *dataptr, size_t size, int flags);
|
||||
int lwip_sendmsg(int s, const struct msghdr *message, int flags);
|
||||
int lwip_sendto(int s, const void *dataptr, size_t size, int flags,
|
||||
ssize_t lwip_recvmsg(int s, struct msghdr *message, int flags);
|
||||
ssize_t lwip_send(int s, const void *dataptr, size_t size, int flags);
|
||||
ssize_t lwip_sendmsg(int s, const struct msghdr *message, int flags);
|
||||
ssize_t lwip_sendto(int s, const void *dataptr, size_t size, int flags,
|
||||
const struct sockaddr *to, socklen_t tolen);
|
||||
int lwip_socket(int domain, int type, int protocol);
|
||||
int lwip_write(int s, const void *dataptr, size_t size);
|
||||
int lwip_writev(int s, const struct iovec *iov, int iovcnt);
|
||||
ssize_t lwip_write(int s, const void *dataptr, size_t size);
|
||||
ssize_t lwip_writev(int s, const struct iovec *iov, int iovcnt);
|
||||
#if LWIP_SOCKET_SELECT
|
||||
int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
|
||||
struct timeval *timeout);
|
||||
#endif
|
||||
#if LWIP_SOCKET_POLL
|
||||
int lwip_poll(struct pollfd *fds, nfds_t nfds, int timeout);
|
||||
#endif
|
||||
int lwip_ioctl(int s, long cmd, void *argp);
|
||||
int lwip_fcntl(int s, int cmd, int val);
|
||||
const char *lwip_inet_ntop(int af, const void *src, char *dst, socklen_t size);
|
||||
int lwip_inet_pton(int af, const char *src, void *dst);
|
||||
|
||||
// Copied from lwip/src/include/sockets.h and renamed to prevent a name collision
|
||||
// with system definitions
|
||||
|
||||
Reference in New Issue
Block a user