| config_site_sample.h | | config_site_sample.h | |
| | | | |
| skipping to change at line 51 | | skipping to change at line 51 | |
| | | | |
| /* We probably need more buffers on WM, so increase the limit */ | | /* We probably need more buffers on WM, so increase the limit */ | |
| #define PJMEDIA_SOUND_BUFFER_COUNT 32 | | #define PJMEDIA_SOUND_BUFFER_COUNT 32 | |
| | | | |
| /* Fine tune Speex's default settings for best performance/quality */ | | /* Fine tune Speex's default settings for best performance/quality */ | |
| #define PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY 5 | | #define PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY 5 | |
| | | | |
| /* For CPU reason, disable speex AEC and use the echo suppressor. */ | | /* For CPU reason, disable speex AEC and use the echo suppressor. */ | |
| #define PJMEDIA_HAS_SPEEX_AEC 0 | | #define PJMEDIA_HAS_SPEEX_AEC 0 | |
| | | | |
|
| /* Shouldn't use resampling for performance reason too. */ | | /* Previously, resampling is disabled due to performance reason and | |
| #define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_NONE | | * this condition prevented some 'light' wideband codecs (e.g: G722.1) | |
| | | * to work along with narrowband codecs. Lately, some tests showed | |
| | | * that 16kHz <-> 8kHz resampling using libresample small filter was | |
| | | * affordable on ARM9 260 MHz, so here we decided to enable resampling. | |
| | | * Note that it is important to make sure that libresample is created | |
| | | * using small filter. For example PJSUA_DEFAULT_CODEC_QUALITY must | |
| | | * be set to 3 or 4 so pjsua-lib will apply small filter resampling. | |
| | | */ | |
| | | //#define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_NONE | |
| | | #define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_LIBRESAMPLE | |
| | | | |
| /* Use the lighter WSOLA implementation */ | | /* Use the lighter WSOLA implementation */ | |
| #define PJMEDIA_WSOLA_IMP PJMEDIA_WSOLA_IMP_WSOLA_LITE | | #define PJMEDIA_WSOLA_IMP PJMEDIA_WSOLA_IMP_WSOLA_LITE | |
| | | | |
| /* | | /* | |
| * PJSIP settings. | | * PJSIP settings. | |
| */ | | */ | |
| | | | |
| /* Set maximum number of dialog/transaction/calls to minimum to reduce | | /* Set maximum number of dialog/transaction/calls to minimum to reduce | |
| * memory usage | | * memory usage | |
| */ | | */ | |
| #define PJSIP_MAX_TSX_COUNT 31 | | #define PJSIP_MAX_TSX_COUNT 31 | |
| #define PJSIP_MAX_DIALOG_COUNT 31 | | #define PJSIP_MAX_DIALOG_COUNT 31 | |
| #define PJSUA_MAX_CALLS 4 | | #define PJSUA_MAX_CALLS 4 | |
| | | | |
| /* | | /* | |
| * PJSUA settings | | * PJSUA settings | |
| */ | | */ | |
| | | | |
|
| /* Default codec (Speex) quality */ | | /* Default codec quality, previously was set to 5, however it is now | |
| #define PJSUA_DEFAULT_CODEC_QUALITY 5 | | * set to 4 to make sure pjsua instantiates resampler with small filter | |
| | | . | |
| | | */ | |
| | | #define PJSUA_DEFAULT_CODEC_QUALITY 4 | |
| | | | |
| /* Set maximum number of objects to minimum to reduce memory usage */ | | /* Set maximum number of objects to minimum to reduce memory usage */ | |
| #define PJSUA_MAX_ACC 4 | | #define PJSUA_MAX_ACC 4 | |
| #define PJSUA_MAX_PLAYERS 4 | | #define PJSUA_MAX_PLAYERS 4 | |
| #define PJSUA_MAX_RECORDERS 4 | | #define PJSUA_MAX_RECORDERS 4 | |
| #define PJSUA_MAX_CONF_PORTS (PJSUA_MAX_CALLS+2*PJSUA_MAX
_PLAYERS) | | #define PJSUA_MAX_CONF_PORTS (PJSUA_MAX_CALLS+2*PJSUA_MAX
_PLAYERS) | |
| #define PJSUA_MAX_BUDDIES 32 | | #define PJSUA_MAX_BUDDIES 32 | |
| | | | |
| #endif /* PJ_WIN32_WINCE */ | | #endif /* PJ_WIN32_WINCE */ | |
| | | | |
| | | | |
| skipping to change at line 133 | | skipping to change at line 144 | |
| #define PJMEDIA_HAS_L16_CODEC 0 | | #define PJMEDIA_HAS_L16_CODEC 0 | |
| #define PJMEDIA_HAS_ILBC_CODEC 0 | | #define PJMEDIA_HAS_ILBC_CODEC 0 | |
| #define PJMEDIA_HAS_G722_CODEC 0 | | #define PJMEDIA_HAS_G722_CODEC 0 | |
| | | | |
| /* Fine tune Speex's default settings for best performance/quality */ | | /* Fine tune Speex's default settings for best performance/quality */ | |
| #define PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY 5 | | #define PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY 5 | |
| | | | |
| /* For CPU reason, disable speex AEC and use the echo suppressor. */ | | /* For CPU reason, disable speex AEC and use the echo suppressor. */ | |
| #define PJMEDIA_HAS_SPEEX_AEC 0 | | #define PJMEDIA_HAS_SPEEX_AEC 0 | |
| | | | |
|
| /* Shouldn't use resampling for performance reason too. */ | | /* Previously, resampling is disabled due to performance reason and | |
| #define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_NONE | | * this condition prevented some 'light' wideband codecs (e.g: G722.1) | |
| | | * to work along with narrowband codecs. Lately, some tests showed | |
| | | * that 16kHz <-> 8kHz resampling using libresample small filter was | |
| | | * affordable on ARM9 222 MHz, so here we decided to enable resampling. | |
| | | * Note that it is important to make sure that libresample is created | |
| | | * using small filter. For example PJSUA_DEFAULT_CODEC_QUALITY must | |
| | | * be set to 3 or 4 so pjsua-lib will apply small filter resampling. | |
| | | */ | |
| | | //#define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_NONE | |
| | | #define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_LIBRESAMPLE | |
| | | | |
| /* Use the lighter WSOLA implementation */ | | /* Use the lighter WSOLA implementation */ | |
| #define PJMEDIA_WSOLA_IMP PJMEDIA_WSOLA_IMP_WSOLA_LITE | | #define PJMEDIA_WSOLA_IMP PJMEDIA_WSOLA_IMP_WSOLA_LITE | |
| | | | |
| /* We probably need more buffers especially if MDA audio backend | | /* We probably need more buffers especially if MDA audio backend | |
| * is used, so increase the limit | | * is used, so increase the limit | |
| */ | | */ | |
| #define PJMEDIA_SOUND_BUFFER_COUNT 32 | | #define PJMEDIA_SOUND_BUFFER_COUNT 32 | |
| | | | |
| /* | | /* | |
| | | | |
| skipping to change at line 172 | | skipping to change at line 192 | |
| #define PJSIP_POOL_INC_UA 1000 | | #define PJSIP_POOL_INC_UA 1000 | |
| #define PJSIP_POOL_TSX_LAYER_LEN 256 | | #define PJSIP_POOL_TSX_LAYER_LEN 256 | |
| #define PJSIP_POOL_TSX_LAYER_INC 256 | | #define PJSIP_POOL_TSX_LAYER_INC 256 | |
| #define PJSIP_POOL_TSX_LEN 512 | | #define PJSIP_POOL_TSX_LEN 512 | |
| #define PJSIP_POOL_TSX_INC 128 | | #define PJSIP_POOL_TSX_INC 128 | |
| | | | |
| /* | | /* | |
| * PJSUA settings. | | * PJSUA settings. | |
| */ | | */ | |
| | | | |
|
| /* Default codec quality */ | | /* Default codec quality, previously was set to 5, however it is now | |
| #define PJSUA_DEFAULT_CODEC_QUALITY 5 | | * set to 4 to make sure pjsua instantiates resampler with small filter | |
| | | . | |
| | | */ | |
| | | #define PJSUA_DEFAULT_CODEC_QUALITY 4 | |
| | | | |
| /* Set maximum number of dialog/transaction/calls to minimum */ | | /* Set maximum number of dialog/transaction/calls to minimum */ | |
| #define PJSIP_MAX_TSX_COUNT 31 | | #define PJSIP_MAX_TSX_COUNT 31 | |
| #define PJSIP_MAX_DIALOG_COUNT 31 | | #define PJSIP_MAX_DIALOG_COUNT 31 | |
| #define PJSUA_MAX_CALLS 4 | | #define PJSUA_MAX_CALLS 4 | |
| | | | |
| /* Other pjsua settings */ | | /* Other pjsua settings */ | |
| #define PJSUA_MAX_ACC 4 | | #define PJSUA_MAX_ACC 4 | |
| #define PJSUA_MAX_PLAYERS 4 | | #define PJSUA_MAX_PLAYERS 4 | |
| #define PJSUA_MAX_RECORDERS 4 | | #define PJSUA_MAX_RECORDERS 4 | |
| | | | |
End of changes. 4 change blocks. |
| 8 lines changed or deleted | | 32 lines changed or added | |
|
| ice_session.h | | ice_session.h | |
|
| /* $Id: ice_session.h 2394 2008-12-23 17:27:53Z bennylp $ */ | | /* $Id: ice_session.h 2642 2009-04-22 17:20:24Z bennylp $ */ | |
| /* | | /* | |
| * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) | | * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) | |
| * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> | | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> | |
| * | | * | |
| * This program is free software; you can redistribute it and/or modify | | * This program is free software; you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | | * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation; either version 2 of the License, or | | * the Free Software Foundation; either version 2 of the License, or | |
| * (at your option) any later version. | | * (at your option) any later version. | |
| * | | * | |
| * This program is distributed in the hope that it will be useful, | | * This program is distributed in the hope that it will be useful, | |
| | | | |
| skipping to change at line 33 | | skipping to change at line 33 | |
| /** | | /** | |
| * @file ice_session.h | | * @file ice_session.h | |
| * @brief ICE session management | | * @brief ICE session management | |
| */ | | */ | |
| #include <pjnath/types.h> | | #include <pjnath/types.h> | |
| #include <pjnath/stun_session.h> | | #include <pjnath/stun_session.h> | |
| #include <pjnath/errno.h> | | #include <pjnath/errno.h> | |
| #include <pj/sock.h> | | #include <pj/sock.h> | |
| #include <pj/timer.h> | | #include <pj/timer.h> | |
| | | | |
|
| /** | | | |
| * @defgroup PJNATH_ICE Interactive Connectivity Establishment (ICE) | | | |
| * @brief Interactive Connectivity Establishment (ICE) | | | |
| */ | | | |
| | | | |
| PJ_BEGIN_DECL | | PJ_BEGIN_DECL | |
| | | | |
| /** | | /** | |
|
| * @defgroup PJNATH_ICE_SESSION ICE Session | | * @addtogroup PJNATH_ICE_SESSION | |
| * @brief Transport Independent ICE Session | | | |
| * @ingroup PJNATH_ICE | | | |
| * @{ | | * @{ | |
| * | | * | |
| * This module describes #pj_ice_sess, a transport independent ICE session, | | * This module describes #pj_ice_sess, a transport independent ICE session, | |
| * part of PJNATH - the Open Source NAT helper library. | | * part of PJNATH - the Open Source NAT helper library. | |
| * | | * | |
| * \section pj_ice_sess_sec ICE Session | | * \section pj_ice_sess_sec ICE Session | |
| * | | * | |
| * An ICE session, represented by #pj_ice_sess structure, is the lowest | | * An ICE session, represented by #pj_ice_sess structure, is the lowest | |
| * abstraction of ICE in PJNATH, and it is used to perform and manage | | * abstraction of ICE in PJNATH, and it is used to perform and manage | |
| * connectivity checks of transport address candidates <b>within a | | * connectivity checks of transport address candidates <b>within a | |
| | | | |
| skipping to change at line 202 | | skipping to change at line 195 | |
| */ | | */ | |
| pj_stun_session *stun_sess; | | pj_stun_session *stun_sess; | |
| | | | |
| } pj_ice_sess_comp; | | } pj_ice_sess_comp; | |
| | | | |
| /** | | /** | |
| * Data structure to be attached to internal message processing. | | * Data structure to be attached to internal message processing. | |
| */ | | */ | |
| typedef struct pj_ice_msg_data | | typedef struct pj_ice_msg_data | |
| { | | { | |
|
| | | /** Transport ID for this message */ | |
| unsigned transport_id; | | unsigned transport_id; | |
|
| | | | |
| | | /** Flag to indicate whether data.req contains data */ | |
| pj_bool_t has_req_data; | | pj_bool_t has_req_data; | |
| | | | |
|
| | | /** The data */ | |
| union data { | | union data { | |
|
| | | /** Request data */ | |
| struct request_data { | | struct request_data { | |
|
| pj_ice_sess *ice; | | pj_ice_sess *ice; /**< ICE session */ | |
| pj_ice_sess_checklist *clist; | | pj_ice_sess_checklist *clist; /**< Checklist */ | |
| unsigned ckid; | | unsigned ckid; /**< Check ID */ | |
| } req; | | } req; | |
| } data; | | } data; | |
|
| | | | |
| } pj_ice_msg_data; | | } pj_ice_msg_data; | |
| | | | |
| /** | | /** | |
| * This structure describes an ICE candidate. | | * This structure describes an ICE candidate. | |
| * ICE candidate is a transport address that is to be tested by ICE | | * ICE candidate is a transport address that is to be tested by ICE | |
| * procedures in order to determine its suitability for usage for | | * procedures in order to determine its suitability for usage for | |
| * receipt of media. Candidates also have properties - their type | | * receipt of media. Candidates also have properties - their type | |
| * (server reflexive, relayed or host), priority, foundation, and | | * (server reflexive, relayed or host), priority, foundation, and | |
| * base. | | * base. | |
| */ | | */ | |
| | | | |
| skipping to change at line 529 | | skipping to change at line 528 | |
| * This structure represents an incoming check (an incoming Binding | | * This structure represents an incoming check (an incoming Binding | |
| * request message), and is mainly used to keep early checks in the | | * request message), and is mainly used to keep early checks in the | |
| * list in the ICE session. An early check is a request received | | * list in the ICE session. An early check is a request received | |
| * from remote when we haven't received SDP answer yet, therefore we | | * from remote when we haven't received SDP answer yet, therefore we | |
| * can't perform triggered check. For such cases, keep the incoming | | * can't perform triggered check. For such cases, keep the incoming | |
| * request in a list, and we'll do triggered checks (simultaneously) | | * request in a list, and we'll do triggered checks (simultaneously) | |
| * as soon as we receive answer. | | * as soon as we receive answer. | |
| */ | | */ | |
| typedef struct pj_ice_rx_check | | typedef struct pj_ice_rx_check | |
| { | | { | |
|
| PJ_DECL_LIST_MEMBER(struct pj_ice_rx_check); | | PJ_DECL_LIST_MEMBER(struct pj_ice_rx_check); /**< Standard list */ | |
| | | | |
| unsigned comp_id; /**< Component ID. */ | | unsigned comp_id; /**< Component ID. */ | |
| unsigned transport_id; /**< Transport ID. */ | | unsigned transport_id; /**< Transport ID. */ | |
| | | | |
| pj_sockaddr src_addr; /**< Source address of reque
st */ | | pj_sockaddr src_addr; /**< Source address of reque
st */ | |
| unsigned src_addr_len; /**< Length of src address. */ | | unsigned src_addr_len; /**< Length of src address. */ | |
| | | | |
| pj_bool_t use_candidate; /**< USE-CANDIDATE is present? */ | | pj_bool_t use_candidate; /**< USE-CANDIDATE is present? */ | |
| pj_uint32_t priority; /**< PRIORITY value in the r
eq. */ | | pj_uint32_t priority; /**< PRIORITY value in the r
eq. */ | |
| pj_stun_uint64_attr *role_attr; /**< ICE-CONTROLLING/CONTROLLED */ | | pj_stun_uint64_attr *role_attr; /**< ICE-CONTROLLING/CONTROLLED */ | |
| | | | |
| skipping to change at line 589 | | skipping to change at line 588 | |
| pj_ice_sess_comp comp[PJ_ICE_MAX_COMP]; /**< Component array
*/ | | pj_ice_sess_comp comp[PJ_ICE_MAX_COMP]; /**< Component array
*/ | |
| | | | |
| /* Local candidates */ | | /* Local candidates */ | |
| unsigned lcand_cnt; /**< # of local cand.
*/ | | unsigned lcand_cnt; /**< # of local cand.
*/ | |
| pj_ice_sess_cand lcand[PJ_ICE_MAX_CAND]; /**< Array of cand.
*/ | | pj_ice_sess_cand lcand[PJ_ICE_MAX_CAND]; /**< Array of cand.
*/ | |
| | | | |
| /* Remote candidates */ | | /* Remote candidates */ | |
| unsigned rcand_cnt; /**< # of remote cand.
*/ | | unsigned rcand_cnt; /**< # of remote cand.
*/ | |
| pj_ice_sess_cand rcand[PJ_ICE_MAX_CAND]; /**< Array of cand.
*/ | | pj_ice_sess_cand rcand[PJ_ICE_MAX_CAND]; /**< Array of cand.
*/ | |
| | | | |
|
| /* Array of transport datas */ | | /** Array of transport datas */ | |
| pj_ice_msg_data tp_data[4]; | | pj_ice_msg_data tp_data[4]; | |
| | | | |
| /* List of eearly checks */ | | /* List of eearly checks */ | |
| pj_ice_rx_check early_check; /**< Early checks.
*/ | | pj_ice_rx_check early_check; /**< Early checks.
*/ | |
| | | | |
| /* Checklist */ | | /* Checklist */ | |
| pj_ice_sess_checklist clist; /**< Active checklist
*/ | | pj_ice_sess_checklist clist; /**< Active checklist
*/ | |
| | | | |
| /* Valid list */ | | /* Valid list */ | |
| pj_ice_sess_checklist valid_list; /**< Valid list.
*/ | | pj_ice_sess_checklist valid_list; /**< Valid list.
*/ | |
| | | | |
|
| /* Temporary buffer for misc stuffs to avoid using stack too much */ | | /** Temporary buffer for misc stuffs to avoid using stack too much */ | |
| union { | | union { | |
| char txt[128]; | | char txt[128]; | |
| char errmsg[PJ_ERR_MSG_SIZE]; | | char errmsg[PJ_ERR_MSG_SIZE]; | |
| } tmp; | | } tmp; | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * This is a utility function to retrieve the string name for the | | * This is a utility function to retrieve the string name for the | |
| * particular candidate type. | | * particular candidate type. | |
| * | | * | |
| | | | |
End of changes. 12 change blocks. |
| 15 lines changed or deleted | | 14 lines changed or added | |
|
| ice_strans.h | | ice_strans.h | |
|
| /* $Id: ice_strans.h 2394 2008-12-23 17:27:53Z bennylp $ */ | | /* $Id: ice_strans.h 2642 2009-04-22 17:20:24Z bennylp $ */ | |
| /* | | /* | |
| * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) | | * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) | |
| * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> | | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> | |
| * | | * | |
| * This program is free software; you can redistribute it and/or modify | | * This program is free software; you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | | * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation; either version 2 of the License, or | | * the Free Software Foundation; either version 2 of the License, or | |
| * (at your option) any later version. | | * (at your option) any later version. | |
| * | | * | |
| * This program is distributed in the hope that it will be useful, | | * This program is distributed in the hope that it will be useful, | |
| | | | |
| skipping to change at line 37 | | skipping to change at line 37 | |
| #include <pjnath/ice_session.h> | | #include <pjnath/ice_session.h> | |
| #include <pjnath/stun_sock.h> | | #include <pjnath/stun_sock.h> | |
| #include <pjnath/turn_sock.h> | | #include <pjnath/turn_sock.h> | |
| #include <pjlib-util/resolver.h> | | #include <pjlib-util/resolver.h> | |
| #include <pj/ioqueue.h> | | #include <pj/ioqueue.h> | |
| #include <pj/timer.h> | | #include <pj/timer.h> | |
| | | | |
| PJ_BEGIN_DECL | | PJ_BEGIN_DECL | |
| | | | |
| /** | | /** | |
|
| * @defgroup PJNATH_ICE_STREAM_TRANSPORT ICE Stream Transport | | * @addtogroup PJNATH_ICE_STREAM_TRANSPORT | |
| * @brief Transport for media streams using ICE | | | |
| * @ingroup PJNATH_ICE | | | |
| * @{ | | * @{ | |
| * | | * | |
| * This module describes ICE stream transport, as represented by #pj_ice_st
rans | | * This module describes ICE stream transport, as represented by #pj_ice_st
rans | |
| * structure, and is part of PJNATH - the Open Source NAT traversal helper | | * structure, and is part of PJNATH - the Open Source NAT traversal helper | |
| * library. | | * library. | |
| * | | * | |
| * ICE stream transport, as represented by #pj_ice_strans structure, is an
ICE | | * ICE stream transport, as represented by #pj_ice_strans structure, is an
ICE | |
| * capable class for transporting media streams within a media session. | | * capable class for transporting media streams within a media session. | |
| * It consists of one or more transport sockets (typically two for RTP | | * It consists of one or more transport sockets (typically two for RTP | |
| * based communication - one for RTP and one for RTCP), and an | | * based communication - one for RTP and one for RTCP), and an | |
| * \ref PJNATH_ICE_SESSION for performing connectivity checks among the. | | * \ref PJNATH_ICE_SESSION for performing connectivity checks among the. | |
| * various candidates of the transport addresses. | | * various candidates of the transport addresses. | |
| * | | * | |
|
| | | * | |
| | | * \section ice_strans_using_sec Using the ICE stream transport | |
| | | * | |
| | | * The steps below describe how to use ICE session: | |
| | | * | |
| | | * - initialize a #pj_ice_strans_cfg structure. This contains various | |
| | | * settings for the ICE stream transport, and among other things contain | |
| | | s | |
| | | * the STUN and TURN settings.\n\n | |
| | | * - create the instance with #pj_ice_strans_create(). Among other things, | |
| | | * the function needs the following arguments: | |
| | | * - the #pj_ice_strans_cfg structure for the main configurations | |
| | | * - number of components to be supported | |
| | | * - instance of #pj_ice_strans_cb structure to report callbacks to | |
| | | * application.\n\n | |
| | | * - while the #pj_ice_strans_create() call completes immediately, the | |
| | | * initialization will be running in the background to gather the | |
| | | * candidates (for example STUN and TURN candidates, if they are enabled | |
| | | * in the #pj_ice_strans_cfg setting). Application will be notified when | |
| | | * the initialization completes in the \a on_ice_complete callback of | |
| | | * the #pj_ice_strans_cb structure (the \a op argument of this callback | |
| | | * will be PJ_ICE_STRANS_OP_INIT).\n\n | |
| | | * - when media stream is to be started (for example, a call is to be | |
| | | * started), create an ICE session by calling #pj_ice_strans_init_ice(). | |
| | | \n\n | |
| | | * - the application now typically will need to communicate local ICE | |
| | | * information to remote host. It can achieve this by using the followin | |
| | | g | |
| | | * functions to query local ICE information: | |
| | | * - #pj_ice_strans_get_ufrag_pwd() | |
| | | * - #pj_ice_strans_enum_cands() | |
| | | * - #pj_ice_strans_get_def_cand()\n | |
| | | * The application may need to encode the above information as SDP.\n\n | |
| | | * - when the application receives remote ICE information (for example, fr | |
| | | om | |
| | | * the SDP received from remote), it can now start ICE negotiation, by | |
| | | * calling #pj_ice_strans_start_ice(). This function requires some | |
| | | * information about remote ICE agent such as remote ICE username fragme | |
| | | nt | |
| | | * and password as well as array of remote candidates.\n\n | |
| | | * - note that the PJNATH library does not work with SDP; application woul | |
| | | d | |
| | | * need to encode and parse the SDP itself.\n\n | |
| | | * - once ICE negotiation has been started, application will be notified | |
| | | * about the completion in the \a on_ice_complete() callback of the | |
| | | * #pj_ice_strans_cb.\n\n | |
| | | * - at any time, application may send or receive data. However the ICE | |
| | | * stream transport may not be able to send it depending on its current | |
| | | * state. Before ICE negotiation is started, the data will be sent using | |
| | | * default candidate of the component. After negotiation is completed, | |
| | | * data will be sent using the candidate from the successful/nominated | |
| | | * pair. The ICE stream transport may not be able to send data while | |
| | | * negotiation is in progress.\n\n | |
| | | * - application sends data by using #pj_ice_strans_sendto(). Incoming | |
| | | * data will be reported in \a on_rx_data() callback of the | |
| | | * #pj_ice_strans_cb.\n\n | |
| | | * - once the media session has finished (e.g. user hangs up the call), | |
| | | * destroy the ICE session with #pj_ice_strans_stop_ice().\n\n | |
| | | * - at this point, application may destroy the ICE stream transport itsel | |
| | | f, | |
| | | * or let it run so that it can be reused to create other ICE session. | |
| | | * The benefit of letting the ICE stream transport alive (without any | |
| | | * session active) is to avoid delay with the initialization, howerver | |
| | | * keeping the transport alive means the transport needs to keep the | |
| | | * STUN binding open by using keep-alive and also TURN allocation alive, | |
| | | * and this will consume power which is an important issue for mobile | |
| | | * applications.\n\n | |
| */ | | */ | |
| | | | |
| /** Forward declaration for ICE stream transport. */ | | /** Forward declaration for ICE stream transport. */ | |
| typedef struct pj_ice_strans pj_ice_strans; | | typedef struct pj_ice_strans pj_ice_strans; | |
| | | | |
| /** Transport operation types to be reported on \a on_status() callback */ | | /** Transport operation types to be reported on \a on_status() callback */ | |
| typedef enum pj_ice_strans_op | | typedef enum pj_ice_strans_op | |
| { | | { | |
| /** Initialization (candidate gathering) */ | | /** Initialization (candidate gathering) */ | |
| PJ_ICE_STRANS_OP_INIT, | | PJ_ICE_STRANS_OP_INIT, | |
| | | | |
End of changes. 3 change blocks. |
| 4 lines changed or deleted | | 69 lines changed or added | |
|
| publish.h | | publish.h | |
|
| /* $Id: publish.h 2394 2008-12-23 17:27:53Z bennylp $ */ | | /* $Id: publish.h 2661 2009-04-28 22:19:49Z bennylp $ */ | |
| /* | | /* | |
| * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) | | * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) | |
| * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> | | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> | |
| * | | * | |
| * This program is free software; you can redistribute it and/or modify | | * This program is free software; you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | | * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation; either version 2 of the License, or | | * the Free Software Foundation; either version 2 of the License, or | |
| * (at your option) any later version. | | * (at your option) any later version. | |
| * | | * | |
| * This program is distributed in the hope that it will be useful, | | * This program is distributed in the hope that it will be useful, | |
| | | | |
| skipping to change at line 75 | | skipping to change at line 75 | |
| * has finished. | | * has finished. | |
| */ | | */ | |
| struct pjsip_publishc_cbparam | | struct pjsip_publishc_cbparam | |
| { | | { | |
| pjsip_publishc *pubc; /**< Client publication structure.
*/ | | pjsip_publishc *pubc; /**< Client publication structure.
*/ | |
| void *token; /**< Arbitrary token.
*/ | | void *token; /**< Arbitrary token.
*/ | |
| pj_status_t status; /**< Error status.
*/ | | pj_status_t status; /**< Error status.
*/ | |
| int code; /**< SIP status code received.
*/ | | int code; /**< SIP status code received.
*/ | |
| pj_str_t reason; /**< SIP reason phrase received.
*/ | | pj_str_t reason; /**< SIP reason phrase received.
*/ | |
| pjsip_rx_data *rdata; /**< The complete received response.
*/ | | pjsip_rx_data *rdata; /**< The complete received response.
*/ | |
|
| int expiration;/**< Next expiration interval. | | int expiration;/**< Next expiration interval. I | |
| */ | | f the | |
| | | value is -1, it means the session | |
| | | will not renew itself. | |
| | | */ | |
| }; | | }; | |
| | | | |
| /** Type declaration for callback to receive publication result. */ | | /** Type declaration for callback to receive publication result. */ | |
| typedef void pjsip_publishc_cb(struct pjsip_publishc_cbparam *param); | | typedef void pjsip_publishc_cb(struct pjsip_publishc_cbparam *param); | |
| | | | |
| /** | | /** | |
| * Initialize client publication module. | | * Initialize client publication module. | |
| * | | * | |
| * @param endpt SIP endpoint. | | * @param endpt SIP endpoint. | |
| * | | * | |
| | | | |
| skipping to change at line 177 | | skipping to change at line 179 | |
| * | | * | |
| * @param pubc The client publication structure. | | * @param pubc The client publication structure. | |
| * @param rs List containing Route headers. | | * @param rs List containing Route headers. | |
| * | | * | |
| * @return PJ_SUCCESS on success. | | * @return PJ_SUCCESS on success. | |
| */ | | */ | |
| PJ_DECL(pj_status_t) pjsip_publishc_set_route_set(pjsip_publishc *pubc, | | PJ_DECL(pj_status_t) pjsip_publishc_set_route_set(pjsip_publishc *pubc, | |
| const pjsip_route_hdr *rs)
; | | const pjsip_route_hdr *rs)
; | |
| | | | |
| /** | | /** | |
|
| | | * Set list of headers to be added to each PUBLISH request generated by | |
| | | * the client publication session. Note that application can also add | |
| | | * the headers to the request after calling #pjsip_publishc_publish() | |
| | | * or #pjsip_publishc_unpublish(), but the benefit of this function is | |
| | | * the headers will also be added to requests generated internally by | |
| | | * the session, such as during session renewal/refresh. | |
| | | * | |
| | | * Note that calling this function will clear the previously added list | |
| | | * of headers. | |
| | | * | |
| | | * @param pubc The client publication structure. | |
| | | * @param hdr_list The list of headers. | |
| | | * | |
| | | * @return PJ_SUCCESS on success. | |
| | | */ | |
| | | PJ_DECL(pj_status_t) pjsip_publishc_set_headers(pjsip_publishc *pubc, | |
| | | const pjsip_hdr *hdr_list); | |
| | | | |
| | | /** | |
| * Create PUBLISH request for the specified client publication structure. | | * Create PUBLISH request for the specified client publication structure. | |
| * Application can use this function to both create initial publication | | * Application can use this function to both create initial publication | |
| * or to modify existing publication. | | * or to modify existing publication. | |
| * | | * | |
| * After the PUBLISH request is created, application MUST fill in the | | * After the PUBLISH request is created, application MUST fill in the | |
| * body part of the request with the appropriate content for the Event | | * body part of the request with the appropriate content for the Event | |
| * being published. | | * being published. | |
| * | | * | |
| * Note that publication refresh are handled automatically by the session | | * Note that publication refresh are handled automatically by the session | |
| * (as long as auto_refresh argument below is non-zero), and application | | * (as long as auto_refresh argument below is non-zero), and application | |
| | | | |
End of changes. 3 change blocks. |
| 3 lines changed or deleted | | 25 lines changed or added | |
|
| sip_inv.h | | sip_inv.h | |
|
| /* $Id: sip_inv.h 2394 2008-12-23 17:27:53Z bennylp $ */ | | /* $Id: sip_inv.h 2647 2009-04-26 11:30:22Z bennylp $ */ | |
| /* | | /* | |
| * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) | | * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) | |
| * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> | | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> | |
| * | | * | |
| * This program is free software; you can redistribute it and/or modify | | * This program is free software; you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | | * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation; either version 2 of the License, or | | * the Free Software Foundation; either version 2 of the License, or | |
| * (at your option) any later version. | | * (at your option) any later version. | |
| * | | * | |
| * This program is distributed in the hope that it will be useful, | | * This program is distributed in the hope that it will be useful, | |
| | | | |
| skipping to change at line 638 | | skipping to change at line 638 | |
| * | | * | |
| * @return PJ_SUCCESS if local answer can be accepted by | | * @return PJ_SUCCESS if local answer can be accepted by | |
| * SDP negotiator. | | * SDP negotiator. | |
| */ | | */ | |
| PJ_DECL(pj_status_t) pjsip_inv_set_sdp_answer(pjsip_inv_session *inv, | | PJ_DECL(pj_status_t) pjsip_inv_set_sdp_answer(pjsip_inv_session *inv, | |
| const pjmedia_sdp_session *sdp
); | | const pjmedia_sdp_session *sdp
); | |
| | | | |
| /** | | /** | |
| * Create a SIP message to initiate invite session termination. Depending o
n | | * Create a SIP message to initiate invite session termination. Depending o
n | |
| * the state of the session, this function may return CANCEL request, | | * the state of the session, this function may return CANCEL request, | |
|
| * a non-2xx final response, or a BYE request. If the session has not answe | | * a non-2xx final response, a BYE request, or even no request. | |
| red | | * | |
| * the incoming INVITE, this function creates the non-2xx final response wi | | * For UAS, if the session has not answered the incoming INVITE, this funct | |
| th | | ion | |
| * the specified status code in st_code and optional status text in st_text | | * creates the non-2xx final response with the specified status code in | |
| . | | * \a st_code and optional status text in \a st_text. | |
| | | * | |
| | | * For UAC, if the original INVITE has not been answered with a final | |
| | | * response, the behavior depends on whether provisional response has been | |
| | | * received. If provisional response has been received, this function will | |
| | | * create CANCEL request. If no provisional response has been received, the | |
| | | * function will not create CANCEL request (the function will return | |
| | | * PJ_SUCCESS but the \a p_tdata will contain NULL) because we cannot send | |
| | | * CANCEL before receiving provisional response. If then a provisional | |
| | | * response is received, the invite session will send CANCEL automatically. | |
| | | * | |
| | | * For both UAC and UAS, if the INVITE session has been answered with final | |
| | | * response, a BYE request will be created. | |
| * | | * | |
| * @param inv The invite session. | | * @param inv The invite session. | |
| * @param st_code Status code to be used for terminating the session. | | * @param st_code Status code to be used for terminating the session. | |
| * @param st_text Optional status text. | | * @param st_text Optional status text. | |
|
| * @param p_tdata Pointer to receive the message to be created. | | * @param p_tdata Pointer to receive the message to be created. Note | |
| | | * that it's possible to receive NULL here while the | |
| | | * function returns PJ_SUCCESS, see the description. | |
| * | | * | |
|
| * @return PJ_SUCCESS if termination message can be created. | | * @return PJ_SUCCESS if termination is initiated. | |
| */ | | */ | |
| PJ_DECL(pj_status_t) pjsip_inv_end_session( pjsip_inv_session *inv, | | PJ_DECL(pj_status_t) pjsip_inv_end_session( pjsip_inv_session *inv, | |
| int st_code, | | int st_code, | |
| const pj_str_t *st_text, | | const pj_str_t *st_text, | |
| pjsip_tx_data **p_tdata ); | | pjsip_tx_data **p_tdata ); | |
| | | | |
| /** | | /** | |
| * Create a re-INVITE request. | | * Create a re-INVITE request. | |
| * | | * | |
| * @param inv The invite session. | | * @param inv The invite session. | |
| | | | |
End of changes. 4 change blocks. |
| 9 lines changed or deleted | | 23 lines changed or added | |
|
| stun_msg.h | | stun_msg.h | |
|
| /* $Id: stun_msg.h 2394 2008-12-23 17:27:53Z bennylp $ */ | | /* $Id: stun_msg.h 2642 2009-04-22 17:20:24Z bennylp $ */ | |
| /* | | /* | |
| * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) | | * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) | |
| * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> | | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> | |
| * | | * | |
| * This program is free software; you can redistribute it and/or modify | | * This program is free software; you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | | * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation; either version 2 of the License, or | | * the Free Software Foundation; either version 2 of the License, or | |
| * (at your option) any later version. | | * (at your option) any later version. | |
| * | | * | |
| * This program is distributed in the hope that it will be useful, | | * This program is distributed in the hope that it will be useful, | |
| | | | |
| skipping to change at line 36 | | skipping to change at line 36 | |
| */ | | */ | |
| | | | |
| #include <pjnath/types.h> | | #include <pjnath/types.h> | |
| #include <pj/sock.h> | | #include <pj/sock.h> | |
| | | | |
| PJ_BEGIN_DECL | | PJ_BEGIN_DECL | |
| | | | |
| /* ************************************************************************
**/ | | /* ************************************************************************
**/ | |
| /** | | /** | |
| * @defgroup PJNATH_STUN_MSG STUN Message Representation and Parsing | | * @defgroup PJNATH_STUN_MSG STUN Message Representation and Parsing | |
|
| * @ingroup PJNATH_STUN | | * @ingroup PJNATH_STUN_BASE | |
| * @brief Low-level representation and parsing of STUN messages. | | * @brief Low-level representation and parsing of STUN messages. | |
| * @{ | | * @{ | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * STUN magic cookie. | | * STUN magic cookie. | |
| */ | | */ | |
| #define PJ_STUN_MAGIC 0x2112A442 | | #define PJ_STUN_MAGIC 0x2112A442 | |
| | | | |
| /** | | /** | |
| | | | |
| skipping to change at line 82 | | skipping to change at line 82 | |
| * STUN/TURN Send indication as defined by draft-ietf-behave-turn | | * STUN/TURN Send indication as defined by draft-ietf-behave-turn | |
| */ | | */ | |
| PJ_STUN_SEND_METHOD = 6, | | PJ_STUN_SEND_METHOD = 6, | |
| | | | |
| /** | | /** | |
| * STUN/TURN Data indication as defined by draft-ietf-behave-turn | | * STUN/TURN Data indication as defined by draft-ietf-behave-turn | |
| */ | | */ | |
| PJ_STUN_DATA_METHOD = 7, | | PJ_STUN_DATA_METHOD = 7, | |
| | | | |
| /** | | /** | |
|
| | | * STUN/TURN CreatePermission method as defined by draft-ietf-behave-tu | |
| | | rn | |
| | | */ | |
| | | PJ_STUN_CREATE_PERM_METHOD = 8, | |
| | | | |
| | | /** | |
| * STUN/TURN ChannelBind as defined by draft-ietf-behave-turn | | * STUN/TURN ChannelBind as defined by draft-ietf-behave-turn | |
| */ | | */ | |
| PJ_STUN_CHANNEL_BIND_METHOD = 9, | | PJ_STUN_CHANNEL_BIND_METHOD = 9, | |
| | | | |
| /** | | /** | |
| * All known methods. | | * All known methods. | |
| */ | | */ | |
| PJ_STUN_METHOD_MAX | | PJ_STUN_METHOD_MAX | |
| }; | | }; | |
| | | | |
| | | | |
| skipping to change at line 240 | | skipping to change at line 245 | |
| * TURN Send indication | | * TURN Send indication | |
| */ | | */ | |
| PJ_STUN_SEND_INDICATION = 0x0016, | | PJ_STUN_SEND_INDICATION = 0x0016, | |
| | | | |
| /** | | /** | |
| * TURN Data indication | | * TURN Data indication | |
| */ | | */ | |
| PJ_STUN_DATA_INDICATION = 0x0017, | | PJ_STUN_DATA_INDICATION = 0x0017, | |
| | | | |
| /** | | /** | |
|
| | | * TURN CreatePermission request | |
| | | */ | |
| | | PJ_STUN_CREATE_PERM_REQUEST = 0x0008, | |
| | | | |
| | | /** | |
| | | * TURN CreatePermission successful response. | |
| | | */ | |
| | | PJ_STUN_CREATE_PERM_RESPONSE = 0x0108, | |
| | | | |
| | | /** | |
| | | * TURN CreatePermission failure response | |
| | | */ | |
| | | PJ_STUN_CREATE_PERM_ERROR_RESPONSE = 0x0118, | |
| | | | |
| | | /** | |
| * STUN/TURN ChannelBind Request | | * STUN/TURN ChannelBind Request | |
| */ | | */ | |
| PJ_STUN_CHANNEL_BIND_REQUEST = 0x0009, | | PJ_STUN_CHANNEL_BIND_REQUEST = 0x0009, | |
| | | | |
| /** | | /** | |
| * Successful response to STUN ChannelBind request | | * Successful response to STUN ChannelBind request | |
| */ | | */ | |
| PJ_STUN_CHANNEL_BIND_RESPONSE = 0x0109, | | PJ_STUN_CHANNEL_BIND_RESPONSE = 0x0109, | |
| | | | |
| /** | | /** | |
| | | | |
| skipping to change at line 276 | | skipping to change at line 296 | |
| PJ_STUN_ATTR_USERNAME = 0x0006,/**< USERNAME attribute.
*/ | | PJ_STUN_ATTR_USERNAME = 0x0006,/**< USERNAME attribute.
*/ | |
| PJ_STUN_ATTR_PASSWORD = 0x0007,/**< was PASSWORD attribute.
*/ | | PJ_STUN_ATTR_PASSWORD = 0x0007,/**< was PASSWORD attribute.
*/ | |
| PJ_STUN_ATTR_MESSAGE_INTEGRITY = 0x0008,/**< MESSAGE-INTEGRITY.
*/ | | PJ_STUN_ATTR_MESSAGE_INTEGRITY = 0x0008,/**< MESSAGE-INTEGRITY.
*/ | |
| PJ_STUN_ATTR_ERROR_CODE = 0x0009,/**< ERROR-CODE.
*/ | | PJ_STUN_ATTR_ERROR_CODE = 0x0009,/**< ERROR-CODE.
*/ | |
| PJ_STUN_ATTR_UNKNOWN_ATTRIBUTES = 0x000A,/**< UNKNOWN-ATTRIBUTES.
*/ | | PJ_STUN_ATTR_UNKNOWN_ATTRIBUTES = 0x000A,/**< UNKNOWN-ATTRIBUTES.
*/ | |
| PJ_STUN_ATTR_REFLECTED_FROM = 0x000B,/**< REFLECTED-FROM (de
precatd)*/ | | PJ_STUN_ATTR_REFLECTED_FROM = 0x000B,/**< REFLECTED-FROM (de
precatd)*/ | |
| PJ_STUN_ATTR_CHANNEL_NUMBER = 0x000C,/**< TURN CHANNEL-NUMBE
R */ | | PJ_STUN_ATTR_CHANNEL_NUMBER = 0x000C,/**< TURN CHANNEL-NUMBE
R */ | |
| PJ_STUN_ATTR_LIFETIME = 0x000D,/**< TURN LIFETIME attr.
*/ | | PJ_STUN_ATTR_LIFETIME = 0x000D,/**< TURN LIFETIME attr.
*/ | |
| PJ_STUN_ATTR_MAGIC_COOKIE = 0x000F,/**< MAGIC-COOKIE attr (deprec)
*/ | | PJ_STUN_ATTR_MAGIC_COOKIE = 0x000F,/**< MAGIC-COOKIE attr (deprec)
*/ | |
| PJ_STUN_ATTR_BANDWIDTH = 0x0010,/**< TURN BANDWIDTH (deprec)
*/ | | PJ_STUN_ATTR_BANDWIDTH = 0x0010,/**< TURN BANDWIDTH (deprec)
*/ | |
|
| PJ_STUN_ATTR_PEER_ADDR = 0x0012,/**< TURN PEER-ADDRESS attr.
*/ | | PJ_STUN_ATTR_XOR_PEER_ADDR = 0x0012,/**< TURN XOR-PEER-ADDRESS
*/ | |
| PJ_STUN_ATTR_DATA = 0x0013,/**< DATA attribute.
*/ | | PJ_STUN_ATTR_DATA = 0x0013,/**< DATA attribute.
*/ | |
| PJ_STUN_ATTR_REALM = 0x0014,/**< REALM attribute.
*/ | | PJ_STUN_ATTR_REALM = 0x0014,/**< REALM attribute.
*/ | |
| PJ_STUN_ATTR_NONCE = 0x0015,/**< NONCE attribute.
*/ | | PJ_STUN_ATTR_NONCE = 0x0015,/**< NONCE attribute.
*/ | |
|
| PJ_STUN_ATTR_RELAYED_ADDR = 0x0016,/**< RELAYED-ADDRESS attribute.
*/ | | PJ_STUN_ATTR_XOR_RELAYED_ADDR = 0x0016,/**< TURN XOR-RELAYED-ADDRESS
*/ | |
| PJ_STUN_ATTR_REQ_ADDR_TYPE = 0x0017,/**< REQUESTED-ADDRESS-TYPE
*/ | | PJ_STUN_ATTR_REQ_ADDR_TYPE = 0x0017,/**< REQUESTED-ADDRESS-TYPE
*/ | |
|
| PJ_STUN_ATTR_REQ_PROPS = 0x0018,/**< REQUESTED-PROPS | | PJ_STUN_ATTR_EVEN_PORT = 0x0018,/**< TURN EVEN-PORT | |
| */ | | */ | |
| PJ_STUN_ATTR_REQ_TRANSPORT = 0x0019,/**< REQUESTED-TRANSPORT | | PJ_STUN_ATTR_REQ_TRANSPORT = 0x0019,/**< TURN REQUESTED-TRANSPORT | |
| */ | | */ | |
| | | PJ_STUN_ATTR_DONT_FRAGMENT = 0x001A,/**< TURN DONT-FRAGMENT | |
| | | */ | |
| PJ_STUN_ATTR_XOR_MAPPED_ADDR = 0x0020,/**< XOR-MAPPED-ADDRESS
*/ | | PJ_STUN_ATTR_XOR_MAPPED_ADDR = 0x0020,/**< XOR-MAPPED-ADDRESS
*/ | |
| PJ_STUN_ATTR_TIMER_VAL = 0x0021,/**< TIMER-VAL attribute.
*/ | | PJ_STUN_ATTR_TIMER_VAL = 0x0021,/**< TIMER-VAL attribute.
*/ | |
| PJ_STUN_ATTR_RESERVATION_TOKEN = 0x0022,/**< TURN RESERVATION-TOKEN
*/ | | PJ_STUN_ATTR_RESERVATION_TOKEN = 0x0022,/**< TURN RESERVATION-TOKEN
*/ | |
| PJ_STUN_ATTR_XOR_REFLECTED_FROM = 0x0023,/**< XOR-REFLECTED-FROM
*/ | | PJ_STUN_ATTR_XOR_REFLECTED_FROM = 0x0023,/**< XOR-REFLECTED-FROM
*/ | |
| PJ_STUN_ATTR_PRIORITY = 0x0024,/**< PRIORITY
*/ | | PJ_STUN_ATTR_PRIORITY = 0x0024,/**< PRIORITY
*/ | |
| PJ_STUN_ATTR_USE_CANDIDATE = 0x0025,/**< USE-CANDIDATE
*/ | | PJ_STUN_ATTR_USE_CANDIDATE = 0x0025,/**< USE-CANDIDATE
*/ | |
| PJ_STUN_ATTR_ICMP = 0x0030,/**< ICMP (TURN)
*/ | | PJ_STUN_ATTR_ICMP = 0x0030,/**< ICMP (TURN)
*/ | |
| | | | |
| PJ_STUN_ATTR_END_MANDATORY_ATTR, | | PJ_STUN_ATTR_END_MANDATORY_ATTR, | |
| | | | |
| | | | |
| skipping to change at line 315 | | skipping to change at line 336 | |
| } pj_stun_attr_type; | | } pj_stun_attr_type; | |
| | | | |
| /** | | /** | |
| * STUN error codes, which goes into STUN ERROR-CODE attribute. | | * STUN error codes, which goes into STUN ERROR-CODE attribute. | |
| */ | | */ | |
| typedef enum pj_stun_status | | typedef enum pj_stun_status | |
| { | | { | |
| PJ_STUN_SC_TRY_ALTERNATE = 300, /**< Try Alternate
*/ | | PJ_STUN_SC_TRY_ALTERNATE = 300, /**< Try Alternate
*/ | |
| PJ_STUN_SC_BAD_REQUEST = 400, /**< Bad Request
*/ | | PJ_STUN_SC_BAD_REQUEST = 400, /**< Bad Request
*/ | |
| PJ_STUN_SC_UNAUTHORIZED = 401, /**< Unauthorized
*/ | | PJ_STUN_SC_UNAUTHORIZED = 401, /**< Unauthorized
*/ | |
|
| | | PJ_STUN_SC_FORBIDDEN = 403, /**< Forbidden (TURN)
*/ | |
| PJ_STUN_SC_UNKNOWN_ATTRIBUTE = 420, /**< Unknown Attribute
*/ | | PJ_STUN_SC_UNKNOWN_ATTRIBUTE = 420, /**< Unknown Attribute
*/ | |
| #if 0 | | #if 0 | |
| /* These were obsolete in recent rfc3489bis */ | | /* These were obsolete in recent rfc3489bis */ | |
| //PJ_STUN_SC_STALE_CREDENTIALS = 430, /**< Stale Credentials
*/ | | //PJ_STUN_SC_STALE_CREDENTIALS = 430, /**< Stale Credentials
*/ | |
| //PJ_STUN_SC_INTEGRITY_CHECK_FAILURE= 431, /**< Integrity Chk Fail
*/ | | //PJ_STUN_SC_INTEGRITY_CHECK_FAILURE= 431, /**< Integrity Chk Fail
*/ | |
| //PJ_STUN_SC_MISSING_USERNAME = 432, /**< Missing Username
*/ | | //PJ_STUN_SC_MISSING_USERNAME = 432, /**< Missing Username
*/ | |
| //PJ_STUN_SC_USE_TLS = 433, /**< Use TLS
*/ | | //PJ_STUN_SC_USE_TLS = 433, /**< Use TLS
*/ | |
| //PJ_STUN_SC_MISSING_REALM = 434, /**< Missing Realm
*/ | | //PJ_STUN_SC_MISSING_REALM = 434, /**< Missing Realm
*/ | |
| //PJ_STUN_SC_MISSING_NONCE = 435, /**< Missing Nonce
*/ | | //PJ_STUN_SC_MISSING_NONCE = 435, /**< Missing Nonce
*/ | |
| //PJ_STUN_SC_UNKNOWN_USERNAME = 436, /**< Unknown Username
*/ | | //PJ_STUN_SC_UNKNOWN_USERNAME = 436, /**< Unknown Username
*/ | |
| #endif | | #endif | |
| PJ_STUN_SC_ALLOCATION_MISMATCH = 437, /**< TURN Alloc Mismatch
*/ | | PJ_STUN_SC_ALLOCATION_MISMATCH = 437, /**< TURN Alloc Mismatch
*/ | |
| PJ_STUN_SC_STALE_NONCE = 438, /**< Stale Nonce
*/ | | PJ_STUN_SC_STALE_NONCE = 438, /**< Stale Nonce
*/ | |
| PJ_STUN_SC_TRANSITIONING = 439, /**< Transitioning.
*/ | | PJ_STUN_SC_TRANSITIONING = 439, /**< Transitioning.
*/ | |
| PJ_STUN_SC_WRONG_CREDENTIALS = 441, /**< TURN Wrong Credentials
*/ | | PJ_STUN_SC_WRONG_CREDENTIALS = 441, /**< TURN Wrong Credentials
*/ | |
| PJ_STUN_SC_UNSUPP_TRANSPORT_PROTO = 442, /**< Unsupported Transport
or | | PJ_STUN_SC_UNSUPP_TRANSPORT_PROTO = 442, /**< Unsupported Transport
or | |
| Protocol (TURN) */ | | Protocol (TURN) */ | |
|
| PJ_STUN_SC_INVALID_IP_ADDR = 443, /**< Invalid IP Address(TURN | | | |
| )*/ | | | |
| PJ_STUN_SC_INVALID_PORT = 444, /**< Invalid Port (TURN) | | | |
| */ | | | |
| PJ_STUN_SC_OPER_TCP_ONLY = 445, /**< Operation for TCP Only
*/ | | PJ_STUN_SC_OPER_TCP_ONLY = 445, /**< Operation for TCP Only
*/ | |
| PJ_STUN_SC_CONNECTION_FAILURE = 446, /**< Connection Failure
*/ | | PJ_STUN_SC_CONNECTION_FAILURE = 446, /**< Connection Failure
*/ | |
| PJ_STUN_SC_CONNECTION_TIMEOUT = 447, /**< Connection Timeout
*/ | | PJ_STUN_SC_CONNECTION_TIMEOUT = 447, /**< Connection Timeout
*/ | |
| PJ_STUN_SC_ALLOCATION_QUOTA_REACHED = 486, /**< Allocation Quota Reach
ed | | PJ_STUN_SC_ALLOCATION_QUOTA_REACHED = 486, /**< Allocation Quota Reach
ed | |
| (TURN) */ | | (TURN) */ | |
| PJ_STUN_SC_ROLE_CONFLICT = 487, /**< Role Conflict
*/ | | PJ_STUN_SC_ROLE_CONFLICT = 487, /**< Role Conflict
*/ | |
| PJ_STUN_SC_SERVER_ERROR = 500, /**< Server Error
*/ | | PJ_STUN_SC_SERVER_ERROR = 500, /**< Server Error
*/ | |
|
| PJ_STUN_SC_INSUFFICIENT_CAPACITY = 507, /**< Insufficient Capacity | | PJ_STUN_SC_INSUFFICIENT_CAPACITY = 508, /**< Insufficient Capacity | |
| (TURN) */ | | | |
| PJ_STUN_SC_INSUFFICIENT_PORT_CAPACITY=508, /**< Insufficient Port Capa | | | |
| city | | | |
| (TURN) */ | | (TURN) */ | |
| PJ_STUN_SC_GLOBAL_FAILURE = 600 /**< Global Failure
*/ | | PJ_STUN_SC_GLOBAL_FAILURE = 600 /**< Global Failure
*/ | |
| } pj_stun_status; | | } pj_stun_status; | |
| | | | |
| /** | | /** | |
| * This structure describes STUN message header. A STUN message has the | | * This structure describes STUN message header. A STUN message has the | |
| * following format: | | * following format: | |
| * | | * | |
| * \verbatim | | * \verbatim | |
| | | | |
| | | | |
| skipping to change at line 866 | | skipping to change at line 884 | |
| | | | |
| /** | | /** | |
| * This describes STUN BANDWIDTH attribute. | | * This describes STUN BANDWIDTH attribute. | |
| * The bandwidth attribute represents the peak bandwidth, measured in | | * The bandwidth attribute represents the peak bandwidth, measured in | |
| * kbits per second, that the client expects to use on the binding. The | | * kbits per second, that the client expects to use on the binding. The | |
| * value represents the sum in the receive and send directions. | | * value represents the sum in the receive and send directions. | |
| */ | | */ | |
| typedef struct pj_stun_uint_attr pj_stun_bandwidth_attr; | | typedef struct pj_stun_uint_attr pj_stun_bandwidth_attr; | |
| | | | |
| /** | | /** | |
|
| * This describes the STUN PEER-ADDRESS attribute. | | * This describes the STUN XOR-PEER-ADDRESS attribute. | |
| * The PEER-ADDRESS specifies the address and port of the peer as seen | | * The XOR-PEER-ADDRESS specifies the address and port of the peer as seen | |
| * from the TURN server. It is encoded in the same way as XOR-MAPPED- | | * from the TURN server. It is encoded in the same way as XOR-MAPPED- | |
| * ADDRESS. | | * ADDRESS. | |
| */ | | */ | |
|
| typedef struct pj_stun_sockaddr_attr pj_stun_peer_addr_attr; | | typedef struct pj_stun_sockaddr_attr pj_stun_xor_peer_addr_attr; | |
| | | | |
| /** | | /** | |
| * This describes the STUN DATA attribute. | | * This describes the STUN DATA attribute. | |
| * The DATA attribute is present in Send Indications and Data | | * The DATA attribute is present in Send Indications and Data | |
| * Indications. It contains raw payload data that is to be sent (in the | | * Indications. It contains raw payload data that is to be sent (in the | |
| * case of a Send Request) or was received (in the case of a Data | | * case of a Send Request) or was received (in the case of a Data | |
| * Indication).. | | * Indication).. | |
| */ | | */ | |
| typedef struct pj_stun_binary_attr pj_stun_data_attr; | | typedef struct pj_stun_binary_attr pj_stun_data_attr; | |
| | | | |
| /** | | /** | |
|
| * This describes the STUN RELAYED-ADDRESS attribute. | | * This describes the STUN XOR-RELAYED-ADDRESS attribute. The | |
| * The RELAYED-ADDRESS is present in Allocate responses. It specifies the | | * XOR-RELAYED-ADDRESS is present in Allocate responses. It specifies the | |
| * address and port that the server allocated to the client. It is | | * address and port that the server allocated to the client. It is | |
| * encoded in the same way as XOR-MAPPED-ADDRESS. | | * encoded in the same way as XOR-MAPPED-ADDRESS. | |
| */ | | */ | |
|
| typedef struct pj_stun_sockaddr_attr pj_stun_relayed_addr_attr; | | typedef struct pj_stun_sockaddr_attr pj_stun_xor_relayed_addr_attr; | |
| | | | |
| /** | | /** | |
| * This describes the REQUESTED-ADDRESS-TYPE attribute. | | * This describes the REQUESTED-ADDRESS-TYPE attribute. | |
| * The REQUESTED-ADDRESS-TYPE attribute is used by clients to request | | * The REQUESTED-ADDRESS-TYPE attribute is used by clients to request | |
| * the allocation of a specific address type from a server. The | | * the allocation of a specific address type from a server. The | |
| * following is the format of the REQUESTED-ADDRESS-TYPE attribute. | | * following is the format of the REQUESTED-ADDRESS-TYPE attribute. | |
| | | | |
| \verbatim | | \verbatim | |
| | | | |
| 0 1 2 3 | | 0 1 2 3 | |
| 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | | 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | |
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| | Family | Reserved | | | | Family | Reserved | | |
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| | | | |
| \endverbatim | | \endverbatim | |
| */ | | */ | |
|
| typedef struct pj_stun_uint_attr pj_stun_req_addr_type; | | typedef struct pj_stun_uint_attr pj_stun_req_addr_type_attr; | |
| | | | |
| /** | | /** | |
|
| * This describes the TURN REQUESTED-PROPS attribute, encoded as | | * This describes the TURN REQUESTED-TRANSPORT attribute, encoded in | |
| * STUN 32bit integer attribute. Few macros are provided to manipulate | | * STUN generic integer attribute. | |
| * the values in this attribute: #PJ_STUN_GET_PROP_TYPE(), and | | | |
| * #PJ_STUN_SET_PROP_TYPE(). | | | |
| * | | | |
| * This attribute allows the client to request that the allocation have | | | |
| * certain properties, and by the server to indicate which properties | | | |
| * are supported. The attribute is 32 bits long. Its format is: | | | |
| | | | |
| \verbatim | | | |
| | | | |
| 0 1 2 3 | | | |
| 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | | | |
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | |
| | Prop-type | Reserved = 0 | | | | |
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | |
| | | | |
| \endverbatim | | | |
| | | | |
| * The field labeled "Prop-type" is an 8-bit field specifying the | | | |
| * desired property. The rest of the attribute is RFFU (Reserved For | | | |
| * Future Use) and MUST be set to 0 on transmission and ignored on | | | |
| * reception. | | | |
| * | | * | |
|
| * The "Prop-type" field is formatted as follows: | | * This attribute allows the client to request that the port in the | |
| | | * relayed-transport-address be even, and (optionally) that the server | |
| \verbatim | | * reserve the next-higher port number. The attribute is 8 bits long. | |
| | | * Its format is: | |
| | | | |
|
| | | \verbatim | |
| | | 0 | |
| 0 1 2 3 4 5 6 7 | | 0 1 2 3 4 5 6 7 | |
| +-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+ | |
|
| |E|R|P| | | | |R| RFFU | | |
| +-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+ | |
| | | | |
|
| \endverbatim | | \endverbatim | |
| | | | |
| The bits in "Prop-type" are: | | | |
| | | | |
| E: If 1, the port number for the relayed-transport-address must be | | | |
| even. If 0, the port number can be even or odd. | | | |
| | | | |
| R: If 1, the server must reserve the next highest port for a | | | |
| subsequent allocation. If 0, no such reservation is requested. | | | |
| If the client sets the R bit to 1, it MUST also set the E bit to 1 | | | |
| (however, the E bit may be 1 when the R bit is 0). | | | |
| | | | |
| P: If 1, the allocation must be a Preserving allocation. If 0, the | | | |
| allocation can be either Preserving or Non-Preserving. | | | |
| | | | |
| */ | | | |
| typedef struct pj_stun_uint_attr pj_stun_req_props_attr; | | | |
| | | | |
| /** | | | |
| * Get the 8bit Prop-type value from a 32bit integral value of TURN | | | |
| * TURN REQUESTED-PROPS attribute. | | | |
| */ | | | |
| #define PJ_STUN_GET_PROP_TYPE(u32) (u32 >> 24) | | | |
| | | | |
|
| /** | | * The attribute contains a single 1-bit flag: | |
| * Convert 8bit Prop-type value to a 32bit integral value of TURN | | * | |
| * REQUESTED-PROPS attribute. | | * R: If 1, the server is requested to reserve the next higher port | |
| | | * number (on the same IP address) for a subsequent allocation. If | |
| | | * 0, no such reservation is requested. | |
| | | * | |
| | | * The other 7 bits of the attribute must be set to zero on transmission | |
| | | * and ignored on reception. | |
| */ | | */ | |
|
| #define PJ_STUN_SET_PROP_TYPE(PropType) (PropType << 24) | | typedef struct pj_stun_uint_attr pj_stun_even_port_attr; | |
| | | | |
| /** | | /** | |
| * This describes the TURN REQUESTED-TRANSPORT attribute, encoded in | | * This describes the TURN REQUESTED-TRANSPORT attribute, encoded in | |
| * STUN generic integer attribute. | | * STUN generic integer attribute. | |
| * | | * | |
| * This attribute is used by the client to request a specific transport | | * This attribute is used by the client to request a specific transport | |
| * protocol for the allocated transport address. It has the following | | * protocol for the allocated transport address. It has the following | |
| * format: | | * format: | |
| | | | |
| \verbatim | | \verbatim | |
| | | | |
| skipping to change at line 1013 | | skipping to change at line 996 | |
| */ | | */ | |
| #define PJ_STUN_GET_RT_PROTO(u32) (u32 >> 24) | | #define PJ_STUN_GET_RT_PROTO(u32) (u32 >> 24) | |
| | | | |
| /** | | /** | |
| * Convert protocol value to be placed in 32bit TURN REQUESTED-TRANSPORT | | * Convert protocol value to be placed in 32bit TURN REQUESTED-TRANSPORT | |
| * attribute. | | * attribute. | |
| */ | | */ | |
| #define PJ_STUN_SET_RT_PROTO(proto) (((pj_uint32_t)(proto)) << 24) | | #define PJ_STUN_SET_RT_PROTO(proto) (((pj_uint32_t)(proto)) << 24) | |
| | | | |
| /** | | /** | |
|
| | | * This describes the TURN DONT-FRAGMENT attribute. | |
| | | * | |
| | | * This attribute is used by the client to request that the server set | |
| | | * the DF (Don't Fragment) bit in the IP header when relaying the | |
| | | * application data onward to the peer. This attribute has no value | |
| | | * part and thus the attribute length field is 0. | |
| | | */ | |
| | | typedef struct pj_stun_empty_attr pj_stun_dont_fragment_attr; | |
| | | | |
| | | /** | |
| * This describes the TURN RESERVATION-TOKEN attribute. | | * This describes the TURN RESERVATION-TOKEN attribute. | |
| * The RESERVATION-TOKEN attribute contains a token that uniquely | | * The RESERVATION-TOKEN attribute contains a token that uniquely | |
| * identifies a relayed transport address being held in reserve by the | | * identifies a relayed transport address being held in reserve by the | |
| * server. The server includes this attribute in a success response to | | * server. The server includes this attribute in a success response to | |
| * tell the client about the token, and the client includes this | | * tell the client about the token, and the client includes this | |
| * attribute in a subsequent Allocate request to request the server use | | * attribute in a subsequent Allocate request to request the server use | |
| * that relayed transport address for the allocation. | | * that relayed transport address for the allocation. | |
| * | | * | |
| * The attribute value is a 64-bit-long field containing the token | | * The attribute value is a 64-bit-long field containing the token | |
| * value. | | * value. | |
| | | | |
End of changes. 23 change blocks. |
| 77 lines changed or deleted | | 69 lines changed or added | |
|
| stun_session.h | | stun_session.h | |
|
| /* $Id: stun_session.h 2394 2008-12-23 17:27:53Z bennylp $ */ | | /* $Id: stun_session.h 2642 2009-04-22 17:20:24Z bennylp $ */ | |
| /* | | /* | |
| * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) | | * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) | |
| * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> | | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> | |
| * | | * | |
| * This program is free software; you can redistribute it and/or modify | | * This program is free software; you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | | * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation; either version 2 of the License, or | | * the Free Software Foundation; either version 2 of the License, or | |
| * (at your option) any later version. | | * (at your option) any later version. | |
| * | | * | |
| * This program is distributed in the hope that it will be useful, | | * This program is distributed in the hope that it will be useful, | |
| | | | |
| skipping to change at line 39 | | skipping to change at line 39 | |
| #include <pjnath/stun_auth.h> | | #include <pjnath/stun_auth.h> | |
| #include <pjnath/stun_config.h> | | #include <pjnath/stun_config.h> | |
| #include <pjnath/stun_transaction.h> | | #include <pjnath/stun_transaction.h> | |
| #include <pj/list.h> | | #include <pj/list.h> | |
| #include <pj/timer.h> | | #include <pj/timer.h> | |
| | | | |
| PJ_BEGIN_DECL | | PJ_BEGIN_DECL | |
| | | | |
| /* ************************************************************************
**/ | | /* ************************************************************************
**/ | |
| /** | | /** | |
|
| * @defgroup PJNATH_STUN_SESSION STUN Client/Server Session | | * @addtogroup PJNATH_STUN_SESSION | |
| * @brief STUN client and server session | | | |
| * @ingroup PJNATH_STUN | | | |
| * @{ | | * @{ | |
|
| | | * | |
| | | * This is is a transport-independent object to manage a client or server | |
| | | * STUN session. It has the following features: | |
| | | * | |
| | | * - <b>transport independent</b>:\n | |
| | | * the object does not have it's own socket, but rather it provides | |
| | | * functions and callbacks to send and receive packets. This way the | |
| | | * object can be used by different transport types (e.g. UDP, TCP, | |
| | | * TLS, etc.) as well as better integration to application which | |
| | | * already has its own means to send and receive packets. | |
| | | * | |
| | | * - <b>authentication management</b>:\n | |
| | | * the object manages STUN authentication throughout the lifetime of | |
| | | * the session. For client sessions, once it's given a credential to | |
| | | * authenticate itself with the server, the object will automatically | |
| | | * add authentication info (the MESSAGE-INTEGRITY) to the request as | |
| | | * well as authenticate the response. It will also handle long-term | |
| | | * authentication challenges, including handling of nonce expiration, | |
| | | * and retry the request automatically. For server sessions, it can | |
| | | * be configured to authenticate incoming requests automatically. | |
| | | * | |
| | | * - <b>static or dynamic credential</b>:\n | |
| | | * application may specify static or dynamic credential to be used by | |
| | | * the STUN session. Static credential means a static combination of | |
| | | * username and password (and these cannot change during the session | |
| | | * duration), while dynamic credential provides callback to ask the | |
| | | * application about which username/password to use everytime | |
| | | * authentication is about to be performed. | |
| | | * | |
| | | * - <b>client transaction management</b>:\n | |
| | | * outgoing requests may be sent with a STUN transaction for reliability | |
| | | , | |
| | | * and the object will manage the transaction internally (including | |
| | | * performing retransmissions). Application will be notified about the | |
| | | * result of the request when the response arrives (or the transaction | |
| | | * times out). When the request is challenged with authentication, the | |
| | | * object will retry the request with new authentication info, and | |
| | | * application will be notified about the final result of this request. | |
| | | * | |
| | | * - <b>server transaction management</b>:\n | |
| | | * application may ask response to incoming requests to be cached by | |
| | | * the object, and in this case the object will check for cached | |
| | | * response everytime request is received. The cached response will be | |
| | | * deleted once a timer expires. | |
| | | * | |
| | | * \section using_stun_sess_sec Using the STUN session | |
| | | * | |
| | | * The following steps describes how to use the STUN session: | |
| | | * | |
| | | * - <b>create the object configuration</b>:\n | |
| | | * The #pj_stun_config contains the configuration to create the STUN | |
| | | * session, such as the timer heap to register internal timers and | |
| | | * various STUN timeout values. You can initialize this structure by | |
| | | * calling #pj_stun_config_init() | |
| | | * | |
| | | * - <b>create the STUN session</b>:\n | |
| | | * by calling #pj_stun_session_create(). Among other things, this | |
| | | * function requires the instance of #pj_stun_config and also | |
| | | * #pj_stun_session_cb structure which stores callbacks to send | |
| | | * outgoing packets as well as to notify application about incoming | |
| | | * STUN requests, responses, and indicates and other events. | |
| | | * | |
| | | * - <b>configure credential:</b>\n | |
| | | * if authentication is required for the session, configure the | |
| | | * credential with #pj_stun_session_set_credential() | |
| | | * | |
| | | * - <b>configuring other settings:</b>\n | |
| | | * several APIs are provided to configure the behavior of the STUN | |
| | | * session (for example, to set the SOFTWARE attribute value, controls | |
| | | * the logging behavior, fine tune the mutex locking, etc.). Please see | |
| | | * the API reference for more info. | |
| | | * | |
| | | * - <b>creating outgoing STUN requests or indications:</b>\n | |
| | | * create the STUN message by using #pj_stun_session_create_req() or | |
| | | * #pj_stun_session_create_ind(). This will create a transmit data | |
| | | * buffer containing a blank STUN request or indication. You will then | |
| | | * typically need to add STUN attributes that are relevant to the | |
| | | * request or indication, but note that some default attributes will | |
| | | * be added by the session later when the message is sent (such as | |
| | | * SOFTWARE attribute and attributes related to authentication). | |
| | | * The message is now ready to be sent. | |
| | | * | |
| | | * - <b>sending outgoing message:</b>\n | |
| | | * use #pj_stun_session_send_msg() to send outgoing STUN messages (this | |
| | | * includes STUN requests, indications, and responses). The function has | |
| | | * options whether to retransmit the request (for non reliable transport | |
| | | s) | |
| | | * or to cache the response if we're sending response. This function in | |
| | | * turn will call the \a on_send_msg() callback of #pj_stun_session_cb | |
| | | * to request the application to send the packet. | |
| | | * | |
| | | * - <b>handling incoming packet:</b>\n | |
| | | * call #pj_stun_session_on_rx_pkt() everytime the application receives | |
| | | * a STUN packet. This function will decode the packet and process the | |
| | | * packet according to the message, and normally this will cause one | |
| | | * of the callback in the #pj_stun_session_cb to be called to notify | |
| | | * the application about the event. | |
| | | * | |
| | | * - <b>handling incoming requests:</b>\n | |
| | | * incoming requests are notified to application in the \a on_rx_request | |
| | | * callback of the #pj_stun_session_cb. If authentication is enabled in | |
| | | * the session, the application will only receive this callback after | |
| | | * the incoming request has been authenticated (if the authentication | |
| | | * fails, the session would respond automatically with 401 error and | |
| | | * the callback will not be called). Application now must create and | |
| | | * send response for this request. | |
| | | * | |
| | | * - <b>creating and sending response:</b>\n | |
| | | * create the STUN response with #pj_stun_session_create_res(). This wil | |
| | | l | |
| | | * create a transmit data buffer containing a blank STUN response. You | |
| | | * will then typically need to add STUN attributes that are relevant to | |
| | | * the response, but note that some default attributes will | |
| | | * be added by the session later when the message is sent (such as | |
| | | * SOFTWARE attribute and attributes related to authentication). | |
| | | * The message is now ready to be sent. Use #pj_stun_session_send_msg() | |
| | | * (as explained above) to send the response. | |
| | | * | |
| | | * - <b>convenient way to send response:</b>\n | |
| | | * the #pj_stun_session_respond() is provided as a convenient way to | |
| | | * create and send simple STUN responses, such as error responses. | |
| | | * | |
| | | * - <b>destroying the session:</b>\n | |
| | | * once the session is done, use #pj_stun_session_destroy() to destroy | |
| | | * the session. | |
| */ | | */ | |
| | | | |
| /** Forward declaration for pj_stun_tx_data */ | | /** Forward declaration for pj_stun_tx_data */ | |
| typedef struct pj_stun_tx_data pj_stun_tx_data; | | typedef struct pj_stun_tx_data pj_stun_tx_data; | |
| | | | |
| /** Forward declaration for pj_stun_rx_data */ | | /** Forward declaration for pj_stun_rx_data */ | |
| typedef struct pj_stun_rx_data pj_stun_rx_data; | | typedef struct pj_stun_rx_data pj_stun_rx_data; | |
| | | | |
| /** Forward declaration for pj_stun_session */ | | /** Forward declaration for pj_stun_session */ | |
| typedef struct pj_stun_session pj_stun_session; | | typedef struct pj_stun_session pj_stun_session; | |
| | | | |
| skipping to change at line 322 | | skipping to change at line 442 | |
| * @param sess The STUN session instance. | | * @param sess The STUN session instance. | |
| * @param lock New lock instance to be used by the STUN session. | | * @param lock New lock instance to be used by the STUN session. | |
| * @param auto_del Specify whether STUN session should destroy this | | * @param auto_del Specify whether STUN session should destroy this | |
| * lock instance when it's destroyed. | | * lock instance when it's destroyed. | |
| */ | | */ | |
| PJ_DECL(pj_status_t) pj_stun_session_set_lock(pj_stun_session *sess, | | PJ_DECL(pj_status_t) pj_stun_session_set_lock(pj_stun_session *sess, | |
| pj_lock_t *lock, | | pj_lock_t *lock, | |
| pj_bool_t auto_del); | | pj_bool_t auto_del); | |
| | | | |
| /** | | /** | |
|
| * Set server name to be included in all response. | | * Set SOFTWARE name to be included in all requests and responses. | |
| * | | * | |
| * @param sess The STUN session instance. | | * @param sess The STUN session instance. | |
|
| * @param srv_name Server name string. | | * @param sw Software name string. If this argument is NULL or | |
| | | * empty, the session will not include SOFTWARE attribute | |
| | | * in STUN requests and responses. | |
| * | | * | |
|
| * @return The user data associated with this STUN session. | | * @return PJ_SUCCESS on success, or the appropriate error code. | |
| */ | | */ | |
|
| PJ_DECL(pj_status_t) pj_stun_session_set_server_name(pj_stun_session *sess, | | PJ_DECL(pj_status_t) pj_stun_session_set_software_name(pj_stun_session *ses | |
| const pj_str_t *srv_nam | | s, | |
| e); | | const pj_str_t *sw); | |
| | | | |
| /** | | /** | |
| * Set credential to be used by this session. Once credential is set, all | | * Set credential to be used by this session. Once credential is set, all | |
| * outgoing messages will include MESSAGE-INTEGRITY, and all incoming | | * outgoing messages will include MESSAGE-INTEGRITY, and all incoming | |
| * message will be authenticated against this credential. | | * message will be authenticated against this credential. | |
| * | | * | |
| * To disable authentication after it has been set, call this function | | * To disable authentication after it has been set, call this function | |
| * again with NULL as the argument. | | * again with NULL as the argument. | |
| * | | * | |
| * @param sess The STUN session instance. | | * @param sess The STUN session instance. | |
| | | | |
End of changes. 7 change blocks. |
| 10 lines changed or deleted | | 135 lines changed or added | |
|
| stun_sock.h | | stun_sock.h | |
|
| /* $Id: stun_sock.h 2484 2009-03-04 12:56:32Z bennylp $ */ | | /* $Id: stun_sock.h 2642 2009-04-22 17:20:24Z bennylp $ */ | |
| /* | | /* | |
| * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) | | * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) | |
| * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> | | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> | |
| * | | * | |
| * This program is free software; you can redistribute it and/or modify | | * This program is free software; you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | | * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation; either version 2 of the License, or | | * the Free Software Foundation; either version 2 of the License, or | |
| * (at your option) any later version. | | * (at your option) any later version. | |
| * | | * | |
| * This program is distributed in the hope that it will be useful, | | * This program is distributed in the hope that it will be useful, | |
| | | | |
| skipping to change at line 35 | | skipping to change at line 35 | |
| * @brief STUN aware socket transport | | * @brief STUN aware socket transport | |
| */ | | */ | |
| #include <pjnath/stun_config.h> | | #include <pjnath/stun_config.h> | |
| #include <pjlib-util/resolver.h> | | #include <pjlib-util/resolver.h> | |
| #include <pj/ioqueue.h> | | #include <pj/ioqueue.h> | |
| #include <pj/sock.h> | | #include <pj/sock.h> | |
| | | | |
| PJ_BEGIN_DECL | | PJ_BEGIN_DECL | |
| | | | |
| /** | | /** | |
|
| * @defgroup PJNATH_STUN_SOCK STUN aware socket transport | | * @addtogroup PJNATH_STUN_SOCK | |
| * @brief STUN aware socket transport | | | |
| * @ingroup PJNATH_STUN | | | |
| * @{ | | * @{ | |
| * | | * | |
| * The STUN transport provides asynchronous UDP like socket transport | | * The STUN transport provides asynchronous UDP like socket transport | |
|
| * with the additional capability to query the publicly mapped transport | | * with the additional STUN capability. It has the following features: | |
| * address (using STUN resolution), to refresh the NAT binding, and to | | * | |
| * demultiplex internal STUN messages from application data (the | | * - API to send and receive UDP packets | |
| * application data may be a STUN message as well). | | * | |
| | | * - multiplex STUN and non-STUN incoming packets and distinguish between | |
| | | * STUN responses that belong to internal requests with application data | |
| | | * (the application data may be STUN packets as well) | |
| | | * | |
| | | * - DNS SRV resolution to the STUN server (if wanted), along with fallbac | |
| | | k | |
| | | * to DNS A resolution if SRV record is not found. | |
| | | * | |
| | | * - STUN keep-alive maintenance, and handle changes to the mapped address | |
| | | * (when the NAT binding changes) | |
| | | * | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * Opaque type to represent a STUN transport. | | * Opaque type to represent a STUN transport. | |
| */ | | */ | |
| typedef struct pj_stun_sock pj_stun_sock; | | typedef struct pj_stun_sock pj_stun_sock; | |
| | | | |
| /** | | /** | |
| * Types of operation being reported in \a on_status() callback of | | * Types of operation being reported in \a on_status() callback of | |
| * pj_stun_sock_cb. Application may retrieve the string representation | | * pj_stun_sock_cb. Application may retrieve the string representation | |
| | | | |
| skipping to change at line 268 | | skipping to change at line 276 | |
| * @param af Address family of socket. Currently pj_AF_INET() | | * @param af Address family of socket. Currently pj_AF_INET() | |
| * and pj_AF_INET6() are supported. | | * and pj_AF_INET6() are supported. | |
| * @param name Optional name to be given to this transport to | | * @param name Optional name to be given to this transport to | |
| * assist debugging. | | * assist debugging. | |
| * @param cb Callback to receive events/data from the transport. | | * @param cb Callback to receive events/data from the transport. | |
| * @param cfg Optional transport settings. | | * @param cfg Optional transport settings. | |
| * @param user_data Arbitrary application data to be associated with | | * @param user_data Arbitrary application data to be associated with | |
| * this transport. | | * this transport. | |
| * @param p_sock Pointer to receive the created transport instance. | | * @param p_sock Pointer to receive the created transport instance. | |
| * | | * | |
|
| * @restun PJ_SUCCESS if the operation has been successful, | | * @return PJ_SUCCESS if the operation has been successful, | |
| * or the appropriate error code on failure. | | * or the appropriate error code on failure. | |
| */ | | */ | |
| PJ_DECL(pj_status_t) pj_stun_sock_create(pj_stun_config *stun_cfg, | | PJ_DECL(pj_status_t) pj_stun_sock_create(pj_stun_config *stun_cfg, | |
| const char *name, | | const char *name, | |
| int af, | | int af, | |
| const pj_stun_sock_cb *cb, | | const pj_stun_sock_cb *cb, | |
| const pj_stun_sock_cfg *cfg, | | const pj_stun_sock_cfg *cfg, | |
| void *user_data, | | void *user_data, | |
| pj_stun_sock **p_sock); | | pj_stun_sock **p_sock); | |
| | | | |
| | | | |
| skipping to change at line 319 | | skipping to change at line 327 | |
| PJ_DECL(pj_status_t) pj_stun_sock_start(pj_stun_sock *stun_sock, | | PJ_DECL(pj_status_t) pj_stun_sock_start(pj_stun_sock *stun_sock, | |
| const pj_str_t *domain, | | const pj_str_t *domain, | |
| pj_uint16_t default_port, | | pj_uint16_t default_port, | |
| pj_dns_resolver *resolver); | | pj_dns_resolver *resolver); | |
| | | | |
| /** | | /** | |
| * Destroy the STUN transport. | | * Destroy the STUN transport. | |
| * | | * | |
| * @param sock The STUN transport socket. | | * @param sock The STUN transport socket. | |
| * | | * | |
|
| * @restun PJ_SUCCESS if the operation has been successful, | | * @return PJ_SUCCESS if the operation has been successful, | |
| * or the appropriate error code on failure. | | * or the appropriate error code on failure. | |
| */ | | */ | |
| PJ_DECL(pj_status_t) pj_stun_sock_destroy(pj_stun_sock *sock); | | PJ_DECL(pj_status_t) pj_stun_sock_destroy(pj_stun_sock *sock); | |
| | | | |
| /** | | /** | |
| * Associate a user data with this STUN transport. The user data may then | | * Associate a user data with this STUN transport. The user data may then | |
| * be retrieved later with #pj_stun_sock_get_user_data(). | | * be retrieved later with #pj_stun_sock_get_user_data(). | |
| * | | * | |
| * @param stun_sock The STUN transport instance. | | * @param stun_sock The STUN transport instance. | |
| * @param user_data Arbitrary data. | | * @param user_data Arbitrary data. | |
| * | | * | |
|
| * @restun PJ_SUCCESS if the operation has been successful, | | * @return PJ_SUCCESS if the operation has been successful, | |
| * or the appropriate error code on failure. | | * or the appropriate error code on failure. | |
| */ | | */ | |
| PJ_DECL(pj_status_t) pj_stun_sock_set_user_data(pj_stun_sock *stun_sock, | | PJ_DECL(pj_status_t) pj_stun_sock_set_user_data(pj_stun_sock *stun_sock, | |
| void *user_data); | | void *user_data); | |
| | | | |
| /** | | /** | |
| * Retrieve the previously assigned user data associated with this STUN | | * Retrieve the previously assigned user data associated with this STUN | |
| * transport. | | * transport. | |
| * | | * | |
| * @param stun_sock The STUN transport instance. | | * @param stun_sock The STUN transport instance. | |
| * | | * | |
|
| * @restun The user/application data. | | * @return The user/application data. | |
| */ | | */ | |
| PJ_DECL(void*) pj_stun_sock_get_user_data(pj_stun_sock *stun_sock); | | PJ_DECL(void*) pj_stun_sock_get_user_data(pj_stun_sock *stun_sock); | |
| | | | |
| /** | | /** | |
| * Get the STUN transport info. The transport info contains, among other | | * Get the STUN transport info. The transport info contains, among other | |
| * things, the allocated relay address. | | * things, the allocated relay address. | |
| * | | * | |
| * @param stun_sock The STUN transport instance. | | * @param stun_sock The STUN transport instance. | |
| * @param info Pointer to be filled with STUN transport info. | | * @param info Pointer to be filled with STUN transport info. | |
| * | | * | |
|
| * @restun PJ_SUCCESS if the operation has been successful, | | * @return PJ_SUCCESS if the operation has been successful, | |
| * or the appropriate error code on failure. | | * or the appropriate error code on failure. | |
| */ | | */ | |
| PJ_DECL(pj_status_t) pj_stun_sock_get_info(pj_stun_sock *stun_sock, | | PJ_DECL(pj_status_t) pj_stun_sock_get_info(pj_stun_sock *stun_sock, | |
| pj_stun_sock_info *info); | | pj_stun_sock_info *info); | |
| | | | |
| /** | | /** | |
| * Send a data to the specified address. This function may complete | | * Send a data to the specified address. This function may complete | |
| * asynchronously and in this case \a on_data_sent() will be called. | | * asynchronously and in this case \a on_data_sent() will be called. | |
| * | | * | |
| * @param stun_sock The STUN transport instance. | | * @param stun_sock The STUN transport instance. | |
|
| * @param op_key Optional send key for sending the packet down to | | * @param send_key Optional send key for sending the packet down to | |
| * the ioqueue. This value will be given back to | | * the ioqueue. This value will be given back to | |
| * \a on_data_sent() callback | | * \a on_data_sent() callback | |
| * @param pkt The data/packet to be sent to peer. | | * @param pkt The data/packet to be sent to peer. | |
| * @param pkt_len Length of the data. | | * @param pkt_len Length of the data. | |
| * @param flag pj_ioqueue_sendto() flag. | | * @param flag pj_ioqueue_sendto() flag. | |
| * @param dst_addr The remote address. | | * @param dst_addr The remote address. | |
| * @param addr_len Length of the address. | | * @param addr_len Length of the address. | |
| * | | * | |
| * @return PJ_SUCCESS if data has been sent immediately, or | | * @return PJ_SUCCESS if data has been sent immediately, or | |
| * PJ_EPENDING if data cannot be sent immediately. In | | * PJ_EPENDING if data cannot be sent immediately. In | |
| | | | |
End of changes. 9 change blocks. |
| 14 lines changed or deleted | | 23 lines changed or added | |
|
| turn_session.h | | turn_session.h | |
|
| /* $Id: turn_session.h 2394 2008-12-23 17:27:53Z bennylp $ */ | | /* $Id: turn_session.h 2642 2009-04-22 17:20:24Z bennylp $ */ | |
| /* | | /* | |
| * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) | | * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) | |
| * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> | | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> | |
| * | | * | |
| * This program is free software; you can redistribute it and/or modify | | * This program is free software; you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | | * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation; either version 2 of the License, or | | * the Free Software Foundation; either version 2 of the License, or | |
| * (at your option) any later version. | | * (at your option) any later version. | |
| * | | * | |
| * This program is distributed in the hope that it will be useful, | | * This program is distributed in the hope that it will be useful, | |
| | | | |
| skipping to change at line 32 | | skipping to change at line 32 | |
| | | | |
| /** | | /** | |
| * @file turn_session.h | | * @file turn_session.h | |
| * @brief Transport independent TURN client session. | | * @brief Transport independent TURN client session. | |
| */ | | */ | |
| #include <pjnath/stun_session.h> | | #include <pjnath/stun_session.h> | |
| #include <pjlib-util/resolver.h> | | #include <pjlib-util/resolver.h> | |
| | | | |
| PJ_BEGIN_DECL | | PJ_BEGIN_DECL | |
| | | | |
|
| /** | | | |
| * @defgroup PJNATH_TURN TURN Client Library | | | |
| */ | | | |
| | | | |
| /* ************************************************************************
**/ | | /* ************************************************************************
**/ | |
| /** | | /** | |
|
| * @defgroup PJNATH_TURN_SESSION Transport independent TURN client session | | @addtogroup PJNATH_TURN_SESSION | |
| * @brief Transport independent TURN client session | | @{ | |
| * @ingroup PJNATH_TURN | | | |
| * @{ | | The \ref PJNATH_TURN_SESSION is a transport-independent object to | |
| * | | manage a client TURN session. It contains the core logic for manage | |
| * This module describes the transport independent TURN client session. Thi | | the TURN client session as listed in \ref turn_op_sec, but | |
| s | | in transport-independent manner (i.e. it doesn't have a socket), so | |
| * interface is provided for implementors of a TURN client transport, and | | that developer can integrate TURN client functionality into existing | |
| * application usually will want to use \ref PJNATH_TURN_SOCK instead. | | framework that already has its own means to send and receive data, | |
| * | | or to support new transport types to TURN, such as TLS. | |
| * The transport independent TURN client session is created to facilitate | | | |
| * the creation of different types of transports between the client and the | | \section turn_sess_using_sec Using the TURN session | |
| * TURN server. | | | |
| | | These steps describes how to use the TURN session: | |
| | | | |
| | | - <b>Creating the session</b>:\n | |
| | | use #pj_turn_session_create() to create the session. | |
| | | | |
| | | - <b>Configuring credential</b>:\n | |
| | | all TURN operations requires the use of authentication (it uses STUN | |
| | | long term autentication method). Use #pj_turn_session_set_credential() | |
| | | to configure the TURN credential to be used by the session. | |
| | | | |
| | | - <b>Configuring server</b>:\n | |
| | | application must call #pj_turn_session_set_server() before it can send | |
| | | Allocate request (with pj_turn_session_alloc()). This function will | |
| | | resolve the TURN server using DNS SRV resolution if the \a resolver | |
| | | is set. The server resolution process will complete asynchronously, | |
| | | and application will be notified in \a on_state() callback of the | |
| | | #pj_turn_session_cb structurewith the session state set to | |
| | | PJ_TURN_STATE_RESOLVED. | |
| | | | |
| | | - <b>Creating allocation</b>:\n | |
| | | create one "relay port" (or called <b>relayed-transport-address</b> | |
| | | in TURN terminology) in the TURN server by using #pj_turn_session_alloc( | |
| | | ). | |
| | | This will send Allocate request to the server. This function will comple | |
| | | te | |
| | | immediately, and application will be notified about the allocation | |
| | | result in the \a on_state() callback of the #pj_turn_session_cb structur | |
| | | e. | |
| | | | |
| | | - <b>Getting the allocation result</b>:\n | |
| | | if allocation is successful, the session state will progress to | |
| | | \a PJ_TURN_STATE_READY, otherwise the state will be | |
| | | \a PJ_TURN_STATE_DEALLOCATED or higher. Session state progression is | |
| | | reported in the \a on_state() callback of the #pj_turn_session_cb | |
| | | structure. On successful allocation, application may retrieve the | |
| | | allocation info by calling #pj_turn_session_get_info(). | |
| | | | |
| | | - <b>Sending data through the relay</b>.\n | |
| | | Once allocation has been created, client may send data to any remote | |
| | | endpoints (called peers in TURN terminology) via the "relay port". It do | |
| | | es | |
| | | so by calling #pj_turn_session_sendto(), giving the peer address | |
| | | in the function argument. But note that at this point peers are not allo | |
| | | wed | |
| | | to send data towards the client (via the "relay port") before permission | |
| | | is | |
| | | installed for that peer. | |
| | | | |
| | | - <b>Creating permissions</b>.\n | |
| | | Permission needs to be created in the TURN server so that a peer can sen | |
| | | d | |
| | | data to the client via the relay port (a peer in this case is identified | |
| | | by | |
| | | its IP address). Without this, when the TURN server receives data from t | |
| | | he | |
| | | peer in the "relay port", it will drop this data. Create the permission | |
| | | by | |
| | | calling #pj_turn_session_set_perm(), specifying the peer IP address in t | |
| | | he | |
| | | argument (the port part of the address is ignored). More than one IP | |
| | | addresses may be specified. | |
| | | | |
| | | - <b>Receiving data from peers</b>.\n | |
| | | Once permission has been installed for the peer, any data received by th | |
| | | e | |
| | | TURN server (from that peer) in the "relay port" will be relayed back to | |
| | | client by the server, and application will be notified via \a on_rx_data | |
| | | callback of the #pj_turn_session_cb. | |
| | | | |
| | | - <b>Using ChannelData</b>.\n | |
| | | TURN provides optimized framing to the data by using ChannelData | |
| | | packetization. The client activates this format for the specified peer b | |
| | | y | |
| | | calling #pj_turn_session_bind_channel(). Data sent or received to/for | |
| | | this peer will then use ChannelData format instead of Send or Data | |
| | | Indications. | |
| | | | |
| | | - <b>Refreshing the allocation, permissions, and channel bindings</b>.\n | |
| | | Allocations, permissions, and channel bindings will be refreshed by the | |
| | | session automatically when they about to expire. | |
| | | | |
| | | - <b>Destroying the allocation</b>.\n | |
| | | Once the "relay port" is no longer needed, client destroys the allocatio | |
| | | n | |
| | | by calling #pj_turn_session_shutdown(). This function will return | |
| | | immediately, and application will be notified about the deallocation | |
| | | result in the \a on_state() callback of the #pj_turn_session_cb structur | |
| | | e. | |
| | | Once the state has reached PJ_TURN_STATE_DESTROYING, application must | |
| | | assume that the session will be destroyed shortly after. | |
| | | | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * Opaque declaration for TURN client session. | | * Opaque declaration for TURN client session. | |
| */ | | */ | |
| typedef struct pj_turn_session pj_turn_session; | | typedef struct pj_turn_session pj_turn_session; | |
| | | | |
| /** | | /** | |
| * TURN transport types, which will be used both to specify the connection | | * TURN transport types, which will be used both to specify the connection | |
| * type for reaching TURN server and the type of allocation transport to be | | * type for reaching TURN server and the type of allocation transport to be | |
| | | | |
| skipping to change at line 424 | | skipping to change at line 497 | |
| /** | | /** | |
| * Configure message logging. By default all flags are enabled. | | * Configure message logging. By default all flags are enabled. | |
| * | | * | |
| * @param sess The TURN client session. | | * @param sess The TURN client session. | |
| * @param flags Bitmask combination of #pj_stun_sess_msg_log
_flag | | * @param flags Bitmask combination of #pj_stun_sess_msg_log
_flag | |
| */ | | */ | |
| PJ_DECL(void) pj_turn_session_set_log(pj_turn_session *sess, | | PJ_DECL(void) pj_turn_session_set_log(pj_turn_session *sess, | |
| unsigned flags); | | unsigned flags); | |
| | | | |
| /** | | /** | |
|
| | | * Configure the SOFTWARE name to be sent in all STUN requests by the | |
| | | * TURN session. | |
| | | * | |
| | | * @param sess The TURN client session. | |
| | | * @param sw Software name string. If this argument is NULL or | |
| | | * empty, the session will not include SOFTWARE attribute | |
| | | * in STUN requests and responses. | |
| | | * | |
| | | * @return PJ_SUCCESS on success, or the appropriate error code. | |
| | | */ | |
| | | PJ_DECL(pj_status_t) pj_turn_session_set_software_name(pj_turn_session *ses | |
| | | s, | |
| | | const pj_str_t *sw); | |
| | | | |
| | | /** | |
| * Set the server or domain name of the server. Before the application | | * Set the server or domain name of the server. Before the application | |
| * can send Allocate request (with pj_turn_session_alloc()), it must first | | * can send Allocate request (with pj_turn_session_alloc()), it must first | |
| * resolve the server address(es) using this function. This function will | | * resolve the server address(es) using this function. This function will | |
| * resolve the TURN server using DNS SRV resolution if the \a resolver | | * resolve the TURN server using DNS SRV resolution if the \a resolver | |
| * is set. The server resolution process will complete asynchronously, | | * is set. The server resolution process will complete asynchronously, | |
| * and application will be notified in \a on_state() callback with the | | * and application will be notified in \a on_state() callback with the | |
| * session state set to PJ_TURN_STATE_RESOLVED. | | * session state set to PJ_TURN_STATE_RESOLVED. | |
| * | | * | |
| * Application may call with pj_turn_session_alloc() before the server | | * Application may call with pj_turn_session_alloc() before the server | |
| * resolution completes. In this case, the operation will be queued by | | * resolution completes. In this case, the operation will be queued by | |
| | | | |
| skipping to change at line 503 | | skipping to change at line 590 | |
| * @param sess The TURN client session. | | * @param sess The TURN client session. | |
| * @param param Optional TURN allocation parameter. | | * @param param Optional TURN allocation parameter. | |
| * | | * | |
| * @return PJ_SUCCESS if the operation has been successfully | | * @return PJ_SUCCESS if the operation has been successfully | |
| * initiated or the appropriate error code on failure. | | * initiated or the appropriate error code on failure. | |
| */ | | */ | |
| PJ_DECL(pj_status_t) pj_turn_session_alloc(pj_turn_session *sess, | | PJ_DECL(pj_status_t) pj_turn_session_alloc(pj_turn_session *sess, | |
| const pj_turn_alloc_param *param)
; | | const pj_turn_alloc_param *param)
; | |
| | | | |
| /** | | /** | |
|
| | | * Create or renew permission in the TURN server for the specified peer IP | |
| | | * addresses. Application must install permission for a particular (peer) | |
| | | * IP address before it sends any data to that IP address, or otherwise | |
| | | * the TURN server will drop the data. | |
| | | * | |
| | | * @param sess The TURN client session. | |
| | | * @param addr_cnt Number of IP addresses. | |
| | | * @param addr Array of peer IP addresses. Only the address family | |
| | | * and IP address portion of the socket address matter. | |
| | | * @param options Specify 1 to let the TURN client session automatical | |
| | | ly | |
| | | * renew the permission later when they are about to | |
| | | * expire. | |
| | | * | |
| | | * @return PJ_SUCCESS if the operation has been successfully | |
| | | * issued, or the appropriate error code. Note that | |
| | | * the operation itself will complete asynchronously. | |
| | | */ | |
| | | PJ_DECL(pj_status_t) pj_turn_session_set_perm(pj_turn_session *sess, | |
| | | unsigned addr_cnt, | |
| | | const pj_sockaddr addr[], | |
| | | unsigned options); | |
| | | | |
| | | /** | |
| * Send a data to the specified peer address via the TURN relay. This | | * Send a data to the specified peer address via the TURN relay. This | |
| * function will encapsulate the data as STUN Send Indication or TURN | | * function will encapsulate the data as STUN Send Indication or TURN | |
| * ChannelData packet and send the message to the TURN server. The TURN | | * ChannelData packet and send the message to the TURN server. The TURN | |
| * server then will send the data to the peer. | | * server then will send the data to the peer. | |
| * | | * | |
| * The allocation (pj_turn_session_alloc()) must have been successfully | | * The allocation (pj_turn_session_alloc()) must have been successfully | |
| * created before application can relay any data. | | * created before application can relay any data. | |
| * | | * | |
| * Since TURN session is transport independent, this function will | | * Since TURN session is transport independent, this function will | |
| * ultimately call \a on_send_pkt() callback to request the application | | * ultimately call \a on_send_pkt() callback to request the application | |
| | | | |
End of changes. 5 change blocks. |
| 18 lines changed or deleted | | 144 lines changed or added | |
|
| turn_sock.h | | turn_sock.h | |
|
| /* $Id: turn_sock.h 2394 2008-12-23 17:27:53Z bennylp $ */ | | /* $Id: turn_sock.h 2642 2009-04-22 17:20:24Z bennylp $ */ | |
| /* | | /* | |
| * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) | | * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) | |
| * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> | | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> | |
| * | | * | |
| * This program is free software; you can redistribute it and/or modify | | * This program is free software; you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | | * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation; either version 2 of the License, or | | * the Free Software Foundation; either version 2 of the License, or | |
| * (at your option) any later version. | | * (at your option) any later version. | |
| * | | * | |
| * This program is distributed in the hope that it will be useful, | | * This program is distributed in the hope that it will be useful, | |
| | | | |
| skipping to change at line 33 | | skipping to change at line 33 | |
| /** | | /** | |
| * @file turn_sock.h | | * @file turn_sock.h | |
| * @brief TURN relay using UDP client as transport protocol | | * @brief TURN relay using UDP client as transport protocol | |
| */ | | */ | |
| #include <pjnath/turn_session.h> | | #include <pjnath/turn_session.h> | |
| | | | |
| PJ_BEGIN_DECL | | PJ_BEGIN_DECL | |
| | | | |
| /* ************************************************************************
**/ | | /* ************************************************************************
**/ | |
| /** | | /** | |
|
| * @defgroup PJNATH_TURN_SOCK TURN client transport | | @addtogroup PJNATH_TURN_SOCK | |
| * @brief Client transport utilizing TURN relay | | @{ | |
| * @ingroup PJNATH_TURN | | | |
| * @{ | | This is a ready to use object for relaying application data via a TURN serv | |
| * | | er, | |
| * The TURN relay client transport can be used to relay data from the clien | | by managing all the operations in \ref turn_op_sec. | |
| t | | | |
| * to peer via a TURN relay. The application establishes TURN connection to | | \section turnsock_using_sec Using TURN transport | |
| * the TURN server using UDP or TCP as the transport, then creates a relay | | | |
| * address in the TURN server to be advertised to remote peer(s) as the | | This object provides a thin wrapper to the \ref PJNATH_TURN_SESSION, hence | |
| * transport address. When application sends data to a remote address via | | the | |
| * this transport, the data will be sent via the TURN relay, and vice versa | | API is very much the same (apart from the obvious difference in the names). | |
| . | | Please see \ref PJNATH_TURN_SESSION for the documentation on how to use the | |
| | | session. | |
| | | | |
| | | \section turnsock_samples_sec Samples | |
| | | | |
| | | The \ref turn_client_sample is a sample application to use the | |
| | | \ref PJNATH_TURN_SOCK. | |
| | | | |
| | | Also see <b>\ref samples_page</b> for other samples. | |
| | | | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * Opaque declaration for TURN client. | | * Opaque declaration for TURN client. | |
| */ | | */ | |
| typedef struct pj_turn_sock pj_turn_sock; | | typedef struct pj_turn_sock pj_turn_sock; | |
| | | | |
| /** | | /** | |
| * This structure contains callbacks that will be called by the TURN | | * This structure contains callbacks that will be called by the TURN | |
| * transport. | | * transport. | |
| | | | |
| skipping to change at line 201 | | skipping to change at line 210 | |
| * Set STUN message logging for this TURN session. | | * Set STUN message logging for this TURN session. | |
| * See #pj_stun_session_set_log(). | | * See #pj_stun_session_set_log(). | |
| * | | * | |
| * @param turn_sock The TURN transport instance. | | * @param turn_sock The TURN transport instance. | |
| * @param flags Bitmask combination of #pj_stun_sess_msg_log
_flag | | * @param flags Bitmask combination of #pj_stun_sess_msg_log
_flag | |
| */ | | */ | |
| PJ_DECL(void) pj_turn_sock_set_log(pj_turn_sock *turn_sock, | | PJ_DECL(void) pj_turn_sock_set_log(pj_turn_sock *turn_sock, | |
| unsigned flags); | | unsigned flags); | |
| | | | |
| /** | | /** | |
|
| | | * Configure the SOFTWARE name to be sent in all STUN requests by the | |
| | | * TURN session. | |
| | | * | |
| | | * @param turn_sock The TURN transport instance. | |
| | | * @param sw Software name string. If this argument is NULL or | |
| | | * empty, the session will not include SOFTWARE attribute | |
| | | * in STUN requests and responses. | |
| | | * | |
| | | * @return PJ_SUCCESS on success, or the appropriate error code. | |
| | | */ | |
| | | PJ_DECL(pj_status_t) pj_turn_sock_set_software_name(pj_turn_sock *turn_sock | |
| | | , | |
| | | const pj_str_t *sw); | |
| | | | |
| | | /** | |
| * Allocate a relay address/resource in the TURN server. This function | | * Allocate a relay address/resource in the TURN server. This function | |
| * will resolve the TURN server using DNS SRV (if desired) and send TURN | | * will resolve the TURN server using DNS SRV (if desired) and send TURN | |
| * \a Allocate request using the specified credential to allocate a relay | | * \a Allocate request using the specified credential to allocate a relay | |
| * address in the server. This function completes asynchronously, and | | * address in the server. This function completes asynchronously, and | |
| * application will be notified when the allocation process has been | | * application will be notified when the allocation process has been | |
| * successful in the \a on_state() callback when the state is set to | | * successful in the \a on_state() callback when the state is set to | |
| * PJ_TURN_STATE_READY. If the allocation fails, the state will be set | | * PJ_TURN_STATE_READY. If the allocation fails, the state will be set | |
| * to PJ_TURN_STATE_DEALLOCATING or greater. | | * to PJ_TURN_STATE_DEALLOCATING or greater. | |
| * | | * | |
| * @param turn_sock The TURN transport instance. | | * @param turn_sock The TURN transport instance. | |
| | | | |
| skipping to change at line 243 | | skipping to change at line 266 | |
| * | | * | |
| */ | | */ | |
| PJ_DECL(pj_status_t) pj_turn_sock_alloc(pj_turn_sock *turn_sock, | | PJ_DECL(pj_status_t) pj_turn_sock_alloc(pj_turn_sock *turn_sock, | |
| const pj_str_t *domain, | | const pj_str_t *domain, | |
| int default_port, | | int default_port, | |
| pj_dns_resolver *resolver, | | pj_dns_resolver *resolver, | |
| const pj_stun_auth_cred *cred, | | const pj_stun_auth_cred *cred, | |
| const pj_turn_alloc_param *param); | | const pj_turn_alloc_param *param); | |
| | | | |
| /** | | /** | |
|
| | | * Create or renew permission in the TURN server for the specified peer IP | |
| | | * addresses. Application must install permission for a particular (peer) | |
| | | * IP address before it sends any data to that IP address, or otherwise | |
| | | * the TURN server will drop the data. | |
| | | * | |
| | | * @param turn_sock The TURN transport instance. | |
| | | * @param addr_cnt Number of IP addresses. | |
| | | * @param addr Array of peer IP addresses. Only the address family | |
| | | * and IP address portion of the socket address matter. | |
| | | * @param options Specify 1 to let the TURN client session automatical | |
| | | ly | |
| | | * renew the permission later when they are about to | |
| | | * expire. | |
| | | * | |
| | | * @return PJ_SUCCESS if the operation has been successfully | |
| | | * issued, or the appropriate error code. Note that | |
| | | * the operation itself will complete asynchronously. | |
| | | */ | |
| | | PJ_DECL(pj_status_t) pj_turn_sock_set_perm(pj_turn_sock *turn_sock, | |
| | | unsigned addr_cnt, | |
| | | const pj_sockaddr addr[], | |
| | | unsigned options); | |
| | | | |
| | | /** | |
| * Send a data to the specified peer address via the TURN relay. This | | * Send a data to the specified peer address via the TURN relay. This | |
| * function will encapsulate the data as STUN Send Indication or TURN | | * function will encapsulate the data as STUN Send Indication or TURN | |
| * ChannelData packet and send the message to the TURN server. The TURN | | * ChannelData packet and send the message to the TURN server. The TURN | |
| * server then will send the data to the peer. | | * server then will send the data to the peer. | |
| * | | * | |
| * The allocation (pj_turn_sock_alloc()) must have been successfully | | * The allocation (pj_turn_sock_alloc()) must have been successfully | |
| * created before application can relay any data. | | * created before application can relay any data. | |
| * | | * | |
| * @param turn_sock The TURN transport instance. | | * @param turn_sock The TURN transport instance. | |
| * @param pkt The data/packet to be sent to peer. | | * @param pkt The data/packet to be sent to peer. | |
| | | | |
End of changes. 4 change blocks. |
| 14 lines changed or deleted | | 62 lines changed or added | |
|