summaryrefslogtreecommitdiffstats
path: root/daemon/bindings
diff options
context:
space:
mode:
authorOto Šťáva <oto.stava@nic.cz>2022-04-29 08:50:35 +0200
committerVladimír Čunát <vladimir.cunat@nic.cz>2022-05-02 12:17:49 +0200
commit08d66491af0123d9b4af4fee38e8a8b27bd80a71 (patch)
treec6e58ac7b73c795d9b16f4a99174cda2dd222204 /daemon/bindings
parentMerge branch !1285: daemon/zimport: close transaction after importing batch (diff)
downloadknot-resolver-08d66491af0123d9b4af4fee38e8a8b27bd80a71.tar.xz
knot-resolver-08d66491af0123d9b4af4fee38e8a8b27bd80a71.zip
lib/utils: sockaddr key generation
Diffstat (limited to 'daemon/bindings')
-rw-r--r--daemon/bindings/net.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/daemon/bindings/net.c b/daemon/bindings/net.c
index 7e1afd71..c6b0f5dc 100644
--- a/daemon/bindings/net.c
+++ b/daemon/bindings/net.c
@@ -414,18 +414,6 @@ static int net_close(lua_State *L)
return 1;
}
-/** Check whether `addr` points to an `AF_INET6` address and whether the address
- * is link-local. */
-static bool ip6_link_local(struct sockaddr_in6 *addr)
-{
- if (addr->sin6_family != AF_INET6)
- return false;
-
- /* Link-local: https://tools.ietf.org/html/rfc4291#section-2.4 */
- const uint8_t prefix[] = { 0xFE, 0x80 };
- return kr_bitcmp((char *) addr->sin6_addr.s6_addr, (char *) prefix, 10) == 0;
-}
-
/** List available interfaces. */
static int net_interfaces(lua_State *L)
{
@@ -457,7 +445,7 @@ static int net_interfaces(lua_State *L)
buf[0] = '\0';
}
- if (ip6_link_local(&iface.address.address6)) {
+ if (kr_sockaddr_link_local((struct sockaddr *) &iface.address)) {
/* Link-local IPv6: add %interface prefix */
auto_free char *str = NULL;
int ret = asprintf(&str, "%s%%%s", buf, iface.name);