diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2020-05-05 21:59:38 -0400 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@ocrete.ca> | 2020-05-06 02:06:22 +0000 |
commit | db9c2ca612482e49ae829d11a4a5eaad0058ed83 (patch) | |
tree | 29f59369c03bbdba87f492ab6b96276956c4b214 | |
parent | ac3f7b5ec4ac3036d65a3990245ec5a046d68631 (diff) | |
download | libnice-db9c2ca612482e49ae829d11a4a5eaad0058ed83.tar.gz |
interfaces: Use union for sockaddr/sockaddr_in
This makes clang happy
Fixes #100
-rw-r--r-- | agent/interfaces.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/agent/interfaces.c b/agent/interfaces.c index a147808..42cb74a 100644 --- a/agent/interfaces.c +++ b/agent/interfaces.c @@ -269,7 +269,11 @@ get_local_ips_ioctl (gboolean include_loopback) gint size = 0; struct ifreq *ifr; struct ifconf ifc; - struct sockaddr_in *sa; + union { + struct sockaddr_in *sin; + struct sockaddr *sa; + } sa; + GList *loopbacks = NULL; #ifdef IGNORED_IFACE_PREFIX const gchar **prefix; @@ -324,12 +328,12 @@ get_local_ips_ioctl (gboolean include_loopback) if ((ifr->ifr_flags & IFF_RUNNING) == 0) continue; - sa = (struct sockaddr_in *) &ifr->ifr_addr; + sa.sa = &ifr->ifr_addr; nice_debug ("Interface: %s", ifr->ifr_name); - nice_debug ("IP Address: %s", inet_ntoa (sa->sin_addr)); + nice_debug ("IP Address: %s", inet_ntoa (sa.sin->sin_addr)); if ((ifr->ifr_flags & IFF_LOOPBACK) == IFF_LOOPBACK){ if (include_loopback) - loopbacks = add_ip_to_list (loopbacks, g_strdup (inet_ntoa (sa->sin_addr)), TRUE); + loopbacks = add_ip_to_list (loopbacks, g_strdup (inet_ntoa (sa.sin->sin_addr)), TRUE); else nice_debug ("Ignoring loopback interface"); continue; @@ -350,10 +354,10 @@ get_local_ips_ioctl (gboolean include_loopback) continue; #endif - if (nice_interfaces_is_private_ip ((struct sockaddr *) sa)) { - ips = add_ip_to_list (ips, g_strdup (inet_ntoa (sa->sin_addr)), TRUE); + if (nice_interfaces_is_private_ip (sa.sa)) { + ips = add_ip_to_list (ips, g_strdup (inet_ntoa (sa.sin->sin_addr)), TRUE); } else { - ips = add_ip_to_list (ips, g_strdup (inet_ntoa (sa->sin_addr)), FALSE); + ips = add_ip_to_list (ips, g_strdup (inet_ntoa (sa.sin->sin_addr)), FALSE); } } |