Fixed some debug trace format specifiers to reduce compile-time warnings

This commit is contained in:
Joseph Henry
2018-02-21 11:42:07 -08:00
parent 5fb501299e
commit 9fba2a6d32
11 changed files with 50 additions and 77 deletions

View File

@@ -68,10 +68,10 @@ int main(int argc, char **argv)
DEBUG_TEST("Waiting for libzt to come online...\n"); DEBUG_TEST("Waiting for libzt to come online...\n");
uint64_t nwid = strtoull(nwidstr.c_str(),NULL,16); uint64_t nwid = strtoull(nwidstr.c_str(),NULL,16);
printf("nwid=%llx\n", nwid); printf("nwid=%llx\n", (unsigned long long)nwid);
zts_startjoin(path.c_str(), nwid); zts_startjoin(path.c_str(), nwid);
uint64_t nodeId = zts_get_node_id(); uint64_t nodeId = zts_get_node_id();
DEBUG_TEST("I am %llx", nodeId); DEBUG_TEST("I am %llx", (unsigned long long)nodeId);
if ((sockfd = zts_socket(AF_INET, SOCK_STREAM, 0)) < 0) { if ((sockfd = zts_socket(AF_INET, SOCK_STREAM, 0)) < 0) {
DEBUG_ERROR("error creating ZeroTier socket"); DEBUG_ERROR("error creating ZeroTier socket");

View File

@@ -64,10 +64,10 @@ int main(int argc, char **argv)
DEBUG_TEST("Waiting for libzt to come online...\n"); DEBUG_TEST("Waiting for libzt to come online...\n");
uint64_t nwid = strtoull(nwidstr.c_str(),NULL,16); uint64_t nwid = strtoull(nwidstr.c_str(),NULL,16);
printf("nwid=%llx\n", nwid); printf("nwid=%llx\n", (unsigned long long)nwid);
zts_startjoin(path.c_str(), nwid); zts_startjoin(path.c_str(), nwid);
uint64_t nodeId = zts_get_node_id(); uint64_t nodeId = zts_get_node_id();
DEBUG_TEST("I am %llx", nodeId); DEBUG_TEST("I am %llx", (unsigned long long)nodeId);
if ((sockfd = zts_socket(AF_INET, SOCK_STREAM, 0)) < 0) { if ((sockfd = zts_socket(AF_INET, SOCK_STREAM, 0)) < 0) {
DEBUG_ERROR("error creating ZeroTier socket"); DEBUG_ERROR("error creating ZeroTier socket");

View File

@@ -86,10 +86,10 @@ int main(int argc, char **argv)
DEBUG_TEST("Waiting for libzt to come online...\n"); DEBUG_TEST("Waiting for libzt to come online...\n");
uint64_t nwid = generate_adhoc_nwid_from_port(remote_port); uint64_t nwid = generate_adhoc_nwid_from_port(remote_port);
printf("nwid=%llx\n", nwid); printf("nwid=%llx\n", (unsigned long long)nwid);
zts_startjoin(path.c_str(), nwid); zts_startjoin(path.c_str(), nwid);
uint64_t nodeId = zts_get_node_id(); uint64_t nodeId = zts_get_node_id();
DEBUG_TEST("I am %llx", nodeId); DEBUG_TEST("I am %llx", (unsigned long long)nodeId);
if ((sockfd = zts_socket(AF_INET6, SOCK_STREAM, 0)) < 0) { if ((sockfd = zts_socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
DEBUG_ERROR("error creating ZeroTier socket"); DEBUG_ERROR("error creating ZeroTier socket");

View File

@@ -86,10 +86,10 @@ int main(int argc, char **argv)
DEBUG_TEST("Waiting for libzt to come online...\n"); DEBUG_TEST("Waiting for libzt to come online...\n");
nwid = generate_adhoc_nwid_from_port(bind_port); nwid = generate_adhoc_nwid_from_port(bind_port);
printf("nwid=%llx\n", nwid); printf("nwid=%llx\n", (unsigned long long)nwid);
zts_startjoin(path.c_str(), nwid); zts_startjoin(path.c_str(), nwid);
uint64_t nodeId = zts_get_node_id(); uint64_t nodeId = zts_get_node_id();
DEBUG_TEST("I am %llx", nodeId); DEBUG_TEST("I am %llx", (unsigned long long)nodeId);
if ((sockfd = zts_socket(AF_INET6, SOCK_STREAM, 0)) < 0) { if ((sockfd = zts_socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
DEBUG_ERROR("error creating ZeroTier socket"); DEBUG_ERROR("error creating ZeroTier socket");

View File

@@ -68,10 +68,10 @@ int main(int argc, char **argv)
DEBUG_TEST("Waiting for libzt to come online...\n"); DEBUG_TEST("Waiting for libzt to come online...\n");
uint64_t nwid = strtoull(nwidstr.c_str(),NULL,16); uint64_t nwid = strtoull(nwidstr.c_str(),NULL,16);
printf("nwid=%llx\n", nwid); printf("nwid=%llx\n", (unsigned long long)nwid);
zts_startjoin(path.c_str(), nwid); zts_startjoin(path.c_str(), nwid);
uint64_t nodeId = zts_get_node_id(); uint64_t nodeId = zts_get_node_id();
DEBUG_TEST("I am %llx", nodeId); DEBUG_TEST("I am %llx", (unsigned long long)nodeId);
if ((sockfd = zts_socket(AF_INET6, SOCK_STREAM, 0)) < 0) { if ((sockfd = zts_socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
DEBUG_ERROR("error creating ZeroTier socket"); DEBUG_ERROR("error creating ZeroTier socket");

View File

@@ -65,10 +65,10 @@ int main(int argc, char **argv)
DEBUG_TEST("Waiting for libzt to come online...\n"); DEBUG_TEST("Waiting for libzt to come online...\n");
uint64_t nwid = strtoull(nwidstr.c_str(),NULL,16); uint64_t nwid = strtoull(nwidstr.c_str(),NULL,16);
printf("nwid=%llx\n", nwid); printf("nwid=%llx\n", (unsigned long long)nwid);
zts_startjoin(path.c_str(), nwid); zts_startjoin(path.c_str(), nwid);
uint64_t nodeId = zts_get_node_id(); uint64_t nodeId = zts_get_node_id();
DEBUG_TEST("I am %llx", nodeId); DEBUG_TEST("I am %llx", (unsigned long long)nodeId);
if ((sockfd = zts_socket(AF_INET6, SOCK_STREAM, 0)) < 0) { if ((sockfd = zts_socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
DEBUG_ERROR("error creating ZeroTier socket"); DEBUG_ERROR("error creating ZeroTier socket");

View File

@@ -279,15 +279,6 @@ ZT_SOCKET_API unsigned long zts_get_peer_count();
*/ */
ZT_SOCKET_API int ZTCALL zts_get_peer_address(char *peer, const uint64_t nodeId); ZT_SOCKET_API int ZTCALL zts_get_peer_address(char *peer, const uint64_t nodeId);
/**
* @brief Allow or disallow this instance of libzt to be controlled via HTTP requests
*
* @usage Call this after zts_start() has succeeded
* @param allowed True or false value
* @return
*/
ZT_SOCKET_API void ZTCALL zts_allow_http_control(bool allowed);
/****************************************************************************/ /****************************************************************************/
/* POSIX-like socket API */ /* POSIX-like socket API */
/****************************************************************************/ /****************************************************************************/

View File

@@ -81,7 +81,7 @@ VirtualTap::VirtualTap(
// set virtual tap interface name (full) // set virtual tap interface name (full)
memset(vtap_full_name, 0, sizeof(vtap_full_name)); memset(vtap_full_name, 0, sizeof(vtap_full_name));
ifindex = devno; ifindex = devno;
snprintf(vtap_full_name, sizeof(vtap_full_name), "libzt%d-%llx", devno++, _nwid); snprintf(vtap_full_name, sizeof(vtap_full_name), "libzt%d-%llx", devno++, (unsigned long long)_nwid);
_dev = vtap_full_name; _dev = vtap_full_name;
DEBUG_INFO("set VirtualTap interface name to: %s", _dev.c_str()); DEBUG_INFO("set VirtualTap interface name to: %s", _dev.c_str());
// set virtual tap interface name (abbreviated) // set virtual tap interface name (abbreviated)
@@ -128,7 +128,7 @@ bool VirtualTap::addIp(const InetAddress &ip)
{ {
#if defined(NO_STACK) #if defined(NO_STACK)
char ipbuf[INET6_ADDRSTRLEN]; char ipbuf[INET6_ADDRSTRLEN];
DEBUG_INFO("addIp=%s, nwid=%llx", ip.toString(ipbuf), _nwid); DEBUG_INFO("addIp=%s, nwid=%llx", ip.toString(ipbuf), (unsigned long long)_nwid);
_ips.push_back(ip); _ips.push_back(ip);
std::sort(_ips.begin(),_ips.end()); std::sort(_ips.begin(),_ips.end());
return true; return true;
@@ -488,7 +488,7 @@ int VirtualTap::Write(VirtualSocket *vs, void *data, ssize_t len)
#if defined(NO_STACK) #if defined(NO_STACK)
return -1; return -1;
#endif #endif
DEBUG_EXTRA("vs=%p, fd=%d, data=%p, len=%d", vs, vs->app_fd, data, len); DEBUG_EXTRA("vs=%p, fd=%d, data=%p, len=%lu", vs, vs->app_fd, data, (unsigned long)len);
int err = -1; int err = -1;
#if defined(LIBZT_RAW) #if defined(LIBZT_RAW)
// VL2, SOCK_RAW, no network stack // VL2, SOCK_RAW, no network stack
@@ -652,7 +652,7 @@ void VirtualTap::Housekeeping()
} }
} }
if (found == false) { if (found == false) {
DEBUG_INFO("removing route to <target=%s>", routes[i].first.toString(ipbuf), routes[i].second.toString(ipbuf2)); DEBUG_INFO("removing route to <%s,%s>", routes[i].first.toString(ipbuf), routes[i].second.toString(ipbuf2));
routes.erase(routes.begin() + i); routes.erase(routes.begin() + i);
routeDelete(routes[i].first, routes[i].second); routeDelete(routes[i].first, routes[i].second);
} }

View File

@@ -62,7 +62,6 @@ WSADATA wsaData;
#include <Windows.h> #include <Windows.h>
#endif #endif
// prototype
void api_sleep(int interval_ms); void api_sleep(int interval_ms);
/****************************************************************************/ /****************************************************************************/
@@ -172,7 +171,6 @@ VirtualTap *getAnyTap()
uint64_t zts_get_node_id_from_file(const char *filepath) uint64_t zts_get_node_id_from_file(const char *filepath)
{ {
DEBUG_EXTRA("");
std::string fname("identity.public"); std::string fname("identity.public");
std::string fpath(filepath); std::string fpath(filepath);
std::string oldid; std::string oldid;
@@ -300,7 +298,7 @@ int zts_get_address_at_index(
int zts_set_service_port(int portno) int zts_set_service_port(int portno)
{ {
if (portno > -1 && portno < 65535) { if (portno > -1 && portno < 65535) {
// 0 is allowed, see docs // 0 is allowed, signals zt service to bind to a random port
servicePort = portno; servicePort = portno;
return 0; return 0;
} }
@@ -316,14 +314,9 @@ int zts_get_address(const uint64_t nwid, struct sockaddr_storage *addr,
} }
VirtualTap *tap = getTapByNWID(nwid); VirtualTap *tap = getTapByNWID(nwid);
if (!tap) { if (!tap) {
//DEBUG_ERROR("!tap");
return -1; return -1;
} }
_vtaps_lock.lock(); _vtaps_lock.lock();
if (!tap->_ips.size()) {
// DEBUG_ERROR("!sz");
}
else {
socklen_t addrlen = sizeof(struct sockaddr_storage); socklen_t addrlen = sizeof(struct sockaddr_storage);
for (size_t i=0; i<tap->_ips.size(); i++) { for (size_t i=0; i<tap->_ips.size(); i++) {
if (address_family == AF_INET) { if (address_family == AF_INET) {
@@ -343,7 +336,6 @@ int zts_get_address(const uint64_t nwid, struct sockaddr_storage *addr,
} }
} }
} }
}
_vtaps_lock.unlock(); _vtaps_lock.unlock();
return err; // nothing found return err; // nothing found
} }
@@ -377,7 +369,7 @@ void zts_get_rfc4193_addr(struct sockaddr_storage *addr, const uint64_t nwid, co
int zts_join(const uint64_t nwid) int zts_join(const uint64_t nwid)
{ {
DEBUG_EXTRA(""); DEBUG_INFO("joining %llx", (unsigned long long)nwid);
if (nwid == 0) { if (nwid == 0) {
return -1; return -1;
} }
@@ -397,7 +389,7 @@ int zts_join(const uint64_t nwid)
int zts_leave(const uint64_t nwid) int zts_leave(const uint64_t nwid)
{ {
DEBUG_EXTRA(""); DEBUG_INFO("leaving %llx", (unsigned long long)nwid);
if (nwid == 0) { if (nwid == 0) {
return -1; return -1;
} }
@@ -428,7 +420,6 @@ int zts_ready()
int zts_start(const char *path, bool blocking = false) int zts_start(const char *path, bool blocking = false)
{ {
DEBUG_EXTRA("");
if (zt1Service) { if (zt1Service) {
return 0; // already initialized, ok return 0; // already initialized, ok
} }
@@ -455,7 +446,7 @@ int zts_start(const char *path, bool blocking = false)
while (zt1Service->getNode()->address() <= 0) { while (zt1Service->getNode()->address() <= 0) {
api_sleep(ZTO_WRAPPER_CHECK_INTERVAL); api_sleep(ZTO_WRAPPER_CHECK_INTERVAL);
} }
DEBUG_EXTRA("node=%llx", zts_get_node_id()); DEBUG_EXTRA("node=%llx", (unsigned long long)zts_get_node_id());
DEBUG_EXTRA("waiting for node to come online. ensure the node is authorized to join the network"); DEBUG_EXTRA("waiting for node to come online. ensure the node is authorized to join the network");
while (status.online <= 0) { while (status.online <= 0) {
api_sleep(ZTO_WRAPPER_CHECK_INTERVAL); api_sleep(ZTO_WRAPPER_CHECK_INTERVAL);
@@ -467,7 +458,6 @@ int zts_start(const char *path, bool blocking = false)
int zts_startjoin(const char *path, const uint64_t nwid) int zts_startjoin(const char *path, const uint64_t nwid)
{ {
DEBUG_EXTRA("");
int err = zts_start(path, true); int err = zts_start(path, true);
while (true) { while (true) {
try { try {
@@ -475,7 +465,8 @@ int zts_startjoin(const char *path, const uint64_t nwid)
break; break;
} }
catch( ... ) { catch( ... ) {
DEBUG_ERROR("there was a problem joining the virtual network %s", nwid); DEBUG_ERROR("there was a problem joining the virtual network %llx",
(unsigned long long)nwid);
api_sleep(ZTO_WRAPPER_CHECK_INTERVAL); api_sleep(ZTO_WRAPPER_CHECK_INTERVAL);
} }
} }
@@ -487,7 +478,6 @@ int zts_startjoin(const char *path, const uint64_t nwid)
void zts_stop() void zts_stop()
{ {
DEBUG_EXTRA("");
if (zt1Service) { if (zt1Service) {
zt1Service->terminate(); zt1Service->terminate();
// disableTaps(); // disableTaps();
@@ -499,7 +489,6 @@ void zts_stop()
void zts_get_path(char *homePath, size_t len) void zts_get_path(char *homePath, size_t len)
{ {
DEBUG_EXTRA("");
if (homeDir.length()) { if (homeDir.length()) {
memset(homePath, 0, len); memset(homePath, 0, len);
size_t buf_len = len < homeDir.length() ? len : homeDir.length(); size_t buf_len = len < homeDir.length() ? len : homeDir.length();
@@ -509,16 +498,14 @@ void zts_get_path(char *homePath, size_t len)
uint64_t zts_get_node_id() uint64_t zts_get_node_id()
{ {
DEBUG_EXTRA("");
if (zt1Service) { if (zt1Service) {
return zt1Service->getNode()->address(); return zt1Service->getNode()->address();
} }
return -1; return 0;
} }
unsigned long zts_get_peer_count() unsigned long zts_get_peer_count()
{ {
DEBUG_EXTRA("");
if (zt1Service) { if (zt1Service) {
return zt1Service->getNode()->peers()->peerCount; return zt1Service->getNode()->peers()->peerCount;
} }
@@ -529,7 +516,7 @@ unsigned long zts_get_peer_count()
int zts_get_peer_address(char *peer, const uint64_t nodeId) int zts_get_peer_address(char *peer, const uint64_t nodeId)
{ {
DEBUG_EXTRA(""); /*
if (zt1Service) { if (zt1Service) {
ZT_PeerList *pl = zt1Service->getNode()->peers(); ZT_PeerList *pl = zt1Service->getNode()->peers();
// uint64_t addr; // uint64_t addr;
@@ -542,12 +529,8 @@ int zts_get_peer_address(char *peer, const uint64_t nodeId)
else { else {
return -1; return -1;
} }
} */
return -1;
void zts_allow_http_control(bool allowed)
{
DEBUG_EXTRA("");
// TODO
} }
bool _ipv6_in_subnet(ZeroTier::InetAddress *subnet, ZeroTier::InetAddress *addr) bool _ipv6_in_subnet(ZeroTier::InetAddress *subnet, ZeroTier::InetAddress *addr)

View File

@@ -221,7 +221,7 @@ int zts_getsockopt(int fd, int level, int optname, void *optval, socklen_t *optl
int zts_getsockname(int fd, struct sockaddr *addr, socklen_t *addrlen) int zts_getsockname(int fd, struct sockaddr *addr, socklen_t *addrlen)
{ {
DEBUG_EXTRA("fd=%p", fd); DEBUG_EXTRA("fd=%d", fd);
if (zts_ready() == false) { if (zts_ready() == false) {
DEBUG_ERROR("service not started yet, call zts_startjoin()"); DEBUG_ERROR("service not started yet, call zts_startjoin()");
return -1; return -1;
@@ -423,7 +423,7 @@ int zts_fcntl(int fd, int cmd, int flags)
int zts_ioctl(int fd, unsigned long request, void *argp) int zts_ioctl(int fd, unsigned long request, void *argp)
{ {
DEBUG_EXTRA("fd=%d, req=%d", fd, request); DEBUG_EXTRA("fd=%d", fd);
if (zts_ready() == false) { if (zts_ready() == false) {
DEBUG_ERROR("service not started yet, call zts_startjoin()"); DEBUG_ERROR("service not started yet, call zts_startjoin()");
return -1; return -1;
@@ -442,7 +442,7 @@ int zts_ioctl(int fd, unsigned long request, void *argp)
ssize_t zts_sendto(int fd, const void *buf, size_t len, int flags, ssize_t zts_sendto(int fd, const void *buf, size_t len, int flags,
const struct sockaddr *addr, socklen_t addrlen) const struct sockaddr *addr, socklen_t addrlen)
{ {
DEBUG_TRANS("fd=%d, len=%d", fd, len); DEBUG_TRANS("fd=%d, len=%zu", fd, len);
if (zts_ready() == false) { if (zts_ready() == false) {
DEBUG_ERROR("service not started yet, call zts_startjoin()"); DEBUG_ERROR("service not started yet, call zts_startjoin()");
return -1; return -1;
@@ -464,7 +464,7 @@ ssize_t zts_sendto(int fd, const void *buf, size_t len, int flags,
ssize_t zts_send(int fd, const void *buf, size_t len, int flags) ssize_t zts_send(int fd, const void *buf, size_t len, int flags)
{ {
DEBUG_TRANS("fd=%d, len=%d", fd, len); DEBUG_TRANS("fd=%d, len=%zu", fd, len);
if (zts_ready() == false) { if (zts_ready() == false) {
DEBUG_ERROR("service not started yet, call zts_startjoin()"); DEBUG_ERROR("service not started yet, call zts_startjoin()");
return -1; return -1;
@@ -500,7 +500,7 @@ ssize_t zts_sendmsg(int fd, const struct msghdr *msg, int flags)
ssize_t zts_recv(int fd, void *buf, size_t len, int flags) ssize_t zts_recv(int fd, void *buf, size_t len, int flags)
{ {
DEBUG_TRANS("fd=%d", fd); DEBUG_TRANS("fd=%d, len=%zu", fd);
if (zts_ready() == false) { if (zts_ready() == false) {
DEBUG_ERROR("service not started yet, call zts_startjoin()"); DEBUG_ERROR("service not started yet, call zts_startjoin()");
return -1; return -1;
@@ -519,7 +519,7 @@ ssize_t zts_recv(int fd, void *buf, size_t len, int flags)
ssize_t zts_recvfrom(int fd, void *buf, size_t len, int flags, ssize_t zts_recvfrom(int fd, void *buf, size_t len, int flags,
struct sockaddr *addr, socklen_t *addrlen) struct sockaddr *addr, socklen_t *addrlen)
{ {
DEBUG_TRANS("fd=%d", fd); DEBUG_TRANS("fd=%d, len=%zu", fd);
if (zts_ready() == false) { if (zts_ready() == false) {
DEBUG_ERROR("service not started yet, call zts_startjoin()"); DEBUG_ERROR("service not started yet, call zts_startjoin()");
return -1; return -1;
@@ -535,7 +535,7 @@ ssize_t zts_recvfrom(int fd, void *buf, size_t len, int flags,
#endif #endif
} }
ssize_t zts_recvmsg(int fd, struct msghdr *msg,int flags) ssize_t zts_recvmsg(int fd, struct msghdr *msg, int flags)
{ {
DEBUG_TRANS("fd=%d", fd); DEBUG_TRANS("fd=%d", fd);
if (zts_ready() == false) { if (zts_ready() == false) {
@@ -556,7 +556,7 @@ ssize_t zts_recvmsg(int fd, struct msghdr *msg,int flags)
int zts_read(int fd, void *buf, size_t len) int zts_read(int fd, void *buf, size_t len)
{ {
DEBUG_TRANS("fd=%d, len=%d", fd, len); DEBUG_TRANS("fd=%d, len=%zu", fd, len);
if (zts_ready() == false) { if (zts_ready() == false) {
DEBUG_ERROR("service not started yet, call zts_startjoin()"); DEBUG_ERROR("service not started yet, call zts_startjoin()");
return -1; return -1;
@@ -574,7 +574,7 @@ int zts_read(int fd, void *buf, size_t len)
int zts_write(int fd, const void *buf, size_t len) int zts_write(int fd, const void *buf, size_t len)
{ {
DEBUG_EXTRA("fd=%d, len=%d", fd, len); DEBUG_TRANS("fd=%d, len=%zu", fd, len);
if (zts_ready() == false) { if (zts_ready() == false) {
DEBUG_ERROR("service not started yet, call zts_startjoin()"); DEBUG_ERROR("service not started yet, call zts_startjoin()");
return -1; return -1;

View File

@@ -181,7 +181,6 @@ namespace ZeroTier {
} }
// TODO: ZT_SOCKET_API int ZTCALL zts_get_peer_address(char *peer, const uint64_t nodeId); // TODO: ZT_SOCKET_API int ZTCALL zts_get_peer_address(char *peer, const uint64_t nodeId);
// TODO: ZT_SOCKET_API void ZTCALL zts_allow_http_control(bool allowed);
/****************************************************************************/ /****************************************************************************/
/* ZeroTier Socket API */ /* ZeroTier Socket API */