From f46d59e0dc7b54a3f4a7ead2fd2d4258b3f56782 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 17 Aug 2016 08:41:52 +0200 Subject: llmnrd: Allow to bind to a specific network interface Add a command line option -i/--interface which allows to bind the llmnrd sockets to a specific interface. If used, requests are only answered on the specified interface. Example: llmnrd -i eth0 Closes #9 Signed-off-by: Tobias Klauser --- llmnr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'llmnr.c') diff --git a/llmnr.c b/llmnr.c index a833ef1..206f165 100644 --- a/llmnr.c +++ b/llmnr.c @@ -61,19 +61,21 @@ static void llmnr_iface_event_handle(enum iface_event_type type, unsigned char a } } -int llmnr_init(const char *hostname, uint16_t port, bool ipv6) +int llmnr_init(const char *hostname, uint16_t port, bool ipv6, const char *iface) { llmnr_hostname[0] = strlen(hostname); strncpy(&llmnr_hostname[1], hostname, LLMNR_LABEL_MAX_SIZE); llmnr_hostname[LLMNR_LABEL_MAX_SIZE + 1] = '\0'; log_info("Starting llmnrd on port %u, hostname %s\n", port, hostname); + if (iface) + log_info("Binding to interface %s\n", iface); - llmnr_sock_ipv4 = socket_open_ipv4(port); + llmnr_sock_ipv4 = socket_open_ipv4(port, iface); if (llmnr_sock_ipv4 < 0) return -1; if (ipv6) { - llmnr_sock_ipv6 = socket_open_ipv6(port); + llmnr_sock_ipv6 = socket_open_ipv6(port, iface); if (llmnr_sock_ipv6 < 0) return -1; } -- cgit v1.2.3-54-g00ecf