LWIP 2.0.0 adaptations, formatted debug outputs
This commit is contained in:
112
attic/make-liblwip.mk
Normal file
112
attic/make-liblwip.mk
Normal file
@@ -0,0 +1,112 @@
|
||||
#
|
||||
# Copyright (c) 2001, 2002 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>
|
||||
#
|
||||
|
||||
CONTRIBDIR=ext/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=gcc
|
||||
CC=gcc
|
||||
CFLAGS=-O3 -g -Wall -DIPv4 -fPIC
|
||||
|
||||
# Debug output for lwIP
|
||||
ifeq ($(SDK_LWIP_DEBUG),1)
|
||||
CFLAGS+=-DLWIP_DEBUG
|
||||
endif
|
||||
|
||||
CFLAGS:=$(CFLAGS) \
|
||||
-I$(LWIPDIR)/include -I$(LWIPARCH)/include -I$(LWIPDIR)/include/ipv4 \
|
||||
-I$(LWIPDIR) -I.
|
||||
|
||||
|
||||
# COREFILES, CORE4FILES: The minimum set of files needed for lwIP.
|
||||
COREFILES=$(LWIPDIR)/core/mem.c $(LWIPDIR)/core/memp.c $(LWIPDIR)/core/netif.c \
|
||||
$(LWIPDIR)/core/pbuf.c $(LWIPDIR)/core/raw.c $(LWIPDIR)/core/stats.c \
|
||||
$(LWIPDIR)/core/sys.c $(LWIPDIR)/core/tcp.c $(LWIPDIR)/core/tcp_in.c \
|
||||
$(LWIPDIR)/core/tcp_out.c $(LWIPDIR)/core/udp.c \
|
||||
# $(LWIPDIR)/core/dhcp.c \
|
||||
$(LWIPDIR)/core/init.c $(LWIPDIR)/core/timers.c $(LWIPDIR)/core/def.c
|
||||
CORE4FILES=$(wildcard $(LWIPDIR)/core/ipv4/*.c) $(LWIPDIR)/core/ipv4/inet.c \
|
||||
$(LWIPDIR)/core/ipv4/inet_chksum.c
|
||||
|
||||
# SNMPFILES: Extra SNMPv1 agent
|
||||
SNMPFILES=$(LWIPDIR)/core/snmp/asn1_dec.c $(LWIPDIR)/core/snmp/asn1_enc.c \
|
||||
$(LWIPDIR)/core/snmp/mib2.c $(LWIPDIR)/core/snmp/mib_structs.c \
|
||||
$(LWIPDIR)/core/snmp/msg_in.c $(LWIPDIR)/core/snmp/msg_out.c
|
||||
|
||||
# APIFILES: The files which implement the sequential and socket APIs.
|
||||
APIFILES=$(LWIPDIR)/api/api_lib.c $(LWIPDIR)/api/api_msg.c $(LWIPDIR)/api/tcpip.c \
|
||||
$(LWIPDIR)/api/err.c $(LWIPDIR)/api/sockets.c $(LWIPDIR)/api/netbuf.c $(LWIPDIR)/api/netdb.c
|
||||
|
||||
# NETIFFILES: Files implementing various generic network interface functions.'
|
||||
NETIFFILES=$(LWIPDIR)/netif/etharp.c $(LWIPDIR)/netif/slipif.c
|
||||
|
||||
# NETIFFILES: Add PPP netif
|
||||
NETIFFILES+=$(LWIPDIR)/netif/ppp/auth.c $(LWIPDIR)/netif/ppp/chap.c \
|
||||
$(LWIPDIR)/netif/ppp/chpms.c $(LWIPDIR)/netif/ppp/fsm.c \
|
||||
$(LWIPDIR)/netif/ppp/ipcp.c $(LWIPDIR)/netif/ppp/lcp.c \
|
||||
$(LWIPDIR)/netif/ppp/magic.c $(LWIPDIR)/netif/ppp/md5.c \
|
||||
$(LWIPDIR)/netif/ppp/pap.c $(LWIPDIR)/netif/ppp/ppp.c \
|
||||
$(LWIPDIR)/netif/ppp/randm.c $(LWIPDIR)/netif/ppp/vj.c
|
||||
|
||||
# ARCHFILES: Architecture specific files.
|
||||
ARCHFILES=$(wildcard $(LWIPARCH)/*.c $(LWIPARCH)tapif.c $(LWIPARCH)/netif/list.c $(LWIPARCH)/netif/tcpdump.c)
|
||||
|
||||
# LWIPFILES: All the above.
|
||||
LWIPFILES=$(COREFILES) $(CORE4FILES) $(SNMPFILES) $(APIFILES) $(NETIFFILES) $(ARCHFILES)
|
||||
LWIPFILESW=$(wildcard $(LWIPFILES))
|
||||
LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o))
|
||||
|
||||
LWIPLIB=liblwip.so
|
||||
|
||||
%.o:
|
||||
$(CC) $(CFLAGS) -c $(<:.o=.c)
|
||||
|
||||
all: $(LWIPLIB)
|
||||
.PHONY: all
|
||||
|
||||
clean:
|
||||
rm -f *.o $(LWIPLIB) *.s .depend* *.core core
|
||||
|
||||
depend dep: .depend
|
||||
|
||||
include .depend
|
||||
|
||||
$(LWIPLIB): $(LWIPOBJS)
|
||||
mkdir -p build
|
||||
$(CC) -g -nostartfiles -shared -o build/$@ $^
|
||||
|
||||
.depend: $(LWIPFILES)
|
||||
$(CCDEP) $(CFLAGS) -MM $^ > .depend || rm -f .depend
|
||||
24
docs/api_discussion.md
Normal file
24
docs/api_discussion.md
Normal file
@@ -0,0 +1,24 @@
|
||||
ZTSDK API Options
|
||||
====
|
||||
|
||||
*This document is under construction*
|
||||
|
||||
## APIs
|
||||
|
||||
**Hook/Intercept**
|
||||
- Uses dynamic loading of our library to allow function interposition or "hooking" to re-implement traditional socket API functions like `socket()`, `connect()`, `bind()`, etc.
|
||||
|
||||
**SOCKS5 Proxy**
|
||||
- Provides an integrated SOCKS5 server alongside the ZeroTier service to proxy connections from an application to resources on a ZeroTier network. For instance, a developer which has built an iOS app using the NSStreams API could add ZeroTier to their application and simply use the SOCKS5 support build into NSStreams to reach resources on their network. An Android developer could do the same using the SOCKS5 support provided in the `Socket` API.
|
||||
|
||||
**Direct Call**
|
||||
- Directly call the `zt_` API specified in [SDK.h](src/SDK.h). For this to work, just use one of the provided headers that specify the interface for your system/architecture and then either dynamically-load our library into your app or compile it right in.
|
||||
|
||||
***
|
||||

|
||||
|
||||
|
||||
The following APIs are available for this integration:
|
||||
- `Direct Call`: Consult [src/SDK_Apple-Bridging-Header.h](../../../../src/SDK_Apple-Bridging-Header.h).
|
||||
- `Hook of BSD-like sockets`: Use BSD-like sockets as you normally would.
|
||||
- `Proxy of NSStream`: Create NSStream. Configure stream for SOCKS5 Proxy (127.0.0.1:PORT). Start Proxy. Use stream. An example of how to use the proxy can be found in the example iOS/OSX projects.
|
||||
@@ -38,6 +38,27 @@
|
||||
#define MSG_EXTRA 4 // If nothing in your world makes sense
|
||||
|
||||
#define __SHOW_FILENAMES__ true
|
||||
#define __SHOW_COLOR__ true
|
||||
|
||||
#if defined(__SHOW_COLOR__)
|
||||
#define RED "\x1B[31m"
|
||||
#define GRN "\x1B[32m"
|
||||
#define YEL "\x1B[33m"
|
||||
#define BLU "\x1B[34m"
|
||||
#define MAG "\x1B[35m"
|
||||
#define CYN "\x1B[36m"
|
||||
#define WHT "\x1B[37m"
|
||||
#define RESET "\x1B[0m"
|
||||
#else
|
||||
#define RED
|
||||
#define GRN
|
||||
#define YEL
|
||||
#define BLU
|
||||
#define MAG
|
||||
#define CYN
|
||||
#define WHT
|
||||
#define RESET
|
||||
#endif
|
||||
|
||||
// filenames
|
||||
#if __SHOW_FILENAMES__
|
||||
@@ -62,17 +83,18 @@ extern "C" {
|
||||
|
||||
//#if defined(SDK_DEBUG)
|
||||
#if DEBUG_LEVEL >= MSG_ERROR
|
||||
#define DEBUG_ERROR(fmt, args...) fprintf(stderr, "ZT_ERROR: %s:%d:%s(): " fmt "\n", __FILENAME__, __LINE__, __FUNCTION__, ##args)
|
||||
#define DEBUG_ERROR(fmt, args...) fprintf(stderr, RED"ZT_ERROR: %20s:%4d:%20s: " fmt "\n"RESET, __FILENAME__, __LINE__, __FUNCTION__, ##args)
|
||||
#else
|
||||
#define DEBUG_ERROR(fmt, args...)
|
||||
#endif
|
||||
#if DEBUG_LEVEL >= MSG_INFO
|
||||
#if defined(__ANDROID__)
|
||||
#define DEBUG_INFO(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "ZT_INFO : %s:%d:%s(): " fmt "\n", __FILENAME__, __LINE__, __FUNCTION__, ##args))
|
||||
#define DEBUG_BLANK(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "ZT_INFO : %s:%d:" fmt "\n", __FILENAME__, __LINE__, __FUNCTION__, ##args))
|
||||
#define DEBUG_INFO(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "ZT_INFO : %20s:%4d:%20s: " fmt "\n", __FILENAME__, __LINE__, __FUNCTION__, ##args))
|
||||
#define DEBUG_BLANK(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "ZT_INFO : %20s:%4d:" fmt "\n", __FILENAME__, __LINE__, __FUNCTION__, ##args))
|
||||
#else
|
||||
#define DEBUG_INFO(fmt, args...) fprintf(stderr, "ZT_INFO : %s:%d:%s(): " fmt "\n", __FILENAME__, __LINE__, __FUNCTION__, ##args)
|
||||
#define DEBUG_BLANK(fmt, args...) fprintf(stderr, "ZT_INFO : %s:%d:" fmt "\n", __FILENAME__, __LINE__, ##args)
|
||||
#define DEBUG_INFO(fmt, args...) fprintf(stderr, "ZT_INFO : %20s:%4d:%20s: " fmt "\n", __FILENAME__, __LINE__, __FUNCTION__, ##args)
|
||||
#define DEBUG_ATTN(fmt, args...) fprintf(stderr, CYN"ZT_INFO : %20s:%4d:%20s: " fmt "\n"RESET, __FILENAME__, __LINE__, __FUNCTION__, ##args)
|
||||
#define DEBUG_BLANK(fmt, args...) fprintf(stderr, "ZT_INFO : %20s:%4d:" fmt "\n", __FILENAME__, __LINE__, ##args)
|
||||
#endif
|
||||
#else
|
||||
#define DEBUG_INFO(fmt, args...)
|
||||
@@ -80,18 +102,18 @@ extern "C" {
|
||||
#endif
|
||||
#if DEBUG_LEVEL >= MSG_TRANSFER
|
||||
#if defined(__ANDROID__)
|
||||
#define DEBUG_TRANS(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "ZT_TRANS : %s:%d:%s(): " fmt "\n", __FILENAME__, __LINE__, __FUNCTION__, ##args))
|
||||
#define DEBUG_TRANS(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "ZT_TRANS : %20s:%4d:%20s: " fmt "\n", __FILENAME__, __LINE__, __FUNCTION__, ##args))
|
||||
#else
|
||||
#define DEBUG_TRANS(fmt, args...) fprintf(stderr, "ZT_TRANS: %s:%d:%s(): " fmt "\n", __FILENAME__, __LINE__, __FUNCTION__, ##args)
|
||||
#define DEBUG_TRANS(fmt, args...) fprintf(stderr, GRN"ZT_TRANS: %20s:%4d:%20s: " fmt "\n"RESET, __FILENAME__, __LINE__, __FUNCTION__, ##args)
|
||||
#endif
|
||||
#else
|
||||
#define DEBUG_TRANS(fmt, args...)
|
||||
#endif
|
||||
#if DEBUG_LEVEL >= MSG_EXTRA
|
||||
#if defined(__ANDROID__)
|
||||
#define DEBUG_EXTRA(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "ZT_EXTRA : %s:%d:%s(): " fmt "\n", __FILENAME__, __LINE__, __FUNCTION__, ##args))
|
||||
#define DEBUG_EXTRA(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "ZT_EXTRA : %20s:%4d:%20s: " fmt "\n", __FILENAME__, __LINE__, __FUNCTION__, ##args))
|
||||
#else
|
||||
#define DEBUG_EXTRA(fmt, args...) fprintf(stderr, "ZT_EXTRA: %s:%d:%s(): " fmt "\n", __FILENAME__, __LINE__, __FUNCTION__, ##args)
|
||||
#define DEBUG_EXTRA(fmt, args...) fprintf(stderr, "ZT_EXTRA: %20s:%4d:%20s: " fmt "\n", __FILENAME__, __LINE__, __FUNCTION__, ##args)
|
||||
#endif
|
||||
#else
|
||||
#define DEBUG_EXTRA(fmt, args...)
|
||||
|
||||
@@ -44,13 +44,19 @@
|
||||
|
||||
#include "SDK_LWIPStack.hpp"
|
||||
|
||||
//#include "lwip/tcp_impl.h"
|
||||
#include "lwip/priv/tcp_priv.h"
|
||||
// LWIP
|
||||
#if defined(LWIP_VERSION_2)
|
||||
//#define LWIPDIR "ext/lwip_2.0.0"
|
||||
#include "lwip/priv/tcp_priv.h"
|
||||
#elif defined (LWIP_VERSION_1)
|
||||
//#define LWIPDIR "ext/lwip_1.4.1"
|
||||
#include "lwip/tcp_impl.h"
|
||||
#include "lwip/ip_frag.h"
|
||||
#endif
|
||||
#include "netif/etharp.h"
|
||||
#include "lwip/api.h"
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
//#include "lwip/ip_frag.h"
|
||||
#include "lwip/tcp.h"
|
||||
#include "lwip/init.h"
|
||||
#include "lwip/mem.h"
|
||||
@@ -61,6 +67,7 @@
|
||||
#include "lwip/tcp.h"
|
||||
|
||||
|
||||
|
||||
#include "SDK.h"
|
||||
#include "SDK_Debug.h"
|
||||
|
||||
@@ -259,7 +266,6 @@ void NetconEthernetTap::put(const MAC &from,const MAC &to,unsigned int etherType
|
||||
struct pbuf *p,*q;
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
struct eth_hdr ethhdr;
|
||||
from.copyTo(ethhdr.src.addr, 6);
|
||||
to.copyTo(ethhdr.dest.addr, 6);
|
||||
@@ -549,11 +555,11 @@ void NetconEthernetTap::phyOnUnixData(PhySocket *sock, void **uptr, void *data,
|
||||
if(detected_rpc) {
|
||||
unloadRPC(data, pid, tid, timestamp, CANARY, cmd, payload);
|
||||
memcpy(&CANARY_num, CANARY, CANARY_SZ);
|
||||
DEBUG_EXTRA(" <sock=%p> RPC: (pid=%d, tid=%d, timestamp=%s, cmd=%d)",
|
||||
DEBUG_EXTRA(" RPC: sock=%p, (pid=%d, tid=%d, timestamp=%s, cmd=%d)",
|
||||
(void*)&sock, pid, tid, timestamp, cmd);
|
||||
|
||||
if(cmd == RPC_SOCKET) {
|
||||
DEBUG_INFO(" <sock=%p> RPC_SOCKET", (void*)&sock);
|
||||
DEBUG_INFO(" RPC_SOCKET, sock=%p", (void*)&sock);
|
||||
// Create new lwip socket and associate it with this sock
|
||||
struct socket_st socket_rpc;
|
||||
memcpy(&socket_rpc, &buf[IDX_PAYLOAD+STRUCT_IDX], sizeof(struct socket_st));
|
||||
@@ -581,7 +587,7 @@ void NetconEthernetTap::phyOnUnixData(PhySocket *sock, void **uptr, void *data,
|
||||
// Find job
|
||||
sockdata = jobmap[CANARY_num];
|
||||
if(!sockdata.first) {
|
||||
DEBUG_ERROR(" <sock=%p> unable to locate job entry for %llu", (void*)&sock, CANARY_num);
|
||||
DEBUG_ERROR(" unable to locate job entry for %llu, sock=%p", CANARY_num, (void*)&sock);
|
||||
return;
|
||||
} else
|
||||
foundJob = true;
|
||||
@@ -643,36 +649,36 @@ void NetconEthernetTap::phyOnUnixData(PhySocket *sock, void **uptr, void *data,
|
||||
rpcSock = sockdata.first;
|
||||
buf = (unsigned char*)sockdata.second;
|
||||
unloadRPC(buf, pid, tid, timestamp, CANARY, cmd, payload);
|
||||
DEBUG_EXTRA(" <sock=%p> RPC: (pid=%d, tid=%d, timestamp=%s, cmd=%d)",
|
||||
DEBUG_EXTRA(" RPC: sock=%p, (pid=%d, tid=%d, timestamp=%s, cmd=%d)",
|
||||
(void*)&sock, pid, tid, timestamp, cmd);
|
||||
|
||||
switch(cmd) {
|
||||
case RPC_BIND:
|
||||
DEBUG_INFO(" <sock=%p> RPC_BIND", (void*)&sock);
|
||||
DEBUG_INFO(" RPC_BIND, sock=%p", (void*)&sock);
|
||||
struct bind_st bind_rpc;
|
||||
memcpy(&bind_rpc, &buf[IDX_PAYLOAD+STRUCT_IDX], sizeof(struct bind_st));
|
||||
handleBind(sock, rpcSock, uptr, &bind_rpc);
|
||||
break;
|
||||
case RPC_LISTEN:
|
||||
DEBUG_INFO(" <sock=%p> RPC_LISTEN", (void*)&sock);
|
||||
DEBUG_INFO(" RPC_LISTEN, sock=%p", (void*)&sock);
|
||||
struct listen_st listen_rpc;
|
||||
memcpy(&listen_rpc, &buf[IDX_PAYLOAD+STRUCT_IDX], sizeof(struct listen_st));
|
||||
handleListen(sock, rpcSock, uptr, &listen_rpc);
|
||||
break;
|
||||
case RPC_GETSOCKNAME:
|
||||
DEBUG_INFO(" <sock=%p> RPC_GETSOCKNAME", (void*)&sock);
|
||||
DEBUG_INFO(" RPC_GETSOCKNAME, sock=%p", (void*)&sock);
|
||||
struct getsockname_st getsockname_rpc;
|
||||
memcpy(&getsockname_rpc, &buf[IDX_PAYLOAD+STRUCT_IDX], sizeof(struct getsockname_st));
|
||||
handleGetsockname(sock, rpcSock, uptr, &getsockname_rpc);
|
||||
break;
|
||||
case RPC_GETPEERNAME:
|
||||
DEBUG_INFO(" <sock=%p> RPC_GETPEERNAME", (void*)&sock);
|
||||
DEBUG_INFO(" RPC_GETPEERNAME, sock=%p", (void*)&sock);
|
||||
struct getsockname_st getpeername_rpc;
|
||||
memcpy(&getpeername_rpc, &buf[IDX_PAYLOAD+STRUCT_IDX], sizeof(struct getsockname_st));
|
||||
handleGetpeername(sock, rpcSock, uptr, &getpeername_rpc);
|
||||
break;
|
||||
case RPC_CONNECT:
|
||||
DEBUG_INFO(" <sock=%p> RPC_CONNECT", (void*)&sock);
|
||||
DEBUG_INFO(" RPC_CONNECT, sock=%p", (void*)&sock);
|
||||
struct connect_st connect_rpc;
|
||||
memcpy(&connect_rpc, &buf[IDX_PAYLOAD+STRUCT_IDX], sizeof(struct connect_st));
|
||||
handleConnect(sock, rpcSock, conn, &connect_rpc);
|
||||
@@ -725,7 +731,7 @@ void NetconEthernetTap::unloadRPC(void *data, pid_t &pid, pid_t &tid,
|
||||
|
||||
err_t NetconEthernetTap::nc_accept(void *arg, struct tcp_pcb *newPCB, err_t err)
|
||||
{
|
||||
DEBUG_INFO("pcb=%p", (void*)&newPCB);
|
||||
DEBUG_ATTN("pcb=%p", (void*)&newPCB);
|
||||
Larg *l = (Larg*)arg;
|
||||
Mutex::Lock _l(l->tap->_tcpconns_m);
|
||||
Connection *conn = l->conn;
|
||||
@@ -903,7 +909,7 @@ err_t NetconEthernetTap::nc_connected_proxy(void *arg, struct tcp_pcb *PCB, err_
|
||||
|
||||
err_t NetconEthernetTap::nc_connected(void *arg, struct tcp_pcb *PCB, err_t err)
|
||||
{
|
||||
DEBUG_INFO("pcb=%p", (void*)&PCB);
|
||||
DEBUG_ATTN("pcb=%p", (void*)&PCB);
|
||||
Larg *l = (Larg*)arg;
|
||||
if(l && l->conn)
|
||||
l->tap->sendReturnValue(l->tap->_phy.getDescriptor(l->conn->rpcSock), ERR_OK);
|
||||
@@ -917,7 +923,7 @@ err_t NetconEthernetTap::nc_poll(void* arg, struct tcp_pcb *PCB)
|
||||
|
||||
void NetconEthernetTap::nc_err(void *arg, err_t err)
|
||||
{
|
||||
DEBUG_INFO("err=%d", err);
|
||||
DEBUG_ERROR("err=%d", err);
|
||||
Larg *l = (Larg*)arg;
|
||||
Mutex::Lock _l(l->tap->_tcpconns_m);
|
||||
|
||||
@@ -1037,17 +1043,19 @@ void NetconEthernetTap::handleBind(PhySocket *sock, PhySocket *rpcSock, void **u
|
||||
return;
|
||||
}
|
||||
|
||||
int ip = rawAddr->sin_addr.s_addr;
|
||||
unsigned char d[4];
|
||||
d[0] = ip & 0xFF;
|
||||
d[1] = (ip >> 8) & 0xFF;
|
||||
d[2] = (ip >> 16) & 0xFF;
|
||||
d[3] = (ip >> 24) & 0xFF;
|
||||
DEBUG_INFO(" addr=%d.%d.%d.%d:%d", d[0],d[1],d[2],d[3], port);
|
||||
#if DEBUG_LEVEL >= MSG_TRANSFER
|
||||
int ip = rawAddr->sin_addr.s_addr;
|
||||
unsigned char d[4];
|
||||
d[0] = ip & 0xFF;
|
||||
d[1] = (ip >> 8) & 0xFF;
|
||||
d[2] = (ip >> 16) & 0xFF;
|
||||
d[3] = (ip >> 24) & 0xFF;
|
||||
DEBUG_INFO(" addr=%d.%d.%d.%d:%d", d[0],d[1],d[2],d[3], port);
|
||||
#endif
|
||||
|
||||
connAddr.addr = *((u32_t *)_ips[0].rawIpData());
|
||||
Connection *conn = getConnection(sock);
|
||||
DEBUG_INFO(" sock=%p, fd=%d, port=%d", (void*)&sock, bind_rpc->fd, port);
|
||||
DEBUG_ATTN(" sock=%p, fd=%d, port=%d", (void*)&sock, bind_rpc->fd, port);
|
||||
if(conn) {
|
||||
if(conn->type == SOCK_DGRAM) {
|
||||
#if defined(__ANDROID__)
|
||||
@@ -1096,7 +1104,7 @@ void NetconEthernetTap::handleBind(PhySocket *sock, PhySocket *rpcSock, void **u
|
||||
|
||||
void NetconEthernetTap::handleListen(PhySocket *sock, PhySocket *rpcSock, void **uptr, struct listen_st *listen_rpc)
|
||||
{
|
||||
DEBUG_INFO("sock=%p", (void*)&sock);
|
||||
DEBUG_ATTN("sock=%p", (void*)&sock);
|
||||
Mutex::Lock _l(_tcpconns_m);
|
||||
Connection *conn = getConnection(sock);
|
||||
|
||||
@@ -1138,10 +1146,10 @@ Connection * NetconEthernetTap::handleSocketProxy(PhySocket *sock, int socket_ty
|
||||
{
|
||||
Connection *conn = getConnection(sock);
|
||||
if(!conn){
|
||||
DEBUG_INFO("unable to locate Connection object for this PhySocket sock=%p", (void*)&sock);
|
||||
DEBUG_ERROR("unable to locate Connection object for this PhySocket sock=%p", (void*)&sock);
|
||||
return NULL;
|
||||
}
|
||||
DEBUG_INFO("sock=%p", (void*)&sock);
|
||||
DEBUG_ATTN("sock=%p", (void*)&sock);
|
||||
struct udp_pcb *new_udp_PCB = NULL;
|
||||
struct tcp_pcb *new_tcp_PCB = NULL;
|
||||
if(socket_type == SOCK_DGRAM) {
|
||||
@@ -1170,7 +1178,7 @@ Connection * NetconEthernetTap::handleSocketProxy(PhySocket *sock, int socket_ty
|
||||
|
||||
Connection * NetconEthernetTap::handleSocket(PhySocket *sock, void **uptr, struct socket_st* socket_rpc)
|
||||
{
|
||||
DEBUG_INFO("sock=%p", (void*)&sock);
|
||||
DEBUG_ATTN("sock=%p", (void*)&sock);
|
||||
struct udp_pcb *new_udp_PCB = NULL;
|
||||
struct tcp_pcb *new_tcp_PCB = NULL;
|
||||
if(socket_rpc->socket_type == SOCK_DGRAM) {
|
||||
@@ -1202,7 +1210,7 @@ Connection * NetconEthernetTap::handleSocket(PhySocket *sock, void **uptr, struc
|
||||
|
||||
int NetconEthernetTap::handleConnectProxy(PhySocket *sock, struct sockaddr_in *rawAddr)
|
||||
{
|
||||
DEBUG_INFO("sock=%p", (void*)&sock);
|
||||
DEBUG_ATTN("sock=%p", (void*)&sock);
|
||||
Mutex::Lock _l(_tcpconns_m);
|
||||
int port = rawAddr->sin_port;
|
||||
ip_addr_t connAddr = convert_ip(rawAddr);
|
||||
@@ -1298,7 +1306,7 @@ int NetconEthernetTap::handleConnectProxy(PhySocket *sock, struct sockaddr_in *r
|
||||
|
||||
void NetconEthernetTap::handleConnect(PhySocket *sock, PhySocket *rpcSock, Connection *conn, struct connect_st* connect_rpc)
|
||||
{
|
||||
DEBUG_EXTRA("sock=%p", (void*)&sock);
|
||||
DEBUG_ATTN("sock=%p", (void*)&sock);
|
||||
Mutex::Lock _l(_tcpconns_m);
|
||||
struct sockaddr_in *rawAddr = (struct sockaddr_in *) &connect_rpc->addr;
|
||||
int port = lwipstack->__lwip_ntohs(rawAddr->sin_port);
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
#if defined(_SDK_INTERCEPT_)
|
||||
#if defined(SDK_INTERCEPT)
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
@@ -121,7 +121,7 @@ pthread_key_t thr_id_key;
|
||||
// Return whether 'intercept' API is enabled for this thread
|
||||
|
||||
bool check_intercept_enabled() {
|
||||
DEBUG_EXTRA("");
|
||||
// DEBUG_EXTRA("");
|
||||
if(!realconnect){
|
||||
load_symbols();
|
||||
}
|
||||
@@ -265,7 +265,7 @@ pthread_key_t thr_id_key;
|
||||
|
||||
int socket(SOCKET_SIG)
|
||||
{
|
||||
DEBUG_INFO();
|
||||
DEBUG_ATTN();
|
||||
if (!check_intercept_enabled() && socket_type) {
|
||||
int err = realsocket(socket_family, socket_type, protocol);
|
||||
if(err < 0) {
|
||||
@@ -296,7 +296,7 @@ pthread_key_t thr_id_key;
|
||||
|
||||
int connect(CONNECT_SIG)
|
||||
{
|
||||
DEBUG_INFO("fd=%d", fd);
|
||||
DEBUG_ATTN("fd=%d", fd);
|
||||
struct sockaddr_in *connaddr;
|
||||
connaddr = (struct sockaddr_in *)addr;
|
||||
if(addr->sa_family == AF_LOCAL || addr->sa_family == AF_UNIX) {
|
||||
@@ -359,7 +359,7 @@ pthread_key_t thr_id_key;
|
||||
|
||||
int bind(BIND_SIG)
|
||||
{
|
||||
DEBUG_INFO("fd=%d", fd);
|
||||
DEBUG_ATTN("fd=%d", fd);
|
||||
// make sure we don't touch any standard outputs
|
||||
if(fd == 0 || fd == 1 || fd == 2)
|
||||
return(realbind(fd, addr, addrlen));
|
||||
@@ -417,7 +417,7 @@ pthread_key_t thr_id_key;
|
||||
|
||||
#if defined(__linux__)
|
||||
int accept4(ACCEPT4_SIG) {
|
||||
DEBUG_INFO("fd=%d", fd);
|
||||
DEBUG_ATTN("fd=%d", fd);
|
||||
return zts_accept4(fd, addr, addrlen, flags);
|
||||
}
|
||||
#endif
|
||||
@@ -428,7 +428,7 @@ pthread_key_t thr_id_key;
|
||||
// int fd struct sockaddr *addr, socklen_t *addrlen
|
||||
|
||||
int accept(ACCEPT_SIG) {
|
||||
DEBUG_INFO("fd=%d", fd);
|
||||
DEBUG_ATTN("fd=%d", fd);
|
||||
if (!check_intercept_enabled())
|
||||
return realaccept(fd, addr, addrlen);
|
||||
|
||||
@@ -483,7 +483,7 @@ pthread_key_t thr_id_key;
|
||||
|
||||
int listen(LISTEN_SIG)
|
||||
{
|
||||
DEBUG_INFO("fd=%d", fd);
|
||||
DEBUG_ATTN("fd=%d", fd);
|
||||
if (!check_intercept_enabled())
|
||||
return reallisten(fd, backlog);
|
||||
|
||||
|
||||
@@ -52,7 +52,11 @@ struct tcp_pcb;
|
||||
#define LWIP_HTONS_SIG u16_t x
|
||||
#define LWIP_NTOHS_SIG u16_t x
|
||||
#define IPADDR_NTOA_SIG const ip_addr_t *addr
|
||||
#define ETHARP_OUTPUT_SIG struct netif *netif, struct pbuf *q, const ip_addr_t *ipaddr
|
||||
#if defined(LWIP_VERSION_2)
|
||||
#define ETHARP_OUTPUT_SIG struct netif *netif, struct pbuf *q, const ip_addr_t *ipaddr
|
||||
#elif defined (LWIP_VERSION_1)
|
||||
#define ETHARP_OUTPUT_SIG struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr
|
||||
#endif
|
||||
#define ETHERNET_INPUT_SIG struct pbuf *p, struct netif *netif
|
||||
#define IP_INPUT_SIG struct pbuf *p, struct netif *inp
|
||||
#define NETIF_SET_DEFAULT_SIG struct netif *netif
|
||||
|
||||
@@ -115,7 +115,7 @@ int (*realclose)(CLOSE_SIG);
|
||||
DEBUG_INFO("$ZT_NC_NETWORK(len=%d)=%s", strlen(api_netpath), api_netpath);
|
||||
}
|
||||
#endif
|
||||
DEBUG_EXTRA("api_netpath=%s", api_netpath);
|
||||
//DEBUG_EXTRA("api_netpath=%s", api_netpath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user