From be3adf279d95d26b8ac118d118bf23076829e9bf Mon Sep 17 00:00:00 2001 From: 7u83 <7u83@mail.ru> Date: Mon, 8 Aug 2022 23:09:10 +0200 Subject: [PATCH] ipv4 and ipv6 are configurable --- src/ac/socklist.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ac/socklist.c b/src/ac/socklist.c index 31ccc7b4..f3e3e991 100644 --- a/src/ac/socklist.c +++ b/src/ac/socklist.c @@ -335,7 +335,7 @@ static int socklist_check_size() } -int socklist_add_unicast(const char *addr, const char *port, int ac_proto) +int socklist_add_unicast(const char *addr, const char *port, int ac_proto, int ipv4, int ipv6) { char sock_buf[SOCK_ADDR_BUFSIZE]; struct addrinfo hints; @@ -364,6 +364,14 @@ int socklist_add_unicast(const char *addr, const char *port, int ac_proto) struct sockaddr broadcast; struct sockaddr *sa; int sockfd; + + if (res->ai_addr->sa_family == AF_INET && !ipv4){ + continue; + } + if (res->ai_addr->sa_family == AF_INET6 && !ipv6){ + continue; + } + ifname[0] = 0; rc = sock_getifinfo(res->ai_addr, ifname, &broadcast, &netmask); @@ -372,6 +380,7 @@ int socklist_add_unicast(const char *addr, const char *port, int ac_proto) continue; } + /* Bind the control port */ sa = res->ai_addr; sockfd = socket(res->ai_addr->sa_family, SOCK_DGRAM, 0);