Commit 85b0d43b authored by jehan's avatar jehan
Browse files

Merge branch 'feature/100rel'

parents 0ccbe50e c380db61
belle-sip (Unreleased): Jully 2018
* rfc3262 (100rel) support
belle_sip-1.6.2 -- July 21th, 2017
* Build fix for Windows
......
......@@ -34,7 +34,6 @@ BELLESIP_EXPORT const char* belle_sip_dialog_state_to_string(const belle_sip_dia
BELLESIP_EXPORT belle_sip_request_t *belle_sip_dialog_create_ack(belle_sip_dialog_t *dialog, unsigned int cseq);
/**
* Create a request part of this dialog.
**/
......
......@@ -748,6 +748,20 @@ BELLESIP_EXPORT belle_sip_list_t* belle_sip_header_supported_get_supported(const
#define BELLE_SIP_HEADER_SUPPORTED(t) BELLE_SIP_CAST(t,belle_sip_header_supported_t)
#define BELLE_SIP_SUPPORTED "Supported"
/******************************
* Require header object inherent from header
*
******************************/
typedef struct _belle_sip_header_require belle_sip_header_require_t;
BELLESIP_EXPORT belle_sip_header_require_t* belle_sip_header_require_new(void);
BELLESIP_EXPORT belle_sip_header_require_t* belle_sip_header_require_parse(const char* require) ;
BELLESIP_EXPORT belle_sip_header_require_t* belle_sip_header_require_create(const char* require);
BELLESIP_EXPORT void belle_sip_header_require_add_require(belle_sip_header_require_t* require, const char* value);
BELLESIP_EXPORT void belle_sip_header_require_set_require(belle_sip_header_require_t* require, belle_sip_list_t* require_values);
BELLESIP_EXPORT belle_sip_list_t* belle_sip_header_require_get_require(const belle_sip_header_require_t* require);
#define BELLE_SIP_HEADER_REQUIRE(t) BELLE_SIP_CAST(t,belle_sip_header_require_t)
#define BELLE_SIP_REQUIRE "Require"
/******************************
* Content Disposition header object inherent from header
*
......
......@@ -144,6 +144,7 @@ BELLE_SIP_DECLARE_TYPES_BEGIN(belle_sip,1)
BELLE_SIP_TYPE_ID(belle_sip_multipart_body_handler_t),
BELLE_SIP_TYPE_ID(belle_sip_header_event_t),
BELLE_SIP_TYPE_ID(belle_sip_header_supported_t),
BELLE_SIP_TYPE_ID(belle_sip_header_require_t),
BELLE_SIP_TYPE_ID(belle_sip_header_content_disposition_t),
BELLE_SIP_TYPE_ID(belle_sip_header_accept_t),
BELLE_SIP_TYPE_ID(belle_sip_header_reason_t),
......
......@@ -79,6 +79,7 @@ static struct header_name_func_pair header_table[] = {
,{PROTO_SIP, BELLE_SIP_EVENT, (header_parse_func)belle_sip_header_event_parse}
,{PROTO_SIP, BELLE_SIP_SUPPORTED, (header_parse_func)belle_sip_header_supported_parse}
,{PROTO_SIP, "k", (header_parse_func)belle_sip_header_supported_parse}
,{PROTO_SIP, BELLE_SIP_REQUIRE, (header_parse_func)belle_sip_header_require_parse}
,{PROTO_SIP, BELLE_SIP_CONTENT_DISPOSITION, (header_parse_func)belle_sip_header_content_disposition_parse}
,{PROTO_SIP, BELLE_SIP_ACCEPT, (header_parse_func)belle_sip_header_accept_parse}
,{PROTO_SIP, BELLE_SIP_REASON, (header_parse_func)belle_sip_header_reason_parse}
......@@ -1959,6 +1960,12 @@ belle_sip_header_event_t* belle_sip_header_event_create (const char* package_nam
******************************/
PRIVACY_LIKE_HEADER(supported,BELLE_SIP_SUPPORTED,",")
/******************************
* Require header inherits from header
*
******************************/
PRIVACY_LIKE_HEADER(require,BELLE_SIP_REQUIRE,",")
/******************************
* Content-Disposition header inherits from header
*
......
......@@ -225,6 +225,7 @@ BELLE_SIP_DECLARE_VPTR(belle_tls_crypto_config_t);
BELLE_SIP_DECLARE_VPTR(belle_http_header_authorization_t);
BELLE_SIP_DECLARE_VPTR(belle_sip_header_event_t);
BELLE_SIP_DECLARE_VPTR(belle_sip_header_supported_t);
BELLE_SIP_DECLARE_VPTR(belle_sip_header_require_t);
BELLE_SIP_DECLARE_VPTR(belle_sip_header_content_disposition_t);
BELLE_SIP_DECLARE_VPTR(belle_sip_header_accept_t);
BELLE_SIP_DECLARE_VPTR(belle_sip_header_reason_t);
......
......@@ -450,6 +450,95 @@ static void belle_sip_dialog_update_remote_target(belle_sip_dialog_t *obj, belle
}
}
static void belle_sip_dialog_update_local_cseq(belle_sip_dialog_t *obj, const char *method){
if (obj->local_cseq==0) obj->local_cseq=110;
if (strcmp(method,"ACK")!=0) obj->local_cseq++;
}
static belle_sip_request_t *belle_sip_dialog_create_prack(belle_sip_dialog_t *dialog, unsigned int rseq, unsigned int cseq, const char* method){
belle_sip_request_t *prack;
belle_sip_request_t *invite = dialog->last_out_invite;
if (!invite){
belle_sip_error("No INVITE to PACK.");
return NULL;
}
prack = belle_sip_dialog_create_request(dialog, "PRACK");
if (prack){
//RAck
char header[50];
snprintf(header,sizeof(header),"%d %d %s", rseq, cseq, method);
belle_sip_header_t *rack = belle_sip_header_create("RAck", header);
belle_sip_message_add_header(BELLE_SIP_MESSAGE(prack), rack);
//Contact
belle_sip_header_from_t* from_header = belle_sip_message_get_header_by_type(prack, belle_sip_header_from_t);
belle_sip_uri_t* req_uri = belle_sip_header_address_get_uri((belle_sip_header_address_t*)from_header);
belle_sip_header_contact_t* contact_header = belle_sip_header_contact_new();
belle_sip_header_address_set_uri((belle_sip_header_address_t*)contact_header, belle_sip_uri_new());
belle_sip_uri_set_user(belle_sip_header_address_get_uri((belle_sip_header_address_t*)contact_header),belle_sip_uri_get_user(req_uri));
belle_sip_message_add_header(BELLE_SIP_MESSAGE(prack),BELLE_SIP_HEADER(contact_header));
const belle_sip_list_t *aut = belle_sip_message_get_headers((belle_sip_message_t*)invite, "Authorization");
const belle_sip_list_t *prx_aut = belle_sip_message_get_headers((belle_sip_message_t*)invite, "Proxy-Authorization");
if (aut)
belle_sip_message_add_headers((belle_sip_message_t*)prack, aut);
if (prx_aut)
belle_sip_message_add_headers((belle_sip_message_t*)prack, prx_aut);
}
return prack;
}
static void belle_sip_dialog_send_prack(belle_sip_dialog_t *dialog, belle_sip_request_t *request){
belle_sip_provider_send_request(dialog->provider, request);
}
static void belle_sip_dialog_process_response_100rel(belle_sip_dialog_t *obj, belle_sip_response_t *resp){
belle_sip_message_t* msg = (belle_sip_message_t*)resp;
belle_sip_header_cseq_t *header_cseq_resp = belle_sip_message_get_header_by_type(msg, belle_sip_header_cseq_t);
if (header_cseq_resp == NULL){
belle_sip_message("Message [%p] does not contain CSeq header!", msg);
}
belle_sip_header_require_t* header_require = belle_sip_message_get_header_by_type(msg, belle_sip_header_require_t);
if (header_require){
belle_sip_list_t* list = belle_sip_header_require_get_require(header_require);
int require_100rel = 0;
while (list){
if (strcmp(list->data, "100rel") == 0){
require_100rel = 1;
break;
}
list=list->next;
}
if (require_100rel){
belle_sip_message("Found header Require with value 100rel in message [%p].", msg);
belle_sip_header_t *header_rseq = belle_sip_message_get_header(msg, "RSeq");
if (header_rseq){
const char* header_rseq_value = belle_sip_header_get_unparsed_value(header_rseq);
long rseq = strtol(header_rseq_value, NULL, 10);
unsigned int cseq_resp = belle_sip_header_cseq_get_seq_number(header_cseq_resp);
const char* method_resp = belle_sip_header_cseq_get_method(header_cseq_resp);
/*send PRACK from callee */
belle_sip_request_t *prack = belle_sip_dialog_create_prack(obj, rseq, cseq_resp, method_resp);
if (prack){
belle_sip_dialog_send_prack(obj, prack);
}
else {
belle_sip_message("Failed to create PRACK message!");
}
}
else {
belle_sip_message("Message [%p] does not contain RSeq header! (required be with 100rel)", msg);
}
}
}
}
/*
* return 0 if message should be delivered to the next listener, otherwise, its a retransmision, just keep it
* */
......@@ -498,6 +587,9 @@ int belle_sip_dialog_update(belle_sip_dialog_t *obj, belle_sip_transaction_t* tr
belle_sip_dialog_establish(obj,req,resp);
if (code<200){
set_state(obj,BELLE_SIP_DIALOG_EARLY);
if ((code == 180 || code == 183) && !as_uas) {
belle_sip_dialog_process_response_100rel(obj, resp);
}
break;
}/* no break for code >200 because need to call belle_sip_dialog_establish_full*/
}
......@@ -532,6 +624,9 @@ int belle_sip_dialog_update(belle_sip_dialog_t *obj, belle_sip_transaction_t* tr
/*no response establishing the dialog, and transaction terminated (transport errors)*/
delete_dialog=TRUE;
}
if ((code == 180 || code == 183) && !as_uas) {
belle_sip_dialog_process_response_100rel(obj, resp);
}
break;
case BELLE_SIP_DIALOG_CONFIRMED:
if (code==481 && (is_invite || is_subscribe)) {
......@@ -710,20 +805,23 @@ belle_sip_dialog_t *belle_sip_dialog_new(belle_sip_transaction_t *t){
}
belle_sip_request_t *belle_sip_dialog_create_ack(belle_sip_dialog_t *obj, unsigned int cseq){
belle_sip_header_cseq_t *cseqh;
belle_sip_request_t *invite=obj->last_out_invite;
belle_sip_request_t *ack;
belle_sip_header_cseq_t* cseqh;
if (!invite){
belle_sip_error("No INVITE to ACK.");
return NULL;
}
cseqh=belle_sip_message_get_header_by_type(invite,belle_sip_header_cseq_t);
if (belle_sip_header_cseq_get_seq_number(cseqh)!=cseq){
belle_sip_error("No INVITE with cseq %i to create ack for.",cseq);
return NULL;
}
ack=create_request(obj,"ACK",TRUE);
belle_sip_message_set_header(BELLE_SIP_MESSAGE(ack), BELLE_SIP_HEADER(belle_sip_header_cseq_create(cseq, "ACK")));
/*
22 Usage of HTTP Authentication
22.1 Framework
......@@ -819,11 +917,6 @@ belle_sip_request_t * belle_sip_dialog_create_queued_request(belle_sip_dialog_t
return req;
}
static void belle_sip_dialog_update_local_cseq(belle_sip_dialog_t *obj, const char *method){
if (obj->local_cseq==0) obj->local_cseq=110;
if (strcmp(method,"ACK")!=0) obj->local_cseq++;
}
belle_sip_request_t *belle_sip_dialog_create_request(belle_sip_dialog_t *obj, const char *method){
belle_sip_request_t *req;
......
......@@ -2,7 +2,7 @@
* This C source file was generated by $ANTLR version 3.4
*
* - From the grammar source file : ../grammars/belle_sdp.g
* - On : 2018-01-22 10:48:20
* - On : 2018-07-11 16:46:26
* - for the lexer : belle_sdpLexerLexer
*
* Editing it, at least manually, is not wise.
......
......@@ -2,7 +2,7 @@
* This C header file was generated by $ANTLR version 3.4
*
* - From the grammar source file : ../grammars/belle_sdp.g
* - On : 2018-01-22 10:48:20
* - On : 2018-07-11 16:46:26
* - for the lexer : belle_sdpLexerLexer
*
* Editing it, at least manually, is not wise.
......
......@@ -2,7 +2,7 @@
* This C source file was generated by $ANTLR version 3.4
*
* - From the grammar source file : ../grammars/belle_sdp.g
* - On : 2018-01-22 10:48:19
* - On : 2018-07-11 16:46:24
* - for the parser : belle_sdpParserParser
*
* Editing it, at least manually, is not wise.
......
......@@ -2,7 +2,7 @@
* This C header file was generated by $ANTLR version 3.4
*
* - From the grammar source file : ../grammars/belle_sdp.g
* - On : 2018-01-22 10:48:19
* - On : 2018-07-11 16:46:24
* - for the parser : belle_sdpParserParser
*
* Editing it, at least manually, is not wise.
......
......@@ -1520,6 +1520,19 @@ catch [ANTLR3_RECOGNITION_EXCEPTION]
}
supported_val: token {belle_sip_header_supported_add_supported($header_supported::current,(const char*)$token.text->chars);};
//**********************************Require*******************************//
header_require returns [belle_sip_header_require_t* ret]
scope { belle_sip_header_require_t* current; }
@init { $header_require::current = belle_sip_header_require_new();$ret = $header_require::current;}
: {IS_TOKEN(Require)}? token /*'Require'*/ hcolon require_val (comma require_val)*;
catch [ANTLR3_RECOGNITION_EXCEPTION]
{
belle_sip_message("[\%s] reason [\%s]",(const char*)EXCEPTION->name,(const char*)EXCEPTION->message);
belle_sip_object_unref($ret);
$ret=NULL;
}
require_val: token {belle_sip_header_require_add_require($header_require::current,(const char*)$token.text->chars);};
//**********************************Content-Disposition*******************************//
content_disposition_value: token ;
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
* This C header file was generated by $ANTLR version 3.4
*
* - From the grammar source file : ../grammars/belle_sip_message.g
* - On : 2018-01-22 10:48:30
* - On : 2018-07-11 16:47:03
* - for the lexer : belle_sip_messageLexerLexer
*
* Editing it, at least manually, is not wise.
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
* This C header file was generated by $ANTLR version 3.4
*
* - From the grammar source file : ../grammars/belle_sip_message.g
* - On : 2018-01-22 10:48:29
* - On : 2018-07-11 16:46:55
* - for the parser : belle_sip_messageParserParser
*
* Editing it, at least manually, is not wise.
......@@ -587,6 +587,12 @@ has the callable functions (rules) shown below,
void
pbelle_sip_messageParser->supported_val(pbelle_sip_messageParser)
* -
belle_sip_header_require_t*
pbelle_sip_messageParser->header_require(pbelle_sip_messageParser)
* -
void
pbelle_sip_messageParser->require_val(pbelle_sip_messageParser)
* -
belle_sip_messageParser_content_disposition_value_return
pbelle_sip_messageParser->content_disposition_value(pbelle_sip_messageParser)
* -
......@@ -2861,6 +2867,35 @@ typedef struct belle_sip_messageParser_header_supported_SCOPE_struct
belle_sip_messageParser_header_supported_SCOPE, * pbelle_sip_messageParser_header_supported_SCOPE;
/* ruleAttributeScopeDecl(scope)
*/
/* makeScopeSet()
*/
/** Definition of the header_require scope variable tracking
* structure. An instance of this structure is created by calling
* belle_sip_messageParser_header_requirePush().
*/
typedef struct belle_sip_messageParser_header_require_SCOPE_struct
{
/** Function that the user may provide to be called when the
* scope is destroyed (so you can free pANTLR3_HASH_TABLES and so on)
*
* \param POinter to an instance of this typedef/struct
*/
void (ANTLR3_CDECL *free) (struct belle_sip_messageParser_header_require_SCOPE_struct * frame);
/* =============================================================================
* Programmer defined variables...
*/
belle_sip_header_require_t* current;
/* End of programmer defined variables
* =============================================================================
*/
}
belle_sip_messageParser_header_require_SCOPE, * pbelle_sip_messageParser_header_require_SCOPE;
/* ruleAttributeScopeDecl(scope)
*/
/* makeScopeSet()
......@@ -3869,6 +3904,17 @@ struct belle_sip_messageParser_Ctx_struct
pbelle_sip_messageParser_header_supported_SCOPE pbelle_sip_messageParser_header_supportedTop;
/* ruleAttributeScopeDef(scope)
*/
/** Pointer to the header_require stack for use by pbelle_sip_messageParser_header_requirePush()
* and pbelle_sip_messageParser_header_requirePop()
*/
pANTLR3_STACK pbelle_sip_messageParser_header_requireStack;
ANTLR3_UINT32 pbelle_sip_messageParser_header_requireStack_limit;
pbelle_sip_messageParser_header_require_SCOPE (*pbelle_sip_messageParser_header_requirePush)(struct belle_sip_messageParser_Ctx_struct * ctx);
pbelle_sip_messageParser_header_require_SCOPE pbelle_sip_messageParser_header_requireTop;
/* ruleAttributeScopeDef(scope)
*/
/** Pointer to the header_content_disposition stack for use by pbelle_sip_messageParser_header_content_dispositionPush()
......@@ -4627,6 +4673,12 @@ struct belle_sip_messageParser_Ctx_struct
void
(*supported_val) (struct belle_sip_messageParser_Ctx_struct * ctx);
belle_sip_header_require_t*
(*header_require) (struct belle_sip_messageParser_Ctx_struct * ctx);
void
(*require_val) (struct belle_sip_messageParser_Ctx_struct * ctx);
belle_sip_messageParser_content_disposition_value_return
(*content_disposition_value) (struct belle_sip_messageParser_Ctx_struct * ctx);
......
......@@ -47,6 +47,7 @@ static belle_sip_dialog_t* caller_dialog;
static belle_sip_dialog_t* callee_dialog;
static belle_sip_response_t* ok_response;
static belle_sip_server_transaction_t* inserv_transaction;
static belle_sip_client_transaction_t* pauline_reg_transaction;
belle_sip_request_t* build_request(belle_sip_stack_t * stack
......@@ -68,7 +69,9 @@ belle_sip_request_t* build_request(belle_sip_stack_t * stack
contact_header= belle_sip_header_contact_new();
belle_sip_header_address_set_uri((belle_sip_header_address_t*)contact_header,belle_sip_uri_new());
belle_sip_uri_set_user(belle_sip_header_address_get_uri((belle_sip_header_address_t*)contact_header),belle_sip_uri_get_user(req_uri));
belle_sip_uri_set_user(belle_sip_header_address_get_uri((belle_sip_header_address_t*)contact_header),
belle_sip_uri_get_user(belle_sip_header_address_get_uri((belle_sip_header_address_t*)from_header)));
req=belle_sip_request_create(
req_uri,
method,
......@@ -78,6 +81,7 @@ belle_sip_request_t* build_request(belle_sip_stack_t * stack
to_header,
belle_sip_header_via_new(),
70);
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(contact_header));
if (route) {
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_route_create(route)));
......@@ -131,6 +135,14 @@ static void callee_process_request_event(void *user_ctx, const belle_sip_request
return; /*not for the callee*/
}
method = belle_sip_request_get_method(belle_sip_request_event_get_request(event));
if (strcmp(method,"PRACK") == 0){
belle_sip_server_transaction_t* server_trans = belle_sip_provider_create_server_transaction(prov,belle_sip_request_event_get_request(event));
belle_sip_response_t* prack_resp_ok = belle_sip_response_create_from_request(belle_sip_request_event_get_request(event), 200);
belle_sip_server_transaction_send_response(server_trans, prack_resp_ok);
return;
}
if (!server_transaction && strcmp(method,"ACK")!=0) {
server_transaction= belle_sip_provider_create_server_transaction(prov,belle_sip_request_event_get_request(event));
}
......@@ -143,8 +155,37 @@ static void callee_process_request_event(void *user_ctx, const belle_sip_request
callee_dialog=dialog;
inserv_transaction=server_transaction;
}
if (belle_sip_dialog_get_state(dialog) == BELLE_SIP_DIALOG_NULL) {
/*prepare 180*/
ringing_response = belle_sip_response_create_from_request(belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(server_transaction)),180);
belle_sip_header_supported_t* header_supported = belle_sip_message_get_header_by_type(belle_sip_request_event_get_request(event),belle_sip_header_supported_t);
if (header_supported){
belle_sip_list_t* list = belle_sip_header_supported_get_supported(header_supported);
int supported_100rel = 0;
while (list){
if (strcmp(list->data, "100rel") == 0){
supported_100rel = 1;
break;
}
list=list->next;
}
if (supported_100rel){
belle_sip_message("Found supported 100rel in message [%p]. PRACK will be required in response 180.", belle_sip_request_event_get_request(event));
belle_sip_header_t* header_require = belle_sip_header_create("Require", "100rel");
belle_sip_header_t* header_rseq = belle_sip_header_create("RSeq", "1");
belle_sip_message_add_header(BELLE_SIP_MESSAGE(ringing_response), BELLE_SIP_HEADER(header_require));
belle_sip_message_add_header(BELLE_SIP_MESSAGE(ringing_response), BELLE_SIP_HEADER(header_rseq));
//workaround for PRACK message. Server will correct Contact header that will be used during create PRACK massege (dialog->remote_target)
belle_sip_response_t* marie_reg_response = belle_sip_transaction_get_response((belle_sip_transaction_t*)pauline_reg_transaction);
BC_ASSERT_PTR_NOT_NULL(marie_reg_response);
belle_sip_header_contact_t* L_tmp = belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(marie_reg_response), belle_sip_header_contact_t);
belle_sip_header_contact_t* contact_header = BELLE_SIP_HEADER_CONTACT(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_message_add_header(BELLE_SIP_MESSAGE(ringing_response),BELLE_SIP_HEADER(contact_header));
}
}
/*prepare 200ok*/
ok_response = belle_sip_response_create_from_request(belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(server_transaction)),200);
content_length= belle_sip_header_content_length_create(strlen(sdp));
......@@ -153,6 +194,7 @@ static void callee_process_request_event(void *user_ctx, const belle_sip_request
belle_sip_message_add_header(BELLE_SIP_MESSAGE(ok_response),BELLE_SIP_HEADER(content_length));
belle_sip_message_set_body(BELLE_SIP_MESSAGE(ok_response),sdp,strlen(sdp));
belle_sip_object_ref(ok_response);
/*only send ringing*/
belle_sip_server_transaction_send_response(server_transaction,ringing_response);
} else if (belle_sip_dialog_get_state(dialog) == BELLE_SIP_DIALOG_CONFIRMED) {
......@@ -167,11 +209,14 @@ static void callee_process_request_event(void *user_ctx, const belle_sip_request
static void caller_process_response_event(void *user_ctx, const belle_sip_response_event_t *event){
belle_sip_client_transaction_t* client_transaction = belle_sip_response_event_get_client_transaction(event);
if (client_transaction == NULL)
return; //fix for received 200 of PRACK
belle_sip_header_from_t* from=belle_sip_message_get_header_by_type(belle_sip_response_event_get_response(event),belle_sip_header_from_t);
belle_sip_header_cseq_t* invite_cseq=belle_sip_message_get_header_by_type(belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(client_transaction)),belle_sip_header_cseq_t);
belle_sip_request_t* ack;
belle_sip_dialog_t* dialog;
int status;
if (!belle_sip_uri_equals(BELLE_SIP_URI(user_ctx),belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(from)))) {
belle_sip_message("Message [%p] not for caller, skipping",belle_sip_response_event_get_response(event));
return; /*not for the caller*/
......@@ -250,7 +295,7 @@ static void listener_destroyed(void *user_ctx){
belle_sip_object_unref(user_ctx);
}
static void do_simple_call(void) {
static void do_simple_call(int enable_100rel) {
#define CALLER "marie"
#define CALLEE "pauline"
belle_sip_request_t *pauline_register_req;
......@@ -285,32 +330,37 @@ static void do_simple_call(void) {
callee_listener_callbacks.process_transaction_terminated=process_transaction_terminated;
callee_listener_callbacks.listener_destroyed=listener_destroyed;
pauline_register_req=register_user(stack, prov, "TCP" ,1 ,CALLER,NULL);
pauline_reg_transaction = register_user_with_transaction(stack, prov, "TCP", CALLEE, NULL);
pauline_register_req = belle_sip_transaction_get_request((belle_sip_transaction_t*)pauline_reg_transaction);
if (belle_sip_provider_get_listening_point(prov, "tls")) {
marie_register_req=register_user(stack, prov, "TLS" ,1 ,CALLEE,NULL);
marie_register_req = register_user(stack, prov, "TLS", 1, CALLER, NULL);
} else {
marie_register_req=register_user(stack, prov, "TCP" ,1 ,CALLEE,NULL);
marie_register_req = register_user(stack, prov, "TCP", 1, CALLER, NULL);
}
from=belle_sip_header_address_create(NULL,belle_sip_uri_create(CALLER,test_domain));
from = belle_sip_header_address_create(NULL,belle_sip_uri_create(CALLER,test_domain));
/*to make sure unexpected messages are ignored*/
belle_sip_parameters_set_parameter(BELLE_SIP_PARAMETERS(from),"cookie",belle_sip_random_token(cookie,sizeof(cookie)));
/*to make sure unexpected messages are ignored*/
to=belle_sip_header_address_create(NULL,belle_sip_uri_create(CALLEE,test_domain));
to = belle_sip_header_address_create(NULL,belle_sip_uri_create(CALLEE,test_domain));
belle_sip_parameters_set_parameter(BELLE_SIP_PARAMETERS(to),"cookie",belle_sip_random_token(cookie,sizeof(cookie)));
belle_sip_provider_add_sip_listener(prov,caller_listener=belle_sip_listener_create_from_callbacks(&caller_listener_callbacks,belle_sip_object_ref(belle_sip_header_address_get_uri((belle_sip_header_address_t*)from))));
belle_sip_provider_add_sip_listener(prov,callee_listener=belle_sip_listener_create_from_callbacks(&callee_listener_callbacks,belle_sip_object_ref(belle_sip_header_address_get_uri((belle_sip_header_address_t*)to))));
belle_sip_provider_add_sip_listener(prov, caller_listener = belle_sip_listener_create_from_callbacks(&caller_listener_callbacks, belle_sip_object_ref(belle_sip_header_address_get_uri((belle_sip_header_address_t*)from))));
belle_sip_provider_add_sip_listener(prov, callee_listener = belle_sip_listener_create_from_callbacks(&callee_listener_callbacks, belle_sip_object_ref(belle_sip_header_address_get_uri((belle_sip_header_address_t*)to))));
route = belle_sip_header_address_create(NULL,belle_sip_uri_create(NULL,test_domain));
belle_sip_uri_set_transport_param(belle_sip_header_address_get_uri(route),"tcp");
req=build_request(stack,prov,from,to,route,"INVITE");
header_allow = belle_sip_header_allow_create("INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO");
req = build_request(stack,prov,from,to,route,"INVITE");
header_allow = belle_sip_header_allow_create("INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, PRACK");
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(header_allow));
if (enable_100rel){
belle_sip_header_supported_t* header_supported = belle_sip_header_supported_create("100rel");
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req), BELLE_SIP_HEADER(header_supported));
}
content_length= belle_sip_header_content_length_create(strlen(sdp));
content_length = belle_sip_header_content_length_create(strlen(sdp));
content_type = belle_sip_header_content_type_create("application","sdp");
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(content_type));
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(content_length));
......@@ -318,10 +368,10 @@ static void do_simple_call(void) {
client_transaction = belle_sip_provider_create_client_transaction(prov,req);
caller_dialog=belle_sip_provider_create_dialog(prov,BELLE_SIP_TRANSACTION(client_transaction));
caller_dialog = belle_sip_provider_create_dialog(prov,BELLE_SIP_TRANSACTION(client_transaction));
BC_ASSERT_PTR_NOT_NULL(belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(client_transaction)));
//belle_sip_transaction_set_application_data(BELLE_SIP_TRANSACTION(client_transaction),op);
call_endeed=0;
call_endeed = 0;
belle_sip_client_transaction_send_request(client_transaction);
//int i=0;
//for(i=0;i<10 &&!call_endeed;i++)
......@@ -342,14 +392,20 @@ static void do_simple_call(void) {
static void simple_call(void){
belle_sip_stack_set_tx_delay(stack,0);
do_simple_call();
do_simple_call(0);
}
static void simple_call_with_delay(void){
belle_sip_stack_set_tx_delay(stack,2000);
do_simple_call();
do_simple_call(0);
belle_sip_stack_set_tx_delay(stack,0);
}
static void simple_call_with_prack(void){
belle_sip_stack_set_tx_delay(stack,0);
do_simple_call(1);
}
/*static void simple_call_udp_tcp_with_delay(void){
belle_sip_listening_point_t* lp=belle_sip_provider_get_listening_point(prov,"tls");
belle_sip_object_ref(lp);
......@@ -365,6 +421,7 @@ static void simple_call_with_delay(void){
test_t dialog_tests[] = {
TEST_ONE_TAG("Simple call", simple_call, "LeaksMemory"),
TEST_ONE_TAG("Simple call with delay", simple_call_with_delay, "LeaksMemory"),
TEST_ONE_TAG("Simple call with prack", simple_call_with_prack, "LeaksMemory"),
};
test_suite_t dialog_test_suite = {"Dialog", register_before_all, register_after_all, belle_sip_tester_before_each,
......
......@@ -452,6 +452,24 @@ static void test_route_header(void) {
}
static void test_rseq_header()
{
belle_sip_header_t* L_tmp;
belle_sip_header_t* L_rseq;
char* l_raw_header = NULL;
L_rseq = belle_sip_header_parse("RSeq: 3344");
l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_rseq));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_rseq));
L_tmp = belle_sip_header_parse(l_raw_header);
L_rseq = BELLE_SIP_HEADER(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));