linphone-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Linphone-developers] ipv6 patch for 1.0.1


From: steve ayer
Subject: [Linphone-developers] ipv6 patch for 1.0.1
Date: Thu, 14 Jul 2005 09:39:55 -0400
User-agent: Mozilla Thunderbird 1.0.5 (X11/20050711)

hi,

i'd like to submit this patch to linphone-1.0.1 that 1) fixes a couple of bugs in the ipv6 comm in udp.c, and 2) partially fixes the hard-coded remote host address problem in linphone_core_get_primary_contact() in linphonecore.c; i say "partially" because it derives a remote host address from the sip uri, which isn't really accessible by reasonable means in all calling contexts.

this gets an ipv6 session as far as the rtp exchange, which is still broken, it seems. i'll take a peek at that next.

i look forward to your comments/suggestions.

thanks,

steve
---
Steven M. Ayer                          address@hidden
Cambridge Research Laboratory           617-551-7716
HPLabs/Hewlett-Packard Company
One Cambridge Center
Cambridge, MA   02142
diff -ur linphone-1.0.1/coreapi/friend.c linphone-1.0.1.hacked/coreapi/friend.c
--- linphone-1.0.1/coreapi/friend.c     2005-03-10 12:56:33.000000000 -0500
+++ linphone-1.0.1.hacked/coreapi/friend.c      2005-07-11 12:36:33.445893688 
-0400
@@ -101,7 +101,8 @@
          fr->sid=-2;
        if (err<0)
          {
-           
err=eXosip_subscribe((gchar*)req_uri,(gchar*)linphone_core_get_primary_contact(fr->lc),route);
+             // assume here that the url field is fleshed out (evidence from 
its use is osip_from_to_str() call above
+             
err=eXosip_subscribe((gchar*)req_uri,(gchar*)linphone_core_get_primary_contact(fr->lc,
 fr->url->url->host),route);
          }
        eXosip_unlock();
        fr->last_outsubsc=time(NULL);
diff -ur linphone-1.0.1/coreapi/linphonecore.c 
linphone-1.0.1.hacked/coreapi/linphonecore.c
--- linphone-1.0.1/coreapi/linphonecore.c       2005-03-16 11:16:55.000000000 
-0500
+++ linphone-1.0.1.hacked/coreapi/linphonecore.c        2005-07-14 
08:22:11.010747040 -0400
@@ -16,7 +16,6 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
-
 #include "linphonecore.h"
 #include <mediastream.h>
 #include <eXosip.h>
@@ -821,7 +820,7 @@
        return 0;
 }
 
-const gchar *linphone_core_get_primary_contact(LinphoneCore *lc)
+const gchar *linphone_core_get_primary_contact(LinphoneCore *lc, char * 
remote_host)
 {
        gchar *identity;
        if (lc->sip_conf.guess_hostname){
@@ -833,21 +832,25 @@
                                lc->sip_conf.guessed_contact=NULL;
                        }
                        
-                       osip_from_init(&url);
-                       if (osip_from_parse(url,lc->sip_conf.contact)==0){
-                               
-                       }else g_error("Could not parse identity contact !");
+                       osip_from_init(&url);   
+
+                       if (osip_from_parse(url,lc->sip_conf.contact)){
+                           g_error("Could not parse identity contact !");
+                       }
                        if (!lc->sip_conf.ipv6_enabled){
-                               eXosip_get_localip_for("15.128.128.93", &tmp);
+                           eXosip_get_localip_for(remote_host, &tmp);
                        }else{
-                               
eXosip_get_localip_for("fe80::208:2ff:fee8:564f", &tmp);
+                           eXosip_get_localip_for(remote_host, &tmp);
                        }
+
                        if (strcmp(tmp,"127.0.0.1")==0 || strcmp(tmp,"::1")==0 
){
                                g_warning("Local loopback network only !");
                                lc->sip_conf.loopback_only=TRUE;
                        }else lc->sip_conf.loopback_only=FALSE;
+
                        osip_free(url->url->host);
                        url->url->host=tmp;
+
                        osip_from_to_str(url,&guessed);
                        lc->sip_conf.guessed_contact=guessed;
                        osip_from_free(url);
@@ -871,7 +874,8 @@
        int err;
        osip_from_t *contact;
        osip_from_init(&contact);
-       err=osip_from_parse(contact,linphone_core_get_primary_contact(lc));
+       
+       err=osip_from_parse(contact,linphone_core_get_primary_contact(lc, 
NULL));
        if (err<0) {
                osip_from_free(contact);
                return NULL;
@@ -1064,6 +1068,7 @@
        osip_message_t *invite=NULL;
        sdp_context_t *ctx=NULL;
        enum_lookup_res_t *enumres=NULL;
+
        
        if (is_enum(url,&enum_domain)){
                lc->vtable.display_status(lc,_("Looking for telephone number 
destination..."));
@@ -1081,17 +1086,21 @@
                return -1;
        }
        if (proxy==NULL) proxy=lc->default_proxy;
+
        
        barmsg=g_malloc(strlen(url)+strlen(contacting)+2);
-       sprintf(barmsg,"%s %s",contacting,url);
+
        lc->vtable.display_status(lc,barmsg);
        if (proxy!=NULL) {
                route=linphone_proxy_config_get_route(proxy);
                from=linphone_proxy_config_get_identity(proxy);
        }
        /* if no proxy or no identity defined for this proxy, default to 
primary contact*/
-       if (from==NULL) from=linphone_core_get_primary_contact(lc);
-
+       {
+           osip_uri_t ou;
+           osip_uri_parse(&ou, url);
+       if (from==NULL) from=linphone_core_get_primary_contact(lc, ou.host);
+       }
        err=eXosip_build_initial_invite(&invite,(gchar*)url,(gchar*)from,
                                                                
(gchar*)route,"Phone call");
 
diff -ur linphone-1.0.1/coreapi/linphonecore.h 
linphone-1.0.1.hacked/coreapi/linphonecore.h
--- linphone-1.0.1/coreapi/linphonecore.h       2005-03-10 11:53:12.000000000 
-0500
+++ linphone-1.0.1.hacked/coreapi/linphonecore.h        2005-07-11 
12:36:32.303067424 -0400
@@ -428,7 +428,7 @@
 
 int linphone_core_set_primary_contact(LinphoneCore *lc, const gchar *contact);
 
-const gchar *linphone_core_get_primary_contact(LinphoneCore *lc);
+const gchar *linphone_core_get_primary_contact(LinphoneCore *lc, char * 
remote_host);
 
 void linphone_core_set_guess_hostname(LinphoneCore *lc, gboolean val);
 gboolean linphone_core_get_guess_hostname(LinphoneCore *lc);
diff -ur linphone-1.0.1/coreapi/proxy.c linphone-1.0.1.hacked/coreapi/proxy.c
--- linphone-1.0.1/coreapi/proxy.c      2005-03-23 03:16:16.000000000 -0500
+++ linphone-1.0.1.hacked/coreapi/proxy.c       2005-07-11 15:40:28.019383536 
-0400
@@ -168,8 +168,11 @@
 void linphone_proxy_config_done(LinphoneProxyConfig *obj)
 {
        const gchar *id_str;
-       if (obj->reg_identity!=NULL) id_str=obj->reg_identity;
-       else id_str=linphone_core_get_primary_contact(obj->lc);
+       if (obj->reg_identity!=NULL) 
+           id_str=obj->reg_identity;
+       else 
+           id_str=linphone_core_get_primary_contact(obj->lc, NULL);
+
        obj->frozen=FALSE;
        if (obj->reg_sendregister){
                gchar *ct=NULL;
@@ -229,7 +232,7 @@
   if (proxy!=NULL) {
     from=linphone_proxy_config_get_identity(proxy);
   }
-  if (from==NULL) from=linphone_core_get_primary_contact(proxy->lc);
+  if (from==NULL) from=linphone_core_get_primary_contact(proxy->lc, NULL);
 
   if (presence_mode==LINPHONE_STATUS_ONLINE)
     {
diff -ur linphone-1.0.1/exosip/eXosip.c linphone-1.0.1.hacked/exosip/eXosip.c
--- linphone-1.0.1/exosip/eXosip.c      2005-02-22 12:30:10.000000000 -0500
+++ linphone-1.0.1.hacked/exosip/eXosip.c       2005-07-14 08:27:34.933503296 
-0400
@@ -1108,6 +1108,7 @@
                  int pos=0;
                  struct addrinfo *addrinfo;
                  struct __eXosip_sockaddr addr;
+
                  i = eXosip_get_addrinfo(&addrinfo, invite->req_uri->host, 
5060);
                  if (i==0)
                        {
diff -ur linphone-1.0.1/exosip/eXutils.c linphone-1.0.1.hacked/exosip/eXutils.c
--- linphone-1.0.1/exosip/eXutils.c     2005-03-11 08:07:22.000000000 -0500
+++ linphone-1.0.1.hacked/exosip/eXutils.c      2005-07-14 08:28:55.738219112 
-0400
@@ -345,6 +345,7 @@
   return 0;
 }
 
+    
 void eXosip_get_localip_for(char *address_to_reach,char **loc){
        int err,tmp;
        struct addrinfo hints;
@@ -420,7 +421,6 @@
 #endif
 
 #ifdef SM
-
 void eXosip_get_localip_from_via(osip_message_t *mesg,char **locip){
        osip_via_t *via=NULL;
        char *host;
@@ -538,7 +538,7 @@
       error = getaddrinfo (hostname, portbuf, &hints, addrinfo);
       OSIP_TRACE (osip_trace
                  (__FILE__, __LINE__, OSIP_INFO2, NULL,
-                  "DNS resolution with %s:%i\n", hostname, service));
+                  "DNS resolution with %s:%i, (error=%s)\n", hostname, 
service, gai_strerror(error)));
     }
   if (error || *addrinfo == NULL)
     { 
diff -ur linphone-1.0.1/exosip/jrequest.c 
linphone-1.0.1.hacked/exosip/jrequest.c
--- linphone-1.0.1/exosip/jrequest.c    2005-02-18 06:07:45.000000000 -0500
+++ linphone-1.0.1.hacked/exosip/jrequest.c     2005-07-14 08:40:32.572284232 
-0400
@@ -231,6 +231,7 @@
 
          struct addrinfo *addrinfo;
          struct __eXosip_sockaddr addr;
+
          i = eXosip_get_addrinfo(&addrinfo, request->req_uri->host, 5060);
          if (i==0)
                {
@@ -323,6 +324,7 @@
 
                  struct addrinfo *addrinfo;
                  struct __eXosip_sockaddr addr;
+
                  i = eXosip_get_addrinfo(&addrinfo, request->req_uri->host, 
5060);
                  if (i==0)
                        {
@@ -457,6 +459,7 @@
 
                  struct addrinfo *addrinfo;
                  struct __eXosip_sockaddr addr;
+
                  i = eXosip_get_addrinfo(&addrinfo, (*reg)->req_uri->host, 
5060);
                  if (i==0)
                        {
@@ -896,6 +899,7 @@
 
          struct addrinfo *addrinfo;
          struct __eXosip_sockaddr addr;
+
          i = eXosip_get_addrinfo(&addrinfo, request->req_uri->host, 5060);
          if (i==0)
                {
@@ -979,6 +983,7 @@
 
          struct addrinfo *addrinfo;
          struct __eXosip_sockaddr addr;
+
          i = eXosip_get_addrinfo(&addrinfo, request->req_uri->host, 5060);
          if (i==0)
                {
diff -ur linphone-1.0.1/exosip/jresponse.c 
linphone-1.0.1.hacked/exosip/jresponse.c
--- linphone-1.0.1/exosip/jresponse.c   2005-02-04 11:09:37.000000000 -0500
+++ linphone-1.0.1.hacked/exosip/jresponse.c    2005-07-14 08:40:57.984421000 
-0400
@@ -198,6 +198,7 @@
 
          struct addrinfo *addrinfo;
          struct __eXosip_sockaddr addr;
+
          i = eXosip_get_addrinfo(&addrinfo, con->url->host, 5060);
          if (i==0)
                {
diff -ur linphone-1.0.1/exosip/udp.c linphone-1.0.1.hacked/exosip/udp.c
--- linphone-1.0.1/exosip/udp.c 2005-02-18 06:07:45.000000000 -0500
+++ linphone-1.0.1.hacked/exosip/udp.c  2005-07-14 08:50:16.248551952 -0400
@@ -2173,15 +2173,17 @@
        }
       else if (FD_ISSET (eXosip.j_socket, &osip_fdset))
        {
-         struct sockaddr_in sa;
+           struct sockaddr_storage sa;
 #ifdef __linux
          socklen_t slen;
 #else
          int slen;
 #endif
-         slen = sizeof(struct sockaddr_in);
+         slen = sizeof(struct sockaddr_storage);
+
          i = recvfrom (eXosip.j_socket, buf, SIP_MESSAGE_MAX_LENGTH, 0,
                        (struct sockaddr *) &sa, &slen);
+             
          if( i > 5 ) /* we expect at least one byte, otherwise there's no 
doubt that it is not a sip message !*/
            {
              /* Message might not end with a "\0" but we know the number of */
@@ -2203,7 +2205,23 @@
              transaction = NULL;
              if (sipevent!=NULL&&sipevent->sip!=NULL)
                {
-                 osip_message_fix_last_via_header(sipevent->sip, inet_ntoa 
(sa.sin_addr), ntohs (sa.sin_port));
+                   char out_addr[INET6_ADDRSTRLEN];
+
+                   if(eXosip.ip_family == AF_INET)                 
+                       osip_message_fix_last_via_header(sipevent->sip, 
+                                                        inet_ntop (AF_INET,
+                                                                   (void 
*)&(((struct sockaddr_in *)&sa)->sin_addr).s_addr,
+                                                                   out_addr,
+                                                                   
INET_ADDRSTRLEN),
+                                                        ntohs(((struct 
sockaddr_in *)&sa)->sin_port));
+                   else
+                       osip_message_fix_last_via_header(sipevent->sip, 
+                                                        inet_ntop (AF_INET6, 
+                                                                   (void 
*)&(((struct sockaddr_in6 *)&sa)->sin6_addr).s6_addr, 
+                                                                   out_addr,
+                                                                   
INET6_ADDRSTRLEN),
+                                                        ntohs (((struct 
sockaddr_in6 *)&sa)->sin6_port));                  
+                   
                  i = osip_find_transaction_and_add_event(eXosip.j_osip, 
sipevent);
                  if (i!=0)
                    {
diff -ur linphone-1.0.1/gnome/callbacks.c 
linphone-1.0.1.hacked/gnome/callbacks.c
--- linphone-1.0.1/gnome/callbacks.c    2005-03-11 07:19:26.000000000 -0500
+++ linphone-1.0.1.hacked/gnome/callbacks.c     2005-07-14 08:51:13.661823808 
-0400
@@ -45,7 +45,7 @@
                /* we have no dialog in progress */
                /* get the url to call */
                
sipurl=gtk_editable_get_chars(GTK_EDITABLE(ui->main_window.addressentry),0,-1);
-               linphone_core_invite(lc,sipurl,NULL);
+               linphone_core_invite(lc,sipurl,NULL);
                g_free(sipurl);
        }else linphone_core_accept_dialog(lc,NULL);
 }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]