diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index 33d44cec7..b037bbf60 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -107,7 +107,17 @@ static void process_dialog_terminated(void *sal, const belle_sip_dialog_terminat } } static void process_io_error(void *user_ctx, const belle_sip_io_error_event_t *event){ - ms_error("process_io_error not implemented yet"); + belle_sip_client_transaction_t*client_transaction; + SalOp* op; + if (belle_sip_object_is_instance_of(BELLE_SIP_OBJECT(belle_sip_io_error_event_get_source(event)),BELLE_SIP_TYPE_ID(belle_sip_client_transaction_t))) { + client_transaction=BELLE_SIP_CLIENT_TRANSACTION(belle_sip_io_error_event_get_source(event)); + op = (SalOp*)belle_sip_transaction_get_application_data(BELLE_SIP_TRANSACTION(client_transaction)); + if (op->callbacks.process_io_error) { + op->callbacks.process_io_error(op,event); + } + } else { + ms_error("process_io_error not implemented yet for non transaction"); + } } static void process_request_event(void *sal, const belle_sip_request_event_t *event) { SalOp* op=NULL; @@ -580,3 +590,6 @@ void sal_set_dscp(Sal *ctx, int dscp){ void sal_set_send_error(Sal *sal,int value) { belle_sip_stack_set_send_error(sal->stack,value); } +void sal_set_recv_error(Sal *sal,int value) { + belle_sip_provider_set_recv_error(sal->prov,value); +} diff --git a/coreapi/bellesip_sal/sal_op_call.c b/coreapi/bellesip_sal/sal_op_call.c index 74db3bba1..a39cc3dbb 100644 --- a/coreapi/bellesip_sal/sal_op_call.c +++ b/coreapi/bellesip_sal/sal_op_call.c @@ -82,7 +82,7 @@ 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("process_io_error not implemented yet"); + ms_error("call_process_io_error not implemented yet"); } 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 bd5af0598..a22c5392a 100644 --- a/coreapi/bellesip_sal/sal_op_impl.c +++ b/coreapi/bellesip_sal/sal_op_impl.c @@ -34,6 +34,7 @@ void sal_op_release(SalOp *op){ belle_sip_refresher_stop(op->registration_refresher); belle_sip_object_unref(op->registration_refresher); } + if (op->pending_inv_client_trans) belle_sip_object_unref(op->pending_inv_client_trans); __sal_op_free(op); return ; } @@ -135,7 +136,9 @@ int sal_op_send_request(SalOp* op, belle_sip_request_t* request) { client_transaction = belle_sip_provider_create_client_transaction(prov,request); belle_sip_transaction_set_application_data(BELLE_SIP_TRANSACTION(client_transaction),op); if ( strcmp("INVITE",belle_sip_request_get_method(request))==0) { + if (op->pending_inv_client_trans) belle_sip_object_unref(op->pending_inv_client_trans); op->pending_inv_client_trans=client_transaction; /*update pending inv for being able to cancel*/ + belle_sip_object_ref(op->pending_inv_client_trans); } if (!belle_sip_message_get_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_AUTHORIZATION) diff --git a/coreapi/bellesip_sal/sal_op_registration.c b/coreapi/bellesip_sal/sal_op_registration.c index d4c6c37eb..4f5036ae2 100644 --- a/coreapi/bellesip_sal/sal_op_registration.c +++ b/coreapi/bellesip_sal/sal_op_registration.c @@ -21,7 +21,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static void register_process_io_error(void *user_ctx, const belle_sip_io_error_event_t *event){ - ms_error("process_io_error not implemented yet"); + SalOp* op = (SalOp*)user_ctx; + ms_error("register_process_io_error io error reported for [%s]",sal_op_get_proxy(op)); + if (op->registration_refresher) { + op->base.root->callbacks.register_failure(op,SalErrorFailure,SalErrorFailure,"io error"); + } } static void register_refresher_listener ( const belle_sip_refresher_t* refresher @@ -46,53 +50,16 @@ static void register_response_event(void *user_ctx, const belle_sip_response_eve belle_sip_client_transaction_t* client_transaction = belle_sip_response_event_get_client_transaction(event); SalOp* op = (SalOp*)belle_sip_transaction_get_application_data(BELLE_SIP_TRANSACTION(client_transaction)); belle_sip_response_t* response = belle_sip_response_event_get_response(event); -/* belle_sip_request_t* original_request=belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(client_transaction)); - belle_sip_header_expires_t* expires_header; - belle_sip_header_contact_t* original_contact=belle_sip_message_get_header_by_type(original_request,belle_sip_header_contact_t); - const belle_sip_list_t* contact_header_list; - char* tmp_string;*/ - - belle_sip_header_service_route_t* service_route; belle_sip_header_address_t* service_route_address=NULL; int response_code = belle_sip_response_get_status_code(response); - /*int expires=-1;*/ if (response_code<200) return;/*nothing to do*/ switch (response_code) { case 200: { -/* contact_header_list = belle_sip_message_get_headers(BELLE_SIP_MESSAGE(response),BELLE_SIP_CONTACT); - if (contact_header_list) { - contact_header_list = belle_sip_list_find_custom((belle_sip_list_t*)contact_header_list,(belle_sip_compare_func)belle_sip_header_contact_not_equals, (const void*)original_contact); - if (!contact_header_list) { - reset header list - contact_header_list = belle_sip_message_get_headers(BELLE_SIP_MESSAGE(response),BELLE_SIP_CONTACT); - contact_header_list = belle_sip_list_find_custom((belle_sip_list_t*)contact_header_list,(belle_sip_compare_func)belle_sip_header_contact_not_equals, (const void*)sal_op_get_contact_address(op)); - } - if (!contact_header_list) { - tmp_string=belle_sip_object_to_string(BELLE_SIP_OBJECT(original_contact)); - ms_error("no matching contact neither for [%s] nor [%s]", tmp_string, sal_op_get_contact(op)); - belle_sip_free(tmp_string); - } else { - expires=belle_sip_header_contact_get_expires(BELLE_SIP_HEADER_CONTACT(contact_header_list->data)); - } - } - - if (expires<0 ) { - no contact with expire, looking for Expires header - if ((expires_header=(belle_sip_header_expires_t*)belle_sip_message_get_header(BELLE_SIP_MESSAGE(response),BELLE_SIP_EXPIRES))) { - expires = belle_sip_header_expires_get_expires(expires_header); - } - } - if (expires<0) { - if ((expires_header=(belle_sip_header_expires_t*)belle_sip_message_get_header(BELLE_SIP_MESSAGE(original_request),BELLE_SIP_EXPIRES))) { - expires = belle_sip_header_expires_get_expires(expires_header); - ms_message("Neither Expires header nor corresponding Contact header found, using expires value [%i] from request",expires); - } - }*/ /*check service route rfc3608*/ if ((service_route=belle_sip_message_get_header_by_type(response,belle_sip_header_service_route_t))) { service_route_address=belle_sip_header_address_create(NULL,belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(service_route))); diff --git a/coreapi/sal.h b/coreapi/sal.h index 1084ebce6..0f5c646b9 100644 --- a/coreapi/sal.h +++ b/coreapi/sal.h @@ -491,4 +491,6 @@ void __sal_op_free(SalOp *b); /*test api*/ /*0 for no error*/ void sal_set_send_error(Sal *sal,int value); +/*1 for no error*/ +void sal_set_recv_error(Sal *sal,int value); #endif diff --git a/tester/register_tester.c b/tester/register_tester.c index 826c3703d..a655a8c86 100644 --- a/tester/register_tester.c +++ b/tester/register_tester.c @@ -235,6 +235,25 @@ static void network_state_change(){ linphone_core_destroy(lc); } +static void io_recv_error(){ + LinphoneCoreVTable v_table; + LinphoneCore* lc; + int register_ok; + stats* counters ; + + memset (&v_table,0,sizeof(LinphoneCoreVTable)); + v_table.registration_state_changed=registration_state_changed; + lc=configure_lc(&v_table); + counters = (stats*)linphone_core_get_user_data(lc); + register_ok=counters->number_of_LinphoneRegistrationOk; + sal_set_recv_error(lc->sal, 0); + + CU_ASSERT_TRUE_FATAL(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationFailed,register_ok-1 /*because 1 udp*/)); + sal_set_recv_error(lc->sal, 1); /*reset*/ + + linphone_core_destroy(lc); +} + int register_test_suite () { CU_pSuite pSuite = CU_add_suite("Register", NULL, NULL); @@ -272,6 +291,9 @@ int register_test_suite () { if (NULL == CU_add_test(pSuite, "network_state_change", network_state_change)) { return CU_get_error(); } + if (NULL == CU_add_test(pSuite, "io_recv_error_0", io_recv_error)) { + return CU_get_error(); + } return 0; }