[LEDE-DEV] [PATCH umdns] Drop unneeded code to simplify getting hosts over ubus

Rafał Miłecki zajec5 at gmail.com
Thu Mar 9 13:30:11 PST 2017


From: Rafał Miłecki <rafal at milecki.pl>

This code in umdns_hosts was there since ever but it seems like an
unneeded copy & paste part of umdns_browse. In this function we iterate
over *host* entries of cached services list. It means the entry field
conains values like "example.local".

In such case looking for "._" is pointless and appending ".local"
results in looking for entries like "example.local.local".

This code make sense for browsing *services* only where for entries like
"ex._ssh._tcp.local" we try dumping "ex.local" & "ex._ssh._tcp.local".

Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
 ubus.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/ubus.c b/ubus.c
index 9ceeab1..4120fd5 100644
--- a/ubus.c
+++ b/ubus.c
@@ -97,21 +97,13 @@ umdns_hosts(struct ubus_context *ctx, struct ubus_object *obj,
 		struct blob_attr *msg)
 {
 	struct cache_service *s;
-	char *buffer = (char *) mdns_buf;
 	void *c;
 
 	blob_buf_init(&b, 0);
 	avl_for_each_element(&services, s, avl) {
-		char *local;
 		if (!cache_service_is_host(s))
 			continue;
-		snprintf(buffer, MAX_NAME_LEN, "%s", s->entry);
-		local = strstr(buffer, "._");
-		if (local)
-			*local = '\0';
-		c = blobmsg_open_table(&b, buffer);
-		strncat(buffer, ".local", MAX_NAME_LEN);
-		cache_dump_records(&b, buffer);
+		c = blobmsg_open_table(&b, s->entry);
 		cache_dump_records(&b, s->entry);
 		blobmsg_close_table(&b, c);
 	}
-- 
2.11.0




More information about the Lede-dev mailing list