Wed Apr 6 11:29:48 2011

Asterisk developer's documentation


stun.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2008, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*!
00020  * \file stun.h
00021  * \brief STUN support.
00022  *
00023  * STUN is defined in RFC 3489.
00024  */
00025 
00026 #ifndef _ASTERISK_STUN_H
00027 #define _ASTERISK_STUN_H
00028 
00029 #include "asterisk/network.h"
00030 
00031 #if defined(__cplusplus) || defined(c_plusplus)
00032 extern "C" {
00033 #endif
00034 
00035 static const int STANDARD_STUN_PORT = 3478;
00036 
00037 enum ast_stun_result {
00038    AST_STUN_IGNORE = 0,
00039    AST_STUN_ACCEPT,
00040 };
00041 
00042 struct stun_attr;
00043 
00044 /*! \brief Generic STUN request
00045  * send a generic stun request to the server specified.
00046  * \param s the socket used to send the request
00047  * \param dst the address of the STUN server
00048  * \param username if non null, add the username in the request
00049  * \param answer if non null, the function waits for a response and
00050  *    puts here the externally visible address.
00051  * \return 0 on success, other values on error.
00052  * The interface it may change in the future.
00053  */
00054 int ast_stun_request(int s, struct sockaddr_in *dst, const char *username, struct sockaddr_in *answer);
00055 
00056 /*! \brief callback type to be invoked on stun responses. */
00057 typedef int (stun_cb_f)(struct stun_attr *attr, void *arg);
00058 
00059 /*! \brief handle an incoming STUN message.
00060  *
00061  * Do some basic sanity checks on packet size and content,
00062  * try to extract a bit of information, and possibly reply.
00063  * At the moment this only processes BIND requests, and returns
00064  * the externally visible address of the request.
00065  * If a callback is specified, invoke it with the attribute.
00066  */
00067 int ast_stun_handle_packet(int s, struct sockaddr_in *src, unsigned char *data, size_t len, stun_cb_f *stun_cb, void *arg);
00068 
00069 #if defined(__cplusplus) || defined(c_plusplus)
00070 }
00071 #endif
00072 
00073 #endif /* _ASTERISK_STUN_H */

Generated on Wed Apr 6 11:29:48 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7