Mercurial > pidgin
comparison libpurple/protocols/bonjour/jabber.c @ 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 | e1d31abb245c |
children | 0734b9c8c345 c0c60e110c82 |
comparison
equal
deleted
inserted
replaced
32367:00ea5f8ef509 | 32369:d6cc1ff0d9b7 |
---|---|
663 fcntl(client_socket, F_SETFD, FD_CLOEXEC); | 663 fcntl(client_socket, F_SETFD, FD_CLOEXEC); |
664 #endif | 664 #endif |
665 | 665 |
666 /* Look for the buddy that has opened the conversation and fill information */ | 666 /* Look for the buddy that has opened the conversation and fill information */ |
667 #ifdef HAVE_INET_NTOP | 667 #ifdef HAVE_INET_NTOP |
668 if (their_addr.ss_family == AF_INET6) | 668 if (their_addr.ss_family == AF_INET6) { |
669 address_text = inet_ntop(their_addr.ss_family, &((struct sockaddr_in6 *)&their_addr)->sin6_addr, | 669 address_text = inet_ntop(their_addr.ss_family, &((struct sockaddr_in6 *)&their_addr)->sin6_addr, |
670 addrstr, sizeof(addrstr)); | 670 addrstr, sizeof(addrstr)); |
671 | |
672 append_iface_if_linklocal(addrstr, | |
673 ((struct sockaddr_in6 *)&their_addr)->sin6_scope_id); | |
674 } | |
671 else | 675 else |
672 address_text = inet_ntop(their_addr.ss_family, &((struct sockaddr_in *)&their_addr)->sin_addr, | 676 address_text = inet_ntop(their_addr.ss_family, &((struct sockaddr_in *)&their_addr)->sin_addr, |
673 addrstr, sizeof(addrstr)); | 677 addrstr, sizeof(addrstr)); |
674 #else | 678 #else |
675 address_text = inet_ntoa(((struct sockaddr_in *)&their_addr)->sin_addr); | 679 address_text = inet_ntoa(((struct sockaddr_in *)&their_addr)->sin_addr); |
1440 } | 1444 } |
1441 #endif | 1445 #endif |
1442 | 1446 |
1443 return ips; | 1447 return ips; |
1444 } | 1448 } |
1449 | |
1450 void | |
1451 append_iface_if_linklocal(char *ip, uint32_t interface) { | |
1452 struct in6_addr in6_addr; | |
1453 int len_remain = INET6_ADDRSTRLEN - strlen(ip); | |
1454 | |
1455 if (len_remain <= 1) | |
1456 return; | |
1457 | |
1458 if (inet_pton(AF_INET6, ip, &in6_addr) != 1 || | |
1459 !IN6_IS_ADDR_LINKLOCAL(&in6_addr)) | |
1460 return; | |
1461 | |
1462 snprintf(ip + strlen(ip), len_remain, "%%%d", | |
1463 interface); | |
1464 } |