From bf0db8f9e4e18b4745a55e7943b59ced8ff4a8d2 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 28 Feb 2013 16:06:13 +0100 Subject: [PATCH] io error repporting for calls --- coreapi/bellesip_sal/sal_impl.c | 10 ++++++++-- coreapi/bellesip_sal/sal_op_call.c | 9 ++++++++- coreapi/bellesip_sal/sal_op_impl.c | 6 +++--- coreapi/sal.h | 3 +++ tester/call_tester.c | 20 ++++++++++++++++++++ tester/liblinphone_tester.c | 10 ++++++---- 6 files changed, 48 insertions(+), 10 deletions(-) diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index 619defd5c..17e3f2d42 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -582,8 +582,8 @@ MSList * sal_get_pending_auths(Sal *sal){ /*misc*/ void sal_get_default_local_ip(Sal *sal, int address_family, char *ip, size_t iplen){ - ms_fatal("sal_get_default_local_ip not implemented yet"); - return ; + strncpy(ip,address_family==AF_INET6 ? "::1" : "127.0.0.1",iplen); + ms_error("Could not find default routable ip address !"); } const char *sal_get_root_ca(Sal* ctx) { @@ -611,3 +611,9 @@ void sal_nat_helper_enable(Sal *sal,bool_t enable) { bool_t sal_nat_helper_enabled(Sal *sal) { return sal->nat_helper_enabled; } +void sal_set_dns_timeout(Sal* sal,int timeout) { + belle_sip_stack_set_dns_timeout(sal->stack, timeout); +} +int sal_get_dns_timeout(const Sal* sal) { + return belle_sip_stack_get_dns_timeout(sal->stack); +} diff --git a/coreapi/bellesip_sal/sal_op_call.c b/coreapi/bellesip_sal/sal_op_call.c index 88f6d7457..f2ec4e883 100644 --- a/coreapi/bellesip_sal/sal_op_call.c +++ b/coreapi/bellesip_sal/sal_op_call.c @@ -81,7 +81,14 @@ static int set_sdp_from_desc(belle_sip_message_t *msg, const SalMediaDescription } static void call_process_io_error(void *user_ctx, const belle_sip_io_error_event_t *event){ - ms_error("call_process_io_error not implemented yet"); + SalOp* op=(SalOp*)user_ctx; + if (!op->dialog) { + /*call terminated very early*/ + op->base.root->callbacks.call_failure(op,SalErrorNoResponse,SalReasonUnknown,"Service Unavailable",503); + op->state=SalOpStateTerminated; + } else { + /*dialog will terminated shortly, nothing to do*/ + } } static void process_dialog_terminated(void *ctx, const belle_sip_dialog_terminated_event_t *event) { SalOp* op=(SalOp*)ctx; diff --git a/coreapi/bellesip_sal/sal_op_impl.c b/coreapi/bellesip_sal/sal_op_impl.c index c33feb7d4..43ceb22ae 100644 --- a/coreapi/bellesip_sal/sal_op_impl.c +++ b/coreapi/bellesip_sal/sal_op_impl.c @@ -169,7 +169,7 @@ static int _sal_op_send_request_with_contact(SalOp* op, belle_sip_request_t* req } int sal_op_send_request(SalOp* op, belle_sip_request_t* request) { - bool_t need_ack=FALSE; + bool_t need_contact=FALSE; /* Header field where proxy ACK BYE CAN INV OPT REG ___________________________________________________________ @@ -179,9 +179,9 @@ int sal_op_send_request(SalOp* op, belle_sip_request_t* request) { ||strcmp(belle_sip_request_get_method(request),"REGISTER")==0 ||strcmp(belle_sip_request_get_method(request),"SUBSCRIBE")==0 ||strcmp(belle_sip_request_get_method(request),"OPTION")==0) - need_ack=TRUE; + need_contact=TRUE; - return _sal_op_send_request_with_contact(op, request,need_ack); + return _sal_op_send_request_with_contact(op, request,need_contact); } diff --git a/coreapi/sal.h b/coreapi/sal.h index d7c75b46c..886f69c0f 100644 --- a/coreapi/sal.h +++ b/coreapi/sal.h @@ -519,4 +519,7 @@ void sal_set_recv_error(Sal *sal,int value); /*enable contact fixing*/ void sal_nat_helper_enable(Sal *sal,bool_t enable); bool_t sal_nat_helper_enabled(Sal *sal); + +void sal_set_dns_timeout(Sal* sal,int timeout); +int sal_get_dns_timeout(const Sal* sal); #endif diff --git a/tester/call_tester.c b/tester/call_tester.c index c68ec96ab..8ffbdb7bf 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -197,6 +197,22 @@ static void call_canceled() { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } + +static void call_with_dns_time_out() { + LinphoneCoreManager* marie = linphone_core_manager_new(NULL); + LCSipTransports transport = {9773,0,0,0}; + linphone_core_set_sip_transports(marie->lc,&transport); + linphone_core_iterate(marie->lc); + sal_set_dns_timeout(marie->lc->sal,0); + linphone_core_invite(marie->lc,"sip:toto@toto.com"); + linphone_core_iterate(marie->lc); + linphone_core_iterate(marie->lc); + CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallOutgoingInit,1); + CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallOutgoingProgress,1); + CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallError,1); + linphone_core_manager_destroy(marie); +} + static void call_ringing_canceled() { LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc"); @@ -585,6 +601,10 @@ int call_test_suite () { if (NULL == CU_add_test(pSuite, "call_canceled", call_canceled)) { return CU_get_error(); } + if (NULL == CU_add_test(pSuite, "call_with_dns_time_out", call_with_dns_time_out)) { + return CU_get_error(); + } + if (NULL == CU_add_test(pSuite, "call_ringing_canceled", call_ringing_canceled)) { return CU_get_error(); } diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c index ebbafc7d1..4c8861a13 100644 --- a/tester/liblinphone_tester.c +++ b/tester/liblinphone_tester.c @@ -159,17 +159,19 @@ LinphoneCoreManager* linphone_core_manager_new(const char* rc_file) { mgr->v_table.new_subscription_request=new_subscribtion_request; mgr->v_table.notify_presence_recv=notify_presence_received; mgr->v_table.transfer_state_changed=linphone_transfer_state_changed; - mgr->lc=configure_lc_from(&mgr->v_table,rc_file,1); + mgr->lc=configure_lc_from(&mgr->v_table,rc_file,rc_file?1:0); enable_codec(mgr->lc,"PCMU",8000); linphone_core_set_user_data(mgr->lc,&mgr->stat); linphone_core_get_default_proxy(mgr->lc,&proxy); - mgr->identity = linphone_address_new(linphone_proxy_config_get_identity(proxy)); - linphone_address_clean(mgr->identity); + if (proxy) { + mgr->identity = linphone_address_new(linphone_proxy_config_get_identity(proxy)); + linphone_address_clean(mgr->identity); + } return mgr; } void linphone_core_manager_destroy(LinphoneCoreManager* mgr) { linphone_core_destroy(mgr->lc); - linphone_address_destroy(mgr->identity); + if (mgr->identity) linphone_address_destroy(mgr->identity); free(mgr); }