Merge branch 'master' into dev
This commit is contained in:
22
Makefile
22
Makefile
@@ -35,26 +35,41 @@ endif
|
||||
|
||||
OSTYPE=$(shell uname -s | tr '[A-Z]' '[a-z]')
|
||||
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
|
||||
ifeq ($(OSTYPE),darwin)
|
||||
ARTOOL=libtool
|
||||
ARFLAGS=-static
|
||||
LWIPARCHINCLUDE=$(LWIPCONTRIBDIR)/ports/unix/include
|
||||
endif
|
||||
# Linux
|
||||
ifeq ($(OSTYPE),linux)
|
||||
ARTOOL=ar
|
||||
ARFLAGS=rcs
|
||||
LWIPARCHINCLUDE=$(LWIPCONTRIBDIR)/ports/unix/include
|
||||
endif
|
||||
# FreeBSD
|
||||
ifeq ($(OSTYPE),freebsd)
|
||||
ARTOOL=ar
|
||||
ARFLAGS=rcs
|
||||
LWIPARCHINCLUDE=$(LWIPCONTRIBDIR)/ports/unix/include
|
||||
endif
|
||||
# OpenBSD
|
||||
ifeq ($(OSTYPE),openbsd)
|
||||
ARTOOL=ar
|
||||
ARFLAGS=rcs
|
||||
LWIPARCHINCLUDE=$(LWIPCONTRIBDIR)/ports/unix/include
|
||||
endif
|
||||
|
||||
##############################################################################
|
||||
@@ -147,7 +162,7 @@ ifeq ($(SDK_JNI), 1)
|
||||
LIBZT_DEFS+=-DSDK_JNI
|
||||
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\""
|
||||
LIBZT_FILES:=src/VirtualTap.cpp src/libzt.cpp src/Utilities.cpp
|
||||
STATIC_LIB=$(BUILD)/libzt.a
|
||||
@@ -211,9 +226,8 @@ endif
|
||||
STACK_DRIVER_DEFS+=-DLWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
|
||||
STACK_DRIVER_DEFS+=-DSTACK_LWIP
|
||||
STACK_DRIVER_FILES:=src/lwIP.cpp
|
||||
LWIPARCH=$(CONTRIBDIR)/ports/unix
|
||||
LWIPDIR=ext/lwip/src
|
||||
STACK_INCLUDES+=-Iext/lwip/src/include/lwip \
|
||||
STACK_INCLUDES+=-I$(LWIPARCHINCLUDE) -Iext/lwip/src/include/lwip \
|
||||
-I$(LWIPDIR)/include \
|
||||
-I$(LWIPARCH)/include \
|
||||
-I$(LWIPDIR)/include/ipv4 \
|
||||
@@ -349,7 +363,7 @@ nativetest:
|
||||
@date +"Build script finished on %F %T"
|
||||
ztproxy:
|
||||
$(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
|
||||
@date +"Build script finished on %F %T"
|
||||
intercept:
|
||||
|
||||
@@ -26,12 +26,17 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
//#include "Winsock2.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <fcntl.h>
|
||||
#include <regex.h>
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
@@ -39,6 +44,7 @@
|
||||
|
||||
#include "RingBuffer.hpp"
|
||||
#include "ztproxy.hpp"
|
||||
#include "Utilities.h"
|
||||
#include "libzt.h"
|
||||
|
||||
namespace ZeroTier {
|
||||
@@ -57,10 +63,6 @@ namespace ZeroTier {
|
||||
_dns_nameserver(dns_nameserver),
|
||||
_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
|
||||
// IPv4
|
||||
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_port = Utils::hton((uint16_t)proxy_listen_port);
|
||||
_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
|
||||
/*
|
||||
struct sockaddr_in6 in6;
|
||||
memset((void *)&in6,0,sizeof(in6));
|
||||
in6.sin6_family = AF_INET6;
|
||||
@@ -77,13 +83,12 @@ namespace ZeroTier {
|
||||
in6.sin6_addr.s6_addr[15] = 1; // IPv6 localhost == ::1
|
||||
in6.sin6_port = Utils::hton((uint16_t)proxy_listen_port);
|
||||
_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) {
|
||||
DEBUG_ERROR("Error binding on port %d for IPv6 HTTP listen socket", proxy_listen_port);
|
||||
}
|
||||
*/
|
||||
_thread = Thread::start(this);
|
||||
}
|
||||
|
||||
@@ -117,14 +122,14 @@ namespace ZeroTier {
|
||||
// Moves data between client application socket and libzt VirtualSocket
|
||||
while(_run) {
|
||||
|
||||
_phy.poll(5);
|
||||
_phy.poll(1);
|
||||
|
||||
conn_m.lock();
|
||||
// build fd_sets to select upon
|
||||
FD_ZERO(&read_set);
|
||||
FD_ZERO(&write_set);
|
||||
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, &write_set);
|
||||
nfds = clist[i]->zfd > nfds ? clist[i]->zfd : nfds;
|
||||
@@ -212,7 +217,6 @@ namespace ZeroTier {
|
||||
exit(0);
|
||||
}
|
||||
if (conn->zfd < 0) { // no connection yet
|
||||
DEBUG_INFO("no connection yet, will establish...");
|
||||
if (host == "") {
|
||||
DEBUG_ERROR("invalid hostname or address (empty)");
|
||||
return;
|
||||
@@ -256,6 +260,7 @@ namespace ZeroTier {
|
||||
}
|
||||
if (ipv == 6) {
|
||||
//DEBUG_INFO("attempting to proxy [0.0.0.0:%d -> %s:%d]", _proxy_listen_port, host.c_str(), dest_port);
|
||||
/*
|
||||
struct sockaddr_in6 in6;
|
||||
memset(&in6,0,sizeof(in6));
|
||||
in6.sin6_family = AF_INET;
|
||||
@@ -265,6 +270,7 @@ namespace ZeroTier {
|
||||
in6.sin6_port = Utils::hton(dest_port);
|
||||
zfd = zts_socket(AF_INET, SOCK_STREAM, 0);
|
||||
err = zts_connect(zfd, (const struct sockaddr *)&in6, sizeof(in6));
|
||||
*/
|
||||
}
|
||||
if (zfd < 0 || err < 0) {
|
||||
// now release TX buffer contents we previously saved, since we can't connect
|
||||
@@ -287,9 +293,6 @@ namespace ZeroTier {
|
||||
zmap[zfd] = conn;
|
||||
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
|
||||
conn->tx_m.lock();
|
||||
if ((wr = conn->TXbuf->write((const unsigned char *)data, len)) < 0) {
|
||||
@@ -321,7 +324,7 @@ namespace ZeroTier {
|
||||
zts_close(conn->zfd);
|
||||
}
|
||||
cmap.erase(sock);
|
||||
for (int i=0; i<clist.size(); i++) {
|
||||
for (size_t i=0; i<clist.size(); i++) {
|
||||
if (conn == clist[i]) {
|
||||
clist.erase(clist.begin()+i);
|
||||
break;
|
||||
@@ -371,7 +374,12 @@ int main(int argc, char **argv)
|
||||
std::string nwid = argv[3];
|
||||
std::string internal_addr = argv[4];
|
||||
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);
|
||||
|
||||
|
||||
@@ -34,10 +34,13 @@
|
||||
#include "Phy.hpp"
|
||||
#include "OSUtils.hpp"
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <sys/select.h>
|
||||
|
||||
#define BUF_SZ 1024*1024
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#pragma warning (disable: 4820) /* 'x' bytes padding added after data member 'y' */
|
||||
#endif
|
||||
|
||||
#define LWIP_PROVIDE_ERRNO
|
||||
#define LWIP_PROVIDE_ERRNO 0
|
||||
|
||||
/* Define platform endianness (might already be defined) */
|
||||
#ifndef BYTE_ORDER
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
#include "lwip/errno.h"
|
||||
#include "errno.h"
|
||||
|
||||
#if !NO_SYS
|
||||
/** Table to quickly map an lwIP error (err_t) to a socket error
|
||||
|
||||
@@ -658,10 +658,19 @@ lwip_connect(int s, const struct sockaddr *name, socklen_t 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));
|
||||
err = netconn_disconnect(sock->conn);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ip_addr_t remote_addr;
|
||||
u16_t remote_port;
|
||||
|
||||
|
||||
386
ext/lwip/src/include/lwip/errno.h → ext/lwip/src/include/lwip/errno.h.bak
Executable file → Normal file
386
ext/lwip/src/include/lwip/errno.h → ext/lwip/src/include/lwip/errno.h.bak
Executable file → Normal file
@@ -1,193 +1,193 @@
|
||||
/**
|
||||
* @file
|
||||
* Posix Errno defines
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* 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
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_ERRNO_H
|
||||
#define LWIP_HDR_ERRNO_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_PROVIDE_ERRNO
|
||||
|
||||
#define EPERM 1 /* Operation not permitted */
|
||||
#define ENOENT 2 /* No such file or directory */
|
||||
#define ESRCH 3 /* No such process */
|
||||
#define EINTR 4 /* Interrupted system call */
|
||||
#define EIO 5 /* I/O error */
|
||||
#define ENXIO 6 /* No such device or address */
|
||||
#define E2BIG 7 /* Arg list too long */
|
||||
#define ENOEXEC 8 /* Exec format error */
|
||||
#define EBADF 9 /* Bad file number */
|
||||
#define ECHILD 10 /* No child processes */
|
||||
#define EAGAIN 11 /* Try again */
|
||||
#define ENOMEM 12 /* Out of memory */
|
||||
#define EACCES 13 /* Permission denied */
|
||||
#define EFAULT 14 /* Bad address */
|
||||
#define ENOTBLK 15 /* Block device required */
|
||||
#define EBUSY 16 /* Device or resource busy */
|
||||
#define EEXIST 17 /* File exists */
|
||||
#define EXDEV 18 /* Cross-device link */
|
||||
#define ENODEV 19 /* No such device */
|
||||
#define ENOTDIR 20 /* Not a directory */
|
||||
#define EISDIR 21 /* Is a directory */
|
||||
#define EINVAL 22 /* Invalid argument */
|
||||
#define ENFILE 23 /* File table overflow */
|
||||
#define EMFILE 24 /* Too many open files */
|
||||
#define ENOTTY 25 /* Not a typewriter */
|
||||
#define ETXTBSY 26 /* Text file busy */
|
||||
#define EFBIG 27 /* File too large */
|
||||
#define ENOSPC 28 /* No space left on device */
|
||||
#define ESPIPE 29 /* Illegal seek */
|
||||
#define EROFS 30 /* Read-only file system */
|
||||
#define EMLINK 31 /* Too many links */
|
||||
#define EPIPE 32 /* Broken pipe */
|
||||
#define EDOM 33 /* Math argument out of domain of func */
|
||||
#define ERANGE 34 /* Math result not representable */
|
||||
#define EDEADLK 35 /* Resource deadlock would occur */
|
||||
#define ENAMETOOLONG 36 /* File name too long */
|
||||
#define ENOLCK 37 /* No record locks available */
|
||||
#define ENOSYS 38 /* Function not implemented */
|
||||
#define ENOTEMPTY 39 /* Directory not empty */
|
||||
#define ELOOP 40 /* Too many symbolic links encountered */
|
||||
#define EWOULDBLOCK EAGAIN /* Operation would block */
|
||||
#define ENOMSG 42 /* No message of desired type */
|
||||
#define EIDRM 43 /* Identifier removed */
|
||||
#define ECHRNG 44 /* Channel number out of range */
|
||||
#define EL2NSYNC 45 /* Level 2 not synchronized */
|
||||
#define EL3HLT 46 /* Level 3 halted */
|
||||
#define EL3RST 47 /* Level 3 reset */
|
||||
#define ELNRNG 48 /* Link number out of range */
|
||||
#define EUNATCH 49 /* Protocol driver not attached */
|
||||
#define ENOCSI 50 /* No CSI structure available */
|
||||
#define EL2HLT 51 /* Level 2 halted */
|
||||
#define EBADE 52 /* Invalid exchange */
|
||||
#define EBADR 53 /* Invalid request descriptor */
|
||||
#define EXFULL 54 /* Exchange full */
|
||||
#define ENOANO 55 /* No anode */
|
||||
#define EBADRQC 56 /* Invalid request code */
|
||||
#define EBADSLT 57 /* Invalid slot */
|
||||
|
||||
#define EDEADLOCK EDEADLK
|
||||
|
||||
#define EBFONT 59 /* Bad font file format */
|
||||
#define ENOSTR 60 /* Device not a stream */
|
||||
#define ENODATA 61 /* No data available */
|
||||
#define ETIME 62 /* Timer expired */
|
||||
#define ENOSR 63 /* Out of streams resources */
|
||||
#define ENONET 64 /* Machine is not on the network */
|
||||
#define ENOPKG 65 /* Package not installed */
|
||||
#define EREMOTE 66 /* Object is remote */
|
||||
#define ENOLINK 67 /* Link has been severed */
|
||||
#define EADV 68 /* Advertise error */
|
||||
#define ESRMNT 69 /* Srmount error */
|
||||
#define ECOMM 70 /* Communication error on send */
|
||||
#define EPROTO 71 /* Protocol error */
|
||||
#define EMULTIHOP 72 /* Multihop attempted */
|
||||
#define EDOTDOT 73 /* RFS specific error */
|
||||
#define EBADMSG 74 /* Not a data message */
|
||||
#define EOVERFLOW 75 /* Value too large for defined data type */
|
||||
#define ENOTUNIQ 76 /* Name not unique on network */
|
||||
#define EBADFD 77 /* File descriptor in bad state */
|
||||
#define EREMCHG 78 /* Remote address changed */
|
||||
#define ELIBACC 79 /* Can not access a needed shared library */
|
||||
#define ELIBBAD 80 /* Accessing a corrupted shared library */
|
||||
#define ELIBSCN 81 /* .lib section in a.out corrupted */
|
||||
#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
|
||||
#define ELIBEXEC 83 /* Cannot exec a shared library directly */
|
||||
#define EILSEQ 84 /* Illegal byte sequence */
|
||||
#define ERESTART 85 /* Interrupted system call should be restarted */
|
||||
#define ESTRPIPE 86 /* Streams pipe error */
|
||||
#define EUSERS 87 /* Too many users */
|
||||
#define ENOTSOCK 88 /* Socket operation on non-socket */
|
||||
#define EDESTADDRREQ 89 /* Destination address required */
|
||||
#define EMSGSIZE 90 /* Message too long */
|
||||
#define EPROTOTYPE 91 /* Protocol wrong type for socket */
|
||||
#define ENOPROTOOPT 92 /* Protocol not available */
|
||||
#define EPROTONOSUPPORT 93 /* Protocol not supported */
|
||||
#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
|
||||
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
|
||||
#define EPFNOSUPPORT 96 /* Protocol family not supported */
|
||||
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
|
||||
#define EADDRINUSE 98 /* Address already in use */
|
||||
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
|
||||
#define ENETDOWN 100 /* Network is down */
|
||||
#define ENETUNREACH 101 /* Network is unreachable */
|
||||
#define ENETRESET 102 /* Network dropped connection because of reset */
|
||||
#define ECONNABORTED 103 /* Software caused connection abort */
|
||||
#define ECONNRESET 104 /* Connection reset by peer */
|
||||
#define ENOBUFS 105 /* No buffer space available */
|
||||
#define EISCONN 106 /* Transport endpoint is already connected */
|
||||
#define ENOTCONN 107 /* Transport endpoint is not connected */
|
||||
#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
|
||||
#define ETOOMANYREFS 109 /* Too many references: cannot splice */
|
||||
#define ETIMEDOUT 110 /* Connection timed out */
|
||||
#define ECONNREFUSED 111 /* Connection refused */
|
||||
#define EHOSTDOWN 112 /* Host is down */
|
||||
#define EHOSTUNREACH 113 /* No route to host */
|
||||
#define EALREADY 114 /* Operation already in progress */
|
||||
#define EINPROGRESS 115 /* Operation now in progress */
|
||||
#define ESTALE 116 /* Stale NFS file handle */
|
||||
#define EUCLEAN 117 /* Structure needs cleaning */
|
||||
#define ENOTNAM 118 /* Not a XENIX named type file */
|
||||
#define ENAVAIL 119 /* No XENIX semaphores available */
|
||||
#define EISNAM 120 /* Is a named type file */
|
||||
#define EREMOTEIO 121 /* Remote I/O error */
|
||||
#define EDQUOT 122 /* Quota exceeded */
|
||||
|
||||
#define ENOMEDIUM 123 /* No medium found */
|
||||
#define EMEDIUMTYPE 124 /* Wrong medium type */
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#else /* LWIP_PROVIDE_ERRNO */
|
||||
|
||||
/* Define LWIP_ERRNO_INCLUDE to <errno.h> to include the error defines here */
|
||||
#ifdef LWIP_ERRNO_INCLUDE
|
||||
//#include
|
||||
#endif /* LWIP_ERRNO_INCLUDE */
|
||||
|
||||
#endif /* LWIP_PROVIDE_ERRNO */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_ERRNO_H */
|
||||
/**
|
||||
* @file
|
||||
* Posix Errno defines
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* 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
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef LWIP_HDR_ERRNO_H
|
||||
#define LWIP_HDR_ERRNO_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_PROVIDE_ERRNO
|
||||
|
||||
#define EPERM 1 /* Operation not permitted */
|
||||
#define ENOENT 2 /* No such file or directory */
|
||||
#define ESRCH 3 /* No such process */
|
||||
#define EINTR 4 /* Interrupted system call */
|
||||
#define EIO 5 /* I/O error */
|
||||
#define ENXIO 6 /* No such device or address */
|
||||
#define E2BIG 7 /* Arg list too long */
|
||||
#define ENOEXEC 8 /* Exec format error */
|
||||
#define EBADF 9 /* Bad file number */
|
||||
#define ECHILD 10 /* No child processes */
|
||||
#define EAGAIN 11 /* Try again */
|
||||
#define ENOMEM 12 /* Out of memory */
|
||||
#define EACCES 13 /* Permission denied */
|
||||
#define EFAULT 14 /* Bad address */
|
||||
#define ENOTBLK 15 /* Block device required */
|
||||
#define EBUSY 16 /* Device or resource busy */
|
||||
#define EEXIST 17 /* File exists */
|
||||
#define EXDEV 18 /* Cross-device link */
|
||||
#define ENODEV 19 /* No such device */
|
||||
#define ENOTDIR 20 /* Not a directory */
|
||||
#define EISDIR 21 /* Is a directory */
|
||||
#define EINVAL 22 /* Invalid argument */
|
||||
#define ENFILE 23 /* File table overflow */
|
||||
#define EMFILE 24 /* Too many open files */
|
||||
#define ENOTTY 25 /* Not a typewriter */
|
||||
#define ETXTBSY 26 /* Text file busy */
|
||||
#define EFBIG 27 /* File too large */
|
||||
#define ENOSPC 28 /* No space left on device */
|
||||
#define ESPIPE 29 /* Illegal seek */
|
||||
#define EROFS 30 /* Read-only file system */
|
||||
#define EMLINK 31 /* Too many links */
|
||||
#define EPIPE 32 /* Broken pipe */
|
||||
#define EDOM 33 /* Math argument out of domain of func */
|
||||
#define ERANGE 34 /* Math result not representable */
|
||||
#define EDEADLK 35 /* Resource deadlock would occur */
|
||||
#define ENAMETOOLONG 36 /* File name too long */
|
||||
#define ENOLCK 37 /* No record locks available */
|
||||
#define ENOSYS 38 /* Function not implemented */
|
||||
#define ENOTEMPTY 39 /* Directory not empty */
|
||||
#define ELOOP 40 /* Too many symbolic links encountered */
|
||||
#define EWOULDBLOCK EAGAIN /* Operation would block */
|
||||
#define ENOMSG 42 /* No message of desired type */
|
||||
#define EIDRM 43 /* Identifier removed */
|
||||
#define ECHRNG 44 /* Channel number out of range */
|
||||
#define EL2NSYNC 45 /* Level 2 not synchronized */
|
||||
#define EL3HLT 46 /* Level 3 halted */
|
||||
#define EL3RST 47 /* Level 3 reset */
|
||||
#define ELNRNG 48 /* Link number out of range */
|
||||
#define EUNATCH 49 /* Protocol driver not attached */
|
||||
#define ENOCSI 50 /* No CSI structure available */
|
||||
#define EL2HLT 51 /* Level 2 halted */
|
||||
#define EBADE 52 /* Invalid exchange */
|
||||
#define EBADR 53 /* Invalid request descriptor */
|
||||
#define EXFULL 54 /* Exchange full */
|
||||
#define ENOANO 55 /* No anode */
|
||||
#define EBADRQC 56 /* Invalid request code */
|
||||
#define EBADSLT 57 /* Invalid slot */
|
||||
|
||||
#define EDEADLOCK EDEADLK
|
||||
|
||||
#define EBFONT 59 /* Bad font file format */
|
||||
#define ENOSTR 60 /* Device not a stream */
|
||||
#define ENODATA 61 /* No data available */
|
||||
#define ETIME 62 /* Timer expired */
|
||||
#define ENOSR 63 /* Out of streams resources */
|
||||
#define ENONET 64 /* Machine is not on the network */
|
||||
#define ENOPKG 65 /* Package not installed */
|
||||
#define EREMOTE 66 /* Object is remote */
|
||||
#define ENOLINK 67 /* Link has been severed */
|
||||
#define EADV 68 /* Advertise error */
|
||||
#define ESRMNT 69 /* Srmount error */
|
||||
#define ECOMM 70 /* Communication error on send */
|
||||
#define EPROTO 71 /* Protocol error */
|
||||
#define EMULTIHOP 72 /* Multihop attempted */
|
||||
#define EDOTDOT 73 /* RFS specific error */
|
||||
#define EBADMSG 74 /* Not a data message */
|
||||
#define EOVERFLOW 75 /* Value too large for defined data type */
|
||||
#define ENOTUNIQ 76 /* Name not unique on network */
|
||||
#define EBADFD 77 /* File descriptor in bad state */
|
||||
#define EREMCHG 78 /* Remote address changed */
|
||||
#define ELIBACC 79 /* Can not access a needed shared library */
|
||||
#define ELIBBAD 80 /* Accessing a corrupted shared library */
|
||||
#define ELIBSCN 81 /* .lib section in a.out corrupted */
|
||||
#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
|
||||
#define ELIBEXEC 83 /* Cannot exec a shared library directly */
|
||||
#define EILSEQ 84 /* Illegal byte sequence */
|
||||
#define ERESTART 85 /* Interrupted system call should be restarted */
|
||||
#define ESTRPIPE 86 /* Streams pipe error */
|
||||
#define EUSERS 87 /* Too many users */
|
||||
#define ENOTSOCK 88 /* Socket operation on non-socket */
|
||||
#define EDESTADDRREQ 89 /* Destination address required */
|
||||
#define EMSGSIZE 90 /* Message too long */
|
||||
#define EPROTOTYPE 91 /* Protocol wrong type for socket */
|
||||
#define ENOPROTOOPT 92 /* Protocol not available */
|
||||
#define EPROTONOSUPPORT 93 /* Protocol not supported */
|
||||
#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
|
||||
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
|
||||
#define EPFNOSUPPORT 96 /* Protocol family not supported */
|
||||
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
|
||||
#define EADDRINUSE 98 /* Address already in use */
|
||||
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
|
||||
#define ENETDOWN 100 /* Network is down */
|
||||
#define ENETUNREACH 101 /* Network is unreachable */
|
||||
#define ENETRESET 102 /* Network dropped connection because of reset */
|
||||
#define ECONNABORTED 103 /* Software caused connection abort */
|
||||
#define ECONNRESET 104 /* Connection reset by peer */
|
||||
#define ENOBUFS 105 /* No buffer space available */
|
||||
#define EISCONN 106 /* Transport endpoint is already connected */
|
||||
#define ENOTCONN 107 /* Transport endpoint is not connected */
|
||||
#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
|
||||
#define ETOOMANYREFS 109 /* Too many references: cannot splice */
|
||||
#define ETIMEDOUT 110 /* Connection timed out */
|
||||
#define ECONNREFUSED 111 /* Connection refused */
|
||||
#define EHOSTDOWN 112 /* Host is down */
|
||||
#define EHOSTUNREACH 113 /* No route to host */
|
||||
#define EALREADY 114 /* Operation already in progress */
|
||||
#define EINPROGRESS 115 /* Operation now in progress */
|
||||
#define ESTALE 116 /* Stale NFS file handle */
|
||||
#define EUCLEAN 117 /* Structure needs cleaning */
|
||||
#define ENOTNAM 118 /* Not a XENIX named type file */
|
||||
#define ENAVAIL 119 /* No XENIX semaphores available */
|
||||
#define EISNAM 120 /* Is a named type file */
|
||||
#define EREMOTEIO 121 /* Remote I/O error */
|
||||
#define EDQUOT 122 /* Quota exceeded */
|
||||
|
||||
#define ENOMEDIUM 123 /* No medium found */
|
||||
#define EMEDIUMTYPE 124 /* Wrong medium type */
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#else /* LWIP_PROVIDE_ERRNO */
|
||||
|
||||
/* Define LWIP_ERRNO_INCLUDE to <errno.h> to include the error defines here */
|
||||
#ifdef LWIP_ERRNO_INCLUDE
|
||||
//#include
|
||||
#endif /* LWIP_ERRNO_INCLUDE */
|
||||
|
||||
#endif /* LWIP_PROVIDE_ERRNO */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_ERRNO_H */
|
||||
@@ -34,11 +34,14 @@
|
||||
#define LIBZT_DEBUG_HPP
|
||||
|
||||
#include <pthread.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <cstring>
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <sys/syscall.h>
|
||||
#endif
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#define ZT_MSG_ERROR true // Errors
|
||||
@@ -53,7 +56,7 @@
|
||||
#if defined(__APPLE__)
|
||||
#include "TargetConditionals.h"
|
||||
#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_GRN "\x1B[32m"
|
||||
#define ZT_YEL "\x1B[33m"
|
||||
@@ -88,6 +91,9 @@ extern unsigned int gettid(); // defined in libzt.cpp
|
||||
#elif __APPLE__
|
||||
#define ZT_THREAD_ID (long)0//(long)gettid()
|
||||
#endif
|
||||
#ifdef __MINGW32__
|
||||
#define ZT_THREAD_ID (long)0
|
||||
#endif
|
||||
|
||||
#if defined(__JNI_LIB__)
|
||||
#include <jni.h>
|
||||
|
||||
@@ -48,7 +48,9 @@
|
||||
*/
|
||||
#define ZTO_ID_LEN 16
|
||||
|
||||
#if !defined(__MINGW32__)
|
||||
typedef uint32_t socklen_t;
|
||||
#endif
|
||||
|
||||
/****************************************************************************/
|
||||
/* For SOCK_RAW support, it will initially be modeled after linux's API, so */
|
||||
|
||||
@@ -35,6 +35,17 @@
|
||||
|
||||
#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
|
||||
*
|
||||
@@ -62,7 +73,7 @@ char *beautify_eth_proto_nums(int proto);
|
||||
* @param inet
|
||||
* @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
|
||||
|
||||
@@ -103,7 +103,7 @@ void disableTaps();
|
||||
* @param addrlen
|
||||
* @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
|
||||
@@ -114,7 +114,7 @@ void zts_get_ipv4_address(const char *nwid, char *addrstr, const int addrlen);
|
||||
* @param addrlen
|
||||
* @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
|
||||
@@ -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
|
||||
* come online.
|
||||
* @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
|
||||
@@ -211,15 +211,15 @@ void zts_start(const char *path);
|
||||
* come online.
|
||||
* @param path
|
||||
* @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)
|
||||
*
|
||||
* @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();
|
||||
|
||||
@@ -231,7 +231,7 @@ void zts_stop();
|
||||
* @param len
|
||||
* @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
|
||||
|
||||
@@ -33,11 +33,14 @@
|
||||
#ifndef LIBZT_H
|
||||
#define LIBZT_H
|
||||
|
||||
#include <poll.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <poll.h>
|
||||
#endif
|
||||
|
||||
#include "Debug.hpp"
|
||||
#include "Defs.h"
|
||||
|
||||
@@ -50,7 +53,6 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
// forward declarations from ZT1Service.h
|
||||
void zts_simple_start(const char *path, const char *nwid);
|
||||
int zts_get_device_id(char *devID);
|
||||
|
||||
void init_network_stack();
|
||||
@@ -68,7 +70,7 @@ void init_network_stack();
|
||||
* @param nwid A 16-digit hexidecimal network identifier (e.g. Earth: `8056c2e21c000001`)
|
||||
* @return 0 if successful; or 1 if failed
|
||||
*/
|
||||
void zts_start(const char *path);
|
||||
int zts_start(const char *path);
|
||||
|
||||
/**
|
||||
* @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`)
|
||||
* @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
|
||||
@@ -140,7 +142,7 @@ void zts_leave_soft(const char * filepath, const char * nwid);
|
||||
* @param len
|
||||
* @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)
|
||||
@@ -195,7 +197,7 @@ int zts_has_address(const char *nwid);
|
||||
* @param addrlen
|
||||
* @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
|
||||
@@ -206,7 +208,7 @@ void zts_get_ipv4_address(const char *nwid, char *addrstr, const int addrlen);
|
||||
* @param addrlen
|
||||
* @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
|
||||
@@ -440,7 +442,9 @@ int zts_close(int fd);
|
||||
* @param timeout
|
||||
* @return
|
||||
*/
|
||||
#if defined(__linux__)
|
||||
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"
|
||||
|
||||
@@ -60,12 +60,12 @@ void lwip_dns_init();
|
||||
* @usage lwip_driver_init()
|
||||
* @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);
|
||||
|
||||
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.
|
||||
|
||||
@@ -32,21 +32,38 @@
|
||||
#
|
||||
|
||||
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
|
||||
|
||||
CCDEP=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
|
||||
ifeq ($(origin CCX),default)
|
||||
CCX=$(shell if [ -e /usr/bin/clang++ ]; then echo clang++; else echo g++; fi)
|
||||
ifeq ($(origin CXX),default)
|
||||
CXX=$(shell if [ -e /usr/bin/clang++ ]; then echo clang++; else echo g++; fi)
|
||||
endif
|
||||
|
||||
LWIPINCLUDES:=-I$(LWIPDIR)/include -I$(LWIPARCH) -I$(LWIPDIR) -I. -Iext -Iinclude
|
||||
CFLAGS=-Wno-format -Wno-deprecated -O3 -g -Wall -fPIC
|
||||
OSTYPE=$(shell uname -s | tr '[A-Z]' '[a-z]')
|
||||
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)
|
||||
|
||||
UNIXLIB=liblwip.a
|
||||
@@ -63,8 +80,6 @@ LWIPNOAPPSFILES+=$(ARCHFILES)
|
||||
LWIPNOAPPSFILESW=$(wildcard $(LWIPNOAPPSFILES))
|
||||
LWIPNOAPPSOBJS=$(notdir $(LWIPNOAPPSFILESW:.c=.o))
|
||||
|
||||
CCX=clang++
|
||||
|
||||
%.o:
|
||||
$(CCX) $(CFLAGS) -c $(<:.o=.c)
|
||||
|
||||
|
||||
@@ -53,7 +53,8 @@ void handle_general_failure() {
|
||||
inline unsigned int gettid()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return GetCurrentThreadId();
|
||||
//return GetCurrentThreadId();
|
||||
return 0;
|
||||
#elif defined(__linux__)
|
||||
return static_cast<unsigned int>(syscall(__NR_gettid));
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
@@ -32,6 +32,171 @@
|
||||
|
||||
#include "InetAddress.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)
|
||||
{
|
||||
@@ -120,6 +285,7 @@ bool ipv6_in_subnet(ZeroTier::InetAddress *subnet, ZeroTier::InetAddress *addr)
|
||||
return !strcmp(r.toIpString(b0), b.toIpString(b1));
|
||||
}
|
||||
|
||||
/*
|
||||
void sockaddr2inet(int socket_family, const struct sockaddr *addr, ZeroTier::InetAddress *inet)
|
||||
{
|
||||
char ipstr[INET6_ADDRSTRLEN];
|
||||
@@ -137,6 +303,7 @@ void sockaddr2inet(int socket_family, const struct sockaddr *addr, ZeroTier::Ine
|
||||
inet->fromString(addrstr);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void mac2str(char *macbuf, int len, unsigned char* addr)
|
||||
{
|
||||
|
||||
@@ -34,7 +34,10 @@
|
||||
#define ZT_VIRTUALSOCKET_HPP
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#include "VirtualSocket.h"
|
||||
#include "VirtualBindingPair.h"
|
||||
|
||||
@@ -84,6 +84,7 @@ namespace ZeroTier {
|
||||
_handler(handler),
|
||||
_homePath(homePath),
|
||||
_arg(arg),
|
||||
_initialized(false),
|
||||
_enabled(true),
|
||||
_run(true),
|
||||
_mac(mac),
|
||||
@@ -421,7 +422,7 @@ namespace ZeroTier {
|
||||
target_addr = managed_routes->at(i).target;
|
||||
via_addr = managed_routes->at(i).via;
|
||||
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)) {
|
||||
found=true;
|
||||
continue;
|
||||
@@ -439,7 +440,7 @@ namespace ZeroTier {
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
for (int j=0; j<ZT_MAX_NETWORK_ROUTES; j++) {
|
||||
target_addr = managed_routes->at(j).target;
|
||||
|
||||
@@ -41,6 +41,13 @@
|
||||
#include "Thread.hpp"
|
||||
#include "Phy.hpp"
|
||||
|
||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||
#include <WinSock2.h>
|
||||
#include <Windows.h>
|
||||
#include <IPHlpApi.h>
|
||||
#include <Ifdef.h>
|
||||
#endif
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
/**
|
||||
@@ -119,6 +126,20 @@ namespace ZeroTier {
|
||||
void threadMain()
|
||||
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
|
||||
*/
|
||||
@@ -185,13 +206,14 @@ namespace ZeroTier {
|
||||
char vtap_abbr_name[16];
|
||||
|
||||
static int devno;
|
||||
int ifindex = 0;
|
||||
size_t ifindex = 0;
|
||||
|
||||
std::vector<InetAddress> ips() const;
|
||||
std::vector<InetAddress> _ips;
|
||||
|
||||
std::string _homePath;
|
||||
void *_arg;
|
||||
volatile bool _initialized;
|
||||
volatile bool _enabled;
|
||||
volatile bool _run;
|
||||
MAC _mac;
|
||||
|
||||
@@ -55,6 +55,10 @@ namespace ZeroTier {
|
||||
ZeroTier::Mutex _multiplexer_lock;
|
||||
}
|
||||
|
||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||
WSADATA wsaData;
|
||||
#endif
|
||||
|
||||
/****************************************************************************/
|
||||
/* 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::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];
|
||||
if (s->_nwid == nwid) { tap = s; }
|
||||
}
|
||||
@@ -82,7 +86,7 @@ ZeroTier::VirtualTap *getTapByAddr(ZeroTier::InetAddress *addr)
|
||||
ZeroTier::_vtaps_lock.lock();
|
||||
ZeroTier::VirtualTap *s, *tap = nullptr;
|
||||
//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];
|
||||
// check address schemes
|
||||
for (int j=0; j<s->_ips.size(); j++) {
|
||||
@@ -104,7 +108,7 @@ ZeroTier::VirtualTap *getTapByAddr(ZeroTier::InetAddress *addr)
|
||||
if (tap == NULL) {
|
||||
std::vector<ZT_VirtualNetworkRoute> *managed_routes = ZeroTier::zt1Service->getRoutes(s->_nwid);
|
||||
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;
|
||||
nm = target.netmask();
|
||||
via = managed_routes->at(i).via;
|
||||
@@ -124,7 +128,7 @@ ZeroTier::VirtualTap *getTapByName(char *ifname)
|
||||
{
|
||||
ZeroTier::_vtaps_lock.lock();
|
||||
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];
|
||||
if (strcmp(s->_dev.c_str(), ifname) == false) {
|
||||
tap = s;
|
||||
@@ -134,11 +138,11 @@ ZeroTier::VirtualTap *getTapByName(char *ifname)
|
||||
return tap;
|
||||
}
|
||||
|
||||
ZeroTier::VirtualTap *getTapByIndex(int index)
|
||||
ZeroTier::VirtualTap *getTapByIndex(size_t index)
|
||||
{
|
||||
ZeroTier::_vtaps_lock.lock();
|
||||
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];
|
||||
if (s->ifindex == index) {
|
||||
tap = s;
|
||||
@@ -247,20 +251,20 @@ void *zts_start_service(void *thread_id)
|
||||
void disableTaps()
|
||||
{
|
||||
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]);
|
||||
((ZeroTier::VirtualTap*)ZeroTier::vtaps[i])->_enabled = false;
|
||||
}
|
||||
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) {
|
||||
uint64_t nwid_int = strtoull(nwid, NULL, 16);
|
||||
ZeroTier::VirtualTap *tap = getTapByNWID(nwid_int);
|
||||
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()) {
|
||||
char ipbuf[INET_ADDRSTRLEN];
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
uint64_t nwid_int = strtoull(nwid, NULL, 16);
|
||||
ZeroTier::VirtualTap *tap = getTapByNWID(nwid_int);
|
||||
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()) {
|
||||
char ipbuf[INET6_ADDRSTRLEN];
|
||||
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
|
||||
// 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];
|
||||
s->zt1ServiceRef=(void*)ZeroTier::zt1Service;
|
||||
}
|
||||
@@ -387,21 +391,24 @@ int zts_running() {
|
||||
return ZeroTier::zt1Service == NULL ? false : ZeroTier::zt1Service->isRunning();
|
||||
}
|
||||
|
||||
void zts_start(const char *path)
|
||||
int zts_start(const char *path)
|
||||
{
|
||||
if (ZeroTier::zt1Service) {
|
||||
return;
|
||||
return 0; // already initialized, ok
|
||||
}
|
||||
if (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_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) {
|
||||
DEBUG_EXTRA("waiting for service to start");
|
||||
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) {
|
||||
nanosleep((const struct timespec[]) {{0, (ZTO_WRAPPER_CHECK_INTERVAL * 1000000)}}, NULL);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
void zts_stop() {
|
||||
@@ -426,12 +434,15 @@ void zts_stop() {
|
||||
ZeroTier::zt1Service->terminate();
|
||||
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()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -470,7 +481,7 @@ int zts_get_peer_address(char *peer, const char *devID) {
|
||||
if (ZeroTier::zt1Service) {
|
||||
ZT_PeerList *pl = ZeroTier::zt1Service->getNode()->peers();
|
||||
// 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]);
|
||||
// DEBUG_INFO("peer[%d] = %lx", i, p->address);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ void sys2lwip(int fd, const struct sockaddr *orig, struct sockaddr *modified)
|
||||
}
|
||||
#if defined(LIBZT_IPV4)
|
||||
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 *addr4 = (struct sockaddr_in*)orig;
|
||||
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 (ss.ss_family == AF_INET6) {
|
||||
#if defined(__linux__)
|
||||
#if defined(__linux__) || defined(__MINGW32__)
|
||||
struct sockaddr_in6 *p6 = (struct sockaddr_in6 *)modified;
|
||||
struct sockaddr_in6 *addr6 = (struct sockaddr_in6*)orig;
|
||||
p6->sin6_len = sizeof(struct sockaddr_in6);
|
||||
@@ -311,6 +311,7 @@ int zts_close(int fd)
|
||||
return err;
|
||||
}
|
||||
|
||||
#if defined(__linux__)
|
||||
int zts_poll(struct pollfd *fds, nfds_t nfds, int timeout)
|
||||
{
|
||||
int err = -1;
|
||||
@@ -324,6 +325,7 @@ int zts_poll(struct pollfd *fds, nfds_t nfds, int timeout)
|
||||
#endif
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
int zts_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
||||
struct timeval *timeout)
|
||||
|
||||
11
src/lwIP.cpp
11
src/lwIP.cpp
@@ -115,6 +115,9 @@ void lwip_driver_init()
|
||||
if (lwip_driver_initialized == true) {
|
||||
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,
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
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
|
||||
}
|
||||
|
||||
void general_turn_on_interface(struct netif *interface)
|
||||
void general_turn_on_interface(void *netif)
|
||||
{
|
||||
//netif_set_up(&n1);
|
||||
//netif_set_default(&n1);
|
||||
@@ -206,9 +209,9 @@ void lwip_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)
|
||||
|
||||
2
zto
2
zto
Submodule zto updated: 59b7cbb591...f2c69ede96
Reference in New Issue
Block a user