[LEDE-DEV] [PATCH mdns] Change dns_send_question function arg from unicast to multicast
Rafał Miłecki
zajec5 at gmail.com
Wed Feb 8 05:04:57 PST 2017
From: Rafał Miłecki <rafal at milecki.pl>
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 at milecki.pl>
---
announce.c | 2 +-
cache.c | 6 +++---
dns.c | 4 ++--
dns.h | 2 +-
interface.c | 4 ++--
ubus.c | 4 ++--
6 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/announce.c b/announce.c
index 3ff64b2..d1aca5b 100644
--- a/announce.c
+++ b/announce.c
@@ -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 07d4f20..fa32465 100644
--- 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 89cd4ce..63788f7 100644
--- 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 4425d4c..6210e0e 100644
--- 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);
diff --git a/interface.c b/interface.c
index 4dfeace..f09329b 100644
--- a/interface.c
+++ b/interface.c
@@ -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 3cf2313..19bc33f 100644
--- 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")) {
--
2.11.0
More information about the Lede-dev
mailing list