Frameworks/libpurple.framework/Versions/0.6.2/Headers/stun.h
changeset 2592 e8d15275025e
parent 1739 8b0daad9656c
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Frameworks/libpurple.framework/Versions/0.6.2/Headers/stun.h	Fri Aug 21 13:25:11 2009 -0700
     1.3 @@ -0,0 +1,88 @@
     1.4 +/**
     1.5 + * @file stun.h STUN API
     1.6 + * @ingroup core
     1.7 + */
     1.8 +
     1.9 +/* purple
    1.10 + *
    1.11 + * Purple is the legal property of its developers, whose names are too numerous
    1.12 + * to list here.  Please refer to the COPYRIGHT file distributed with this
    1.13 + * source distribution.
    1.14 + *
    1.15 + * This program is free software; you can redistribute it and/or modify
    1.16 + * it under the terms of the GNU General Public License as published by
    1.17 + * the Free Software Foundation; either version 2 of the License, or
    1.18 + * (at your option) any later version.
    1.19 + *
    1.20 + * This program is distributed in the hope that it will be useful,
    1.21 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.22 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.23 + * GNU General Public License for more details.
    1.24 + *
    1.25 + * You should have received a copy of the GNU General Public License
    1.26 + * along with this program; if not, write to the Free Software
    1.27 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
    1.28 + */
    1.29 +#ifndef _PURPLE_STUN_H_
    1.30 +#define _PURPLE_STUN_H_
    1.31 +
    1.32 +#ifdef __cplusplus
    1.33 +extern "C" {
    1.34 +#endif
    1.35 +
    1.36 +/**************************************************************************/
    1.37 +/** @name STUN API                                                        */
    1.38 +/**************************************************************************/
    1.39 +/*@{*/
    1.40 +
    1.41 +typedef struct _PurpleStunNatDiscovery PurpleStunNatDiscovery;
    1.42 +
    1.43 +typedef enum {
    1.44 +	PURPLE_STUN_STATUS_UNDISCOVERED = -1,
    1.45 +	PURPLE_STUN_STATUS_UNKNOWN, /* no STUN server reachable */
    1.46 +	PURPLE_STUN_STATUS_DISCOVERING,
    1.47 +	PURPLE_STUN_STATUS_DISCOVERED
    1.48 +} PurpleStunStatus;
    1.49 +
    1.50 +typedef enum {
    1.51 +	PURPLE_STUN_NAT_TYPE_PUBLIC_IP,
    1.52 +	PURPLE_STUN_NAT_TYPE_UNKNOWN_NAT,
    1.53 +	PURPLE_STUN_NAT_TYPE_FULL_CONE,
    1.54 +	PURPLE_STUN_NAT_TYPE_RESTRICTED_CONE,
    1.55 +	PURPLE_STUN_NAT_TYPE_PORT_RESTRICTED_CONE,
    1.56 +	PURPLE_STUN_NAT_TYPE_SYMMETRIC
    1.57 +} PurpleStunNatType;
    1.58 +
    1.59 +struct _PurpleStunNatDiscovery {
    1.60 +	PurpleStunStatus status;
    1.61 +	PurpleStunNatType type;
    1.62 +	char publicip[16];
    1.63 +	char *servername;
    1.64 +	time_t lookup_time;
    1.65 +};
    1.66 +
    1.67 +typedef void (*StunCallback) (PurpleStunNatDiscovery *);
    1.68 +
    1.69 +/**
    1.70 + * Starts a NAT discovery. It returns a PurpleStunNatDiscovery if the discovery
    1.71 + * is already done. Otherwise the callback is called when the discovery is over
    1.72 + * and NULL is returned.
    1.73 + *
    1.74 + * @param cb The callback to call when the STUN discovery is finished if the
    1.75 + *           discovery would block.  If the discovery is done, this is NOT
    1.76 + *           called.
    1.77 + *
    1.78 + * @return a PurpleStunNatDiscovery which includes the public IP and the type
    1.79 + *         of NAT or NULL is discovery would block
    1.80 + */
    1.81 +PurpleStunNatDiscovery *purple_stun_discover(StunCallback cb);
    1.82 +
    1.83 +void purple_stun_init(void);
    1.84 +
    1.85 +/*@}*/
    1.86 +
    1.87 +#ifdef __cplusplus
    1.88 +}
    1.89 +#endif
    1.90 +
    1.91 +#endif /* _PURPLE_STUN_H_ */