--- a/ChangeLog.API Mon Apr 15 00:48:17 2013 +0200
+++ b/ChangeLog.API Wed Apr 17 18:56:03 2013 +0200
@@ -196,6 +196,7 @@
* purple_network_listen_map_external
* purple_network_listen_range_family. Use purple_network_listen,
+ * purple_network_ip_atoi * purple_notify_searchresults_column_get_title
* purple_notify_searchresults_get_columns_count
* purple_notify_searchresults_get_rows_count
--- a/libpurple/network.c Mon Apr 15 00:48:17 2013 +0200
+++ b/libpurple/network.c Wed Apr 17 18:56:03 2013 +0200
@@ -121,28 +121,6 @@
static GHashTable *upnp_port_mappings = NULL;
static GHashTable *nat_pmp_port_mappings = NULL;
-purple_network_ip_atoi(const char *ip)
- static unsigned char ret[4];
- gchar *delimiter = ".";
- g_return_val_if_fail(ip != NULL, NULL);
- split = g_strsplit(ip, delimiter, 4);
- for (i = 0; split[i] != NULL; i++)
- ret[i] = atoi(split[i]);
- /* i should always be 4 */
purple_network_set_public_ip(const char *ip)
@@ -287,6 +265,24 @@
#endif /* HAVE_GETIFADDRS && HAVE_INET_NTOP */
+ * Checks, if specified hostname is valid ipv4 address. + * @param hostname The hostname to be verified. + * @return TRUE, if the hostname is valid. +purple_network_is_ipv4(const gchar *hostname) + g_return_val_if_fail(hostname != NULL, FALSE); + /* We don't accept ipv6 here. */ + if (strchr(hostname, ':') != NULL) + return g_hostname_is_ip_address(hostname); purple_network_get_my_ip(int fd)
@@ -297,7 +293,7 @@
if (!purple_prefs_get_bool("/purple/network/auto_ip")) {
ip = purple_network_get_public_ip();
/* Make sure the IP address entered by the user is valid */
- if ((ip != NULL) && (purple_network_ip_atoi(ip) != NULL))
+ if ((ip != NULL) && (purple_network_is_ipv4(ip))) /* Check if STUN discovery was already done */
--- a/libpurple/network.h Mon Apr 15 00:48:17 2013 +0200
+++ b/libpurple/network.h Wed Apr 17 18:56:03 2013 +0200
@@ -40,20 +40,6 @@
typedef void (*PurpleNetworkListenCallback) (int listenfd, gpointer data);
- * Converts a dot-decimal IP address to an array of unsigned
- * chars. For example, converts 192.168.0.1 to a 4 byte
- * array containing 192, 168, 0 and 1.
- * @param ip An IP address in dot-decimal notiation.
- * @return An array of 4 bytes containing an IP addresses
- * equivalent to the given parameter, or NULL if
- * the given IP address is invalid. This value
- * is statically allocated and should not be
-const unsigned char *purple_network_ip_atoi(const char *ip);
* Sets the IP address of the local system in preferences. This
* is the IP address that should be used for incoming connections
* (file transfer, direct IM, etc.) and should therefore be
--- a/libpurple/plugins/perl/common/Network.xs Mon Apr 15 00:48:17 2013 +0200
+++ b/libpurple/plugins/perl/common/Network.xs Wed Apr 17 18:56:03 2013 +0200
@@ -18,10 +18,6 @@
purple_network_get_public_ip()
-purple_network_ip_atoi(ip)
Purple::NetworkListenData
purple_network_listen(port, socket_family, socket_type, map_external, cb, cb_data)
--- a/libpurple/protocols/oscar/peer.c Mon Apr 15 00:48:17 2013 +0200
+++ b/libpurple/protocols/oscar/peer.c Wed Apr 17 18:56:03 2013 +0200
@@ -642,6 +642,40 @@
+ * Converts a dot-decimal IP address to an array of unsigned + * chars. For example, converts 192.168.0.1 to a 4 byte + * array containing 192, 168, 0 and 1. + * @param ip An IP address in dot-decimal notiation. + * @return An array of 4 bytes containing an IP addresses + * equivalent to the given parameter, or NULL if + * the given IP address is invalid. This value + * is statically allocated and should not be +static const unsigned char * +peer_ip_atoi(const char *ip) + static unsigned char ret[4]; + gchar *delimiter = "."; + g_return_val_if_fail(ip != NULL, NULL); + split = g_strsplit(ip, delimiter, 4); + for (i = 0; split[i] != NULL; i++) + ret[i] = atoi(split[i]); + /* i should always be 4 */ * We've just opened a listener socket, so we send the remote
* user an ICBM and ask them to connect to us.
@@ -692,13 +726,13 @@
listener_ip = purple_network_get_my_ip(bos_conn->fd);
- ip_atoi = purple_network_ip_atoi(listener_ip);
+ ip_atoi = peer_ip_atoi(listener_ip); /* Could not convert IP to 4 byte array--weird, but this does
happen for some users (#4829, Adium #15839). Maybe they're
connecting with IPv6...? Maybe through a proxy? */
purple_debug_error("oscar", "Can't ask peer to connect to us "
- "because purple_network_ip_atoi(%s) returned NULL. "
+ "because peer_ip_atoi(%s) returned NULL. " listener_ip ? listener_ip : "(null)",
bos_conn->gsc ? bos_conn->gsc->fd : bos_conn->fd,