From e022c5762737c846bf2a7822417321e12d964a22 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Sun, 9 Mar 2014 22:18:37 +0100 Subject: [PATCH] fix few bugs around ipv6 detection --- coreapi/linphonecore.c | 2 +- coreapi/misc.c | 10 +++++++--- gtk/propertybox.c | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 061008066..6243d82d4 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1488,7 +1488,7 @@ void linphone_core_get_local_ip(LinphoneCore *lc, int af, char *result){ has_ipv6=linphone_core_get_local_ip_for(AF_INET6,NULL,result)==0; if (strcmp(result,"::1")!=0) return; /*this machine has real ipv6 connectivity*/ - if (linphone_core_get_local_ip_for(AF_INET,NULL,result)==0 && strcmp(result,"::1")!=0) + if (linphone_core_get_local_ip_for(AF_INET,NULL,result)==0 && strcmp(result,"127.0.0.1")!=0) return; /*this machine has only ipv4 connectivity*/ if (has_ipv6){ /*this machine has only local loopback for both ipv4 and ipv6, so prefer ipv6*/ diff --git a/coreapi/misc.c b/coreapi/misc.c index 6af42bf39..9e4700510 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -1057,9 +1057,13 @@ static int get_local_ip_for_with_connect(int type, const char *dest, char *resul if (err!=0){ ms_error("getnameinfo error: %s",strerror(errno)); } + /*avoid ipv6 link-local addresses*/ + if (type==AF_INET6 && strchr(result,'%')!=NULL){ + strcpy(result,"::1"); + close_socket(sock); + return -1; + } close_socket(sock); - - return 0; } @@ -1090,7 +1094,7 @@ int linphone_core_get_local_ip_for(int type, const char *dest, char *result){ return -1; } #endif - return 0; + return 0; } SalReason linphone_reason_to_sal(LinphoneReason reason){ diff --git a/gtk/propertybox.c b/gtk/propertybox.c index 01134c073..4d4c3ffad 100644 --- a/gtk/propertybox.c +++ b/gtk/propertybox.c @@ -1464,11 +1464,11 @@ void linphone_gtk_show_parameters(void){ } if (linphone_address_get_username(contact)) gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(pb,"username")),linphone_address_get_username(contact)); + linphone_address_destroy(contact); } #ifdef BUILD_WIZARD gtk_widget_show(linphone_gtk_get_widget(pb,"wizard")); #endif - linphone_address_destroy(contact); linphone_gtk_show_sip_accounts(pb); /* CODECS CONFIG */ linphone_gtk_init_codec_list(GTK_TREE_VIEW(codec_list));