From 5689b5d8603a4c153876ba97e36cb3dcffd262c0 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 7 Jun 2010 12:09:47 +0200 Subject: [PATCH 1/6] fix linphone_core_get_sip_transports naming --- coreapi/linphonecore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 778494aa3..11674665d 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1553,7 +1553,7 @@ int linphone_core_set_sip_transports(LinphoneCore *lc, const LCSipTransports * t * is not used. * @ingroup network_parameters **/ -int linphone_core_get_sip_transport(LinphoneCore *lc, LCSipTransports *tr){ +int linphone_core_get_sip_transports(LinphoneCore *lc, LCSipTransports *tr){ memcpy(tr,&lc->sip_conf.transports,sizeof(*tr)); return 0; } From d3d68693f67af344d014372bb791c2bb30af7087 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 10 Jun 2010 09:35:32 +0200 Subject: [PATCH 2/6] re-enable LinphoneFactory log handler --- java/common/org/linphone/core/LinphoneCoreFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/common/org/linphone/core/LinphoneCoreFactory.java b/java/common/org/linphone/core/LinphoneCoreFactory.java index cd34cfe36..b3e2952fb 100644 --- a/java/common/org/linphone/core/LinphoneCoreFactory.java +++ b/java/common/org/linphone/core/LinphoneCoreFactory.java @@ -61,5 +61,5 @@ abstract public class LinphoneCoreFactory { */ abstract public void setDebugMode(boolean enable); - //abstract public void setLogHandler(LinphoneLogHandler handler); + abstract public void setLogHandler(LinphoneLogHandler handler); } From 481032c0fb78522592e822f73aee09aa33ac5c2d Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 14 Jun 2010 16:12:38 +0200 Subject: [PATCH 3/6] fix transport parameter in contact header (for tcp) --- coreapi/proxy.c | 8 +++++++- coreapi/sal.h | 2 +- coreapi/sal_eXosip2.c | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 80eb5d522..babd13e34 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -244,7 +244,13 @@ static char *guess_contact_for_register(LinphoneProxyConfig *obj){ contact=linphone_address_new(obj->reg_identity); linphone_address_set_domain (contact,localip); linphone_address_set_port_int(contact,linphone_core_get_sip_port(obj->lc)); - ret=linphone_address_as_string_uri_only (contact); + linphone_address_set_display_name(contact,NULL); + LCSipTransports tr; + linphone_core_get_sip_transports(obj->lc,&tr); + if (tr.udp_port <= 0 && tr.tcp_port>0) { + sal_address_add_param(contact,"transport","tcp"); + } + ret=linphone_address_as_string(contact); linphone_address_destroy(contact); } linphone_address_destroy (proxy); diff --git a/coreapi/sal.h b/coreapi/sal.h index 9790b8c71..e6c1292a2 100644 --- a/coreapi/sal.h +++ b/coreapi/sal.h @@ -57,7 +57,7 @@ void sal_address_clean(SalAddress *addr); char *sal_address_as_string(const SalAddress *u); char *sal_address_as_string_uri_only(const SalAddress *u); void sal_address_destroy(SalAddress *u); - +void sal_address_add_param(SalAddress *u,const char* name,const char* value); diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index fa6fb5f11..df770ce12 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -1749,6 +1749,9 @@ char *sal_address_as_string_uri_only(const SalAddress *u){ osip_free(tmp); return ret; } +void sal_address_add_param(SalAddress *u,const char* name,const char* value) { + osip_uri_uparam_add (((osip_from_t*)u)->url,ms_strdup(name),ms_strdup(value)); +} void sal_address_destroy(SalAddress *u){ osip_from_free((osip_from_t*)u); From 8e6c12d12ac86b9802dff98cc25ab63ebdd4f5b7 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 15 Jun 2010 13:59:00 +0200 Subject: [PATCH 4/6] add random sip port selection add linphone_core_get_port --- coreapi/address.c | 6 ++++++ coreapi/linphonecore.c | 13 ++++++++++--- coreapi/linphonecore.h | 9 +++++++++ coreapi/sal.h | 3 +++ coreapi/sal_eXosip2.c | 12 ++++++++++++ 5 files changed, 40 insertions(+), 3 deletions(-) diff --git a/coreapi/address.c b/coreapi/address.c index 1d893aede..4d4b1d2d6 100644 --- a/coreapi/address.c +++ b/coreapi/address.c @@ -136,5 +136,11 @@ void linphone_address_destroy(LinphoneAddress *u){ sal_address_destroy(u); } +int linphone_address_get_port_int(const LinphoneAddress *u) { + return sal_address_get_port_int(u); +} +const char* linphone_address_get_port(const LinphoneAddress *u) { + return sal_address_get_port(u); +} /** @} */ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 11674665d..b369bb82c 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -646,9 +646,16 @@ static void sip_config_read(LinphoneCore *lc) } linphone_core_enable_ipv6(lc,ipv6); memset(&tr,0,sizeof(tr)); - tr.udp_port=lp_config_get_int(lc->config,"sip","sip_port",5060); - tr.tcp_port=lp_config_get_int(lc->config,"sip","sip_tcp_port",0); - + if (lp_config_get_int(lc->config,"sip","sip_random_port",0)) { + tr.udp_port=(0xDFF&+random())+1024; + } else { + tr.udp_port=lp_config_get_int(lc->config,"sip","sip_port",5060); + } + if (lp_config_get_int(lc->config,"sip","sip_tcp_random_port",0)) { + tr.tcp_port=(0xDFF&+random())+1024; + } else { + tr.tcp_port=lp_config_get_int(lc->config,"sip","sip_tcp_port",0); + } /*start listening on ports*/ linphone_core_set_sip_transports(lc,&tr); diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 34a3483ea..b780956ff 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -75,6 +75,15 @@ const char *linphone_address_get_scheme(const LinphoneAddress *u); const char *linphone_address_get_display_name(const LinphoneAddress* u); const char *linphone_address_get_username(const LinphoneAddress *u); const char *linphone_address_get_domain(const LinphoneAddress *u); +/** + * Get port number as an integer value. + * + */ +int linphone_address_get_port_int(const LinphoneAddress *u); +/** + * Get port number, null if not present. + */ +const char* linphone_address_get_port(const LinphoneAddress *u); void linphone_address_set_display_name(LinphoneAddress *u, const char *display_name); void linphone_address_set_username(LinphoneAddress *uri, const char *username); void linphone_address_set_domain(LinphoneAddress *uri, const char *host); diff --git a/coreapi/sal.h b/coreapi/sal.h index 9790b8c71..58d250e90 100644 --- a/coreapi/sal.h +++ b/coreapi/sal.h @@ -48,6 +48,9 @@ const char *sal_address_get_display_name(const SalAddress* addr); char *sal_address_get_display_name_unquoted(const SalAddress *addr); const char *sal_address_get_username(const SalAddress *addr); const char *sal_address_get_domain(const SalAddress *addr); +const char * sal_address_get_port(const SalAddress *addr); +int sal_address_get_port_int(const SalAddress *uri); + void sal_address_set_display_name(SalAddress *addr, const char *display_name); void sal_address_set_username(SalAddress *addr, const char *username); void sal_address_set_domain(SalAddress *addr, const char *host); diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index fa6fb5f11..8a427a2df 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -1758,4 +1758,16 @@ void sal_set_keepalive_period(Sal *ctx,unsigned int value) { ctx->keepalive_period=value; eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE, &value); } +const char * sal_address_get_port(const SalAddress *addr) { + const osip_from_t *u=(const osip_from_t*)addr; + return null_if_empty(u->url->port); +} +int sal_address_get_port_int(const SalAddress *uri) { + const char* port = sal_address_get_port(uri); + if (port != NULL) { + return atoi(port); + } else { + return 5060; + } +} From d21df41a760b67f13fdba03b612e94e6720abf61 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 16 Jun 2010 16:05:05 +0200 Subject: [PATCH 5/6] destroy cleared proxy config after 5 seconds --- coreapi/linphonecore.c | 10 ++++++++++ coreapi/proxy.c | 3 +++ 2 files changed, 13 insertions(+) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index b369bb82c..75bfee8ab 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1646,6 +1646,16 @@ static void monitor_network_state(LinphoneCore *lc, time_t curtime){ static void proxy_update(LinphoneCore *lc){ ms_list_for_each(lc->sip_conf.proxies,(void (*)(void*))&linphone_proxy_config_update); + MSList* list=ms_list_copy(lc->sip_conf.deleted_proxies); + for(;list!=NULL;list=list->next){ + LinphoneProxyConfig* cfg = (LinphoneProxyConfig*) list->data; + if (ms_time(NULL) - cfg->deletion_date > 5) { + lc->sip_conf.deleted_proxies =ms_list_remove(lc->sip_conf.deleted_proxies,(void *)cfg); + ms_message("clearing proxy config for [%s]",linphone_proxy_config_get_addr(cfg)); + linphone_proxy_config_destroy(cfg); + } + } + ms_list_free(list); } static void assign_buddy_info(LinphoneCore *lc, BuddyInfo *info){ diff --git a/coreapi/proxy.c b/coreapi/proxy.c index babd13e34..59d767303 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -22,6 +22,7 @@ Copyright (C) 2000 Simon MORLAT (simon.morlat@linphone.org) #include "sipsetup.h" #include "lpconfig.h" #include "private.h" +#include "mediastreamer2/mediastream.h" #include @@ -505,6 +506,7 @@ void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *cf lc->sip_conf.proxies=ms_list_remove(lc->sip_conf.proxies,(void *)cfg); /* add to the list of destroyed proxies, so that the possible unREGISTER request can succeed authentication */ lc->sip_conf.deleted_proxies=ms_list_append(lc->sip_conf.deleted_proxies,(void *)cfg); + cfg->deletion_date=ms_time(NULL); /* this will unREGISTER */ linphone_proxy_config_edit(cfg); if (lc->default_proxy==cfg){ @@ -793,3 +795,4 @@ void * linphone_proxy_config_get_user_data(LinphoneProxyConfig *cr) { + From 8821090e4551afe21adaa3d113e416fc1fe42f17 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 17 Jun 2010 09:51:39 +0200 Subject: [PATCH 6/6] add delation_date attribute to proxy cfg --- coreapi/private.h | 1 + 1 file changed, 1 insertion(+) diff --git a/coreapi/private.h b/coreapi/private.h index cd3abd3c9..43f4e0f08 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -207,6 +207,7 @@ struct _LinphoneProxyConfig bool_t publish; bool_t dial_escape_plus; void* user_data; + time_t deletion_date; }; struct _LinphoneAuthInfo