This commit is contained in:
Joseph Henry
2018-02-07 15:10:38 -08:00
parent de3fc72ba0
commit b0ac457ff1
3 changed files with 247 additions and 317 deletions

View File

@@ -50,19 +50,6 @@
#define STACK_PICO 0
#define NO_STACK 0 // for layer-2 only (this will omit all userspace network stack code)
/* The following three quantities are related and govern how incoming frames are fed into the
network stack's core:
Every LWIP_GUARDED_BUF_CHECK_INTERVAL milliseconds, a callback will be called from the core and
will input a maximum of LWIP_FRAMES_HANDLED_PER_CORE_CALL frames before returning control back
to the core. Meanwhile, incoming frames from the ZeroTier wire will be allocated and their
pointers will be cached in the receive frame buffer of the size LWIP_MAX_GUARDED_RX_BUF_SZ to
await the next callback from the core */
#define LWIP_GUARDED_BUF_CHECK_INTERVAL 50 // in ms
#define LWIP_MAX_GUARDED_RX_BUF_SZ 1024 // number of frame pointers that can be cached waiting for receipt into core
#define LWIP_FRAMES_HANDLED_PER_CORE_CALL 16
/* sanity checks for userspace network stack and socket API layer choices
EX.
@@ -139,10 +126,6 @@ await the next callback from the core */
*/
#define ZTO_ID_LEN 16
//#if !defined(__WIN32__)
//typedef unsigned int socklen_t;
//#endif
#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
@@ -173,81 +156,40 @@ struct sockaddr_ll {
#endif
/*
// Provide missing optnames for setsockopt() implementations
#ifdef _WIN32
#ifdef _WIN64
#else
#endif
#elif __APPLE__
#define IP_BIND_ADDRESS_NO_PORT 201
#define IP_FREEBIND 202
#define IP_MTU 203
#define IP_MTU_DISCOVER 204
#define IP_MULTICAST_ALL 205
#define IP_NODEFRAG 206
#define IP_RECVORIGDSTADDR 207
#define IP_ROUTER_ALERT 208
#define IP_TRANSPARENT 209
#define TCP_INFO 210
#define SO_STYLE 100
#define TCP_CORK 101
#define TCP_DEFER_ACCEPT 102
//#ifndef TCP_KEEPIDLE
//#define TCP_KEEPIDLE 103
//#endif
#define TCP_LINGER2 104
#define TCP_QUICKACK 105
#define TCP_SYNCNT 106
#define TCP_WINDOW_CLAMP 107
#define UDP_CORK 108
#elif __linux__
#define SO_STYLE 100
#define UDP_CORK 101
#define IP_BIND_ADDRESS_NO_PORT 201
#define IP_NODEFRAG 206
#elif __unix__
#elif defined(_POSIX_VERSION)
#else
# error "Unknown platform"
#endif
*/
/****************************************************************************/
/* Legend */
/****************************************************************************/
/*
NSLWIP network_stack_lwip
NSPICO network_stack_pico
NSRXBF network_stack_pico guarded frame buffer RX
ZTVIRT zt_virtual_wire
APPFDS app_fd
VSRXBF app_fd TX buf
VSTXBF app_fd RX buf
*/
/****************************************************************************/
/* lwIP */
/****************************************************************************/
#define LWIP_NETIF_STATUS_CALLBACK 0
// For LWIP configuration see: include/lwipopts.h
#if defined(STACK_LWIP)
/* The following three quantities are related and govern how incoming frames are fed into the
network stack's core:
Every LWIP_GUARDED_BUF_CHECK_INTERVAL milliseconds, a callback will be called from the core and
will input a maximum of LWIP_FRAMES_HANDLED_PER_CORE_CALL frames before returning control back
to the core. Meanwhile, incoming frames from the ZeroTier wire will be allocated and their
pointers will be cached in the receive frame buffer of the size LWIP_MAX_GUARDED_RX_BUF_SZ to
await the next callback from the core */
#define LWIP_GUARDED_BUF_CHECK_INTERVAL 50 // in ms
#define LWIP_MAX_GUARDED_RX_BUF_SZ 1024 // number of frame pointers that can be cached waiting for receipt into core
#define LWIP_FRAMES_HANDLED_PER_CORE_CALL 16 // How many frames are handled per call from core
#define LWIP_NETIF_STATUS_CALLBACK 0
typedef signed char err_t;
#define ND6_DISCOVERY_INTERVAL 1000
#define ARP_DISCOVERY_INTERVAL ARP_TMR_INTERVAL
/**
Specifies the polling interval and the callback function that should
be called to poll the application. The interval is specified in
number of TCP coarse grained timer shots, which typically occurs
twice a second. An interval of 10 means that the application would
be polled every 5 seconds. (only for raw lwIP driver)
* Specifies the polling interval and the callback function that should
* be called to poll the application. The interval is specified in
* number of TCP coarse grained timer shots, which typically occurs
* twice a second. An interval of 10 means that the application would
* be polled every 5 seconds. (only for raw lwIP driver)
*/
#define LWIP_APPLICATION_POLL_FREQ 2
@@ -264,13 +206,6 @@ typedef signed char err_t;
// #define LWIP_CHKSUM <your_checksum_routine>, See: RFC1071 for inspiration
#endif
/****************************************************************************/
/* picoTCP */
/****************************************************************************/
#if defined(STACK_PICO)
#endif
/****************************************************************************/
/* Defines */
/****************************************************************************/
@@ -345,27 +280,26 @@ typedef signed char err_t;
*/
#define ZT_UDP_RX_BUF_SZ ZT_MAX_MTU * 10
// Send and Receive buffer sizes for the network stack
// By default picoTCP sets them to 16834, this is good for embedded-scale
// stuff but you might want to consider higher values for desktop and mobile
// applications.
/**
*
* Send buffer size for the network stack
* By default picoTCP sets them to 16834, this is good for embedded-scale
* stuff but you might want to consider higher values for desktop and mobile
* applications.
*/
#define ZT_STACK_TCP_SOCKET_TX_SZ ZT_TCP_TX_BUF_SZ
/**
*
* Receive buffer size for the network stack
* By default picoTCP sets them to 16834, this is good for embedded-scale
* stuff but you might want to consider higher values for desktop and mobile
* applications.
*/
#define ZT_STACK_TCP_SOCKET_RX_SZ ZT_TCP_RX_BUF_SZ
// Maximum size we're allowed to read or write from a stack socket
// This is put in place because picoTCP seems to fail at higher values.
// If you use another stack you can probably bump this up a bit.
/**
* Maximum size of write operation to a network stack
* Maximum size we're allowed to read or write from a stack socket
* This is put in place because picoTCP seems to fail at higher values.
* If you use another stack you can probably bump this up a bit.
*/
#define ZT_STACK_SOCKET_WR_MAX 4096

View File

@@ -78,7 +78,7 @@ struct netif lwipInterfaces[10];
int lwipInterfacesCount = 0;
ZeroTier::Mutex _rx_input_lock_m;
struct pbuf* lwip_frame_rxbuf[MAX_GUARDED_RX_BUF_SZ];
struct pbuf* lwip_frame_rxbuf[LWIP_MAX_GUARDED_RX_BUF_SZ];
int lwip_frame_rxbuf_tot = 0;
@@ -386,10 +386,6 @@ void lwip_init_interface(void *tapref, const ZeroTier::MAC &mac, const ZeroTier:
lwipInterfacesCount++;
}
/****************************************************************************/
/* Raw API driver */
/****************************************************************************/