minor tweaks for build warnings on linux
This commit is contained in:
@@ -27,7 +27,7 @@ INCLUDES=
|
|||||||
DEFS=
|
DEFS=
|
||||||
ARCH_FLAGS=-arch x86_64
|
ARCH_FLAGS=-arch x86_64
|
||||||
CFLAGS=
|
CFLAGS=
|
||||||
CXXFLAGS=$(CFLAGS) -fno-rtti -std=c++11 -DZT_SDK
|
CXXFLAGS=$(CFLAGS) -Wno-format -fno-rtti -std=c++11 -DZT_SDK
|
||||||
|
|
||||||
include objects.mk
|
include objects.mk
|
||||||
|
|
||||||
@@ -69,6 +69,7 @@ INCLUDES+= -Iext \
|
|||||||
-I$(ZT1)/osdep \
|
-I$(ZT1)/osdep \
|
||||||
-I$(ZT1)/node \
|
-I$(ZT1)/node \
|
||||||
-I$(ZT1)/service \
|
-I$(ZT1)/service \
|
||||||
|
-I$(ZT1)/include \
|
||||||
-I../$(ZT1)/osdep \
|
-I../$(ZT1)/osdep \
|
||||||
-I../$(ZT1)/node \
|
-I../$(ZT1)/node \
|
||||||
-I../$(ZT1)/service \
|
-I../$(ZT1)/service \
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ INCLUDES=
|
|||||||
DEFS=
|
DEFS=
|
||||||
ARCH_FLAGS=-arch x86_64
|
ARCH_FLAGS=-arch x86_64
|
||||||
CFLAGS=
|
CFLAGS=
|
||||||
CXXFLAGS=$(CFLAGS) -fno-rtti -std=c++11 -DZT_SDK
|
CXXFLAGS=$(CFLAGS) -Wno-format -fno-rtti -std=c++11 -DZT_SDK
|
||||||
|
|
||||||
include objects.mk
|
include objects.mk
|
||||||
|
|
||||||
|
|||||||
@@ -214,8 +214,8 @@ namespace ZeroTier
|
|||||||
{
|
{
|
||||||
if(len >= 3)
|
if(len >= 3)
|
||||||
{
|
{
|
||||||
int version = buf[IDX_VERSION];
|
//int version = buf[IDX_VERSION];
|
||||||
int methodsLength = buf[IDX_NMETHODS];
|
//int methodsLength = buf[IDX_NMETHODS];
|
||||||
int firstSupportedMethod = buf[IDX_METHODS];
|
int firstSupportedMethod = buf[IDX_METHODS];
|
||||||
int supportedMethod = 0;
|
int supportedMethod = 0;
|
||||||
|
|
||||||
@@ -223,7 +223,7 @@ namespace ZeroTier
|
|||||||
if(firstSupportedMethod == 2) {
|
if(firstSupportedMethod == 2) {
|
||||||
supportedMethod = firstSupportedMethod;
|
supportedMethod = firstSupportedMethod;
|
||||||
}
|
}
|
||||||
DEBUG_INFO(" INFO <ver=%d, meth_len=%d, supp_meth=%d>", version, methodsLength, supportedMethod);
|
//DEBUG_INFO(" INFO <ver=%d, meth_len=%d, supp_meth=%d>", version, methodsLength, supportedMethod);
|
||||||
|
|
||||||
// Send METHOD selection msg
|
// Send METHOD selection msg
|
||||||
// +----+--------+
|
// +----+--------+
|
||||||
@@ -252,11 +252,11 @@ namespace ZeroTier
|
|||||||
// Ex. 4(meta) + 4(ipv4) + 2(port) = 10
|
// Ex. 4(meta) + 4(ipv4) + 2(port) = 10
|
||||||
if(len >= 10)
|
if(len >= 10)
|
||||||
{
|
{
|
||||||
int version = buf[IDX_VERSION];
|
//int version = buf[IDX_VERSION];
|
||||||
int cmd = buf[IDX_COMMAND];
|
int cmd = buf[IDX_COMMAND];
|
||||||
int addr_type = buf[IDX_ATYP];
|
int addr_type = buf[IDX_ATYP];
|
||||||
|
|
||||||
DEBUG_INFO("SOCKS REQUEST = <ver=%d, cmd=%d, typ=%d>", version, cmd, addr_type);
|
//DEBUG_INFO("SOCKS REQUEST = <ver=%d, cmd=%d, typ=%d>", version, cmd, addr_type);
|
||||||
|
|
||||||
// CONNECT request
|
// CONNECT request
|
||||||
if(cmd == 1) {
|
if(cmd == 1) {
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ void zts_get_ipv6_address(const char *nwid, char *addrstr)
|
|||||||
int zts_get_device_id(char *devID) {
|
int zts_get_device_id(char *devID) {
|
||||||
if(zt1Service) {
|
if(zt1Service) {
|
||||||
char id[10];
|
char id[10];
|
||||||
sprintf(id, "%llx",zt1Service->getNode()->address());
|
sprintf(id, "%lx",zt1Service->getNode()->address());
|
||||||
memcpy(devID, id, 10);
|
memcpy(devID, id, 10);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -262,9 +262,9 @@ int zts_get_device_id_from_file(const char *filepath, char *devID) {
|
|||||||
int zts_get_peer_address(char *peer, const char *devID) {
|
int zts_get_peer_address(char *peer, const char *devID) {
|
||||||
if(zt1Service) {
|
if(zt1Service) {
|
||||||
ZT_PeerList *pl = zt1Service->getNode()->peers();
|
ZT_PeerList *pl = zt1Service->getNode()->peers();
|
||||||
uint64_t addr;
|
// uint64_t addr;
|
||||||
for(int i=0; i<pl->peerCount; i++) {
|
for(int i=0; i<pl->peerCount; i++) {
|
||||||
ZT_Peer *p = &(pl->peers[i]);
|
// ZT_Peer *p = &(pl->peers[i]);
|
||||||
// DEBUG_INFO("peer[%d] = %lx", i, p->address);
|
// DEBUG_INFO("peer[%d] = %lx", i, p->address);
|
||||||
}
|
}
|
||||||
return pl->peerCount;
|
return pl->peerCount;
|
||||||
|
|||||||
@@ -247,9 +247,13 @@ namespace ZeroTier {
|
|||||||
if(sz)
|
if(sz)
|
||||||
memmove(&conn->txbuf, (conn->txbuf+r), sz);
|
memmove(&conn->txbuf, (conn->txbuf+r), sz);
|
||||||
conn->txsz -= r;
|
conn->txsz -= r;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL >= MSG_TRANSFER
|
||||||
int max = conn->type == SOCK_STREAM ? DEFAULT_TCP_TX_BUF_SZ : DEFAULT_UDP_TX_BUF_SZ;
|
int max = conn->type == SOCK_STREAM ? DEFAULT_TCP_TX_BUF_SZ : DEFAULT_UDP_TX_BUF_SZ;
|
||||||
DEBUG_TRANS("[TCP TX] ---> :: {TX: %.3f%%, RX: %.3f%%, physock=%p} :: %d bytes",
|
DEBUG_TRANS("[TCP TX] ---> :: {TX: %.3f%%, RX: %.3f%%, physock=%p} :: %d bytes",
|
||||||
(float)conn->txsz / (float)max, (float)conn->rxsz / max, conn->sock, r);
|
(float)conn->txsz / (float)max, (float)conn->rxsz / max, conn->sock, r);
|
||||||
|
#endif
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -673,22 +677,19 @@ namespace ZeroTier {
|
|||||||
picotap->_tcpconns_m.lock();
|
picotap->_tcpconns_m.lock();
|
||||||
picotap->_rx_buf_m.lock();
|
picotap->_rx_buf_m.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
int tot = 0, n = -1, write_attempts = 0;
|
int tot = 0, n = -1, write_attempts = 0;
|
||||||
|
|
||||||
Connection *conn = picotap->getConnection(sock);
|
Connection *conn = picotap->getConnection(sock);
|
||||||
if(conn && conn->rxsz) {
|
if(conn && conn->rxsz) {
|
||||||
float max = conn->type == SOCK_STREAM ? (float)DEFAULT_TCP_RX_BUF_SZ : (float)DEFAULT_UDP_RX_BUF_SZ;
|
|
||||||
|
|
||||||
|
//
|
||||||
if(conn->type==SOCK_DGRAM) {
|
if(conn->type==SOCK_DGRAM) {
|
||||||
//DEBUG_ERROR(" [ ZTSOCK <- RXBUF] attempting write, RXBUF(%d)", conn->rxsz);
|
|
||||||
// Try to write SDK_MTU-sized chunk to app socket
|
// Try to write SDK_MTU-sized chunk to app socket
|
||||||
while(tot < SDK_MTU) {
|
while(tot < SDK_MTU) {
|
||||||
write_attempts++;
|
write_attempts++;
|
||||||
n = picotap->_phy.streamSend(conn->sock, (conn->rxbuf)+tot, SDK_MTU);
|
n = picotap->_phy.streamSend(conn->sock, (conn->rxbuf)+tot, SDK_MTU);
|
||||||
tot += n;
|
tot += n;
|
||||||
//DEBUG_ERROR(" [ ZTSOCK <- RXBUF] wrote = %d, total = %d, errno=%d", n, tot, errno);
|
DEBUG_FLOW(" [ ZTSOCK <- RXBUF] wrote = %d, errno=%d", n, errno);
|
||||||
|
|
||||||
// If socket is unavailable, attempt to write N times before giving up
|
// If socket is unavailable, attempt to write N times before giving up
|
||||||
if(errno==35) {
|
if(errno==35) {
|
||||||
if(write_attempts == 1024) {
|
if(write_attempts == 1024) {
|
||||||
@@ -696,9 +697,7 @@ namespace ZeroTier {
|
|||||||
tot = SDK_MTU;
|
tot = SDK_MTU;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// DEBUG_EXTRA("SOCK_DGRAM, conn=%p, physock=%p", conn, sock);
|
|
||||||
int payload_sz, addr_sz_offset = sizeof(struct sockaddr_storage);
|
int payload_sz, addr_sz_offset = sizeof(struct sockaddr_storage);
|
||||||
memcpy(&payload_sz, conn->rxbuf + addr_sz_offset, sizeof(int));
|
memcpy(&payload_sz, conn->rxbuf + addr_sz_offset, sizeof(int));
|
||||||
struct sockaddr_storage addr;
|
struct sockaddr_storage addr;
|
||||||
@@ -713,17 +712,22 @@ namespace ZeroTier {
|
|||||||
}
|
}
|
||||||
conn->rxsz -= SDK_MTU;
|
conn->rxsz -= SDK_MTU;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
if(conn->type==SOCK_STREAM) {
|
if(conn->type==SOCK_STREAM) {
|
||||||
n = picotap->_phy.streamSend(conn->sock, conn->rxbuf, conn->rxsz);
|
n = picotap->_phy.streamSend(conn->sock, conn->rxbuf, conn->rxsz);
|
||||||
if(conn->rxsz-n > 0) // If more remains on buffer
|
if(conn->rxsz-n > 0) // If more remains on buffer
|
||||||
memcpy(conn->rxbuf, conn->rxbuf+n, conn->rxsz - n);
|
memcpy(conn->rxbuf, conn->rxbuf+n, conn->rxsz - n);
|
||||||
conn->rxsz -= n;
|
conn->rxsz -= n;
|
||||||
}
|
}
|
||||||
|
// Notify ZT I/O loop that it has new buffer contents
|
||||||
if(n) {
|
if(n) {
|
||||||
if(conn->type==SOCK_STREAM) {
|
if(conn->type==SOCK_STREAM) {
|
||||||
//DEBUG_TRANS("[TCP RX] <--- :: {TX: %.3f%%, RX: %.3f%%, physock=%p} :: %d bytes",
|
|
||||||
// (float)conn->txsz / max, (float)conn->rxsz / max, conn->sock, n);
|
#if DEBUG_LEVEL >= MSG_TRANSFER
|
||||||
|
float max = conn->type == SOCK_STREAM ? (float)DEFAULT_TCP_RX_BUF_SZ : (float)DEFAULT_UDP_RX_BUF_SZ;
|
||||||
|
DEBUG_TRANS("[TCP RX] <--- :: {TX: %.3f%%, RX: %.3f%%, physock=%p} :: %d bytes",
|
||||||
|
(float)conn->txsz / max, (float)conn->rxsz / max, conn->sock, n);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if(conn->rxsz == 0) {
|
if(conn->rxsz == 0) {
|
||||||
picotap->_phy.setNotifyWritable(sock, false);
|
picotap->_phy.setNotifyWritable(sock, false);
|
||||||
@@ -740,7 +744,6 @@ namespace ZeroTier {
|
|||||||
picotap->_tcpconns_m.unlock();
|
picotap->_tcpconns_m.unlock();
|
||||||
picotap->_rx_buf_m.unlock();
|
picotap->_rx_buf_m.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_FLOW(" [ ZTSOCK <- RXBUF] Emitted (%d) from RXBUF(%d) to socket", tot, conn->rxsz);
|
DEBUG_FLOW(" [ ZTSOCK <- RXBUF] Emitted (%d) from RXBUF(%d) to socket", tot, conn->rxsz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ void NetconEthernetTap::phyOnUnixData(PhySocket *sock, void **uptr, void *data,
|
|||||||
jobmap[CANARY_num] = std::pair<PhySocket*, void*>(sock, tmpbuf);
|
jobmap[CANARY_num] = std::pair<PhySocket*, void*>(sock, tmpbuf);
|
||||||
|
|
||||||
}
|
}
|
||||||
int nwrit = write(_phy.getDescriptor(sock), "z", 1); // RPC ACK byte to maintain order
|
write(_phy.getDescriptor(sock), "z", 1); // RPC ACK byte to maintain order
|
||||||
}
|
}
|
||||||
// STREAM
|
// STREAM
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user