updated apple osx_app_framework
This commit is contained in:
@@ -46,10 +46,10 @@
|
||||
|
||||
// IPV6 Related
|
||||
//#if defined(SDK_IPV6)
|
||||
#define LWIP_IPV6 1
|
||||
#define LWIP_IPV6 0
|
||||
//#endif
|
||||
//#if defined(SDK_IPV4)
|
||||
#define LWIP_IPV4 0
|
||||
#define LWIP_IPV4 1
|
||||
//#endif
|
||||
|
||||
#define IP6_DEBUG 1
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
17
make-mac.mk
17
make-mac.mk
@@ -109,17 +109,16 @@ all: one osx ios android lwip check
|
||||
|
||||
# --- EXTERNAL LIBRARIES ---
|
||||
lwip:
|
||||
ifeq ($(LWIP_VERSION_2),1)
|
||||
mv ext/lwip_2.0.0 ext/lwip
|
||||
-make -f make-liblwip200.mk $(LWIP_FLAGS)
|
||||
mv ext/lwip ext/lwip_2.0.0
|
||||
else
|
||||
mv ext/lwip_1.4.1 ext/lwip
|
||||
-make -f make-liblwip141.mk $(LWIP_FLAGS)
|
||||
mv ext/lwip ext/lwip_1.4.1
|
||||
endif
|
||||
-make -f make-liblwip.mk $(LWIP_FLAGS)
|
||||
|
||||
pico:
|
||||
mkdir -p build
|
||||
cd ext/picotcp; make lib ARCH=shared IPV4=1 IPV6=1
|
||||
$(CC) -g -nostartfiles -shared -o ext/picotcp/build/lib/libpicotcp.so ext/picotcp/build/lib/*.o ext/picotcp/build/modules/*.o
|
||||
cp ext/picotcp/build/lib/libpicotcp.so build/libpicotcp.so
|
||||
|
||||
jip:
|
||||
-make -f make-jip.mk $(JIP_FLAGS)
|
||||
|
||||
# ------- IOS / OSX --------
|
||||
# Build all Apple targets
|
||||
|
||||
@@ -88,6 +88,8 @@ namespace ZeroTier {
|
||||
---------- This section represents the "driver" for the picoTCP stack ----------
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#if defined(SDK_PICOTCP)
|
||||
|
||||
// Reference to the tap interface
|
||||
// This is needed due to the fact that there's a lot going on in the tap interface
|
||||
// that needs to be updated on each of the network stack's callbacks and not every
|
||||
@@ -617,6 +619,7 @@ namespace ZeroTier {
|
||||
}
|
||||
DEBUG_ERROR("invalid connection or pico_socket");
|
||||
}
|
||||
#endif // SDK_PICOTCP
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
@@ -822,12 +825,12 @@ void NetconEthernetTap::jip_init_interface(const InetAddress &ip)
|
||||
|
||||
bool NetconEthernetTap::addIp(const InetAddress &ip)
|
||||
{
|
||||
picotap = this;
|
||||
// SIP-1
|
||||
// Initialize network stack's interface, assign addresses
|
||||
#if defined(SDK_LWIP)
|
||||
lwIP_init_interface(ip);
|
||||
#elif defined(SDK_PICOTCP)
|
||||
picotap = this;
|
||||
pico_init_interface(this, ip);
|
||||
#elif defined(SDK_JIP)
|
||||
jip_init_interface(ip);
|
||||
@@ -1747,7 +1750,6 @@ void NetconEthernetTap::handleBind(PhySocket *sock, PhySocket *rpcSock, void **u
|
||||
|
||||
// ipv4
|
||||
#if defined(SDK_IPV4)
|
||||
//ip4_addr_t ba;
|
||||
if(addr->sa_family == AF_INET) {
|
||||
struct sockaddr_in *connaddr = (struct sockaddr_in *)addr;
|
||||
inet_ntop(AF_INET, &(connaddr->sin_addr), addrstr, INET_ADDRSTRLEN);
|
||||
@@ -1757,10 +1759,8 @@ void NetconEthernetTap::handleBind(PhySocket *sock, PhySocket *rpcSock, void **u
|
||||
|
||||
// ipv6
|
||||
#if defined(SDK_IPV6)
|
||||
//ip6_addr_t ba;
|
||||
struct sockaddr_in6 *in6 = (struct sockaddr_in6*)&bind_rpc->addr;
|
||||
in6_to_ip6((ip6_addr *)&ba, in6);
|
||||
|
||||
if(addr->sa_family == AF_INET6) {
|
||||
struct sockaddr_in6 *connaddr6 = (struct sockaddr_in6 *)addr;
|
||||
inet_ntop(AF_INET6, &(connaddr6->sin6_addr), addrstr, INET6_ADDRSTRLEN);
|
||||
@@ -1942,8 +1942,9 @@ Connection * NetconEthernetTap::handleSocket(PhySocket *sock, void **uptr, struc
|
||||
}
|
||||
DEBUG_ERROR(" memory not available for new PCB");
|
||||
sendReturnValue(_phy.getDescriptor(sock), -1, ENOMEM);
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int NetconEthernetTap::handleConnectProxy(PhySocket *sock, struct sockaddr_in *rawAddr)
|
||||
@@ -2064,7 +2065,6 @@ void NetconEthernetTap::handleConnect(PhySocket *sock, PhySocket *rpcSock, Conne
|
||||
|
||||
// ipv4
|
||||
#if defined(SDK_IPV4)
|
||||
//ip4_addr_t ba;
|
||||
if(addr->sa_family == AF_INET) {
|
||||
struct sockaddr_in *connaddr = (struct sockaddr_in *)addr;
|
||||
inet_ntop(AF_INET, &(connaddr->sin_addr), addrstr, INET_ADDRSTRLEN);
|
||||
@@ -2074,7 +2074,6 @@ void NetconEthernetTap::handleConnect(PhySocket *sock, PhySocket *rpcSock, Conne
|
||||
|
||||
// ipv6
|
||||
#if defined(SDK_IPV6)
|
||||
//ip6_addr_t ba;
|
||||
struct sockaddr_in6 *in6 = (struct sockaddr_in6*)&connect_rpc->addr;
|
||||
in6_to_ip6((ip6_addr *)&ba, in6);
|
||||
|
||||
|
||||
@@ -49,11 +49,12 @@
|
||||
#include "SDK_defs.h"
|
||||
#include "SDK_RPC.h"
|
||||
#include "SDK_lwIP.hpp"
|
||||
#include "SDK_picoTCP.hpp"
|
||||
#include "SDK_jip.hpp"
|
||||
|
||||
#if defined(SDK_PICOTCP)
|
||||
#include "SDK_picoTCP.hpp"
|
||||
#include "pico_protocol.h"
|
||||
|
||||
#endif
|
||||
|
||||
// lwIP structs
|
||||
struct tcp_pcb;
|
||||
@@ -174,11 +175,13 @@ namespace ZeroTier {
|
||||
jip_stack *jipstack;
|
||||
|
||||
// picoTCP
|
||||
#if defined(SDK_PICOTCP)
|
||||
struct pico_device picodev;
|
||||
unsigned char pico_frame_rxbuf[MAX_PICO_FRAME_RX_BUF_SZ];
|
||||
int pico_frame_rxbuf_tot = 0;
|
||||
Mutex _pico_frame_rxbuf_m;
|
||||
picoTCP_stack *picostack;
|
||||
#endif
|
||||
|
||||
// LWIP callbacks
|
||||
// NOTE: these are called from within LWIP, meaning that lwipstack->_lock is ALREADY
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/socket.h>
|
||||
//#include <sys/socket.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include "SDK.h"
|
||||
@@ -53,8 +53,6 @@
|
||||
int (*realsocket)(SOCKET_SIG);
|
||||
int (*realconnect)(CONNECT_SIG);
|
||||
|
||||
void dwr(int level, const char *fmt, ... );
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -472,7 +472,7 @@ void *zts_start_core_service(void *thread_id) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
DEBUG_ERROR(stderr, "homeDir is empty, could not construct path");
|
||||
DEBUG_ERROR("homeDir is empty, could not construct path");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/init.h"
|
||||
#include "lwip/udp.h"
|
||||
#include "lwip/tcp.h"
|
||||
|
||||
#include "Mutex.hpp"
|
||||
#include "OSUtils.hpp"
|
||||
@@ -55,7 +56,6 @@ struct tcp_pcb;
|
||||
#define PBUF_ALLOC_SIG pbuf_layer layer, u16_t length, pbuf_type type
|
||||
#define LWIP_HTONS_SIG u16_t x
|
||||
#define LWIP_NTOHS_SIG u16_t x
|
||||
#define IPADDR_NTOA_SIG const ip_addr_t *addr
|
||||
|
||||
// lwIP UDP API
|
||||
#define UDP_NEW_SIG void
|
||||
@@ -90,7 +90,6 @@ struct tcp_pcb;
|
||||
|
||||
// lwIP network stack interfaces
|
||||
#define NETIF_IP6_ADDR_SET_STATE_SIG struct netif* netif, s8_t addr_idx, u8_t state
|
||||
#define NETIF_LOOPIF_INIT_SIG struct netif *netif
|
||||
#define NETIF_CREATE_IP6_LINKLOCAL_ADDRESS_SIG struct netif *netif, u8_t from_mac_48bit
|
||||
#define ETHERNET_INPUT_SIG struct pbuf *p, struct netif *netif
|
||||
#define IP_INPUT_SIG struct pbuf *p, struct netif *inp
|
||||
@@ -148,7 +147,6 @@ namespace ZeroTier {
|
||||
#endif
|
||||
|
||||
void (*_netif_init)(void);
|
||||
void (*_netif_loopif_init)(NETIF_LOOPIF_INIT_SIG);
|
||||
// void (*_netif_set_addr)(NETIF_SET_ADDR_SIG);
|
||||
|
||||
void (*_lwip_init)();
|
||||
@@ -185,7 +183,6 @@ namespace ZeroTier {
|
||||
struct pbuf * (*_pbuf_alloc)(PBUF_ALLOC_SIG);
|
||||
u16_t (*_lwip_htons)(LWIP_HTONS_SIG);
|
||||
u16_t (*_lwip_ntohs)(LWIP_NTOHS_SIG);
|
||||
char* (*_ipaddr_ntoa)(IPADDR_NTOA_SIG);
|
||||
err_t (*_ethernet_input)(ETHERNET_INPUT_SIG);
|
||||
void (*_tcp_input)(TCP_INPUT_SIG);
|
||||
err_t (*_ip_input)(IP_INPUT_SIG);
|
||||
@@ -225,8 +222,6 @@ namespace ZeroTier {
|
||||
#ifdef __STATIC_LWIP__ // Set static references (for use in iOS)
|
||||
|
||||
_netif_init = (void(*)(void))&netif_init;
|
||||
_netif_loopif_init = (void(*)(NETIF_LOOPIF_INIT_SIG))&netif_loopif_init;
|
||||
|
||||
_ethernet_input = (err_t(*)(ETHERNET_INPUT_SIG))ðernet_input;
|
||||
_lwip_init = (void(*)(void))&lwip_init;
|
||||
_tcp_write = (err_t(*)(TCP_WRITE_SIG))&tcp_write;
|
||||
@@ -259,7 +254,6 @@ namespace ZeroTier {
|
||||
_pbuf_alloc = (struct pbuf*(*)(PBUF_ALLOC_SIG))&pbuf_alloc;
|
||||
_lwip_htons = (u16_t(*)(LWIP_HTONS_SIG))&lwip_htons;
|
||||
_lwip_ntohs = (u16_t(*)(LWIP_NTOHS_SIG))&lwip_ntohs;
|
||||
_ipaddr_ntoa = (char*(*)(IPADDR_NTOA_SIG))&ipaddr_ntoa;
|
||||
_tcp_input = (void(*)(TCP_INPUT_SIG))&tcp_input;
|
||||
_ip_input = (err_t(*)(IP_INPUT_SIG))&ip_input;
|
||||
_netif_set_default = (void(*)(NETIF_SET_DEFAULT_SIG))&netif_set_default;
|
||||
@@ -284,9 +278,6 @@ namespace ZeroTier {
|
||||
if(_libref == NULL)
|
||||
DEBUG_ERROR("dlerror(): %s", dlerror());
|
||||
|
||||
_netif_init = (void(*)(void))dlsym(_libref, "netif_init");
|
||||
_netif_loopif_init = (void(*)(NETIF_LOOPIF_INIT_SIG))dlsym(_libref, "netif_loopif_init");
|
||||
|
||||
#if defined(SDK_IPV4)
|
||||
_etharp_output = (err_t(*)(ETHARP_OUTPUT_SIG))dlsym(_libref, "etharp_output");
|
||||
#endif
|
||||
@@ -298,6 +289,7 @@ namespace ZeroTier {
|
||||
_ethip6_output = (err_t(*)(ETHIP6_OUTPUT_SIG))dlsym(_libref, "ethip6_output");
|
||||
#endif
|
||||
|
||||
_netif_init = (void(*)(void))dlsym(_libref, "netif_init");
|
||||
// _netif_set_addr = (void(*))(NETIF_SET_ADDR_SIG))dlsym(_libref, "netif_set_addr");
|
||||
|
||||
_ethernet_input = (err_t(*)(ETHERNET_INPUT_SIG))dlsym(_libref, "ethernet_input");
|
||||
@@ -334,7 +326,6 @@ namespace ZeroTier {
|
||||
_pbuf_alloc = (struct pbuf*(*)(PBUF_ALLOC_SIG))dlsym(_libref, "pbuf_alloc");
|
||||
_lwip_htons = (u16_t(*)(LWIP_HTONS_SIG))dlsym(_libref, "lwip_htons");
|
||||
_lwip_ntohs = (u16_t(*)(LWIP_NTOHS_SIG))dlsym(_libref, "lwip_ntohs");
|
||||
_ipaddr_ntoa = (char*(*)(IPADDR_NTOA_SIG))dlsym(_libref, "ipaddr_ntoa");
|
||||
_tcp_input = (void(*)(TCP_INPUT_SIG))dlsym(_libref, "tcp_input");
|
||||
_ip_input = (err_t(*)(IP_INPUT_SIG))dlsym(_libref, "ip_input");
|
||||
_netif_set_default = (void(*)(NETIF_SET_DEFAULT_SIG))dlsym(_libref, "netif_set_default");
|
||||
@@ -350,7 +341,6 @@ namespace ZeroTier {
|
||||
}
|
||||
|
||||
inline void __netif_init(void) throw() { Mutex::Lock _l(_lock); _netif_init(); }
|
||||
inline void __netif_loopif_init(NETIF_LOOPIF_INIT_SIG) throw() { DEBUG_STACK(); Mutex::Lock _l(_lock); _netif_loopif_init(netif); }
|
||||
// inline void __netif_set_addr(NETIF_SET_ADDR_SIG) throw() { Mutex::Lock _l(_lock); _netif_set_addr(netif, ipaddr, netmask, gw); }
|
||||
|
||||
inline void __lwip_init() throw() { DEBUG_STACK(); Mutex::Lock _l(_lock); return _lwip_init(); }
|
||||
@@ -386,7 +376,6 @@ namespace ZeroTier {
|
||||
inline struct pbuf * __pbuf_alloc(PBUF_ALLOC_SIG) throw() { /*DEBUG_STACK();*/ Mutex::Lock _l(_lock_mem); return _pbuf_alloc(layer,length,type); }
|
||||
inline u16_t __lwip_htons(LWIP_HTONS_SIG) throw() { DEBUG_STACK(); Mutex::Lock _l(_lock); return _lwip_htons(x); }
|
||||
inline u16_t __lwip_ntohs(LWIP_NTOHS_SIG) throw() { DEBUG_STACK(); Mutex::Lock _l(_lock); return _lwip_ntohs(x); }
|
||||
inline char* __ipaddr_ntoa(IPADDR_NTOA_SIG) throw() { DEBUG_STACK(); Mutex::Lock _l(_lock); return _ipaddr_ntoa(addr); }
|
||||
|
||||
//inline err_t __etharp_output(ETHARP_OUTPUT_SIG) throw() { Mutex::Lock _l(_lock); return _etharp_output(netif,q,ipaddr); }
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#ifndef SDK_PICOSTACK_H
|
||||
#define SDK_PICOSTACK_H
|
||||
|
||||
#if defined(SDK_PICOTCP)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <dlfcn.h>
|
||||
@@ -126,11 +127,9 @@ namespace ZeroTier {
|
||||
int (*_pico_socket_write)(PICO_SOCKET_WRITE_SIG);
|
||||
int (*_pico_socket_close)(PICO_SOCKET_CLOSE_SIG);
|
||||
int (*_pico_socket_shutdown)(PICO_SOCKET_SHUTDOWN_SIG);
|
||||
|
||||
struct pico_socket *(*_pico_socket_accept)(PICO_SOCKET_ACCEPT_SIG);
|
||||
|
||||
int (*_pico_ipv6_link_add)(PICO_IPV6_LINK_ADD_SIG);
|
||||
pico_err_t (*_get_pico_err)(void);
|
||||
//pico_err_t (*_get_pico_err)(void);
|
||||
|
||||
Mutex _lock;
|
||||
Mutex _lock_mem;
|
||||
@@ -165,7 +164,7 @@ namespace ZeroTier {
|
||||
// SIP-
|
||||
_pico_stack_init = (void(*)(void))&pico_stack_init;
|
||||
_pico_stack_tick = (void(*)(void))&pico_stack_tick;
|
||||
_pico_tap_create = (struct pico_device*(*)(PICO_TAP_CREATE_SIG)&pico_tap_create;
|
||||
_pico_tap_create = (struct pico_device*(*)(PICO_TAP_CREATE_SIG))&pico_tap_create;
|
||||
_pico_string_to_ipv4 = (int(*)(PICO_STRING_TO_IPV4_SIG))&pico_string_to_ipv4;
|
||||
_pico_ipv4_to_string = (int(*)(PICO_IPV4_TO_STRING_SIG))&pico_ipv4_to_string;
|
||||
_pico_ipv4_link_add = (int(*)(PICO_IPV4_LINK_ADD_SIG))&pico_ipv4_link_add;
|
||||
@@ -185,13 +184,9 @@ namespace ZeroTier {
|
||||
_pico_socket_write = (int(*)(PICO_SOCKET_WRITE_SIG))&pico_socket_write;
|
||||
_pico_socket_close = (int(*)(PICO_SOCKET_CLOSE_SIG))&pico_socket_close;
|
||||
_pico_socket_shutdown = (int(*)(PICO_SOCKET_SHUTDOWN_SIG))&pico_socket_shutdown;
|
||||
|
||||
pico_socket_accept = (struct pico_socket*(*)(PICO_SOCKET_ACCEPT_SIG))&pico_socket_accept;
|
||||
|
||||
|
||||
_pico_socket_accept = (struct pico_socket*(*)(PICO_SOCKET_ACCEPT_SIG))&pico_socket_accept;
|
||||
_pico_ipv6_link_add = (int(*)(PICO_IPV6_LINK_ADD_SIG))&pico_ipv6_link_add;
|
||||
|
||||
_get_pico_err = (pico_err_t(*)())&get_pico_err;
|
||||
//_get_pico_err = (pico_err_t(*)())&get_pico_err;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -226,7 +221,7 @@ namespace ZeroTier {
|
||||
_pico_socket_accept = (struct pico_socket*(*)(PICO_SOCKET_ACCEPT_SIG))dlsym(_libref, "pico_socket_accept");
|
||||
_pico_ipv6_link_add = (int(*)(PICO_IPV6_LINK_ADD_SIG))dlsym(_libref, "pico_ipv6_link_add");
|
||||
|
||||
_get_pico_err = (pico_err_t(*)())dlsym(_libref, "get_pico_err");
|
||||
//_get_pico_err = (pico_err_t(*)())dlsym(_libref, "get_pico_err");
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -262,9 +257,11 @@ namespace ZeroTier {
|
||||
inline int __pico_socket_shutdown(PICO_SOCKET_SHUTDOWN_SIG) throw() { DEBUG_STACK(); Mutex::Lock _l(_lock); return _pico_socket_shutdown(s, mode); }
|
||||
inline struct pico_socket * __pico_socket_accept(PICO_SOCKET_ACCEPT_SIG) throw() { DEBUG_STACK(); /*Mutex::Lock _l(_lock);*/ return _pico_socket_accept(s, orig, port); }
|
||||
inline int __pico_ipv6_link_add(PICO_IPV6_LINK_ADD_SIG) throw() { DEBUG_STACK(); Mutex::Lock _l(_lock); return _pico_ipv6_link_add(dev, address, netmask); }
|
||||
inline pico_err_t __get_pico_err(void) throw() { DEBUG_STACK(); Mutex::Lock _l(_lock); return _get_pico_err(); }
|
||||
//inline pico_err_t __get_pico_err(void) throw() { DEBUG_STACK(); Mutex::Lock _l(_lock); return _get_pico_err(); }
|
||||
};
|
||||
|
||||
} // namespace ZeroTier
|
||||
|
||||
#endif
|
||||
|
||||
#endif // SDK_PICOTCP
|
||||
|
||||
Reference in New Issue
Block a user