fixed warnings

This commit is contained in:
Joseph Henry
2016-10-28 13:11:46 -07:00
parent 5b777ad3f5
commit 92c945aee3
4 changed files with 61 additions and 62 deletions

View File

@@ -46,10 +46,10 @@
// IPV6 Related
//#if defined(SDK_IPV6)
#define LWIP_IPV6 1
#define LWIP_IPV6 0
//#endif
//#if defined(SDK_IPV4)
#define LWIP_IPV4 0
#define LWIP_IPV4 1
//#endif
#define LWIP_TCP 1

View File

@@ -234,7 +234,7 @@ namespace ZeroTier {
// SIP-
inline void __pico_stack_init(void) throw() { DEBUG_STACK(); Mutex::Lock _l(_lock); _pico_stack_init(); }
inline void __pico_stack_tick(void) throw() { /*DEBUG_STACK();*/ Mutex::Lock _l(_lock); _pico_stack_tick(); }
inline void __pico_stack_tick(void) throw() { DEBUG_STACK(); /*Mutex::Lock _l(_lock);*/ _pico_stack_tick(); }
inline struct pico_device * __pico_tap_create(PICO_TAP_CREATE_SIG) throw() { DEBUG_STACK(); Mutex::Lock _l(_lock); return _pico_tap_create(name); }
inline int __pico_ipv4_to_string(PICO_IPV4_TO_STRING_SIG) throw() { DEBUG_STACK(); Mutex::Lock _l(_lock); return _pico_ipv4_to_string(ipbuf, ip); }
inline int __pico_ipv4_link_add(PICO_IPV4_LINK_ADD_SIG) throw() { DEBUG_STACK(); Mutex::Lock _l(_lock); return _pico_ipv4_link_add(dev, address, netmask); }

View File

@@ -113,7 +113,6 @@ namespace ZeroTier {
#if defined(SDK_IPV4)
if(ip.isV4())
{
int id;
struct pico_ip4 ipaddr, netmask;
ipaddr.addr = *((u32_t *)ip.rawIpData());
netmask.addr = *((u32_t *)ip.netmask().rawIpData());
@@ -161,8 +160,8 @@ namespace ZeroTier {
DEBUG_INFO();
while(tap->_run)
{
tap->_phy.poll((unsigned long)std::min(100,200));
usleep(500);
tap->_phy.poll((unsigned long)std::min(500,1000));
usleep(1000);
tap->picostack->__pico_stack_tick();
}
}
@@ -284,6 +283,7 @@ namespace ZeroTier {
}
// Called when an incoming ping is received
/*
static void pico_cb_ping(struct pico_icmp4_stats *s)
{
DEBUG_INFO();
@@ -296,6 +296,7 @@ namespace ZeroTier {
printf("PING %lu to %s: Error %d\n", s->seq, host, s->err);
}
}
*/
// Sends data to the tap device (in our case, the ZeroTier service)
static int pico_eth_send(struct pico_device *dev, void *buf, int len)
@@ -353,27 +354,20 @@ namespace ZeroTier {
// OPTIMIZATION: The copy logic and/or buffer structure should be reworked for better performance after the BETA
// NetconEthernetTap *tap = (NetconEthernetTap*)netif->state;
Mutex::Lock _l(picotap->_pico_frame_rxbuf_m);
uint8_t *buf = NULL;
uint32_t len = 0;
struct eth_hdr ethhdr;
unsigned char frame[ZT_MAX_MTU];
uint32_t len;
while (picotap->pico_frame_rxbuf_tot > 0) {
memset(frame, 0, sizeof(frame));
unsigned int len = 0;
len = 0;
memcpy(&len, picotap->pico_frame_rxbuf, sizeof(len)); // get frame len
//DEBUG_EXTRA("reading frame len = %ld", len);
memcpy(frame, picotap->pico_frame_rxbuf + sizeof(len), len); // get frame data
memmove(picotap->pico_frame_rxbuf, picotap->pico_frame_rxbuf + sizeof(len) + len, ZT_MAX_MTU-(sizeof(len) + len));
int rx_ret = picotap->picostack->__pico_stack_recv(dev, (uint8_t*)frame, len);
picotap->picostack->__pico_stack_recv(dev, (uint8_t*)frame, len);
picotap->pico_frame_rxbuf_tot-=(sizeof(len) + len);
//DEBUG_EXTRA("rx_ret = %d", rx_ret);
//DEBUG_EXTRA("RX frame buffer %3f full", (float)(picotap->pico_frame_rxbuf_tot) / (float)(MAX_PICO_FRAME_RX_BUF_SZ));
// DEBUG_EXTRA("RX frame buffer %3f full", (float)(picotap->pico_frame_rxbuf_tot) / (float)(MAX_PICO_FRAME_RX_BUF_SZ));
loop_score--;
}
//DEBUG_ATTN("loop_score = %d", loop_score);
return loop_score;
}
@@ -389,8 +383,6 @@ namespace ZeroTier {
#endif
if(psock) {
DEBUG_ATTN("psock = %p", (void*)psock);
int yes = 1;
//picostack->__pico_socket_setoption(psock, PICO_TCP_NODELAY, &yes);
Connection * newConn = new Connection();
*uptr = newConn;
newConn->type = socket_rpc->socket_type;
@@ -454,7 +446,6 @@ namespace ZeroTier {
DEBUG_INFO();
if(conn->picosock) {
struct sockaddr_in *addr = (struct sockaddr_in *) &connect_rpc->addr;
pico_address paddr;
int ret;
// TODO: Rewrite this
#if defined(SDK_IPV4)
@@ -463,7 +454,7 @@ namespace ZeroTier {
char ipv4_str[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &(in4->sin_addr), ipv4_str, INET_ADDRSTRLEN);
picotap->picostack->__pico_string_to_ipv4(ipv4_str, &(zaddr.addr));
DEBUG_ATTN("addr=%s:%d", ipv4_str, (uint16_t*)&(addr->sin_port));
DEBUG_ATTN("addr=%s:%d", ipv4_str, addr->sin_port);
ret = picotap->picostack->__pico_socket_connect(conn->picosock, &zaddr, addr->sin_port);
#elif defined(SDK_IPV6) // "fd56:5799:d8f6:1238:8c99:9322:30ce:418a"
struct pico_ip6 zaddr;
@@ -471,7 +462,7 @@ namespace ZeroTier {
char ipv6_str[INET6_ADDRSTRLEN];
inet_ntop(AF_INET6, &(in6->sin6_addr), ipv6_str, INET6_ADDRSTRLEN);
picotap->picostack->__pico_string_to_ipv6(ipv6_str, zaddr.addr);
DEBUG_ATTN("addr=%s:%d", ipv6_str, (uint16_t*)&(addr->sin_port));
DEBUG_ATTN("addr=%s:%d", ipv6_str, addr->sin_port);
ret = picotap->picostack->__pico_socket_connect(conn->picosock, &zaddr, addr->sin_port);
#endif
@@ -567,7 +558,6 @@ namespace ZeroTier {
if(conn && conn->rxsz) {
float max = conn->type == SOCK_STREAM ? (float)DEFAULT_TCP_RX_BUF_SZ : (float)DEFAULT_UDP_RX_BUF_SZ;
long n = picotap->_phy.streamSend(conn->sock, conn->rxbuf, /* ZT_MAX_MTU */ conn->rxsz);
// DEBUG_INFO(" n=%d", n);
// extract address and payload size info
if(conn->type==SOCK_DGRAM) {
int payload_sz, addr_sz_offset = sizeof(struct sockaddr_storage);
@@ -599,13 +589,13 @@ namespace ZeroTier {
picotap->_phy.setNotifyWritable(conn->sock, true);
}
if(!n || !(conn->rxsz)) {
//DEBUG_ERROR("error writing %d-byte-sized chunk to client socket", ZT_MAX_MTU);
picotap->_phy.setNotifyWritable(conn->sock, false);
}
}
}
// Closes a pico_socket
/*
static void pico_handleClose(Connection *conn)
{
DEBUG_INFO();
@@ -619,6 +609,8 @@ namespace ZeroTier {
}
DEBUG_ERROR("invalid connection or pico_socket");
}
*/
#endif // SDK_PICOTCP
@@ -626,17 +618,18 @@ namespace ZeroTier {
-------------------------------- Tap Service ----------------------------------
------------------------------------------------------------------------------*/
static err_t tapif_init(struct netif *netif)
{
#if SDK_LWIP
static err_t tapif_init(struct netif *netif)
{
// Actual init functionality is in addIp() of tap
return ERR_OK;
}
}
/*
/*
* Outputs data from the pbuf queue to the interface
*/
static err_t low_level_output(struct netif *netif, struct pbuf *p)
{
static err_t low_level_output(struct netif *netif, struct pbuf *p)
{
struct pbuf *q;
char buf[ZT_MAX_MTU+32];
char *bufptr;
@@ -663,7 +656,9 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p)
tap->_handler(tap->_arg,tap->_nwid,src_mac,dest_mac,
Utils::ntoh((uint16_t)ethhdr->type),0,buf + sizeof(struct eth_hdr),totalLength - sizeof(struct eth_hdr));
return ERR_OK;
}
}
#endif
// ---------------------------------------------------------------------------
@@ -1092,7 +1087,7 @@ void NetconEthernetTap::closeConnection(PhySocket *sock)
// picoTCP
#if defined(SDK_PICOTCP)
//pico_handleClose(conn);
// pico_handleClose(conn);
#endif
// lwIP
@@ -1822,7 +1817,6 @@ void NetconEthernetTap::handleListen(PhySocket *sock, PhySocket *rpcSock, void *
{
DEBUG_ATTN("sock=%p", (void*)&sock);
Mutex::Lock _l(_tcpconns_m);
Connection *conn = getConnection(sock);
// picoTCP
#if defined(SDK_PICOTCP)
@@ -1831,6 +1825,7 @@ void NetconEthernetTap::handleListen(PhySocket *sock, PhySocket *rpcSock, void *
// lwIP
#if defined(SDK_LWIP)
Connection *conn = getConnection(sock);
if(conn->type==SOCK_DGRAM) {
// FIX: Added sendReturnValue() call to fix listen() return bug on Android
sendReturnValue(rpcSock, ERR_OK, ERR_OK);

View File

@@ -497,7 +497,11 @@ namespace ZeroTier {
*/
void closeConnection(PhySocket *sock);
#if defined(SDK_PICOTCP)
void pico_init_interface(const InetAddress &ip);
#if defined(SDK_IPV4)
ip_addr_t convert_ip(struct sockaddr_in * addr)
{
ip_addr_t conn_addr;