Added differentiation of LIBZT_DEBUG and NS_DEBUG flags, other minor tweaks

This commit is contained in:
Joseph Henry
2017-09-13 16:26:27 -07:00
parent bd68e808c1
commit 0dc390ddcf
8 changed files with 139 additions and 93 deletions

View File

@@ -529,7 +529,7 @@ namespace ZeroTier {
{
/* FIXME: There is a call to *_Connect for each send, we should probably figure out a better way to do this,
possibly consult the stack for "connection" state */
// TODO: flags
int err = 0;
#if defined(STACK_PICO)
@@ -546,8 +546,12 @@ namespace ZeroTier {
#endif
#if defined(STACK_LWIP)
if(lwipstack) {
err = lwipstack->lwip_Connect(vs, addr, addrlen); // implicit
err = lwipstack->lwip_Write(vs, (void*)buf, len);
if((err = lwipstack->lwip_Connect(vs, addr, addrlen)) < 0) { // implicit
return err;
}
if((err = lwipstack->lwip_Write(vs, (void*)buf, len)) < 0) {
return err;
}
}
#endif
return err;
@@ -586,14 +590,13 @@ namespace ZeroTier {
if(picostack) {
err = picostack->pico_Shutdown(vs, how);
}
return err;
#endif
#if defined(STACK_LWIP)
if(lwipstack) {
err = lwipstack->lwip_Shutdown(vs, how);
}
return err;
#endif
return err;
}
void VirtualTap::Housekeeping()

View File

@@ -264,16 +264,15 @@ namespace ZeroTier {
handle_general_failure();
return;
}
int r, n;
int r;
uint16_t port = 0;
union {
struct pico_ip4 ip4;
struct pico_ip6 ip6;
} peer;
do {
n = 0;
int n = 0;
int avail = ZT_TCP_RX_BUF_SZ - vs->RXbuf->count();
if(avail) {
r = pico_socket_recvfrom(s, vs->RXbuf->get_buf(), ZT_STACK_SOCKET_RD_MAX,
@@ -622,7 +621,7 @@ namespace ZeroTier {
Utils::ntoh(ethhdr->proto), beautify_eth_proto_nums(Utils::ntoh(ethhdr->proto)), flagbuf);
}
tap->_handler(tap->_arg,NULL,tap->_nwid,src_mac,dest_mac,
Utils::ntoh((uint16_t)ethhdr->proto),0, ((char*)buf)
Utils::ntoh((uint16_t)ethhdr->proto), 0, ((char*)buf)
+ sizeof(struct pico_eth_hdr),len - sizeof(struct pico_eth_hdr));
//_picostack_driver_lock.unlock();
return len;