Reduce number of compile-time warnings

This commit is contained in:
Joseph Henry
2021-04-30 15:36:46 -07:00
parent c6a51d3188
commit 6763ced6f5
5 changed files with 635 additions and 585 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -267,6 +267,7 @@ DWORD WINAPI cbRun(LPVOID arg)
void* cbRun(void* arg)
#endif
{
ZTS_UNUSED_ARG(arg);
#if defined(__APPLE__)
pthread_setname_np(ZTS_EVENT_CALLBACK_THREAD_NAME);
#endif
@@ -481,6 +482,7 @@ DWORD WINAPI _runNodeService(LPVOID arg)
void* _runNodeService(void* arg)
#endif
{
ZTS_UNUSED_ARG(arg);
#if defined(__APPLE__)
pthread_setname_np(ZTS_SERVICE_THREAD_NAME);
#endif
@@ -597,14 +599,14 @@ int zts_node_free()
int zts_moon_orbit(uint64_t moon_roots_id, uint64_t moon_seed)
{
ACQUIRE_SERVICE(ZTS_ERR_SERVICE);
zts_service->orbit(NULL, moon_roots_id, moon_seed);
zts_service->orbit(moon_roots_id, moon_seed);
return ZTS_ERR_OK;
}
int zts_moon_deorbit(uint64_t moon_roots_id)
{
ACQUIRE_SERVICE(ZTS_ERR_SERVICE);
zts_service->deorbit(NULL, moon_roots_id);
zts_service->deorbit(moon_roots_id);
return ZTS_ERR_OK;
}

View File

@@ -38,6 +38,130 @@
namespace ZeroTier {
static int SnodeVirtualNetworkConfigFunction(
ZT_Node* node,
void* uptr,
void* tptr,
uint64_t net_id,
void** nuptr,
enum ZT_VirtualNetworkConfigOperation op,
const ZT_VirtualNetworkConfig* nwconf)
{
ZTS_UNUSED_ARG(node);
ZTS_UNUSED_ARG(tptr);
return reinterpret_cast<NodeService*>(uptr)->nodeVirtualNetworkConfigFunction(net_id, nuptr, op, nwconf);
}
static void SnodeEventCallback(ZT_Node* node, void* uptr, void* tptr, enum ZT_Event event, const void* metaData)
{
ZTS_UNUSED_ARG(node);
ZTS_UNUSED_ARG(tptr);
reinterpret_cast<NodeService*>(uptr)->nodeEventCallback(event, metaData);
}
static void SnodeStatePutFunction(
ZT_Node* node,
void* uptr,
void* tptr,
enum ZT_StateObjectType type,
const uint64_t id[2],
const void* data,
int len)
{
ZTS_UNUSED_ARG(node);
ZTS_UNUSED_ARG(tptr);
reinterpret_cast<NodeService*>(uptr)->nodeStatePutFunction(type, id, data, len);
}
static int SnodeStateGetFunction(
ZT_Node* node,
void* uptr,
void* tptr,
enum ZT_StateObjectType type,
const uint64_t id[2],
void* data,
unsigned int maxlen)
{
ZTS_UNUSED_ARG(node);
ZTS_UNUSED_ARG(tptr);
return reinterpret_cast<NodeService*>(uptr)->nodeStateGetFunction(type, id, data, maxlen);
}
static int SnodeWirePacketSendFunction(
ZT_Node* node,
void* uptr,
void* tptr,
int64_t localSocket,
const struct sockaddr_storage* addr,
const void* data,
unsigned int len,
unsigned int ttl)
{
ZTS_UNUSED_ARG(node);
ZTS_UNUSED_ARG(tptr);
return reinterpret_cast<NodeService*>(uptr)->nodeWirePacketSendFunction(localSocket, addr, data, len, ttl);
}
static void SnodeVirtualNetworkFrameFunction(
ZT_Node* node,
void* uptr,
void* tptr,
uint64_t net_id,
void** nuptr,
uint64_t sourceMac,
uint64_t destMac,
unsigned int etherType,
unsigned int vlanId,
const void* data,
unsigned int len)
{
ZTS_UNUSED_ARG(node);
ZTS_UNUSED_ARG(tptr);
reinterpret_cast<NodeService*>(uptr)
->nodeVirtualNetworkFrameFunction(net_id, nuptr, sourceMac, destMac, etherType, vlanId, data, len);
}
static int SnodePathCheckFunction(
ZT_Node* node,
void* uptr,
void* tptr,
uint64_t ztaddr,
int64_t localSocket,
const struct sockaddr_storage* remoteAddr)
{
ZTS_UNUSED_ARG(node);
ZTS_UNUSED_ARG(tptr);
return reinterpret_cast<NodeService*>(uptr)->nodePathCheckFunction(ztaddr, localSocket, remoteAddr);
}
static int SnodePathLookupFunction(
ZT_Node* node,
void* uptr,
void* tptr,
uint64_t ztaddr,
int family,
struct sockaddr_storage* result)
{
ZTS_UNUSED_ARG(node);
ZTS_UNUSED_ARG(tptr);
return reinterpret_cast<NodeService*>(uptr)->nodePathLookupFunction(ztaddr, family, result);
}
static void StapFrameHandler(
void* uptr,
void* tptr,
uint64_t net_id,
const MAC& from,
const MAC& to,
unsigned int etherType,
unsigned int vlanId,
const void* data,
unsigned int len)
{
ZTS_UNUSED_ARG(tptr);
reinterpret_cast<NodeService*>(uptr)->tapFrameHandler(net_id, from, to, etherType, vlanId, data, len);
}
NodeService::NodeService()
: _phy(this, false, true)
, _node((Node*)0)
@@ -59,8 +183,8 @@ NodeService::NodeService()
, _userDefinedWorld(false)
, _nodeIsOnline(false)
, _eventsEnabled(false)
, _events(NULL)
, _homePath("")
, _events(NULL)
{
}
@@ -285,10 +409,13 @@ NodeService::ReasonForTermination NodeService::run()
c != mgChanges.end();
++c) {
auto mgpair = c->second;
for (std::vector<MulticastGroup>::iterator m(mgpair.first.begin()); m != mgpair.first.end(); ++m)
for (std::vector<MulticastGroup>::iterator m(mgpair.first.begin()); m != mgpair.first.end(); ++m) {
_node->multicastSubscribe((void*)0, c->first, m->mac().toInt(), m->adi());
for (std::vector<MulticastGroup>::iterator m(mgpair.second.begin()); m != mgpair.second.end(); ++m)
}
for (std::vector<MulticastGroup>::iterator m(mgpair.second.begin()); m != mgpair.second.end();
++m) {
_node->multicastUnsubscribe(c->first, m->mac().toInt(), m->adi());
}
}
}
@@ -339,8 +466,9 @@ NodeService::ReasonForTermination NodeService::run()
{
Mutex::Lock _l(_nets_m);
for (std::map<uint64_t, NetworkState>::iterator n(_nets.begin()); n != _nets.end(); ++n)
for (std::map<uint64_t, NetworkState>::iterator n(_nets.begin()); n != _nets.end(); ++n) {
delete n->second.tap;
}
_nets.clear();
}
@@ -458,6 +586,8 @@ void NodeService::phyOnDatagram(
void* data,
unsigned long len)
{
ZTS_UNUSED_ARG(uptr);
ZTS_UNUSED_ARG(localAddr);
if ((len >= 16) && (reinterpret_cast<const InetAddress*>(from)->ipScope() == InetAddress::IP_SCOPE_GLOBAL))
_lastDirectReceiveFromGlobal = OSUtils::now();
const ZT_ResultCode rc = _node->processWirePacket(
@@ -548,6 +678,7 @@ int NodeService::nodeVirtualNetworkConfigFunction(
void NodeService::nodeEventCallback(enum ZT_Event event, const void* metaData)
{
ZTS_UNUSED_ARG(metaData);
zts_node_info_t* nd = new zts_node_info_t;
nd->node_id = _node ? _node->address() : 0x0;
nd->ver_major = ZEROTIER_ONE_VERSION_MAJOR;
@@ -962,7 +1093,7 @@ int NodeService::networkHasRoute(uint64_t net_id, unsigned int family)
return false;
}
int NodeService::orbit(void* tptr, uint64_t moon_roots_id, uint64_t moon_seed)
int NodeService::orbit(uint64_t moon_roots_id, uint64_t moon_seed)
{
if (! moon_roots_id || ! moon_seed) {
return ZTS_ERR_ARG;
@@ -974,7 +1105,7 @@ int NodeService::orbit(void* tptr, uint64_t moon_roots_id, uint64_t moon_seed)
return _node->orbit(NULL, moon_roots_id, moon_seed);
}
int NodeService::deorbit(void* tptr, uint64_t moon_roots_id)
int NodeService::deorbit(uint64_t moon_roots_id)
{
if (! moon_roots_id) {
return ZTS_ERR_ARG;
@@ -1262,6 +1393,8 @@ void NodeService::nodeVirtualNetworkFrameFunction(
const void* data,
unsigned int len)
{
ZTS_UNUSED_ARG(vlanId);
ZTS_UNUSED_ARG(net_id);
NetworkState* n = reinterpret_cast<NetworkState*>(*nuptr);
if ((! n) || (! n->tap)) {
return;
@@ -1274,6 +1407,7 @@ int NodeService::nodePathCheckFunction(
const int64_t localSocket,
const struct sockaddr_storage* remoteAddr)
{
ZTS_UNUSED_ARG(localSocket);
// Make sure we're not trying to do ZeroTier-over-ZeroTier
{
Mutex::Lock _l(_nets_m);

View File

@@ -20,6 +20,8 @@
#ifndef ZTS_NODE_SERVICE_HPP
#define ZTS_NODE_SERVICE_HPP
#define ZTS_UNUSED_ARG(x) (void)x
#include "Binder.hpp"
#include "Mutex.hpp"
#include "Node.hpp"
@@ -47,7 +49,7 @@
namespace ZeroTier {
class InetAddress;
struct InetAddress;
class VirtualTap;
class MAC;
class Events;
@@ -303,10 +305,10 @@ class NodeService {
int getPathAtIdx(uint64_t peer_id, unsigned int idx, char* path, unsigned int len);
/** Orbit a moon */
int orbit(void* tptr, uint64_t moonWorldId, uint64_t moonSeed);
int orbit(uint64_t moonWorldId, uint64_t moonSeed);
/** De-orbit a moon */
int deorbit(void* tptr, uint64_t moonWorldId);
int deorbit(uint64_t moonWorldId);
/** Return the integer-form of the node's identity */
uint64_t getNodeId();
@@ -425,153 +427,69 @@ class NodeService {
void phyOnTcpConnect(PhySocket* sock, void** uptr, bool success)
{
// Intentionally left empty
ZTS_UNUSED_ARG(sock);
ZTS_UNUSED_ARG(uptr);
ZTS_UNUSED_ARG(success);
}
void phyOnTcpAccept(PhySocket* sockL, PhySocket* sockN, void** uptrL, void** uptrN, const struct sockaddr* from)
{
// Intentionally left empty
ZTS_UNUSED_ARG(sockL);
ZTS_UNUSED_ARG(sockN);
ZTS_UNUSED_ARG(uptrL);
ZTS_UNUSED_ARG(uptrN);
ZTS_UNUSED_ARG(from);
}
void phyOnTcpClose(PhySocket* sock, void** uptr)
{
// Intentionally left empty
ZTS_UNUSED_ARG(sock);
ZTS_UNUSED_ARG(uptr);
}
void phyOnTcpData(PhySocket* sock, void** uptr, void* data, unsigned long len)
{
// Intentionally left empty
ZTS_UNUSED_ARG(sock);
ZTS_UNUSED_ARG(uptr);
ZTS_UNUSED_ARG(data);
ZTS_UNUSED_ARG(len);
}
void phyOnTcpWritable(PhySocket* sock, void** uptr)
{
// Intentionally left empty
ZTS_UNUSED_ARG(sock);
ZTS_UNUSED_ARG(uptr);
}
void phyOnFileDescriptorActivity(PhySocket* sock, void** uptr, bool readable, bool writable)
{
// Intentionally left empty
ZTS_UNUSED_ARG(sock);
ZTS_UNUSED_ARG(uptr);
ZTS_UNUSED_ARG(readable);
ZTS_UNUSED_ARG(writable);
}
void phyOnUnixAccept(PhySocket* sockL, PhySocket* sockN, void** uptrL, void** uptrN)
{
// Intentionally left empty
ZTS_UNUSED_ARG(sockL);
ZTS_UNUSED_ARG(sockN);
ZTS_UNUSED_ARG(uptrL);
ZTS_UNUSED_ARG(uptrN);
}
void phyOnUnixClose(PhySocket* sock, void** uptr)
{
// Intentionally left empty
ZTS_UNUSED_ARG(sock);
ZTS_UNUSED_ARG(uptr);
}
void phyOnUnixData(PhySocket* sock, void** uptr, void* data, unsigned long len)
{
// Intentionally left empty
ZTS_UNUSED_ARG(sock);
ZTS_UNUSED_ARG(uptr);
ZTS_UNUSED_ARG(data);
ZTS_UNUSED_ARG(len);
}
void phyOnUnixWritable(PhySocket* sock, void** uptr)
{
// Intentionally left empty
ZTS_UNUSED_ARG(sock);
ZTS_UNUSED_ARG(uptr);
}
};
static int SnodeVirtualNetworkConfigFunction(
ZT_Node* node,
void* uptr,
void* tptr,
uint64_t net_id,
void** nuptr,
enum ZT_VirtualNetworkConfigOperation op,
const ZT_VirtualNetworkConfig* nwconf)
{
return reinterpret_cast<NodeService*>(uptr)->nodeVirtualNetworkConfigFunction(net_id, nuptr, op, nwconf);
}
static void SnodeEventCallback(ZT_Node* node, void* uptr, void* tptr, enum ZT_Event event, const void* metaData)
{
reinterpret_cast<NodeService*>(uptr)->nodeEventCallback(event, metaData);
}
static void SnodeStatePutFunction(
ZT_Node* node,
void* uptr,
void* tptr,
enum ZT_StateObjectType type,
const uint64_t id[2],
const void* data,
int len)
{
reinterpret_cast<NodeService*>(uptr)->nodeStatePutFunction(type, id, data, len);
}
static int SnodeStateGetFunction(
ZT_Node* node,
void* uptr,
void* tptr,
enum ZT_StateObjectType type,
const uint64_t id[2],
void* data,
unsigned int maxlen)
{
return reinterpret_cast<NodeService*>(uptr)->nodeStateGetFunction(type, id, data, maxlen);
}
static int SnodeWirePacketSendFunction(
ZT_Node* node,
void* uptr,
void* tptr,
int64_t localSocket,
const struct sockaddr_storage* addr,
const void* data,
unsigned int len,
unsigned int ttl)
{
return reinterpret_cast<NodeService*>(uptr)->nodeWirePacketSendFunction(localSocket, addr, data, len, ttl);
}
static void SnodeVirtualNetworkFrameFunction(
ZT_Node* node,
void* uptr,
void* tptr,
uint64_t net_id,
void** nuptr,
uint64_t sourceMac,
uint64_t destMac,
unsigned int etherType,
unsigned int vlanId,
const void* data,
unsigned int len)
{
reinterpret_cast<NodeService*>(uptr)
->nodeVirtualNetworkFrameFunction(net_id, nuptr, sourceMac, destMac, etherType, vlanId, data, len);
}
static int SnodePathCheckFunction(
ZT_Node* node,
void* uptr,
void* tptr,
uint64_t ztaddr,
int64_t localSocket,
const struct sockaddr_storage* remoteAddr)
{
return reinterpret_cast<NodeService*>(uptr)->nodePathCheckFunction(ztaddr, localSocket, remoteAddr);
}
static int SnodePathLookupFunction(
ZT_Node* node,
void* uptr,
void* tptr,
uint64_t ztaddr,
int family,
struct sockaddr_storage* result)
{
return reinterpret_cast<NodeService*>(uptr)->nodePathLookupFunction(ztaddr, family, result);
}
static void StapFrameHandler(
void* uptr,
void* tptr,
uint64_t net_id,
const MAC& from,
const MAC& to,
unsigned int etherType,
unsigned int vlanId,
const void* data,
unsigned int len)
{
reinterpret_cast<NodeService*>(uptr)->tapFrameHandler(net_id, from, to, etherType, vlanId, data, len);
}
} // namespace ZeroTier
#endif

View File

@@ -23,6 +23,8 @@
#define ZTS_LWIP_THREAD_NAME "ZTNetworkStackThread"
#define VTAP_NAME_LEN 64
#define ZTS_UNUSED_ARG(x) (void)x
#include "Events.hpp"
#include "MAC.hpp"
#include "Phy.hpp"
@@ -173,15 +175,27 @@ class VirtualTap {
void phyOnTcpConnect(PhySocket* sock, void** uptr, bool success)
{
ZTS_UNUSED_ARG(sock);
ZTS_UNUSED_ARG(uptr);
ZTS_UNUSED_ARG(success);
}
void phyOnTcpAccept(PhySocket* sockL, PhySocket* sockN, void** uptrL, void** uptrN, const struct sockaddr* from)
{
ZTS_UNUSED_ARG(sockL);
ZTS_UNUSED_ARG(sockN);
ZTS_UNUSED_ARG(uptrL);
ZTS_UNUSED_ARG(uptrN);
ZTS_UNUSED_ARG(from);
}
void phyOnTcpClose(PhySocket* sock, void** uptr)
{
ZTS_UNUSED_ARG(sock);
ZTS_UNUSED_ARG(uptr);
}
void phyOnUnixClose(PhySocket* sock, void** uptr)
{
ZTS_UNUSED_ARG(sock);
ZTS_UNUSED_ARG(uptr);
}
};