[Freeswitch-svn] [commit] r13579 - freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia
FreeSWITCH SVN
mikej at freeswitch.org
Wed Jun 3 11:16:52 PDT 2009
Author: mikej
Date: Wed Jun 3 13:16:51 2009
New Revision: 13579
Log:
factor out helper function for getting ip address information from a msg_t sofia_glue_get_addr()
Modified:
freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_sla.c
Modified: freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original)
+++ freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Wed Jun 3 13:16:51 2009
@@ -885,3 +885,4 @@
sofia_cid_type_t sofia_cid_name2type(const char *name);
void sofia_glue_tech_set_local_sdp(private_object_t *tech_pvt, const char *sdp_str, switch_bool_t dup);
void sofia_glue_set_rtp_stats(private_object_t *tech_pvt);
+void sofia_glue_get_addr(msg_t *msg, char *buf, size_t buflen, int *port);
Modified: freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia.c Wed Jun 3 13:16:51 2009
@@ -406,8 +406,7 @@
if (authorization) {
char network_ip[80];
- su_addrinfo_t *addrinfo = msg_addrinfo(nua_current_request(nua));
- get_addr(network_ip, sizeof(network_ip), addrinfo->ai_addr, addrinfo->ai_addrlen);
+ sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), NULL);
auth_res = sofia_reg_parse_auth(profile, authorization, sip,
(char *) sip->sip_request->rq_method_name, tech_pvt->key, strlen(tech_pvt->key), network_ip, NULL, 0,
REG_INVITE, NULL, NULL);
@@ -2833,13 +2832,11 @@
const char *uuid;
switch_core_session_t *other_session;
private_object_t *tech_pvt = switch_core_session_get_private(session);
- su_addrinfo_t *my_addrinfo = msg_addrinfo(nua_current_request(nua));
char network_ip[80];
int network_port = 0;
switch_caller_profile_t *caller_profile = NULL;
- get_addr(network_ip, sizeof(network_ip), my_addrinfo->ai_addr, my_addrinfo->ai_addrlen);
- network_port = ntohs(((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_port);
+ sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
switch_channel_set_variable(channel, "sip_reply_host", network_ip);
switch_channel_set_variable_printf(channel, "sip_reply_port", "%d", network_port);
@@ -4341,7 +4338,6 @@
uint32_t sess_count = switch_core_session_count();
uint32_t sess_max = switch_core_session_limit(0);
int is_auth = 0, calling_myself = 0;
- su_addrinfo_t *my_addrinfo = msg_addrinfo(nua_current_request(nua));
int network_port = 0;
char *is_nat = NULL;
char acl_token[512] = "";
@@ -4365,9 +4361,7 @@
goto fail;
}
- get_addr(network_ip, sizeof(network_ip), my_addrinfo->ai_addr, my_addrinfo->ai_addrlen);
- network_port = ntohs(((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_port);
-
+ sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
if (sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION)) {
if (sip && sip->sip_via) {
Modified: freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Wed Jun 3 13:16:51 2009
@@ -830,6 +830,18 @@
}
}
+void sofia_glue_get_addr(msg_t *msg, char *buf, size_t buflen, int *port) {
+ su_addrinfo_t *addrinfo = msg_addrinfo(msg);
+
+ if (buf) {
+ get_addr(buf, buflen, addrinfo->ai_addr, addrinfo->ai_addrlen);
+ }
+
+ if (port) {
+ *port = get_port(addrinfo->ai_addr);
+ }
+}
+
char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char *uri, const sofia_transport_t transport, switch_bool_t uri_only,
const char *params)
{
Modified: freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original)
+++ freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Wed Jun 3 13:16:51 2009
@@ -764,19 +764,17 @@
char *force_user;
char received_data[128] = "";
char *path_val = NULL;
- su_addrinfo_t *my_addrinfo = msg_addrinfo(nua_current_request(nua));
switch_event_t *auth_params = NULL;
int r = 0;
/* all callers must confirm that sip, sip->sip_request and sip->sip_contact are not NULL */
switch_assert(sip != NULL && sip->sip_contact != NULL && sip->sip_request != NULL);
- get_addr(network_ip, sizeof(network_ip), my_addrinfo->ai_addr,my_addrinfo->ai_addrlen);
- network_port = get_port(my_addrinfo->ai_addr);
+ sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
snprintf(network_port_c, sizeof(network_port_c), "%d", network_port);
- snprintf(url_ip, sizeof(url_ip), my_addrinfo->ai_addr->sa_family == AF_INET6 ? "[%s]" : "%s", network_ip);
+ snprintf(url_ip, sizeof(url_ip), (msg_addrinfo(nua_current_request(nua)))->ai_addr->sa_family == AF_INET6 ? "[%s]" : "%s", network_ip);
expires = sip->sip_expires;
authorization = sip->sip_authorization;
@@ -1281,22 +1279,17 @@
}
-
void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
tagi_t tags[])
{
char key[128] = "";
switch_event_t *v_event = NULL;
char network_ip[80];
- su_addrinfo_t *my_addrinfo = msg_addrinfo(nua_current_request(nua));
sofia_regtype_t type = REG_REGISTER;
int network_port = 0;
char *is_nat = NULL;
-
- get_addr(network_ip, sizeof(network_ip), my_addrinfo->ai_addr, my_addrinfo->ai_addrlen);
- network_port = get_port(msg_addrinfo(nua_current_request(nua))->ai_addr);
-
+ sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
if (!(sip->sip_contact && sip->sip_contact->m_url)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO CONTACT!\n");
Modified: freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_sla.c
==============================================================================
--- freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_sla.c (original)
+++ freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_sla.c Wed Jun 3 13:16:51 2009
@@ -76,12 +76,10 @@
struct sla_helper sh = { { 0 } };
char *contact_str = strip_uri(full_contact);
sofia_transport_t transport = sofia_glue_url2transport(sip->sip_contact->m_url);
- su_addrinfo_t *my_addrinfo = msg_addrinfo(nua_current_request(nua));
char network_ip[80];
int network_port = 0;
- get_addr(network_ip, sizeof(network_ip), my_addrinfo->ai_addr, my_addrinfo->ai_addrlen);
- network_port = ntohs(((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_port);
+ sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
sql = switch_mprintf("select call_id from sip_shared_appearance_dialogs where hostname='%q' and profile_name='%q' and contact_str='%q'",
mod_sofia_globals.hostname, profile->name, contact_str);
@@ -136,14 +134,11 @@
char *sql = NULL;
char *route_uri = NULL;
char *sla_contact = NULL;
- su_addrinfo_t *my_addrinfo = msg_addrinfo(nua_current_request(nua));
char network_ip[80];
int network_port = 0;
sofia_transport_t transport = sofia_glue_url2transport(sip->sip_contact->m_url);
-
- get_addr(network_ip, sizeof(network_ip), my_addrinfo->ai_addr, my_addrinfo->ai_addrlen);
- network_port = ntohs(((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_port);
+ sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
/*
* XXX MTK FIXME - we don't look at the tag to see if NUTAG_SUBSTATE(nua_substate_terminated) or
* a Subscription-State header with state "terminated" and/or expiration of 0. So we never forget
More information about the Freeswitch-svn
mailing list