Rename service_name function to the service_instance_name
authorRafał Miłecki <rafal@milecki.pl>
Wed, 10 May 2017 10:47:33 +0000 (12:47 +0200)
committerRafał Miłecki <rafal@milecki.pl>
Fri, 12 May 2017 08:35:46 +0000 (10:35 +0200)
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

index 8e0e493..c8187de 100644 (file)
--- 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;
 
 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 *
 static const char *
-service_name(const char *domain)
+service_instance_name(const char *service_domain)
 {
        static char buffer[256];
 
 {
        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;
 }
 
        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)
 {
 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);
 
        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();
        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();
        dns_send_answer(iface, to, service);
 
        dns_init_answer();