summaryrefslogtreecommitdiff
path: root/llmnr.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2016-08-17 08:41:52 +0200
committerTobias Klauser <tklauser@distanz.ch>2016-08-17 08:41:52 +0200
commitf46d59e0dc7b54a3f4a7ead2fd2d4258b3f56782 (patch)
tree076ca9422193ee640dc16c69c0923a4c9feeaec1 /llmnr.c
parentf1081b6b0f47160f83ded689d956bd577819d752 (diff)
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 <tklauser@distanz.ch>
Diffstat (limited to 'llmnr.c')
-rw-r--r--llmnr.c8
1 files changed, 5 insertions, 3 deletions
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;
}