pidgin.2.x.y: 80cf272a: Append interface ID only to local interf...

elb at pidgin.im elb at pidgin.im
Tue Nov 29 20:05:47 EST 2011


----------------------------------------------------------------------
Revision: 80cf272a3ddfb229a3480ad465b277e546c31b1e
Parent:   0c3ef8388ce0f274d695767f513518b859889979
Author:   linus.luessing at web.de
Date:     11/29/11 19:58:50
Branch:   im.pidgin.pidgin.2.x.y
URL: http://d.pidgin.im/viewmtn/revision/info/80cf272a3ddfb229a3480ad465b277e546c31b1e

Changelog: 

Append interface ID only to local interfaces for IPv6 Bonjour.

This should fix unsuccessful connection attempts both for two IPv6 hosts
with a non-link-local address next to the link-local one or without.

Changes against parent 0c3ef8388ce0f274d695767f513518b859889979

  patched  ChangeLog
  patched  libpurple/protocols/bonjour/jabber.c
  patched  libpurple/protocols/bonjour/jabber.h
  patched  libpurple/protocols/bonjour/mdns_avahi.c

-------------- next part --------------
============================================================
--- ChangeLog	d08cc16922cc18fdc5b32f1e9d7318cb10b53a5f
+++ ChangeLog	804f5180f40b46eaea728f6dd16905448739e354
@@ -4,6 +4,9 @@ version 2.10.1 (10/11/2011):
 	Finch:
 	* Fix compilation on OpenBSD.
 
+	Bonjour:
+	* IPv6 fixes (Linus L?ssing)
+
 	Gadu-Gadu:
 	* Fix problems linking against GnuTLS. (#14544)
 
============================================================
--- libpurple/protocols/bonjour/jabber.c	32bccc4ccc1b1d62971ce596dad35325bde4f513
+++ libpurple/protocols/bonjour/jabber.c	294ed3f158619462447e09d17b1d0f37121836e3
@@ -665,9 +665,13 @@ _server_socket_handler(gpointer data, in
 
 	/* Look for the buddy that has opened the conversation and fill information */
 #ifdef HAVE_INET_NTOP
-	if (their_addr.ss_family == AF_INET6)
+	if (their_addr.ss_family == AF_INET6) {
 		address_text = inet_ntop(their_addr.ss_family, &((struct sockaddr_in6 *)&their_addr)->sin6_addr,
 			addrstr, sizeof(addrstr));
+
+		append_iface_if_linklocal(addrstr,
+			((struct sockaddr_in6 *)&their_addr)->sin6_scope_id);
+	}
 	else
 		address_text = inet_ntop(their_addr.ss_family, &((struct sockaddr_in *)&their_addr)->sin_addr,
 			addrstr, sizeof(addrstr));
@@ -1442,3 +1446,19 @@ bonjour_jabber_get_local_ips(int fd)
 
 	return ips;
 }
+
+void
+append_iface_if_linklocal(char *ip, uint32_t interface) {
+	struct in6_addr in6_addr;
+	int len_remain = INET6_ADDRSTRLEN - strlen(ip);
+
+	if (len_remain <= 1)
+		return;
+
+	if (inet_pton(AF_INET6, ip, &in6_addr) != 1 ||
+	    !IN6_IS_ADDR_LINKLOCAL(&in6_addr))
+		return;
+
+	snprintf(ip + strlen(ip), len_remain, "%%%d",
+		 interface);
+}
============================================================
--- libpurple/protocols/bonjour/jabber.h	c2277098331059135ab10da92ebe8c3d9ff4f75e
+++ libpurple/protocols/bonjour/jabber.h	11e281b0805e889a57abbd1552fef84f2454a3f2
@@ -111,4 +111,6 @@ GSList * bonjour_jabber_get_local_ips(in
 int xep_iq_send_and_free(XepIq *iq);
 GSList * bonjour_jabber_get_local_ips(int fd);
 
+void append_iface_if_linklocal(char *ip, uint32_t interface);
+
 #endif /* _BONJOUR_JABBER_H_ */
============================================================
--- libpurple/protocols/bonjour/mdns_avahi.c	7da97ca06c35f9dc1dc1e5b106a7dad3ea2fc107
+++ libpurple/protocols/bonjour/mdns_avahi.c	96c2858b5dfd35e4858c455cb0f2f2c71488cbda
@@ -179,6 +179,9 @@ _resolver_callback(AvahiServiceResolver 
 			ip[0] = '\0';
 			avahi_address_snprint(ip, AVAHI_ADDRESS_STR_MAX, a);
 
+			if (protocol == AVAHI_PROTO_INET6)
+				append_iface_if_linklocal(ip, interface);
+
 			purple_debug_info("bonjour", "_resolve_callback - name:%s ip:%s prev_ip:%s\n",
 				name, ip, rd->ip);
 
@@ -190,7 +193,7 @@ _resolver_callback(AvahiServiceResolver 
 				}
 				/* IPv6 goes at the front of the list and IPv4 at the end so that we "prefer" IPv6, if present */
 				if (protocol == AVAHI_PROTO_INET6) {
-					rd->ip = g_strdup_printf("%s%%%d", ip, interface);
+					rd->ip = g_strdup_printf("%s", ip);
 					bb->ips = g_slist_prepend(bb->ips, (gchar *) rd->ip);
 				} else {
 					rd->ip = g_strdup(ip);


More information about the Commits mailing list