Renamed pjsip_url to pjsip_sip_uri
git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@119 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
parent
8220f90610
commit
0c2bc618aa
17 changed files with 1031 additions and 218 deletions
|
@ -124,13 +124,6 @@ SOURCE=..\src\pjsip\sip_tel_uri.c
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\src\pjsip\sip_transaction.c
|
SOURCE=..\src\pjsip\sip_transaction.c
|
||||||
|
|
||||||
!IF "$(CFG)" == "pjsip_core - Win32 Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "pjsip_core - Win32 Debug"
|
|
||||||
|
|
||||||
!ENDIF
|
|
||||||
|
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
@ -257,10 +250,6 @@ SOURCE=..\include\pjsip\sip_util.h
|
||||||
# Begin Group "Inline Files"
|
# Begin Group "Inline Files"
|
||||||
|
|
||||||
# PROP Default_Filter ""
|
# PROP Default_Filter ""
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\include\pjsip\sip_msg_i.h
|
|
||||||
# End Source File
|
|
||||||
# End Group
|
# End Group
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -716,7 +716,10 @@ PJ_DECL(void*) pjsip_msg_find_remove_hdr( pjsip_msg *msg,
|
||||||
* @bug Once the header is put in a list (or message), it can not be put in
|
* @bug Once the header is put in a list (or message), it can not be put in
|
||||||
* other list (or message). Otherwise Real Bad Thing will happen.
|
* other list (or message). Otherwise Real Bad Thing will happen.
|
||||||
*/
|
*/
|
||||||
PJ_IDECL(void) pjsip_msg_add_hdr( pjsip_msg *msg, pjsip_hdr *hdr );
|
PJ_INLINE(void) pjsip_msg_add_hdr( pjsip_msg *msg, pjsip_hdr *hdr )
|
||||||
|
{
|
||||||
|
pj_list_insert_before(&msg->hdr, hdr);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add header field to the message, putting it in the front of the header list.
|
* Add header field to the message, putting it in the front of the header list.
|
||||||
|
@ -727,7 +730,10 @@ PJ_IDECL(void) pjsip_msg_add_hdr( pjsip_msg *msg, pjsip_hdr *hdr );
|
||||||
* @bug Once the header is put in a list (or message), it can not be put in
|
* @bug Once the header is put in a list (or message), it can not be put in
|
||||||
* other list (or message). Otherwise Real Bad Thing will happen.
|
* other list (or message). Otherwise Real Bad Thing will happen.
|
||||||
*/
|
*/
|
||||||
PJ_IDECL(void) pjsip_msg_insert_first_hdr( pjsip_msg *msg, pjsip_hdr *hdr );
|
PJ_INLINE(void) pjsip_msg_insert_first_hdr( pjsip_msg *msg, pjsip_hdr *hdr )
|
||||||
|
{
|
||||||
|
pj_list_insert_after(&msg->hdr, hdr);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print the message to the specified buffer.
|
* Print the message to the specified buffer.
|
||||||
|
@ -1551,13 +1557,6 @@ typedef pjsip_generic_string_hdr pjsip_warning_hdr;
|
||||||
* @} // PJSIP_MSG
|
* @} // PJSIP_MSG
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* Include inline definitions.
|
|
||||||
*/
|
|
||||||
#if PJ_FUNCTIONS_ARE_INLINED
|
|
||||||
# include <pjsip/sip_msg_i.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
PJ_END_DECL
|
PJ_END_DECL
|
||||||
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
/* $Id$ */
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
PJ_IDEF(void) pjsip_msg_add_hdr( pjsip_msg *msg, pjsip_hdr *hdr )
|
|
||||||
{
|
|
||||||
pj_list_insert_before(&msg->hdr, hdr);
|
|
||||||
}
|
|
||||||
|
|
||||||
PJ_IDEF(void) pjsip_msg_insert_first_hdr( pjsip_msg *msg, pjsip_hdr *hdr )
|
|
||||||
{
|
|
||||||
pj_list_insert_after(&msg->hdr, hdr);
|
|
||||||
}
|
|
||||||
|
|
|
@ -105,7 +105,10 @@ PJ_DECL(void) pjsip_param_shallow_clone(pj_pool_t *pool,
|
||||||
* @param size Size of buffer.
|
* @param size Size of buffer.
|
||||||
* @param pname_unres Specification of allowed characters in pname.
|
* @param pname_unres Specification of allowed characters in pname.
|
||||||
* @param pvalue_unres Specification of allowed characters in pvalue.
|
* @param pvalue_unres Specification of allowed characters in pvalue.
|
||||||
* @param sep Separator character (either ';' or ',').
|
* @param sep Separator character (either ';', ',', or '?').
|
||||||
|
* When separator is set to '?', this function will
|
||||||
|
* automatically adjust the separator character to
|
||||||
|
* '&' after the first parameter is printed.
|
||||||
*
|
*
|
||||||
* @return The number of bytes printed, or -1 on errr.
|
* @return The number of bytes printed, or -1 on errr.
|
||||||
*/
|
*/
|
||||||
|
@ -221,7 +224,7 @@ struct pjsip_uri
|
||||||
/**
|
/**
|
||||||
* SIP and SIPS URL scheme.
|
* SIP and SIPS URL scheme.
|
||||||
*/
|
*/
|
||||||
typedef struct pjsip_url
|
typedef struct pjsip_sip_uri
|
||||||
{
|
{
|
||||||
pjsip_uri_vptr *vptr; /**< Pointer to virtual function table.*/
|
pjsip_uri_vptr *vptr; /**< Pointer to virtual function table.*/
|
||||||
pj_str_t user; /**< Optional user part. */
|
pj_str_t user; /**< Optional user part. */
|
||||||
|
@ -236,7 +239,7 @@ typedef struct pjsip_url
|
||||||
pj_str_t maddr_param; /**< Optional maddr param */
|
pj_str_t maddr_param; /**< Optional maddr param */
|
||||||
pjsip_param other_param; /**< Other parameters grouped together. */
|
pjsip_param other_param; /**< Other parameters grouped together. */
|
||||||
pjsip_param header_param; /**< Optional header parameter. */
|
pjsip_param header_param; /**< Optional header parameter. */
|
||||||
} pjsip_url;
|
} pjsip_sip_uri;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -329,20 +332,20 @@ PJ_INLINE(void*) pjsip_uri_clone( pj_pool_t *pool, const void *uri )
|
||||||
* @param secure Tlag to indicate whether secure transport should be used.
|
* @param secure Tlag to indicate whether secure transport should be used.
|
||||||
* @return SIP URL.
|
* @return SIP URL.
|
||||||
*/
|
*/
|
||||||
PJ_DECL(pjsip_url*) pjsip_url_create( pj_pool_t *pool, int secure );
|
PJ_DECL(pjsip_sip_uri*) pjsip_url_create( pj_pool_t *pool, int secure );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new SIPS URL and initialize all fields with zero or NULL.
|
* Create new SIPS URL and initialize all fields with zero or NULL.
|
||||||
* @param pool The pool.
|
* @param pool The pool.
|
||||||
* @return SIPS URL.
|
* @return SIPS URL.
|
||||||
*/
|
*/
|
||||||
PJ_DECL(pjsip_url*) pjsips_url_create( pj_pool_t *pool );
|
PJ_DECL(pjsip_sip_uri*) pjsips_url_create( pj_pool_t *pool );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize SIP URL (all fields are set to NULL or zero).
|
* Initialize SIP URL (all fields are set to NULL or zero).
|
||||||
* @param url The URL.
|
* @param url The URL.
|
||||||
*/
|
*/
|
||||||
PJ_DECL(void) pjsip_url_init(pjsip_url *url, int secure);
|
PJ_DECL(void) pjsip_url_init(pjsip_sip_uri *url, int secure);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform full assignment to the SIP URL.
|
* Perform full assignment to the SIP URL.
|
||||||
|
@ -350,7 +353,8 @@ PJ_DECL(void) pjsip_url_init(pjsip_url *url, int secure);
|
||||||
* @param url Destination URL.
|
* @param url Destination URL.
|
||||||
* @param rhs The source URL.
|
* @param rhs The source URL.
|
||||||
*/
|
*/
|
||||||
PJ_DECL(void) pjsip_url_assign(pj_pool_t *pool, pjsip_url *url, const pjsip_url *rhs);
|
PJ_DECL(void) pjsip_url_assign(pj_pool_t *pool, pjsip_sip_uri *url,
|
||||||
|
const pjsip_sip_uri *rhs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new instance of name address and initialize all fields with zero or
|
* Create new instance of name address and initialize all fields with zero or
|
||||||
|
|
|
@ -412,7 +412,7 @@ pj_status_t pjsip_dlg_init_from_rdata( pjsip_dlg *dlg, pjsip_rx_data *rdata )
|
||||||
pjsip_to_hdr *to;
|
pjsip_to_hdr *to;
|
||||||
pjsip_contact_hdr *contact;
|
pjsip_contact_hdr *contact;
|
||||||
pjsip_name_addr *name_addr;
|
pjsip_name_addr *name_addr;
|
||||||
pjsip_url *url;
|
pjsip_sip_uri *url;
|
||||||
unsigned flag;
|
unsigned flag;
|
||||||
pjsip_event event;
|
pjsip_event event;
|
||||||
|
|
||||||
|
@ -445,7 +445,7 @@ pj_status_t pjsip_dlg_init_from_rdata( pjsip_dlg *dlg, pjsip_rx_data *rdata )
|
||||||
dlg->local.contact->star = 0;
|
dlg->local.contact->star = 0;
|
||||||
name_addr = (pjsip_name_addr *)dlg->local.info->uri;
|
name_addr = (pjsip_name_addr *)dlg->local.info->uri;
|
||||||
dlg->local.contact->uri = (pjsip_uri*) name_addr;
|
dlg->local.contact->uri = (pjsip_uri*) name_addr;
|
||||||
url = (pjsip_url*) name_addr->uri;
|
url = (pjsip_sip_uri*) name_addr->uri;
|
||||||
//url->port = rdata->via->sent_by.port;
|
//url->port = rdata->via->sent_by.port;
|
||||||
//url->port = pj_sockaddr_get_port( pjsip_transport_get_local_addr(rdata->transport) );
|
//url->port = pj_sockaddr_get_port( pjsip_transport_get_local_addr(rdata->transport) );
|
||||||
|
|
||||||
|
|
|
@ -24,13 +24,6 @@
|
||||||
#include <pj/pool.h>
|
#include <pj/pool.h>
|
||||||
#include <pj/assert.h>
|
#include <pj/assert.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* Include inline definitions here if functions are NOT inlined.
|
|
||||||
*/
|
|
||||||
#if PJ_FUNCTIONS_ARE_INLINED==0
|
|
||||||
# include <pjsip/sip_msg_i.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const pjsip_method
|
const pjsip_method
|
||||||
pjsip_invite_method = { PJSIP_INVITE_METHOD, { "INVITE",6 } },
|
pjsip_invite_method = { PJSIP_INVITE_METHOD, { "INVITE",6 } },
|
||||||
pjsip_cancel_method = { PJSIP_CANCEL_METHOD, { "CANCEL",6 } },
|
pjsip_cancel_method = { PJSIP_CANCEL_METHOD, { "CANCEL",6 } },
|
||||||
|
|
|
@ -154,7 +154,7 @@ static void int_parse_uri_host_port( pj_scanner *scanner,
|
||||||
static pjsip_uri * int_parse_uri_or_name_addr( pj_scanner *scanner,
|
static pjsip_uri * int_parse_uri_or_name_addr( pj_scanner *scanner,
|
||||||
pj_pool_t *pool,
|
pj_pool_t *pool,
|
||||||
unsigned option);
|
unsigned option);
|
||||||
static pjsip_url * int_parse_sip_url( pj_scanner *scanner,
|
static pjsip_sip_uri* int_parse_sip_url( pj_scanner *scanner,
|
||||||
pj_pool_t *pool,
|
pj_pool_t *pool,
|
||||||
pj_bool_t parse_params);
|
pj_bool_t parse_params);
|
||||||
static pjsip_name_addr *
|
static pjsip_name_addr *
|
||||||
|
@ -953,9 +953,14 @@ void pjsip_parse_param_imp( pj_scanner *scanner, pj_pool_t *pool,
|
||||||
pj_scan_get(scanner, &pjsip_PARAM_CHAR_SPEC, pname);
|
pj_scan_get(scanner, &pjsip_PARAM_CHAR_SPEC, pname);
|
||||||
*pname = pj_str_unescape(pool, pname);
|
*pname = pj_str_unescape(pool, pname);
|
||||||
|
|
||||||
|
/* init pvalue */
|
||||||
|
pvalue->ptr = NULL;
|
||||||
|
pvalue->slen = 0;
|
||||||
|
|
||||||
/* pvalue, if any */
|
/* pvalue, if any */
|
||||||
if (*scanner->curptr == '=') {
|
if (*scanner->curptr == '=') {
|
||||||
pj_scan_get_char(scanner);
|
pj_scan_get_char(scanner);
|
||||||
|
if (!pj_scan_is_eof(scanner)) {
|
||||||
/* pvalue can be a quoted string. */
|
/* pvalue can be a quoted string. */
|
||||||
if (*scanner->curptr == '"') {
|
if (*scanner->curptr == '"') {
|
||||||
pj_scan_get_quote( scanner, '"', '"', pvalue);
|
pj_scan_get_quote( scanner, '"', '"', pvalue);
|
||||||
|
@ -963,13 +968,11 @@ void pjsip_parse_param_imp( pj_scanner *scanner, pj_pool_t *pool,
|
||||||
pvalue->ptr++;
|
pvalue->ptr++;
|
||||||
pvalue->slen -= 2;
|
pvalue->slen -= 2;
|
||||||
}
|
}
|
||||||
} else {
|
} else if(pj_cis_match(&pjsip_PARAM_CHAR_SPEC, *scanner->curptr)) {
|
||||||
pj_scan_get(scanner, &pjsip_PARAM_CHAR_SPEC, pvalue);
|
pj_scan_get(scanner, &pjsip_PARAM_CHAR_SPEC, pvalue);
|
||||||
*pvalue = pj_str_unescape(pool, pvalue);
|
*pvalue = pj_str_unescape(pool, pvalue);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
pvalue->ptr = NULL;
|
|
||||||
pvalue->slen = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -996,14 +999,19 @@ static void int_parse_hparam( pj_scanner *scanner, pj_pool_t *pool,
|
||||||
pj_scan_get(scanner, &pjsip_HDR_CHAR_SPEC, hname);
|
pj_scan_get(scanner, &pjsip_HDR_CHAR_SPEC, hname);
|
||||||
*hname = pj_str_unescape(pool, hname);
|
*hname = pj_str_unescape(pool, hname);
|
||||||
|
|
||||||
|
/* Init hvalue */
|
||||||
|
hvalue->ptr = NULL;
|
||||||
|
hvalue->slen = 0;
|
||||||
|
|
||||||
/* pvalue, if any */
|
/* pvalue, if any */
|
||||||
if (*scanner->curptr == '=') {
|
if (*scanner->curptr == '=') {
|
||||||
pj_scan_get_char(scanner);
|
pj_scan_get_char(scanner);
|
||||||
|
if (!pj_scan_is_eof(scanner) &&
|
||||||
|
pj_cis_match(&pjsip_HDR_CHAR_SPEC, *scanner->curptr))
|
||||||
|
{
|
||||||
pj_scan_get(scanner, &pjsip_HDR_CHAR_SPEC, hvalue);
|
pj_scan_get(scanner, &pjsip_HDR_CHAR_SPEC, hvalue);
|
||||||
*hvalue = pj_str_unescape(pool, hvalue);
|
*hvalue = pj_str_unescape(pool, hvalue);
|
||||||
} else {
|
}
|
||||||
hvalue->ptr = NULL;
|
|
||||||
hvalue->slen = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1142,12 +1150,12 @@ static pjsip_uri *int_parse_uri(pj_scanner *scanner, pj_pool_t *pool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse "sip:" and "sips:" URI. */
|
/* Parse "sip:" and "sips:" URI. */
|
||||||
static pjsip_url *int_parse_sip_url( pj_scanner *scanner,
|
static pjsip_sip_uri *int_parse_sip_url( pj_scanner *scanner,
|
||||||
pj_pool_t *pool,
|
pj_pool_t *pool,
|
||||||
pj_bool_t parse_params)
|
pj_bool_t parse_params)
|
||||||
{
|
{
|
||||||
pj_str_t scheme;
|
pj_str_t scheme;
|
||||||
pjsip_url *url = NULL;
|
pjsip_sip_uri *url = NULL;
|
||||||
int colon;
|
int colon;
|
||||||
int skip_ws = scanner->skip_ws;
|
int skip_ws = scanner->skip_ws;
|
||||||
scanner->skip_ws = 0;
|
scanner->skip_ws = 0;
|
||||||
|
|
|
@ -499,20 +499,29 @@ PJ_DEF(pj_status_t) pjsip_tsx_layer_destroy(void)
|
||||||
/*
|
/*
|
||||||
* Register the transaction to the hash table.
|
* Register the transaction to the hash table.
|
||||||
*/
|
*/
|
||||||
static void mod_tsx_layer_register_tsx( pjsip_transaction *tsx)
|
static pj_status_t mod_tsx_layer_register_tsx( pjsip_transaction *tsx)
|
||||||
{
|
{
|
||||||
pj_assert(tsx->transaction_key.slen != 0);
|
pj_assert(tsx->transaction_key.slen != 0);
|
||||||
//pj_assert(tsx->state != PJSIP_TSX_STATE_NULL);
|
|
||||||
|
|
||||||
/* Lock hash table mutex. */
|
/* Lock hash table mutex. */
|
||||||
pj_mutex_lock(mod_tsx_layer.mutex);
|
pj_mutex_lock(mod_tsx_layer.mutex);
|
||||||
|
|
||||||
|
/* Check if no transaction with the same key exists. */
|
||||||
|
if (pj_hash_get( mod_tsx_layer.htable, &tsx->transaction_key.ptr,
|
||||||
|
tsx->transaction_key.slen) != NULL)
|
||||||
|
{
|
||||||
|
pj_mutex_unlock(mod_tsx_layer.mutex);
|
||||||
|
return PJ_EEXISTS;
|
||||||
|
}
|
||||||
|
|
||||||
/* Register the transaction to the hash table. */
|
/* Register the transaction to the hash table. */
|
||||||
pj_hash_set( tsx->pool, mod_tsx_layer.htable, tsx->transaction_key.ptr,
|
pj_hash_set( tsx->pool, mod_tsx_layer.htable, tsx->transaction_key.ptr,
|
||||||
tsx->transaction_key.slen, tsx);
|
tsx->transaction_key.slen, tsx);
|
||||||
|
|
||||||
/* Unlock mutex. */
|
/* Unlock mutex. */
|
||||||
pj_mutex_unlock(mod_tsx_layer.mutex);
|
pj_mutex_unlock(mod_tsx_layer.mutex);
|
||||||
|
|
||||||
|
return PJ_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1050,7 +1059,12 @@ PJ_DEF(pj_status_t) pjsip_tsx_create_uac( pjsip_module *tsx_user,
|
||||||
tsx->is_reliable = (dst_info.flag & PJSIP_TRANSPORT_RELIABLE);
|
tsx->is_reliable = (dst_info.flag & PJSIP_TRANSPORT_RELIABLE);
|
||||||
|
|
||||||
/* Register transaction to hash table. */
|
/* Register transaction to hash table. */
|
||||||
mod_tsx_layer_register_tsx(tsx);
|
status = mod_tsx_layer_register_tsx(tsx);
|
||||||
|
if (status != PJ_SUCCESS) {
|
||||||
|
pj_assert(!"Bug in branch_param generator (i.e. not unique)");
|
||||||
|
tsx_destroy(tsx);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Unlock transaction and return. */
|
/* Unlock transaction and return. */
|
||||||
|
@ -1159,8 +1173,11 @@ PJ_DEF(pj_status_t) pjsip_tsx_create_uas( pjsip_module *tsx_user,
|
||||||
|
|
||||||
|
|
||||||
/* Register the transaction. */
|
/* Register the transaction. */
|
||||||
mod_tsx_layer_register_tsx(tsx);
|
status = mod_tsx_layer_register_tsx(tsx);
|
||||||
|
if (status != PJ_SUCCESS) {
|
||||||
|
tsx_destroy(tsx);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
/* Unlock transaction and return. */
|
/* Unlock transaction and return. */
|
||||||
unlock_tsx(tsx, &lck);
|
unlock_tsx(tsx, &lck);
|
||||||
|
@ -1540,8 +1557,16 @@ static void tsx_resched_retransmission( pjsip_transaction *tsx )
|
||||||
|
|
||||||
msec_time = (1 << (tsx->retransmit_count)) * PJSIP_T1_TIMEOUT;
|
msec_time = (1 << (tsx->retransmit_count)) * PJSIP_T1_TIMEOUT;
|
||||||
|
|
||||||
|
if (tsx->role == PJSIP_ROLE_UAC) {
|
||||||
|
/* Retransmission for non-INVITE transaction caps-off at T2 */
|
||||||
if (msec_time>PJSIP_T2_TIMEOUT && tsx->method.id!=PJSIP_INVITE_METHOD)
|
if (msec_time>PJSIP_T2_TIMEOUT && tsx->method.id!=PJSIP_INVITE_METHOD)
|
||||||
msec_time = PJSIP_T2_TIMEOUT;
|
msec_time = PJSIP_T2_TIMEOUT;
|
||||||
|
} else {
|
||||||
|
/* Retransmission of INVITE final response also caps-off at T2 */
|
||||||
|
pj_assert(tsx->status_code >= 200);
|
||||||
|
if (msec_time>PJSIP_T2_TIMEOUT)
|
||||||
|
msec_time = PJSIP_T2_TIMEOUT;
|
||||||
|
}
|
||||||
|
|
||||||
timeout.sec = msec_time / 1000;
|
timeout.sec = msec_time / 1000;
|
||||||
timeout.msec = msec_time % 1000;
|
timeout.msec = msec_time % 1000;
|
||||||
|
|
|
@ -347,7 +347,8 @@ static char *get_msg_info(pj_pool_t *pool, const char *obj_name,
|
||||||
PJ_DEF(char*) pjsip_tx_data_get_info( pjsip_tx_data *tdata )
|
PJ_DEF(char*) pjsip_tx_data_get_info( pjsip_tx_data *tdata )
|
||||||
{
|
{
|
||||||
|
|
||||||
PJ_ASSERT_RETURN(tdata && tdata->msg, "INVALID MSG");
|
if (tdata==NULL || tdata->msg==NULL)
|
||||||
|
return "INVALID MSG";
|
||||||
|
|
||||||
if (tdata->info)
|
if (tdata->info)
|
||||||
return tdata->info;
|
return tdata->info;
|
||||||
|
|
|
@ -111,6 +111,7 @@ PJ_DEF(pj_ssize_t) pjsip_param_print_on( const pjsip_param *param_list,
|
||||||
copy_advance_escape(buf, p->value, (*pvalue_spec));
|
copy_advance_escape(buf, p->value, (*pvalue_spec));
|
||||||
}
|
}
|
||||||
p = p->next;
|
p = p->next;
|
||||||
|
if (sep == '?') sep = '&';
|
||||||
} while (p != param_list);
|
} while (p != param_list);
|
||||||
|
|
||||||
return buf-startbuf;
|
return buf-startbuf;
|
||||||
|
@ -122,8 +123,8 @@ PJ_DEF(pj_ssize_t) pjsip_param_print_on( const pjsip_param *param_list,
|
||||||
*/
|
*/
|
||||||
#define IS_SIPS(url) ((url)->vptr==&sips_url_vptr)
|
#define IS_SIPS(url) ((url)->vptr==&sips_url_vptr)
|
||||||
|
|
||||||
static const pj_str_t *pjsip_url_get_scheme( const pjsip_url* );
|
static const pj_str_t *pjsip_url_get_scheme( const pjsip_sip_uri* );
|
||||||
static const pj_str_t *pjsips_url_get_scheme( const pjsip_url* );
|
static const pj_str_t *pjsips_url_get_scheme( const pjsip_sip_uri* );
|
||||||
static const pj_str_t *pjsip_name_addr_get_scheme( const pjsip_name_addr * );
|
static const pj_str_t *pjsip_name_addr_get_scheme( const pjsip_name_addr * );
|
||||||
static void *pjsip_get_uri( pjsip_uri *uri );
|
static void *pjsip_get_uri( pjsip_uri *uri );
|
||||||
static void *pjsip_name_addr_get_uri( pjsip_name_addr *name );
|
static void *pjsip_name_addr_get_uri( pjsip_name_addr *name );
|
||||||
|
@ -146,11 +147,13 @@ static int pjsip_name_addr_compare( pjsip_uri_context_e context,
|
||||||
const pjsip_name_addr *naddr1,
|
const pjsip_name_addr *naddr1,
|
||||||
const pjsip_name_addr *naddr2);
|
const pjsip_name_addr *naddr2);
|
||||||
static int pjsip_url_print( pjsip_uri_context_e context,
|
static int pjsip_url_print( pjsip_uri_context_e context,
|
||||||
const pjsip_url *url,
|
const pjsip_sip_uri *url,
|
||||||
char *buf, pj_size_t size);
|
char *buf, pj_size_t size);
|
||||||
static int pjsip_url_compare( pjsip_uri_context_e context,
|
static int pjsip_url_compare( pjsip_uri_context_e context,
|
||||||
const pjsip_url *url1, const pjsip_url *url2);
|
const pjsip_sip_uri *url1,
|
||||||
static pjsip_url* pjsip_url_clone(pj_pool_t *pool, const pjsip_url *rhs);
|
const pjsip_sip_uri *url2);
|
||||||
|
static pjsip_sip_uri* pjsip_url_clone(pj_pool_t *pool,
|
||||||
|
const pjsip_sip_uri *rhs);
|
||||||
|
|
||||||
static pjsip_uri_vptr sip_url_vptr =
|
static pjsip_uri_vptr sip_url_vptr =
|
||||||
{
|
{
|
||||||
|
@ -179,13 +182,13 @@ static pjsip_uri_vptr name_addr_vptr =
|
||||||
HAPPY_FLAG &pjsip_name_addr_clone
|
HAPPY_FLAG &pjsip_name_addr_clone
|
||||||
};
|
};
|
||||||
|
|
||||||
static const pj_str_t *pjsip_url_get_scheme(const pjsip_url *url)
|
static const pj_str_t *pjsip_url_get_scheme(const pjsip_sip_uri *url)
|
||||||
{
|
{
|
||||||
PJ_UNUSED_ARG(url);
|
PJ_UNUSED_ARG(url);
|
||||||
return &sip_str;
|
return &sip_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const pj_str_t *pjsips_url_get_scheme(const pjsip_url *url)
|
static const pj_str_t *pjsips_url_get_scheme(const pjsip_sip_uri *url)
|
||||||
{
|
{
|
||||||
PJ_UNUSED_ARG(url);
|
PJ_UNUSED_ARG(url);
|
||||||
return &sips_str;
|
return &sips_str;
|
||||||
|
@ -201,7 +204,7 @@ static void *pjsip_name_addr_get_uri( pjsip_name_addr *name )
|
||||||
return name->uri;
|
return name->uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
PJ_DEF(void) pjsip_url_init(pjsip_url *url, int secure)
|
PJ_DEF(void) pjsip_url_init(pjsip_sip_uri *url, int secure)
|
||||||
{
|
{
|
||||||
pj_memset(url, 0, sizeof(*url));
|
pj_memset(url, 0, sizeof(*url));
|
||||||
url->ttl_param = -1;
|
url->ttl_param = -1;
|
||||||
|
@ -210,23 +213,21 @@ PJ_DEF(void) pjsip_url_init(pjsip_url *url, int secure)
|
||||||
pj_list_init(&url->header_param);
|
pj_list_init(&url->header_param);
|
||||||
}
|
}
|
||||||
|
|
||||||
PJ_DEF(pjsip_url*) pjsip_url_create( pj_pool_t *pool, int secure )
|
PJ_DEF(pjsip_sip_uri*) pjsip_url_create( pj_pool_t *pool, int secure )
|
||||||
{
|
{
|
||||||
pjsip_url *url = pj_pool_alloc(pool, sizeof(pjsip_url));
|
pjsip_sip_uri *url = pj_pool_alloc(pool, sizeof(pjsip_sip_uri));
|
||||||
pjsip_url_init(url, secure);
|
pjsip_url_init(url, secure);
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pjsip_url_print( pjsip_uri_context_e context,
|
static int pjsip_url_print( pjsip_uri_context_e context,
|
||||||
const pjsip_url *url,
|
const pjsip_sip_uri *url,
|
||||||
char *buf, pj_size_t size)
|
char *buf, pj_size_t size)
|
||||||
{
|
{
|
||||||
int printed;
|
int printed;
|
||||||
char *startbuf = buf;
|
char *startbuf = buf;
|
||||||
char *endbuf = buf+size;
|
char *endbuf = buf+size;
|
||||||
const pj_str_t *scheme;
|
const pj_str_t *scheme;
|
||||||
pjsip_param *param;
|
|
||||||
char hparam_char = '?';
|
|
||||||
|
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
|
|
||||||
|
@ -317,19 +318,18 @@ static int pjsip_url_print( pjsip_uri_context_e context,
|
||||||
return -1;
|
return -1;
|
||||||
buf += printed;
|
buf += printed;
|
||||||
|
|
||||||
/* Header param. */
|
/* Header param.
|
||||||
param = url->header_param.next;
|
* Header param is only allowed in these contexts:
|
||||||
while (param != &url->header_param) {
|
* - PJSIP_URI_IN_CONTACT_HDR
|
||||||
if (endbuf - buf < param->name.slen+2)
|
* - PJSIP_URI_IN_OTHER
|
||||||
|
*/
|
||||||
|
if (context == PJSIP_URI_IN_CONTACT_HDR || context == PJSIP_URI_IN_OTHER) {
|
||||||
|
printed = pjsip_param_print_on(&url->header_param, buf, endbuf-buf,
|
||||||
|
&pjsip_HDR_CHAR_SPEC,
|
||||||
|
&pjsip_HDR_CHAR_SPEC, '?');
|
||||||
|
if (printed < 0)
|
||||||
return -1;
|
return -1;
|
||||||
*buf++ = hparam_char;
|
buf += printed;
|
||||||
copy_advance_escape(buf, param->name, pjsip_HDR_CHAR_SPEC);
|
|
||||||
if (param->value.slen) {
|
|
||||||
*buf++ = '=';
|
|
||||||
copy_advance_escape(buf, param->value, pjsip_HDR_CHAR_SPEC);
|
|
||||||
}
|
|
||||||
param = param->next;
|
|
||||||
hparam_char = '&';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
|
@ -337,8 +337,8 @@ static int pjsip_url_print( pjsip_uri_context_e context,
|
||||||
}
|
}
|
||||||
|
|
||||||
static pj_status_t pjsip_url_compare( pjsip_uri_context_e context,
|
static pj_status_t pjsip_url_compare( pjsip_uri_context_e context,
|
||||||
const pjsip_url *url1,
|
const pjsip_sip_uri *url1,
|
||||||
const pjsip_url *url2)
|
const pjsip_sip_uri *url2)
|
||||||
{
|
{
|
||||||
const pjsip_param *p1;
|
const pjsip_param *p1;
|
||||||
|
|
||||||
|
@ -465,8 +465,8 @@ static pj_status_t pjsip_url_compare( pjsip_uri_context_e context,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PJ_DEF(void) pjsip_url_assign(pj_pool_t *pool, pjsip_url *url,
|
PJ_DEF(void) pjsip_url_assign(pj_pool_t *pool, pjsip_sip_uri *url,
|
||||||
const pjsip_url *rhs)
|
const pjsip_sip_uri *rhs)
|
||||||
{
|
{
|
||||||
pj_strdup( pool, &url->user, &rhs->user);
|
pj_strdup( pool, &url->user, &rhs->user);
|
||||||
pj_strdup( pool, &url->passwd, &rhs->passwd);
|
pj_strdup( pool, &url->passwd, &rhs->passwd);
|
||||||
|
@ -482,9 +482,9 @@ PJ_DEF(void) pjsip_url_assign(pj_pool_t *pool, pjsip_url *url,
|
||||||
url->lr_param = rhs->lr_param;
|
url->lr_param = rhs->lr_param;
|
||||||
}
|
}
|
||||||
|
|
||||||
static pjsip_url* pjsip_url_clone(pj_pool_t *pool, const pjsip_url *rhs)
|
static pjsip_sip_uri* pjsip_url_clone(pj_pool_t *pool, const pjsip_sip_uri *rhs)
|
||||||
{
|
{
|
||||||
pjsip_url *url = pj_pool_alloc(pool, sizeof(pjsip_url));
|
pjsip_sip_uri *url = pj_pool_alloc(pool, sizeof(pjsip_sip_uri));
|
||||||
if (!url)
|
if (!url)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -112,11 +112,30 @@ static void init_request_throw( pjsip_endpoint *endpt,
|
||||||
/* Add CSeq header. */
|
/* Add CSeq header. */
|
||||||
pjsip_msg_add_hdr(msg, (void*)param_cseq);
|
pjsip_msg_add_hdr(msg, (void*)param_cseq);
|
||||||
|
|
||||||
/* Add a blank Via header. */
|
/* Add a blank Via header in the front of the message. */
|
||||||
via = pjsip_via_hdr_create(tdata->pool);
|
via = pjsip_via_hdr_create(tdata->pool);
|
||||||
via->rport_param = 0;
|
via->rport_param = 0;
|
||||||
pjsip_msg_insert_first_hdr(msg, (void*)via);
|
pjsip_msg_insert_first_hdr(msg, (void*)via);
|
||||||
|
|
||||||
|
/* Add header params as request headers */
|
||||||
|
if (PJSIP_URI_SCHEME_IS_SIP(param_target) ||
|
||||||
|
PJSIP_URI_SCHEME_IS_SIPS(param_target))
|
||||||
|
{
|
||||||
|
pjsip_sip_uri *uri = (pjsip_sip_uri*) pjsip_uri_get_uri(param_target);
|
||||||
|
pjsip_param *hparam;
|
||||||
|
|
||||||
|
hparam = uri->header_param.next;
|
||||||
|
while (hparam != &uri->header_param) {
|
||||||
|
pjsip_generic_string_hdr *hdr;
|
||||||
|
|
||||||
|
hdr = pjsip_generic_string_hdr_create_with_text(tdata->pool,
|
||||||
|
&hparam->name,
|
||||||
|
&hparam->value);
|
||||||
|
pjsip_msg_add_hdr(msg, (pjsip_hdr*)hdr);
|
||||||
|
hparam = hparam->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Create message body. */
|
/* Create message body. */
|
||||||
if (param_text) {
|
if (param_text) {
|
||||||
body = pj_pool_calloc(tdata->pool, 1, sizeof(pjsip_msg_body));
|
body = pj_pool_calloc(tdata->pool, 1, sizeof(pjsip_msg_body));
|
||||||
|
@ -636,7 +655,8 @@ PJ_DEF(pj_status_t) pjsip_get_request_addr( pjsip_tx_data *tdata,
|
||||||
if (PJSIP_URI_SCHEME_IS_SIP(topmost_route_uri) ||
|
if (PJSIP_URI_SCHEME_IS_SIP(topmost_route_uri) ||
|
||||||
PJSIP_URI_SCHEME_IS_SIPS(topmost_route_uri))
|
PJSIP_URI_SCHEME_IS_SIPS(topmost_route_uri))
|
||||||
{
|
{
|
||||||
const pjsip_url *url = pjsip_uri_get_uri((void*)topmost_route_uri);
|
const pjsip_sip_uri *url =
|
||||||
|
pjsip_uri_get_uri((void*)topmost_route_uri);
|
||||||
has_lr_param = url->lr_param;
|
has_lr_param = url->lr_param;
|
||||||
} else {
|
} else {
|
||||||
has_lr_param = 0;
|
has_lr_param = 0;
|
||||||
|
@ -673,7 +693,7 @@ PJ_DEF(pj_status_t) pjsip_get_request_addr( pjsip_tx_data *tdata,
|
||||||
|
|
||||||
if (PJSIP_URI_SCHEME_IS_SIPS(target_uri)) {
|
if (PJSIP_URI_SCHEME_IS_SIPS(target_uri)) {
|
||||||
pjsip_uri *uri = (pjsip_uri*) target_uri;
|
pjsip_uri *uri = (pjsip_uri*) target_uri;
|
||||||
const pjsip_url *url = (const pjsip_url*)pjsip_uri_get_uri(uri);
|
const pjsip_sip_uri *url=(const pjsip_sip_uri*)pjsip_uri_get_uri(uri);
|
||||||
dest_info->flag |= (PJSIP_TRANSPORT_SECURE | PJSIP_TRANSPORT_RELIABLE);
|
dest_info->flag |= (PJSIP_TRANSPORT_SECURE | PJSIP_TRANSPORT_RELIABLE);
|
||||||
pj_strdup(tdata->pool, &dest_info->addr.host, &url->host);
|
pj_strdup(tdata->pool, &dest_info->addr.host, &url->host);
|
||||||
dest_info->addr.port = url->port;
|
dest_info->addr.port = url->port;
|
||||||
|
@ -682,7 +702,7 @@ PJ_DEF(pj_status_t) pjsip_get_request_addr( pjsip_tx_data *tdata,
|
||||||
|
|
||||||
} else if (PJSIP_URI_SCHEME_IS_SIP(target_uri)) {
|
} else if (PJSIP_URI_SCHEME_IS_SIP(target_uri)) {
|
||||||
pjsip_uri *uri = (pjsip_uri*) target_uri;
|
pjsip_uri *uri = (pjsip_uri*) target_uri;
|
||||||
const pjsip_url *url = (const pjsip_url*)pjsip_uri_get_uri(uri);
|
const pjsip_sip_uri *url=(const pjsip_sip_uri*)pjsip_uri_get_uri(uri);
|
||||||
pj_strdup(tdata->pool, &dest_info->addr.host, &url->host);
|
pj_strdup(tdata->pool, &dest_info->addr.host, &url->host);
|
||||||
dest_info->addr.port = url->port;
|
dest_info->addr.port = url->port;
|
||||||
dest_info->type =
|
dest_info->type =
|
||||||
|
|
|
@ -1108,7 +1108,7 @@ static pj_status_t init_stack()
|
||||||
uri = pjsip_parse_uri(pool, global.local_uri.ptr, global.local_uri.slen, 0);
|
uri = pjsip_parse_uri(pool, global.local_uri.ptr, global.local_uri.slen, 0);
|
||||||
if (uri) {
|
if (uri) {
|
||||||
if (pj_stricmp2(pjsip_uri_get_scheme(uri), "sip")==0) {
|
if (pj_stricmp2(pjsip_uri_get_scheme(uri), "sip")==0) {
|
||||||
pjsip_url *url = (pjsip_url*)pjsip_uri_get_uri(uri);
|
pjsip_sip_uri *url = (pjsip_sip_uri*)pjsip_uri_get_uri(uri);
|
||||||
if (url->user.slen)
|
if (url->user.slen)
|
||||||
strncpy(global.user_id, url->user.ptr, url->user.slen);
|
strncpy(global.user_id, url->user.ptr, url->user.slen);
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,7 +332,7 @@ static pjsip_msg *create_msg0(pj_pool_t *pool)
|
||||||
|
|
||||||
pjsip_msg *msg;
|
pjsip_msg *msg;
|
||||||
pjsip_name_addr *name_addr;
|
pjsip_name_addr *name_addr;
|
||||||
pjsip_url *url;
|
pjsip_sip_uri *url;
|
||||||
pjsip_fromto_hdr *fromto;
|
pjsip_fromto_hdr *fromto;
|
||||||
pjsip_cid_hdr *cid;
|
pjsip_cid_hdr *cid;
|
||||||
pjsip_clen_hdr *clen;
|
pjsip_clen_hdr *clen;
|
||||||
|
@ -537,7 +537,7 @@ static pjsip_msg *create_msg1(pj_pool_t *pool)
|
||||||
pjsip_via_hdr *via;
|
pjsip_via_hdr *via;
|
||||||
pjsip_route_hdr *route;
|
pjsip_route_hdr *route;
|
||||||
pjsip_name_addr *name_addr;
|
pjsip_name_addr *name_addr;
|
||||||
pjsip_url *url;
|
pjsip_sip_uri *url;
|
||||||
pjsip_max_forwards_hdr *max_fwd;
|
pjsip_max_forwards_hdr *max_fwd;
|
||||||
pjsip_to_hdr *to;
|
pjsip_to_hdr *to;
|
||||||
pjsip_from_hdr *from;
|
pjsip_from_hdr *from;
|
||||||
|
|
|
@ -45,24 +45,31 @@
|
||||||
**
|
**
|
||||||
** TEST4_BRANCH_ID
|
** TEST4_BRANCH_ID
|
||||||
** Transaction retransmits last response (if any) without notifying
|
** Transaction retransmits last response (if any) without notifying
|
||||||
** transaction user upon receiving request retransmissions on:
|
** transaction user upon receiving request retransmissions on TRYING
|
||||||
** a. TRYING state.
|
** state
|
||||||
** a. PROCEEDING state.
|
|
||||||
** b. COMPLETED state.
|
|
||||||
**
|
**
|
||||||
** TEST5_BRANCH_ID
|
** TEST5_BRANCH_ID
|
||||||
** INVITE transaction MUST retransmit final response. (Note: PJSIP also
|
** As above, in PROCEEDING state.
|
||||||
** retransmit 2xx final response until it's terminated by user).
|
|
||||||
**
|
**
|
||||||
** TEST6_BRANCH_ID
|
** TEST6_BRANCH_ID
|
||||||
** INVITE transaction MUST cease retransmission of final response when
|
** As above, in COMPLETED state, with first sending provisional response.
|
||||||
* ACK is received. (Note: PJSIP also retransmit 2xx final response
|
|
||||||
* until it's terminated by user).
|
|
||||||
**
|
**
|
||||||
** TEST7_BRANCH_ID
|
** TEST7_BRANCH_ID
|
||||||
** Test where INVITE UAS transaction never receives ACK
|
** INVITE transaction MUST retransmit non-2xx final response.
|
||||||
**
|
**
|
||||||
** TEST8_BRANCH_ID
|
** TEST8_BRANCH_ID
|
||||||
|
** As above, for INVITE's 2xx final response (this is PJSIP specific).
|
||||||
|
**
|
||||||
|
** TEST9_BRANCH_ID
|
||||||
|
** INVITE transaction MUST cease retransmission of final response when
|
||||||
|
** ACK is received. (Note: PJSIP also retransmit 2xx final response
|
||||||
|
** until it's terminated by user).
|
||||||
|
** Transaction also MUST terminate in T4 seconds.
|
||||||
|
**
|
||||||
|
** TEST10_BRANCH_ID
|
||||||
|
** Test where INVITE UAS transaction never receives ACK
|
||||||
|
**
|
||||||
|
** TEST11_BRANCH_ID
|
||||||
** When UAS failed to deliver the response with the selected transport,
|
** When UAS failed to deliver the response with the selected transport,
|
||||||
** it should try contacting the client with other transport or begin
|
** it should try contacting the client with other transport or begin
|
||||||
** RFC 3263 server resolution procedure.
|
** RFC 3263 server resolution procedure.
|
||||||
|
@ -72,7 +79,7 @@
|
||||||
** upon receiving request retransmission).
|
** upon receiving request retransmission).
|
||||||
** c. COMPLETED state.
|
** c. COMPLETED state.
|
||||||
**
|
**
|
||||||
** TEST9_BRANCH_ID
|
** TEST12_BRANCH_ID
|
||||||
** Variant of previous test, where transaction fails to deliver the
|
** Variant of previous test, where transaction fails to deliver the
|
||||||
** response using any kind of transports. Transaction should report
|
** response using any kind of transports. Transaction should report
|
||||||
** transport error to its transaction user.
|
** transport error to its transaction user.
|
||||||
|
@ -86,13 +93,38 @@ static char *TEST4_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test4";
|
||||||
static char *TEST5_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test5";
|
static char *TEST5_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test5";
|
||||||
static char *TEST6_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test6";
|
static char *TEST6_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test6";
|
||||||
static char *TEST7_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test7";
|
static char *TEST7_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test7";
|
||||||
|
static char *TEST8_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test8";
|
||||||
|
static char *TEST9_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test9";
|
||||||
|
static char *TEST10_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test10";
|
||||||
|
static char *TEST11_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test11";
|
||||||
|
static char *TEST12_BRANCH_ID = PJSIP_RFC3261_BRANCH_ID "-UAS-Test12";
|
||||||
|
|
||||||
#define TEST1_STATUS_CODE 200
|
#define TEST1_STATUS_CODE 200
|
||||||
#define TEST2_STATUS_CODE 301
|
#define TEST2_STATUS_CODE 301
|
||||||
#define TEST3_PROVISIONAL_CODE PJSIP_SC_QUEUED
|
#define TEST3_PROVISIONAL_CODE PJSIP_SC_QUEUED
|
||||||
#define TEST3_STATUS_CODE 202
|
#define TEST3_STATUS_CODE 202
|
||||||
|
#define TEST4_STATUS_CODE 200
|
||||||
|
#define TEST4_REQUEST_COUNT 2
|
||||||
|
#define TEST5_PROVISIONAL_CODE 100
|
||||||
|
#define TEST5_STATUS_CODE 200
|
||||||
|
#define TEST5_REQUEST_COUNT 2
|
||||||
|
#define TEST5_RESPONSE_COUNT 2
|
||||||
|
#define TEST6_PROVISIONAL_CODE 100
|
||||||
|
#define TEST6_STATUS_CODE 200 /* Must be final */
|
||||||
|
#define TEST6_REQUEST_COUNT 2
|
||||||
|
#define TEST6_RESPONSE_COUNT 3
|
||||||
|
#define TEST7_STATUS_CODE 301
|
||||||
|
#define TEST8_STATUS_CODE 302
|
||||||
|
|
||||||
|
|
||||||
|
#define TEST4_TITLE "test4: absorbing request retransmission"
|
||||||
|
#define TEST5_TITLE "test5: retransmit last response in PROCEEDING state"
|
||||||
|
#define TEST6_TITLE "test6: retransmit last response in COMPLETED state"
|
||||||
|
|
||||||
|
|
||||||
|
#define TEST_TIMEOUT_ERROR -30
|
||||||
|
#define MAX_ALLOWED_DIFF 150
|
||||||
|
|
||||||
static void tsx_user_on_tsx_state(pjsip_transaction *tsx, pjsip_event *e);
|
static void tsx_user_on_tsx_state(pjsip_transaction *tsx, pjsip_event *e);
|
||||||
static pj_bool_t on_rx_message(pjsip_rx_data *rdata);
|
static pj_bool_t on_rx_message(pjsip_rx_data *rdata);
|
||||||
|
|
||||||
|
@ -161,6 +193,7 @@ struct response
|
||||||
pjsip_tx_data *tdata;
|
pjsip_tx_data *tdata;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Timer callback to send response. */
|
||||||
static void send_response_timer( pj_timer_heap_t *timer_heap,
|
static void send_response_timer( pj_timer_heap_t *timer_heap,
|
||||||
struct pj_timer_entry *entry)
|
struct pj_timer_entry *entry)
|
||||||
{
|
{
|
||||||
|
@ -183,6 +216,31 @@ static void send_response_timer( pj_timer_heap_t *timer_heap,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Utility to send response. */
|
||||||
|
static void send_response( pjsip_rx_data *rdata,
|
||||||
|
pjsip_transaction *tsx,
|
||||||
|
int status_code )
|
||||||
|
{
|
||||||
|
pj_status_t status;
|
||||||
|
pjsip_tx_data *tdata;
|
||||||
|
|
||||||
|
status = pjsip_endpt_create_response( endpt, rdata, status_code, NULL,
|
||||||
|
&tdata);
|
||||||
|
if (status != PJ_SUCCESS) {
|
||||||
|
app_perror(" error: unable to create response", status);
|
||||||
|
test_complete = -196;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = pjsip_tsx_send_msg(tsx, tdata);
|
||||||
|
if (status != PJ_SUCCESS) {
|
||||||
|
app_perror(" error: unable to send response", status);
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
test_complete = -197;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Schedule timer to send response for the specified UAS transaction */
|
/* Schedule timer to send response for the specified UAS transaction */
|
||||||
static void schedule_send_response( pjsip_rx_data *rdata,
|
static void schedule_send_response( pjsip_rx_data *rdata,
|
||||||
const pj_str_t *tsx_key,
|
const pj_str_t *tsx_key,
|
||||||
|
@ -222,6 +280,49 @@ static void schedule_send_response( pjsip_rx_data *rdata,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Find and terminate tsx with the specified key. */
|
||||||
|
static void terminate_our_tsx(int status_code)
|
||||||
|
{
|
||||||
|
pjsip_transaction *tsx;
|
||||||
|
|
||||||
|
tsx = pjsip_tsx_layer_find_tsx(&tsx_key, PJ_TRUE);
|
||||||
|
if (!tsx) {
|
||||||
|
PJ_LOG(3,(THIS_FILE," error: timer unable to find transaction"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pjsip_tsx_terminate(tsx, status_code);
|
||||||
|
pj_mutex_unlock(tsx->mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Timer callback to terminate transaction. */
|
||||||
|
static void terminate_tsx_timer( pj_timer_heap_t *timer_heap,
|
||||||
|
struct pj_timer_entry *entry)
|
||||||
|
{
|
||||||
|
terminate_our_tsx(entry->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Schedule timer to terminate transaction. */
|
||||||
|
static void schedule_terminate_tsx( pjsip_transaction *tsx,
|
||||||
|
int status_code,
|
||||||
|
int msec_delay )
|
||||||
|
{
|
||||||
|
pj_time_val delay;
|
||||||
|
|
||||||
|
delay.sec = 0;
|
||||||
|
delay.msec = msec_delay;
|
||||||
|
pj_time_val_normalize(&delay);
|
||||||
|
|
||||||
|
pj_assert(pj_strcmp(&tsx->transaction_key, &tsx_key)==0);
|
||||||
|
timer.user_data = NULL;
|
||||||
|
timer.id = status_code;
|
||||||
|
timer.cb = &terminate_tsx_timer;
|
||||||
|
pjsip_endpt_schedule_timer(endpt, &timer, &delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the handler to receive state changed notification from the
|
* This is the handler to receive state changed notification from the
|
||||||
* transaction. It is used to verify that the transaction behaves according
|
* transaction. It is used to verify that the transaction behaves according
|
||||||
|
@ -331,6 +432,148 @@ static void tsx_user_on_tsx_state(pjsip_transaction *tsx, pjsip_event *e)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else
|
||||||
|
if (pj_strcmp2(&tsx->branch, TEST4_BRANCH_ID)==0) {
|
||||||
|
/*
|
||||||
|
* TEST4_BRANCH_ID tests receiving retransmissions in TRYING state.
|
||||||
|
*/
|
||||||
|
if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
|
||||||
|
|
||||||
|
/* Check that status code is status_code. */
|
||||||
|
if (tsx->status_code != TEST4_STATUS_CODE) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
|
||||||
|
test_complete = -120;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Previous state. */
|
||||||
|
if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_TRYING) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state"));
|
||||||
|
test_complete = -121;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (tsx->state != PJSIP_TSX_STATE_DESTROYED)
|
||||||
|
{
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: unexpected state"));
|
||||||
|
test_complete = -122;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else
|
||||||
|
if (pj_strcmp2(&tsx->branch, TEST5_BRANCH_ID)==0) {
|
||||||
|
/*
|
||||||
|
* TEST5_BRANCH_ID tests receiving retransmissions in PROCEEDING state
|
||||||
|
*/
|
||||||
|
if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
|
||||||
|
|
||||||
|
/* Check that status code is status_code. */
|
||||||
|
if (tsx->status_code != TEST5_STATUS_CODE) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
|
||||||
|
test_complete = -130;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Previous state. */
|
||||||
|
if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_PROCEEDING) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state"));
|
||||||
|
test_complete = -131;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (tsx->state == PJSIP_TSX_STATE_PROCEEDING) {
|
||||||
|
|
||||||
|
/* Check status code. */
|
||||||
|
if (tsx->status_code != TEST5_PROVISIONAL_CODE) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
|
||||||
|
test_complete = -132;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (tsx->state != PJSIP_TSX_STATE_DESTROYED) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: unexpected state"));
|
||||||
|
test_complete = -133;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else
|
||||||
|
if (pj_strcmp2(&tsx->branch, TEST6_BRANCH_ID)==0) {
|
||||||
|
/*
|
||||||
|
* TEST6_BRANCH_ID tests receiving retransmissions in COMPLETED state
|
||||||
|
*/
|
||||||
|
if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
|
||||||
|
|
||||||
|
/* Check that status code is status_code. */
|
||||||
|
if (tsx->status_code != TEST6_STATUS_CODE) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
|
||||||
|
test_complete = -140;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Previous state. */
|
||||||
|
if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_COMPLETED) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state"));
|
||||||
|
test_complete = -141;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (tsx->state != PJSIP_TSX_STATE_PROCEEDING &&
|
||||||
|
tsx->state != PJSIP_TSX_STATE_COMPLETED &&
|
||||||
|
tsx->state != PJSIP_TSX_STATE_DESTROYED)
|
||||||
|
{
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: unexpected state"));
|
||||||
|
test_complete = -142;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else
|
||||||
|
if (pj_strcmp2(&tsx->branch, TEST7_BRANCH_ID)==0 ||
|
||||||
|
pj_strcmp2(&tsx->branch, TEST8_BRANCH_ID)==0)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* TEST7_BRANCH_ID and TEST8_BRANCH_ID test retransmission of
|
||||||
|
* INVITE final response
|
||||||
|
*/
|
||||||
|
int code;
|
||||||
|
|
||||||
|
if (pj_strcmp2(&tsx->branch, TEST7_BRANCH_ID) == 0)
|
||||||
|
code = TEST7_STATUS_CODE;
|
||||||
|
else
|
||||||
|
code = TEST8_STATUS_CODE;
|
||||||
|
|
||||||
|
if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
|
||||||
|
|
||||||
|
if (test_complete == 0)
|
||||||
|
test_complete = 1;
|
||||||
|
|
||||||
|
/* Check status code. */
|
||||||
|
if (tsx->status_code != PJSIP_SC_TSX_TIMEOUT) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
|
||||||
|
test_complete = -150;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Previous state. */
|
||||||
|
if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_COMPLETED) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state"));
|
||||||
|
test_complete = -151;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (tsx->state == PJSIP_TSX_STATE_COMPLETED) {
|
||||||
|
|
||||||
|
/* Check that status code is status_code. */
|
||||||
|
if (tsx->status_code != code) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: incorrect status code"));
|
||||||
|
test_complete = -152;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Previous state. */
|
||||||
|
if (e->body.tsx_state.prev_state != PJSIP_TSX_STATE_TRYING) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state"));
|
||||||
|
test_complete = -153;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (tsx->state != PJSIP_TSX_STATE_DESTROYED) {
|
||||||
|
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: unexpected state"));
|
||||||
|
test_complete = -154;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -344,6 +587,8 @@ static void save_key(pjsip_transaction *tsx)
|
||||||
pj_strcpy(&tsx_key, &key);
|
pj_strcpy(&tsx_key, &key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DIFF(a,b) ((a<b) ? (b-a) : (a-b))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Message receiver handler.
|
* Message receiver handler.
|
||||||
*/
|
*/
|
||||||
|
@ -371,7 +616,6 @@ static pj_bool_t on_rx_message(pjsip_rx_data *rdata)
|
||||||
* response.
|
* response.
|
||||||
*/
|
*/
|
||||||
pjsip_transaction *tsx;
|
pjsip_transaction *tsx;
|
||||||
pjsip_tx_data *tdata;
|
|
||||||
|
|
||||||
status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx);
|
status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
|
@ -381,22 +625,7 @@ static pj_bool_t on_rx_message(pjsip_rx_data *rdata)
|
||||||
}
|
}
|
||||||
|
|
||||||
save_key(tsx);
|
save_key(tsx);
|
||||||
|
send_response(rdata, tsx, status_code);
|
||||||
status = pjsip_endpt_create_response(endpt, rdata,
|
|
||||||
status_code, NULL,
|
|
||||||
&tdata);
|
|
||||||
if (status != PJ_SUCCESS) {
|
|
||||||
app_perror(" error: unable to create response", status);
|
|
||||||
test_complete = -111;
|
|
||||||
return PJ_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = pjsip_tsx_send_msg(tsx, tdata);
|
|
||||||
if (status != PJ_SUCCESS) {
|
|
||||||
app_perror(" error: unable to send response", status);
|
|
||||||
test_complete = -112;
|
|
||||||
return PJ_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* Verify the response received. */
|
/* Verify the response received. */
|
||||||
|
@ -427,7 +656,6 @@ static pj_bool_t on_rx_message(pjsip_rx_data *rdata)
|
||||||
* response, then schedule timer to send final response.
|
* response, then schedule timer to send final response.
|
||||||
*/
|
*/
|
||||||
pjsip_transaction *tsx;
|
pjsip_transaction *tsx;
|
||||||
pjsip_tx_data *tdata;
|
|
||||||
|
|
||||||
status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx);
|
status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
|
@ -438,22 +666,7 @@ static pj_bool_t on_rx_message(pjsip_rx_data *rdata)
|
||||||
|
|
||||||
save_key(tsx);
|
save_key(tsx);
|
||||||
|
|
||||||
status = pjsip_endpt_create_response(endpt, rdata,
|
send_response(rdata, tsx, TEST3_PROVISIONAL_CODE);
|
||||||
TEST3_PROVISIONAL_CODE, NULL,
|
|
||||||
&tdata);
|
|
||||||
if (status != PJ_SUCCESS) {
|
|
||||||
app_perror(" error: unable to create response", status);
|
|
||||||
test_complete = -121;
|
|
||||||
return PJ_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = pjsip_tsx_send_msg(tsx, tdata);
|
|
||||||
if (status != PJ_SUCCESS) {
|
|
||||||
app_perror(" error: unable to send response", status);
|
|
||||||
test_complete = -122;
|
|
||||||
return PJ_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
schedule_send_response(rdata, &tsx->transaction_key,
|
schedule_send_response(rdata, &tsx->transaction_key,
|
||||||
TEST3_STATUS_CODE, 2000);
|
TEST3_STATUS_CODE, 2000);
|
||||||
|
|
||||||
|
@ -482,6 +695,255 @@ static pj_bool_t on_rx_message(pjsip_rx_data *rdata)
|
||||||
}
|
}
|
||||||
return PJ_TRUE;
|
return PJ_TRUE;
|
||||||
|
|
||||||
|
} else if (pj_strcmp2(&branch_param, TEST4_BRANCH_ID) == 0 ||
|
||||||
|
pj_strcmp2(&branch_param, TEST5_BRANCH_ID) == 0 ||
|
||||||
|
pj_strcmp2(&branch_param, TEST6_BRANCH_ID) == 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* TEST4_BRANCH_ID: absorbs retransmissions in TRYING state. */
|
||||||
|
/* TEST5_BRANCH_ID: retransmit last response in PROCEEDING state. */
|
||||||
|
/* TEST6_BRANCH_ID: retransmit last response in COMPLETED state. */
|
||||||
|
|
||||||
|
if (msg->type == PJSIP_REQUEST_MSG) {
|
||||||
|
/* On received response, create UAS. */
|
||||||
|
pjsip_transaction *tsx;
|
||||||
|
|
||||||
|
status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx);
|
||||||
|
if (status != PJ_SUCCESS) {
|
||||||
|
app_perror(" error: unable to create transaction", status);
|
||||||
|
test_complete = -130;
|
||||||
|
return PJ_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
save_key(tsx);
|
||||||
|
|
||||||
|
if (pj_strcmp2(&branch_param, TEST4_BRANCH_ID) == 0) {
|
||||||
|
|
||||||
|
} else if (pj_strcmp2(&branch_param, TEST5_BRANCH_ID) == 0) {
|
||||||
|
send_response(rdata, tsx, TEST5_PROVISIONAL_CODE);
|
||||||
|
|
||||||
|
} else if (pj_strcmp2(&branch_param, TEST6_BRANCH_ID) == 0) {
|
||||||
|
send_response(rdata, tsx, TEST6_PROVISIONAL_CODE);
|
||||||
|
send_response(rdata, tsx, TEST6_STATUS_CODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
/* Verify the response received. */
|
||||||
|
|
||||||
|
++recv_count;
|
||||||
|
|
||||||
|
if (pj_strcmp2(&branch_param, TEST4_BRANCH_ID) == 0) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: not expecting response!"));
|
||||||
|
test_complete = -132;
|
||||||
|
|
||||||
|
} else if (pj_strcmp2(&branch_param, TEST5_BRANCH_ID) == 0) {
|
||||||
|
|
||||||
|
if (rdata->msg_info.msg->line.status.code!=TEST5_PROVISIONAL_CODE) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: incorrect status code!"));
|
||||||
|
test_complete = -133;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (recv_count > TEST5_RESPONSE_COUNT) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: not expecting response!"));
|
||||||
|
test_complete = -134;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (pj_strcmp2(&branch_param, TEST6_BRANCH_ID) == 0) {
|
||||||
|
|
||||||
|
int code = rdata->msg_info.msg->line.status.code;
|
||||||
|
|
||||||
|
switch (recv_count) {
|
||||||
|
case 1:
|
||||||
|
if (code != TEST6_PROVISIONAL_CODE) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: invalid code!"));
|
||||||
|
test_complete = -135;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
if (code != TEST6_STATUS_CODE) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: invalid code!"));
|
||||||
|
test_complete = -136;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: not expecting response"));
|
||||||
|
test_complete = -137;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PJ_TRUE;
|
||||||
|
|
||||||
|
|
||||||
|
} else if (pj_strcmp2(&branch_param, TEST7_BRANCH_ID) == 0 ||
|
||||||
|
pj_strcmp2(&branch_param, TEST8_BRANCH_ID) == 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TEST7_BRANCH_ID and TEST8_BRANCH_ID test the retransmission
|
||||||
|
* of INVITE final response
|
||||||
|
*/
|
||||||
|
if (msg->type == PJSIP_REQUEST_MSG) {
|
||||||
|
|
||||||
|
/* On received response, create UAS. */
|
||||||
|
pjsip_transaction *tsx;
|
||||||
|
|
||||||
|
status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx);
|
||||||
|
if (status != PJ_SUCCESS) {
|
||||||
|
app_perror(" error: unable to create transaction", status);
|
||||||
|
test_complete = -140;
|
||||||
|
return PJ_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
save_key(tsx);
|
||||||
|
|
||||||
|
if (pj_strcmp2(&branch_param, TEST7_BRANCH_ID) == 0) {
|
||||||
|
|
||||||
|
send_response(rdata, tsx, TEST7_STATUS_CODE);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
send_response(rdata, tsx, TEST8_STATUS_CODE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
int code;
|
||||||
|
|
||||||
|
++recv_count;
|
||||||
|
|
||||||
|
if (pj_strcmp2(&branch_param, TEST7_BRANCH_ID) == 0)
|
||||||
|
code = TEST7_STATUS_CODE;
|
||||||
|
else
|
||||||
|
code = TEST8_STATUS_CODE;
|
||||||
|
|
||||||
|
if (recv_count==1) {
|
||||||
|
|
||||||
|
if (rdata->msg_info.msg->line.status.code != code) {
|
||||||
|
PJ_LOG(3,(THIS_FILE," error: invalid status code"));
|
||||||
|
test_complete = -141;
|
||||||
|
}
|
||||||
|
|
||||||
|
recv_last = rdata->pkt_info.timestamp;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
pj_time_val now;
|
||||||
|
unsigned msec, msec_expected;
|
||||||
|
|
||||||
|
now = rdata->pkt_info.timestamp;
|
||||||
|
|
||||||
|
PJ_TIME_VAL_SUB(now, recv_last);
|
||||||
|
|
||||||
|
msec = now.sec*1000 + now.msec;
|
||||||
|
msec_expected = (1 << (recv_count-2)) * PJSIP_T1_TIMEOUT;
|
||||||
|
if (msec_expected > PJSIP_T2_TIMEOUT)
|
||||||
|
msec_expected = PJSIP_T2_TIMEOUT;
|
||||||
|
|
||||||
|
if (DIFF(msec, msec_expected) > MAX_ALLOWED_DIFF) {
|
||||||
|
PJ_LOG(3,(THIS_FILE,
|
||||||
|
" error: incorrect retransmission "
|
||||||
|
"time (%d ms expected, %d ms received",
|
||||||
|
msec_expected, msec));
|
||||||
|
test_complete = -142;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recv_count > 11) {
|
||||||
|
PJ_LOG(3,(THIS_FILE," error: too many responses (%d)",
|
||||||
|
recv_count));
|
||||||
|
test_complete = -143;
|
||||||
|
}
|
||||||
|
|
||||||
|
recv_last = rdata->pkt_info.timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return PJ_TRUE;
|
||||||
|
|
||||||
|
} else if (pj_strcmp2(&branch_param, TEST9_BRANCH_ID)) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TEST9_BRANCH_ID tests that the retransmission of INVITE final
|
||||||
|
* response should cease when ACK is received. Transaction also MUST
|
||||||
|
* terminate in T4 seconds.
|
||||||
|
*/
|
||||||
|
if (msg->type == PJSIP_REQUEST_MSG) {
|
||||||
|
|
||||||
|
/* On received response, create UAS. */
|
||||||
|
pjsip_transaction *tsx;
|
||||||
|
|
||||||
|
status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx);
|
||||||
|
if (status != PJ_SUCCESS) {
|
||||||
|
app_perror(" error: unable to create transaction", status);
|
||||||
|
test_complete = -140;
|
||||||
|
return PJ_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
save_key(tsx);
|
||||||
|
|
||||||
|
if (pj_strcmp2(&branch_param, TEST7_BRANCH_ID) == 0) {
|
||||||
|
|
||||||
|
send_response(rdata, tsx, TEST7_STATUS_CODE);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
send_response(rdata, tsx, TEST8_STATUS_CODE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
int code;
|
||||||
|
|
||||||
|
++recv_count;
|
||||||
|
|
||||||
|
if (pj_strcmp2(&branch_param, TEST7_BRANCH_ID) == 0)
|
||||||
|
code = TEST7_STATUS_CODE;
|
||||||
|
else
|
||||||
|
code = TEST8_STATUS_CODE;
|
||||||
|
|
||||||
|
if (recv_count==1) {
|
||||||
|
|
||||||
|
if (rdata->msg_info.msg->line.status.code != code) {
|
||||||
|
PJ_LOG(3,(THIS_FILE," error: invalid status code"));
|
||||||
|
test_complete = -141;
|
||||||
|
}
|
||||||
|
|
||||||
|
recv_last = rdata->pkt_info.timestamp;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
pj_time_val now;
|
||||||
|
unsigned msec, msec_expected;
|
||||||
|
|
||||||
|
now = rdata->pkt_info.timestamp;
|
||||||
|
|
||||||
|
PJ_TIME_VAL_SUB(now, recv_last);
|
||||||
|
|
||||||
|
msec = now.sec*1000 + now.msec;
|
||||||
|
msec_expected = (1 << (recv_count-2)) * PJSIP_T1_TIMEOUT;
|
||||||
|
if (msec_expected > PJSIP_T2_TIMEOUT)
|
||||||
|
msec_expected = PJSIP_T2_TIMEOUT;
|
||||||
|
|
||||||
|
if (DIFF(msec, msec_expected) > MAX_ALLOWED_DIFF) {
|
||||||
|
PJ_LOG(3,(THIS_FILE,
|
||||||
|
" error: incorrect retransmission "
|
||||||
|
"time (%d ms expected, %d ms received",
|
||||||
|
msec_expected, msec));
|
||||||
|
test_complete = -142;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recv_count > 11) {
|
||||||
|
PJ_LOG(3,(THIS_FILE," error: too many responses (%d)",
|
||||||
|
recv_count));
|
||||||
|
test_complete = -143;
|
||||||
|
}
|
||||||
|
|
||||||
|
recv_last = rdata->pkt_info.timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return PJ_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PJ_FALSE;
|
return PJ_FALSE;
|
||||||
|
@ -492,12 +954,15 @@ static pj_bool_t on_rx_message(pjsip_rx_data *rdata)
|
||||||
*/
|
*/
|
||||||
static int perform_test( char *target_uri, char *from_uri,
|
static int perform_test( char *target_uri, char *from_uri,
|
||||||
char *branch_param, int test_time,
|
char *branch_param, int test_time,
|
||||||
const pjsip_method *method )
|
const pjsip_method *method,
|
||||||
|
int request_cnt, int request_interval_msec,
|
||||||
|
int expecting_timeout)
|
||||||
{
|
{
|
||||||
pjsip_tx_data *tdata;
|
pjsip_tx_data *tdata;
|
||||||
pj_str_t target, from;
|
pj_str_t target, from;
|
||||||
pjsip_via_hdr *via;
|
pjsip_via_hdr *via;
|
||||||
pj_time_val timeout;
|
pj_time_val timeout, next_send;
|
||||||
|
int sent_cnt;
|
||||||
pj_status_t status;
|
pj_status_t status;
|
||||||
|
|
||||||
PJ_LOG(3,(THIS_FILE,
|
PJ_LOG(3,(THIS_FILE,
|
||||||
|
@ -526,17 +991,10 @@ static int perform_test( char *target_uri, char *from_uri,
|
||||||
via = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL);
|
via = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL);
|
||||||
via->branch_param = pj_str(branch_param);
|
via->branch_param = pj_str(branch_param);
|
||||||
|
|
||||||
/* Add additional reference to tdata to prevent transaction from
|
/* Schedule first send. */
|
||||||
* deleting it.
|
sent_cnt = 0;
|
||||||
*/
|
pj_gettimeofday(&next_send);
|
||||||
pjsip_tx_data_add_ref(tdata);
|
pj_time_val_normalize(&next_send);
|
||||||
|
|
||||||
/* Send the first message. */
|
|
||||||
status = pjsip_endpt_send_request_stateless(endpt, tdata, NULL, NULL);
|
|
||||||
if (status != PJ_SUCCESS) {
|
|
||||||
app_perror(" Error: unable to send request", status);
|
|
||||||
return -20;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set test completion time. */
|
/* Set test completion time. */
|
||||||
pj_gettimeofday(&timeout);
|
pj_gettimeofday(&timeout);
|
||||||
|
@ -549,10 +1007,35 @@ static int perform_test( char *target_uri, char *from_uri,
|
||||||
pjsip_endpt_handle_events(endpt, &poll_delay);
|
pjsip_endpt_handle_events(endpt, &poll_delay);
|
||||||
|
|
||||||
pj_gettimeofday(&now);
|
pj_gettimeofday(&now);
|
||||||
|
|
||||||
|
if (sent_cnt < request_cnt && PJ_TIME_VAL_GTE(now, next_send)) {
|
||||||
|
/* Add additional reference to tdata to prevent transaction from
|
||||||
|
* deleting it.
|
||||||
|
*/
|
||||||
|
pjsip_tx_data_add_ref(tdata);
|
||||||
|
|
||||||
|
/* (Re)Send the request. */
|
||||||
|
status = pjsip_endpt_send_request_stateless(endpt, tdata, 0, 0);
|
||||||
|
if (status != PJ_SUCCESS) {
|
||||||
|
app_perror(" Error: unable to send request", status);
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -20;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Schedule next send, if any. */
|
||||||
|
sent_cnt++;
|
||||||
|
if (sent_cnt < request_cnt) {
|
||||||
|
pj_gettimeofday(&next_send);
|
||||||
|
next_send.msec += request_interval_msec;
|
||||||
|
pj_time_val_normalize(&next_send);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (now.sec > timeout.sec) {
|
if (now.sec > timeout.sec) {
|
||||||
|
if (!expecting_timeout)
|
||||||
PJ_LOG(3,(THIS_FILE, " Error: test has timed out"));
|
PJ_LOG(3,(THIS_FILE, " Error: test has timed out"));
|
||||||
pjsip_tx_data_dec_ref(tdata);
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
return -30;
|
return TEST_TIMEOUT_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,7 +1095,7 @@ static int tsx_basic_final_response_test(void)
|
||||||
"sip:129.0.0.1;transport=loop-dgram",
|
"sip:129.0.0.1;transport=loop-dgram",
|
||||||
TEST1_BRANCH_ID,
|
TEST1_BRANCH_ID,
|
||||||
33, /* Test duration must be greater than 32 secs */
|
33, /* Test duration must be greater than 32 secs */
|
||||||
&pjsip_options_method);
|
&pjsip_options_method, 1, 0, 0);
|
||||||
if (status != 0)
|
if (status != 0)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
@ -622,7 +1105,7 @@ static int tsx_basic_final_response_test(void)
|
||||||
"sip:129.0.0.1;transport=loop-dgram",
|
"sip:129.0.0.1;transport=loop-dgram",
|
||||||
TEST2_BRANCH_ID,
|
TEST2_BRANCH_ID,
|
||||||
33, /* Test duration must be greater than 32 secs */
|
33, /* Test duration must be greater than 32 secs */
|
||||||
&pjsip_options_method);
|
&pjsip_options_method, 1, 0, 0);
|
||||||
if (status != 0)
|
if (status != 0)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
@ -646,11 +1129,90 @@ static int tsx_basic_provisional_response_test(void)
|
||||||
"sip:129.0.0.1;transport=loop-dgram",
|
"sip:129.0.0.1;transport=loop-dgram",
|
||||||
TEST3_BRANCH_ID,
|
TEST3_BRANCH_ID,
|
||||||
35,
|
35,
|
||||||
&pjsip_options_method);
|
&pjsip_options_method, 1, 0, 0);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
**
|
||||||
|
** TEST4_BRANCH_ID: Absorbs retransmissions in TRYING state
|
||||||
|
** TEST5_BRANCH_ID: Absorbs retransmissions in PROCEEDING state
|
||||||
|
** TEST6_BRANCH_ID: Absorbs retransmissions in COMPLETED state
|
||||||
|
**
|
||||||
|
*****************************************************************************
|
||||||
|
*/
|
||||||
|
static int tsx_retransmit_last_response_test(const char *title,
|
||||||
|
char *branch_id,
|
||||||
|
int request_cnt,
|
||||||
|
int status_code)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
|
||||||
|
PJ_LOG(3,(THIS_FILE," %s", title));
|
||||||
|
|
||||||
|
status = perform_test("sip:129.0.0.1;transport=loop-dgram",
|
||||||
|
"sip:129.0.0.1;transport=loop-dgram",
|
||||||
|
branch_id,
|
||||||
|
5,
|
||||||
|
&pjsip_options_method,
|
||||||
|
request_cnt, 1000, 1);
|
||||||
|
if (status && status != TEST_TIMEOUT_ERROR)
|
||||||
|
return status;
|
||||||
|
if (!status) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: expecting timeout"));
|
||||||
|
return -31;
|
||||||
|
}
|
||||||
|
|
||||||
|
terminate_our_tsx(status_code);
|
||||||
|
flush_events(100);
|
||||||
|
|
||||||
|
if (test_complete != 1)
|
||||||
|
return test_complete;
|
||||||
|
|
||||||
|
flush_events(100);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
**
|
||||||
|
** TEST7_BRANCH_ID: INVITE non-2xx final response retransmission test
|
||||||
|
** TEST8_BRANCH_ID: INVITE 2xx final response retransmission test
|
||||||
|
**
|
||||||
|
*****************************************************************************
|
||||||
|
*/
|
||||||
|
static int tsx_final_response_retransmission_test(void)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
|
||||||
|
PJ_LOG(3,(THIS_FILE,
|
||||||
|
" test7: INVITE non-2xx final response retransmission"));
|
||||||
|
|
||||||
|
status = perform_test("sip:129.0.0.1;transport=loop-dgram",
|
||||||
|
"sip:129.0.0.1;transport=loop-dgram",
|
||||||
|
TEST7_BRANCH_ID,
|
||||||
|
33, /* Test duration must be greater than 32 secs */
|
||||||
|
&pjsip_invite_method, 1, 0, 0);
|
||||||
|
if (status != 0)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
PJ_LOG(3,(THIS_FILE,
|
||||||
|
" test8: INVITE 2xx final response retransmission"));
|
||||||
|
|
||||||
|
status = perform_test("sip:129.0.0.1;transport=loop-dgram",
|
||||||
|
"sip:129.0.0.1;transport=loop-dgram",
|
||||||
|
TEST8_BRANCH_ID,
|
||||||
|
33, /* Test duration must be greater than 32 secs */
|
||||||
|
&pjsip_invite_method, 1, 0, 0);
|
||||||
|
if (status != 0)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
**
|
**
|
||||||
** UAS Transaction Test.
|
** UAS Transaction Test.
|
||||||
|
@ -689,7 +1251,6 @@ int tsx_uas_test(void)
|
||||||
status = tsx_basic_final_response_test();
|
status = tsx_basic_final_response_test();
|
||||||
if (status != 0)
|
if (status != 0)
|
||||||
return status;
|
return status;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* TEST3_BRANCH_ID: with provisional response
|
/* TEST3_BRANCH_ID: with provisional response
|
||||||
*/
|
*/
|
||||||
|
@ -697,6 +1258,42 @@ int tsx_uas_test(void)
|
||||||
if (status != 0)
|
if (status != 0)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
/* TEST4_BRANCH_ID: absorbs retransmissions in TRYING state
|
||||||
|
*/
|
||||||
|
status = tsx_retransmit_last_response_test(TEST4_TITLE,
|
||||||
|
TEST4_BRANCH_ID,
|
||||||
|
TEST4_REQUEST_COUNT,
|
||||||
|
TEST4_STATUS_CODE);
|
||||||
|
if (status != 0)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
/* TEST5_BRANCH_ID: retransmit last response in PROCEEDING state
|
||||||
|
*/
|
||||||
|
status = tsx_retransmit_last_response_test(TEST5_TITLE,
|
||||||
|
TEST5_BRANCH_ID,
|
||||||
|
TEST5_REQUEST_COUNT,
|
||||||
|
TEST5_STATUS_CODE);
|
||||||
|
if (status != 0)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
/* TEST6_BRANCH_ID: retransmit last response in PROCEEDING state
|
||||||
|
*/
|
||||||
|
status = tsx_retransmit_last_response_test(TEST6_TITLE,
|
||||||
|
TEST6_BRANCH_ID,
|
||||||
|
TEST6_REQUEST_COUNT,
|
||||||
|
TEST6_STATUS_CODE);
|
||||||
|
if (status != 0)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
/* TEST7_BRANCH_ID: INVITE non-2xx final response retransmission test
|
||||||
|
* TEST8_BRANCH_ID: INVITE 2xx final response retransmission test
|
||||||
|
*/
|
||||||
|
|
||||||
|
status = tsx_final_response_retransmission_test();
|
||||||
|
if (status != 0)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
pjsip_transport_dec_ref(loop);
|
pjsip_transport_dec_ref(loop);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -29,13 +29,15 @@
|
||||||
/*
|
/*
|
||||||
* This tests various core message creation functions.
|
* This tests various core message creation functions.
|
||||||
*/
|
*/
|
||||||
int txdata_test(void)
|
static int core_txdata_test(void)
|
||||||
{
|
{
|
||||||
pj_status_t status;
|
pj_status_t status;
|
||||||
pj_str_t target, from, to, contact, body;
|
pj_str_t target, from, to, contact, body;
|
||||||
pjsip_rx_data dummy_rdata;
|
pjsip_rx_data dummy_rdata;
|
||||||
pjsip_tx_data *invite, *invite2, *cancel, *response, *ack;
|
pjsip_tx_data *invite, *invite2, *cancel, *response, *ack;
|
||||||
|
|
||||||
|
PJ_LOG(3,(THIS_FILE, " core transmit data test"));
|
||||||
|
|
||||||
/* Create INVITE request. */
|
/* Create INVITE request. */
|
||||||
target = pj_str("tel:+1");
|
target = pj_str("tel:+1");
|
||||||
from = pj_str("tel:+0");
|
from = pj_str("tel:+0");
|
||||||
|
@ -321,3 +323,207 @@ int txdata_test(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This tests the request creating functions against the following
|
||||||
|
* requirements:
|
||||||
|
* - header params in URI creates header in the request.
|
||||||
|
* - method and headers params are correctly shown or hidden in
|
||||||
|
* request URI, From, To, and Contact header.
|
||||||
|
*/
|
||||||
|
static int txdata_test_uri_params(void)
|
||||||
|
{
|
||||||
|
char msgbuf[512];
|
||||||
|
pj_str_t target = pj_str("sip:alice@wonderland:5061;x-param=param%201"
|
||||||
|
"?X-Hdr-1=Header%201"
|
||||||
|
"&X-Empty-Hdr=");
|
||||||
|
pj_str_t pname = pj_str("x-param");
|
||||||
|
pj_str_t hname = pj_str("X-Hdr-1");
|
||||||
|
pj_str_t hemptyname = pj_str("X-Empty-Hdr");
|
||||||
|
pjsip_from_hdr *from_hdr;
|
||||||
|
pjsip_to_hdr *to_hdr;
|
||||||
|
pjsip_contact_hdr *contact_hdr;
|
||||||
|
pjsip_generic_string_hdr *hdr;
|
||||||
|
pjsip_tx_data *tdata;
|
||||||
|
pjsip_sip_uri *uri;
|
||||||
|
pjsip_param *param;
|
||||||
|
pjsip_msg *msg;
|
||||||
|
int len;
|
||||||
|
pj_status_t status;
|
||||||
|
|
||||||
|
PJ_LOG(3,(THIS_FILE, " header param in URI to create request"));
|
||||||
|
|
||||||
|
/* Create request with header param in target URI. */
|
||||||
|
status = pjsip_endpt_create_request(endpt, &pjsip_invite_method, &target,
|
||||||
|
&target, &target, &target, NULL, -1,
|
||||||
|
NULL, &tdata);
|
||||||
|
if (status != 0) {
|
||||||
|
app_perror(" error: Unable to create request", status);
|
||||||
|
return -200;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print and parse the request.
|
||||||
|
* We'll check that header params are not present in
|
||||||
|
*/
|
||||||
|
len = pjsip_msg_print(tdata->msg, msgbuf, sizeof(msgbuf));
|
||||||
|
if (len < 1) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: printing message"));
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -250;
|
||||||
|
}
|
||||||
|
msgbuf[len] = '\0';
|
||||||
|
|
||||||
|
PJ_LOG(5,(THIS_FILE, "%d bytes request created:--begin-msg--\n"
|
||||||
|
"%s\n"
|
||||||
|
"--end-msg--", len, msgbuf));
|
||||||
|
|
||||||
|
/* Now parse the message. */
|
||||||
|
msg = pjsip_parse_msg( tdata->pool, msgbuf, len, NULL);
|
||||||
|
if (msg == NULL) {
|
||||||
|
app_perror(" error: parsing message message", status);
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -250;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check the existence of port, other_param, and header param.
|
||||||
|
* Port is now allowed in To and From header.
|
||||||
|
*/
|
||||||
|
/* Port in request URI. */
|
||||||
|
uri = (pjsip_sip_uri*) pjsip_uri_get_uri(msg->line.req.uri);
|
||||||
|
if (uri->port != 5061) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: port not present in request URI"));
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -260;
|
||||||
|
}
|
||||||
|
/* other_param in request_uri */
|
||||||
|
param = pjsip_param_find(&uri->other_param, &pname);
|
||||||
|
if (param == NULL || pj_strcmp2(¶m->value, "param 1") != 0) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: x-param not present in request URI"));
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -261;
|
||||||
|
}
|
||||||
|
/* header param in request uri. */
|
||||||
|
if (!pj_list_empty(&uri->header_param)) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: hparam in request URI"));
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -262;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Port in From header. */
|
||||||
|
from_hdr = (pjsip_from_hdr*) pjsip_msg_find_hdr(msg, PJSIP_H_FROM, NULL);
|
||||||
|
uri = (pjsip_sip_uri*) pjsip_uri_get_uri(from_hdr->uri);
|
||||||
|
if (uri->port != 0) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: port most not exist in From header"));
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -270;
|
||||||
|
}
|
||||||
|
/* other_param in From header */
|
||||||
|
param = pjsip_param_find(&uri->other_param, &pname);
|
||||||
|
if (param == NULL || pj_strcmp2(¶m->value, "param 1") != 0) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: x-param not present in From header"));
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -271;
|
||||||
|
}
|
||||||
|
/* header param in From header. */
|
||||||
|
if (!pj_list_empty(&uri->header_param)) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: hparam in From header"));
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -272;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Port in To header. */
|
||||||
|
to_hdr = (pjsip_to_hdr*) pjsip_msg_find_hdr(msg, PJSIP_H_TO, NULL);
|
||||||
|
uri = (pjsip_sip_uri*) pjsip_uri_get_uri(to_hdr->uri);
|
||||||
|
if (uri->port != 0) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: port most not exist in To header"));
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -280;
|
||||||
|
}
|
||||||
|
/* other_param in To header */
|
||||||
|
param = pjsip_param_find(&uri->other_param, &pname);
|
||||||
|
if (param == NULL || pj_strcmp2(¶m->value, "param 1") != 0) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: x-param not present in To header"));
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -281;
|
||||||
|
}
|
||||||
|
/* header param in From header. */
|
||||||
|
if (!pj_list_empty(&uri->header_param)) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: hparam in To header"));
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -282;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Port in Contact header. */
|
||||||
|
contact_hdr = (pjsip_contact_hdr*) pjsip_msg_find_hdr(msg, PJSIP_H_CONTACT, NULL);
|
||||||
|
uri = (pjsip_sip_uri*) pjsip_uri_get_uri(contact_hdr->uri);
|
||||||
|
if (uri->port != 5061) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: port not present in Contact header"));
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -290;
|
||||||
|
}
|
||||||
|
/* other_param in Contact header */
|
||||||
|
param = pjsip_param_find(&uri->other_param, &pname);
|
||||||
|
if (param == NULL || pj_strcmp2(¶m->value, "param 1") != 0) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: x-param not present in Contact header"));
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -291;
|
||||||
|
}
|
||||||
|
/* header param in Contact header. */
|
||||||
|
if (pj_list_empty(&uri->header_param)) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: hparam is missing in Contact header"));
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -292;
|
||||||
|
}
|
||||||
|
/* Check for X-Hdr-1 */
|
||||||
|
param = pjsip_param_find(&uri->header_param, &hname);
|
||||||
|
if (param == NULL || pj_strcmp2(¶m->value, "Header 1")!=0) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: hparam is missing in Contact header"));
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -293;
|
||||||
|
}
|
||||||
|
/* Check for X-Empty-Hdr */
|
||||||
|
param = pjsip_param_find(&uri->header_param, &hemptyname);
|
||||||
|
if (param == NULL || pj_strcmp2(¶m->value, "")!=0) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: hparam is missing in Contact header"));
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -294;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Check that headers are present in the request. */
|
||||||
|
hdr = (pjsip_generic_string_hdr*)
|
||||||
|
pjsip_msg_find_hdr_by_name(msg, &hname, NULL);
|
||||||
|
if (hdr == NULL || pj_strcmp2(&hdr->hvalue, "Header 1")!=0) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: header X-Hdr-1 not created"));
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -300;
|
||||||
|
}
|
||||||
|
|
||||||
|
hdr = (pjsip_generic_string_hdr*)
|
||||||
|
pjsip_msg_find_hdr_by_name(msg, &hemptyname, NULL);
|
||||||
|
if (hdr == NULL || pj_strcmp2(¶m->value, "")!=0) {
|
||||||
|
PJ_LOG(3,(THIS_FILE, " error: header X-Empty-Hdr not created"));
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return -330;
|
||||||
|
}
|
||||||
|
|
||||||
|
pjsip_tx_data_dec_ref(tdata);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int txdata_test(void)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
|
||||||
|
status = core_txdata_test();
|
||||||
|
if (status != 0)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
|
||||||
|
status = txdata_test_uri_params();
|
||||||
|
if (status != 0)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -317,7 +317,7 @@ struct uri_test
|
||||||
static pjsip_uri *create_uri0(pj_pool_t *pool)
|
static pjsip_uri *create_uri0(pj_pool_t *pool)
|
||||||
{
|
{
|
||||||
/* "sip:localhost" */
|
/* "sip:localhost" */
|
||||||
pjsip_url *url = pjsip_url_create(pool, 0);
|
pjsip_sip_uri *url = pjsip_url_create(pool, 0);
|
||||||
|
|
||||||
pj_strdup2(pool, &url->host, "localhost");
|
pj_strdup2(pool, &url->host, "localhost");
|
||||||
return (pjsip_uri*)url;
|
return (pjsip_uri*)url;
|
||||||
|
@ -326,7 +326,7 @@ static pjsip_uri *create_uri0(pj_pool_t *pool)
|
||||||
static pjsip_uri *create_uri1(pj_pool_t *pool)
|
static pjsip_uri *create_uri1(pj_pool_t *pool)
|
||||||
{
|
{
|
||||||
/* "sip:user@localhost" */
|
/* "sip:user@localhost" */
|
||||||
pjsip_url *url = pjsip_url_create(pool, 0);
|
pjsip_sip_uri *url = pjsip_url_create(pool, 0);
|
||||||
|
|
||||||
pj_strdup2( pool, &url->user, "user");
|
pj_strdup2( pool, &url->user, "user");
|
||||||
pj_strdup2( pool, &url->host, "localhost");
|
pj_strdup2( pool, &url->host, "localhost");
|
||||||
|
@ -337,7 +337,7 @@ static pjsip_uri *create_uri1(pj_pool_t *pool)
|
||||||
static pjsip_uri *create_uri2(pj_pool_t *pool)
|
static pjsip_uri *create_uri2(pj_pool_t *pool)
|
||||||
{
|
{
|
||||||
/* "sip:user:password@localhost:5060" */
|
/* "sip:user:password@localhost:5060" */
|
||||||
pjsip_url *url = pjsip_url_create(pool, 0);
|
pjsip_sip_uri *url = pjsip_url_create(pool, 0);
|
||||||
|
|
||||||
pj_strdup2( pool, &url->user, "user");
|
pj_strdup2( pool, &url->user, "user");
|
||||||
pj_strdup2( pool, &url->passwd, "password");
|
pj_strdup2( pool, &url->passwd, "password");
|
||||||
|
@ -350,7 +350,7 @@ static pjsip_uri *create_uri2(pj_pool_t *pool)
|
||||||
static pjsip_uri *create_uri3(pj_pool_t *pool)
|
static pjsip_uri *create_uri3(pj_pool_t *pool)
|
||||||
{
|
{
|
||||||
/* Like: "sip:localhost:5060", but without the port. */
|
/* Like: "sip:localhost:5060", but without the port. */
|
||||||
pjsip_url *url = pjsip_url_create(pool, 0);
|
pjsip_sip_uri *url = pjsip_url_create(pool, 0);
|
||||||
|
|
||||||
pj_strdup2(pool, &url->host, "localhost");
|
pj_strdup2(pool, &url->host, "localhost");
|
||||||
return (pjsip_uri*)url;
|
return (pjsip_uri*)url;
|
||||||
|
@ -359,7 +359,7 @@ static pjsip_uri *create_uri3(pj_pool_t *pool)
|
||||||
static pjsip_uri *create_uri4(pj_pool_t *pool)
|
static pjsip_uri *create_uri4(pj_pool_t *pool)
|
||||||
{
|
{
|
||||||
/* "sip:localhost;transport=tcp;user=ip;ttl=255;lr;maddr=127.0.0.1;method=ACK" */
|
/* "sip:localhost;transport=tcp;user=ip;ttl=255;lr;maddr=127.0.0.1;method=ACK" */
|
||||||
pjsip_url *url = pjsip_url_create(pool, 0);
|
pjsip_sip_uri *url = pjsip_url_create(pool, 0);
|
||||||
|
|
||||||
pj_strdup2(pool, &url->host, "localhost");
|
pj_strdup2(pool, &url->host, "localhost");
|
||||||
pj_strdup2(pool, &url->transport_param, "tcp");
|
pj_strdup2(pool, &url->transport_param, "tcp");
|
||||||
|
@ -386,7 +386,7 @@ static pjsip_uri *create_uri5(pj_pool_t *pool)
|
||||||
/* "sip:localhost;pickup=hurry;user=phone;message=I%20am%20sorry"
|
/* "sip:localhost;pickup=hurry;user=phone;message=I%20am%20sorry"
|
||||||
"?Subject=Hello%20There&Server=SIP%20Server"
|
"?Subject=Hello%20There&Server=SIP%20Server"
|
||||||
*/
|
*/
|
||||||
pjsip_url *url = pjsip_url_create(pool, 0);
|
pjsip_sip_uri *url = pjsip_url_create(pool, 0);
|
||||||
|
|
||||||
pj_strdup2(pool, &url->host, "localhost");
|
pj_strdup2(pool, &url->host, "localhost");
|
||||||
pj_strdup2(pool, &url->user_param, "phone");
|
pj_strdup2(pool, &url->user_param, "phone");
|
||||||
|
@ -405,7 +405,7 @@ static pjsip_uri *create_uri5(pj_pool_t *pool)
|
||||||
static pjsip_uri *create_uri6(pj_pool_t *pool)
|
static pjsip_uri *create_uri6(pj_pool_t *pool)
|
||||||
{
|
{
|
||||||
/* "sips:localhost" */
|
/* "sips:localhost" */
|
||||||
pjsip_url *url = pjsip_url_create(pool, 1);
|
pjsip_sip_uri *url = pjsip_url_create(pool, 1);
|
||||||
|
|
||||||
pj_strdup2(pool, &url->host, "localhost");
|
pj_strdup2(pool, &url->host, "localhost");
|
||||||
return (pjsip_uri*)url;
|
return (pjsip_uri*)url;
|
||||||
|
@ -415,7 +415,7 @@ static pjsip_uri *create_uri7(pj_pool_t *pool)
|
||||||
{
|
{
|
||||||
/* "<sip:localhost>" */
|
/* "<sip:localhost>" */
|
||||||
pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
|
pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
|
||||||
pjsip_url *url;
|
pjsip_sip_uri *url;
|
||||||
|
|
||||||
url = pjsip_url_create(pool, 0);
|
url = pjsip_url_create(pool, 0);
|
||||||
name_addr->uri = (pjsip_uri*) url;
|
name_addr->uri = (pjsip_uri*) url;
|
||||||
|
@ -428,7 +428,7 @@ static pjsip_uri *create_uri8(pj_pool_t *pool)
|
||||||
{
|
{
|
||||||
/* " Power Administrator <sips:localhost>" */
|
/* " Power Administrator <sips:localhost>" */
|
||||||
pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
|
pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
|
||||||
pjsip_url *url;
|
pjsip_sip_uri *url;
|
||||||
|
|
||||||
url = pjsip_url_create(pool, 1);
|
url = pjsip_url_create(pool, 1);
|
||||||
name_addr->uri = (pjsip_uri*) url;
|
name_addr->uri = (pjsip_uri*) url;
|
||||||
|
@ -442,7 +442,7 @@ static pjsip_uri *create_uri9(pj_pool_t *pool)
|
||||||
{
|
{
|
||||||
/* " \"User\" <sip:user@localhost:5071>" */
|
/* " \"User\" <sip:user@localhost:5071>" */
|
||||||
pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
|
pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
|
||||||
pjsip_url *url;
|
pjsip_sip_uri *url;
|
||||||
|
|
||||||
url = pjsip_url_create(pool, 0);
|
url = pjsip_url_create(pool, 0);
|
||||||
name_addr->uri = (pjsip_uri*) url;
|
name_addr->uri = (pjsip_uri*) url;
|
||||||
|
@ -458,7 +458,7 @@ static pjsip_uri *create_uri10(pj_pool_t *pool)
|
||||||
{
|
{
|
||||||
/* " \"Strange User\\\"\\\\\\\"\" <sip:localhost>" */
|
/* " \"Strange User\\\"\\\\\\\"\" <sip:localhost>" */
|
||||||
pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
|
pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
|
||||||
pjsip_url *url;
|
pjsip_sip_uri *url;
|
||||||
|
|
||||||
url = pjsip_url_create(pool, 0);
|
url = pjsip_url_create(pool, 0);
|
||||||
name_addr->uri = (pjsip_uri*) url;
|
name_addr->uri = (pjsip_uri*) url;
|
||||||
|
@ -472,7 +472,7 @@ static pjsip_uri *create_uri11(pj_pool_t *pool)
|
||||||
{
|
{
|
||||||
/* " \"Rogue User\\\" <sip:localhost>" */
|
/* " \"Rogue User\\\" <sip:localhost>" */
|
||||||
pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
|
pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
|
||||||
pjsip_url *url;
|
pjsip_sip_uri *url;
|
||||||
|
|
||||||
url = pjsip_url_create(pool, 0);
|
url = pjsip_url_create(pool, 0);
|
||||||
name_addr->uri = (pjsip_uri*) url;
|
name_addr->uri = (pjsip_uri*) url;
|
||||||
|
@ -486,7 +486,7 @@ static pjsip_uri *create_uri12(pj_pool_t *pool)
|
||||||
{
|
{
|
||||||
/* "Strange User\" <sip:localhost>" */
|
/* "Strange User\" <sip:localhost>" */
|
||||||
pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
|
pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
|
||||||
pjsip_url *url;
|
pjsip_sip_uri *url;
|
||||||
|
|
||||||
url = pjsip_url_create(pool, 0);
|
url = pjsip_url_create(pool, 0);
|
||||||
name_addr->uri = (pjsip_uri*) url;
|
name_addr->uri = (pjsip_uri*) url;
|
||||||
|
@ -499,7 +499,7 @@ static pjsip_uri *create_uri12(pj_pool_t *pool)
|
||||||
static pjsip_uri *create_uri13(pj_pool_t *pool)
|
static pjsip_uri *create_uri13(pj_pool_t *pool)
|
||||||
{
|
{
|
||||||
/* "sip:localhost;pvalue=\"hello world\"" */
|
/* "sip:localhost;pvalue=\"hello world\"" */
|
||||||
pjsip_url *url;
|
pjsip_sip_uri *url;
|
||||||
url = pjsip_url_create(pool, 0);
|
url = pjsip_url_create(pool, 0);
|
||||||
pj_strdup2(pool, &url->host, "localhost");
|
pj_strdup2(pool, &url->host, "localhost");
|
||||||
//pj_strdup2(pool, &url->other_param, ";pvalue=\"hello world\"");
|
//pj_strdup2(pool, &url->other_param, ";pvalue=\"hello world\"");
|
||||||
|
@ -511,7 +511,7 @@ static pjsip_uri *create_uri14(pj_pool_t *pool)
|
||||||
{
|
{
|
||||||
/* "This is -. !% *_+`'~ me <sip:a19A&=+$,;?/%2c:%40a&Zz=+$,@my_proxy09.my-domain.com:9801>" */
|
/* "This is -. !% *_+`'~ me <sip:a19A&=+$,;?/%2c:%40a&Zz=+$,@my_proxy09.my-domain.com:9801>" */
|
||||||
pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
|
pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
|
||||||
pjsip_url *url;
|
pjsip_sip_uri *url;
|
||||||
|
|
||||||
url = pjsip_url_create(pool, 0);
|
url = pjsip_url_create(pool, 0);
|
||||||
name_addr->uri = (pjsip_uri*) url;
|
name_addr->uri = (pjsip_uri*) url;
|
||||||
|
@ -527,7 +527,7 @@ static pjsip_uri *create_uri14(pj_pool_t *pool)
|
||||||
static pjsip_uri *create_uri15(pj_pool_t *pool)
|
static pjsip_uri *create_uri15(pj_pool_t *pool)
|
||||||
{
|
{
|
||||||
/* "sip:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.com" */
|
/* "sip:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.com" */
|
||||||
pjsip_url *url;
|
pjsip_sip_uri *url;
|
||||||
url = pjsip_url_create(pool, 0);
|
url = pjsip_url_create(pool, 0);
|
||||||
pj_strdup2(pool, &url->host, ALPHANUM "-_.com");
|
pj_strdup2(pool, &url->host, ALPHANUM "-_.com");
|
||||||
return (pjsip_uri*)url;
|
return (pjsip_uri*)url;
|
||||||
|
@ -536,7 +536,7 @@ static pjsip_uri *create_uri15(pj_pool_t *pool)
|
||||||
static pjsip_uri *create_uri16(pj_pool_t *pool)
|
static pjsip_uri *create_uri16(pj_pool_t *pool)
|
||||||
{
|
{
|
||||||
/* "sip:" USER_CHAR ":" PASS_CHAR "@host" */
|
/* "sip:" USER_CHAR ":" PASS_CHAR "@host" */
|
||||||
pjsip_url *url;
|
pjsip_sip_uri *url;
|
||||||
url = pjsip_url_create(pool, 0);
|
url = pjsip_url_create(pool, 0);
|
||||||
pj_strdup2(pool, &url->user, USER_CHAR);
|
pj_strdup2(pool, &url->user, USER_CHAR);
|
||||||
pj_strdup2(pool, &url->passwd, PASS_CHAR);
|
pj_strdup2(pool, &url->passwd, PASS_CHAR);
|
||||||
|
@ -547,7 +547,7 @@ static pjsip_uri *create_uri16(pj_pool_t *pool)
|
||||||
static pjsip_uri *create_uri17(pj_pool_t *pool)
|
static pjsip_uri *create_uri17(pj_pool_t *pool)
|
||||||
{
|
{
|
||||||
/* "sip:host;user=ip;" PARAM_CHAR "%21=" PARAM_CHAR "%21;lr;other=1;transport=sctp;other2" */
|
/* "sip:host;user=ip;" PARAM_CHAR "%21=" PARAM_CHAR "%21;lr;other=1;transport=sctp;other2" */
|
||||||
pjsip_url *url;
|
pjsip_sip_uri *url;
|
||||||
url = pjsip_url_create(pool, 0);
|
url = pjsip_url_create(pool, 0);
|
||||||
pj_strdup2(pool, &url->host, "host");
|
pj_strdup2(pool, &url->host, "host");
|
||||||
pj_strdup2(pool, &url->user_param, "ip");
|
pj_strdup2(pool, &url->user_param, "ip");
|
||||||
|
|
Loading…
Reference in a new issue