Oops, I forgot this. This is done internally in libgadu, and not doing it
[pidgin-git.git] / libpurple / upnp.h
blobb0e4ab4e47b2ffe1ccd2588a9a9e03c252ecf760
1 /**
2 * @file upnp.h Universal Plug N Play API
3 * @ingroup core
4 */
6 /* purple
8 * Purple is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
27 #ifndef _PURPLE_UPNP_H_
28 #define _PURPLE_UPNP_H_
30 typedef struct _UPnPMappingAddRemove UPnPMappingAddRemove;
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 /**************************************************************************/
37 /** @name UPnP API */
38 /**************************************************************************/
39 /*@{*/
41 /* typedef struct _PurpleUPnPRequestData PurpleUPnPRequestData; */
43 typedef void (*PurpleUPnPCallback) (gboolean success, gpointer data);
46 /**
47 * Initialize UPnP
49 void purple_upnp_init(void);
52 /**
53 * Sends a discovery request to search for a UPnP enabled IGD that
54 * contains the WANIPConnection service that will allow us to recieve the
55 * public IP address of the IGD, and control it for forwarding ports.
56 * The result will be cached for further use.
58 * @param cb an optional callback function to be notified when the UPnP
59 * discovery is complete
60 * @param cb_data Extra data to be passed to the callback
62 void purple_upnp_discover(PurpleUPnPCallback cb, gpointer cb_data);
64 #if 0
65 /**
66 * Retrieve the current UPnP control info, if there is any available.
67 * This will only be filled in if purple_upnp_discover() had been called,
68 * and finished discovering.
70 * @return The control URL for the IGD we'll use to use the IGD services
72 const PurpleUPnPControlInfo* purple_upnp_get_control_info(void);
73 #endif
75 /**
76 * Gets the IP address from a UPnP enabled IGD that sits on the local
77 * network, so when getting the network IP, instead of returning the
78 * local network IP, the public IP is retrieved. This is a cached value from
79 * the time of the UPnP discovery.
81 * @return The IP address of the network, or NULL if something went wrong
83 const gchar* purple_upnp_get_public_ip(void);
85 /**
86 * Cancel a pending port mapping request initiated with either
87 * purple_upnp_set_port_mapping() or purple_upnp_remove_port_mapping().
89 * @param mapping_data The data returned when you initiated the UPnP mapping request.
91 void purple_upnp_cancel_port_mapping(UPnPMappingAddRemove *mapping_data);
93 /**
94 * Maps Ports in a UPnP enabled IGD that sits on the local network to
95 * this purple client. Essentially, this function takes care of the port
96 * forwarding so things like file transfers can work behind NAT firewalls
98 * @param portmap The port to map to this client
99 * @param protocol The protocol to map, either "TCP" or "UDP"
100 * @param cb an optional callback function to be notified when the mapping
101 * addition is complete
102 * @param cb_data Extra data to be passed to the callback
104 * @return Data which can be passed to purple_upnp_port_mapping_cancel() to cancel
106 UPnPMappingAddRemove *purple_upnp_set_port_mapping(unsigned short portmap, const gchar* protocol,
107 PurpleUPnPCallback cb, gpointer cb_data);
110 * Deletes a port mapping in a UPnP enabled IGD that sits on the local network
111 * to this purple client. Essentially, this function takes care of deleting the
112 * port forwarding after they have completed a connection so another client on
113 * the local network can take advantage of the port forwarding
115 * @param portmap The port to delete the mapping for
116 * @param protocol The protocol to map to. Either "TCP" or "UDP"
117 * @param cb an optional callback function to be notified when the mapping
118 * removal is complete
119 * @param cb_data Extra data to be passed to the callback
121 * @return Data which can be passed to purple_upnp_port_mapping_cancel() to cancel
123 UPnPMappingAddRemove *purple_upnp_remove_port_mapping(unsigned short portmap,
124 const gchar* protocol, PurpleUPnPCallback cb, gpointer cb_data);
126 /*@}*/
128 #ifdef __cplusplus
130 #endif
132 #endif /* _PURPLE_UPNP_H_ */