a77755a3c7992e004178f51e497a75332455be98
[oweals/gnunet.git] / src / upnp / upnp.h
1 /**
2  * @file upnp.h Universal Plug N Play API
3  * @ingroup core
4  *
5  * gaim
6  *
7  * Gaim is the legal property of its developers, whose names are too numerous
8  * to list here.  Please refer to the COPYRIGHT file distributed with this
9  * source distribution.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24  */
25
26 #ifndef _GAIM_UPNP_H_
27 #define _GAIM_UPNP_H_
28
29 #include <libxml/parser.h>
30 #include <string.h>
31 #include "gnunet_util_lib.h"
32
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #if 0                           /* keep Emacsens' auto-indent happy */
37 }
38 #endif
39 #endif
40
41 /**
42  * Sends a discovery request to search for a UPnP enabled IGD that
43  * contains the WANIPConnection service that will allow us to receive the
44  * public IP address of the IGD, and control it for forwarding ports.
45  * The result will be cached for further use.
46  */
47 int gaim_upnp_discover (struct GNUNET_CONFIGURATION_Handle *cfg, int sock);
48
49 /**
50  * Gets the IP address from a UPnP enabled IGD that sits on the local
51  * network, so when getting the network IP, instead of returning the
52  * local network IP, the public IP is retrieved.  This is a cached value from
53  * the time of the UPnP discovery.
54  *
55  * @return The IP address of the network, or NULL if something went wrong
56  */
57 const char *gaim_upnp_get_public_ip (void);
58
59 /**
60  * Maps Ports in a UPnP enabled IGD that sits on the local network to
61  * this gaim client. Essentially, this function takes care of the port
62  * forwarding so things like file transfers can work behind NAT firewalls
63  *
64  * @param cfg configuration to use
65  * @param do_add TRUE/GNUNET_YES to add, FALSE/GNUNET_NO to remove
66  * @param portmap The port to map to this client
67  * @param protocol The protocol to map, either "TCP" or "UDP"
68  */
69 int gaim_upnp_change_port_mapping (struct GNUNET_CONFIGURATION_Handle *cfg,
70                                    int do_add,
71                                    uint16_t portmap, const char *protocol);
72
73 #if 0                           /* keep Emacsens' auto-indent happy */
74 {
75 #endif
76 #ifdef __cplusplus
77 }
78 #endif
79
80 #endif /* _GAIM_UPNP_H_ */