Fixed some debug trace format specifiers to reduce compile-time warnings
This commit is contained in:
@@ -68,10 +68,10 @@ int main(int argc, char **argv)
|
||||
|
||||
DEBUG_TEST("Waiting for libzt to come online...\n");
|
||||
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);
|
||||
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) {
|
||||
DEBUG_ERROR("error creating ZeroTier socket");
|
||||
|
||||
@@ -64,10 +64,10 @@ int main(int argc, char **argv)
|
||||
|
||||
DEBUG_TEST("Waiting for libzt to come online...\n");
|
||||
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);
|
||||
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) {
|
||||
DEBUG_ERROR("error creating ZeroTier socket");
|
||||
|
||||
@@ -86,10 +86,10 @@ int main(int argc, char **argv)
|
||||
|
||||
DEBUG_TEST("Waiting for libzt to come online...\n");
|
||||
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);
|
||||
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) {
|
||||
DEBUG_ERROR("error creating ZeroTier socket");
|
||||
|
||||
@@ -86,10 +86,10 @@ int main(int argc, char **argv)
|
||||
|
||||
DEBUG_TEST("Waiting for libzt to come online...\n");
|
||||
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);
|
||||
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) {
|
||||
DEBUG_ERROR("error creating ZeroTier socket");
|
||||
|
||||
@@ -68,10 +68,10 @@ int main(int argc, char **argv)
|
||||
|
||||
DEBUG_TEST("Waiting for libzt to come online...\n");
|
||||
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);
|
||||
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) {
|
||||
DEBUG_ERROR("error creating ZeroTier socket");
|
||||
|
||||
@@ -65,10 +65,10 @@ int main(int argc, char **argv)
|
||||
|
||||
DEBUG_TEST("Waiting for libzt to come online...\n");
|
||||
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);
|
||||
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) {
|
||||
DEBUG_ERROR("error creating ZeroTier socket");
|
||||
|
||||
@@ -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);
|
||||
|
||||
/**
|
||||
* @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 */
|
||||
/****************************************************************************/
|
||||
|
||||
@@ -81,7 +81,7 @@ VirtualTap::VirtualTap(
|
||||
// set virtual tap interface name (full)
|
||||
memset(vtap_full_name, 0, sizeof(vtap_full_name));
|
||||
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;
|
||||
DEBUG_INFO("set VirtualTap interface name to: %s", _dev.c_str());
|
||||
// set virtual tap interface name (abbreviated)
|
||||
@@ -128,7 +128,7 @@ bool VirtualTap::addIp(const InetAddress &ip)
|
||||
{
|
||||
#if defined(NO_STACK)
|
||||
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);
|
||||
std::sort(_ips.begin(),_ips.end());
|
||||
return true;
|
||||
@@ -488,7 +488,7 @@ int VirtualTap::Write(VirtualSocket *vs, void *data, ssize_t len)
|
||||
#if defined(NO_STACK)
|
||||
return -1;
|
||||
#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;
|
||||
#if defined(LIBZT_RAW)
|
||||
// VL2, SOCK_RAW, no network stack
|
||||
@@ -652,7 +652,7 @@ void VirtualTap::Housekeeping()
|
||||
}
|
||||
}
|
||||
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);
|
||||
routeDelete(routes[i].first, routes[i].second);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ WSADATA wsaData;
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
// prototype
|
||||
void api_sleep(int interval_ms);
|
||||
|
||||
/****************************************************************************/
|
||||
@@ -172,7 +171,6 @@ VirtualTap *getAnyTap()
|
||||
|
||||
uint64_t zts_get_node_id_from_file(const char *filepath)
|
||||
{
|
||||
DEBUG_EXTRA("");
|
||||
std::string fname("identity.public");
|
||||
std::string fpath(filepath);
|
||||
std::string oldid;
|
||||
@@ -300,7 +298,7 @@ int zts_get_address_at_index(
|
||||
int zts_set_service_port(int portno)
|
||||
{
|
||||
if (portno > -1 && portno < 65535) {
|
||||
// 0 is allowed, see docs
|
||||
// 0 is allowed, signals zt service to bind to a random port
|
||||
servicePort = portno;
|
||||
return 0;
|
||||
}
|
||||
@@ -316,31 +314,25 @@ int zts_get_address(const uint64_t nwid, struct sockaddr_storage *addr,
|
||||
}
|
||||
VirtualTap *tap = getTapByNWID(nwid);
|
||||
if (!tap) {
|
||||
//DEBUG_ERROR("!tap");
|
||||
return -1;
|
||||
}
|
||||
_vtaps_lock.lock();
|
||||
if (!tap->_ips.size()) {
|
||||
// DEBUG_ERROR("!sz");
|
||||
}
|
||||
else {
|
||||
socklen_t addrlen = sizeof(struct sockaddr_storage);
|
||||
for (size_t i=0; i<tap->_ips.size(); i++) {
|
||||
if (address_family == AF_INET) {
|
||||
if (tap->_ips[i].isV4()) {
|
||||
memcpy(addr, &(tap->_ips[i]), addrlen);
|
||||
addr->ss_family = AF_INET;
|
||||
err = 0;
|
||||
break;
|
||||
}
|
||||
socklen_t addrlen = sizeof(struct sockaddr_storage);
|
||||
for (size_t i=0; i<tap->_ips.size(); i++) {
|
||||
if (address_family == AF_INET) {
|
||||
if (tap->_ips[i].isV4()) {
|
||||
memcpy(addr, &(tap->_ips[i]), addrlen);
|
||||
addr->ss_family = AF_INET;
|
||||
err = 0;
|
||||
break;
|
||||
}
|
||||
if (address_family == AF_INET6) {
|
||||
if (tap->_ips[i].isV6()) {
|
||||
memcpy(addr, &(tap->_ips[i]), addrlen);
|
||||
addr->ss_family = AF_INET6;
|
||||
err = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (address_family == AF_INET6) {
|
||||
if (tap->_ips[i].isV6()) {
|
||||
memcpy(addr, &(tap->_ips[i]), addrlen);
|
||||
addr->ss_family = AF_INET6;
|
||||
err = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
DEBUG_EXTRA("");
|
||||
DEBUG_INFO("joining %llx", (unsigned long long)nwid);
|
||||
if (nwid == 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -397,7 +389,7 @@ int zts_join(const uint64_t nwid)
|
||||
|
||||
int zts_leave(const uint64_t nwid)
|
||||
{
|
||||
DEBUG_EXTRA("");
|
||||
DEBUG_INFO("leaving %llx", (unsigned long long)nwid);
|
||||
if (nwid == 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -428,7 +420,6 @@ int zts_ready()
|
||||
|
||||
int zts_start(const char *path, bool blocking = false)
|
||||
{
|
||||
DEBUG_EXTRA("");
|
||||
if (zt1Service) {
|
||||
return 0; // already initialized, ok
|
||||
}
|
||||
@@ -455,7 +446,7 @@ int zts_start(const char *path, bool blocking = false)
|
||||
while (zt1Service->getNode()->address() <= 0) {
|
||||
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");
|
||||
while (status.online <= 0) {
|
||||
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)
|
||||
{
|
||||
DEBUG_EXTRA("");
|
||||
int err = zts_start(path, true);
|
||||
while (true) {
|
||||
try {
|
||||
@@ -475,7 +465,8 @@ int zts_startjoin(const char *path, const uint64_t nwid)
|
||||
break;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -487,7 +478,6 @@ int zts_startjoin(const char *path, const uint64_t nwid)
|
||||
|
||||
void zts_stop()
|
||||
{
|
||||
DEBUG_EXTRA("");
|
||||
if (zt1Service) {
|
||||
zt1Service->terminate();
|
||||
// disableTaps();
|
||||
@@ -499,7 +489,6 @@ void zts_stop()
|
||||
|
||||
void zts_get_path(char *homePath, size_t len)
|
||||
{
|
||||
DEBUG_EXTRA("");
|
||||
if (homeDir.length()) {
|
||||
memset(homePath, 0, len);
|
||||
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()
|
||||
{
|
||||
DEBUG_EXTRA("");
|
||||
if (zt1Service) {
|
||||
return zt1Service->getNode()->address();
|
||||
}
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long zts_get_peer_count()
|
||||
{
|
||||
DEBUG_EXTRA("");
|
||||
if (zt1Service) {
|
||||
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)
|
||||
{
|
||||
DEBUG_EXTRA("");
|
||||
/*
|
||||
if (zt1Service) {
|
||||
ZT_PeerList *pl = zt1Service->getNode()->peers();
|
||||
// uint64_t addr;
|
||||
@@ -542,12 +529,8 @@ int zts_get_peer_address(char *peer, const uint64_t nodeId)
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void zts_allow_http_control(bool allowed)
|
||||
{
|
||||
DEBUG_EXTRA("");
|
||||
// TODO
|
||||
*/
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool _ipv6_in_subnet(ZeroTier::InetAddress *subnet, ZeroTier::InetAddress *addr)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
DEBUG_EXTRA("fd=%p", fd);
|
||||
DEBUG_EXTRA("fd=%d", fd);
|
||||
if (zts_ready() == false) {
|
||||
DEBUG_ERROR("service not started yet, call zts_startjoin()");
|
||||
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)
|
||||
{
|
||||
DEBUG_EXTRA("fd=%d, req=%d", fd, request);
|
||||
DEBUG_EXTRA("fd=%d", fd);
|
||||
if (zts_ready() == false) {
|
||||
DEBUG_ERROR("service not started yet, call zts_startjoin()");
|
||||
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,
|
||||
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) {
|
||||
DEBUG_ERROR("service not started yet, call zts_startjoin()");
|
||||
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)
|
||||
{
|
||||
DEBUG_TRANS("fd=%d, len=%d", fd, len);
|
||||
DEBUG_TRANS("fd=%d, len=%zu", fd, len);
|
||||
if (zts_ready() == false) {
|
||||
DEBUG_ERROR("service not started yet, call zts_startjoin()");
|
||||
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)
|
||||
{
|
||||
DEBUG_TRANS("fd=%d", fd);
|
||||
DEBUG_TRANS("fd=%d, len=%zu", fd);
|
||||
if (zts_ready() == false) {
|
||||
DEBUG_ERROR("service not started yet, call zts_startjoin()");
|
||||
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,
|
||||
struct sockaddr *addr, socklen_t *addrlen)
|
||||
{
|
||||
DEBUG_TRANS("fd=%d", fd);
|
||||
DEBUG_TRANS("fd=%d, len=%zu", fd);
|
||||
if (zts_ready() == false) {
|
||||
DEBUG_ERROR("service not started yet, call zts_startjoin()");
|
||||
return -1;
|
||||
@@ -535,7 +535,7 @@ ssize_t zts_recvfrom(int fd, void *buf, size_t len, int flags,
|
||||
#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);
|
||||
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)
|
||||
{
|
||||
DEBUG_TRANS("fd=%d, len=%d", fd, len);
|
||||
DEBUG_TRANS("fd=%d, len=%zu", fd, len);
|
||||
if (zts_ready() == false) {
|
||||
DEBUG_ERROR("service not started yet, call zts_startjoin()");
|
||||
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)
|
||||
{
|
||||
DEBUG_EXTRA("fd=%d, len=%d", fd, len);
|
||||
DEBUG_TRANS("fd=%d, len=%zu", fd, len);
|
||||
if (zts_ready() == false) {
|
||||
DEBUG_ERROR("service not started yet, call zts_startjoin()");
|
||||
return -1;
|
||||
|
||||
@@ -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 void ZTCALL zts_allow_http_control(bool allowed);
|
||||
|
||||
/****************************************************************************/
|
||||
/* ZeroTier Socket API */
|
||||
|
||||
Reference in New Issue
Block a user