Signed-off-by: John Crispin <blogic@openwrt.org>
if (cache_init())
return -1;
if (cache_init())
return -1;
ubus_startup();
uloop_run();
ubus_startup();
uloop_run();
static VLIST_TREE(services, avl_strcmp, service_update, false, false);
static char *sdudp = "_services._dns-sd._udp.local";
static char *sdtcp = "_services._dns-sd._tcp.local";
static VLIST_TREE(services, avl_strcmp, service_update, false, false);
static char *sdudp = "_services._dns-sd._udp.local";
static char *sdtcp = "_services._dns-sd._tcp.local";
+static int service_init_announce;
static const char *
service_name(const char *domain)
static const char *
service_name(const char *domain)
-service_reply_single(struct interface *iface, struct service *s, const char *match, int ttl)
+service_reply_single(struct interface *iface, struct service *s, const char *match, int ttl, int force)
{
const char *host = service_name(s->service);
char *service = strstr(host, "._");
{
const char *host = service_name(s->service);
char *service = strstr(host, "._");
- if (!s->active || !service || !service_timeout(s))
+ if (!force && (!s->active || !service || !service_timeout(s)))
struct service *s;
vlist_for_each_element(&services, s, node)
struct service *s;
vlist_for_each_element(&services, s, node)
- service_reply_single(iface, s, match, ttl);
+ service_reply_single(iface, s, match, ttl, 0);
struct interface *iface;
struct service *s;
struct interface *iface;
struct service *s;
+ if (!node_old) {
+ s = container_of(node_new, struct service, node);
+ if (service_init_announce)
+ vlist_for_each_element(&interfaces, iface, node) {
+ s->t = 0;
+ service_reply_single(iface, s, NULL, announce_ttl, 1);
+ }
s = container_of(node_old, struct service, node);
s = container_of(node_old, struct service, node);
+ if (!node_new && service_init_announce)
vlist_for_each_element(&interfaces, iface, node)
vlist_for_each_element(&interfaces, iface, node)
- service_reply_single(iface, s, NULL, 0);
-
+ service_reply_single(iface, s, NULL, 0, 1);
+service_init(int announce)
+ service_init_announce = announce;
+
get_hostname();
vlist_update(&services);
get_hostname();
vlist_update(&services);
#ifndef _SERVICE_H__
#define _SERVICE_H__
#ifndef _SERVICE_H__
#define _SERVICE_H__
-extern void service_init(void);
+extern void service_init(int announce);
extern void service_cleanup(void);
extern void service_announce(struct interface *iface);
extern void service_announce_services(struct interface *iface, const char *service);
extern void service_cleanup(void);
extern void service_announce(struct interface *iface);
extern void service_announce_services(struct interface *iface, const char *service);
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
{
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
{