added check for assigned address
This commit is contained in:
@@ -117,6 +117,7 @@ void zts_leave_network(const char * nwid);
|
||||
// void zts_get_addresses(const char * nwid, char * addrstr);
|
||||
void zts_get_ipv4_address(const char *nwid, char *addrstr);
|
||||
void zts_get_ipv6_address(const char *nwid, char *addrstr);
|
||||
bool zts_has_address(const char *nwid);
|
||||
int zts_get_device_id();
|
||||
bool zts_is_relayed();
|
||||
char *zts_get_homepath();
|
||||
|
||||
@@ -160,6 +160,19 @@ void zts_stop_service() {
|
||||
// Now only returns first assigned address per network. Shouldn't normally be a problem.
|
||||
|
||||
// Get IPV4 Address for this device on given network
|
||||
|
||||
bool zts_has_address(const char *nwid)
|
||||
{
|
||||
char ipv4_addr[64], ipv6_addr[64];
|
||||
zts_get_ipv4_address(nwid, ipv4_addr);
|
||||
zts_get_ipv6_address(nwid, ipv6_addr);
|
||||
if(!strcmp(ipv4_addr, "-1.-1.-1.-1/-1") && !strcmp(ipv4_addr, "-1.-1.-1.-1/-1")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void zts_get_ipv4_address(const char *nwid, char *addrstr)
|
||||
{
|
||||
uint64_t nwid_int = strtoull(nwid, NULL, 16);
|
||||
|
||||
@@ -123,14 +123,14 @@ int (*realclose)(CLOSE_SIG);
|
||||
// start the SDK service if this is bundled
|
||||
#if defined(SDK_BUNDLED)
|
||||
if(!service_initialized) {
|
||||
//api_netpath = "/root/dev/ztest5/nc_565799d8f612388c";
|
||||
DEBUG_ATTN("api_netpath = %s", api_netpath);
|
||||
pthread_t intercept_thread;
|
||||
pthread_create(&intercept_thread, NULL, zts_start_core_service, (void *)(path));
|
||||
service_initialized = 1;
|
||||
DEBUG_ATTN("waiting for service to come online");
|
||||
//while(!zts_service_is_running()) { }
|
||||
sleep(10);
|
||||
DEBUG_ATTN("waiting for service to assign address to network stack");
|
||||
// wait for zt service to assign the network stack an address
|
||||
sleep(1);
|
||||
while(!zts_has_address(nwid)) { }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -98,12 +98,6 @@ namespace ZeroTier {
|
||||
void pico_cb_tcp_write(NetconEthernetTap *tap, struct pico_socket *s);
|
||||
void pico_cb_socket_activity(uint16_t ev, struct pico_socket *s);
|
||||
|
||||
/*
|
||||
void pico_cb_udp(uint16_t ev, struct pico_socket *s);
|
||||
void pico_cb_udp_write(NetconEthernetTap *tap, struct pico_socket *s);
|
||||
void pico_cb_udp_read(NetconEthernetTap *tap, struct pico_socket *s);
|
||||
*/
|
||||
|
||||
int pico_eth_send(struct pico_device *dev, void *buf, int len);
|
||||
void pico_rx(NetconEthernetTap *tap, const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len);
|
||||
int pico_eth_poll(struct pico_device *dev, int loop_score);
|
||||
|
||||
Reference in New Issue
Block a user