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); 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*/ } status = belle_sip_response_get_status_code(belle_sip_response_event_get_response(event)); belle_sip_message("caller_process_response_event [%i]",status); if (BC_ASSERT_PTR_NOT_NULL(client_transaction)) { dialog = belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(client_transaction)); if (BC_ASSERT_PTR_NOT_NULL(dialog)) { BC_ASSERT_PTR_EQUAL(caller_dialog,dialog); if (belle_sip_dialog_get_state(dialog) == BELLE_SIP_DIALOG_NULL) { BC_ASSERT_EQUAL(status,100, int, "%d"); } else if (belle_sip_dialog_get_state(dialog) == BELLE_SIP_DIALOG_EARLY){ BC_ASSERT_EQUAL(status,180, int, "%d"); /*send 200ok from callee*/ belle_sip_server_transaction_send_response(inserv_transaction,ok_response); belle_sip_object_unref(ok_response); ok_response=NULL; } else if (belle_sip_dialog_get_state(dialog) == BELLE_SIP_DIALOG_CONFIRMED) {
/* IPv4 A query timeout */ static void ipv4_a_query_timeout(void) { endpoint_t *client = create_endpoint(); if (!BC_ASSERT_PTR_NOT_NULL(client)) return; belle_sip_stack_set_dns_timeout(client->stack, 0); client->resolver_ctx = belle_sip_stack_resolve_a(client->stack, "toto.com", SIP_PORT, AF_INET, a_resolve_done, client); BC_ASSERT_PTR_NOT_NULL(client->resolver_ctx); BC_ASSERT_TRUE(wait_for(client->stack, &client->resolve_done, 1, 2000)); BC_ASSERT_PTR_EQUAL(client->ai_list, NULL); BC_ASSERT_EQUAL(client->resolve_ko,1, int, "%d"); destroy_endpoint(client); }
/* Successful IPv4 A query with no result */ static void ipv4_a_query_no_result(void) { int timeout; endpoint_t *client = create_endpoint(); if (!BC_ASSERT_PTR_NOT_NULL(client)) return; timeout = belle_sip_stack_get_dns_timeout(client->stack); client->resolver_ctx = belle_sip_stack_resolve_a(client->stack, IPV4_SIP_BAD_DOMAIN, SIP_PORT, AF_INET, a_resolve_done, client); BC_ASSERT_PTR_NOT_NULL(client->resolver_ctx); BC_ASSERT_TRUE(wait_for(client->stack, &client->resolve_done, 1, timeout)); BC_ASSERT_PTR_EQUAL(client->ai_list, NULL); destroy_endpoint(client); }
static void call_with_tunnel_base(LinphoneTunnelMode tunnel_mode, bool_t with_sip, LinphoneMediaEncryption encryption, bool_t with_video_and_ice) { if (linphone_core_tunnel_available()){ LinphoneCoreManager *pauline = linphone_core_manager_new( "pauline_rc"); LinphoneCoreManager *marie = linphone_core_manager_new( "marie_rc"); LinphoneCall *pauline_call, *marie_call; LinphoneProxyConfig *proxy = linphone_core_get_default_proxy_config(pauline->lc); LinphoneAddress *server_addr = linphone_address_new(linphone_proxy_config_get_server_addr(proxy)); LinphoneAddress *route = linphone_address_new(linphone_proxy_config_get_route(proxy)); const char * tunnel_ip = get_ip_from_hostname("tunnel.linphone.org"); char *public_ip, *public_ip2=NULL; BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_LinphoneRegistrationOk,1)); public_ip = get_public_contact_ip(pauline->lc); BC_ASSERT_STRING_NOT_EQUAL(public_ip, tunnel_ip); linphone_core_set_media_encryption(pauline->lc, encryption); if (with_video_and_ice){ /*we want to test that tunnel is able to work with long SIP message, above mtu. * Enable ICE and many codec to make the SIP message bigger*/ linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); linphone_core_enable_payload_type(pauline->lc, linphone_core_find_payload_type(pauline->lc, "speex", 32000, 1), TRUE); linphone_core_enable_payload_type(pauline->lc, linphone_core_find_payload_type(pauline->lc, "speex", 16000, 1), TRUE); linphone_core_enable_payload_type(pauline->lc, linphone_core_find_payload_type(pauline->lc, "G722", 8000, 1), TRUE); linphone_core_enable_payload_type(marie->lc, linphone_core_find_payload_type(marie->lc, "speex", 32000, 1), TRUE); linphone_core_enable_payload_type(marie->lc, linphone_core_find_payload_type(marie->lc, "speex", 16000, 1), TRUE); linphone_core_enable_payload_type(marie->lc, linphone_core_find_payload_type(marie->lc, "G722", 8000, 1), TRUE); } if (tunnel_mode != LinphoneTunnelModeDisable){ LinphoneTunnel *tunnel = linphone_core_get_tunnel(pauline->lc); LinphoneTunnelConfig *config = linphone_tunnel_config_new(); linphone_tunnel_config_set_host(config, "tunnel.linphone.org"); linphone_tunnel_config_set_port(config, 443); linphone_tunnel_config_set_remote_udp_mirror_port(config, 12345); linphone_tunnel_add_server(tunnel, config); linphone_tunnel_set_mode(tunnel, tunnel_mode); linphone_tunnel_enable_sip(tunnel, with_sip); /* * Enabling the tunnel with sip cause another REGISTER to be made. * In automatic mode, the udp test should conclude (assuming we have a normal network), that no * tunnel is needed. Thus the number of registrations should stay to 1. * The library is missing a notification of "tunnel connectivity test finished" to enable the * full testing of the automatic mode. */ if (tunnel_mode == LinphoneTunnelModeEnable && with_sip) { BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_LinphoneRegistrationOk,2)); /* Ensure that we did use the tunnel. If so, we should see contact changed from: Contact: <sip:[email protected]>;.[...] To: Contact: <sip:[email protected]:43867>;[....] (91.121.209.194 must be tunnel.liphone.org) */ ms_free(public_ip); public_ip = get_public_contact_ip(pauline->lc); BC_ASSERT_STRING_EQUAL(public_ip, tunnel_ip); } else { public_ip2 = get_public_contact_ip(pauline->lc); BC_ASSERT_STRING_EQUAL(public_ip, public_ip2); } } BC_ASSERT_TRUE(call(pauline,marie)); pauline_call=linphone_core_get_current_call(pauline->lc); BC_ASSERT_PTR_NOT_NULL(pauline_call); if (pauline_call!=NULL){ BC_ASSERT_PTR_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(pauline_call)), encryption); } if (tunnel_mode == LinphoneTunnelModeEnable && with_sip){ /* make sure the call from pauline arrived from the tunnel by checking the contact address*/ marie_call = linphone_core_get_current_call(marie->lc); BC_ASSERT_PTR_NOT_NULL(marie_call); if (marie_call){ const char *remote_contact = linphone_call_get_remote_contact(marie_call); BC_ASSERT_PTR_NOT_NULL(remote_contact); if (remote_contact){ LinphoneAddress *tmp = linphone_address_new(remote_contact); BC_ASSERT_PTR_NOT_NULL(tmp); if (tmp){ BC_ASSERT_STRING_EQUAL(linphone_address_get_domain(tmp), tunnel_ip); linphone_address_destroy(tmp); } } } } #ifdef VIDEO_ENABLED if (with_video_and_ice){ BC_ASSERT_TRUE(add_video(pauline, marie, TRUE)); } #endif end_call(pauline,marie); ms_free(public_ip); if(public_ip2 != NULL) ms_free(public_ip2); linphone_address_destroy(server_addr); linphone_address_destroy(route); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie); }else{ ms_warning("Could not test %s because tunnel functionality is not available",__FUNCTION__); } }