changeset 27110:455e679ea0db

Remove port mappings from the hash tables when removing them. Actually add NAT-PMP mappings to their hash table
author Marcus Lundblad <ml@update.uu.se>
date Wed, 17 Jun 2009 18:14:51 +0000
parents 38c4973b5222
children 510f07e1f5c1
files libpurple/network.c
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/network.c	Mon Jun 15 21:43:25 2009 +0000
+++ b/libpurple/network.c	Wed Jun 17 18:14:51 2009 +0000
@@ -283,9 +283,16 @@
 purple_network_finish_pmp_map_cb(gpointer data)
 {
 	PurpleNetworkListenData *listen_data;
+	gint *key = g_new(gint, 1);
+	gint *value = g_new(gint, 1);
 
 	listen_data = data;
 
+	/* add port mapping to hash table */
+	*key = purple_network_get_port_from_fd(listen_data->listenfd);
+	*value = listen_data->socket_type;
+	g_hash_table_insert(nat_pmp_port_mappings, key, value);
+
 	if (listen_data->cb)
 		listen_data->cb(listen_data->listenfd, listen_data->cb_data);
 
@@ -925,6 +932,7 @@
 	purple_upnp_remove_port_mapping(port, 
 		protocol == SOCK_STREAM ? "TCP" : "UDP", 
 		purple_network_upnp_mapping_remove_cb, NULL);
+	g_hash_table_remove(upnp_port_mappings, key);
 }
 
 static void
@@ -938,6 +946,7 @@
 	purple_pmp_destroy_map(
 		protocol == SOCK_STREAM ? PURPLE_PMP_TYPE_TCP : PURPLE_PMP_TYPE_UDP, 
 		port);
+	g_hash_table_remove(nat_pmp_port_mappings, key);
 }
 
 void