mesh->appname = xstrdup(params->appname);
mesh->devclass = params->devclass;
- mesh->discovery = true;
+ mesh->discovery.enabled = true;
mesh->invitation_timeout = 604800; // 1 week
mesh->netns = params->netns;
mesh->submeshes = NULL;
pthread_mutex_init(&mesh->mutex, &attr);
pthread_cond_init(&mesh->cond, NULL);
- pthread_mutex_init(&mesh->discovery_mutex, NULL);
- pthread_cond_init(&mesh->discovery_cond, NULL);
-
pthread_cond_init(&mesh->adns_cond, NULL);
mesh->threadstarted = false;
#endif // HAVE_SETNS
}
-#if HAVE_CATTA
-
- if(mesh->discovery) {
+ if(mesh->discovery.enabled) {
discovery_start(mesh);
}
-#endif
-
if(pthread_mutex_lock(&mesh->mutex) != 0) {
abort();
}
pthread_mutex_unlock(&mesh->mutex);
-#if HAVE_CATTA
-
// Stop discovery
- if(mesh->discovery) {
+ if(mesh->discovery.enabled) {
discovery_stop(mesh);
}
-#endif
-
return NULL;
}
}
void meshlink_enable_discovery(meshlink_handle_t *mesh, bool enable) {
-#if HAVE_CATTA
-
if(!mesh) {
meshlink_errno = MESHLINK_EINVAL;
return;
abort();
}
- if(mesh->discovery == enable) {
+ if(mesh->discovery.enabled == enable) {
goto end;
}
}
}
- mesh->discovery = enable;
+ mesh->discovery.enabled = enable;
end:
pthread_mutex_unlock(&mesh->mutex);
-#else
- (void)mesh;
- (void)enable;
- meshlink_errno = MESHLINK_ENOTSUP;
-#endif
}
void meshlink_set_dev_class_timeouts(meshlink_handle_t *mesh, dev_class_t devclass, int pinginterval, int pingtimeout) {
}
handle_network_change(mesh, true);
+
+ if(mesh->discovery.enabled) {
+ discovery_refresh(mesh);
+ }
+
pthread_mutex_unlock(&mesh->mutex);
}