# HG changeset patch # User linus.luessing@web.de # Date 1322614730 0 # Node ID d6cc1ff0d9b77cac648bea3073edd11e88d594d9 # Parent 00ea5f8ef50913ce92985fbb74dbb764eb1d7343 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. committer: Ethan Blanton diff -r 00ea5f8ef509 -r d6cc1ff0d9b7 ChangeLog --- a/ChangeLog Tue Nov 29 03:58:50 2011 +0000 +++ b/ChangeLog Wed Nov 30 00:58:50 2011 +0000 @@ -4,6 +4,9 @@ Finch: * Fix compilation on OpenBSD. + Bonjour: + * IPv6 fixes (Linus Lüssing) + Gadu-Gadu: * Fix problems linking against GnuTLS. (#14544) diff -r 00ea5f8ef509 -r d6cc1ff0d9b7 libpurple/protocols/bonjour/jabber.c --- a/libpurple/protocols/bonjour/jabber.c Tue Nov 29 03:58:50 2011 +0000 +++ b/libpurple/protocols/bonjour/jabber.c Wed Nov 30 00:58:50 2011 +0000 @@ -665,9 +665,13 @@ /* 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 @@ 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); +} diff -r 00ea5f8ef509 -r d6cc1ff0d9b7 libpurple/protocols/bonjour/jabber.h --- a/libpurple/protocols/bonjour/jabber.h Tue Nov 29 03:58:50 2011 +0000 +++ b/libpurple/protocols/bonjour/jabber.h Wed Nov 30 00:58:50 2011 +0000 @@ -111,4 +111,6 @@ 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_ */ diff -r 00ea5f8ef509 -r d6cc1ff0d9b7 libpurple/protocols/bonjour/mdns_avahi.c --- a/libpurple/protocols/bonjour/mdns_avahi.c Tue Nov 29 03:58:50 2011 +0000 +++ b/libpurple/protocols/bonjour/mdns_avahi.c Wed Nov 30 00:58:50 2011 +0000 @@ -179,6 +179,9 @@ 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 @@ } /* 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);