Mercurial > pidgin
changeset 32369:d6cc1ff0d9b7
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 <elb@pidgin.im>
author | linus.luessing@web.de |
---|---|
date | Wed, 30 Nov 2011 00:58:50 +0000 |
parents | 00ea5f8ef509 |
children | c37cd9c2da7f |
files | ChangeLog libpurple/protocols/bonjour/jabber.c libpurple/protocols/bonjour/jabber.h libpurple/protocols/bonjour/mdns_avahi.c |
diffstat | 4 files changed, 30 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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); +}
--- 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_ */
--- 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);