[Freeswitch-svn] [commit] r4169 - in freeswitch/trunk/src: . include mod/endpoints/mod_sofia

Freeswitch SVN mikej at freeswitch.org
Thu Feb 8 15:16:09 EST 2007


Author: mikej
Date: Thu Feb  8 15:16:08 2007
New Revision: 4169

Modified:
   freeswitch/trunk/src/include/switch_utils.h
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/switch_utils.c

Log:
make sofia set network_addr as the address the packet was actually received from, not the address from the uri.

Modified: freeswitch/trunk/src/include/switch_utils.h
==============================================================================
--- freeswitch/trunk/src/include/switch_utils.h	(original)
+++ freeswitch/trunk/src/include/switch_utils.h	Thu Feb  8 15:16:08 2007
@@ -94,6 +94,15 @@
 */
 SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int family);
 
+/*!
+  \brief find the char representation of an ip adress
+  \param buf the buffer to write the ip adress found into
+  \param len the length of the buf
+  \param the struct in_addr * to get the adress from
+  \return the ip adress string
+*/
+SWITCH_DECLARE(char *) get_addr(char *buf, switch_size_t len, struct in_addr *in);
+
 #define SWITCH_STATUS_IS_BREAK(x) (x == SWITCH_STATUS_BREAK || x == 730035 || x == 35)
 
 /*!

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Thu Feb  8 15:16:08 2007
@@ -74,6 +74,7 @@
 #include <sofia-sip/su_md5.h>
 #include <sofia-sip/su_log.h>
 #include <sofia-sip/nea.h>
+#include <sofia-sip/msg_addr.h>
 
 extern su_log_t tport_log[];
 
@@ -4173,7 +4174,7 @@
 	sip_unknown_t *un;
     private_object_t *tech_pvt = NULL;
     switch_channel_t *channel = NULL;
-    sip_from_t const *from = sip->sip_from;
+	sip_from_t const *from = sip->sip_from;
     sip_to_t const *to = sip->sip_to;
     char *displayname;
     char *username, *req_username = NULL;
@@ -4184,8 +4185,9 @@
     char *via_rport, *via_host, *via_port;
     char *from_port;
     char uri[1024];
+	char network_ip[80];
+
 
-    
     if (!(sip && sip->sip_contact && sip->sip_contact->m_url)) {
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO CONTACT!\n");
         return;
@@ -4212,6 +4214,9 @@
         tech_pvt->key = switch_core_session_strdup(session, key);
     }
 
+	get_addr(network_ip, sizeof(network_ip), &((struct sockaddr_in *)msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_addr);
+	
+
     to_user = (char *) to->a_url->url_user;
     to_host = (char *) to->a_url->url_host;
     if (!(to_port = (char *) to->a_url->url_port)) {
@@ -4365,7 +4370,7 @@
                                                               profile->dialplan,
                                                               displayname,
                                                               (char *) from->a_url->url_user,
-                                                              (char *) from->a_url->url_host,
+                                                              network_ip,
                                                               NULL,
                                                               NULL,
                                                               NULL,

Modified: freeswitch/trunk/src/switch_utils.c
==============================================================================
--- freeswitch/trunk/src/switch_utils.c	(original)
+++ freeswitch/trunk/src/switch_utils.c	Thu Feb  8 15:16:08 2007
@@ -36,7 +36,6 @@
 #ifndef WIN32
 #include <arpa/inet.h>
 #endif
-static char *get_addr(char *buf, switch_size_t len, struct in_addr *in);
 
 SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int family)
 {
@@ -348,7 +347,7 @@
 
 static char RFC2833_CHARS[] = "0123456789*#ABCDF";
 
-static char *get_addr(char *buf, switch_size_t len, struct in_addr *in)
+SWITCH_DECLARE(char *) get_addr(char *buf, switch_size_t len, struct in_addr *in)
 {
 	uint8_t x, *i;
 	char *p = buf;



More information about the Freeswitch-svn mailing list