diff mbox

[LEDE-DEV,umdns,2/3] Rename service_name function to the service_instance_name

Message ID 20170510104734.29300-2-zajec5@gmail.com
State Accepted
Delegated to: Rafał Miłecki
Headers show

Commit Message

Rafał Miłecki May 10, 2017, 10:47 a.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

This name matches what is really returned by the function according to
the RFC 6763. Also document it while at it.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 service.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/service.c b/service.c
index 8e0e493..c8187de 100644
--- a/service.c
+++ b/service.c
@@ -67,12 +67,21 @@  static struct blob_buf b;
 static VLIST_TREE(services, avl_strcmp, service_update, false, false);
 static int service_init_announce;
 
+/**
+ * service_instance_name - construct Service Instance Name as in RFC 6763
+ *
+ * RFC 6763 specifies Service Instance Names in the following way:
+ *
+ * Service Instance Name = <Instance> . <Service> . <Domain>
+ *
+ * @service_domain: service name (a pair of labels) with domain name appended
+ */
 static const char *
-service_name(const char *domain)
+service_instance_name(const char *service_domain)
 {
 	static char buffer[256];
 
-	snprintf(buffer, sizeof(buffer), "%s.%s", umdns_host_label, domain);
+	snprintf(buffer, sizeof(buffer), "%s.%s", umdns_host_label, service_domain);
 
 	return buffer;
 }
@@ -118,7 +127,7 @@  service_timeout(struct service *s)
 static void
 service_reply_single(struct interface *iface, struct sockaddr *to, struct service *s, int ttl, int force)
 {
-	const char *host = service_name(s->service);
+	const char *host = service_instance_name(s->service);
 	char *service = strstr(host, "._");
 	time_t t = service_timeout(s);
 
@@ -131,7 +140,7 @@  service_reply_single(struct interface *iface, struct sockaddr *to, struct servic
 	s->t = t;
 
 	dns_init_answer();
-	service_add_ptr(service_name(s->service), ttl);
+	service_add_ptr(service_instance_name(s->service), ttl);
 	dns_send_answer(iface, to, service);
 
 	dns_init_answer();