Change dns_send_question function arg from unicast to multicast
authorRafał Miłecki <rafal@milecki.pl>
Wed, 8 Feb 2017 13:04:57 +0000 (14:04 +0100)
committerRafał Miłecki <rafal@milecki.pl>
Wed, 8 Feb 2017 15:32:37 +0000 (16:32 +0100)
This trivial patch just reverses argument logic to make it a bit more
consistent with struct interface which contains "multicast" field. This
hopefully will make typos less likely and code easier to follow.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: John Crispin <john@phrozen.org>
announce.c
cache.c
dns.c
dns.h
interface.c
ubus.c

index 3ff64b26d23abd967296d30403810498048dcfb7..d1aca5bd661a34d6a1881bbad561d958ca21b78a 100644 (file)
@@ -46,7 +46,7 @@ announce_timer(struct uloop_timeout *timeout)
                case STATE_PROBE1:
                case STATE_PROBE2:
                case STATE_PROBE3:
-                       dns_send_question(iface, mdns_hostname_local, TYPE_ANY, 0);
+                       dns_send_question(iface, mdns_hostname_local, TYPE_ANY, 1);
                        uloop_timeout_set(timeout, 250);
                        iface->announce_state++;
                        break;
diff --git a/cache.c b/cache.c
index 07d4f20d5e1065f9146b791658582fbfc69e8275..fa32465f953bb18a3577ef48282f70bc18050a12 100644 (file)
--- a/cache.c
+++ b/cache.c
@@ -89,7 +89,7 @@ cache_gc_timer(struct uloop_timeout *timeout)
                        continue;
                }
                s->refresh += 50;
-               dns_send_question(s->iface, s->entry, TYPE_PTR, 1);
+               dns_send_question(s->iface, s->entry, TYPE_PTR, 0);
        }
 
        uloop_timeout_set(timeout, 10000);
@@ -128,7 +128,7 @@ cache_scan(void)
 
        vlist_for_each_element(&interfaces, iface, node)
                avl_for_each_element(&services, s, avl)
-                       dns_send_question(iface, s->entry, TYPE_PTR, 1);
+                       dns_send_question(iface, s->entry, TYPE_PTR, 0);
 }
 
 static struct cache_service*
@@ -167,7 +167,7 @@ cache_service(struct interface *iface, char *entry, int hlen, int ttl)
        avl_insert(&services, &s->avl);
 
        if (!hlen)
-               dns_send_question(iface, entry, TYPE_PTR, !iface->multicast);
+               dns_send_question(iface, entry, TYPE_PTR, iface->multicast);
 
        return s;
 }
diff --git a/dns.c b/dns.c
index 89cd4ce5a76fc4ebd736784cf6d6fcbe4180bf0d..63788f73ebdb708ea66ac2e83e920e152ca68aed 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -67,7 +67,7 @@ dns_type_string(uint16_t type)
 }
 
 void
-dns_send_question(struct interface *iface, const char *question, int type, int unicast)
+dns_send_question(struct interface *iface, const char *question, int type, int multicast)
 {
        static struct dns_header h;
        static struct dns_question q;
@@ -87,7 +87,7 @@ dns_send_question(struct interface *iface, const char *question, int type, int u
        int len;
 
        h.questions = cpu_to_be16(1);
-       q.class = cpu_to_be16(((unicast) ? (CLASS_UNICAST) : (0))  | 1);
+       q.class = cpu_to_be16((multicast ? 0 : CLASS_UNICAST) | 1);
        q.type = cpu_to_be16(type);
 
        len = dn_comp(question, (void *) dns_buffer, sizeof(dns_buffer), NULL, NULL);
diff --git a/dns.h b/dns.h
index 4425d4cb8a36ae338b077c78bd19721f63ea25e1..6210e0e52868d83892202714b1be2917762b3326 100644 (file)
--- a/dns.h
+++ b/dns.h
@@ -73,7 +73,7 @@ struct interface;
 extern int cfg_proto;
 extern int cfg_no_subnet;
 
-void dns_send_question(struct interface *iface, const char *question, int type, int unicast);
+void dns_send_question(struct interface *iface, const char *question, int type, int multicast);
 void dns_init_answer(void);
 void dns_add_answer(int type, const uint8_t *rdata, uint16_t rdlength, int ttl);
 void dns_send_answer(struct interface *iface, const char *answer);
index 4dfeace9de337916b662c608d1cedbab8953734f..f09329ba17e586f17d5eb15805f4799d7c57bbbf 100644 (file)
@@ -417,7 +417,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, 1);
+               dns_send_question(iface, "_services._dns-sd._udp.local", TYPE_PTR, 0);
                announce_init(iface);
        }
 
@@ -465,7 +465,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, 1);
+               dns_send_question(iface, "_services._dns-sd._udp.local", TYPE_PTR, 0);
                announce_init(iface);
        }
 
diff --git a/ubus.c b/ubus.c
index 3cf2313f1f0eb49a5e4e6e67e51a73463144db88..19bc33f0f7a6008e927a5afac9aa81065a0c118d 100644 (file)
--- a/ubus.c
+++ b/ubus.c
@@ -205,10 +205,10 @@ mdns_query(struct ubus_context *ctx, struct ubus_object *obj,
 
        if (!strcmp(method, "query")) {
                if (iface_v4)
-                       dns_send_question(iface_v4, question, type, 0);
+                       dns_send_question(iface_v4, question, type, 1);
 
                if (iface_v6)
-                       dns_send_question(iface_v6, question, type, 0);
+                       dns_send_question(iface_v6, question, type, 1);
 
                return UBUS_STATUS_OK;
        } else if (!strcmp(method, "fetch")) {