changeset 29496:f1aa01ff26dd

Remove IPv6 support from _get_local_system_ips, since I couldn't get it to work yet...
author Marcus Lundblad <ml@update.uu.se>
date Thu, 10 Sep 2009 20:33:18 +0000
parents 02f6f49da454
children 60d0242ea902
files libpurple/network.c libpurple/network.h libpurple/protocols/jabber/si.c
diffstat 3 files changed, 10 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/network.c	Wed Sep 09 19:01:03 2009 +0000
+++ b/libpurple/network.c	Thu Sep 10 20:33:18 2009 +0000
@@ -201,33 +201,29 @@
 }
 
 GList *
-purple_network_get_all_local_system_ips(int fd)
+purple_network_get_all_local_system_ips(void)
 {
 	GList *result = NULL;
-	int source = fd;
+	int source = source = socket(PF_INET,SOCK_STREAM, 0);;
 	char buffer[1024];
 	char *tmp;
 	struct ifconf ifc;
 	struct ifreq *ifr;
-
-	if (fd < 0)
-		source = socket(PF_INET,SOCK_STREAM, 0);
 	
 	ifc.ifc_len = sizeof(buffer);
 	ifc.ifc_req = (struct ifreq *)buffer;
 	ioctl(source, SIOCGIFCONF, &ifc);
-
-	if (fd < 0)
-		close(source);
+	close(source);
 
 	/* enumerate the interfaces on IPv4 (or from source given by fd) */
 	tmp = buffer;
 	while (tmp < buffer + ifc.ifc_len) {
-		char dst[INET6_ADDRSTRLEN];
+		char dst[INET_ADDRSTRLEN];
 
 		ifr = (struct ifreq *)tmp;
 		tmp += HX_SIZE_OF_IFREQ(*ifr);
 
+		/* TODO: handle IPv6 */
 		if (ifr->ifr_addr.sa_family == AF_INET) {
 			struct sockaddr_in *sinptr = (struct sockaddr_in *)&ifr->ifr_addr;
 
@@ -240,38 +236,6 @@
 			}
 		}
 	}
-	
-	/* enumerate IPv6 interfaces (done when NOT specifying an fd,
-								  in that case use it (see above)) */
-	if (fd < 0) {
-		source = socket(PF_INET6, SOCK_STREAM, 0);
-	
-		ifc.ifc_len = sizeof(buffer);
-		ifc.ifc_req = (struct ifreq *)buffer;
-		ioctl(source, SIOCGIFCONF, &ifc);
-
-		close(source);
-
-		tmp = buffer;
-		while (tmp < buffer + ifc.ifc_len) {
-			char dst[INET6_ADDRSTRLEN];
-
-			ifr = (struct ifreq *)tmp;
-			tmp += HX_SIZE_OF_IFREQ(*ifr);
-
-			if (ifr->ifr_addr.sa_family == AF_INET6) {
-				struct sockaddr_in6 *sinptr =
-					(struct sockaddr_in6 *)&ifr->ifr_addr;
-
-				inet_ntop(AF_INET6, &sinptr->sin6_addr, dst, sizeof(dst));
-				purple_debug_info("network", 
-					"found local i/f with address %s on IPv4\n", dst);
-				if (!purple_strequal(dst, "::1")) {
-					result = g_list_append(result, g_strdup(dst));
-				}
-			}
-		}
-	}
 
 	return result;
 }
--- a/libpurple/network.h	Wed Sep 09 19:01:03 2009 +0000
+++ b/libpurple/network.h	Thu Sep 10 20:33:18 2009 +0000
@@ -90,12 +90,13 @@
 /**
  * Returns all IP addresses of the local system.
  *
- * @note The caller must free this list
+ * @note The caller must free this list, this function currently only
+ *       handles IPv4 addresses
+ * @since 2.7.0
  *
- * @param fd The fd to use to help figure out the IPs, or else -1.
  * @return A list of local IP addresses.
  */
-GList *purple_network_get_all_local_system_ips(int fd);
+GList *purple_network_get_all_local_system_ips(void);
 
 /**
  * Returns the IP address that should be used anywhere a
--- a/libpurple/protocols/jabber/si.c	Wed Sep 09 19:01:03 2009 +0000
+++ b/libpurple/protocols/jabber/si.c	Thu Sep 10 20:33:18 2009 +0000
@@ -854,7 +854,7 @@
 	if (sock >= 0) {
 		gchar *jid;
 		GList *local_ips =
-			purple_network_get_all_local_system_ips(jsx->js->fd);
+			purple_network_get_all_local_system_ips();
 		const char *public_ip;
 		gboolean has_public_ip = FALSE;