pidgin.next.minor: fc6c8215: Remove IPv6 support from _get_local_syst...

malu at pidgin.im malu at pidgin.im
Thu Sep 10 16:37:02 EDT 2009


-----------------------------------------------------------------
Revision: fc6c8215a0288300cef71feafe25ee91f7567034
Ancestor: a3f7a4c3280716f828ba129e718bbf16b1a691f4
Author: malu at pidgin.im
Date: 2009-09-10T20:33:18
Branch: im.pidgin.pidgin.next.minor
URL: http://d.pidgin.im/viewmtn/revision/info/fc6c8215a0288300cef71feafe25ee91f7567034

Modified files:
        libpurple/network.c libpurple/network.h
        libpurple/protocols/jabber/si.c

ChangeLog: 

Remove IPv6 support from _get_local_system_ips, since I couldn't get it to
work yet...

-------------- next part --------------
============================================================
--- libpurple/network.c	6e231d9f4e9f0dc2f86d417d2c9db4e6e9beb8b2
+++ libpurple/network.c	7d1b868e24ec8563630c22f85d904eda3dc76214
@@ -201,33 +201,29 @@ GList *
 }
 
 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);
+	close(source);
 
-	if (fd < 0)
-		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,39 +236,7 @@ purple_network_get_all_local_system_ips(
 			}
 		}
 	}
-	
-	/* 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;
 }
 
============================================================
--- libpurple/network.h	0692729dcd6a63f697121778e64901d8b8595670
+++ libpurple/network.h	437df253ad6c3b7afd8f8f528ceb5296836eed9b
@@ -90,12 +90,13 @@ const char *purple_network_get_local_sys
 /**
  * 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
============================================================
--- libpurple/protocols/jabber/si.c	95f735f395ac622f9a5d33f549b84fe1c20d1c00
+++ libpurple/protocols/jabber/si.c	a004fccfc7a3115f9ba1a2c37ba9a816342bc1ca
@@ -854,7 +854,7 @@ jabber_si_xfer_bytestreams_listen_cb(int
 	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;
 		


More information about the Commits mailing list