summaryrefslogtreecommitdiff
path: root/llmnr.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2017-02-28 11:20:49 +0100
committerTobias Klauser <tklauser@distanz.ch>2017-02-28 11:20:49 +0100
commitbba51a20374648eec948113cfe1f0cd298bbe771 (patch)
tree157dae2e808c7407118782bc0ffce5cecf4612d3 /llmnr.c
parenta90f8b45355f32376cc127a33b0d1dbed419d293 (diff)
llmnrd: Poll hostname
Poll "/proc/sys/kernel/hostname" and update the hostname when it was changed. systemd has a similar mechanism. Note that the hostname is not polled if it has been provided on the command line, or if "/proc/sys/kernel/hostname" cannot be opened. Patch contributed by @tbetker Fixes #23 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'llmnr.c')
-rw-r--r--llmnr.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/llmnr.c b/llmnr.c
index f5a3f2a..dc4b72a 100644
--- a/llmnr.c
+++ b/llmnr.c
@@ -42,12 +42,16 @@ static bool llmnr_ipv6 = false;
/* Host name in DNS name format (length octet + name + 0 byte) */
static char llmnr_hostname[LLMNR_LABEL_MAX_SIZE + 2];
-void llmnr_init(const char *hostname, bool ipv6)
+void llmnr_set_hostname(const char *hostname)
{
llmnr_hostname[0] = strlen(hostname);
strncpy(&llmnr_hostname[1], hostname, LLMNR_LABEL_MAX_SIZE);
llmnr_hostname[LLMNR_LABEL_MAX_SIZE + 1] = '\0';
+}
+void llmnr_init(const char *hostname, bool ipv6)
+{
+ llmnr_set_hostname(hostname);
llmnr_ipv6 = ipv6;
}