[LEDE-DEV] [PATCH umdns 1/3] Rename mdns_hostname variable to the umdns_host_label
Rafał Miłecki
zajec5 at gmail.com
Wed May 10 03:47:32 PDT 2017
From: Rafał Miłecki <rafal at milecki.pl>
In the whole RFC 6762 document "host name" means a fully qualified
domain name. The value we store in this variable is just a first label
of the name so rename it properly to make the code just a bit easier to
follow.
Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
dns.c | 6 +++---
service.c | 2 +-
util.c | 6 +++---
util.h | 9 ++++++++-
4 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/dns.c b/dns.c
index d384f58..68a088f 100644
--- a/dns.c
+++ b/dns.c
@@ -384,8 +384,8 @@ parse_question(struct interface *iface, struct sockaddr *from, char *name, struc
size_t len = dot ? dot - name : 0;
/* Make sure it's query for the instance name we use */
- if (len && len == strlen(mdns_hostname) &&
- !strncmp(name, mdns_hostname, len))
+ if (len && len == strlen(umdns_host_label) &&
+ !strncmp(name, umdns_host_label, len))
service_reply(iface, to, dot + 1, announce_ttl);
}
break;
@@ -395,7 +395,7 @@ parse_question(struct interface *iface, struct sockaddr *from, char *name, struc
host = strstr(name, ".local");
if (host)
*host = '\0';
- if (!strcmp(mdns_hostname, name))
+ if (!strcmp(umdns_host_label, name))
dns_reply_a(iface, to, announce_ttl);
break;
};
diff --git a/service.c b/service.c
index ca70274..8e0e493 100644
--- a/service.c
+++ b/service.c
@@ -72,7 +72,7 @@ service_name(const char *domain)
{
static char buffer[256];
- snprintf(buffer, sizeof(buffer), "%s.%s", mdns_hostname, domain);
+ snprintf(buffer, sizeof(buffer), "%s.%s", umdns_host_label, domain);
return buffer;
}
diff --git a/util.c b/util.c
index 63f1612..f5cfdb8 100644
--- a/util.c
+++ b/util.c
@@ -35,7 +35,7 @@
uint8_t mdns_buf[MDNS_BUF_LEN];
int debug = 0;
-char mdns_hostname[HOSTNAME_LEN];
+char umdns_host_label[HOSTNAME_LEN];
char mdns_hostname_local[HOSTNAME_LEN + 6];
uint32_t
@@ -65,13 +65,13 @@ void get_hostname(void)
{
struct utsname utsname;
- mdns_hostname[0] = 0;
+ umdns_host_label[0] = 0;
mdns_hostname_local[0] = 0;
if (uname(&utsname) < 0)
return;
- snprintf(mdns_hostname, sizeof(mdns_hostname), "%s", utsname.nodename);
+ snprintf(umdns_host_label, sizeof(umdns_host_label), "%s", utsname.nodename);
snprintf(mdns_hostname_local, sizeof(mdns_hostname_local), "%s.local", utsname.nodename);
}
diff --git a/util.h b/util.h
index efee5dc..c0db9e7 100644
--- a/util.h
+++ b/util.h
@@ -27,7 +27,14 @@
extern int debug;
extern uint8_t mdns_buf[MDNS_BUF_LEN];
-extern char mdns_hostname[HOSTNAME_LEN];
+
+/**
+ * The first label of a host's fully qualified domain name
+ *
+ * E.g. just "example" for the domain name example.local.
+ */
+extern char umdns_host_label[HOSTNAME_LEN];
+
extern char mdns_hostname_local[HOSTNAME_LEN + 6];
extern void get_hostname(void);
--
2.11.0
More information about the Lede-dev
mailing list