Fix various minor compile-time warnings
This commit is contained in:
@@ -924,7 +924,7 @@ ZTS_API int ZTCALL zts_central_api_get_self(int *http_response_code);
|
|||||||
*
|
*
|
||||||
* @return Standard HTTP response codes.
|
* @return Standard HTTP response codes.
|
||||||
*/
|
*/
|
||||||
ZTS_API int ZTCALL zts_central_api_get_network(int *http_response_code, int64_t nwid);
|
ZTS_API int ZTCALL zts_central_api_get_network(int *http_response_code, uint64_t nwid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Update or create a Network.
|
* @brief Update or create a Network.
|
||||||
@@ -936,7 +936,7 @@ ZTS_API int ZTCALL zts_central_api_get_network(int *http_response_code, int64_t
|
|||||||
*
|
*
|
||||||
* @return Standard HTTP response codes.
|
* @return Standard HTTP response codes.
|
||||||
*/
|
*/
|
||||||
ZTS_API int ZTCALL zts_central_api_update_network(int *http_response_code, int64_t nwid);
|
ZTS_API int ZTCALL zts_central_api_update_network(int *http_response_code, uint64_t nwid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Delete a Network.
|
* @brief Delete a Network.
|
||||||
@@ -946,7 +946,7 @@ ZTS_API int ZTCALL zts_central_api_update_network(int *http_response_code, int64
|
|||||||
*
|
*
|
||||||
* @return Standard HTTP response codes.
|
* @return Standard HTTP response codes.
|
||||||
*/
|
*/
|
||||||
ZTS_API int ZTCALL zts_central_api_delete_network(int *http_response_code, int64_t nwid);
|
ZTS_API int ZTCALL zts_central_api_delete_network(int *http_response_code, uint64_t nwid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get All Viewable Networks.
|
* @brief Get All Viewable Networks.
|
||||||
@@ -961,7 +961,7 @@ ZTS_API int ZTCALL zts_central_api_get_networks(int *http_response_code);
|
|||||||
*
|
*
|
||||||
* @return Standard HTTP response codes.
|
* @return Standard HTTP response codes.
|
||||||
*/
|
*/
|
||||||
ZTS_API int ZTCALL zts_central_api_get_member(int *http_response_code, int64_t nwid, int64_t nodeid);
|
ZTS_API int ZTCALL zts_central_api_get_member(int *http_response_code, int64_t nwid, uint64_t nodeid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Update or add a Member.
|
* @brief Update or add a Member.
|
||||||
@@ -970,7 +970,7 @@ ZTS_API int ZTCALL zts_central_api_get_member(int *http_response_code, int64_t n
|
|||||||
*
|
*
|
||||||
* @return Standard HTTP response codes.
|
* @return Standard HTTP response codes.
|
||||||
*/
|
*/
|
||||||
ZTS_API int ZTCALL zts_central_api_update_member(int *http_response_code, int64_t nwid, int64_t nodeid, char *post_data);
|
ZTS_API int ZTCALL zts_central_api_update_member(int *http_response_code, uint64_t nwid, uint64_t nodeid, char *post_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Authorize or (De)authorize a node on a network. This operation is idempotent.
|
* @brief Authorize or (De)authorize a node on a network. This operation is idempotent.
|
||||||
@@ -980,7 +980,7 @@ ZTS_API int ZTCALL zts_central_api_update_member(int *http_response_code, int64_
|
|||||||
* @param is_authed Boolean value for whether this node should be authorized
|
* @param is_authed Boolean value for whether this node should be authorized
|
||||||
* @return Standard HTTP response codes. ZTS_ERR_ARG invalid argument specified.
|
* @return Standard HTTP response codes. ZTS_ERR_ARG invalid argument specified.
|
||||||
*/
|
*/
|
||||||
ZTS_API int ZTCALL zts_set_node_auth(int *http_response_code, int64_t nwid, int64_t nodeid, int8_t is_authed);
|
ZTS_API int ZTCALL zts_set_node_auth(int *http_response_code, uint64_t nwid, uint64_t nodeid, uint64_t is_authed);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get All Members of a Network.
|
* @brief Get All Members of a Network.
|
||||||
@@ -989,7 +989,7 @@ ZTS_API int ZTCALL zts_set_node_auth(int *http_response_code, int64_t nwid, int6
|
|||||||
*
|
*
|
||||||
* @return Standard HTTP response codes.
|
* @return Standard HTTP response codes.
|
||||||
*/
|
*/
|
||||||
ZTS_API int ZTCALL zts_central_api_get_members_of_network(int *http_response_code, int64_t nwid);
|
ZTS_API int ZTCALL zts_central_api_get_members_of_network(int *http_response_code, uint64_t nwid);
|
||||||
|
|
||||||
#endif // NO_CENTRAL_API
|
#endif // NO_CENTRAL_API
|
||||||
|
|
||||||
|
|||||||
@@ -223,21 +223,21 @@ int zts_central_api_get_self(int *http_response_code)
|
|||||||
return _central_req(HTTP_GET, central_api_url, (char*)"/api/self", central_api_token, http_response_code, NULL);
|
return _central_req(HTTP_GET, central_api_url, (char*)"/api/self", central_api_token, http_response_code, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zts_central_api_get_network(int *http_response_code, int64_t nwid)
|
int zts_central_api_get_network(int *http_response_code, uint64_t nwid)
|
||||||
{
|
{
|
||||||
char req[64];
|
char req[64];
|
||||||
sprintf(req, "/api/network/%llx", nwid);
|
sprintf(req, "/api/network/%llx", nwid);
|
||||||
return _central_req(HTTP_GET, central_api_url, req, central_api_token, http_response_code, NULL);
|
return _central_req(HTTP_GET, central_api_url, req, central_api_token, http_response_code, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zts_central_api_update_network(int *http_response_code, int64_t nwid)
|
int zts_central_api_update_network(int *http_response_code, uint64_t nwid)
|
||||||
{
|
{
|
||||||
char req[64];
|
char req[64];
|
||||||
sprintf(req, "/api/network/%llx", nwid);
|
sprintf(req, "/api/network/%llx", nwid);
|
||||||
return _central_req(HTTP_POST, central_api_url, req, central_api_token, http_response_code, NULL);
|
return _central_req(HTTP_POST, central_api_url, req, central_api_token, http_response_code, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zts_central_api_delete_network(int *http_response_code, int64_t nwid)
|
int zts_central_api_delete_network(int *http_response_code, uint64_t nwid)
|
||||||
{
|
{
|
||||||
char req[64];
|
char req[64];
|
||||||
sprintf(req, "/api/network/%llx", nwid);
|
sprintf(req, "/api/network/%llx", nwid);
|
||||||
@@ -249,7 +249,7 @@ int zts_central_api_get_networks(int *http_response_code)
|
|||||||
return _central_req(HTTP_GET, central_api_url, (char*)"/api/network", central_api_token, http_response_code, NULL);
|
return _central_req(HTTP_GET, central_api_url, (char*)"/api/network", central_api_token, http_response_code, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zts_central_api_get_member(int *http_response_code, int64_t nwid, int64_t nodeid)
|
int zts_central_api_get_member(int *http_response_code, uint64_t nwid, uint64_t nodeid)
|
||||||
{
|
{
|
||||||
if (nwid == 0 || nodeid == 0) {
|
if (nwid == 0 || nodeid == 0) {
|
||||||
return ZTS_ERR_ARG;
|
return ZTS_ERR_ARG;
|
||||||
@@ -259,7 +259,7 @@ int zts_central_api_get_member(int *http_response_code, int64_t nwid, int64_t no
|
|||||||
return _central_req(HTTP_GET, central_api_url, req, central_api_token, http_response_code, NULL);
|
return _central_req(HTTP_GET, central_api_url, req, central_api_token, http_response_code, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zts_central_api_update_member(int *http_response_code, int64_t nwid, int64_t nodeid, char *post_data)
|
int zts_central_api_update_member(int *http_response_code, uuint64_t nwid, uuint64_t nodeid, char *post_data)
|
||||||
{
|
{
|
||||||
if (nwid == 0 || nodeid == 0 || post_data == NULL) {
|
if (nwid == 0 || nodeid == 0 || post_data == NULL) {
|
||||||
return ZTS_ERR_ARG;
|
return ZTS_ERR_ARG;
|
||||||
@@ -269,7 +269,7 @@ int zts_central_api_update_member(int *http_response_code, int64_t nwid, int64_t
|
|||||||
return _central_req(HTTP_POST, central_api_url, req, central_api_token, http_response_code, post_data);
|
return _central_req(HTTP_POST, central_api_url, req, central_api_token, http_response_code, post_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zts_set_node_auth(int *http_response_code, int64_t nwid, int64_t nodeid, int8_t is_authed)
|
int zts_set_node_auth(int *http_response_code, uint64_t nwid, uint64_t nodeid, int8_t is_authed)
|
||||||
{
|
{
|
||||||
if (is_authed != 0 && is_authed != 1) {
|
if (is_authed != 0 && is_authed != 1) {
|
||||||
return ZTS_ERR_ARG;
|
return ZTS_ERR_ARG;
|
||||||
@@ -284,7 +284,7 @@ int zts_set_node_auth(int *http_response_code, int64_t nwid, int64_t nodeid, int
|
|||||||
return zts_central_api_update_member(http_response_code, nwid, nodeid, config_data);
|
return zts_central_api_update_member(http_response_code, nwid, nodeid, config_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zts_central_api_get_members_of_network(int *http_response_code, int64_t nwid)
|
int zts_central_api_get_members_of_network(int *http_response_code, uint64_t nwid)
|
||||||
{
|
{
|
||||||
char req[64];
|
char req[64];
|
||||||
sprintf(req, "/api/network/%llx/member", nwid);
|
sprintf(req, "/api/network/%llx/member", nwid);
|
||||||
|
|||||||
@@ -132,9 +132,16 @@ int zts_start_with_identity(const char *key_pair_str, uint16_t key_buf_len,
|
|||||||
// an application restart is required now
|
// an application restart is required now
|
||||||
return ZTS_ERR_SERVICE;
|
return ZTS_ERR_SERVICE;
|
||||||
}
|
}
|
||||||
if (port < 0 || port > 0xFFFF) {
|
#ifdef SDK_JNI
|
||||||
|
_userEventCallbackFunc = callback;
|
||||||
|
#else
|
||||||
|
_userEventCallbackFunc = callback;
|
||||||
|
#endif
|
||||||
|
if (!_isCallbackRegistered()) {
|
||||||
|
// Must have a callback
|
||||||
return ZTS_ERR_ARG;
|
return ZTS_ERR_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceParameters *params = new serviceParameters();
|
serviceParameters *params = new serviceParameters();
|
||||||
params->port = port;
|
params->port = port;
|
||||||
params->path = "";
|
params->path = "";
|
||||||
@@ -147,18 +154,10 @@ int zts_start_with_identity(const char *key_pair_str, uint16_t key_buf_len,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!id) {
|
if (!id) {
|
||||||
|
delete params;
|
||||||
return ZTS_ERR_ARG;
|
return ZTS_ERR_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SDK_JNI
|
|
||||||
_userEventCallbackFunc = callback;
|
|
||||||
#else
|
|
||||||
_userEventCallbackFunc = callback;
|
|
||||||
#endif
|
|
||||||
if (!_isCallbackRegistered()) {
|
|
||||||
// Must have a callback
|
|
||||||
return ZTS_ERR_ARG;
|
|
||||||
}
|
|
||||||
int err;
|
int err;
|
||||||
int retval = ZTS_ERR_OK;
|
int retval = ZTS_ERR_OK;
|
||||||
|
|
||||||
@@ -261,11 +260,7 @@ int zts_start(const char *path, void (*callback)(void *), uint16_t port)
|
|||||||
if (!path) {
|
if (!path) {
|
||||||
return ZTS_ERR_ARG;
|
return ZTS_ERR_ARG;
|
||||||
}
|
}
|
||||||
if (port < 0 || port > 0xFFFF) {
|
|
||||||
return ZTS_ERR_ARG;
|
|
||||||
}
|
|
||||||
serviceParameters *params = new serviceParameters();
|
serviceParameters *params = new serviceParameters();
|
||||||
|
|
||||||
params->port = port;
|
params->port = port;
|
||||||
params->path = std::string(path);
|
params->path = std::string(path);
|
||||||
|
|
||||||
@@ -357,6 +352,7 @@ JNIEXPORT void JNICALL Java_com_zerotier_libzt_ZeroTier_stop(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// TODO: Make sure this woks with user-provided identities
|
||||||
int zts_restart()
|
int zts_restart()
|
||||||
{
|
{
|
||||||
serviceLock.lock();
|
serviceLock.lock();
|
||||||
|
|||||||
@@ -67,25 +67,6 @@ uint8_t disableLocalStorage; // Off by default
|
|||||||
|
|
||||||
typedef VirtualTap EthernetTap;
|
typedef VirtualTap EthernetTap;
|
||||||
|
|
||||||
static std::string _trimString(const std::string &s)
|
|
||||||
{
|
|
||||||
unsigned long end = (unsigned long)s.length();
|
|
||||||
while (end) {
|
|
||||||
char c = s[end - 1];
|
|
||||||
if ((c == ' ')||(c == '\r')||(c == '\n')||(!c)||(c == '\t'))
|
|
||||||
--end;
|
|
||||||
else break;
|
|
||||||
}
|
|
||||||
unsigned long start = 0;
|
|
||||||
while (start < end) {
|
|
||||||
char c = s[start];
|
|
||||||
if ((c == ' ')||(c == '\r')||(c == '\n')||(!c)||(c == '\t'))
|
|
||||||
++start;
|
|
||||||
else break;
|
|
||||||
}
|
|
||||||
return s.substr(start,end - start);
|
|
||||||
}
|
|
||||||
|
|
||||||
class NodeServiceImpl;
|
class NodeServiceImpl;
|
||||||
|
|
||||||
static int SnodeVirtualNetworkConfigFunction(ZT_Node *node,void *uptr,void *tptr,uint64_t nwid,void **nuptr,enum ZT_VirtualNetworkConfigOperation op,const ZT_VirtualNetworkConfig *nwconf);
|
static int SnodeVirtualNetworkConfigFunction(ZT_Node *node,void *uptr,void *tptr,uint64_t nwid,void **nuptr,enum ZT_VirtualNetworkConfigOperation op,const ZT_VirtualNetworkConfig *nwconf);
|
||||||
@@ -120,9 +101,9 @@ public:
|
|||||||
Node *_node;
|
Node *_node;
|
||||||
bool _updateAutoApply;
|
bool _updateAutoApply;
|
||||||
unsigned int _multipathMode = 0;
|
unsigned int _multipathMode = 0;
|
||||||
unsigned int _primaryPort;
|
unsigned int _primaryPort = 0;
|
||||||
unsigned int _secondaryPort = 0;
|
unsigned int _secondaryPort = 0;
|
||||||
unsigned int _tertiaryPort;
|
unsigned int _tertiaryPort = 0;
|
||||||
volatile unsigned int _udpPortPickerCounter;
|
volatile unsigned int _udpPortPickerCounter;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -253,7 +234,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ReasonForTermination run()
|
virtual ReasonForTermination run() override
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
{
|
{
|
||||||
@@ -472,19 +453,19 @@ public:
|
|||||||
return _termReason;
|
return _termReason;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ReasonForTermination reasonForTermination() const
|
virtual ReasonForTermination reasonForTermination() const override
|
||||||
{
|
{
|
||||||
Mutex::Lock _l(_termReason_m);
|
Mutex::Lock _l(_termReason_m);
|
||||||
return _termReason;
|
return _termReason;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::string fatalErrorMessage() const
|
virtual std::string fatalErrorMessage() const override
|
||||||
{
|
{
|
||||||
Mutex::Lock _l(_termReason_m);
|
Mutex::Lock _l(_termReason_m);
|
||||||
return _fatalErrorMessage;
|
return _fatalErrorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::string portDeviceName(uint64_t nwid) const
|
virtual std::string portDeviceName(uint64_t nwid) const override
|
||||||
{
|
{
|
||||||
Mutex::Lock _l(_nets_m);
|
Mutex::Lock _l(_nets_m);
|
||||||
std::map<uint64_t,NetworkState>::const_iterator n(_nets.find(nwid));
|
std::map<uint64_t,NetworkState>::const_iterator n(_nets.find(nwid));
|
||||||
@@ -498,7 +479,7 @@ public:
|
|||||||
return _homePath;
|
return _homePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void getRoutes(uint64_t nwid, void *routeArray, unsigned int *numRoutes)
|
void getRoutes(uint64_t nwid, void *routeArray, unsigned int *numRoutes) override
|
||||||
{
|
{
|
||||||
Mutex::Lock _l(_nets_m);
|
Mutex::Lock _l(_nets_m);
|
||||||
NetworkState &n = _nets[nwid];
|
NetworkState &n = _nets[nwid];
|
||||||
@@ -509,12 +490,12 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Node *getNode()
|
virtual Node *getNode() override
|
||||||
{
|
{
|
||||||
return _node;
|
return _node;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void terminate()
|
virtual void terminate() override
|
||||||
{
|
{
|
||||||
_run_m.lock();
|
_run_m.lock();
|
||||||
_run = false;
|
_run = false;
|
||||||
@@ -522,7 +503,7 @@ public:
|
|||||||
_phy.whack();
|
_phy.whack();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool getNetworkSettings(const uint64_t nwid,NetworkSettings &settings) const
|
virtual bool getNetworkSettings(const uint64_t nwid,NetworkSettings &settings) const override
|
||||||
{
|
{
|
||||||
Mutex::Lock _l(_nets_m);
|
Mutex::Lock _l(_nets_m);
|
||||||
std::map<uint64_t,NetworkState>::const_iterator n(_nets.find(nwid));
|
std::map<uint64_t,NetworkState>::const_iterator n(_nets.find(nwid));
|
||||||
@@ -814,12 +795,12 @@ public:
|
|||||||
|
|
||||||
// Copy and convert address structures
|
// Copy and convert address structures
|
||||||
nd->assignedAddressCount = n.config.assignedAddressCount;
|
nd->assignedAddressCount = n.config.assignedAddressCount;
|
||||||
for (int i=0; i<n.config.assignedAddressCount; i++) {
|
for (unsigned int i=0; i<n.config.assignedAddressCount; i++) {
|
||||||
native_ss_to_zts_ss(&(nd->assignedAddresses[i]), &(n.config.assignedAddresses[i]));
|
native_ss_to_zts_ss(&(nd->assignedAddresses[i]), &(n.config.assignedAddresses[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
nd->routeCount = n.config.routeCount;
|
nd->routeCount = n.config.routeCount;
|
||||||
for (int i=0; i<n.config.routeCount; i++) {
|
for (unsigned int i=0; i<n.config.routeCount; i++) {
|
||||||
native_ss_to_zts_ss(&(nd->routes[i].target), &(n.config.routes[i].target));
|
native_ss_to_zts_ss(&(nd->routes[i].target), &(n.config.routes[i].target));
|
||||||
native_ss_to_zts_ss(&(nd->routes[i].via), &(n.config.routes[i].via));
|
native_ss_to_zts_ss(&(nd->routes[i].via), &(n.config.routes[i].via));
|
||||||
nd->routes[i].flags = n.config.routes[i].flags;
|
nd->routes[i].flags = n.config.routes[i].flags;
|
||||||
@@ -844,7 +825,7 @@ public:
|
|||||||
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) {
|
||||||
int mostRecentStatus = n->second.config.status;
|
int mostRecentStatus = n->second.config.status;
|
||||||
VirtualTap *tap = n->second.tap;
|
VirtualTap *tap = n->second.tap;
|
||||||
uint64_t nwid = n->first;
|
// uint64_t nwid = n->first;
|
||||||
if (n->second.tap->_networkStatus == mostRecentStatus) {
|
if (n->second.tap->_networkStatus == mostRecentStatus) {
|
||||||
continue; // No state change
|
continue; // No state change
|
||||||
}
|
}
|
||||||
@@ -890,26 +871,26 @@ public:
|
|||||||
}
|
}
|
||||||
if (pl->peers[i].pathCount == 0) {
|
if (pl->peers[i].pathCount == 0) {
|
||||||
bShouldCopyPeerInfo=true;
|
bShouldCopyPeerInfo=true;
|
||||||
eventCode = ZTS_EVENT_PEER_RELAY, (void*)pd;
|
eventCode = ZTS_EVENT_PEER_RELAY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Previously known peer, update status
|
// Previously known peer, update status
|
||||||
else {
|
else {
|
||||||
if (peerCache[pl->peers[i].address] < pl->peers[i].pathCount) {
|
if (peerCache[pl->peers[i].address] < pl->peers[i].pathCount) {
|
||||||
bShouldCopyPeerInfo=true;
|
bShouldCopyPeerInfo=true;
|
||||||
eventCode = ZTS_EVENT_PEER_PATH_DISCOVERED, (void*)pd;
|
eventCode = ZTS_EVENT_PEER_PATH_DISCOVERED;
|
||||||
}
|
}
|
||||||
if (peerCache[pl->peers[i].address] > pl->peers[i].pathCount) {
|
if (peerCache[pl->peers[i].address] > pl->peers[i].pathCount) {
|
||||||
bShouldCopyPeerInfo=true;
|
bShouldCopyPeerInfo=true;
|
||||||
eventCode = ZTS_EVENT_PEER_PATH_DEAD, (void*)pd;
|
eventCode = ZTS_EVENT_PEER_PATH_DEAD;
|
||||||
}
|
}
|
||||||
if (peerCache[pl->peers[i].address] == 0 && pl->peers[i].pathCount > 0) {
|
if (peerCache[pl->peers[i].address] == 0 && pl->peers[i].pathCount > 0) {
|
||||||
bShouldCopyPeerInfo=true;
|
bShouldCopyPeerInfo=true;
|
||||||
eventCode = ZTS_EVENT_PEER_DIRECT, (void*)pd;
|
eventCode = ZTS_EVENT_PEER_DIRECT;
|
||||||
}
|
}
|
||||||
if (peerCache[pl->peers[i].address] > 0 && pl->peers[i].pathCount == 0) {
|
if (peerCache[pl->peers[i].address] > 0 && pl->peers[i].pathCount == 0) {
|
||||||
bShouldCopyPeerInfo=true;
|
bShouldCopyPeerInfo=true;
|
||||||
eventCode = ZTS_EVENT_PEER_RELAY, (void*)pd;
|
eventCode = ZTS_EVENT_PEER_RELAY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bShouldCopyPeerInfo) {
|
if (bShouldCopyPeerInfo) {
|
||||||
@@ -928,17 +909,17 @@ public:
|
|||||||
_node->freeQueryResult((void *)pl);
|
_node->freeQueryResult((void *)pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void join(uint64_t nwid)
|
inline void join(uint64_t nwid) override
|
||||||
{
|
{
|
||||||
_node->join(nwid, NULL, NULL);
|
_node->join(nwid, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void leave(uint64_t nwid)
|
inline void leave(uint64_t nwid) override
|
||||||
{
|
{
|
||||||
_node->leave(nwid, NULL, NULL);
|
_node->leave(nwid, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void getIdentity(char *key_pair_str, uint16_t *key_buf_len)
|
inline void getIdentity(char *key_pair_str, uint16_t *key_buf_len) override
|
||||||
{
|
{
|
||||||
if (key_pair_str == NULL || *key_buf_len < ZT_IDENTITY_STRING_BUFFER_LENGTH) {
|
if (key_pair_str == NULL || *key_buf_len < ZT_IDENTITY_STRING_BUFFER_LENGTH) {
|
||||||
return;
|
return;
|
||||||
@@ -1051,7 +1032,7 @@ public:
|
|||||||
inline int nodeStateGetFunction(enum ZT_StateObjectType type,const uint64_t id[2],void *data,unsigned int maxlen)
|
inline int nodeStateGetFunction(enum ZT_StateObjectType type,const uint64_t id[2],void *data,unsigned int maxlen)
|
||||||
{
|
{
|
||||||
char p[4096];
|
char p[4096];
|
||||||
int keylen = 0;
|
unsigned int keylen = 0;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case ZT_STATE_OBJECT_IDENTITY_PUBLIC:
|
case ZT_STATE_OBJECT_IDENTITY_PUBLIC:
|
||||||
if (disableLocalStorage) {
|
if (disableLocalStorage) {
|
||||||
@@ -1309,25 +1290,57 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int SnodeVirtualNetworkConfigFunction(ZT_Node *node,void *uptr,void *tptr,uint64_t nwid,void **nuptr,enum ZT_VirtualNetworkConfigOperation op,const ZT_VirtualNetworkConfig *nwconf)
|
static int SnodeVirtualNetworkConfigFunction(ZT_Node *node,void *uptr,void *tptr,uint64_t nwid,
|
||||||
{ return reinterpret_cast<NodeServiceImpl *>(uptr)->nodeVirtualNetworkConfigFunction(nwid,nuptr,op,nwconf); }
|
void **nuptr,enum ZT_VirtualNetworkConfigOperation op,const ZT_VirtualNetworkConfig *nwconf)
|
||||||
static void SnodeEventCallback(ZT_Node *node,void *uptr,void *tptr,enum ZT_Event event,const void *metaData)
|
{
|
||||||
{ reinterpret_cast<NodeServiceImpl *>(uptr)->nodeEventCallback(event,metaData); }
|
return reinterpret_cast<NodeServiceImpl *>(uptr)->nodeVirtualNetworkConfigFunction(nwid,nuptr,op,nwconf);
|
||||||
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<NodeServiceImpl *>(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<NodeServiceImpl *>(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<NodeServiceImpl *>(uptr)->nodeWirePacketSendFunction(localSocket,addr,data,len,ttl); }
|
|
||||||
static void SnodeVirtualNetworkFrameFunction(ZT_Node *node,void *uptr,void *tptr,uint64_t nwid,void **nuptr,uint64_t sourceMac,uint64_t destMac,unsigned int etherType,unsigned int vlanId,const void *data,unsigned int len)
|
|
||||||
{ reinterpret_cast<NodeServiceImpl *>(uptr)->nodeVirtualNetworkFrameFunction(nwid,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<NodeServiceImpl *>(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<NodeServiceImpl *>(uptr)->nodePathLookupFunction(ztaddr,family,result); }
|
|
||||||
static void StapFrameHandler(void *uptr,void *tptr,uint64_t nwid,const MAC &from,const MAC &to,unsigned int etherType,unsigned int vlanId,const void *data,unsigned int len)
|
|
||||||
{ reinterpret_cast<NodeServiceImpl *>(uptr)->tapFrameHandler(nwid,from,to,etherType,vlanId,data,len); }
|
|
||||||
|
|
||||||
|
static void SnodeEventCallback(ZT_Node *node,void *uptr,void *tptr,enum ZT_Event event,const void *metaData)
|
||||||
|
{
|
||||||
|
reinterpret_cast<NodeServiceImpl *>(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<NodeServiceImpl *>(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<NodeServiceImpl *>(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<NodeServiceImpl *>(uptr)->nodeWirePacketSendFunction(localSocket,addr,data,len,ttl);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SnodeVirtualNetworkFrameFunction(ZT_Node *node,void *uptr,void *tptr,uint64_t nwid,
|
||||||
|
void **nuptr,uint64_t sourceMac,uint64_t destMac,unsigned int etherType,unsigned int vlanId,const void *data,unsigned int len)
|
||||||
|
{
|
||||||
|
reinterpret_cast<NodeServiceImpl *>(uptr)->nodeVirtualNetworkFrameFunction(nwid,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<NodeServiceImpl *>(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<NodeServiceImpl *>(uptr)->nodePathLookupFunction(ztaddr,family,result);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void StapFrameHandler(void *uptr,void *tptr,uint64_t nwid,const MAC &from,const MAC &to,
|
||||||
|
unsigned int etherType,unsigned int vlanId,const void *data,unsigned int len)
|
||||||
|
{
|
||||||
|
reinterpret_cast<NodeServiceImpl *>(uptr)->tapFrameHandler(nwid,from,to,etherType,vlanId,data,len);
|
||||||
|
}
|
||||||
|
|
||||||
std::string NodeService::platformDefaultHomePath()
|
std::string NodeService::platformDefaultHomePath()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -458,7 +458,7 @@ JNIEXPORT int JNICALL Java_com_zerotier_libzt_ZeroTier_ioctl(
|
|||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
if (!buf || len <= 0) {
|
if (!buf) {
|
||||||
return ZTS_ERR_ARG;
|
return ZTS_ERR_ARG;
|
||||||
}
|
}
|
||||||
if (!(_serviceStateFlags & ZTS_STATE_NET_SERVICE_RUNNING)) {
|
if (!(_serviceStateFlags & ZTS_STATE_NET_SERVICE_RUNNING)) {
|
||||||
@@ -480,7 +480,7 @@ JNIEXPORT jint JNICALL Java_com_zerotier_libzt_ZeroTier_send(
|
|||||||
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 zts_sockaddr *addr,zts_socklen_t addrlen)
|
const struct zts_sockaddr *addr,zts_socklen_t addrlen)
|
||||||
{
|
{
|
||||||
if (!addr || !buf || len <= 0) {
|
if (!addr || !buf) {
|
||||||
return ZTS_ERR_ARG;
|
return ZTS_ERR_ARG;
|
||||||
}
|
}
|
||||||
if (addrlen > (int)sizeof(struct zts_sockaddr_storage) || addrlen < (int)sizeof(struct zts_sockaddr_in)) {
|
if (addrlen > (int)sizeof(struct zts_sockaddr_storage) || addrlen < (int)sizeof(struct zts_sockaddr_in)) {
|
||||||
@@ -634,7 +634,7 @@ ssize_t zts_readv(int s, const struct zts_iovec *iov, int iovcnt)
|
|||||||
|
|
||||||
ssize_t zts_write(int fd, const void *buf, size_t len)
|
ssize_t zts_write(int fd, const void *buf, size_t len)
|
||||||
{
|
{
|
||||||
if (!buf || len <= 0) {
|
if (!buf) {
|
||||||
return ZTS_ERR_ARG;
|
return ZTS_ERR_ARG;
|
||||||
}
|
}
|
||||||
if (!(_serviceStateFlags & ZTS_STATE_NET_SERVICE_RUNNING)) {
|
if (!(_serviceStateFlags & ZTS_STATE_NET_SERVICE_RUNNING)) {
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ bool VirtualTap::hasIpv4Addr()
|
|||||||
std::vector<InetAddress>::iterator it(_ips.begin());
|
std::vector<InetAddress>::iterator it(_ips.begin());
|
||||||
while (it != _ips.end()) {
|
while (it != _ips.end()) {
|
||||||
if ((*it).isV4()) { return true; }
|
if ((*it).isV4()) { return true; }
|
||||||
it++;
|
++it;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,7 @@ bool VirtualTap::hasIpv6Addr()
|
|||||||
std::vector<InetAddress>::iterator it(_ips.begin());
|
std::vector<InetAddress>::iterator it(_ips.begin());
|
||||||
while (it != _ips.end()) {
|
while (it != _ips.end()) {
|
||||||
if ((*it).isV6()) { return true; }
|
if ((*it).isV6()) { return true; }
|
||||||
it++;
|
++it;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -223,7 +223,6 @@ void VirtualTap::scanMulticastGroups(std::vector<MulticastGroup> &added,
|
|||||||
newGroups.push_back(MulticastGroup::deriveMulticastGroupForAddressResolution(*ip));
|
newGroups.push_back(MulticastGroup::deriveMulticastGroupForAddressResolution(*ip));
|
||||||
|
|
||||||
std::sort(newGroups.begin(),newGroups.end());
|
std::sort(newGroups.begin(),newGroups.end());
|
||||||
std::unique(newGroups.begin(),newGroups.end());
|
|
||||||
|
|
||||||
for (std::vector<MulticastGroup>::iterator m(newGroups.begin());m!=newGroups.end();++m) {
|
for (std::vector<MulticastGroup>::iterator m(newGroups.begin());m!=newGroups.end();++m) {
|
||||||
if (!std::binary_search(_multicastGroups.begin(),_multicastGroups.end(),*m))
|
if (!std::binary_search(_multicastGroups.begin(),_multicastGroups.end(),*m))
|
||||||
@@ -510,6 +509,7 @@ bool _lwip_is_netif_up(void *n)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
static struct zts_netif_details *_lwip_prepare_netif_status_msg(struct netif *n)
|
static struct zts_netif_details *_lwip_prepare_netif_status_msg(struct netif *n)
|
||||||
{
|
{
|
||||||
if (!n || !n->state) {
|
if (!n || !n->state) {
|
||||||
@@ -560,6 +560,7 @@ static void _netif_link_callback(struct netif *n)
|
|||||||
_enqueueEvent(ZTS_EVENT_NETIF_LINK_DOWN, (void*)_lwip_prepare_netif_status_msg(n));
|
_enqueueEvent(ZTS_EVENT_NETIF_LINK_DOWN, (void*)_lwip_prepare_netif_status_msg(n));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
static err_t _netif_init4(struct netif *n)
|
static err_t _netif_init4(struct netif *n)
|
||||||
{
|
{
|
||||||
@@ -613,7 +614,6 @@ static err_t _netif_init6(struct netif *n)
|
|||||||
|
|
||||||
void _lwip_init_interface(void *tapref, const InetAddress &ip)
|
void _lwip_init_interface(void *tapref, const InetAddress &ip)
|
||||||
{
|
{
|
||||||
char ipbuf[INET6_ADDRSTRLEN];
|
|
||||||
char macbuf[ZTS_MAC_ADDRSTRLEN];
|
char macbuf[ZTS_MAC_ADDRSTRLEN];
|
||||||
|
|
||||||
VirtualTap *vtap = (VirtualTap*)tapref;
|
VirtualTap *vtap = (VirtualTap*)tapref;
|
||||||
@@ -634,7 +634,6 @@ void _lwip_init_interface(void *tapref, const InetAddress &ip)
|
|||||||
netif_set_remove_callback(n, _netif_remove_callback);
|
netif_set_remove_callback(n, _netif_remove_callback);
|
||||||
netif_set_link_callback(n, _netif_link_callback);
|
netif_set_link_callback(n, _netif_link_callback);
|
||||||
*/
|
*/
|
||||||
char nmbuf[INET6_ADDRSTRLEN];
|
|
||||||
static ip4_addr_t ip4, netmask, gw;
|
static ip4_addr_t ip4, netmask, gw;
|
||||||
IP4_ADDR(&gw,127,0,0,1);
|
IP4_ADDR(&gw,127,0,0,1);
|
||||||
ip4.addr = *((u32_t *)ip.rawIpData());
|
ip4.addr = *((u32_t *)ip.rawIpData());
|
||||||
@@ -646,8 +645,12 @@ void _lwip_init_interface(void *tapref, const InetAddress &ip)
|
|||||||
snprintf(macbuf, ZTS_MAC_ADDRSTRLEN, "%02x:%02x:%02x:%02x:%02x:%02x",
|
snprintf(macbuf, ZTS_MAC_ADDRSTRLEN, "%02x:%02x:%02x:%02x:%02x:%02x",
|
||||||
n->hwaddr[0], n->hwaddr[1], n->hwaddr[2],
|
n->hwaddr[0], n->hwaddr[1], n->hwaddr[2],
|
||||||
n->hwaddr[3], n->hwaddr[4], n->hwaddr[5]);
|
n->hwaddr[3], n->hwaddr[4], n->hwaddr[5]);
|
||||||
//DEBUG_INFO("initialized netif=%p as [mac=%s, addr=%s, nm=%s, tap=%p]",n,
|
/*
|
||||||
// macbuf, ip.toString(ipbuf), ip.netmask().toString(nmbuf), vtap);
|
char nmbuf[INET6_ADDRSTRLEN];
|
||||||
|
char ipbuf[INET6_ADDRSTRLEN];
|
||||||
|
DEBUG_INFO("initialized netif=%p as [mac=%s, addr=%s, nm=%s, tap=%p]",n,
|
||||||
|
macbuf, ip.toString(ipbuf), ip.netmask().toString(nmbuf), vtap);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
if (ip.isV6()) {
|
if (ip.isV6()) {
|
||||||
if (vtap->netif6) {
|
if (vtap->netif6) {
|
||||||
@@ -681,8 +684,10 @@ void _lwip_init_interface(void *tapref, const InetAddress &ip)
|
|||||||
snprintf(macbuf, ZTS_MAC_ADDRSTRLEN, "%02x:%02x:%02x:%02x:%02x:%02x",
|
snprintf(macbuf, ZTS_MAC_ADDRSTRLEN, "%02x:%02x:%02x:%02x:%02x:%02x",
|
||||||
n->hwaddr[0], n->hwaddr[1], n->hwaddr[2],
|
n->hwaddr[0], n->hwaddr[1], n->hwaddr[2],
|
||||||
n->hwaddr[3], n->hwaddr[4], n->hwaddr[5]);
|
n->hwaddr[3], n->hwaddr[4], n->hwaddr[5]);
|
||||||
//DEBUG_INFO("initialized netif=%p as [mac=%s, addr=%s, tap=%p]", n,
|
/*
|
||||||
// macbuf, ip.toString(ipbuf), vtap);
|
DEBUG_INFO("initialized netif=%p as [mac=%s, addr=%s, tap=%p]", n,
|
||||||
|
macbuf, ip.toString(ipbuf), vtap);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user