Windows Support

This commit is contained in:
Joseph Henry
2017-10-09 17:56:40 -07:00
parent 06a09edd6d
commit 2900f1f995
28 changed files with 486 additions and 241 deletions

View File

@@ -36,6 +36,18 @@ 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)
# 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++
CONTRIBDIR=ext/lwip-contrib
LWIPARCH=$(CONTRIBDIR)/ports/win32
LWIPARCHINCLUDE=$(LWIPARCH)/include
endif
# Darwin # Darwin
ifeq ($(OSTYPE),darwin) ifeq ($(OSTYPE),darwin)
ARTOOL=libtool ARTOOL=libtool
@@ -147,7 +159,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 +223,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+=$(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 +360,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 {
@@ -69,7 +75,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 +87,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,7 +126,7 @@ 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
@@ -212,7 +221,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 +264,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 +274,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 +297,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) {
@@ -371,7 +378,7 @@ 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];
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

@@ -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"
@@ -440,7 +443,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

@@ -421,7 +421,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 +439,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

@@ -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)