|
|
|
@ -50,19 +50,6 @@ |
|
|
|
#define STACK_PICO 0 |
|
|
|
#define STACK_PICO 0 |
|
|
|
#define NO_STACK 0 // for layer-2 only (this will omit all userspace network stack code)
|
|
|
|
#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
|
|
|
|
/* sanity checks for userspace network stack and socket API layer choices
|
|
|
|
|
|
|
|
|
|
|
|
EX. |
|
|
|
EX. |
|
|
|
@ -139,10 +126,6 @@ await the next callback from the core */ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
#define ZTO_ID_LEN 16 |
|
|
|
#define ZTO_ID_LEN 16 |
|
|
|
|
|
|
|
|
|
|
|
//#if !defined(__WIN32__)
|
|
|
|
|
|
|
|
//typedef unsigned int socklen_t;
|
|
|
|
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(_MSC_VER) |
|
|
|
#if defined(_MSC_VER) |
|
|
|
#include <BaseTsd.h> |
|
|
|
#include <BaseTsd.h> |
|
|
|
typedef SSIZE_T ssize_t; |
|
|
|
typedef SSIZE_T ssize_t; |
|
|
|
@ -173,81 +156,40 @@ struct sockaddr_ll { |
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
#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 */ |
|
|
|
/* lwIP */ |
|
|
|
/****************************************************************************/ |
|
|
|
/****************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
#define LWIP_NETIF_STATUS_CALLBACK 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// For LWIP configuration see: include/lwipopts.h
|
|
|
|
// For LWIP configuration see: include/lwipopts.h
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(STACK_LWIP) |
|
|
|
#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; |
|
|
|
typedef signed char err_t; |
|
|
|
|
|
|
|
|
|
|
|
#define ND6_DISCOVERY_INTERVAL 1000 |
|
|
|
#define ND6_DISCOVERY_INTERVAL 1000 |
|
|
|
#define ARP_DISCOVERY_INTERVAL ARP_TMR_INTERVAL |
|
|
|
#define ARP_DISCOVERY_INTERVAL ARP_TMR_INTERVAL |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
Specifies the polling interval and the callback function that should |
|
|
|
* Specifies the polling interval and the callback function that should |
|
|
|
be called to poll the application. The interval is specified in |
|
|
|
* be called to poll the application. The interval is specified in |
|
|
|
number of TCP coarse grained timer shots, which typically occurs |
|
|
|
* number of TCP coarse grained timer shots, which typically occurs |
|
|
|
twice a second. An interval of 10 means that the application would |
|
|
|
* twice a second. An interval of 10 means that the application would |
|
|
|
be polled every 5 seconds. (only for raw lwIP driver) |
|
|
|
* be polled every 5 seconds. (only for raw lwIP driver) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
#define LWIP_APPLICATION_POLL_FREQ 2 |
|
|
|
#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
|
|
|
|
// #define LWIP_CHKSUM <your_checksum_routine>, See: RFC1071 for inspiration
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/ |
|
|
|
|
|
|
|
/* picoTCP */ |
|
|
|
|
|
|
|
/****************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(STACK_PICO) |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/ |
|
|
|
/****************************************************************************/ |
|
|
|
/* Defines */ |
|
|
|
/* Defines */ |
|
|
|
/****************************************************************************/ |
|
|
|
/****************************************************************************/ |
|
|
|
@ -345,27 +280,26 @@ typedef signed char err_t; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
#define ZT_UDP_RX_BUF_SZ ZT_MAX_MTU * 10 |
|
|
|
#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 |
|
|
|
#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 |
|
|
|
#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 |
|
|
|
#define ZT_STACK_SOCKET_WR_MAX 4096 |
|
|
|
|
|
|
|
|
|
|
|
|