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_addresses(const char * nwid, char * addrstr);
|
||||||
void zts_get_ipv4_address(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);
|
void zts_get_ipv6_address(const char *nwid, char *addrstr);
|
||||||
|
bool zts_has_address(const char *nwid);
|
||||||
int zts_get_device_id();
|
int zts_get_device_id();
|
||||||
bool zts_is_relayed();
|
bool zts_is_relayed();
|
||||||
char *zts_get_homepath();
|
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.
|
// Now only returns first assigned address per network. Shouldn't normally be a problem.
|
||||||
|
|
||||||
// Get IPV4 Address for this device on given network
|
// 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)
|
void zts_get_ipv4_address(const char *nwid, char *addrstr)
|
||||||
{
|
{
|
||||||
uint64_t nwid_int = strtoull(nwid, NULL, 16);
|
uint64_t nwid_int = strtoull(nwid, NULL, 16);
|
||||||
|
|||||||
@@ -123,14 +123,14 @@ int (*realclose)(CLOSE_SIG);
|
|||||||
// start the SDK service if this is bundled
|
// start the SDK service if this is bundled
|
||||||
#if defined(SDK_BUNDLED)
|
#if defined(SDK_BUNDLED)
|
||||||
if(!service_initialized) {
|
if(!service_initialized) {
|
||||||
//api_netpath = "/root/dev/ztest5/nc_565799d8f612388c";
|
|
||||||
DEBUG_ATTN("api_netpath = %s", api_netpath);
|
DEBUG_ATTN("api_netpath = %s", api_netpath);
|
||||||
pthread_t intercept_thread;
|
pthread_t intercept_thread;
|
||||||
pthread_create(&intercept_thread, NULL, zts_start_core_service, (void *)(path));
|
pthread_create(&intercept_thread, NULL, zts_start_core_service, (void *)(path));
|
||||||
service_initialized = 1;
|
service_initialized = 1;
|
||||||
DEBUG_ATTN("waiting for service to come online");
|
DEBUG_ATTN("waiting for service to assign address to network stack");
|
||||||
//while(!zts_service_is_running()) { }
|
// wait for zt service to assign the network stack an address
|
||||||
sleep(10);
|
sleep(1);
|
||||||
|
while(!zts_has_address(nwid)) { }
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,12 +97,6 @@ namespace ZeroTier {
|
|||||||
void pico_cb_udp_read(NetconEthernetTap *tap, struct pico_socket *s);
|
void pico_cb_udp_read(NetconEthernetTap *tap, struct pico_socket *s);
|
||||||
void pico_cb_tcp_write(NetconEthernetTap *tap, struct pico_socket *s);
|
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_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);
|
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);
|
void pico_rx(NetconEthernetTap *tap, const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len);
|
||||||
|
|||||||
Reference in New Issue
Block a user