Merge branch 'master' into dev

This commit is contained in:
Joseph Henry
2017-10-10 14:22:13 -07:00
32 changed files with 565 additions and 283 deletions

View File

@@ -35,26 +35,41 @@ endif
OSTYPE=$(shell uname -s | tr '[A-Z]' '[a-z]') OSTYPE=$(shell uname -s | tr '[A-Z]' '[a-z]')
BUILD=build/$(OSTYPE) BUILD=build/$(OSTYPE)
LWIPCONTRIBDIR=ext/lwip-contrib
# Windows
ifeq ($(OSTYPE),mingw32_nt-6.2)
ARTOOL=ar
ARFLAGS=rcs
CC=gcc
CXX=g++
CXXFLAGS+=-Wno-unknown-pragmas -Wno-pointer-arith -Wno-deprecated-declarations -Wno-conversion-null
WINDEFS=-lws2_32 -lshlwapi -liphlpapi -static -static-libgcc -static-libstdc++
LWIPARCHINCLUDE=$(LWIPCONTRIBDIR)/ports/win32/include
endif
# Darwin # Darwin
ifeq ($(OSTYPE),darwin) ifeq ($(OSTYPE),darwin)
ARTOOL=libtool ARTOOL=libtool
ARFLAGS=-static ARFLAGS=-static
LWIPARCHINCLUDE=$(LWIPCONTRIBDIR)/ports/unix/include
endif endif
# Linux # Linux
ifeq ($(OSTYPE),linux) ifeq ($(OSTYPE),linux)
ARTOOL=ar ARTOOL=ar
ARFLAGS=rcs ARFLAGS=rcs
LWIPARCHINCLUDE=$(LWIPCONTRIBDIR)/ports/unix/include
endif endif
# FreeBSD # FreeBSD
ifeq ($(OSTYPE),freebsd) ifeq ($(OSTYPE),freebsd)
ARTOOL=ar ARTOOL=ar
ARFLAGS=rcs ARFLAGS=rcs
LWIPARCHINCLUDE=$(LWIPCONTRIBDIR)/ports/unix/include
endif endif
# OpenBSD # OpenBSD
ifeq ($(OSTYPE),openbsd) ifeq ($(OSTYPE),openbsd)
ARTOOL=ar ARTOOL=ar
ARFLAGS=rcs ARFLAGS=rcs
LWIPARCHINCLUDE=$(LWIPCONTRIBDIR)/ports/unix/include
endif endif
############################################################################## ##############################################################################
@@ -147,7 +162,7 @@ ifeq ($(SDK_JNI), 1)
LIBZT_DEFS+=-DSDK_JNI LIBZT_DEFS+=-DSDK_JNI
endif endif
CXXFLAGS=$(CFLAGS) -Wno-format -fno-rtti -std=c++11 CXXFLAGS+=$(CFLAGS) -Wno-format -fno-rtti -std=c++11
ZT_DEFS+=-DZT_SDK -DZT_SOFTWARE_UPDATE_DEFAULT="\"disable\"" ZT_DEFS+=-DZT_SDK -DZT_SOFTWARE_UPDATE_DEFAULT="\"disable\""
LIBZT_FILES:=src/VirtualTap.cpp src/libzt.cpp src/Utilities.cpp LIBZT_FILES:=src/VirtualTap.cpp src/libzt.cpp src/Utilities.cpp
STATIC_LIB=$(BUILD)/libzt.a STATIC_LIB=$(BUILD)/libzt.a
@@ -211,9 +226,8 @@ endif
STACK_DRIVER_DEFS+=-DLWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS STACK_DRIVER_DEFS+=-DLWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
STACK_DRIVER_DEFS+=-DSTACK_LWIP STACK_DRIVER_DEFS+=-DSTACK_LWIP
STACK_DRIVER_FILES:=src/lwIP.cpp STACK_DRIVER_FILES:=src/lwIP.cpp
LWIPARCH=$(CONTRIBDIR)/ports/unix
LWIPDIR=ext/lwip/src LWIPDIR=ext/lwip/src
STACK_INCLUDES+=-Iext/lwip/src/include/lwip \ STACK_INCLUDES+=-I$(LWIPARCHINCLUDE) -Iext/lwip/src/include/lwip \
-I$(LWIPDIR)/include \ -I$(LWIPDIR)/include \
-I$(LWIPARCH)/include \ -I$(LWIPARCH)/include \
-I$(LWIPDIR)/include/ipv4 \ -I$(LWIPDIR)/include/ipv4 \
@@ -349,7 +363,7 @@ nativetest:
@date +"Build script finished on %F %T" @date +"Build script finished on %F %T"
ztproxy: ztproxy:
$(CXX) $(CXXFLAGS) $(SANFLAGS) $(LIBZT_INCLUDES) $(LIBZT_DEFS) $(ZT_INCLUDES) \ $(CXX) $(CXXFLAGS) $(SANFLAGS) $(LIBZT_INCLUDES) $(LIBZT_DEFS) $(ZT_INCLUDES) \
examples/ztproxy/ztproxy.cpp -o $(BUILD)/ztproxy $< -L$(BUILD) -lzt examples/ztproxy/ztproxy.cpp -o $(BUILD)/ztproxy $< -L$(BUILD) -lzt $(WINDEFS)
@./check.sh $(BUILD)/ztproxy @./check.sh $(BUILD)/ztproxy
@date +"Build script finished on %F %T" @date +"Build script finished on %F %T"
intercept: intercept:

View File

@@ -26,12 +26,17 @@
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <netdb.h>
#if defined(__linux__) || defined(__APPLE__)
#include <netdb.h>
#endif
//#include "Winsock2.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string> #include <string>
#include <fcntl.h> #include <fcntl.h>
#include <regex.h>
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
@@ -39,6 +44,7 @@
#include "RingBuffer.hpp" #include "RingBuffer.hpp"
#include "ztproxy.hpp" #include "ztproxy.hpp"
#include "Utilities.h"
#include "libzt.h" #include "libzt.h"
namespace ZeroTier { namespace ZeroTier {
@@ -57,10 +63,6 @@ namespace ZeroTier {
_dns_nameserver(dns_nameserver), _dns_nameserver(dns_nameserver),
_phy(this,false,true) _phy(this,false,true)
{ {
// Start ZeroTier Node
// Join Network which contains resources we need to proxy
DEBUG_INFO("waiting for libzt to come online");
zts_simple_start(path.c_str(), nwid.c_str());
// Set up TCP listen sockets // Set up TCP listen sockets
// IPv4 // IPv4
struct sockaddr_in in4; struct sockaddr_in in4;
@@ -69,7 +71,11 @@ namespace ZeroTier {
in4.sin_addr.s_addr = Utils::hton((uint32_t)(0x7f000001)); // listen for TCP @127.0.0.1 in4.sin_addr.s_addr = Utils::hton((uint32_t)(0x7f000001)); // listen for TCP @127.0.0.1
in4.sin_port = Utils::hton((uint16_t)proxy_listen_port); in4.sin_port = Utils::hton((uint16_t)proxy_listen_port);
_tcpListenSocket = _phy.tcpListen((const struct sockaddr *)&in4,this); _tcpListenSocket = _phy.tcpListen((const struct sockaddr *)&in4,this);
if (!_tcpListenSocket) {
DEBUG_ERROR("Error binding on port %d for IPv4 HTTP listen socket", proxy_listen_port);
}
// IPv6 // IPv6
/*
struct sockaddr_in6 in6; struct sockaddr_in6 in6;
memset((void *)&in6,0,sizeof(in6)); memset((void *)&in6,0,sizeof(in6));
in6.sin6_family = AF_INET6; in6.sin6_family = AF_INET6;
@@ -77,13 +83,12 @@ namespace ZeroTier {
in6.sin6_addr.s6_addr[15] = 1; // IPv6 localhost == ::1 in6.sin6_addr.s6_addr[15] = 1; // IPv6 localhost == ::1
in6.sin6_port = Utils::hton((uint16_t)proxy_listen_port); in6.sin6_port = Utils::hton((uint16_t)proxy_listen_port);
_tcpListenSocket6 = _phy.tcpListen((const struct sockaddr *)&in6,this); _tcpListenSocket6 = _phy.tcpListen((const struct sockaddr *)&in6,this);
*/
if (!_tcpListenSocket) { /*
DEBUG_ERROR("Error binding on port %d for IPv4 HTTP listen socket", proxy_listen_port);
}
if (!_tcpListenSocket6) { if (!_tcpListenSocket6) {
DEBUG_ERROR("Error binding on port %d for IPv6 HTTP listen socket", proxy_listen_port); DEBUG_ERROR("Error binding on port %d for IPv6 HTTP listen socket", proxy_listen_port);
} }
*/
_thread = Thread::start(this); _thread = Thread::start(this);
} }
@@ -117,14 +122,14 @@ namespace ZeroTier {
// Moves data between client application socket and libzt VirtualSocket // Moves data between client application socket and libzt VirtualSocket
while(_run) { while(_run) {
_phy.poll(5); _phy.poll(1);
conn_m.lock(); conn_m.lock();
// build fd_sets to select upon // build fd_sets to select upon
FD_ZERO(&read_set); FD_ZERO(&read_set);
FD_ZERO(&write_set); FD_ZERO(&write_set);
nfds = 0; nfds = 0;
for (int i=0; i<clist.size(); i++) { for (size_t i=0; i<clist.size(); i++) {
FD_SET(clist[i]->zfd, &read_set); FD_SET(clist[i]->zfd, &read_set);
FD_SET(clist[i]->zfd, &write_set); FD_SET(clist[i]->zfd, &write_set);
nfds = clist[i]->zfd > nfds ? clist[i]->zfd : nfds; nfds = clist[i]->zfd > nfds ? clist[i]->zfd : nfds;
@@ -212,7 +217,6 @@ namespace ZeroTier {
exit(0); exit(0);
} }
if (conn->zfd < 0) { // no connection yet if (conn->zfd < 0) { // no connection yet
DEBUG_INFO("no connection yet, will establish...");
if (host == "") { if (host == "") {
DEBUG_ERROR("invalid hostname or address (empty)"); DEBUG_ERROR("invalid hostname or address (empty)");
return; return;
@@ -256,6 +260,7 @@ namespace ZeroTier {
} }
if (ipv == 6) { if (ipv == 6) {
//DEBUG_INFO("attempting to proxy [0.0.0.0:%d -> %s:%d]", _proxy_listen_port, host.c_str(), dest_port); //DEBUG_INFO("attempting to proxy [0.0.0.0:%d -> %s:%d]", _proxy_listen_port, host.c_str(), dest_port);
/*
struct sockaddr_in6 in6; struct sockaddr_in6 in6;
memset(&in6,0,sizeof(in6)); memset(&in6,0,sizeof(in6));
in6.sin6_family = AF_INET; in6.sin6_family = AF_INET;
@@ -265,6 +270,7 @@ namespace ZeroTier {
in6.sin6_port = Utils::hton(dest_port); in6.sin6_port = Utils::hton(dest_port);
zfd = zts_socket(AF_INET, SOCK_STREAM, 0); zfd = zts_socket(AF_INET, SOCK_STREAM, 0);
err = zts_connect(zfd, (const struct sockaddr *)&in6, sizeof(in6)); err = zts_connect(zfd, (const struct sockaddr *)&in6, sizeof(in6));
*/
} }
if (zfd < 0 || err < 0) { if (zfd < 0 || err < 0) {
// now release TX buffer contents we previously saved, since we can't connect // now release TX buffer contents we previously saved, since we can't connect
@@ -287,9 +293,6 @@ namespace ZeroTier {
zmap[zfd] = conn; zmap[zfd] = conn;
conn_m.unlock(); conn_m.unlock();
} }
else {
DEBUG_INFO("connection already established, reusing...");
}
// Write data coming from client TCP connection to its TX buffer, later emptied into libzt by threadMain I/O loop // Write data coming from client TCP connection to its TX buffer, later emptied into libzt by threadMain I/O loop
conn->tx_m.lock(); conn->tx_m.lock();
if ((wr = conn->TXbuf->write((const unsigned char *)data, len)) < 0) { if ((wr = conn->TXbuf->write((const unsigned char *)data, len)) < 0) {
@@ -321,7 +324,7 @@ namespace ZeroTier {
zts_close(conn->zfd); zts_close(conn->zfd);
} }
cmap.erase(sock); cmap.erase(sock);
for (int i=0; i<clist.size(); i++) { for (size_t i=0; i<clist.size(); i++) {
if (conn == clist[i]) { if (conn == clist[i]) {
clist.erase(clist.begin()+i); clist.erase(clist.begin()+i);
break; break;
@@ -371,7 +374,12 @@ int main(int argc, char **argv)
std::string nwid = argv[3]; std::string nwid = argv[3];
std::string internal_addr = argv[4]; std::string internal_addr = argv[4];
int internal_port = atoi(argv[5]); int internal_port = atoi(argv[5]);
std::string dns_nameserver= argv[6]; std::string dns_nameserver= "";//argv[6];
// Start ZeroTier Node
// Join Network which contains resources we need to proxy
DEBUG_INFO("waiting for libzt to come online");
zts_simple_start(path.c_str(), nwid.c_str());
ZeroTier::ZTProxy *proxy = new ZeroTier::ZTProxy(proxy_listen_port, nwid, path, internal_addr, internal_port, dns_nameserver); ZeroTier::ZTProxy *proxy = new ZeroTier::ZTProxy(proxy_listen_port, nwid, path, internal_addr, internal_port, dns_nameserver);

View File

@@ -34,10 +34,13 @@
#include "Phy.hpp" #include "Phy.hpp"
#include "OSUtils.hpp" #include "OSUtils.hpp"
#if defined(__linux__) || defined(__APPLE__)
#include <sys/select.h>
#endif
#include <queue> #include <queue>
#include <vector> #include <vector>
#include <stdio.h> #include <stdio.h>
#include <sys/select.h>
#define BUF_SZ 1024*1024 #define BUF_SZ 1024*1024

View File

@@ -39,7 +39,7 @@
#pragma warning (disable: 4820) /* 'x' bytes padding added after data member 'y' */ #pragma warning (disable: 4820) /* 'x' bytes padding added after data member 'y' */
#endif #endif
#define LWIP_PROVIDE_ERRNO #define LWIP_PROVIDE_ERRNO 0
/* Define platform endianness (might already be defined) */ /* Define platform endianness (might already be defined) */
#ifndef BYTE_ORDER #ifndef BYTE_ORDER

View File

@@ -40,7 +40,7 @@
#include "lwip/def.h" #include "lwip/def.h"
#include "lwip/sys.h" #include "lwip/sys.h"
#include "lwip/errno.h" #include "errno.h"
#if !NO_SYS #if !NO_SYS
/** Table to quickly map an lwIP error (err_t) to a socket error /** Table to quickly map an lwIP error (err_t) to a socket error

View File

@@ -658,10 +658,19 @@ lwip_connect(int s, const struct sockaddr *name, socklen_t namelen)
} }
LWIP_UNUSED_ARG(namelen); LWIP_UNUSED_ARG(namelen);
if (name->sa_family == AF_UNSPEC) {
if (
#ifdef __MINGW32__
false
#else
name->sa_family == AF_UNSPEC
#endif
)
{
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, AF_UNSPEC)\n", s)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, AF_UNSPEC)\n", s));
err = netconn_disconnect(sock->conn); err = netconn_disconnect(sock->conn);
} else { }
else {
ip_addr_t remote_addr; ip_addr_t remote_addr;
u16_t remote_port; u16_t remote_port;

View File

@@ -1,193 +1,193 @@
/** /**
* @file * @file
* Posix Errno defines * Posix Errno defines
*/ */
/* /*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science. * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, * 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products * 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE. * OF SUCH DAMAGE.
* *
* This file is part of the lwIP TCP/IP stack. * This file is part of the lwIP TCP/IP stack.
* *
* Author: Adam Dunkels <adam@sics.se> * Author: Adam Dunkels <adam@sics.se>
* *
*/ */
#ifndef LWIP_HDR_ERRNO_H #ifndef LWIP_HDR_ERRNO_H
#define LWIP_HDR_ERRNO_H #define LWIP_HDR_ERRNO_H
#include "lwip/opt.h" #include "lwip/opt.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifdef LWIP_PROVIDE_ERRNO #ifdef LWIP_PROVIDE_ERRNO
#define EPERM 1 /* Operation not permitted */ #define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */ #define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */ #define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */ #define EINTR 4 /* Interrupted system call */
#define EIO 5 /* I/O error */ #define EIO 5 /* I/O error */
#define ENXIO 6 /* No such device or address */ #define ENXIO 6 /* No such device or address */
#define E2BIG 7 /* Arg list too long */ #define E2BIG 7 /* Arg list too long */
#define ENOEXEC 8 /* Exec format error */ #define ENOEXEC 8 /* Exec format error */
#define EBADF 9 /* Bad file number */ #define EBADF 9 /* Bad file number */
#define ECHILD 10 /* No child processes */ #define ECHILD 10 /* No child processes */
#define EAGAIN 11 /* Try again */ #define EAGAIN 11 /* Try again */
#define ENOMEM 12 /* Out of memory */ #define ENOMEM 12 /* Out of memory */
#define EACCES 13 /* Permission denied */ #define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */ #define EFAULT 14 /* Bad address */
#define ENOTBLK 15 /* Block device required */ #define ENOTBLK 15 /* Block device required */
#define EBUSY 16 /* Device or resource busy */ #define EBUSY 16 /* Device or resource busy */
#define EEXIST 17 /* File exists */ #define EEXIST 17 /* File exists */
#define EXDEV 18 /* Cross-device link */ #define EXDEV 18 /* Cross-device link */
#define ENODEV 19 /* No such device */ #define ENODEV 19 /* No such device */
#define ENOTDIR 20 /* Not a directory */ #define ENOTDIR 20 /* Not a directory */
#define EISDIR 21 /* Is a directory */ #define EISDIR 21 /* Is a directory */
#define EINVAL 22 /* Invalid argument */ #define EINVAL 22 /* Invalid argument */
#define ENFILE 23 /* File table overflow */ #define ENFILE 23 /* File table overflow */
#define EMFILE 24 /* Too many open files */ #define EMFILE 24 /* Too many open files */
#define ENOTTY 25 /* Not a typewriter */ #define ENOTTY 25 /* Not a typewriter */
#define ETXTBSY 26 /* Text file busy */ #define ETXTBSY 26 /* Text file busy */
#define EFBIG 27 /* File too large */ #define EFBIG 27 /* File too large */
#define ENOSPC 28 /* No space left on device */ #define ENOSPC 28 /* No space left on device */
#define ESPIPE 29 /* Illegal seek */ #define ESPIPE 29 /* Illegal seek */
#define EROFS 30 /* Read-only file system */ #define EROFS 30 /* Read-only file system */
#define EMLINK 31 /* Too many links */ #define EMLINK 31 /* Too many links */
#define EPIPE 32 /* Broken pipe */ #define EPIPE 32 /* Broken pipe */
#define EDOM 33 /* Math argument out of domain of func */ #define EDOM 33 /* Math argument out of domain of func */
#define ERANGE 34 /* Math result not representable */ #define ERANGE 34 /* Math result not representable */
#define EDEADLK 35 /* Resource deadlock would occur */ #define EDEADLK 35 /* Resource deadlock would occur */
#define ENAMETOOLONG 36 /* File name too long */ #define ENAMETOOLONG 36 /* File name too long */
#define ENOLCK 37 /* No record locks available */ #define ENOLCK 37 /* No record locks available */
#define ENOSYS 38 /* Function not implemented */ #define ENOSYS 38 /* Function not implemented */
#define ENOTEMPTY 39 /* Directory not empty */ #define ENOTEMPTY 39 /* Directory not empty */
#define ELOOP 40 /* Too many symbolic links encountered */ #define ELOOP 40 /* Too many symbolic links encountered */
#define EWOULDBLOCK EAGAIN /* Operation would block */ #define EWOULDBLOCK EAGAIN /* Operation would block */
#define ENOMSG 42 /* No message of desired type */ #define ENOMSG 42 /* No message of desired type */
#define EIDRM 43 /* Identifier removed */ #define EIDRM 43 /* Identifier removed */
#define ECHRNG 44 /* Channel number out of range */ #define ECHRNG 44 /* Channel number out of range */
#define EL2NSYNC 45 /* Level 2 not synchronized */ #define EL2NSYNC 45 /* Level 2 not synchronized */
#define EL3HLT 46 /* Level 3 halted */ #define EL3HLT 46 /* Level 3 halted */
#define EL3RST 47 /* Level 3 reset */ #define EL3RST 47 /* Level 3 reset */
#define ELNRNG 48 /* Link number out of range */ #define ELNRNG 48 /* Link number out of range */
#define EUNATCH 49 /* Protocol driver not attached */ #define EUNATCH 49 /* Protocol driver not attached */
#define ENOCSI 50 /* No CSI structure available */ #define ENOCSI 50 /* No CSI structure available */
#define EL2HLT 51 /* Level 2 halted */ #define EL2HLT 51 /* Level 2 halted */
#define EBADE 52 /* Invalid exchange */ #define EBADE 52 /* Invalid exchange */
#define EBADR 53 /* Invalid request descriptor */ #define EBADR 53 /* Invalid request descriptor */
#define EXFULL 54 /* Exchange full */ #define EXFULL 54 /* Exchange full */
#define ENOANO 55 /* No anode */ #define ENOANO 55 /* No anode */
#define EBADRQC 56 /* Invalid request code */ #define EBADRQC 56 /* Invalid request code */
#define EBADSLT 57 /* Invalid slot */ #define EBADSLT 57 /* Invalid slot */
#define EDEADLOCK EDEADLK #define EDEADLOCK EDEADLK
#define EBFONT 59 /* Bad font file format */ #define EBFONT 59 /* Bad font file format */
#define ENOSTR 60 /* Device not a stream */ #define ENOSTR 60 /* Device not a stream */
#define ENODATA 61 /* No data available */ #define ENODATA 61 /* No data available */
#define ETIME 62 /* Timer expired */ #define ETIME 62 /* Timer expired */
#define ENOSR 63 /* Out of streams resources */ #define ENOSR 63 /* Out of streams resources */
#define ENONET 64 /* Machine is not on the network */ #define ENONET 64 /* Machine is not on the network */
#define ENOPKG 65 /* Package not installed */ #define ENOPKG 65 /* Package not installed */
#define EREMOTE 66 /* Object is remote */ #define EREMOTE 66 /* Object is remote */
#define ENOLINK 67 /* Link has been severed */ #define ENOLINK 67 /* Link has been severed */
#define EADV 68 /* Advertise error */ #define EADV 68 /* Advertise error */
#define ESRMNT 69 /* Srmount error */ #define ESRMNT 69 /* Srmount error */
#define ECOMM 70 /* Communication error on send */ #define ECOMM 70 /* Communication error on send */
#define EPROTO 71 /* Protocol error */ #define EPROTO 71 /* Protocol error */
#define EMULTIHOP 72 /* Multihop attempted */ #define EMULTIHOP 72 /* Multihop attempted */
#define EDOTDOT 73 /* RFS specific error */ #define EDOTDOT 73 /* RFS specific error */
#define EBADMSG 74 /* Not a data message */ #define EBADMSG 74 /* Not a data message */
#define EOVERFLOW 75 /* Value too large for defined data type */ #define EOVERFLOW 75 /* Value too large for defined data type */
#define ENOTUNIQ 76 /* Name not unique on network */ #define ENOTUNIQ 76 /* Name not unique on network */
#define EBADFD 77 /* File descriptor in bad state */ #define EBADFD 77 /* File descriptor in bad state */
#define EREMCHG 78 /* Remote address changed */ #define EREMCHG 78 /* Remote address changed */
#define ELIBACC 79 /* Can not access a needed shared library */ #define ELIBACC 79 /* Can not access a needed shared library */
#define ELIBBAD 80 /* Accessing a corrupted shared library */ #define ELIBBAD 80 /* Accessing a corrupted shared library */
#define ELIBSCN 81 /* .lib section in a.out corrupted */ #define ELIBSCN 81 /* .lib section in a.out corrupted */
#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ #define ELIBMAX 82 /* Attempting to link in too many shared libraries */
#define ELIBEXEC 83 /* Cannot exec a shared library directly */ #define ELIBEXEC 83 /* Cannot exec a shared library directly */
#define EILSEQ 84 /* Illegal byte sequence */ #define EILSEQ 84 /* Illegal byte sequence */
#define ERESTART 85 /* Interrupted system call should be restarted */ #define ERESTART 85 /* Interrupted system call should be restarted */
#define ESTRPIPE 86 /* Streams pipe error */ #define ESTRPIPE 86 /* Streams pipe error */
#define EUSERS 87 /* Too many users */ #define EUSERS 87 /* Too many users */
#define ENOTSOCK 88 /* Socket operation on non-socket */ #define ENOTSOCK 88 /* Socket operation on non-socket */
#define EDESTADDRREQ 89 /* Destination address required */ #define EDESTADDRREQ 89 /* Destination address required */
#define EMSGSIZE 90 /* Message too long */ #define EMSGSIZE 90 /* Message too long */
#define EPROTOTYPE 91 /* Protocol wrong type for socket */ #define EPROTOTYPE 91 /* Protocol wrong type for socket */
#define ENOPROTOOPT 92 /* Protocol not available */ #define ENOPROTOOPT 92 /* Protocol not available */
#define EPROTONOSUPPORT 93 /* Protocol not supported */ #define EPROTONOSUPPORT 93 /* Protocol not supported */
#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ #define ESOCKTNOSUPPORT 94 /* Socket type not supported */
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
#define EPFNOSUPPORT 96 /* Protocol family not supported */ #define EPFNOSUPPORT 96 /* Protocol family not supported */
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ #define EAFNOSUPPORT 97 /* Address family not supported by protocol */
#define EADDRINUSE 98 /* Address already in use */ #define EADDRINUSE 98 /* Address already in use */
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ #define EADDRNOTAVAIL 99 /* Cannot assign requested address */
#define ENETDOWN 100 /* Network is down */ #define ENETDOWN 100 /* Network is down */
#define ENETUNREACH 101 /* Network is unreachable */ #define ENETUNREACH 101 /* Network is unreachable */
#define ENETRESET 102 /* Network dropped connection because of reset */ #define ENETRESET 102 /* Network dropped connection because of reset */
#define ECONNABORTED 103 /* Software caused connection abort */ #define ECONNABORTED 103 /* Software caused connection abort */
#define ECONNRESET 104 /* Connection reset by peer */ #define ECONNRESET 104 /* Connection reset by peer */
#define ENOBUFS 105 /* No buffer space available */ #define ENOBUFS 105 /* No buffer space available */
#define EISCONN 106 /* Transport endpoint is already connected */ #define EISCONN 106 /* Transport endpoint is already connected */
#define ENOTCONN 107 /* Transport endpoint is not connected */ #define ENOTCONN 107 /* Transport endpoint is not connected */
#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
#define ETOOMANYREFS 109 /* Too many references: cannot splice */ #define ETOOMANYREFS 109 /* Too many references: cannot splice */
#define ETIMEDOUT 110 /* Connection timed out */ #define ETIMEDOUT 110 /* Connection timed out */
#define ECONNREFUSED 111 /* Connection refused */ #define ECONNREFUSED 111 /* Connection refused */
#define EHOSTDOWN 112 /* Host is down */ #define EHOSTDOWN 112 /* Host is down */
#define EHOSTUNREACH 113 /* No route to host */ #define EHOSTUNREACH 113 /* No route to host */
#define EALREADY 114 /* Operation already in progress */ #define EALREADY 114 /* Operation already in progress */
#define EINPROGRESS 115 /* Operation now in progress */ #define EINPROGRESS 115 /* Operation now in progress */
#define ESTALE 116 /* Stale NFS file handle */ #define ESTALE 116 /* Stale NFS file handle */
#define EUCLEAN 117 /* Structure needs cleaning */ #define EUCLEAN 117 /* Structure needs cleaning */
#define ENOTNAM 118 /* Not a XENIX named type file */ #define ENOTNAM 118 /* Not a XENIX named type file */
#define ENAVAIL 119 /* No XENIX semaphores available */ #define ENAVAIL 119 /* No XENIX semaphores available */
#define EISNAM 120 /* Is a named type file */ #define EISNAM 120 /* Is a named type file */
#define EREMOTEIO 121 /* Remote I/O error */ #define EREMOTEIO 121 /* Remote I/O error */
#define EDQUOT 122 /* Quota exceeded */ #define EDQUOT 122 /* Quota exceeded */
#define ENOMEDIUM 123 /* No medium found */ #define ENOMEDIUM 123 /* No medium found */
#define EMEDIUMTYPE 124 /* Wrong medium type */ #define EMEDIUMTYPE 124 /* Wrong medium type */
#ifndef errno #ifndef errno
extern int errno; extern int errno;
#endif #endif
#else /* LWIP_PROVIDE_ERRNO */ #else /* LWIP_PROVIDE_ERRNO */
/* Define LWIP_ERRNO_INCLUDE to <errno.h> to include the error defines here */ /* Define LWIP_ERRNO_INCLUDE to <errno.h> to include the error defines here */
#ifdef LWIP_ERRNO_INCLUDE #ifdef LWIP_ERRNO_INCLUDE
//#include //#include
#endif /* LWIP_ERRNO_INCLUDE */ #endif /* LWIP_ERRNO_INCLUDE */
#endif /* LWIP_PROVIDE_ERRNO */ #endif /* LWIP_PROVIDE_ERRNO */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* LWIP_HDR_ERRNO_H */ #endif /* LWIP_HDR_ERRNO_H */

View File

@@ -34,11 +34,14 @@
#define LIBZT_DEBUG_HPP #define LIBZT_DEBUG_HPP
#include <pthread.h> #include <pthread.h>
#include <sys/syscall.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <cstring> #include <cstring>
#if defined(__linux__)
#include <sys/syscall.h>
#endif
#include "Platform.h" #include "Platform.h"
#define ZT_MSG_ERROR true // Errors #define ZT_MSG_ERROR true // Errors
@@ -53,7 +56,7 @@
#if defined(__APPLE__) #if defined(__APPLE__)
#include "TargetConditionals.h" #include "TargetConditionals.h"
#endif #endif
#if defined(ZT_COLOR) && !defined(__ANDROID__) && !defined(TARGET_OS_IPHONE) && !defined(TARGET_IPHONE_SIMULATOR) && !defined(__APP_FRAMEWORK__) #if defined(ZT_COLOR) && !defined(__MINGW32__) && !defined(__ANDROID__) && !defined(TARGET_OS_IPHONE) && !defined(TARGET_IPHONE_SIMULATOR) && !defined(__APP_FRAMEWORK__)
#define ZT_RED "\x1B[31m" #define ZT_RED "\x1B[31m"
#define ZT_GRN "\x1B[32m" #define ZT_GRN "\x1B[32m"
#define ZT_YEL "\x1B[33m" #define ZT_YEL "\x1B[33m"
@@ -88,6 +91,9 @@ extern unsigned int gettid(); // defined in libzt.cpp
#elif __APPLE__ #elif __APPLE__
#define ZT_THREAD_ID (long)0//(long)gettid() #define ZT_THREAD_ID (long)0//(long)gettid()
#endif #endif
#ifdef __MINGW32__
#define ZT_THREAD_ID (long)0
#endif
#if defined(__JNI_LIB__) #if defined(__JNI_LIB__)
#include <jni.h> #include <jni.h>

View File

@@ -48,7 +48,9 @@
*/ */
#define ZTO_ID_LEN 16 #define ZTO_ID_LEN 16
#if !defined(__MINGW32__)
typedef uint32_t socklen_t; typedef uint32_t socklen_t;
#endif
/****************************************************************************/ /****************************************************************************/
/* For SOCK_RAW support, it will initially be modeled after linux's API, so */ /* For SOCK_RAW support, it will initially be modeled after linux's API, so */

View File

@@ -35,6 +35,17 @@
#include "InetAddress.hpp" #include "InetAddress.hpp"
#if defined(__MINGW32__)
#define NS_INADDRSZ 4
#define NS_IN6ADDRSZ 16
#define NS_INT16SZ 2
int inet_pton4(const char *src, void *dst);
int inet_pton6(const char *src, void *dst);
int inet_pton(int af, const char *src, void *dst);
#endif
/** /**
* @brief Returns masked address for subnet comparisons * @brief Returns masked address for subnet comparisons
* *
@@ -62,7 +73,7 @@ char *beautify_eth_proto_nums(int proto);
* @param inet * @param inet
* @return * @return
*/ */
void sockaddr2inet(int socket_family, const struct sockaddr *addr, ZeroTier::InetAddress *inet); //void sockaddr2inet(int socket_family, const struct sockaddr *addr, ZeroTier::InetAddress *inet);
/** /**
* @brief Convert a raw MAC address byte array into a human-readable string * @brief Convert a raw MAC address byte array into a human-readable string

View File

@@ -103,7 +103,7 @@ void disableTaps();
* @param addrlen * @param addrlen
* @return * @return
*/ */
void zts_get_ipv4_address(const char *nwid, char *addrstr, const int addrlen); void zts_get_ipv4_address(const char *nwid, char *addrstr, const size_t addrlen);
/** /**
* @brief Gets the VirtualTap's (interface) IPv6 address * @brief Gets the VirtualTap's (interface) IPv6 address
@@ -114,7 +114,7 @@ void zts_get_ipv4_address(const char *nwid, char *addrstr, const int addrlen);
* @param addrlen * @param addrlen
* @return * @return
*/ */
void zts_get_ipv6_address(const char *nwid, char *addrstr, const int addrlen); void zts_get_ipv6_address(const char *nwid, char *addrstr, const size_t addrlen);
/** /**
* @brief Returns whether the VirtualTap has an assigned IPv4 address * @brief Returns whether the VirtualTap has an assigned IPv4 address
@@ -198,9 +198,9 @@ int zts_running();
* that one call this at the beginning of your application code since it may take several seconds to fully * that one call this at the beginning of your application code since it may take several seconds to fully
* come online. * come online.
* @param path Where this instance of ZeroTier will store its identity and configuration files * @param path Where this instance of ZeroTier will store its identity and configuration files
* @return * @return Returns 1 if ZeroTier is currently running, and 0 if it is not
*/ */
void zts_start(const char *path); int zts_start(const char *path);
/** /**
* @brief Alternative to zts_start(). Start an instance of libzt, wait for an address to be issues, and join * @brief Alternative to zts_start(). Start an instance of libzt, wait for an address to be issues, and join
@@ -211,15 +211,15 @@ void zts_start(const char *path);
* come online. * come online.
* @param path * @param path
* @param nwid A 16-digit hexidecimal virtual network ID * @param nwid A 16-digit hexidecimal virtual network ID
* @return * @return Returns 0 on success, -1 on failure
*/ */
void zts_simple_start(const char *path, const char *nwid); int zts_simple_start(const char *path, const char *nwid);
/** /**
* @brief Stops libzt (ZeroTier core services, stack drivers, stack threads, etc) * @brief Stops libzt (ZeroTier core services, stack drivers, stack threads, etc)
* *
* @usage This should be called at the end of your program or when you do not anticipate communicating over ZeroTier * @usage This should be called at the end of your program or when you do not anticipate communicating over ZeroTier
* @return * @return Returns 0 on success, -1 on failure
*/ */
void zts_stop(); void zts_stop();
@@ -231,7 +231,7 @@ void zts_stop();
* @param len * @param len
* @return * @return
*/ */
void zts_get_homepath(char *homePath, int len); void zts_get_homepath(char *homePath, size_t len);
/** /**
* @brief Copies the hexidecimal representation of this nodeID into the provided buffer * @brief Copies the hexidecimal representation of this nodeID into the provided buffer

View File

@@ -33,11 +33,14 @@
#ifndef LIBZT_H #ifndef LIBZT_H
#define LIBZT_H #define LIBZT_H
#include <poll.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <vector> #include <vector>
#if defined(__linux__)
#include <poll.h>
#endif
#include "Debug.hpp" #include "Debug.hpp"
#include "Defs.h" #include "Defs.h"
@@ -50,7 +53,6 @@ extern "C" {
#endif #endif
// forward declarations from ZT1Service.h // forward declarations from ZT1Service.h
void zts_simple_start(const char *path, const char *nwid);
int zts_get_device_id(char *devID); int zts_get_device_id(char *devID);
void init_network_stack(); void init_network_stack();
@@ -68,7 +70,7 @@ void init_network_stack();
* @param nwid A 16-digit hexidecimal network identifier (e.g. Earth: `8056c2e21c000001`) * @param nwid A 16-digit hexidecimal network identifier (e.g. Earth: `8056c2e21c000001`)
* @return 0 if successful; or 1 if failed * @return 0 if successful; or 1 if failed
*/ */
void zts_start(const char *path); int zts_start(const char *path);
/** /**
* @brief Starts libzt * @brief Starts libzt
@@ -83,7 +85,7 @@ void zts_start(const char *path);
* @param nwid A 16-digit hexidecimal network identifier (e.g. Earth: `8056c2e21c000001`) * @param nwid A 16-digit hexidecimal network identifier (e.g. Earth: `8056c2e21c000001`)
* @return 0 if successful; or 1 if failed * @return 0 if successful; or 1 if failed
*/ */
void zts_simple_start(const char *path, const char *nwid); int zts_simple_start(const char *path, const char *nwid);
/** /**
* @brief Stops the ZeroTier core service and disconnects from all virtual networks * @brief Stops the ZeroTier core service and disconnects from all virtual networks
@@ -140,7 +142,7 @@ void zts_leave_soft(const char * filepath, const char * nwid);
* @param len * @param len
* @return * @return
*/ */
void zts_get_homepath(char *homePath, const int len); void zts_get_homepath(char *homePath, const size_t len);
/** /**
* @brief Get device ID (10-digit hex + NULL byte) * @brief Get device ID (10-digit hex + NULL byte)
@@ -195,7 +197,7 @@ int zts_has_address(const char *nwid);
* @param addrlen * @param addrlen
* @return * @return
*/ */
void zts_get_ipv4_address(const char *nwid, char *addrstr, const int addrlen); void zts_get_ipv4_address(const char *nwid, char *addrstr, const size_t addrlen);
/** /**
* @brief Get IPV6 Address for this device on a given network * @brief Get IPV6 Address for this device on a given network
@@ -206,7 +208,7 @@ void zts_get_ipv4_address(const char *nwid, char *addrstr, const int addrlen);
* @param addrlen * @param addrlen
* @return * @return
*/ */
void zts_get_ipv6_address(const char *nwid, char *addrstr, const int addrlen); void zts_get_ipv6_address(const char *nwid, char *addrstr, const size_t addrlen);
/** /**
* @brief Returns a 6PLANE IPv6 address given a network ID and zerotier ID * @brief Returns a 6PLANE IPv6 address given a network ID and zerotier ID
@@ -440,7 +442,9 @@ int zts_close(int fd);
* @param timeout * @param timeout
* @return * @return
*/ */
#if defined(__linux__)
int zts_poll(struct pollfd *fds, nfds_t nfds, int timeout); int zts_poll(struct pollfd *fds, nfds_t nfds, int timeout);
#endif
/** /**
* @brief Monitor multiple file descriptors, waiting until one or more of the file descriptors become "ready" * @brief Monitor multiple file descriptors, waiting until one or more of the file descriptors become "ready"

View File

@@ -60,12 +60,12 @@ void lwip_dns_init();
* @usage lwip_driver_init() * @usage lwip_driver_init()
* @return * @return
*/ */
void lwip_start_dhcp(struct netif *interface); void lwip_start_dhcp(void *netif);
void general_lwip_init_interface(void *tapref, struct netif *interface, const char *name, const ZeroTier::MAC &mac, void general_lwip_init_interface(void *tapref, void *netif, const char *name, const ZeroTier::MAC &mac,
const ZeroTier::InetAddress &addr, const ZeroTier::InetAddress &nm, const ZeroTier::InetAddress &gw); const ZeroTier::InetAddress &addr, const ZeroTier::InetAddress &nm, const ZeroTier::InetAddress &gw);
void general_turn_on_interface(struct netif *interface); void general_turn_on_interface(void *netif);
/** /**
* @brief Set up an interface in the network stack for the VirtualTap. * @brief Set up an interface in the network stack for the VirtualTap.

View File

@@ -32,21 +32,38 @@
# #
CONTRIBDIR=ext/lwip-contrib CONTRIBDIR=ext/lwip-contrib
LWIPARCH=$(CONTRIBDIR)/ports/unix
#Set this to where you have the lwip core module checked out from CVS
#default assumes it's a dir named lwip at the same level as the contrib module
LWIPDIR=ext/lwip/src LWIPDIR=ext/lwip/src
CCDEP=clang++ CCDEP=clang++
# Automagically pick clang or gcc, with preference for clang # Automagically pick clang or gcc, with preference for clang
# This is only done if we have not overridden these with an environment or CLI variable # This is only done if we have not overridden these with an environment or CLI variable
ifeq ($(origin CCX),default) ifeq ($(origin CXX),default)
CCX=$(shell if [ -e /usr/bin/clang++ ]; then echo clang++; else echo g++; fi) CXX=$(shell if [ -e /usr/bin/clang++ ]; then echo clang++; else echo g++; fi)
endif endif
LWIPINCLUDES:=-I$(LWIPDIR)/include -I$(LWIPARCH) -I$(LWIPDIR) -I. -Iext -Iinclude OSTYPE=$(shell uname -s | tr '[A-Z]' '[a-z]')
CFLAGS=-Wno-format -Wno-deprecated -O3 -g -Wall -fPIC BUILD=build/$(OSTYPE)
CCX=clang++
# Windows
ifeq ($(OSTYPE),mingw32_nt-6.2)
CCX=g++
WINDEFS=-Wno-c++11-compat -std=c++98
LWIPARCH=$(CONTRIBDIR)/ports/win32
endif
ifeq ($(OSTYPE),linux)
LWIPARCH=$(CONTRIBDIR)/ports/unix
endif
ifeq ($(OSTYPE),darwin)
LWIPARCH=$(CONTRIBDIR)/ports/unix
endif
ifeq ($(OSTYPE),freebsd)
LWIPARCH=$(CONTRIBDIR)/ports/unix
endif
LWIPINCLUDES:=-I$(LWIPDIR)/include -I$(LWIPARCH) -I$(LWIPARCH)/include -I$(LWIPDIR) -I. -Iext -Iinclude
CFLAGS= $(WINDEFS) -Wno-format -Wno-deprecated -O3 -g -Wall -fPIC
CFLAGS+=-DLWIP_IPV4 -DLWIP_IPV6=0 -DIPv4 -DLWIP_DEBUG=1 $(LWIPINCLUDES) CFLAGS+=-DLWIP_IPV4 -DLWIP_IPV6=0 -DIPv4 -DLWIP_DEBUG=1 $(LWIPINCLUDES)
UNIXLIB=liblwip.a UNIXLIB=liblwip.a
@@ -63,8 +80,6 @@ LWIPNOAPPSFILES+=$(ARCHFILES)
LWIPNOAPPSFILESW=$(wildcard $(LWIPNOAPPSFILES)) LWIPNOAPPSFILESW=$(wildcard $(LWIPNOAPPSFILES))
LWIPNOAPPSOBJS=$(notdir $(LWIPNOAPPSFILESW:.c=.o)) LWIPNOAPPSOBJS=$(notdir $(LWIPNOAPPSFILESW:.c=.o))
CCX=clang++
%.o: %.o:
$(CCX) $(CFLAGS) -c $(<:.o=.c) $(CCX) $(CFLAGS) -c $(<:.o=.c)

View File

@@ -53,7 +53,8 @@ void handle_general_failure() {
inline unsigned int gettid() inline unsigned int gettid()
{ {
#ifdef _WIN32 #ifdef _WIN32
return GetCurrentThreadId(); //return GetCurrentThreadId();
return 0;
#elif defined(__linux__) #elif defined(__linux__)
return static_cast<unsigned int>(syscall(__NR_gettid)); return static_cast<unsigned int>(syscall(__NR_gettid));
#elif defined(__APPLE__) #elif defined(__APPLE__)

View File

@@ -32,6 +32,171 @@
#include "InetAddress.hpp" #include "InetAddress.hpp"
#include "Debug.hpp" #include "Debug.hpp"
#include "Utilities.h"
#if defined(__MINGW32__)
int inet_pton4(const char *src, void *dst)
{
uint8_t tmp[NS_INADDRSZ], *tp;
int saw_digit = 0;
int octets = 0;
*(tp = tmp) = 0;
int ch;
while ((ch = *src++) != '\0')
{
if (ch >= '0' && ch <= '9')
{
uint32_t n = *tp * 10 + (ch - '0');
if (saw_digit && *tp == 0)
return 0;
if (n > 255)
return 0;
*tp = n;
if (!saw_digit)
{
if (++octets > 4)
return 0;
saw_digit = 1;
}
}
else if (ch == '.' && saw_digit)
{
if (octets == 4)
return 0;
*++tp = 0;
saw_digit = 0;
}
else
return 0;
}
if (octets < 4)
return 0;
memcpy(dst, tmp, NS_INADDRSZ);
return 1;
}
int inet_pton6(const char *src, void *dst)
{
static const char xdigits[] = "0123456789abcdef";
uint8_t tmp[NS_IN6ADDRSZ];
uint8_t *tp = (uint8_t*) memset(tmp, '\0', NS_IN6ADDRSZ);
uint8_t *endp = tp + NS_IN6ADDRSZ;
uint8_t *colonp = NULL;
/* Leading :: requires some special handling. */
if (*src == ':')
{
if (*++src != ':')
return 0;
}
const char *curtok = src;
int saw_xdigit = 0;
uint32_t val = 0;
int ch;
while ((ch = tolower(*src++)) != '\0')
{
const char *pch = strchr(xdigits, ch);
if (pch != NULL)
{
val <<= 4;
val |= (pch - xdigits);
if (val > 0xffff)
return 0;
saw_xdigit = 1;
continue;
}
if (ch == ':')
{
curtok = src;
if (!saw_xdigit)
{
if (colonp)
return 0;
colonp = tp;
continue;
}
else if (*src == '\0')
{
return 0;
}
if (tp + NS_INT16SZ > endp)
return 0;
*tp++ = (uint8_t) (val >> 8) & 0xff;
*tp++ = (uint8_t) val & 0xff;
saw_xdigit = 0;
val = 0;
continue;
}
if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
inet_pton4(curtok, (char*) tp) > 0)
{
tp += NS_INADDRSZ;
saw_xdigit = 0;
break; /* '\0' was seen by inet_pton4(). */
}
return 0;
}
if (saw_xdigit)
{
if (tp + NS_INT16SZ > endp)
return 0;
*tp++ = (uint8_t) (val >> 8) & 0xff;
*tp++ = (uint8_t) val & 0xff;
}
if (colonp != NULL)
{
/*
* Since some memmove()'s erroneously fail to handle
* overlapping regions, we'll do the shift by hand.
*/
const int n = tp - colonp;
if (tp == endp)
return 0;
for (int i = 1; i <= n; i++)
{
endp[-i] = colonp[n - i];
colonp[n - i] = 0;
}
tp = endp;
}
if (tp != endp)
return 0;
memcpy(dst, tmp, NS_IN6ADDRSZ);
return 1;
}
int inet_pton(int af, const char *src, void *dst)
{
switch (af)
{
case AF_INET:
return inet_pton4(src, dst);
case AF_INET6:
return inet_pton6(src, dst);
default:
return -1;
}
}
#endif
char *beautify_eth_proto_nums(int proto) char *beautify_eth_proto_nums(int proto)
{ {
@@ -120,6 +285,7 @@ bool ipv6_in_subnet(ZeroTier::InetAddress *subnet, ZeroTier::InetAddress *addr)
return !strcmp(r.toIpString(b0), b.toIpString(b1)); return !strcmp(r.toIpString(b0), b.toIpString(b1));
} }
/*
void sockaddr2inet(int socket_family, const struct sockaddr *addr, ZeroTier::InetAddress *inet) void sockaddr2inet(int socket_family, const struct sockaddr *addr, ZeroTier::InetAddress *inet)
{ {
char ipstr[INET6_ADDRSTRLEN]; char ipstr[INET6_ADDRSTRLEN];
@@ -137,6 +303,7 @@ void sockaddr2inet(int socket_family, const struct sockaddr *addr, ZeroTier::Ine
inet->fromString(addrstr); inet->fromString(addrstr);
} }
} }
*/
void mac2str(char *macbuf, int len, unsigned char* addr) void mac2str(char *macbuf, int len, unsigned char* addr)
{ {

View File

@@ -34,7 +34,10 @@
#define ZT_VIRTUALSOCKET_HPP #define ZT_VIRTUALSOCKET_HPP
#include <ctime> #include <ctime>
#if defined(__linux__) || defined(__APPLE__)
#include <sys/socket.h> #include <sys/socket.h>
#endif
#include "VirtualSocket.h" #include "VirtualSocket.h"
#include "VirtualBindingPair.h" #include "VirtualBindingPair.h"

View File

@@ -84,6 +84,7 @@ namespace ZeroTier {
_handler(handler), _handler(handler),
_homePath(homePath), _homePath(homePath),
_arg(arg), _arg(arg),
_initialized(false),
_enabled(true), _enabled(true),
_run(true), _run(true),
_mac(mac), _mac(mac),
@@ -421,7 +422,7 @@ namespace ZeroTier {
target_addr = managed_routes->at(i).target; target_addr = managed_routes->at(i).target;
via_addr = managed_routes->at(i).via; via_addr = managed_routes->at(i).via;
nm = target_addr.netmask(); nm = target_addr.netmask();
for (int j=0; j<routes.size(); j++) { for (size_t j=0; j<routes.size(); j++) {
if (via_addr.ipsEqual(null_addr) || target_addr.ipsEqual(null_addr)) { if (via_addr.ipsEqual(null_addr) || target_addr.ipsEqual(null_addr)) {
found=true; found=true;
continue; continue;
@@ -439,7 +440,7 @@ namespace ZeroTier {
} }
} }
// check if route exists in tap but not in pushed routes (remove) // check if route exists in tap but not in pushed routes (remove)
for (int i=0; i<routes.size(); i++) { for (size_t i=0; i<routes.size(); i++) {
found = false; found = false;
for (int j=0; j<ZT_MAX_NETWORK_ROUTES; j++) { for (int j=0; j<ZT_MAX_NETWORK_ROUTES; j++) {
target_addr = managed_routes->at(j).target; target_addr = managed_routes->at(j).target;

View File

@@ -41,6 +41,13 @@
#include "Thread.hpp" #include "Thread.hpp"
#include "Phy.hpp" #include "Phy.hpp"
#if defined(__MINGW32__) || defined(__MINGW64__)
#include <WinSock2.h>
#include <Windows.h>
#include <IPHlpApi.h>
#include <Ifdef.h>
#endif
namespace ZeroTier { namespace ZeroTier {
/** /**
@@ -119,6 +126,20 @@ namespace ZeroTier {
void threadMain() void threadMain()
throw(); throw();
#if defined(__MINGW32__)
/* The following is merely to make ZeroTier's OneService happy while building on Windows.
we won't use these in libzt */
NET_LUID _deviceLuid;
std::string _deviceInstanceId;
/**
* Returns whether the VirtualTap interface has been initialized
*/
bool isInitialized() const { return _initialized; };
inline const NET_LUID &luid() const { return _deviceLuid; }
inline const std::string &instanceId() const { return _deviceInstanceId; }
#endif
/** /**
* For moving data onto the ZeroTier virtual wire * For moving data onto the ZeroTier virtual wire
*/ */
@@ -185,13 +206,14 @@ namespace ZeroTier {
char vtap_abbr_name[16]; char vtap_abbr_name[16];
static int devno; static int devno;
int ifindex = 0; size_t ifindex = 0;
std::vector<InetAddress> ips() const; std::vector<InetAddress> ips() const;
std::vector<InetAddress> _ips; std::vector<InetAddress> _ips;
std::string _homePath; std::string _homePath;
void *_arg; void *_arg;
volatile bool _initialized;
volatile bool _enabled; volatile bool _enabled;
volatile bool _run; volatile bool _run;
MAC _mac; MAC _mac;

View File

@@ -55,6 +55,10 @@ namespace ZeroTier {
ZeroTier::Mutex _multiplexer_lock; ZeroTier::Mutex _multiplexer_lock;
} }
#if defined(__MINGW32__) || defined(__MINGW64__)
WSADATA wsaData;
#endif
/****************************************************************************/ /****************************************************************************/
/* ZeroTier Core helper functions for libzt - DON'T CALL THESE DIRECTLY */ /* ZeroTier Core helper functions for libzt - DON'T CALL THESE DIRECTLY */
/****************************************************************************/ /****************************************************************************/
@@ -69,7 +73,7 @@ ZeroTier::VirtualTap *getTapByNWID(uint64_t nwid)
{ {
ZeroTier::_vtaps_lock.lock(); ZeroTier::_vtaps_lock.lock();
ZeroTier::VirtualTap *s, *tap = nullptr; ZeroTier::VirtualTap *s, *tap = nullptr;
for (int i=0; i<ZeroTier::vtaps.size(); i++) { for (size_t i=0; i<ZeroTier::vtaps.size(); i++) {
s = (ZeroTier::VirtualTap*)ZeroTier::vtaps[i]; s = (ZeroTier::VirtualTap*)ZeroTier::vtaps[i];
if (s->_nwid == nwid) { tap = s; } if (s->_nwid == nwid) { tap = s; }
} }
@@ -82,7 +86,7 @@ ZeroTier::VirtualTap *getTapByAddr(ZeroTier::InetAddress *addr)
ZeroTier::_vtaps_lock.lock(); ZeroTier::_vtaps_lock.lock();
ZeroTier::VirtualTap *s, *tap = nullptr; ZeroTier::VirtualTap *s, *tap = nullptr;
//char ipbuf[64], ipbuf2[64], ipbuf3[64]; //char ipbuf[64], ipbuf2[64], ipbuf3[64];
for (int i=0; i<ZeroTier::vtaps.size(); i++) { for (size_t i=0; i<ZeroTier::vtaps.size(); i++) {
s = (ZeroTier::VirtualTap*)ZeroTier::vtaps[i]; s = (ZeroTier::VirtualTap*)ZeroTier::vtaps[i];
// check address schemes // check address schemes
for (int j=0; j<s->_ips.size(); j++) { for (int j=0; j<s->_ips.size(); j++) {
@@ -104,7 +108,7 @@ ZeroTier::VirtualTap *getTapByAddr(ZeroTier::InetAddress *addr)
if (tap == NULL) { if (tap == NULL) {
std::vector<ZT_VirtualNetworkRoute> *managed_routes = ZeroTier::zt1Service->getRoutes(s->_nwid); std::vector<ZT_VirtualNetworkRoute> *managed_routes = ZeroTier::zt1Service->getRoutes(s->_nwid);
ZeroTier::InetAddress target, nm, via; ZeroTier::InetAddress target, nm, via;
for (int i=0; i<managed_routes->size(); i++) { for (size_t i=0; i<managed_routes->size(); i++) {
target = managed_routes->at(i).target; target = managed_routes->at(i).target;
nm = target.netmask(); nm = target.netmask();
via = managed_routes->at(i).via; via = managed_routes->at(i).via;
@@ -124,7 +128,7 @@ ZeroTier::VirtualTap *getTapByName(char *ifname)
{ {
ZeroTier::_vtaps_lock.lock(); ZeroTier::_vtaps_lock.lock();
ZeroTier::VirtualTap *s, *tap = nullptr; ZeroTier::VirtualTap *s, *tap = nullptr;
for (int i=0; i<ZeroTier::vtaps.size(); i++) { for (size_t i=0; i<ZeroTier::vtaps.size(); i++) {
s = (ZeroTier::VirtualTap*)ZeroTier::vtaps[i]; s = (ZeroTier::VirtualTap*)ZeroTier::vtaps[i];
if (strcmp(s->_dev.c_str(), ifname) == false) { if (strcmp(s->_dev.c_str(), ifname) == false) {
tap = s; tap = s;
@@ -134,11 +138,11 @@ ZeroTier::VirtualTap *getTapByName(char *ifname)
return tap; return tap;
} }
ZeroTier::VirtualTap *getTapByIndex(int index) ZeroTier::VirtualTap *getTapByIndex(size_t index)
{ {
ZeroTier::_vtaps_lock.lock(); ZeroTier::_vtaps_lock.lock();
ZeroTier::VirtualTap *s, *tap = nullptr; ZeroTier::VirtualTap *s, *tap = nullptr;
for (int i=0; i<ZeroTier::vtaps.size(); i++) { for (size_t i=0; i<ZeroTier::vtaps.size(); i++) {
s = (ZeroTier::VirtualTap*)ZeroTier::vtaps[i]; s = (ZeroTier::VirtualTap*)ZeroTier::vtaps[i];
if (s->ifindex == index) { if (s->ifindex == index) {
tap = s; tap = s;
@@ -247,20 +251,20 @@ void *zts_start_service(void *thread_id)
void disableTaps() void disableTaps()
{ {
ZeroTier::_vtaps_lock.lock(); ZeroTier::_vtaps_lock.lock();
for (int i=0; i<ZeroTier::vtaps.size(); i++) { for (size_t i=0; i<ZeroTier::vtaps.size(); i++) {
DEBUG_EXTRA("vt=%p", ZeroTier::vtaps[i]); DEBUG_EXTRA("vt=%p", ZeroTier::vtaps[i]);
((ZeroTier::VirtualTap*)ZeroTier::vtaps[i])->_enabled = false; ((ZeroTier::VirtualTap*)ZeroTier::vtaps[i])->_enabled = false;
} }
ZeroTier::_vtaps_lock.unlock(); ZeroTier::_vtaps_lock.unlock();
} }
void zts_get_ipv4_address(const char *nwid, char *addrstr, const int addrlen) void zts_get_ipv4_address(const char *nwid, char *addrstr, const size_t addrlen)
{ {
if (ZeroTier::zt1Service) { if (ZeroTier::zt1Service) {
uint64_t nwid_int = strtoull(nwid, NULL, 16); uint64_t nwid_int = strtoull(nwid, NULL, 16);
ZeroTier::VirtualTap *tap = getTapByNWID(nwid_int); ZeroTier::VirtualTap *tap = getTapByNWID(nwid_int);
if (tap && tap->_ips.size()) { if (tap && tap->_ips.size()) {
for (int i=0; i<tap->_ips.size(); i++) { for (size_t i=0; i<tap->_ips.size(); i++) {
if (tap->_ips[i].isV4()) { if (tap->_ips[i].isV4()) {
char ipbuf[INET_ADDRSTRLEN]; char ipbuf[INET_ADDRSTRLEN];
std::string addr = tap->_ips[i].toString(ipbuf); std::string addr = tap->_ips[i].toString(ipbuf);
@@ -276,13 +280,13 @@ void zts_get_ipv4_address(const char *nwid, char *addrstr, const int addrlen)
memcpy(addrstr, "\0", 1); memcpy(addrstr, "\0", 1);
} }
void zts_get_ipv6_address(const char *nwid, char *addrstr, const int addrlen) void zts_get_ipv6_address(const char *nwid, char *addrstr, size_t addrlen)
{ {
if (ZeroTier::zt1Service) { if (ZeroTier::zt1Service) {
uint64_t nwid_int = strtoull(nwid, NULL, 16); uint64_t nwid_int = strtoull(nwid, NULL, 16);
ZeroTier::VirtualTap *tap = getTapByNWID(nwid_int); ZeroTier::VirtualTap *tap = getTapByNWID(nwid_int);
if (tap && tap->_ips.size()) { if (tap && tap->_ips.size()) {
for (int i=0; i<tap->_ips.size(); i++) { for (size_t i=0; i<tap->_ips.size(); i++) {
if (tap->_ips[i].isV6()) { if (tap->_ips[i].isV6()) {
char ipbuf[INET6_ADDRSTRLEN]; char ipbuf[INET6_ADDRSTRLEN];
std::string addr = tap->_ips[i].toString(ipbuf); std::string addr = tap->_ips[i].toString(ipbuf);
@@ -351,7 +355,7 @@ void zts_join(const char * nwid) {
} }
// provide ZTO service reference to virtual taps // provide ZTO service reference to virtual taps
// TODO: This might prove to be unreliable, but it works for now // TODO: This might prove to be unreliable, but it works for now
for (int i=0;i<ZeroTier::vtaps.size(); i++) { for (size_t i=0;i<ZeroTier::vtaps.size(); i++) {
ZeroTier::VirtualTap *s = (ZeroTier::VirtualTap*)ZeroTier::vtaps[i]; ZeroTier::VirtualTap *s = (ZeroTier::VirtualTap*)ZeroTier::vtaps[i];
s->zt1ServiceRef=(void*)ZeroTier::zt1Service; s->zt1ServiceRef=(void*)ZeroTier::zt1Service;
} }
@@ -387,21 +391,24 @@ int zts_running() {
return ZeroTier::zt1Service == NULL ? false : ZeroTier::zt1Service->isRunning(); return ZeroTier::zt1Service == NULL ? false : ZeroTier::zt1Service->isRunning();
} }
void zts_start(const char *path) int zts_start(const char *path)
{ {
if (ZeroTier::zt1Service) { if (ZeroTier::zt1Service) {
return; return 0; // already initialized, ok
} }
if (path) { if (path) {
ZeroTier::homeDir = path; ZeroTier::homeDir = path;
} }
#if defined(__MINGW32__) || defined(__MINGW64__)
WSAStartup(MAKEWORD(2, 2), &wsaData); // initialize WinSock. Used in Phy for loopback pipe
#endif
pthread_t service_thread; pthread_t service_thread;
pthread_create(&service_thread, NULL, zts_start_service, NULL); return pthread_create(&service_thread, NULL, zts_start_service, NULL);
} }
void zts_simple_start(const char *path, const char *nwid) int zts_simple_start(const char *path, const char *nwid)
{ {
zts_start(path); int err = zts_start(path);
while (zts_running() == false) { while (zts_running() == false) {
DEBUG_EXTRA("waiting for service to start"); DEBUG_EXTRA("waiting for service to start");
nanosleep((const struct timespec[]) {{0, (ZTO_WRAPPER_CHECK_INTERVAL * 1000000)}}, NULL); nanosleep((const struct timespec[]) {{0, (ZTO_WRAPPER_CHECK_INTERVAL * 1000000)}}, NULL);
@@ -419,6 +426,7 @@ void zts_simple_start(const char *path, const char *nwid)
while (zts_has_address(nwid) == false) { while (zts_has_address(nwid) == false) {
nanosleep((const struct timespec[]) {{0, (ZTO_WRAPPER_CHECK_INTERVAL * 1000000)}}, NULL); nanosleep((const struct timespec[]) {{0, (ZTO_WRAPPER_CHECK_INTERVAL * 1000000)}}, NULL);
} }
return err;
} }
void zts_stop() { void zts_stop() {
@@ -426,12 +434,15 @@ void zts_stop() {
ZeroTier::zt1Service->terminate(); ZeroTier::zt1Service->terminate();
disableTaps(); disableTaps();
} }
#if defined(__MINGW32__) || defined(__MINGW64__)
WSACleanup(); // clean up WinSock
#endif
} }
void zts_get_homepath(char *homePath, int len) { void zts_get_homepath(char *homePath, size_t len) {
if (ZeroTier::homeDir.length()) { if (ZeroTier::homeDir.length()) {
memset(homePath, 0, len); memset(homePath, 0, len);
int buf_len = len < ZeroTier::homeDir.length() ? len : ZeroTier::homeDir.length(); size_t buf_len = len < ZeroTier::homeDir.length() ? len : ZeroTier::homeDir.length();
memcpy(homePath, ZeroTier::homeDir.c_str(), buf_len); memcpy(homePath, ZeroTier::homeDir.c_str(), buf_len);
} }
} }
@@ -470,7 +481,7 @@ int zts_get_peer_address(char *peer, const char *devID) {
if (ZeroTier::zt1Service) { if (ZeroTier::zt1Service) {
ZT_PeerList *pl = ZeroTier::zt1Service->getNode()->peers(); ZT_PeerList *pl = ZeroTier::zt1Service->getNode()->peers();
// uint64_t addr; // uint64_t addr;
for (int i=0; i<pl->peerCount; i++) { for (size_t i=0; i<pl->peerCount; i++) {
// ZT_Peer *p = &(pl->peers[i]); // ZT_Peer *p = &(pl->peers[i]);
// DEBUG_INFO("peer[%d] = %lx", i, p->address); // DEBUG_INFO("peer[%d] = %lx", i, p->address);
} }

View File

@@ -66,7 +66,7 @@ void sys2lwip(int fd, const struct sockaddr *orig, struct sockaddr *modified)
} }
#if defined(LIBZT_IPV4) #if defined(LIBZT_IPV4)
if (ss.ss_family == AF_INET) { if (ss.ss_family == AF_INET) {
#if defined(__linux__) #if defined(__linux__) || defined(__MINGW32__)
struct sockaddr_in *p4 = (struct sockaddr_in *)modified; struct sockaddr_in *p4 = (struct sockaddr_in *)modified;
struct sockaddr_in *addr4 = (struct sockaddr_in*)orig; struct sockaddr_in *addr4 = (struct sockaddr_in*)orig;
p4->sin_len = sizeof(struct sockaddr_in); p4->sin_len = sizeof(struct sockaddr_in);
@@ -80,7 +80,7 @@ void sys2lwip(int fd, const struct sockaddr *orig, struct sockaddr *modified)
#if defined(LIBZT_IPV6) #if defined(LIBZT_IPV6)
if (ss.ss_family == AF_INET6) { if (ss.ss_family == AF_INET6) {
#if defined(__linux__) #if defined(__linux__) || defined(__MINGW32__)
struct sockaddr_in6 *p6 = (struct sockaddr_in6 *)modified; struct sockaddr_in6 *p6 = (struct sockaddr_in6 *)modified;
struct sockaddr_in6 *addr6 = (struct sockaddr_in6*)orig; struct sockaddr_in6 *addr6 = (struct sockaddr_in6*)orig;
p6->sin6_len = sizeof(struct sockaddr_in6); p6->sin6_len = sizeof(struct sockaddr_in6);
@@ -311,6 +311,7 @@ int zts_close(int fd)
return err; return err;
} }
#if defined(__linux__)
int zts_poll(struct pollfd *fds, nfds_t nfds, int timeout) int zts_poll(struct pollfd *fds, nfds_t nfds, int timeout)
{ {
int err = -1; int err = -1;
@@ -324,6 +325,7 @@ int zts_poll(struct pollfd *fds, nfds_t nfds, int timeout)
#endif #endif
return err; return err;
} }
#endif
int zts_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, int zts_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
struct timeval *timeout) struct timeval *timeout)

View File

@@ -115,6 +115,9 @@ void lwip_driver_init()
if (lwip_driver_initialized == true) { if (lwip_driver_initialized == true) {
return; return;
} }
#if defined(__MINGW32__)
sys_init(); // required for win32 initializtion of critical sections
#endif
sys_thread_new("main_network_stack_thread", main_network_stack_thread, sys_thread_new("main_network_stack_thread", main_network_stack_thread,
NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO); NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
} }
@@ -160,7 +163,7 @@ err_t lwip_eth_tx(struct netif *netif, struct pbuf *p)
return ERR_OK; return ERR_OK;
} }
void general_lwip_init_interface(void *tapref, struct netif *interface, const char *name, const ZeroTier::MAC &mac, const ZeroTier::InetAddress &addr, const ZeroTier::InetAddress &nm, const ZeroTier::InetAddress &gw) void general_lwip_init_interface(void *tapref, void *netif, const char *name, const ZeroTier::MAC &mac, const ZeroTier::InetAddress &addr, const ZeroTier::InetAddress &nm, const ZeroTier::InetAddress &gw)
{ {
#if defined(LIBZT_IPV4) #if defined(LIBZT_IPV4)
char ipbuf[INET6_ADDRSTRLEN], nmbuf[INET6_ADDRSTRLEN], gwbuf[INET6_ADDRSTRLEN]; char ipbuf[INET6_ADDRSTRLEN], nmbuf[INET6_ADDRSTRLEN], gwbuf[INET6_ADDRSTRLEN];
@@ -192,7 +195,7 @@ void general_lwip_init_interface(void *tapref, struct netif *interface, const ch
#endif #endif
} }
void general_turn_on_interface(struct netif *interface) void general_turn_on_interface(void *netif)
{ {
//netif_set_up(&n1); //netif_set_up(&n1);
//netif_set_default(&n1); //netif_set_default(&n1);
@@ -206,9 +209,9 @@ void lwip_dns_init()
dns_init(); dns_init();
} }
void lwip_start_dhcp(struct netif *interface) void lwip_start_dhcp(void *netif)
{ {
netifapi_dhcp_start(interface); netifapi_dhcp_start((struct netif *)netif);
} }
void lwip_init_interface(void *tapref, const ZeroTier::MAC &mac, const ZeroTier::InetAddress &ip) void lwip_init_interface(void *tapref, const ZeroTier::MAC &mac, const ZeroTier::InetAddress &ip)

2
zto

Submodule zto updated: 59b7cbb591...f2c69ede96