diff libpurple/upnp.h @ 15440:56a2a0bb290a

Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
author Evan Schoenberg <evan.s@dreskin.net>
date Sun, 28 Jan 2007 15:05:23 +0000
parents 5fe8042783c1
children 32c366eeeb99
line wrap: on
line diff
--- a/libpurple/upnp.h	Sun Jan 28 01:24:15 2007 +0000
+++ b/libpurple/upnp.h	Sun Jan 28 15:05:23 2007 +0000
@@ -26,6 +26,7 @@
 #ifndef _GAIM_UPNP_H_
 #define _GAIM_UPNP_H_
 
+typedef struct _UPnPMappingAddRemove UPnPMappingAddRemove;
 
 #ifdef __cplusplus
 extern "C" {
@@ -74,6 +75,14 @@
 const gchar* gaim_upnp_get_public_ip(void);
 
 /**
+ * Cancel a pending port mapping request initiated with either
+ * gaim_upnp_set_port_mapping() or gaim_upnp_remove_port_mapping().
+ *
+ * @param mapping_data The data returned when you initiated the UPnP mapping request.
+ */
+void gaim_upnp_cancel_port_mapping(UPnPMappingAddRemove *mapping_data);
+
+/**
  * Maps Ports in a UPnP enabled IGD that sits on the local network to
  * this gaim client. Essentially, this function takes care of the port
  * forwarding so things like file transfers can work behind NAT firewalls
@@ -83,8 +92,10 @@
  * @param cb an optional callback function to be notified when the mapping
  *           addition is complete
  * @param cb_data Extra data to be passed to the callback
+ *
+ * @return Data which can be passed to gaim_upnp_port_mapping_cancel() to cancel
  */
-void gaim_upnp_set_port_mapping(unsigned short portmap, const gchar* protocol,
+UPnPMappingAddRemove *gaim_upnp_set_port_mapping(unsigned short portmap, const gchar* protocol,
 		GaimUPnPCallback cb, gpointer cb_data);
 
 /**
@@ -98,8 +109,10 @@
  * @param cb an optional callback function to be notified when the mapping
  *           removal is complete
  * @param cb_data Extra data to be passed to the callback
+ *
+ * @return Data which can be passed to gaim_upnp_port_mapping_cancel() to cancel
  */
-void gaim_upnp_remove_port_mapping(unsigned short portmap,
+UPnPMappingAddRemove *gaim_upnp_remove_port_mapping(unsigned short portmap,
 		const gchar* protocol, GaimUPnPCallback cb, gpointer cb_data);
 
 /*@}*/