Frameworks/libpurple.framework/Versions/0.6.2/Headers/stun.h
author Zachary West <zacw@adium.im>
Fri Aug 21 13:25:11 2009 -0700 (2009-08-21)
changeset 2592 e8d15275025e
parent 1739 Frameworks/libpurple.framework/Versions/0.6.0/Headers/stun.h@8b0daad9656c
permissions -rw-r--r--
im.pidgin.adium.1-4 at 267c6165e02e34318a1823960bd04c0639952f73
     1 /**
     2  * @file stun.h STUN API
     3  * @ingroup core
     4  */
     5 
     6 /* purple
     7  *
     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.
    11  *
    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.
    16  *
    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.
    21  *
    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
    25  */
    26 #ifndef _PURPLE_STUN_H_
    27 #define _PURPLE_STUN_H_
    28 
    29 #ifdef __cplusplus
    30 extern "C" {
    31 #endif
    32 
    33 /**************************************************************************/
    34 /** @name STUN API                                                        */
    35 /**************************************************************************/
    36 /*@{*/
    37 
    38 typedef struct _PurpleStunNatDiscovery PurpleStunNatDiscovery;
    39 
    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;
    46 
    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;
    55 
    56 struct _PurpleStunNatDiscovery {
    57 	PurpleStunStatus status;
    58 	PurpleStunNatType type;
    59 	char publicip[16];
    60 	char *servername;
    61 	time_t lookup_time;
    62 };
    63 
    64 typedef void (*StunCallback) (PurpleStunNatDiscovery *);
    65 
    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.
    70  *
    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.
    74  *
    75  * @return a PurpleStunNatDiscovery which includes the public IP and the type
    76  *         of NAT or NULL is discovery would block
    77  */
    78 PurpleStunNatDiscovery *purple_stun_discover(StunCallback cb);
    79 
    80 void purple_stun_init(void);
    81 
    82 /*@}*/
    83 
    84 #ifdef __cplusplus
    85 }
    86 #endif
    87 
    88 #endif /* _PURPLE_STUN_H_ */