[Freeswitch-svn] [commit] r7723 - freeswitch/trunk/src/mod/endpoints/mod_sofia
Freeswitch SVN
anthm at freeswitch.org
Fri Feb 22 10:02:17 EST 2008
Author: anthm
Date: Fri Feb 22 10:02:16 2008
New Revision: 7723
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
Log:
update
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 Fri Feb 22 10:02:16 2008
@@ -278,26 +278,25 @@
switch_mutex_lock(tech_pvt->profile->flag_mutex);
if (tech_pvt->nh && !switch_test_flag(tech_pvt, TFLAG_BYE)) {
+ char reason[128] = "";
+ if (cause > 1 && cause < 128) {
+ switch_snprintf(reason, sizeof(reason), "Q.850;cause=%d;text=\"%s\"", cause, switch_channel_cause2str(cause));
+ } else if (cause == SWITCH_CAUSE_PICKED_OFF) {
+ switch_snprintf(reason, sizeof(reason), "SIP;cause=200;text=\"Call completed elsewhere\"");
+ } else {
+ switch_snprintf(reason, sizeof(reason), "FreeSWITCH;cause=%d;text=\"%s\"", cause, switch_channel_cause2str(cause));
+ }
+
if (switch_test_flag(tech_pvt, TFLAG_ANS)) {
- char reason[128] = "";
- if (cause > 1 && cause < 128) {
- switch_snprintf(reason, sizeof(reason), "Q.850;cause=%d;text=\"%s\"", cause, switch_channel_cause2str(cause));
- } else {
- switch_snprintf(reason, sizeof(reason), "FreeSWITCH;cause=%d;text=\"%s\"", cause, switch_channel_cause2str(cause));
- }
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending BYE to %s\n", switch_channel_get_name(channel));
nua_bye(tech_pvt->nh, SIPTAG_REASON_STR(reason), TAG_END());
} else {
if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
- switch_call_cause_t causecode = switch_channel_get_cause(channel);
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending CANCEL to %s\n", switch_channel_get_name(channel));
- nua_cancel(tech_pvt->nh, TAG_IF(causecode == SWITCH_CAUSE_PICKED_OFF,
- SIPTAG_REASON_STR("SIP;cause=200;text=\"Call completed elsewhere\"")), TAG_END());
+ nua_cancel(tech_pvt->nh, SIPTAG_REASON_STR(reason), TAG_END());
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding to INVITE with: %d\n", sip_cause);
- nua_respond(tech_pvt->nh, sip_cause, sip_status_phrase(sip_cause), TAG_END());
+ nua_respond(tech_pvt->nh, sip_cause, sip_status_phrase(sip_cause), SIPTAG_REASON_STR(reason), TAG_END());
}
}
switch_set_flag(tech_pvt, TFLAG_BYE);
@@ -882,6 +881,7 @@
if (msg->string_arg) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-directing to %s\n", msg->string_arg);
nua_respond(tech_pvt->nh, SIP_302_MOVED_TEMPORARILY, SIPTAG_CONTACT_STR(msg->string_arg), TAG_END());
+ switch_set_flag_locked(tech_pvt, TFLAG_BYE);
}
break;
@@ -958,6 +958,7 @@
nua_respond(tech_pvt->nh, code, reason, TAG_IF(to_uri, SIPTAG_CONTACT_STR(to_uri)),
SIPTAG_SUPPORTED_STR(NULL), SIPTAG_ACCEPT_STR(NULL),
TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), TAG_END());
+ switch_set_flag_locked(tech_pvt, TFLAG_BYE);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding with %d %s\n", code, reason);
@@ -974,6 +975,7 @@
} else {
nua_respond(tech_pvt->nh, code, reason, SIPTAG_CONTACT_STR(tech_pvt->reply_contact), TAG_END());
}
+ switch_set_flag_locked(tech_pvt, TFLAG_BYE);
}
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Fri Feb 22 10:02:16 2008
@@ -1642,7 +1642,6 @@
}
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "NO CODECS");
- nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
}
} else {
@@ -1816,7 +1815,6 @@
}
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "NO CODECS");
- nua_respond(nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
}
}
@@ -2362,12 +2360,7 @@
return;
}
- if (!(sip->sip_contact && sip->sip_contact->m_url)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO CONTACT!\n");
- nua_respond(nh, 400, "Missing Contact Header", TAG_END());
- return;
- }
-
+
get_addr(network_ip, sizeof(network_ip), &((struct sockaddr_in *) my_addrinfo->ai_addr)->sin_addr);
if ((profile->pflags & PFLAG_AUTH_CALLS) || sip->sip_proxy_authorization || sip->sip_authorization) {
@@ -2383,6 +2376,14 @@
}
is_auth++;
}
+
+
+ if (!(sip->sip_contact && sip->sip_contact->m_url)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO CONTACT!\n");
+ nua_respond(nh, 400, "Missing Contact Header", TAG_END());
+ return;
+ }
+
if (!sofia_endpoint_interface || !(session = switch_core_session_request(sofia_endpoint_interface, NULL))) {
nua_respond(nh, SIP_503_SERVICE_UNAVAILABLE, TAG_END());
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Fri Feb 22 10:02:16 2008
@@ -650,7 +650,7 @@
{
char key[128] = "";
switch_event_t *v_event = NULL;
-
+
if (!sip || !sip->sip_request || !sip->sip_request->rq_method_name) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received an invalid packet!\n");
nua_respond(nh, SIP_500_INTERNAL_SERVER_ERROR, TAG_END());
More information about the Freeswitch-svn
mailing list