LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCreator *creator) { LinphoneAuthInfo *info; LinphoneProxyConfig *cfg = linphone_core_create_proxy_config(creator->core); char *identity_str = _get_identity(creator); LinphoneAddress *identity = linphone_address_new(identity_str); char *route = NULL; char *domain = NULL; ms_free(identity_str); if (creator->display_name) { linphone_address_set_display_name(identity, creator->display_name); } if (creator->route) { route = ms_strdup_printf("%s;transport=%s", creator->route, linphone_transport_to_string(creator->transport)); } if (creator->domain) { domain = ms_strdup_printf("%s;transport=%s", creator->domain, linphone_transport_to_string(creator->transport)); } linphone_proxy_config_set_identity_address(cfg, identity); linphone_proxy_config_set_server_addr(cfg, domain); linphone_proxy_config_set_route(cfg, route); linphone_proxy_config_enable_publish(cfg, FALSE); linphone_proxy_config_enable_register(cfg, TRUE); if (strcmp(creator->domain, "sip.linphone.org") == 0) { linphone_proxy_config_enable_avpf(cfg, TRUE); // If account created on sip.linphone.org, we configure linphone to use TLS by default if (linphone_core_sip_transport_supported(creator->core, LinphoneTransportTls)) { LinphoneAddress *addr = linphone_address_new(linphone_proxy_config_get_server_addr(cfg)); char *tmp; linphone_address_set_transport(addr, LinphoneTransportTls); tmp = linphone_address_as_string(addr); linphone_proxy_config_set_server_addr(cfg, tmp); linphone_proxy_config_set_route(cfg, tmp); ms_free(tmp); linphone_address_destroy(addr); } linphone_core_set_stun_server(creator->core, "stun.linphone.org"); linphone_core_set_firewall_policy(creator->core, LinphonePolicyUseIce); } info = linphone_auth_info_new(linphone_address_get_username(identity), // username NULL, //user id creator->password, // passwd creator->password ? NULL : creator->ha1, // ha1 !creator->password && creator->ha1 ? linphone_address_get_domain(identity) : NULL, // realm - assumed to be domain linphone_address_get_domain(identity) // domain ); linphone_core_add_auth_info(creator->core, info); linphone_address_destroy(identity); if (linphone_core_add_proxy_config(creator->core, cfg) != -1) { linphone_core_set_default_proxy(creator->core, cfg); return cfg; } linphone_core_remove_auth_info(creator->core, info); linphone_proxy_config_unref(cfg); return NULL; }
void AccountSettingsModel::setOutboundProxy(const bool& yes) { if (!_proxyConfig) { return; } linphone_proxy_config_edit(_proxyConfig); if (yes) { linphone_proxy_config_set_route(_proxyConfig, linphone_proxy_config_get_server_addr(_proxyConfig)); } else { linphone_proxy_config_set_route(_proxyConfig, NULL); } linphone_proxy_config_done(_proxyConfig); }
int AccountSettingsModel::transportIndex() const { if (!_proxyConfig) { return -1; } const char *proxy = linphone_proxy_config_get_server_addr(_proxyConfig); LinphoneAddress *addr = linphone_core_create_address(LinphoneManager::getInstance()->getLc(), proxy); LinphoneTransportType transport = linphone_address_get_transport(addr); if (transport == LinphoneTransportUdp) { return 0; } else if (transport == LinphoneTransportTcp) { return 1; } else if (transport == LinphoneTransportTls) { return 2; } return -1; }
LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCreator *creator) { LinphoneAddress *identity; LinphoneAuthInfo *info; LinphoneProxyConfig *cfg = linphone_core_create_proxy_config(creator->core); char *identity_str = ms_strdup_printf("sip:%s@%s", creator->username, creator->domain); linphone_proxy_config_set_identity(cfg, identity_str); linphone_proxy_config_set_server_addr(cfg, creator->domain); linphone_proxy_config_set_route(cfg, creator->route); linphone_proxy_config_enable_publish(cfg, FALSE); linphone_proxy_config_enable_register(cfg, TRUE); ms_free(identity_str); if (strcmp(creator->domain, "sip.linphone.org") == 0) { linphone_proxy_config_enable_avpf(cfg, TRUE); // If account created on sip.linphone.org, we configure linphone to use TLS by default if (linphone_core_sip_transport_supported(creator->core, LinphoneTransportTls)) { LinphoneAddress *addr = linphone_address_new(linphone_proxy_config_get_server_addr(cfg)); char *tmp; linphone_address_set_transport(addr, LinphoneTransportTls); tmp = linphone_address_as_string(addr); linphone_proxy_config_set_server_addr(cfg, tmp); linphone_proxy_config_set_route(cfg, tmp); ms_free(tmp); linphone_address_destroy(addr); } linphone_core_set_stun_server(creator->core, "stun.linphone.org"); linphone_core_set_firewall_policy(creator->core, LinphonePolicyUseIce); } identity = linphone_address_new(linphone_proxy_config_get_identity(cfg)); info = linphone_auth_info_new(linphone_address_get_username(identity), NULL, creator->password, NULL, NULL, linphone_address_get_domain(identity)); linphone_core_add_auth_info(creator->core, info); linphone_address_destroy(identity); if (linphone_core_add_proxy_config(creator->core, cfg) != -1) { linphone_core_set_default_proxy(creator->core, cfg); return cfg; } linphone_core_remove_auth_info(creator->core, info); linphone_proxy_config_unref(cfg); return NULL; }
void AccountSettingsModel::setTransportIndex(const int& transport) { if (!_proxyConfig) { return; } const char *proxy = linphone_proxy_config_get_server_addr(_proxyConfig); LinphoneAddress *addr = linphone_core_create_address(LinphoneManager::getInstance()->getLc(), proxy); if (transport == 0) { linphone_address_set_transport(addr, LinphoneTransportUdp); } else if (transport == 1) { linphone_address_set_transport(addr, LinphoneTransportTcp); } else if (transport == 2) { linphone_address_set_transport(addr, LinphoneTransportTls); } linphone_proxy_config_edit(_proxyConfig); linphone_proxy_config_set_server_addr(_proxyConfig, linphone_address_as_string(addr)); if (outboundProxy()) { linphone_proxy_config_set_route(_proxyConfig, linphone_address_as_string(addr)); } linphone_address_destroy(addr); linphone_proxy_config_done(_proxyConfig); emit accountUpdated(); }
void account_create_on_server(Account *account, const LinphoneProxyConfig *refcfg){ LinphoneCoreVTable vtable={0}; LinphoneCore *lc; LinphoneAddress *tmp_identity=linphone_address_clone(account->modified_identity); LinphoneProxyConfig *cfg; LinphoneAuthInfo *ai; char *tmp; LinphoneAddress *server_addr; LCSipTransports tr; vtable.registration_state_changed=account_created_on_server_cb; vtable.auth_info_requested=account_created_auth_requested_cb; lc=configure_lc_from(&vtable,bc_tester_read_dir_prefix,NULL,account); tr.udp_port=LC_SIP_TRANSPORT_RANDOM; tr.tcp_port=LC_SIP_TRANSPORT_RANDOM; tr.tls_port=LC_SIP_TRANSPORT_RANDOM; linphone_core_set_sip_transports(lc,&tr); cfg=linphone_core_create_proxy_config(lc); linphone_address_set_secure(tmp_identity, FALSE); linphone_address_set_password(tmp_identity,account->password); linphone_address_set_header(tmp_identity,"X-Create-Account","yes"); tmp=linphone_address_as_string(tmp_identity); linphone_proxy_config_set_identity(cfg,tmp); ms_free(tmp); linphone_address_unref(tmp_identity); server_addr=linphone_address_new(linphone_proxy_config_get_server_addr(refcfg)); linphone_address_set_secure(server_addr, FALSE); linphone_address_set_transport(server_addr,LinphoneTransportTcp); /*use tcp for account creation, we may not have certificates configured at this stage*/ linphone_address_set_port(server_addr,0); tmp=linphone_address_as_string(server_addr); linphone_proxy_config_set_server_addr(cfg,tmp); ms_free(tmp); linphone_address_unref(server_addr); linphone_proxy_config_set_expires(cfg,3600); linphone_core_add_proxy_config(lc,cfg); if (wait_for_until(lc,NULL,&account->auth_requested,1,10000)==FALSE){ ms_fatal("Account for %s could not be created on server.", linphone_proxy_config_get_identity(refcfg)); } linphone_proxy_config_edit(cfg); tmp_identity=linphone_address_clone(account->modified_identity); linphone_address_set_secure(tmp_identity, FALSE); tmp=linphone_address_as_string(tmp_identity); linphone_proxy_config_set_identity(cfg,tmp); /*remove the X-Create-Account header*/ linphone_address_unref(tmp_identity); ms_free(tmp); linphone_proxy_config_done(cfg); ai=linphone_auth_info_new(linphone_address_get_username(account->modified_identity), NULL, account->password,NULL,NULL,linphone_address_get_domain(account->modified_identity)); linphone_core_add_auth_info(lc,ai); linphone_auth_info_destroy(ai); if (wait_for_until(lc,NULL,&account->created,1,3000)==FALSE){ ms_fatal("Account for %s is not working on server.", linphone_proxy_config_get_identity(refcfg)); } linphone_core_remove_proxy_config(lc,cfg); linphone_proxy_config_unref(cfg); if (wait_for_until(lc,NULL,&account->done,1,3000)==FALSE){ ms_error("Account creation could not clean the registration context."); } linphone_core_destroy(lc); }
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__); } }
QString AccountSettingsModel::proxy() const { if (!_proxyConfig) { return NULL; } return linphone_proxy_config_get_server_addr(_proxyConfig); }
static void call_with_transport_base(LinphoneTunnelMode tunnel_mode, bool_t with_sip, LinphoneMediaEncryption encryption) { if (linphone_core_tunnel_available()){ LinphoneCoreManager *pauline = linphone_core_manager_new( "pauline_rc"); LinphoneCoreManager *marie = linphone_core_manager_new( "marie_rc"); LinphoneCall *pauline_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; CU_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_LinphoneRegistrationOk,1)); public_ip = get_public_contact_ip(pauline->lc); CU_ASSERT_STRING_NOT_EQUAL(public_ip, tunnel_ip); linphone_core_set_media_encryption(pauline->lc, encryption); 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) { CU_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); CU_ASSERT_STRING_EQUAL(public_ip, tunnel_ip); } else { public_ip2 = get_public_contact_ip(pauline->lc); CU_ASSERT_STRING_EQUAL(public_ip, public_ip2); } } CU_ASSERT_TRUE(call(pauline,marie)); pauline_call=linphone_core_get_current_call(pauline->lc); CU_ASSERT_PTR_NOT_NULL(pauline_call); if (pauline_call!=NULL){ CU_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(pauline_call)), encryption); } 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__); } }