2 * @file stun.h STUN API
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_
33 /**************************************************************************/
35 /**************************************************************************/
38 typedef struct _PurpleStunNatDiscovery PurpleStunNatDiscovery
;
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
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
56 struct _PurpleStunNatDiscovery
{
57 PurpleStunStatus status
;
58 PurpleStunNatType type
;
64 typedef void (*StunCallback
) (PurpleStunNatDiscovery
*);
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
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);
88 #endif /* _PURPLE_STUN_H_ */