Commit 4d89f8d0 authored by jehan's avatar jehan

initial 100rel commit

parent 0f999ecc
...@@ -34,7 +34,6 @@ BELLESIP_EXPORT const char* belle_sip_dialog_state_to_string(const belle_sip_dia ...@@ -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); BELLESIP_EXPORT belle_sip_request_t *belle_sip_dialog_create_ack(belle_sip_dialog_t *dialog, unsigned int cseq);
Please register or sign in to reply
/** /**
* Create a request part of this dialog. * Create a request part of this dialog.
**/ **/
...@@ -103,6 +102,8 @@ BELLESIP_EXPORT int belle_sip_dialog_is_secure(const belle_sip_dialog_t *dialog) ...@@ -103,6 +102,8 @@ BELLESIP_EXPORT int belle_sip_dialog_is_secure(const belle_sip_dialog_t *dialog)
BELLESIP_EXPORT void belle_sip_dialog_send_ack(belle_sip_dialog_t *dialog, belle_sip_request_t *request); BELLESIP_EXPORT void belle_sip_dialog_send_ack(belle_sip_dialog_t *dialog, belle_sip_request_t *request);
BELLESIP_EXPORT void belle_sip_dialog_send_prack(belle_sip_dialog_t *dialog, belle_sip_request_t *request);
Please register or sign in to reply
BELLESIP_EXPORT void belle_sip_dialog_terminate_on_bye(belle_sip_dialog_t *dialog, int val); BELLESIP_EXPORT void belle_sip_dialog_terminate_on_bye(belle_sip_dialog_t *dialog, int val);
/** /**
* Give access to the last transaction processed by a dialog. Can be useful to get reason code for dialog terminated before reaching established state * Give access to the last transaction processed by a dialog. Can be useful to get reason code for dialog terminated before reaching established state
......
...@@ -450,6 +450,84 @@ static void belle_sip_dialog_update_remote_target(belle_sip_dialog_t *obj, belle ...@@ -450,6 +450,84 @@ 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){
  • Why not using belle_sip_dialog_create_request and just add RAck ?

    Edited by jehan
Please register or sign in to reply
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;
}
belle_sip_dialog_update_local_cseq(dialog, "PRACK");
prack = create_request(dialog, "PRACK", TRUE);
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_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_t *header_require = belle_sip_message_get_header(msg, "Require");
if (header_require){
const char* header_require_value = belle_sip_header_get_unparsed_value(header_require);
if (strcmp(header_require_value, "100rel") == 0){
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 * return 0 if message should be delivered to the next listener, otherwise, its a retransmision, just keep it
* */ * */
...@@ -496,6 +574,9 @@ int belle_sip_dialog_update(belle_sip_dialog_t *obj, belle_sip_transaction_t* tr ...@@ -496,6 +574,9 @@ int belle_sip_dialog_update(belle_sip_dialog_t *obj, belle_sip_transaction_t* tr
/*always establish a dialog*/ /*always establish a dialog*/
if (code>100 && code<300 && (is_invite || is_subscribe)) { if (code>100 && code<300 && (is_invite || is_subscribe)) {
belle_sip_dialog_establish(obj,req,resp); belle_sip_dialog_establish(obj,req,resp);
if (code == 180 && !as_uas) {
belle_sip_dialog_process_response_100rel(obj, resp);
}
if (code<200){ if (code<200){
set_state(obj,BELLE_SIP_DIALOG_EARLY); set_state(obj,BELLE_SIP_DIALOG_EARLY);
break; break;
...@@ -532,6 +613,9 @@ int belle_sip_dialog_update(belle_sip_dialog_t *obj, belle_sip_transaction_t* tr ...@@ -532,6 +613,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)*/ /*no response establishing the dialog, and transaction terminated (transport errors)*/
delete_dialog=TRUE; delete_dialog=TRUE;
} }
if (code == 183 && !as_uas) {
belle_sip_dialog_process_response_100rel(obj, resp);
}
break; break;
case BELLE_SIP_DIALOG_CONFIRMED: case BELLE_SIP_DIALOG_CONFIRMED:
if (code==481 && (is_invite || is_subscribe)) { if (code==481 && (is_invite || is_subscribe)) {
...@@ -710,7 +794,6 @@ belle_sip_dialog_t *belle_sip_dialog_new(belle_sip_transaction_t *t){ ...@@ -710,7 +794,6 @@ 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_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 *invite=obj->last_out_invite;
belle_sip_request_t *ack; belle_sip_request_t *ack;
...@@ -718,12 +801,9 @@ belle_sip_request_t *belle_sip_dialog_create_ack(belle_sip_dialog_t *obj, unsign ...@@ -718,12 +801,9 @@ belle_sip_request_t *belle_sip_dialog_create_ack(belle_sip_dialog_t *obj, unsign
belle_sip_error("No INVITE to ACK."); belle_sip_error("No INVITE to ACK.");
return NULL; return NULL;
} }
cseqh=belle_sip_message_get_header_by_type(invite,belle_sip_header_cseq_t);
Please register or sign in to reply
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); 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 Usage of HTTP Authentication
22.1 Framework 22.1 Framework
...@@ -819,11 +899,6 @@ belle_sip_request_t * belle_sip_dialog_create_queued_request(belle_sip_dialog_t ...@@ -819,11 +899,6 @@ belle_sip_request_t * belle_sip_dialog_create_queued_request(belle_sip_dialog_t
return req; 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 *belle_sip_dialog_create_request(belle_sip_dialog_t *obj, const char *method){
belle_sip_request_t *req; belle_sip_request_t *req;
...@@ -993,6 +1068,10 @@ void belle_sip_dialog_send_ack(belle_sip_dialog_t *obj, belle_sip_request_t *req ...@@ -993,6 +1068,10 @@ void belle_sip_dialog_send_ack(belle_sip_dialog_t *obj, belle_sip_request_t *req
} }
} }
void belle_sip_dialog_send_prack(belle_sip_dialog_t *dialog, belle_sip_request_t *request){
Please register or sign in to reply
belle_sip_provider_send_request(dialog->provider, request);
}
void belle_sip_dialog_terminate_on_bye(belle_sip_dialog_t *obj, int val){ void belle_sip_dialog_terminate_on_bye(belle_sip_dialog_t *obj, int val){
obj->terminate_on_bye=val; obj->terminate_on_bye=val;
} }
......
This diff is collapsed.
...@@ -452,6 +452,24 @@ static void test_route_header(void) { ...@@ -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));
belle_sip_free(l_raw_header);
BC_ASSERT_STRING_EQUAL(belle_sip_header_get_unparsed_value(L_rseq), "3344");
belle_sip_object_unref(L_rseq);
}
static void test_service_route_header(void) { static void test_service_route_header(void) {
belle_sip_header_service_route_t* L_service_route = belle_sip_header_service_route_parse("Service-Route: <sip:orig@scscf.ims.linphone.com:6060;lr>"); belle_sip_header_service_route_t* L_service_route = belle_sip_header_service_route_parse("Service-Route: <sip:orig@scscf.ims.linphone.com:6060;lr>");
belle_sip_uri_t* L_uri; belle_sip_uri_t* L_uri;
...@@ -560,6 +578,23 @@ static void test_proxy_authorization_header(void) { ...@@ -560,6 +578,23 @@ static void test_proxy_authorization_header(void) {
BC_ASSERT_PTR_NULL(belle_sip_header_proxy_authorization_parse("nimportequoi")); BC_ASSERT_PTR_NULL(belle_sip_header_proxy_authorization_parse("nimportequoi"));
} }
static void test_rack_header(void ) {
belle_sip_header_t* L_tmp;
belle_sip_header_t* L_rseq;
char* l_raw_header = NULL;
L_rseq = belle_sip_header_parse("RAck: 3344 101 INVITE");
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));
belle_sip_free(l_raw_header);
BC_ASSERT_STRING_EQUAL(belle_sip_header_get_unparsed_value(L_rseq), "3344 101 INVITE");
belle_sip_object_unref(L_rseq);
}
static void check_header_authenticate(belle_sip_header_www_authenticate_t* authenticate) { static void check_header_authenticate(belle_sip_header_www_authenticate_t* authenticate) {
belle_sip_list_t* qop; belle_sip_list_t* qop;
BC_ASSERT_PTR_NOT_NULL(authenticate); BC_ASSERT_PTR_NOT_NULL(authenticate);
...@@ -718,7 +753,7 @@ static void test_expires_header(void) { ...@@ -718,7 +753,7 @@ static void test_expires_header(void) {
static void test_allow_header(void) { static void test_allow_header(void) {
belle_sip_header_allow_t* L_tmp; belle_sip_header_allow_t* L_tmp;
belle_sip_header_allow_t* L_allow = belle_sip_header_allow_parse("Allow:INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO"); belle_sip_header_allow_t* L_allow = belle_sip_header_allow_parse("Allow:INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, PRACK");
char* l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_allow)); char* l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_allow));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_allow)); belle_sip_object_unref(BELLE_SIP_OBJECT(L_allow));
L_tmp = belle_sip_header_allow_parse(l_raw_header); L_tmp = belle_sip_header_allow_parse(l_raw_header);
...@@ -726,7 +761,7 @@ static void test_allow_header(void) { ...@@ -726,7 +761,7 @@ static void test_allow_header(void) {
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp)); belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header); belle_sip_free(l_raw_header);
BC_ASSERT_STRING_EQUAL(belle_sip_header_allow_get_method(L_allow), "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO"); BC_ASSERT_STRING_EQUAL(belle_sip_header_allow_get_method(L_allow), "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, PRACK");
belle_sip_object_unref(BELLE_SIP_OBJECT(L_allow)); belle_sip_object_unref(BELLE_SIP_OBJECT(L_allow));
BC_ASSERT_PTR_NULL(belle_sip_header_allow_parse("nimportequoi")); BC_ASSERT_PTR_NULL(belle_sip_header_allow_parse("nimportequoi"));
} }
...@@ -983,6 +1018,28 @@ static void test_replaces_escaped_header(void) { ...@@ -983,6 +1018,28 @@ static void test_replaces_escaped_header(void) {
} }
static void test_require(const char* header_name, const char * header_value) {
belle_sip_header_t* L_tmp;
belle_sip_header_t* L_require;
char header[256];
char* l_raw_header = NULL;
snprintf(header, sizeof(header), "%s:%s", header_name, header_value);
L_require = belle_sip_header_parse(header);
l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_require));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_require));
L_tmp = belle_sip_header_parse(l_raw_header);
L_require = BELLE_SIP_HEADER(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
BC_ASSERT_STRING_EQUAL(belle_sip_header_get_unparsed_value(L_require), header_value);
belle_sip_object_unref(L_require);
}
static void test_header_require(void) {
test_require("Require", "100rel");
}
#ifndef _WIN32 #ifndef _WIN32
static void _test_date_header(void){ static void _test_date_header(void){
belle_sip_header_date_t *date,*date2; belle_sip_header_date_t *date,*date2;
...@@ -1122,11 +1179,14 @@ static void test_supported(const char* header_name, const char * header_value, c ...@@ -1122,11 +1179,14 @@ static void test_supported(const char* header_name, const char * header_value, c
belle_sip_object_unref(BELLE_SIP_OBJECT(L_supported)); belle_sip_object_unref(BELLE_SIP_OBJECT(L_supported));
BC_ASSERT_PTR_NULL(belle_sip_header_supported_parse("nimportequoi")); BC_ASSERT_PTR_NULL(belle_sip_header_supported_parse("nimportequoi"));
} }
static void test_supported_header(void) { static void test_supported_header(void) {
const char* value1[] ={"user","critical"}; const char* value1[] ={"user","critical"};
const char* value2[] ={"id"}; const char* value2[] ={"id"};
const char* value3[] ={"100rel"};
test_supported("Supported","user, critical",value1,2); test_supported("Supported","user, critical",value1,2);
test_supported("Supported", "id",value2,1); test_supported("Supported", "id",value2,1);
test_supported("Supported", "100rel", value3, 1);
} }
static void test_content_disposition_header(void) { static void test_content_disposition_header(void) {
...@@ -1276,12 +1336,15 @@ test_t headers_tests[] = { ...@@ -1276,12 +1336,15 @@ test_t headers_tests[] = {
TEST_NO_TAG("P-Preferred-Identity", test_p_preferred_identity_header), TEST_NO_TAG("P-Preferred-Identity", test_p_preferred_identity_header),
TEST_NO_TAG("Proxy-Authenticate", test_proxy_authenticate_header), TEST_NO_TAG("Proxy-Authenticate", test_proxy_authenticate_header),
TEST_NO_TAG("Proxy-Authorization", test_proxy_authorization_header), TEST_NO_TAG("Proxy-Authorization", test_proxy_authorization_header),
TEST_NO_TAG("RAck", test_rack_header),
TEST_NO_TAG("Record-Route", test_record_route_header), TEST_NO_TAG("Record-Route", test_record_route_header),
TEST_NO_TAG("Refer-To", test_refer_to_header), TEST_NO_TAG("Refer-To", test_refer_to_header),
TEST_NO_TAG("Referred-By", test_referred_by_header), TEST_NO_TAG("Referred-By", test_referred_by_header),
TEST_NO_TAG("Replaces", test_replaces_header), TEST_NO_TAG("Replaces", test_replaces_header),
TEST_NO_TAG("Replaces (Escaped)", test_replaces_escaped_header), TEST_NO_TAG("Replaces (Escaped)", test_replaces_escaped_header),
TEST_NO_TAG("Require", test_header_require),
TEST_NO_TAG("Route", test_route_header), TEST_NO_TAG("Route", test_route_header),
TEST_NO_TAG("RSeq", test_rseq_header),
TEST_NO_TAG("Service-Route", test_service_route_header), TEST_NO_TAG("Service-Route", test_service_route_header),
TEST_NO_TAG("Subscription-State", test_subscription_state_header), TEST_NO_TAG("Subscription-State", test_subscription_state_header),
TEST_NO_TAG("To", test_to_header), TEST_NO_TAG("To", test_to_header),
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "belle-sip/belle-sip.h" #include "belle-sip/belle-sip.h"
#include "belle_sip_tester.h" #include "belle_sip_tester.h"
#include "belle_sip_internal.h"
static void check_uri_and_headers(belle_sip_message_t* message) { static void check_uri_and_headers(belle_sip_message_t* message) {
...@@ -97,9 +98,10 @@ static void testInviteMessage(void) { ...@@ -97,9 +98,10 @@ static void testInviteMessage(void) {
"From: \"Benjamin Cheong\" <sip:bcheong@sip.linphone.org>;tag=7326e5f6\r\n"\ "From: \"Benjamin Cheong\" <sip:bcheong@sip.linphone.org>;tag=7326e5f6\r\n"\
"Call-ID: Y2NlNzg0ODc0ZGIxODU1MWI5MzhkNDVkNDZhOTQ4YWU.\r\n"\ "Call-ID: Y2NlNzg0ODc0ZGIxODU1MWI5MzhkNDVkNDZhOTQ4YWU.\r\n"\
"CSeq: 1 INVITE\r\n"\ "CSeq: 1 INVITE\r\n"\
"Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO\r\n"\ "Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, PRACK\r\n"\
"c: application/sdp\r\n"\ "c: application/sdp\r\n"\
"Supported: replaces\r\n"\ "Supported: replaces\r\n"\
"Supported: 100rel\r\n"\
"Authorization: Digest username=\"003332176\", realm=\"sip.ovh.net\", nonce=\"24212965507cde726e8bc37e04686459\", uri=\"sip:sip.ovh.net\", response=\"896e786e9c0525ca3085322c7f1bce7b\", algorithm=MD5, opaque=\"241b9fb347752f2\"\r\n"\ "Authorization: Digest username=\"003332176\", realm=\"sip.ovh.net\", nonce=\"24212965507cde726e8bc37e04686459\", uri=\"sip:sip.ovh.net\", response=\"896e786e9c0525ca3085322c7f1bce7b\", algorithm=MD5, opaque=\"241b9fb347752f2\"\r\n"\
"User-Agent: X-Lite 4 release 4.0 stamp 58832\r\n"\ "User-Agent: X-Lite 4 release 4.0 stamp 58832\r\n"\
"Content-Length: 230\r\n\r\n"; "Content-Length: 230\r\n\r\n";
...@@ -113,6 +115,23 @@ static void testInviteMessage(void) { ...@@ -113,6 +115,23 @@ static void testInviteMessage(void) {
BC_ASSERT_PTR_NOT_NULL(belle_sip_message_get_header(message,"Contact")); BC_ASSERT_PTR_NOT_NULL(belle_sip_message_get_header(message,"Contact"));
BC_ASSERT_PTR_NOT_NULL(belle_sip_message_get_header(message,"Authorization")); BC_ASSERT_PTR_NOT_NULL(belle_sip_message_get_header(message,"Authorization"));
BC_ASSERT_PTR_NOT_NULL(belle_sip_message_get_header(message,"Content-Type")); BC_ASSERT_PTR_NOT_NULL(belle_sip_message_get_header(message,"Content-Type"));
belle_sip_header_supported_t* header_support;
BC_ASSERT_PTR_NOT_NULL(header_support=BELLE_SIP_HEADER_SUPPORTED(belle_sip_message_get_header(message,"Supported")));
if (header_support) {
belle_sip_list_t* list;
list = belle_sip_header_supported_get_supported(header_support);
BC_ASSERT_PTR_NOT_NULL(list);
const char* value[] = {"replaces", "100rel"};
int num_supported = 2;
for(int i = 0; i < num_supported; i++){
if (list) {
BC_ASSERT_STRING_EQUAL((const char *)(list->data), value[i]);
list=list->next;
}
}
}
check_uri_and_headers(message); check_uri_and_headers(message);
belle_sip_object_unref(message); belle_sip_object_unref(message);
belle_sip_free(encoded_message); belle_sip_free(encoded_message);
...@@ -388,7 +407,6 @@ static void testMalformedMessageWithWrongStart(void) { ...@@ -388,7 +407,6 @@ static void testMalformedMessageWithWrongStart(void) {
belle_sip_message_t* message = belle_sip_message_parse(raw_message); belle_sip_message_t* message = belle_sip_message_parse(raw_message);
BC_ASSERT_PTR_NULL(message); BC_ASSERT_PTR_NULL(message);
} }
#include "belle_sip_internal.h"
void channel_parser_tester_recovery_from_error_base (const char* prelude,const char* raw_message) { void channel_parser_tester_recovery_from_error_base (const char* prelude,const char* raw_message) {
......
...@@ -445,6 +445,80 @@ belle_sip_request_t* register_user(belle_sip_stack_t * stack ...@@ -445,6 +445,80 @@ belle_sip_request_t* register_user(belle_sip_stack_t * stack
return register_user_at_domain(stack,prov,transport,use_transaction,username,test_domain,outbound); return register_user_at_domain(stack,prov,transport,use_transaction,username,test_domain,outbound);
} }
belle_sip_client_transaction_t* register_user_with_transaction(belle_sip_stack_t * stack
  • Should be possible to share more code with register_user_at_domain

Please register or sign in to reply
,belle_sip_provider_t *prov
,const char *transport
,const char* username
,const char* outbound_proxy) {
belle_sip_request_t *req;
belle_sip_client_transaction_t *t;
char identity[256];
char uri[256];
int i;
char *outbound = NULL;
int do_manual_retransmissions = FALSE;
number_of_challenge = 0;
if (transport)
snprintf(uri, sizeof(uri), "sip:%s;transport=%s", test_domain, transport);
else
snprintf(uri, sizeof(uri), "sip:%s", test_domain);
if (transport && strcasecmp("tls",transport) == 0 && belle_sip_provider_get_listening_point(prov,"tls") == NULL){
belle_sip_error("No TLS support, test skipped.");
return NULL;
}
if (outbound_proxy){
if (strstr(outbound_proxy,"sip:") == NULL && strstr(outbound_proxy,"sips:") == NULL){
outbound = belle_sip_strdup_printf("sip:%s",outbound_proxy);
}
else
outbound=belle_sip_strdup(outbound_proxy);
}
snprintf(identity,sizeof(identity), "Tester <sip:%s@%s>", username, test_domain);
req = belle_sip_request_create(
belle_sip_uri_parse(uri),
"REGISTER",
belle_sip_provider_create_call_id(prov),
belle_sip_header_cseq_create(20,"REGISTER"),
belle_sip_header_from_create2(identity,BELLE_SIP_RANDOM_TAG),
belle_sip_header_to_create2(identity,NULL),
belle_sip_header_via_new(),
70);
belle_sip_object_ref(req);
is_register_ok = 0;
io_error_count = 0;
using_transaction = 0;
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_expires_create(600)));
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_contact_new()));
belle_sip_provider_add_sip_listener(prov,l = BELLE_SIP_LISTENER(listener));
t = belle_sip_provider_create_client_transaction(prov, req);
belle_sip_object_ref(t);
belle_sip_client_transaction_send_request_to(t, outbound ? belle_sip_uri_parse(outbound) : NULL);
for(i = 0; !is_register_ok && i < 20 && io_error_count == 0; i++) {
belle_sip_stack_sleep(stack,500);
if (do_manual_retransmissions && !is_register_ok) {
belle_sip_object_ref(req);
belle_sip_provider_send_request(prov, req); /*manage retransmitions*/
}
}
BC_ASSERT_EQUAL(is_register_ok, 1, int, "%d");
belle_sip_object_unref(req);
belle_sip_provider_remove_sip_listener(prov,l);
if (outbound) belle_sip_free(outbound);
return t;
}
static void register_with_outbound(const char *transport, int use_transaction,const char* outbound ) { static void register_with_outbound(const char *transport, int use_transaction,const char* outbound ) {
belle_sip_request_t *req; belle_sip_request_t *req;
......
...@@ -28,8 +28,11 @@ extern belle_sip_request_t* register_user(belle_sip_stack_t * stack ...@@ -28,8 +28,11 @@ extern belle_sip_request_t* register_user(belle_sip_stack_t * stack
,const char *transport ,const char *transport
,int use_transaction ,int use_transaction
,const char* username,const char* outbound) ; ,const char* username,const char* outbound) ;
extern belle_sip_client_transaction_t* register_user_with_transaction(belle_sip_stack_t * stack
,belle_sip_provider_t *prov
,const char *transport
,const char* username,const char* outbound);
extern void unregister_user(belle_sip_stack_t * stack extern void unregister_user(belle_sip_stack_t * stack
,belle_sip_provider_t *prov ,belle_sip_provider_t *prov
,belle_sip_request_t* initial_request ,belle_sip_request_t* initial_request
,int use_transaction); ,int use_transaction);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment