Use one define for DNS-Based Service Discovery service name
authorRafał Miłecki <rafal@milecki.pl>
Mon, 20 Mar 2017 12:59:04 +0000 (13:59 +0100)
committerRafał Miłecki <rafal@milecki.pl>
Mon, 20 Mar 2017 13:00:21 +0000 (14:00 +0100)
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
dns.c
dns.h
interface.c
service.c
service.h
ubus.c

diff --git a/dns.c b/dns.c
index 7c49236a30cc27d6a99b9d5d7b88ea58fc89fd4f..2e8b0ba0a3da483e9b7a0f6c04d442b6aa7434b5 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -373,7 +373,7 @@ parse_question(struct interface *iface, struct sockaddr *from, char *name, struc
                break;
 
        case TYPE_PTR:
-               if (!strcmp(name, sdudp)) {
+               if (!strcmp(name, C_DNS_SD)) {
                        dns_reply_a(iface, to, announce_ttl);
                        service_announce_services(iface, to, announce_ttl);
                } else {
diff --git a/dns.h b/dns.h
index 0f26f6043a551c14a741626e8070666b20e8c9eb..38ab41f85b8df4e05fed15af21bde1226140d6c0 100644 (file)
--- a/dns.h
+++ b/dns.h
@@ -40,7 +40,7 @@
 #define MAX_NAME_LEN           8096
 #define MAX_DATA_LEN           8096
 
-#define C_DNS_SD                "_services._dns-sd._udp.local"
+#define C_DNS_SD               "_services._dns-sd._udp.local"
 
 struct dns_header {
        uint16_t id;
index cde184bec9b3cc25147c17db327e41f3665b3e79..a984be90a7cbf2de92a047f97ba394ddf6c43d86 100644 (file)
@@ -441,7 +441,7 @@ reconnect_socket4(struct uloop_timeout *timeout)
 
        uloop_fd_add(&iface->fd, ULOOP_READ);
        if (iface->multicast) {
-               dns_send_question(iface, "_services._dns-sd._udp.local", TYPE_PTR, 0);
+               dns_send_question(iface, C_DNS_SD, TYPE_PTR, 0);
                announce_init(iface);
        }
 
@@ -489,7 +489,7 @@ reconnect_socket6(struct uloop_timeout *timeout)
        uloop_fd_add(&iface->fd, ULOOP_READ);
 
        if (iface->multicast) {
-               dns_send_question(iface, "_services._dns-sd._udp.local", TYPE_PTR, 0);
+               dns_send_question(iface, C_DNS_SD, TYPE_PTR, 0);
                announce_init(iface);
        }
 
index 075ac15325fcc927cb9368eaedfe2b229cb86230..ca70274bcc8889897ea0ab4048ae8ca7c5d43abe 100644 (file)
--- a/service.c
+++ b/service.c
@@ -65,7 +65,6 @@ service_update(struct vlist_tree *tree, struct vlist_node *node_new,
 
 static struct blob_buf b;
 static VLIST_TREE(services, avl_strcmp, service_update, false, false);
-const char *sdudp =  "_services._dns-sd._udp.local";
 static int service_init_announce;
 
 static const char *
@@ -163,7 +162,7 @@ service_announce_services(struct interface *iface, struct sockaddr *to, int ttl)
                if (ttl) {
                        dns_init_answer();
                        service_add_ptr(s->service, ttl);
-                       dns_send_answer(iface, to, sdudp);
+                       dns_send_answer(iface, to, C_DNS_SD);
                }
                service_reply_single(iface, to, s, ttl, 0);
        }
index 67a425abbae4feca226ab55bce255f22094295e6..086a0afb7c1d4ee6c806bf4faff1439d57d36754 100644 (file)
--- a/service.h
+++ b/service.h
@@ -14,7 +14,6 @@
 #ifndef _SERVICE_H__
 #define _SERVICE_H__
 
-extern const char *sdudp;
 extern void service_init(int announce);
 extern void service_cleanup(void);
 extern void service_reply(struct interface *iface, struct sockaddr *to, const char *match, int ttl);
diff --git a/ubus.c b/ubus.c
index 0cfd18f4ce783ff3489bcc6d3f13e987a2dd6011..ba89fdd7cb3b302c1e006b6aca35b5319cef3095 100644 (file)
--- a/ubus.c
+++ b/ubus.c
@@ -176,7 +176,7 @@ umdns_query(struct ubus_context *ctx, struct ubus_object *obj,
                    struct blob_attr *msg)
 {
        struct blob_attr *tb[QUERY_MAX], *c;
-       const char *question = "_services._dns-sd._udp.local";
+       const char *question = C_DNS_SD;
        const char *ifname;
        int type = TYPE_ANY;