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
Evan@653
     1
/**
Evan@653
     2
 * @file stun.h STUN API
Evan@653
     3
 * @ingroup core
Evan@653
     4
 */
Evan@653
     5
Evan@653
     6
/* purple
Evan@653
     7
 *
Evan@653
     8
 * Purple is the legal property of its developers, whose names are too numerous
Evan@653
     9
 * to list here.  Please refer to the COPYRIGHT file distributed with this
Evan@653
    10
 * source distribution.
Evan@653
    11
 *
Evan@653
    12
 * This program is free software; you can redistribute it and/or modify
Evan@653
    13
 * it under the terms of the GNU General Public License as published by
Evan@653
    14
 * the Free Software Foundation; either version 2 of the License, or
Evan@653
    15
 * (at your option) any later version.
Evan@653
    16
 *
Evan@653
    17
 * This program is distributed in the hope that it will be useful,
Evan@653
    18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Evan@653
    19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Evan@653
    20
 * GNU General Public License for more details.
Evan@653
    21
 *
Evan@653
    22
 * You should have received a copy of the GNU General Public License
Evan@653
    23
 * along with this program; if not, write to the Free Software
Evan@653
    24
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
Evan@653
    25
 */
Evan@653
    26
#ifndef _PURPLE_STUN_H_
Evan@653
    27
#define _PURPLE_STUN_H_
Evan@653
    28
Evan@653
    29
#ifdef __cplusplus
Evan@653
    30
extern "C" {
Evan@653
    31
#endif
Evan@653
    32
Evan@653
    33
/**************************************************************************/
Evan@653
    34
/** @name STUN API                                                        */
Evan@653
    35
/**************************************************************************/
Evan@653
    36
/*@{*/
Evan@653
    37
Evan@653
    38
typedef struct _PurpleStunNatDiscovery PurpleStunNatDiscovery;
Evan@653
    39
Evan@653
    40
typedef enum {
Evan@653
    41
	PURPLE_STUN_STATUS_UNDISCOVERED = -1,
Evan@653
    42
	PURPLE_STUN_STATUS_UNKNOWN, /* no STUN server reachable */
Evan@653
    43
	PURPLE_STUN_STATUS_DISCOVERING,
Evan@653
    44
	PURPLE_STUN_STATUS_DISCOVERED
Evan@653
    45
} PurpleStunStatus;
Evan@653
    46
Evan@653
    47
typedef enum {
Evan@653
    48
	PURPLE_STUN_NAT_TYPE_PUBLIC_IP,
Evan@653
    49
	PURPLE_STUN_NAT_TYPE_UNKNOWN_NAT,
Evan@653
    50
	PURPLE_STUN_NAT_TYPE_FULL_CONE,
Evan@653
    51
	PURPLE_STUN_NAT_TYPE_RESTRICTED_CONE,
Evan@653
    52
	PURPLE_STUN_NAT_TYPE_PORT_RESTRICTED_CONE,
Evan@653
    53
	PURPLE_STUN_NAT_TYPE_SYMMETRIC
Evan@653
    54
} PurpleStunNatType;
Evan@653
    55
Evan@653
    56
struct _PurpleStunNatDiscovery {
Evan@653
    57
	PurpleStunStatus status;
Evan@653
    58
	PurpleStunNatType type;
Evan@653
    59
	char publicip[16];
Evan@653
    60
	char *servername;
Evan@653
    61
	time_t lookup_time;
Evan@653
    62
};
Evan@653
    63
Evan@653
    64
typedef void (*StunCallback) (PurpleStunNatDiscovery *);
Evan@653
    65
Evan@653
    66
/**
Evan@653
    67
 * Starts a NAT discovery. It returns a PurpleStunNatDiscovery if the discovery
Evan@653
    68
 * is already done. Otherwise the callback is called when the discovery is over
Evan@653
    69
 * and NULL is returned.
Evan@653
    70
 *
Evan@653
    71
 * @param cb The callback to call when the STUN discovery is finished if the
Evan@653
    72
 *           discovery would block.  If the discovery is done, this is NOT
Evan@653
    73
 *           called.
Evan@653
    74
 *
Evan@653
    75
 * @return a PurpleStunNatDiscovery which includes the public IP and the type
Evan@653
    76
 *         of NAT or NULL is discovery would block
Evan@653
    77
 */
Evan@653
    78
PurpleStunNatDiscovery *purple_stun_discover(StunCallback cb);
Evan@653
    79
Evan@653
    80
void purple_stun_init(void);
Evan@653
    81
Evan@653
    82
/*@}*/
Evan@653
    83
Evan@653
    84
#ifdef __cplusplus
Evan@653
    85
}
Evan@653
    86
#endif
Evan@653
    87
Evan@653
    88
#endif /* _PURPLE_STUN_H_ */