Oops, I forgot this. This is done internally in libgadu, and not doing it
[pidgin-git.git] / libpurple / stun.h
blobb51a61c7e519812ab5ea0e556272d9443258e05c
1 /**
2 * @file stun.h STUN 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
26 #ifndef _PURPLE_STUN_H_
27 #define _PURPLE_STUN_H_
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
33 /**************************************************************************/
34 /** @name STUN API */
35 /**************************************************************************/
36 /*@{*/
38 typedef struct _PurpleStunNatDiscovery PurpleStunNatDiscovery;
40 typedef enum {
41 PURPLE_STUN_STATUS_UNDISCOVERED = -1,
42 PURPLE_STUN_STATUS_UNKNOWN, /* no STUN server reachable */
43 PURPLE_STUN_STATUS_DISCOVERING,
44 PURPLE_STUN_STATUS_DISCOVERED
45 } PurpleStunStatus;
47 typedef enum {
48 PURPLE_STUN_NAT_TYPE_PUBLIC_IP,
49 PURPLE_STUN_NAT_TYPE_UNKNOWN_NAT,
50 PURPLE_STUN_NAT_TYPE_FULL_CONE,
51 PURPLE_STUN_NAT_TYPE_RESTRICTED_CONE,
52 PURPLE_STUN_NAT_TYPE_PORT_RESTRICTED_CONE,
53 PURPLE_STUN_NAT_TYPE_SYMMETRIC
54 } PurpleStunNatType;
56 struct _PurpleStunNatDiscovery {
57 PurpleStunStatus status;
58 PurpleStunNatType type;
59 char publicip[16];
60 char *servername;
61 time_t lookup_time;
64 typedef void (*StunCallback) (PurpleStunNatDiscovery *);
66 /**
67 * Starts a NAT discovery. It returns a PurpleStunNatDiscovery if the discovery
68 * is already done. Otherwise the callback is called when the discovery is over
69 * and NULL is returned.
71 * @param cb The callback to call when the STUN discovery is finished if the
72 * discovery would block. If the discovery is done, this is NOT
73 * called.
75 * @return a PurpleStunNatDiscovery which includes the public IP and the type
76 * of NAT or NULL is discovery would block
78 PurpleStunNatDiscovery *purple_stun_discover(StunCallback cb);
80 void purple_stun_init(void);
82 /*@}*/
84 #ifdef __cplusplus
86 #endif
88 #endif /* _PURPLE_STUN_H_ */