Added return values to zts_start() and zts_simple_start(). Also Fixed signed comparison warnings in ztproxy when compiling under Windows

This commit is contained in:
Joseph Henry
2017-10-10 14:20:20 -07:00
parent 9b9aa108c2
commit 08b7ccb921
29 changed files with 83768 additions and 24 deletions

5247
ext/picotcp/RFC/rfc0793.txt Normal file

File diff suppressed because it is too large Load Diff

5043
ext/picotcp/RFC/rfc1066.txt Normal file

File diff suppressed because it is too large Load Diff

6844
ext/picotcp/RFC/rfc1122.txt Normal file

File diff suppressed because it is too large Load Diff

5782
ext/picotcp/RFC/rfc1123.txt Normal file

File diff suppressed because it is too large Load Diff

2075
ext/picotcp/RFC/rfc1323.txt Normal file

File diff suppressed because it is too large Load Diff

2131
ext/picotcp/RFC/rfc1379.txt Normal file

File diff suppressed because it is too large Load Diff

10755
ext/picotcp/RFC/rfc1470.txt Normal file

File diff suppressed because it is too large Load Diff

2131
ext/picotcp/RFC/rfc1644.txt Normal file

File diff suppressed because it is too large Load Diff

2976
ext/picotcp/RFC/rfc1661.txt Normal file

File diff suppressed because it is too large Load Diff

2019
ext/picotcp/RFC/rfc1693.txt Normal file

File diff suppressed because it is too large Load Diff

2019
ext/picotcp/RFC/rfc2026.txt Normal file

File diff suppressed because it is too large Load Diff

2523
ext/picotcp/RFC/rfc2131.txt Normal file

File diff suppressed because it is too large Load Diff

2187
ext/picotcp/RFC/rfc2460.txt Normal file

File diff suppressed because it is too large Load Diff

3419
ext/picotcp/RFC/rfc2525.txt Normal file

File diff suppressed because it is too large Load Diff

2579
ext/picotcp/RFC/rfc2757.txt Normal file

File diff suppressed because it is too large Load Diff

2579
ext/picotcp/RFC/rfc2760.txt Normal file

File diff suppressed because it is too large Load Diff

2523
ext/picotcp/RFC/rfc3135.txt Normal file

File diff suppressed because it is too large Load Diff

3531
ext/picotcp/RFC/rfc3168.txt Normal file

File diff suppressed because it is too large Load Diff

2299
ext/picotcp/RFC/rfc3449.txt Normal file

File diff suppressed because it is too large Load Diff

2187
ext/picotcp/RFC/rfc3493.txt Normal file

File diff suppressed because it is too large Load Diff

1907
ext/picotcp/RFC/rfc3649.txt Normal file

File diff suppressed because it is too large Load Diff

3363
ext/picotcp/RFC/rfc3819.txt Normal file

File diff suppressed because it is too large Load Diff

1851
ext/picotcp/RFC/rfc3927.txt Normal file

File diff suppressed because it is too large Load Diff

1851
ext/picotcp/RFC/rfc4614.txt Normal file

File diff suppressed because it is too large Load Diff

3923
ext/picotcp/RFC/rfc6762.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -103,7 +103,7 @@ void disableTaps();
* @param addrlen
* @return
*/
void zts_get_ipv4_address(const char *nwid, char *addrstr, const int addrlen);
void zts_get_ipv4_address(const char *nwid, char *addrstr, const size_t addrlen);
/**
* @brief Gets the VirtualTap's (interface) IPv6 address
@@ -114,7 +114,7 @@ void zts_get_ipv4_address(const char *nwid, char *addrstr, const int addrlen);
* @param addrlen
* @return
*/
void zts_get_ipv6_address(const char *nwid, char *addrstr, const int addrlen);
void zts_get_ipv6_address(const char *nwid, char *addrstr, const size_t addrlen);
/**
* @brief Returns whether the VirtualTap has an assigned IPv4 address
@@ -198,9 +198,9 @@ int zts_running();
* that one call this at the beginning of your application code since it may take several seconds to fully
* come online.
* @param path Where this instance of ZeroTier will store its identity and configuration files
* @return
* @return Returns 1 if ZeroTier is currently running, and 0 if it is not
*/
void zts_start(const char *path);
int zts_start(const char *path);
/**
* @brief Alternative to zts_start(). Start an instance of libzt, wait for an address to be issues, and join
@@ -211,15 +211,15 @@ void zts_start(const char *path);
* come online.
* @param path
* @param nwid A 16-digit hexidecimal virtual network ID
* @return
* @return Returns 0 on success, -1 on failure
*/
void zts_simple_start(const char *path, const char *nwid);
int zts_simple_start(const char *path, const char *nwid);
/**
* @brief Stops libzt (ZeroTier core services, stack drivers, stack threads, etc)
*
* @usage This should be called at the end of your program or when you do not anticipate communicating over ZeroTier
* @return
* @return Returns 0 on success, -1 on failure
*/
void zts_stop();
@@ -231,7 +231,7 @@ void zts_stop();
* @param len
* @return
*/
void zts_get_homepath(char *homePath, int len);
void zts_get_homepath(char *homePath, size_t len);
/**
* @brief Copies the hexidecimal representation of this nodeID into the provided buffer

View File

@@ -53,7 +53,6 @@ extern "C" {
#endif
// forward declarations from ZT1Service.h
void zts_simple_start(const char *path, const char *nwid);
int zts_get_device_id(char *devID);
void init_network_stack();
@@ -71,7 +70,7 @@ void init_network_stack();
* @param nwid A 16-digit hexidecimal network identifier (e.g. Earth: `8056c2e21c000001`)
* @return 0 if successful; or 1 if failed
*/
void zts_start(const char *path);
int zts_start(const char *path);
/**
* @brief Starts libzt
@@ -86,7 +85,7 @@ void zts_start(const char *path);
* @param nwid A 16-digit hexidecimal network identifier (e.g. Earth: `8056c2e21c000001`)
* @return 0 if successful; or 1 if failed
*/
void zts_simple_start(const char *path, const char *nwid);
int zts_simple_start(const char *path, const char *nwid);
/**
* @brief Stops the ZeroTier core service and disconnects from all virtual networks
@@ -143,7 +142,7 @@ void zts_leave_soft(const char * filepath, const char * nwid);
* @param len
* @return
*/
void zts_get_homepath(char *homePath, const int len);
void zts_get_homepath(char *homePath, const size_t len);
/**
* @brief Get device ID (10-digit hex + NULL byte)
@@ -198,7 +197,7 @@ int zts_has_address(const char *nwid);
* @param addrlen
* @return
*/
void zts_get_ipv4_address(const char *nwid, char *addrstr, const int addrlen);
void zts_get_ipv4_address(const char *nwid, char *addrstr, const size_t addrlen);
/**
* @brief Get IPV6 Address for this device on a given network
@@ -209,7 +208,7 @@ void zts_get_ipv4_address(const char *nwid, char *addrstr, const int addrlen);
* @param addrlen
* @return
*/
void zts_get_ipv6_address(const char *nwid, char *addrstr, const int addrlen);
void zts_get_ipv6_address(const char *nwid, char *addrstr, const size_t addrlen);
/**
* @brief Returns a 6PLANE IPv6 address given a network ID and zerotier ID

View File

@@ -206,7 +206,7 @@ namespace ZeroTier {
char vtap_abbr_name[16];
static int devno;
int ifindex = 0;
size_t ifindex = 0;
std::vector<InetAddress> ips() const;
std::vector<InetAddress> _ips;

View File

@@ -258,7 +258,7 @@ void disableTaps()
ZeroTier::_vtaps_lock.unlock();
}
void zts_get_ipv4_address(const char *nwid, char *addrstr, const int addrlen)
void zts_get_ipv4_address(const char *nwid, char *addrstr, const size_t addrlen)
{
if (ZeroTier::zt1Service) {
uint64_t nwid_int = strtoull(nwid, NULL, 16);
@@ -280,7 +280,7 @@ void zts_get_ipv4_address(const char *nwid, char *addrstr, const int addrlen)
memcpy(addrstr, "\0", 1);
}
void zts_get_ipv6_address(const char *nwid, char *addrstr, const int addrlen)
void zts_get_ipv6_address(const char *nwid, char *addrstr, size_t addrlen)
{
if (ZeroTier::zt1Service) {
uint64_t nwid_int = strtoull(nwid, NULL, 16);
@@ -391,10 +391,10 @@ int zts_running() {
return ZeroTier::zt1Service == NULL ? false : ZeroTier::zt1Service->isRunning();
}
void zts_start(const char *path)
int zts_start(const char *path)
{
if (ZeroTier::zt1Service) {
return;
return 0; // already initialized, ok
}
if (path) {
ZeroTier::homeDir = path;
@@ -403,12 +403,12 @@ void zts_start(const char *path)
WSAStartup(MAKEWORD(2, 2), &wsaData); // initialize WinSock. Used in Phy for loopback pipe
#endif
pthread_t service_thread;
pthread_create(&service_thread, NULL, zts_start_service, NULL);
return pthread_create(&service_thread, NULL, zts_start_service, NULL);
}
void zts_simple_start(const char *path, const char *nwid)
int zts_simple_start(const char *path, const char *nwid)
{
zts_start(path);
int err = zts_start(path);
while (zts_running() == false) {
DEBUG_EXTRA("waiting for service to start");
nanosleep((const struct timespec[]) {{0, (ZTO_WRAPPER_CHECK_INTERVAL * 1000000)}}, NULL);
@@ -426,6 +426,7 @@ void zts_simple_start(const char *path, const char *nwid)
while (zts_has_address(nwid) == false) {
nanosleep((const struct timespec[]) {{0, (ZTO_WRAPPER_CHECK_INTERVAL * 1000000)}}, NULL);
}
return err;
}
void zts_stop() {
@@ -438,10 +439,10 @@ void zts_stop() {
#endif
}
void zts_get_homepath(char *homePath, int len) {
void zts_get_homepath(char *homePath, size_t len) {
if (ZeroTier::homeDir.length()) {
memset(homePath, 0, len);
int buf_len = len < ZeroTier::homeDir.length() ? len : ZeroTier::homeDir.length();
size_t buf_len = len < ZeroTier::homeDir.length() ? len : ZeroTier::homeDir.length();
memcpy(homePath, ZeroTier::homeDir.c_str(), buf_len);
}
}