Changeset 419:1f087a2bf661 in verona


Ignore:
Timestamp:
Jan 23, 2012 3:29:39 PM (17 months ago)
Author:
Vadim Lebedev <vadim@…>
Branch:
default
rebase_source:
d04508730cd4ba67335d6e7f1eace86b6938aea9
Message:

fixes for sip over socks support

Location:
libeXosip2/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libeXosip2/src/eXtl_socks.c

    r418 r419  
    452452                                        int need_more = sk->udplen - sk->pbuflen; 
    453453 
    454                                         i = recv(sk->socket, sk->pbuf, need_more, 0); 
     454                                        i = recv(sk->socket, sk->pbuf+sk->pbuflen, need_more, 0); 
    455455                                        if (i > 0) { 
    456456                                                sk->pbuflen += i; 
     
    463463                                                                                                                        sk->remote_port); 
    464464                                                        sk->udplen = 0; 
     465                                                        sk->pbuflen = 0; 
    465466 
    466467                                                } 
     
    718719} 
    719720 
    720 static int _socks_tl_connect_socket2(char *host, int port, int mode) 
     721static int _socks_tl_connect_socket2(char *host, int port, int mode, int *tabx) 
    721722{ 
    722723        int res; 
     
    737738                return -1; 
    738739 
     740 
    739741        sock = sk->socket; 
    740742 
    741743 
    742744        if (sock > 0) { 
    743                 if (mode & SOCKST_UDPMASK) { 
    744                         sk->pbuf = (char *) osip_malloc(SIP_MESSAGE_MAX_LENGTH); 
    745                         if (!sk->pbuf) { 
    746                                 closesocket(sk->socket); 
    747                                 memset(sk, 0, sizeof(*sk)); 
    748                                 return -1; 
    749                         } 
    750  
    751                 } 
    752  
     745                if (*tabx) 
     746                        *tabx = sk - socks_socket_tab; 
    753747                return sock; 
    754748        } 
     
    757751} 
    758752 
     753static int socks_tl_fix_message(osip_message_t *sip,  int tlx) 
     754{ 
     755        char  portstr[16]; 
     756 
     757        osip_contact_t *ctct = (osip_contact_t*) osip_list_get(&sip->contacts, 0); 
     758        osip_via_t *via = (osip_via_t *) osip_list_get(&sip->vias, 0); 
     759 
     760        snprintf(portstr,16,"%d", socks_socket_tab[tlx].public_port); 
     761 
     762 
     763        if (ctct && ctct->url) { 
     764                if (ctct->url->port) 
     765                        osip_free(ctct->url->port); 
     766 
     767                ctct->url->port = osip_strdup(portstr); 
     768                sip->message_property = 2; 
     769        } 
     770 
     771        if (via) { 
     772                if (via->port) 
     773                        osip_free(via->port); 
     774                via->port = osip_strdup(portstr); 
     775                sip->message_property = 2; 
     776        } 
     777 
     778        return 0; 
     779 
     780} 
    759781 
    760782static int 
     
    774796        } 
    775797 
     798        /* Step 1: find existing socket to send message */ 
     799        if (out_socket <= 0) { 
     800                out_socket = _socks_tl_find_socket(host, port); 
     801 
     802                /* Step 2: create new socket with host:port */ 
     803                if (out_socket <= 0) { 
     804                        int tlx; 
     805 
     806                        out_socket = _socks_tl_connect_socket2(host, port, mode, &tlx); 
     807                        if (out_socket > 0) { 
     808 
     809                                socks_tl_fix_message(sip, tlx); 
     810                        } 
     811                } 
     812        } else { 
     813                OSIP_TRACE(osip_trace(__FILE__, __LINE__, OSIP_INFO1, NULL, 
     814                                                          "reusing REQUEST connection (to dest=%s:%i)\n", 
     815                                                          host, port)); 
     816        } 
     817 
     818        if (out_socket <= 0) { 
     819                osip_free(message); 
     820                return -1; 
     821        } 
     822 
    776823        /* remove preloaded route if there is no tag in the To header 
    777824         */ 
     
    795842        } 
    796843 
    797         /* Step 1: find existing socket to send message */ 
    798         if (out_socket <= 0) { 
    799                 out_socket = _socks_tl_find_socket(host, port); 
    800  
    801                 /* Step 2: create new socket with host:port */ 
    802                 if (out_socket <= 0) { 
    803                         out_socket = _socks_tl_connect_socket2(host, port, mode); 
    804                 } 
    805         } else { 
    806                 OSIP_TRACE(osip_trace(__FILE__, __LINE__, OSIP_INFO1, NULL, 
    807                                                           "reusing REQUEST connection (to dest=%s:%i)\n", 
    808                                                           host, port)); 
    809         } 
    810  
    811         if (out_socket <= 0) { 
    812                 osip_free(message); 
    813                 return -1; 
    814         } 
    815844 
    816845        i = _socks_tl_is_connected(out_socket); 
  • libeXosip2/src/udp.c

    r386 r419  
    15921592                eXtl_udp.tl_set_fdset(&osip_fdset, &max); 
    15931593                eXtl_tcp.tl_set_fdset(&osip_fdset, &max); 
     1594                if (eXosip.eXtl) 
     1595                        eXosip.eXtl->tl_set_fdset(&osip_fdset, &max); 
    15941596#ifdef HAVE_OPENSSL_SSL_H 
    15951597#if !(OPENSSL_VERSION_NUMBER < 0x00908000L) 
     
    16351637                        eXtl_udp.tl_read_message(&osip_fdset); 
    16361638                        eXtl_tcp.tl_read_message(&osip_fdset); 
     1639                        if (eXosip.eXtl) 
     1640                                eXosip.eXtl->tl_read_message(&osip_fdset); 
     1641 
    16371642#ifdef HAVE_OPENSSL_SSL_H 
    16381643#if !(OPENSSL_VERSION_NUMBER < 0x00908000L) 
Note: See TracChangeset for help on using the changeset viewer.