# HG changeset patch # User Daniel Atallah # Date 1323790392 0 # Node ID b30d7c76db03091a50bcb8daf4536efdc7190768 # Parent fac08a235b68fe395fa3d29c4892e20022b95bb9# Parent c0c60e110c82553ab4634ce510a138f6b868a4e3 propagate from branch 'im.pidgin.pidgin.2.x.y' (head 83dd0d90742e9ccf6890fc21736440df73e48f24) to branch 'im.pidgin.pidgin' (head 31a6cb7c7aaed62b686fa3d4403dbed06d291abd) diff -r fac08a235b68 -r b30d7c76db03 libpurple/protocols/bonjour/jabber.c --- a/libpurple/protocols/bonjour/jabber.c Mon Dec 12 09:01:21 2011 +0000 +++ b/libpurple/protocols/bonjour/jabber.c Tue Dec 13 15:33:12 2011 +0000 @@ -1455,7 +1455,7 @@ } void -append_iface_if_linklocal(char *ip, uint32_t interface) { +append_iface_if_linklocal(char *ip, guint32 interface_param) { struct in6_addr in6_addr; int len_remain = INET6_ADDRSTRLEN - strlen(ip); @@ -1467,5 +1467,5 @@ return; snprintf(ip + strlen(ip), len_remain, "%%%d", - interface); + interface_param); } diff -r fac08a235b68 -r b30d7c76db03 libpurple/protocols/bonjour/jabber.h --- a/libpurple/protocols/bonjour/jabber.h Mon Dec 12 09:01:21 2011 +0000 +++ b/libpurple/protocols/bonjour/jabber.h Tue Dec 13 15:33:12 2011 +0000 @@ -111,6 +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); +void append_iface_if_linklocal(char *ip, guint32 interface_param); #endif /* _BONJOUR_JABBER_H_ */ diff -r fac08a235b68 -r b30d7c76db03 libpurple/win32/libc_interface.c --- a/libpurple/win32/libc_interface.c Mon Dec 12 09:01:21 2011 +0000 +++ b/libpurple/win32/libc_interface.c Tue Dec 13 15:33:12 2011 +0000 @@ -300,6 +300,50 @@ return (const char *) dst; } +int +wpurple_inet_pton(int af, const char *src, void *dst) +{ + /* struct sockaddr can't accomodate struct sockaddr_in6. */ + union { + struct sockaddr_in6 sin6; + struct sockaddr_in sin; + } sa; + size_t srcsize; + + switch(af) + { + case AF_INET: + sa.sin.sin_family = AF_INET; + srcsize = sizeof (sa.sin); + break; + case AF_INET6: + sa.sin6.sin6_family = AF_INET6; + srcsize = sizeof (sa.sin6); + break; + default: + errno = WSAEPFNOSUPPORT; + return -1; + } + + if (WSAStringToAddress(src, af, NULL, (struct sockaddr *) &sa, &srcsize) != 0) + { + errno = WSAGetLastError(); + return -1; + } + + switch(af) + { + case AF_INET: + memcpy(dst, &sa.sin.sin_addr, sizeof(sa.sin.sin_addr)); + break; + case AF_INET6: + memcpy(dst, &sa.sin6.sin6_addr, sizeof(sa.sin6.sin6_addr)); + break; + } + + return 1; +} + /* netdb.h */ struct hostent* wpurple_gethostbyname(const char *name) { diff -r fac08a235b68 -r b30d7c76db03 libpurple/win32/libc_interface.h --- a/libpurple/win32/libc_interface.h Mon Dec 12 09:01:21 2011 +0000 +++ b/libpurple/win32/libc_interface.h Tue Dec 13 15:33:12 2011 +0000 @@ -89,6 +89,9 @@ #define inet_ntop( af, src, dst, cnt ) \ wpurple_inet_ntop( af, src, dst, cnt ) +#define inet_pton( af, src, dst ) \ +wpurple_inet_pton( af, src, dst ) + /* netdb.h */ #define gethostbyname( name ) \ wpurple_gethostbyname( name ) diff -r fac08a235b68 -r b30d7c76db03 libpurple/win32/libc_internal.h --- a/libpurple/win32/libc_internal.h Mon Dec 12 09:01:21 2011 +0000 +++ b/libpurple/win32/libc_internal.h Tue Dec 13 15:33:12 2011 +0000 @@ -48,6 +48,7 @@ int wpurple_inet_aton(const char *name, struct in_addr *addr); const char * wpurple_inet_ntop (int af, const void *src, char *dst, socklen_t cnt); +int wpurple_inet_pton(int af, const char *src, void *dst); /* netdb.h */ struct hostent* wpurple_gethostbyname(const char *name);