summaryrefslogtreecommitdiff
path: root/agent
diff options
context:
space:
mode:
authorStefan Becker <chemobejk@gmail.com>2019-06-26 11:00:25 +0300
committerStefan Becker <chemobejk@gmail.com>2019-06-26 11:12:23 +0300
commit3eab4bc45625b92878cceed8f0d33132655f9921 (patch)
treed750eeae74cb3c529dcb368642aebca2a46409aa /agent
parent1ff29177d4ae4f1f2eff108c9f2e506f41072282 (diff)
downloadlibnice-3eab4bc45625b92878cceed8f0d33132655f9921.tar.gz
interfaces: support multiple loopbacks
Clone implementation from HAVE_GETIFADDRS branch to !HAVE_GETIFADDRS branch of nice_interfaces_get_local_ips()
Diffstat (limited to 'agent')
-rw-r--r--agent/interfaces.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/agent/interfaces.c b/agent/interfaces.c
index f3f6d7f..b0bb0e3 100644
--- a/agent/interfaces.c
+++ b/agent/interfaces.c
@@ -309,7 +309,7 @@ nice_interfaces_get_local_ips (gboolean include_loopback)
struct ifreq *ifr;
struct ifconf ifc;
struct sockaddr_in *sa;
- gchar *loopback = NULL;
+ GList *loopbacks = NULL;
if ((sockfd = socket (AF_INET, SOCK_DGRAM, IPPROTO_IP)) < 0) {
nice_debug ("Error : Cannot open socket to retrieve interface list");
@@ -355,7 +355,7 @@ nice_interfaces_get_local_ips (gboolean include_loopback)
nice_debug ("IP Address: %s", inet_ntoa (sa->sin_addr));
if ((ifr->ifr_flags & IFF_LOOPBACK) == IFF_LOOPBACK){
if (include_loopback)
- loopback = g_strdup (inet_ntoa (sa->sin_addr));
+ loopbacks = add_ip_to_list (loopbacks, g_strdup (inet_ntoa (sa->sin_addr)), TRUE);
else
nice_debug ("Ignoring loopback interface");
} else {
@@ -370,8 +370,8 @@ nice_interfaces_get_local_ips (gboolean include_loopback)
close (sockfd);
free (ifc.ifc_req);
- if (loopback)
- ips = add_ip_to_list (ips, loopback, TRUE);
+ if (loopbacks)
+ ips = g_list_concat (ips, loopbacks);
return ips;
}