From 50dfb4359619563012997bc3ddafb7667741066c Mon Sep 17 00:00:00 2001 From: Mamadou DIOP Date: Tue, 23 Feb 2016 22:00:35 +0100 Subject: Add new QoS implementation Code formatting --- tinySIP/test/stdafx.c | 6 +- tinySIP/test/stdafx.h | 6 +- tinySIP/test/targetver.h | 4 +- tinySIP/test/test.c | 36 +- tinySIP/test/test_imsaka.h | 72 ++-- tinySIP/test/test_sipmessages.h | 120 +++--- tinySIP/test/test_stack.h | 832 ++++++++++++++++++++-------------------- tinySIP/test/test_transac.h | 12 +- tinySIP/test/test_uri.h | 224 ++++++----- 9 files changed, 644 insertions(+), 668 deletions(-) (limited to 'tinySIP/test') diff --git a/tinySIP/test/stdafx.c b/tinySIP/test/stdafx.c index 2983941..e7b4dd6 100755 --- a/tinySIP/test/stdafx.c +++ b/tinySIP/test/stdafx.c @@ -2,19 +2,19 @@ * Copyright (C) 2009 Mamadou Diop. * * Contact: Mamadou Diop -* +* * This file is part of Open Source Doubango Framework. * * DOUBANGO 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 3 of the License, or * (at your option) any later version. -* +* * DOUBANGO 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 DOUBANGO. * diff --git a/tinySIP/test/stdafx.h b/tinySIP/test/stdafx.h index 0632737..be4f8f7 100755 --- a/tinySIP/test/stdafx.h +++ b/tinySIP/test/stdafx.h @@ -2,19 +2,19 @@ * Copyright (C) 2009 Mamadou Diop. * * Contact: Mamadou Diop -* +* * This file is part of Open Source Doubango Framework. * * DOUBANGO 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 3 of the License, or * (at your option) any later version. -* +* * DOUBANGO 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 DOUBANGO. * diff --git a/tinySIP/test/targetver.h b/tinySIP/test/targetver.h index 9927d16..92eb509 100755 --- a/tinySIP/test/targetver.h +++ b/tinySIP/test/targetver.h @@ -1,8 +1,8 @@ #ifndef TSIP_TEST_TARGETVER_H #define TSIP_TEST_TARGETVER_H // The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and +// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run +// your application. The macros work by enabling all features available on platform versions up to and // including the version specified. // Modify the following defines if you have to target a platform prior to the ones specified below. diff --git a/tinySIP/test/test.c b/tinySIP/test/test.c index 64eef40..7fc3a22 100755 --- a/tinySIP/test/test.c +++ b/tinySIP/test/test.c @@ -2,19 +2,19 @@ * Copyright (C) 2009 Mamadou Diop. * * Contact: Mamadou Diop -* +* * This file is part of Open Source Doubango Framework. * * DOUBANGO 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 3 of the License, or * (at your option) any later version. -* +* * DOUBANGO 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 DOUBANGO. * @@ -46,40 +46,40 @@ int _tmain(int argc, _TCHAR* argv[]) int main() #endif { - tnet_startup(); + tnet_startup(); #if RUN_TEST_LOOP - for(;;) + for(;;) #endif - { - /* Print copyright information */ - printf("Doubango Project\nCopyright (C) 2009 - 2010 Mamadou Diop \n\n"); + { + /* Print copyright information */ + printf("Doubango Project\nCopyright (C) 2009 - 2010 Mamadou Diop \n\n"); + + - - #if RUN_TEST_ALL || RUN_TEST_MESSAGES - test_messages(); + test_messages(); #endif #if RUN_TEST_ALL || RUN_TEST_URI - test_uri(); + test_uri(); #endif #if RUN_TEST_ALL ||RUN_TEST_TRANSAC - test_transac(); + test_transac(); #endif #if RUN_TEST_ALL || RUN_TEST_STACK - test_stack(); + test_stack(); #endif #if RUN_TEST_ALL || RUN_TEST_IMS_AKA - test_imsaka(); + test_imsaka(); #endif - } + } - tnet_cleanup(); + tnet_cleanup(); - return 0; + return 0; } diff --git a/tinySIP/test/test_imsaka.h b/tinySIP/test/test_imsaka.h index 3b5d35d..0ceb53b 100755 --- a/tinySIP/test/test_imsaka.h +++ b/tinySIP/test/test_imsaka.h @@ -2,19 +2,19 @@ * Copyright (C) 2009 Mamadou Diop. * * Contact: Mamadou Diop -* +* * This file is part of Open Source Doubango Framework. * * DOUBANGO 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 3 of the License, or * (at your option) any later version. -* +* * DOUBANGO 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 DOUBANGO. * @@ -47,46 +47,46 @@ void test_imsaka() { - tsip_challenge_t* challenge; - tsip_stack_handle_t *stack; - tsip_request_t *request = tsk_null; - tsk_ragel_state_t state; - tsip_header_Authorization_t* hdr_Auth; + tsip_challenge_t* challenge; + tsip_stack_handle_t *stack; + tsip_request_t *request = tsk_null; + tsk_ragel_state_t state; + tsip_header_Authorization_t* hdr_Auth; + + /* create the SIP stack */ + stack = tsip_stack_create(tsk_null, "sip:ims.inexbee.com", "bob@ims.inexbee.com", "sip:bob@ims.inexbee.com", + TSIP_STACK_SET_PASSWORD("bob"), + TSIP_STACK_SET_NULL()); - /* create the SIP stack */ - stack = tsip_stack_create(tsk_null, "sip:ims.inexbee.com", "bob@ims.inexbee.com", "sip:bob@ims.inexbee.com", - TSIP_STACK_SET_PASSWORD("bob"), - TSIP_STACK_SET_NULL()); - - /* create the chalenge */ - challenge = tsip_challenge_create(stack, - tsk_false, - "Digest", /* scheme */ - "ims.inexbee.com", /* realm */ - "RqhHfrN+ciXaM4mt8k/0Lyx7bgshVgAA5TcTpiTtqsY=", /* nonce */ - tsk_null, /* opaque */ - "AKAv1-MD5", /* algorithm */ - "auth" /* qop */ - ); + /* create the chalenge */ + challenge = tsip_challenge_create(stack, + tsk_false, + "Digest", /* scheme */ + "ims.inexbee.com", /* realm */ + "RqhHfrN+ciXaM4mt8k/0Lyx7bgshVgAA5TcTpiTtqsY=", /* nonce */ + tsk_null, /* opaque */ + "AKAv1-MD5", /* algorithm */ + "auth" /* qop */ + ); - /* Parse SIP request */ - tsk_ragel_state_init(&state, TEST_IMS_AKA_REQUEST, tsk_strlen(TEST_IMS_AKA_REQUEST)); - if(!tsip_message_parse(&state, &request, tsk_true)){ - goto bail; - } + /* Parse SIP request */ + tsk_ragel_state_init(&state, TEST_IMS_AKA_REQUEST, tsk_strlen(TEST_IMS_AKA_REQUEST)); + if(!tsip_message_parse(&state, &request, tsk_true)) { + goto bail; + } - /* Gets auth header */ - if((hdr_Auth = (tsip_header_Authorization_t*)tsip_challenge_create_header_authorization(challenge, request))){ - TSK_DEBUG_INFO("Response=[%s]", hdr_Auth->response); - } + /* Gets auth header */ + if((hdr_Auth = (tsip_header_Authorization_t*)tsip_challenge_create_header_authorization(challenge, request))) { + TSK_DEBUG_INFO("Response=[%s]", hdr_Auth->response); + } bail: - TSK_OBJECT_SAFE_FREE(request); - TSK_OBJECT_SAFE_FREE(challenge); - TSK_OBJECT_SAFE_FREE(stack); + TSK_OBJECT_SAFE_FREE(request); + TSK_OBJECT_SAFE_FREE(challenge); + TSK_OBJECT_SAFE_FREE(stack); - getchar(); + getchar(); } #endif /* _TEST_IMS_AKA_H */ diff --git a/tinySIP/test/test_sipmessages.h b/tinySIP/test/test_sipmessages.h index 47b5608..0ddb5eb 100755 --- a/tinySIP/test/test_sipmessages.h +++ b/tinySIP/test/test_sipmessages.h @@ -2,19 +2,19 @@ * Copyright (C) 2009 Mamadou Diop. * * Contact: Mamadou Diop -* +* * This file is part of Open Source Doubango Framework. * * DOUBANGO 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 3 of the License, or * (at your option) any later version. -* +* * DOUBANGO 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 DOUBANGO. * @@ -78,8 +78,8 @@ "Subscription-State: active;reason=deactivated;expires=507099;retry-after=145;test=jk\r\n"\ "\r\n" - //"Via: SIP/2.0/UDP 192.168.0.11:64163;rport=4;branch=z9hG4bK1262758946486\r\n" \ - //"Via: SIP/2.0/UDP 192.168.0.11:59265;rport=59265;branch=z9hG4bK1263064096664\r\n" \ +//"Via: SIP/2.0/UDP 192.168.0.11:64163;rport=4;branch=z9hG4bK1262758946486\r\n" \ +//"Via: SIP/2.0/UDP 192.168.0.11:59265;rport=59265;branch=z9hG4bK1263064096664\r\n" \ #define SIP_MESSAGE \ "MESSAGE sip:mamadou@open-ims.test SIP/2.0\r\n" \ @@ -148,7 +148,7 @@ "Content-Length: 0\r\n" \ "Warning: 392 10.19.3.160:6060 \"Noisy feedback tells: pid=30444 req_src_ip=10.19.3.160 req_src_port=5060 in_uri=sip:scscf.open-ims.test:6060 out_uri=sip:scscf.open-ims.test:6060 via_cnt==3\"\r\n" \ "\r\n" \ - + #define SIP_OPTIONS \ "SIP/2.0 200 OK\r\n" \ @@ -186,79 +186,79 @@ void test_parser() { - tsk_ragel_state_t state; - tsip_message_t *message = tsk_null; - tsk_buffer_t *buffer = tsk_buffer_create_null(); - const tsip_header_Contact_t* header_contact; - tsk_size_t i; - - tsk_ragel_state_init(&state, SIP_MSG_2_TEST, tsk_strlen(SIP_MSG_2_TEST)); - tsip_message_parse(&state, &message, tsk_true); - - for(i = 0; (header_contact = (const tsip_header_Contact_t*)tsip_message_get_headerAt(message, tsip_htype_Contact, i)); ++i){ - const char* pub_gruu = TSIP_HEADER_GET_PARAM_VALUE(header_contact, "pub-gruu"); - TSK_DEBUG_INFO("pub-gruu for contact header at index %d = %s", i, (pub_gruu ? pub_gruu : "null")); - } - - tsip_message_tostring(message, buffer); - TSK_DEBUG_INFO("Buffer=\n%s", TSK_BUFFER_TO_STRING(buffer)); - - TSK_OBJECT_SAFE_FREE(message); - TSK_OBJECT_SAFE_FREE(buffer); + tsk_ragel_state_t state; + tsip_message_t *message = tsk_null; + tsk_buffer_t *buffer = tsk_buffer_create_null(); + const tsip_header_Contact_t* header_contact; + tsk_size_t i; + + tsk_ragel_state_init(&state, SIP_MSG_2_TEST, tsk_strlen(SIP_MSG_2_TEST)); + tsip_message_parse(&state, &message, tsk_true); + + for(i = 0; (header_contact = (const tsip_header_Contact_t*)tsip_message_get_headerAt(message, tsip_htype_Contact, i)); ++i) { + const char* pub_gruu = TSIP_HEADER_GET_PARAM_VALUE(header_contact, "pub-gruu"); + TSK_DEBUG_INFO("pub-gruu for contact header at index %d = %s", i, (pub_gruu ? pub_gruu : "null")); + } + + tsip_message_tostring(message, buffer); + TSK_DEBUG_INFO("Buffer=\n%s", TSK_BUFFER_TO_STRING(buffer)); + + TSK_OBJECT_SAFE_FREE(message); + TSK_OBJECT_SAFE_FREE(buffer); } void test_requests() { - tsk_buffer_t *buffer = tsk_buffer_create_null(); - tsip_uri_t *from = tsip_uri_parse("sip:mamadou@open-ims.test", tsk_strlen("sip:mamadou@open-ims.test")); - tsip_uri_t *request_uri = tsip_uri_parse("sip:open-ims.test", tsk_strlen("sip:open-ims.test")); - - - tsip_request_t *request = tsip_request_new("REGISTER", request_uri, from, from, "ABCDEFGHIJKLMOPQRSTUVWXYZ", 4521); - - tsip_message_tostring(request, buffer); - TSK_DEBUG_INFO("Buffer=\n%s", TSK_BUFFER_TO_STRING(buffer)); - - - TSK_OBJECT_SAFE_FREE(from); - TSK_OBJECT_SAFE_FREE(request_uri); - TSK_OBJECT_SAFE_FREE(request); - TSK_OBJECT_SAFE_FREE(buffer); + tsk_buffer_t *buffer = tsk_buffer_create_null(); + tsip_uri_t *from = tsip_uri_parse("sip:mamadou@open-ims.test", tsk_strlen("sip:mamadou@open-ims.test")); + tsip_uri_t *request_uri = tsip_uri_parse("sip:open-ims.test", tsk_strlen("sip:open-ims.test")); + + + tsip_request_t *request = tsip_request_new("REGISTER", request_uri, from, from, "ABCDEFGHIJKLMOPQRSTUVWXYZ", 4521); + + tsip_message_tostring(request, buffer); + TSK_DEBUG_INFO("Buffer=\n%s", TSK_BUFFER_TO_STRING(buffer)); + + + TSK_OBJECT_SAFE_FREE(from); + TSK_OBJECT_SAFE_FREE(request_uri); + TSK_OBJECT_SAFE_FREE(request); + TSK_OBJECT_SAFE_FREE(buffer); } void test_responses() { - tsk_ragel_state_t state; - tsip_request_t *request = 0; - tsip_request_t *response = 0; + tsk_ragel_state_t state; + tsip_request_t *request = 0; + tsip_request_t *response = 0; + + tsk_ragel_state_init(&state, SIP_MSG_2_TEST, tsk_strlen(SIP_MSG_2_TEST)); + tsip_message_parse(&state, &request, tsk_true); - tsk_ragel_state_init(&state, SIP_MSG_2_TEST, tsk_strlen(SIP_MSG_2_TEST)); - tsip_message_parse(&state, &request, tsk_true); + /* Create the response and destroy the request */ + response = tsip_response_new(200, "OK you can move forward", request); + TSK_OBJECT_SAFE_FREE(request); - /* Create the response and destroy the request */ - response = tsip_response_new(200, "OK you can move forward", request); - TSK_OBJECT_SAFE_FREE(request); + { + /* DUMP the response */ + tsk_buffer_t *buffer = tsk_buffer_create_null(); - { - /* DUMP the response */ - tsk_buffer_t *buffer = tsk_buffer_create_null(); + tsip_message_tostring(response, buffer); + TSK_DEBUG_INFO("Response=\n%s", TSK_BUFFER_TO_STRING(buffer)); - tsip_message_tostring(response, buffer); - TSK_DEBUG_INFO("Response=\n%s", TSK_BUFFER_TO_STRING(buffer)); + TSK_OBJECT_SAFE_FREE(buffer); + } - TSK_OBJECT_SAFE_FREE(buffer); - } - - TSK_OBJECT_SAFE_FREE(response); + TSK_OBJECT_SAFE_FREE(response); } void test_messages() { - test_parser(); - //test_requests(); - //test_responses(); + test_parser(); + //test_requests(); + //test_responses(); } diff --git a/tinySIP/test/test_stack.h b/tinySIP/test/test_stack.h index 7cfc04c..0bde757 100755 --- a/tinySIP/test/test_stack.h +++ b/tinySIP/test/test_stack.h @@ -2,19 +2,19 @@ * Copyright (C) 2009 Mamadou Diop. * * Contact: Mamadou Diop -* +* * This file is part of Open Source Doubango Framework. * * DOUBANGO 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 3 of the License, or * (at your option) any later version. -* +* * DOUBANGO 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 DOUBANGO. * @@ -76,158 +76,142 @@ int test_stack_callback(const tsip_event_t *sipevent) { - TSK_DEBUG_INFO("\n====\nSTACK event: %d [%s] with opid=%lld\n=====", - sipevent->code, sipevent->phrase, tsip_ssession_get_id(sipevent->ss)); - - // For ssessions created by the stack ==> call tsk_object_ref(sipevent->ssession); - // to take ownership. - - switch(sipevent->type) - { - // - // REGISTER - // - case tsip_event_register: - { - const tsip_register_event_t* _event; - TSK_DEBUG_INFO("SIP event(REGISTER)"); - - _event = TSIP_REGISTER_EVENT(sipevent); - switch(_event->type){ - case tsip_ao_register: /* Answer to Outgoing REGISTER */ - { - if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)){ - TSK_DEBUG_INFO("Registration succeed."); - } - else{ - TSK_DEBUG_INFO("Registration failed."); - } - break; - } - case tsip_ao_unregister: /* Answer to Outgoing UNREGISTER */ - { - if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)){ - TSK_DEBUG_INFO("UnRegistration succeed."); - } - else{ - TSK_DEBUG_INFO("UnRegistration failed."); - } - break; - } - default: - break; - } - - break; - } - - // - // INVITE - // - case tsip_event_invite: - { - TSK_DEBUG_INFO("SIP event(INVITE)"); - break; - } - - // - // MESSAGE - // - case tsip_event_message: - { - const tsip_message_event_t* _event; - TSK_DEBUG_INFO("SIP event(MESSAGE)"); - - _event = TSIP_MESSAGE_EVENT(sipevent); - switch(_event->type) - { - case tsip_i_message: /* Incoming MESSAGE */ - { - if(TSIP_MESSAGE_HAS_CONTENT(sipevent->sipmessage)){ - TSK_DEBUG_INFO("MESSAGE Content: %s", TSIP_MESSAGE_CONTENT(sipevent->sipmessage)); - } - break; - } - case tsip_ao_message: /* Answer to Outgoing MESSAGE */ - { - if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)){ - TSK_DEBUG_INFO("MESSAGE successfully sent."); - } - else{ - TSK_DEBUG_INFO("Failed to send MESSAGE (sip code:%d).", TSIP_RESPONSE_CODE(sipevent->sipmessage)); - } - } - default: - break; - } - - break; - } - - // - // PUBLISH - // - case tsip_event_publish: - { - TSK_DEBUG_INFO("SIP event(PUBLISH)"); - break; - } - - // - // SUBSCRIBE - // - case tsip_event_subscribe: - { - const tsip_subscribe_event_t* _event; - TSK_DEBUG_INFO("SIP event(SUBSCRIBE)"); - - _event = TSIP_SUBSCRIBE_EVENT(sipevent); - switch(_event->type) - { - case tsip_i_notify: /* Incoming NOTIFY */ - { - if(TSIP_MESSAGE_CONTENT_DATA(sipevent->sipmessage)){ - TSK_DEBUG_INFO("NOTIFY Content: %s", TSIP_MESSAGE_CONTENT(sipevent->sipmessage)); - } - break; - } - case tsip_ao_subscribe: /* Answer to Outgoing SUBSCRIBE */ - { - if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)){ - TSK_DEBUG_INFO("Subscription succeed."); - } - else{ - TSK_DEBUG_INFO("Subscription failed."); - } - break; - } - case tsip_ao_unsubscribe: /* Answer to Outgoing UNSUBSCRIBE */ - { - if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)){ - TSK_DEBUG_INFO("UnSubscription succeed."); - } - else{ - TSK_DEBUG_INFO("UnSubscription failed."); - } - break; - } - default: - break; - } - - break; - } - - default: - { - TSK_DEBUG_INFO("SIP event(UNKNOWN)"); - break; - } - } - - //tsk_thread_sleep(1000000); - - return 0; + TSK_DEBUG_INFO("\n====\nSTACK event: %d [%s] with opid=%lld\n=====", + sipevent->code, sipevent->phrase, tsip_ssession_get_id(sipevent->ss)); + + // For ssessions created by the stack ==> call tsk_object_ref(sipevent->ssession); + // to take ownership. + + switch(sipevent->type) { + // + // REGISTER + // + case tsip_event_register: { + const tsip_register_event_t* _event; + TSK_DEBUG_INFO("SIP event(REGISTER)"); + + _event = TSIP_REGISTER_EVENT(sipevent); + switch(_event->type) { + case tsip_ao_register: { /* Answer to Outgoing REGISTER */ + if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)) { + TSK_DEBUG_INFO("Registration succeed."); + } + else { + TSK_DEBUG_INFO("Registration failed."); + } + break; + } + case tsip_ao_unregister: { /* Answer to Outgoing UNREGISTER */ + if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)) { + TSK_DEBUG_INFO("UnRegistration succeed."); + } + else { + TSK_DEBUG_INFO("UnRegistration failed."); + } + break; + } + default: + break; + } + + break; + } + + // + // INVITE + // + case tsip_event_invite: { + TSK_DEBUG_INFO("SIP event(INVITE)"); + break; + } + + // + // MESSAGE + // + case tsip_event_message: { + const tsip_message_event_t* _event; + TSK_DEBUG_INFO("SIP event(MESSAGE)"); + + _event = TSIP_MESSAGE_EVENT(sipevent); + switch(_event->type) { + case tsip_i_message: { /* Incoming MESSAGE */ + if(TSIP_MESSAGE_HAS_CONTENT(sipevent->sipmessage)) { + TSK_DEBUG_INFO("MESSAGE Content: %s", TSIP_MESSAGE_CONTENT(sipevent->sipmessage)); + } + break; + } + case tsip_ao_message: { /* Answer to Outgoing MESSAGE */ + if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)) { + TSK_DEBUG_INFO("MESSAGE successfully sent."); + } + else { + TSK_DEBUG_INFO("Failed to send MESSAGE (sip code:%d).", TSIP_RESPONSE_CODE(sipevent->sipmessage)); + } + } + default: + break; + } + + break; + } + + // + // PUBLISH + // + case tsip_event_publish: { + TSK_DEBUG_INFO("SIP event(PUBLISH)"); + break; + } + + // + // SUBSCRIBE + // + case tsip_event_subscribe: { + const tsip_subscribe_event_t* _event; + TSK_DEBUG_INFO("SIP event(SUBSCRIBE)"); + + _event = TSIP_SUBSCRIBE_EVENT(sipevent); + switch(_event->type) { + case tsip_i_notify: { /* Incoming NOTIFY */ + if(TSIP_MESSAGE_CONTENT_DATA(sipevent->sipmessage)) { + TSK_DEBUG_INFO("NOTIFY Content: %s", TSIP_MESSAGE_CONTENT(sipevent->sipmessage)); + } + break; + } + case tsip_ao_subscribe: { /* Answer to Outgoing SUBSCRIBE */ + if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)) { + TSK_DEBUG_INFO("Subscription succeed."); + } + else { + TSK_DEBUG_INFO("Subscription failed."); + } + break; + } + case tsip_ao_unsubscribe: { /* Answer to Outgoing UNSUBSCRIBE */ + if(TSIP_RESPONSE_IS_2XX(sipevent->sipmessage)) { + TSK_DEBUG_INFO("UnSubscription succeed."); + } + else { + TSK_DEBUG_INFO("UnSubscription failed."); + } + break; + } + default: + break; + } + + break; + } + + default: { + TSK_DEBUG_INFO("SIP event(UNKNOWN)"); + break; + } + } + + //tsk_thread_sleep(1000000); + + return 0; } @@ -238,283 +222,283 @@ void test_stack() //#define DOMAIN "ims.inexbee.com" //#define DOMAIN "sip2sip.info" - const void* usr_context = tsk_null; - int ret; - uint16_t AMF = 0x0001; -/* - tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, - TSIP_STACK_SET_DISPLAY_NAME("2233392625"), - TSIP_STACK_SET_PUBLIC_IDENTITY("sip:2233392625@"DOMAIN), - TSIP_STACK_SET_PRIVATE_IDENTITY("2233392625"), - TSIP_STACK_SET_PASSWORD("d3sb7j4fb8"), - TSIP_STACK_SET_REALM("sip:"DOMAIN), // FIXME: without sip: - TSIP_STACK_SET_LOCAL_IP(LOCAL_IP), - //TSIP_STACK_SET_DISCOVERY_NAPTR(1), - //TSIP_STACK_SET_PROXY_CSCF("proxy.sipthor.net", "udp", 0), - //TSIP_STACK_SET_PROXY_CSCF("192.168.0.15", "udp", 0), - TSIP_STACK_SET_PROXY_CSCF_PORT(5060), - TSIP_STACK_SET_MOBILITY("fixed"), - TSIP_STACK_SET_DEVICE_ID("dd1289fa-c3d7-47bd-a40d-f1f1b2cc5ffc"), - TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"), - TSIP_STACK_SET_PRIVACY("header;id"), -*/ + const void* usr_context = tsk_null; + int ret; + uint16_t AMF = 0x0001; + /* + tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, + TSIP_STACK_SET_DISPLAY_NAME("2233392625"), + TSIP_STACK_SET_PUBLIC_IDENTITY("sip:2233392625@"DOMAIN), + TSIP_STACK_SET_PRIVATE_IDENTITY("2233392625"), + TSIP_STACK_SET_PASSWORD("d3sb7j4fb8"), + TSIP_STACK_SET_REALM("sip:"DOMAIN), // FIXME: without sip: + TSIP_STACK_SET_LOCAL_IP(LOCAL_IP), + //TSIP_STACK_SET_DISCOVERY_NAPTR(1), + //TSIP_STACK_SET_PROXY_CSCF("proxy.sipthor.net", "udp", 0), + //TSIP_STACK_SET_PROXY_CSCF("192.168.0.15", "udp", 0), + TSIP_STACK_SET_PROXY_CSCF_PORT(5060), + TSIP_STACK_SET_MOBILITY("fixed"), + TSIP_STACK_SET_DEVICE_ID("dd1289fa-c3d7-47bd-a40d-f1f1b2cc5ffc"), + TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"), + TSIP_STACK_SET_PRIVACY("header;id"), + */ + + /* + tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, + TSIP_STACK_SET_DISPLAY_NAME("Mamadou"), + TSIP_STACK_SET_PUBLIC_IDENTITY("sip:mamadou@"DOMAIN), + TSIP_STACK_SET_PRIVATE_IDENTITY("mamadou@"DOMAIN), + TSIP_STACK_SET_PASSWORD("mamadou"), + TSIP_STACK_SET_REALM("sip:"DOMAIN), // FIXME: without sip: + TSIP_STACK_SET_LOCAL_IP(LOCAL_IP), + //TSIP_STACK_SET_DISCOVERY_NAPTR(1), + TSIP_STACK_SET_PROXY_CSCF("192.168.0.15", "udp", 0), + //TSIP_STACK_SET_PROXY_CSCF_PORT(5081), + TSIP_STACK_SET_PROXY_CSCF_PORT(5060), + //TSIP_STACK_SET_SECAGREE_IPSEC("hmac-md5-96", "null", "trans", "esp"), + TSIP_STACK_SET_MOBILITY("fixed"), + TSIP_STACK_SET_DEVICE_ID("dd1289fa-c3d7-47bd-a40d-f1f1b2cc5ffc"), + TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"), + TSIP_STACK_SET_PRIVACY("header;id"), + */ + + + + int32_t port = 4060; + /* + tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, "sip:"DOMAIN, "mamadou@"DOMAIN, "sip:mamadou@"DOMAIN, + TSIP_STACK_SET_DISPLAY_NAME("Mamadou"), + TSIP_STACK_SET_PASSWORD("mamadou"), + TSIP_STACK_SET_IMS_AKA_AMF(AMF), + TSIP_STACK_SET_IMS_AKA_OPERATOR_ID("0xff08"), + TSIP_STACK_SET_HEADER("User-Agent", "IM-client/OMA1.0 doubango/v1.0.0"), + + TSIP_STACK_SET_PROXY_CSCF("192.168.16.225", port, "udp", "ipv4"), + + TSIP_STACK_SET_EARLY_IMS(tsk_true), + */ + + tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, "sip:"DOMAIN, "mamadou@"DOMAIN, "sip:mamadou@"DOMAIN, + TSIP_STACK_SET_DISPLAY_NAME("Mamadou"), + TSIP_STACK_SET_PASSWORD("mamadou"), + TSIP_STACK_SET_IMS_AKA_AMF(AMF), + TSIP_STACK_SET_IMS_AKA_OPERATOR_ID("0xff08"), + TSIP_STACK_SET_HEADER("User-Agent", "IM-client/OMA1.0 doubango/v1.0.0"), + + TSIP_STACK_SET_PROXY_CSCF("192.168.0.13", 5081, "tcp", "ipv4"), + TSIP_STACK_SET_LOCAL_IP(LOCAL_IP), + + TSIP_STACK_SET_EARLY_IMS(tsk_true), + + + /* + tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, "sip:"DOMAIN, "2233392625", "sip:2233392625@"DOMAIN, + TSIP_STACK_SET_DISPLAY_NAME("Mamadou"), + TSIP_STACK_SET_PASSWORD("d3sb7j4fb8"), + + TSIP_STACK_SET_EARLY_IMS(tsk_true), + + TSIP_STACK_SET_HEADER("User-Agent", "IM-client/OMA1.0 doubango/v1.0.0"), + */ + /* + tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, + TSIP_STACK_SET_DISPLAY_NAME("Mamadou"), + TSIP_STACK_SET_PUBLIC_IDENTITY("sip:mamadou@"DOMAIN), + TSIP_STACK_SET_PRIVATE_IDENTITY("mamadou@"DOMAIN), + TSIP_STACK_SET_PASSWORD("mamadou"), + TSIP_STACK_SET_REALM("sip:"DOMAIN), // FIXME: without sip: + TSIP_STACK_SET_LOCAL_IP(LOCAL_IP), + //TSIP_STACK_SET_DISCOVERY_NAPTR(1), + TSIP_STACK_SET_PROXY_CSCF("192.168.16.104", "udp", 0), + //TSIP_STACK_SET_PROXY_CSCF("192.168.0.15", "udp", 0), + TSIP_STACK_SET_PROXY_CSCF_PORT(5060), + //TSIP_STACK_SET_SECAGREE_IPSEC("hmac-md5-96", "null", "trans", "esp"), + TSIP_STACK_SET_MOBILITY("fixed"), + TSIP_STACK_SET_DEVICE_ID("dd1289fa-c3d7-47bd-a40d-f1f1b2cc5ffc"), + TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"), + TSIP_STACK_SET_PRIVACY("header;id"), + */ + + TSIP_STACK_SET_NULL()); + + + + + //tsip_ssession_handle_t *op = tsip_ssession_create(stack, + // TSIP_SSESSION_SET_CONTEXT(usr_context), + // TSIP_SSESSION_SET_HEADER("expires", "30"), + // TSIP_SSESSION_SET_HEADER("Persistence", "session"), + // + // TSIP_SSESSION_SET_CAPS("language", "\"en,fr\""), + // TSIP_SSESSION_SET_CAPS("+audio", ""), + // TSIP_SSESSION_SET_CAPS("+g.oma.sip-im", ""), + // + // tsk_null); + + + tsip_ssession_handle_t *op = tsip_ssession_create(stack, + TSIP_SSESSION_SET_EXPIRES(30), + + TSIP_SSESSION_SET_CAPS("+g.oma.sip-im", ""), + TSIP_SSESSION_SET_CAPS("+audio", ""), + TSIP_SSESSION_SET_CAPS("automata", ""), + TSIP_SSESSION_SET_CAPS("language", "\"en,fr\""), + + TSIP_SSESSION_SET_HEADER("Supported", "ssl"), + TSIP_SSESSION_SET_HEADER("P-Access-Network-Info", "3GPP-UTRAN-TDD;utran-cell-id-3gpp=AAAAA0000BBBB"), + + TSIP_SSESSION_UNSET_HEADER("P-Access-Network-Info"), + + TSIP_SSESSION_SET_NULL()); + + //tsip_ssession_id_t opid = tsip_ssession_get_id(op); + + if((ret = tsip_stack_start(stack))) { + goto bail; + } + + tsip_action_REGISTER(op, + TSIP_ACTION_SET_HEADER("My-Header-1", "My-Value-1"), + TSIP_ACTION_SET_HEADER("My-Header-2", "My-Value-1"), + + TSIP_ACTION_SET_NULL()); + + getchar(); + //tsk_thread_sleep(2000); + + tsip_action_UNREGISTER(op, + TSIP_ACTION_SET_NULL() + ); - /* - tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, - TSIP_STACK_SET_DISPLAY_NAME("Mamadou"), - TSIP_STACK_SET_PUBLIC_IDENTITY("sip:mamadou@"DOMAIN), - TSIP_STACK_SET_PRIVATE_IDENTITY("mamadou@"DOMAIN), - TSIP_STACK_SET_PASSWORD("mamadou"), - TSIP_STACK_SET_REALM("sip:"DOMAIN), // FIXME: without sip: - TSIP_STACK_SET_LOCAL_IP(LOCAL_IP), - //TSIP_STACK_SET_DISCOVERY_NAPTR(1), - TSIP_STACK_SET_PROXY_CSCF("192.168.0.15", "udp", 0), - //TSIP_STACK_SET_PROXY_CSCF_PORT(5081), - TSIP_STACK_SET_PROXY_CSCF_PORT(5060), - //TSIP_STACK_SET_SECAGREE_IPSEC("hmac-md5-96", "null", "trans", "esp"), - TSIP_STACK_SET_MOBILITY("fixed"), - TSIP_STACK_SET_DEVICE_ID("dd1289fa-c3d7-47bd-a40d-f1f1b2cc5ffc"), - TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"), - TSIP_STACK_SET_PRIVACY("header;id"), -*/ + getchar(); + tsk_thread_sleep(2000); - - - int32_t port = 4060; -/* - tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, "sip:"DOMAIN, "mamadou@"DOMAIN, "sip:mamadou@"DOMAIN, - TSIP_STACK_SET_DISPLAY_NAME("Mamadou"), - TSIP_STACK_SET_PASSWORD("mamadou"), - TSIP_STACK_SET_IMS_AKA_AMF(AMF), - TSIP_STACK_SET_IMS_AKA_OPERATOR_ID("0xff08"), - TSIP_STACK_SET_HEADER("User-Agent", "IM-client/OMA1.0 doubango/v1.0.0"), - - TSIP_STACK_SET_PROXY_CSCF("192.168.16.225", port, "udp", "ipv4"), - - TSIP_STACK_SET_EARLY_IMS(tsk_true), -*/ + //tsip_unregister(op, + // TSIP_ACTION_SET_HEADER("Persistence2", "action"), + // + // tsk_null); + /* + tsip_subscribe(op, + TSIP_ACTION_SET_HEADER("Persistence", "action"), + + tsk_null); + + tsk_thread_sleep(5000); + + tsip_unsubscribe(op, + TSIP_ACTION_SET_HEADER("Persistence2", "action"), + + tsk_null); + */ + + /* INVITE */ + /* + { + tsip_ssession_handle_t *call = TSIP_SSESSION_CREATE(stack, + TSIP_SSESSION_SET_HEADER("to", "sip:samba@"DOMAIN), + TSIP_SSESSION_SET_CAPS("+g.3gpp.icsi-ref", "\"urn%3Aurn-7%3gpp-service.ims.icsi.mmtel\""), + TSIP_SSESSION_SET_HEADER("Supported", "timer, norefersub, precondition"), + TSIP_SSESSION_SET_HEADER("Require", "100rel"), + + TSIP_SSESSION_SET_PARAM("content", TEST_STACK_SDP), + + TSIP_SSESSION_SET_NULL()); + tsip_invite(stack, call); + } + */ + + /* SUBSCRIBE */ + //{ + // tsip_ssession_handle_t *ss2 = tsip_ssession_create(stack, + // TSIP_SSESSION_SET_CONTEXT(usr_context), + // TSIP_SSESSION_SET_HEADER("expires", "35"), + // TSIP_SSESSION_SET_HEADER("Event", "reg"), + // TSIP_SSESSION_SET_HEADER("Accept", "application/reginfo+xml"), + // TSIP_SSESSION_SET_HEADER("Allow-Events", "refer, presence, presence.winfo, xcap-diff"), + // TSIP_SSESSION_SET_HEADER("Allow", "INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER"), + // + // tsk_null); - tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, "sip:"DOMAIN, "mamadou@"DOMAIN, "sip:mamadou@"DOMAIN, - TSIP_STACK_SET_DISPLAY_NAME("Mamadou"), - TSIP_STACK_SET_PASSWORD("mamadou"), - TSIP_STACK_SET_IMS_AKA_AMF(AMF), - TSIP_STACK_SET_IMS_AKA_OPERATOR_ID("0xff08"), - TSIP_STACK_SET_HEADER("User-Agent", "IM-client/OMA1.0 doubango/v1.0.0"), - - TSIP_STACK_SET_PROXY_CSCF("192.168.0.13", 5081, "tcp", "ipv4"), - TSIP_STACK_SET_LOCAL_IP(LOCAL_IP), - - TSIP_STACK_SET_EARLY_IMS(tsk_true), - - -/* - tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, "sip:"DOMAIN, "2233392625", "sip:2233392625@"DOMAIN, - TSIP_STACK_SET_DISPLAY_NAME("Mamadou"), - TSIP_STACK_SET_PASSWORD("d3sb7j4fb8"), - - TSIP_STACK_SET_EARLY_IMS(tsk_true), - - TSIP_STACK_SET_HEADER("User-Agent", "IM-client/OMA1.0 doubango/v1.0.0"), -*/ -/* - tsip_stack_handle_t *stack = tsip_stack_create(test_stack_callback, - TSIP_STACK_SET_DISPLAY_NAME("Mamadou"), - TSIP_STACK_SET_PUBLIC_IDENTITY("sip:mamadou@"DOMAIN), - TSIP_STACK_SET_PRIVATE_IDENTITY("mamadou@"DOMAIN), - TSIP_STACK_SET_PASSWORD("mamadou"), - TSIP_STACK_SET_REALM("sip:"DOMAIN), // FIXME: without sip: - TSIP_STACK_SET_LOCAL_IP(LOCAL_IP), - //TSIP_STACK_SET_DISCOVERY_NAPTR(1), - TSIP_STACK_SET_PROXY_CSCF("192.168.16.104", "udp", 0), - //TSIP_STACK_SET_PROXY_CSCF("192.168.0.15", "udp", 0), - TSIP_STACK_SET_PROXY_CSCF_PORT(5060), - //TSIP_STACK_SET_SECAGREE_IPSEC("hmac-md5-96", "null", "trans", "esp"), - TSIP_STACK_SET_MOBILITY("fixed"), - TSIP_STACK_SET_DEVICE_ID("dd1289fa-c3d7-47bd-a40d-f1f1b2cc5ffc"), - TSIP_STACK_SET_NETINFO("ADSL;utran-cell-id-3gpp=00000000"), - TSIP_STACK_SET_PRIVACY("header;id"), -*/ + // tsip_subscribe(ss2, + // TSIP_ACTION_SET_HEADER("Description", "subscribing"), - TSIP_STACK_SET_NULL()); - - - - - //tsip_ssession_handle_t *op = tsip_ssession_create(stack, - // TSIP_SSESSION_SET_CONTEXT(usr_context), - // TSIP_SSESSION_SET_HEADER("expires", "30"), - // TSIP_SSESSION_SET_HEADER("Persistence", "session"), - // - // TSIP_SSESSION_SET_CAPS("language", "\"en,fr\""), - // TSIP_SSESSION_SET_CAPS("+audio", ""), - // TSIP_SSESSION_SET_CAPS("+g.oma.sip-im", ""), - // - // tsk_null); - - -tsip_ssession_handle_t *op = tsip_ssession_create(stack, - TSIP_SSESSION_SET_EXPIRES(30), - - TSIP_SSESSION_SET_CAPS("+g.oma.sip-im", ""), - TSIP_SSESSION_SET_CAPS("+audio", ""), - TSIP_SSESSION_SET_CAPS("automata", ""), - TSIP_SSESSION_SET_CAPS("language", "\"en,fr\""), - - TSIP_SSESSION_SET_HEADER("Supported", "ssl"), - TSIP_SSESSION_SET_HEADER("P-Access-Network-Info", "3GPP-UTRAN-TDD;utran-cell-id-3gpp=AAAAA0000BBBB"), - - TSIP_SSESSION_UNSET_HEADER("P-Access-Network-Info"), - - TSIP_SSESSION_SET_NULL()); - - //tsip_ssession_id_t opid = tsip_ssession_get_id(op); - - if((ret = tsip_stack_start(stack))){ - goto bail; - } - - tsip_action_REGISTER(op, - TSIP_ACTION_SET_HEADER("My-Header-1", "My-Value-1"), - TSIP_ACTION_SET_HEADER("My-Header-2", "My-Value-1"), - - TSIP_ACTION_SET_NULL()); - - getchar(); - //tsk_thread_sleep(2000); - - tsip_action_UNREGISTER(op, - TSIP_ACTION_SET_NULL() - ); - - getchar(); - tsk_thread_sleep(2000); - - //tsip_unregister(op, - // TSIP_ACTION_SET_HEADER("Persistence2", "action"), - // - // tsk_null); -/* - tsip_subscribe(op, - TSIP_ACTION_SET_HEADER("Persistence", "action"), - - tsk_null); - - tsk_thread_sleep(5000); - - tsip_unsubscribe(op, - TSIP_ACTION_SET_HEADER("Persistence2", "action"), - - tsk_null); - */ - - /* INVITE */ - /* - { - tsip_ssession_handle_t *call = TSIP_SSESSION_CREATE(stack, - TSIP_SSESSION_SET_HEADER("to", "sip:samba@"DOMAIN), - TSIP_SSESSION_SET_CAPS("+g.3gpp.icsi-ref", "\"urn%3Aurn-7%3gpp-service.ims.icsi.mmtel\""), - TSIP_SSESSION_SET_HEADER("Supported", "timer, norefersub, precondition"), - TSIP_SSESSION_SET_HEADER("Require", "100rel"), - - TSIP_SSESSION_SET_PARAM("content", TEST_STACK_SDP), - - TSIP_SSESSION_SET_NULL()); - tsip_invite(stack, call); - } - */ - - /* SUBSCRIBE */ - //{ - // tsip_ssession_handle_t *ss2 = tsip_ssession_create(stack, - // TSIP_SSESSION_SET_CONTEXT(usr_context), - // TSIP_SSESSION_SET_HEADER("expires", "35"), - // TSIP_SSESSION_SET_HEADER("Event", "reg"), - // TSIP_SSESSION_SET_HEADER("Accept", "application/reginfo+xml"), - // TSIP_SSESSION_SET_HEADER("Allow-Events", "refer, presence, presence.winfo, xcap-diff"), - // TSIP_SSESSION_SET_HEADER("Allow", "INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER"), - // - // tsk_null); - - // tsip_subscribe(ss2, - // TSIP_ACTION_SET_HEADER("Description", "subscribing"), - - // tsk_null); - - // getchar(); - - // tsip_unsubscribe(ss2, - // TSIP_ACTION_SET_HEADER("Test", "unsubscribing"), - // - // tsk_null); - //} - - /* MESSAGE */ - //{ - // tsip_ssession_handle_t *ss3 = TSIP_SSESSION_CREATE(stack, - // TSIP_SSESSION_SET_HEADER("to", "sip:alice@"DOMAIN), - // TSIP_SSESSION_SET_HEADER("Accept-Contact", "*;+g.oma.sip-im"), - // - // tsk_null); - // tsip_message(ss3, - // TSIP_ACTION_SET_HEADER("Content-Type", "text/plain"), - // TSIP_ACTION_SET_PAYLOAD("Hello world!", tsk_strlen("Hello world!")), - - // tsk_null - // ); - //} - - /* PUBLISH */ - /*{ - tsip_ssession_handle_t *ss4 = TSIP_SSESSION_CREATE(stack, - TSIP_SSESSION_SET_HEADER("expires", "30"), - TSIP_SSESSION_SET_HEADER("to", "sip:mamadou@"DOMAIN), - - TSIP_SSESSION_SET_HEADER("Accept-Contact", "*;+g.oma.sip-im"), - TSIP_SSESSION_SET_HEADER("Event", "presence"), - - tsk_null); - - tsip_publish(ss4, - TSIP_ACTION_SET_HEADER("Description", "publish"), - TSIP_ACTION_SET_HEADER("Content-Type", "application/pidf+xml"), - TSIP_ACTION_SET_PAYLOAD(TEST_STACK_PIDF, tsk_strlen(TEST_STACK_PIDF)), - - tsk_null); - - getchar(); - - tsip_unpublish(ss4, - TSIP_ACTION_SET_HEADER("Description", "unpublish"), - - tsk_null); - } - */ - // /*getchar(); - // tsip_ssession_set(op4, - // TSIP_SSESSION_SET_PARAM("content", TEST_STACK_PIDF), - - // TSIP_SSESSION_SET_NULL()); - // tsip_publish(stack, op4);*/ - // - // getchar(); - // tsip_ssession_hangup(op4); - // - //} + // tsk_null); + + // getchar(); + + // tsip_unsubscribe(ss2, + // TSIP_ACTION_SET_HEADER("Test", "unsubscribing"), + // + // tsk_null); + //} + + /* MESSAGE */ + //{ + // tsip_ssession_handle_t *ss3 = TSIP_SSESSION_CREATE(stack, + // TSIP_SSESSION_SET_HEADER("to", "sip:alice@"DOMAIN), + // TSIP_SSESSION_SET_HEADER("Accept-Contact", "*;+g.oma.sip-im"), + // + // tsk_null); + // tsip_message(ss3, + // TSIP_ACTION_SET_HEADER("Content-Type", "text/plain"), + // TSIP_ACTION_SET_PAYLOAD("Hello world!", tsk_strlen("Hello world!")), + + // tsk_null + // ); + //} + + /* PUBLISH */ + /*{ + tsip_ssession_handle_t *ss4 = TSIP_SSESSION_CREATE(stack, + TSIP_SSESSION_SET_HEADER("expires", "30"), + TSIP_SSESSION_SET_HEADER("to", "sip:mamadou@"DOMAIN), + + TSIP_SSESSION_SET_HEADER("Accept-Contact", "*;+g.oma.sip-im"), + TSIP_SSESSION_SET_HEADER("Event", "presence"), + + tsk_null); + + tsip_publish(ss4, + TSIP_ACTION_SET_HEADER("Description", "publish"), + TSIP_ACTION_SET_HEADER("Content-Type", "application/pidf+xml"), + TSIP_ACTION_SET_PAYLOAD(TEST_STACK_PIDF, tsk_strlen(TEST_STACK_PIDF)), + + tsk_null); + + getchar(); + + tsip_unpublish(ss4, + TSIP_ACTION_SET_HEADER("Description", "unpublish"), + + tsk_null); + } + */ + // /*getchar(); + // tsip_ssession_set(op4, + // TSIP_SSESSION_SET_PARAM("content", TEST_STACK_PIDF), + + // TSIP_SSESSION_SET_NULL()); + // tsip_publish(stack, op4);*/ + // + // getchar(); + // tsip_ssession_hangup(op4); + // + //} bail: - //while(1);//tsk_thread_sleep(500); - //while(1) - //tsk_thread_sleep(50000); - getchar(); + //while(1);//tsk_thread_sleep(500); + //while(1) + //tsk_thread_sleep(50000); + getchar(); - tsip_stack_stop(stack); + tsip_stack_stop(stack); - TSK_OBJECT_SAFE_FREE(op); - TSK_OBJECT_SAFE_FREE(stack); + TSK_OBJECT_SAFE_FREE(op); + TSK_OBJECT_SAFE_FREE(stack); - TSK_DEBUG_INFO("=================="); - TSK_DEBUG_INFO("=================="); - TSK_DEBUG_INFO("=================="); - TSK_DEBUG_INFO("=================="); + TSK_DEBUG_INFO("=================="); + TSK_DEBUG_INFO("=================="); + TSK_DEBUG_INFO("=================="); + TSK_DEBUG_INFO("=================="); } diff --git a/tinySIP/test/test_transac.h b/tinySIP/test/test_transac.h index 3f31173..e274811 100755 --- a/tinySIP/test/test_transac.h +++ b/tinySIP/test/test_transac.h @@ -2,19 +2,19 @@ * Copyright (C) 2009 Mamadou Diop. * * Contact: Mamadou Diop -* +* * This file is part of Open Source Doubango Framework. * * DOUBANGO 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 3 of the License, or * (at your option) any later version. -* +* * DOUBANGO 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 DOUBANGO. * @@ -24,11 +24,11 @@ void test_transac() { - //tsip_transac_nict_t transact; + //tsip_transac_nict_t transact; - //tsip_transac_nict_init(&transact); + //tsip_transac_nict_init(&transact); - //tsk_thread_sleep(2000); + //tsk_thread_sleep(2000); } #endif /* _TEST_TRANSAC_H */ diff --git a/tinySIP/test/test_uri.h b/tinySIP/test/test_uri.h index befbdfd..0558b93 100755 --- a/tinySIP/test/test_uri.h +++ b/tinySIP/test/test_uri.h @@ -2,19 +2,19 @@ * Copyright (C) 2009 Mamadou Diop. * * Contact: Mamadou Diop -* +* * This file is part of Open Source Doubango Framework. * * DOUBANGO 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 3 of the License, or * (at your option) any later version. -* +* * DOUBANGO 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 DOUBANGO. * @@ -22,156 +22,148 @@ #ifndef _TEST_SIPURI_H #define _TEST_SIPURI_H -const char* uris[] = -{ - - //== SIP: - "sip:123.com", - "sip:open-ims.test", - "sip:pcscf.open-ims.test:4060;lr;transport=udp", - "sip:2233392625@sip2sip.info", - "sip:alice@iatlanta.com;p1=23", - "sip:*666*@atlanta.com", - "sip:#66#@atlanta.com", // should fail: # must be replaced with %23 - "sip:alice:secretword@atlanta.com", - "sip:alice:secretword@atlanta.com:65535;transport=tcp", +const char* uris[] = { + + //== SIP: + "sip:123.com", + "sip:open-ims.test", + "sip:pcscf.open-ims.test:4060;lr;transport=udp", + "sip:2233392625@sip2sip.info", + "sip:alice@iatlanta.com;p1=23", + "sip:*666*@atlanta.com", + "sip:#66#@atlanta.com", // should fail: # must be replaced with %23 + "sip:alice:secretword@atlanta.com", + "sip:alice:secretword@atlanta.com:65535;transport=tcp", "sip:+1-212-555-1212:1234@gateway.com;user=phone", - "sip:alice@192.0.2.4:5060", - "sip:alice@[1111::aaa:bbb:ccc:ddd]:5060", - "sip:atlanta.com", - "sip:alice@[1111::aaa:bbb:ccc:ddd]", - "sip:alice@[1111::aaa:bbb:ccc:ddd]:5060;user=phone", - "sip:alice@1111::aaa:bbb:ccc:ddd", // should fail - "sip:alice@[::127]", - "sip:ss2.biloxi.example.com;lr",// FIXME + "sip:alice@192.0.2.4:5060", + "sip:alice@[1111::aaa:bbb:ccc:ddd]:5060", + "sip:atlanta.com", + "sip:alice@[1111::aaa:bbb:ccc:ddd]", + "sip:alice@[1111::aaa:bbb:ccc:ddd]:5060;user=phone", + "sip:alice@1111::aaa:bbb:ccc:ddd", // should fail + "sip:alice@[::127]", + "sip:ss2.biloxi.example.com;lr",// FIXME "sip:atlanta.com;method=REGISTER?to=alice%40atlanta.com", "sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15", "sip:alice@atlanta.com;comp=sigcomp", - "sip:atlanta.com;method=REGISTER?to=alice%40atlanta.com", + "sip:atlanta.com;method=REGISTER?to=alice%40atlanta.com", "sip:alice@atlanta.com?subject=project%20x&priority=urgent", - //== SIPS: - "sips:alice@atlanta.com", + //== SIPS: + "sips:alice@atlanta.com", "sips:alice:secretword@atlanta.com;transport=tcp", "sips:+1-212-555-1212:1234@gateway.com;user=phone", "sips:alice@192.0.2.4", "sips:atlanta.com;method=REGISTER?to=alice%40atlanta.com", "sips:alice@atlanta.com;maddr=239.255.255.1;ttl=15", "sips:alice@atlanta.com;comp=sigcomp", - "sips:atlanta.com;method=REGISTER?to=alice%40atlanta.com", + "sips:atlanta.com;method=REGISTER?to=alice%40atlanta.com", "sips:alice@atlanta.com?subject=project%20x&priority=urgent", - //== TEL: - "tel:+1-201-555-0123", + //== TEL: + "tel:+1-201-555-0123", "tel:7042;phone-context=example.com;ff=ff", "tel:863-1234;phone-context=+1-914-555", - "tel:#666#", + "tel:#666#", }; void test_uri_tostring(const tsip_uri_t *uri) { - char* ret = tsip_uri_tostring(uri, 1, 1); - TSK_DEBUG_INFO("uri_to_string=%s", ret); - TSK_FREE(ret); + char* ret = tsip_uri_tostring(uri, 1, 1); + TSK_DEBUG_INFO("uri_to_string=%s", ret); + TSK_FREE(ret); } void test_uri_parser() { - int i; - tsk_list_item_t *item = 0; - - for(i=0; ischeme); - printf("user-name: %s\n", uri->user_name); - printf("password: %s\n", uri->password); - printf("host: %s\n", uri->host); - printf("port: %d\n", uri->port); - printf("host-type: %s\n", uri->host_type == host_ipv4 ? "IPv4" : (uri->host_type == host_ipv6 ? "IPv6" : (uri->host_type == host_hostname ? "HOSTNAME" : "UNKNOWN")) ); - - printf("---PARAMS---\n"); - - /* dump all parameters */ - tsk_list_foreach(item, uri->params) - { - tsk_param_t* param = item->data; - printf("-->%s=%s\n", param->name, param->value); - } - - printf("Is-secure: %s\n", TSIP_URI_IS_SECURE(uri) ? "YES" : "NO"); - - test_uri_tostring(uri); - } - else - { - printf("INVALID SIP URI.\n"); - } - - printf("\n\n"); - getchar(); - - TSK_OBJECT_SAFE_FREE(uri); - } + int i; + tsk_list_item_t *item = 0; + + for(i=0; ischeme); + printf("user-name: %s\n", uri->user_name); + printf("password: %s\n", uri->password); + printf("host: %s\n", uri->host); + printf("port: %d\n", uri->port); + printf("host-type: %s\n", uri->host_type == host_ipv4 ? "IPv4" : (uri->host_type == host_ipv6 ? "IPv6" : (uri->host_type == host_hostname ? "HOSTNAME" : "UNKNOWN")) ); + + printf("---PARAMS---\n"); + + /* dump all parameters */ + tsk_list_foreach(item, uri->params) { + tsk_param_t* param = item->data; + printf("-->%s=%s\n", param->name, param->value); + } + + printf("Is-secure: %s\n", TSIP_URI_IS_SECURE(uri) ? "YES" : "NO"); + + test_uri_tostring(uri); + } + else { + printf("INVALID SIP URI.\n"); + } + + printf("\n\n"); + getchar(); + + TSK_OBJECT_SAFE_FREE(uri); + } } -struct test_uri_bundle -{ - const char* uri1; - const char* uri2; +struct test_uri_bundle { + const char* uri1; + const char* uri2; - unsigned match:1; + unsigned match:1; }; // From RFC 3261 - 19.1.4 URI Comparison -struct test_uri_bundle test_uri_bundles[] = -{ - /* Match */ - { "sip:%61lice@atlanta.com;transport=TCP", "sip:alice@AtLanTa.CoM;Transport=tcp", 1 }, - { "sip:carol@chicago.com", "sip:carol@chicago.com;newparam=5", 1 }, - { "sip:carol@chicago.com", "sip:carol@chicago.com;security=on", 1 }, - { "sip:carol@chicago.com;newparam=5", "sip:carol@chicago.com;security=on", 1 }, - { "sip:biloxi.com;transport=tcp;method=REGISTER?to=sip:bob%40biloxi.com", "sip:biloxi.com;method=REGISTER;transport=tcp?to=sip:bob%40biloxi.com", 1 }, - { "sip:alice@atlanta.com?subject=project%20x&priority=urgent", "sip:alice@atlanta.com?priority=urgent&subject=project%20x", 1 }, - - /* Do not match */ - { "SIP:ALICE@AtLanTa.CoM;Transport=udp", "sip:alice@AtLanTa.CoM;Transport=UDP", 0 }, /* different usernames */ - { "sip:bob@biloxi.com", "sip:bob@biloxi.com:5060", 0 }, /* can resolve to different ports */ - { "sip:bob@biloxi.com", "sip:bob@biloxi.com;transport=udp", 0 }, /* can resolve to different transports */ - { "sip:bob@biloxi.com", "sip:bob@biloxi.com:6000;transport=tcp", 0 }, /* can resolve to different port and transports */ - { "sip:carol@chicago.com", "sip:carol@chicago.com?Subject=next%20meeting", 0 }, /* different header component */ - { "sip:bob@phone21.boxesbybob.com", "sip:bob@192.0.2.4", 0 }, /* even though that's what phone21.boxesbybob.com resolves to*/ +struct test_uri_bundle test_uri_bundles[] = { + /* Match */ + { "sip:%61lice@atlanta.com;transport=TCP", "sip:alice@AtLanTa.CoM;Transport=tcp", 1 }, + { "sip:carol@chicago.com", "sip:carol@chicago.com;newparam=5", 1 }, + { "sip:carol@chicago.com", "sip:carol@chicago.com;security=on", 1 }, + { "sip:carol@chicago.com;newparam=5", "sip:carol@chicago.com;security=on", 1 }, + { "sip:biloxi.com;transport=tcp;method=REGISTER?to=sip:bob%40biloxi.com", "sip:biloxi.com;method=REGISTER;transport=tcp?to=sip:bob%40biloxi.com", 1 }, + { "sip:alice@atlanta.com?subject=project%20x&priority=urgent", "sip:alice@atlanta.com?priority=urgent&subject=project%20x", 1 }, + + /* Do not match */ + { "SIP:ALICE@AtLanTa.CoM;Transport=udp", "sip:alice@AtLanTa.CoM;Transport=UDP", 0 }, /* different usernames */ + { "sip:bob@biloxi.com", "sip:bob@biloxi.com:5060", 0 }, /* can resolve to different ports */ + { "sip:bob@biloxi.com", "sip:bob@biloxi.com;transport=udp", 0 }, /* can resolve to different transports */ + { "sip:bob@biloxi.com", "sip:bob@biloxi.com:6000;transport=tcp", 0 }, /* can resolve to different port and transports */ + { "sip:carol@chicago.com", "sip:carol@chicago.com?Subject=next%20meeting", 0 }, /* different header component */ + { "sip:bob@phone21.boxesbybob.com", "sip:bob@192.0.2.4", 0 }, /* even though that's what phone21.boxesbybob.com resolves to*/ }; void test_uri_cmp() { - size_t i; - - for(i=0; i< sizeof(test_uri_bundles)/sizeof(struct test_uri_bundle); i++) - { - tsip_uri_t *uri1 = tsip_uri_parse(test_uri_bundles[i].uri1, tsk_strlen(test_uri_bundles[i].uri1)); - tsip_uri_t *uri2 = tsip_uri_parse(test_uri_bundles[i].uri2, tsk_strlen(test_uri_bundles[i].uri2)); - - if(tsk_object_cmp(uri1, uri2) && test_uri_bundles[i].match){ - TSK_DEBUG_ERROR("URI Comparison failed."); - } - else{ - TSK_DEBUG_INFO("URI Comparison ok."); - } - - TSK_OBJECT_SAFE_FREE(uri1); - TSK_OBJECT_SAFE_FREE(uri2); - } + size_t i; + + for(i=0; i< sizeof(test_uri_bundles)/sizeof(struct test_uri_bundle); i++) { + tsip_uri_t *uri1 = tsip_uri_parse(test_uri_bundles[i].uri1, tsk_strlen(test_uri_bundles[i].uri1)); + tsip_uri_t *uri2 = tsip_uri_parse(test_uri_bundles[i].uri2, tsk_strlen(test_uri_bundles[i].uri2)); + + if(tsk_object_cmp(uri1, uri2) && test_uri_bundles[i].match) { + TSK_DEBUG_ERROR("URI Comparison failed."); + } + else { + TSK_DEBUG_INFO("URI Comparison ok."); + } + + TSK_OBJECT_SAFE_FREE(uri1); + TSK_OBJECT_SAFE_FREE(uri2); + } } void test_uri() { - test_uri_parser(); - test_uri_cmp(); + test_uri_parser(); + test_uri_cmp(); } #endif /* _TEST_SIPURI_H */ -- cgit v1.1