mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-21 02:34:16 +00:00
Merge branch 'master' of ssh://git.freeswitch.org:222/freeswitch
This commit is contained in:
commit
a0a9efcf02
102 files changed
+1581
-3304
No files matched your search
@@ -132,7 +132,7 @@
|
||||
//#define SAMPLES_PER_FRAME SAMPLERATE_GSMOPEN/50
|
||||
|
||||
#ifndef GSMOPEN_SVN_VERSION
|
||||
#define GSMOPEN_SVN_VERSION SWITCH_VERSION_REVISION
|
||||
#define GSMOPEN_SVN_VERSION SWITCH_VERSION_FULL
|
||||
#endif /* GSMOPEN_SVN_VERSION */
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005/2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -23,17 +23,15 @@
|
||||
*
|
||||
* This module (mod_gsmopen) has been contributed by:
|
||||
*
|
||||
* Giovanni Maruzzelli (gmaruzz@gmail.com)
|
||||
* Giovanni Maruzzelli <gmaruzz@gmail.com>
|
||||
*
|
||||
* Maintainer: Giovanni Maruzzelli <gmaruzz@gmail.com>
|
||||
*
|
||||
* Further Contributors:
|
||||
*
|
||||
*
|
||||
*
|
||||
* mod_gsmopen.c -- GSM compatible Endpoint Module
|
||||
* mod_gsmopen.cpp -- GSM Modem compatible Endpoint Module
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#define __STDC_LIMIT_MACROS
|
||||
|
||||
#ifdef WIN32
|
||||
@@ -115,7 +113,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef GSMOPEN_SVN_VERSION
|
||||
#define GSMOPEN_SVN_VERSION SWITCH_VERSION_REVISION
|
||||
#define GSMOPEN_SVN_VERSION SWITCH_VERSION_FULL
|
||||
#endif /* GSMOPEN_SVN_VERSION */
|
||||
|
||||
#include "ctb-0.16/ctb.h"
|
||||
|
||||
@@ -1,3 +1,39 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* This module (mod_gsmopen) has been contributed by:
|
||||
*
|
||||
* Giovanni Maruzzelli <gmaruzz@gmail.com>
|
||||
*
|
||||
* Maintainer: Giovanni Maruzzelli <gmaruzz@gmail.com>
|
||||
*
|
||||
* gsmopen_protocol.cpp -- Low Level Interface for mod_gamopen
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "gsmopen.h"
|
||||
#ifdef WIN32
|
||||
#include "win_iconv.c"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005/2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -23,14 +23,11 @@
|
||||
*
|
||||
* This module (mod_gsmopen) has been contributed by:
|
||||
*
|
||||
* Giovanni Maruzzelli (gmaruzz@gmail.com)
|
||||
* Giovanni Maruzzelli <gmaruzz@gmail.com>
|
||||
*
|
||||
* Maintainer: Giovanni Maruzzelli <gmaruzz@gmail.com>
|
||||
*
|
||||
* Further Contributors:
|
||||
*
|
||||
*
|
||||
*
|
||||
* mod_gsmopen.c -- GSM compatible Endpoint Module
|
||||
* mod_gsmopen.cpp -- GSM Modem compatible Endpoint Module
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -1007,6 +1007,7 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r
|
||||
const char *value = switch_xml_attr_soft(xbutton, "value");
|
||||
if(type == SKINNY_BUTTON_LINE) {
|
||||
const char *caller_name = switch_xml_attr_soft(xbutton, "caller-name");
|
||||
const char *reg_metadata = switch_xml_attr_soft(xbutton, "registration-metadata");
|
||||
uint32_t ring_on_idle = atoi(switch_xml_attr_soft(xbutton, "ring-on-idle"));
|
||||
uint32_t ring_on_active = atoi(switch_xml_attr_soft(xbutton, "ring-on-active"));
|
||||
uint32_t busy_trigger = atoi(switch_xml_attr_soft(xbutton, "busy-trigger"));
|
||||
@@ -1030,7 +1031,7 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r
|
||||
switch_safe_free(sql);
|
||||
token = switch_mprintf("skinny/%q/%q/%q:%d", profile->name, value, request->data.reg.device_name, request->data.reg.instance);
|
||||
url = switch_mprintf("skinny/%q/%q", profile->name, value);
|
||||
switch_core_add_registration(value, profile->domain, token, url, 0, network_ip, network_port_c, "tcp");
|
||||
switch_core_add_registration(value, profile->domain, token, url, 0, network_ip, network_port_c, "tcp", reg_metadata);
|
||||
switch_safe_free(token);
|
||||
switch_safe_free(url);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -21,19 +21,17 @@
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* This module (mod_skypopen) has been contributed by:
|
||||
*
|
||||
* Giovanni Maruzzelli (gmaruzz@gmail.com)
|
||||
*
|
||||
*
|
||||
* Further Contributors:
|
||||
* This module (mod_gsmopen) has been contributed by:
|
||||
*
|
||||
* Giovanni Maruzzelli <gmaruzz@gmail.com>
|
||||
*
|
||||
* Maintainer: Giovanni Maruzzelli <gmaruzz@gmail.com>
|
||||
*
|
||||
* mod_skypopen.c -- Skype compatible Endpoint Module
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "skypopen.h"
|
||||
#define SKYPE_CHAT_PROTO "skype"
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/cdev.h>
|
||||
|
||||
#include <asm/system.h> /* cli(), *_flags */
|
||||
#include <asm/uaccess.h> /* copy_*_user */
|
||||
|
||||
#include <linux/soundcard.h>
|
||||
|
||||
@@ -21,6 +21,12 @@
|
||||
|
||||
#include <linux/version.h>
|
||||
#include <linux/ioctl.h> /* needed for the _IOW etc stuff used later */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)
|
||||
#include <asm/switch_to.h> /* cli(), *_flags */
|
||||
#else
|
||||
#include <asm/system.h> /* cli(), *_flags */
|
||||
#endif //LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)
|
||||
|
||||
|
||||
#if LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 18)
|
||||
#define CENTOS_5
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005/2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -21,18 +21,17 @@
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* This module (mod_skypopen) has been contributed by:
|
||||
* This module (mod_gsmopen) has been contributed by:
|
||||
*
|
||||
* Giovanni Maruzzelli (gmaruzz@gmail.com)
|
||||
*
|
||||
*
|
||||
* Further Contributors:
|
||||
* Giovanni Maruzzelli <gmaruzz@gmail.com>
|
||||
*
|
||||
* Maintainer: Giovanni Maruzzelli <gmaruzz@gmail.com>
|
||||
*
|
||||
* mod_skypopen.c -- Skype compatible Endpoint Module
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <switch.h>
|
||||
#include <switch_version.h>
|
||||
|
||||
@@ -86,7 +85,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef SKYPOPEN_SVN_VERSION
|
||||
#define SKYPOPEN_SVN_VERSION SWITCH_VERSION_REVISION
|
||||
#define SKYPOPEN_SVN_VERSION SWITCH_VERSION_FULL
|
||||
#endif /* SKYPOPEN_SVN_VERSION */
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -1,3 +1,37 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* This module (mod_gsmopen) has been contributed by:
|
||||
*
|
||||
* Giovanni Maruzzelli <gmaruzz@gmail.com>
|
||||
*
|
||||
* Maintainer: Giovanni Maruzzelli <gmaruzz@gmail.com>
|
||||
*
|
||||
* skypopen_protocol.c -- Low Level Interface for mod_skypopen
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "skypopen.h"
|
||||
|
||||
#ifdef ASTERISK
|
||||
|
||||
@@ -242,6 +242,8 @@
|
||||
<!-- TLS version ("sslv23" (default), "tlsv1"). NOTE: Phones may not
|
||||
work with TLSv1 -->
|
||||
<param name="tls-version" value="$${sip_tls_version}"/>
|
||||
<!-- TLS maximum session lifetime -->
|
||||
<!-- <param name="tls-timeout" value="300"/> -->
|
||||
|
||||
<!-- turn on auto-flush during bridge (skip timer sleep when the socket
|
||||
already has data) (reduces delay on latent connections default
|
||||
@@ -266,7 +268,7 @@
|
||||
<!-- Let calls hit the dialplan before selecting codec for the a-leg -->
|
||||
<param name="inbound-late-negotiation" value="true"/>
|
||||
|
||||
<!-- Allow ZRTP clients to negotiate end-to-end security associations -->
|
||||
<!-- Allow ZRTP clients to negotiate end-to-end security associations (also enables late negotiation) -->
|
||||
<param name="inbound-zrtp-passthru" value="true"/>
|
||||
|
||||
<!-- this lets anything register -->
|
||||
|
||||
@@ -1587,6 +1587,8 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
|
||||
case SWITCH_MESSAGE_INDICATE_BRIDGE:
|
||||
{
|
||||
|
||||
switch_channel_set_variable(channel, SOFIA_REPLACES_HEADER, NULL);
|
||||
sofia_glue_tech_track(tech_pvt->profile, session);
|
||||
|
||||
sofia_set_flag(tech_pvt, TFLAG_SIMPLIFY);
|
||||
@@ -2337,151 +2339,165 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
break;
|
||||
|
||||
case SWITCH_MESSAGE_INDICATE_RESPOND:
|
||||
if (msg->numeric_arg || msg->string_arg) {
|
||||
int code = msg->numeric_arg;
|
||||
const char *reason = NULL;
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
if (code) {
|
||||
reason = msg->string_arg;
|
||||
} else {
|
||||
if (!zstr(msg->string_arg)) {
|
||||
if ((code = atoi(msg->string_arg))) {
|
||||
if ((reason = strchr(msg->string_arg, ' '))) {
|
||||
reason++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tech_pvt->nh && tech_pvt->nh->nh_ds && tech_pvt->nh->nh_ds->ds_sr && nua_server_request_is_pending(tech_pvt->nh->nh_ds->ds_sr)) {
|
||||
status = tech_pvt->nh->nh_ds->ds_sr->sr_status;
|
||||
}
|
||||
|
||||
if (!code) {
|
||||
code = 488;
|
||||
}
|
||||
|
||||
if (!switch_channel_test_flag(channel, CF_ANSWERED) && code >= 300) {
|
||||
if (sofia_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
goto end_lock;
|
||||
}
|
||||
}
|
||||
|
||||
if (zstr(reason) && code != 407 && code != 302) {
|
||||
reason = sip_status_phrase(code);
|
||||
if (zstr(reason)) {
|
||||
reason = "Because";
|
||||
}
|
||||
}
|
||||
|
||||
if (code == 407 && !msg->numeric_arg) {
|
||||
const char *to_uri = switch_channel_get_variable(channel, "sip_to_uri");
|
||||
const char *to_host = reason;
|
||||
|
||||
if (zstr(to_host)) {
|
||||
to_host = switch_channel_get_variable(channel, "sip_to_host");
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Challenging call %s\n", to_uri);
|
||||
sofia_reg_auth_challenge(tech_pvt->profile, tech_pvt->nh, NULL, REG_INVITE, to_host, 0);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_USER_CHALLENGE);
|
||||
} else if (code == 484 && msg->numeric_arg) {
|
||||
const char *to = switch_channel_get_variable(channel, "sip_to_uri");
|
||||
const char *max_forwards = switch_channel_get_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE);
|
||||
char *cid = generate_pai_str(tech_pvt);
|
||||
char *to_uri = NULL;
|
||||
|
||||
if (to) {
|
||||
char *p;
|
||||
to_uri = switch_core_session_sprintf(session, "sip:%s", to);
|
||||
if ((p = strstr(to_uri, ":5060"))) {
|
||||
*p = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (!switch_channel_test_flag(channel, CF_ANSWERED) && !sofia_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_RESPONSE_HEADER_PREFIX);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Overlap Dial with %d %s\n", code, reason);
|
||||
|
||||
nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), TAG_IF(to_uri, SIPTAG_CONTACT_STR(to_uri)),
|
||||
SIPTAG_SUPPORTED_STR(NULL), SIPTAG_ACCEPT_STR(NULL),
|
||||
TAG_IF(cid, SIPTAG_HEADER_STR(cid)),
|
||||
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
|
||||
TAG_IF(!zstr(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), TAG_END());
|
||||
|
||||
sofia_set_flag_locked(tech_pvt, TFLAG_BYE);
|
||||
switch_safe_free(extra_headers);
|
||||
}
|
||||
} else if (code == 302 && !zstr(msg->string_arg)) {
|
||||
char *p;
|
||||
|
||||
if ((p = strchr(msg->string_arg, ' '))) {
|
||||
*p = '\0';
|
||||
msg->string_arg = p;
|
||||
}
|
||||
|
||||
msg->message_id = SWITCH_MESSAGE_INDICATE_REDIRECT;
|
||||
switch_core_session_receive_message(session, msg);
|
||||
if (status == 0 || status > 199 || tech_pvt->nh->nh_destroyed) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Cannot call respond on handle at status %d\n",
|
||||
switch_channel_get_name(channel), status);
|
||||
goto end_lock;
|
||||
} else {
|
||||
if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
|
||||
char *sdp = (char *) msg->pointer_arg;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Responding with %d [%s]\n", code, reason);
|
||||
sofia_clear_flag(tech_pvt, TFLAG_REINVITED);
|
||||
|
||||
if (!zstr((sdp))) {
|
||||
if (!strcasecmp(sdp, "t38")) {
|
||||
switch_t38_options_t *t38_options = switch_channel_get_private(tech_pvt->channel, "t38_options");
|
||||
if (t38_options) {
|
||||
sofia_glue_set_image_sdp(tech_pvt, t38_options, 0);
|
||||
if (switch_rtp_ready(tech_pvt->rtp_session)) {
|
||||
sofia_clear_flag(tech_pvt, TFLAG_NOTIMER_DURING_BRIDGE);
|
||||
switch_rtp_udptl_mode(tech_pvt->rtp_session);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sofia_glue_tech_set_local_sdp(tech_pvt, sdp, SWITCH_TRUE);
|
||||
}
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
|
||||
sofia_glue_tech_patch_sdp(tech_pvt);
|
||||
sofia_glue_tech_proxy_remote_addr(tech_pvt, NULL);
|
||||
}
|
||||
if (sofia_use_soa(tech_pvt)) {
|
||||
nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
|
||||
SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
|
||||
SOATAG_REUSE_REJECTED(1),
|
||||
SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1),
|
||||
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
|
||||
} else {
|
||||
nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
|
||||
NUTAG_MEDIA_ENABLE(0),
|
||||
SIPTAG_CONTENT_TYPE_STR("application/sdp"),
|
||||
SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),
|
||||
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
|
||||
}
|
||||
if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) {
|
||||
/* Unlock the session signal to allow the ack to make it in */
|
||||
// Maybe we should timeout?
|
||||
switch_mutex_unlock(tech_pvt->sofia_mutex);
|
||||
|
||||
while (switch_channel_ready(channel) && !sofia_test_flag(tech_pvt, TFLAG_3PCC_HAS_ACK)) {
|
||||
switch_cond_next();
|
||||
}
|
||||
|
||||
/* Regain lock on sofia */
|
||||
switch_mutex_lock(tech_pvt->sofia_mutex);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Done waiting for ACK\n");
|
||||
sofia_clear_flag(tech_pvt, TFLAG_3PCC);
|
||||
sofia_clear_flag(tech_pvt, TFLAG_3PCC_HAS_ACK);
|
||||
switch_core_session_pass_indication(session, SWITCH_MESSAGE_INDICATE_ANSWER);
|
||||
}
|
||||
} else {
|
||||
nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
|
||||
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
|
||||
}
|
||||
switch_safe_free(extra_headers);
|
||||
}
|
||||
}
|
||||
|
||||
if (msg->numeric_arg || msg->string_arg) {
|
||||
int code = msg->numeric_arg;
|
||||
const char *reason = NULL;
|
||||
|
||||
if (code) {
|
||||
reason = msg->string_arg;
|
||||
} else {
|
||||
if (!zstr(msg->string_arg)) {
|
||||
if ((code = atoi(msg->string_arg))) {
|
||||
if ((reason = strchr(msg->string_arg, ' '))) {
|
||||
reason++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!code) {
|
||||
code = 488;
|
||||
}
|
||||
|
||||
if (!switch_channel_test_flag(channel, CF_ANSWERED) && code >= 300) {
|
||||
if (sofia_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
goto end_lock;
|
||||
}
|
||||
}
|
||||
|
||||
if (zstr(reason) && code != 407 && code != 302) {
|
||||
reason = sip_status_phrase(code);
|
||||
if (zstr(reason)) {
|
||||
reason = "Because";
|
||||
}
|
||||
}
|
||||
|
||||
if (code == 407 && !msg->numeric_arg) {
|
||||
const char *to_uri = switch_channel_get_variable(channel, "sip_to_uri");
|
||||
const char *to_host = reason;
|
||||
|
||||
if (zstr(to_host)) {
|
||||
to_host = switch_channel_get_variable(channel, "sip_to_host");
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Challenging call %s\n", to_uri);
|
||||
sofia_reg_auth_challenge(tech_pvt->profile, tech_pvt->nh, NULL, REG_INVITE, to_host, 0);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_USER_CHALLENGE);
|
||||
} else if (code == 484 && msg->numeric_arg) {
|
||||
const char *to = switch_channel_get_variable(channel, "sip_to_uri");
|
||||
const char *max_forwards = switch_channel_get_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE);
|
||||
char *cid = generate_pai_str(tech_pvt);
|
||||
char *to_uri = NULL;
|
||||
|
||||
if (to) {
|
||||
char *p;
|
||||
to_uri = switch_core_session_sprintf(session, "sip:%s", to);
|
||||
if ((p = strstr(to_uri, ":5060"))) {
|
||||
*p = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (!switch_channel_test_flag(channel, CF_ANSWERED) && !sofia_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_RESPONSE_HEADER_PREFIX);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Overlap Dial with %d %s\n", code, reason);
|
||||
|
||||
nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), TAG_IF(to_uri, SIPTAG_CONTACT_STR(to_uri)),
|
||||
SIPTAG_SUPPORTED_STR(NULL), SIPTAG_ACCEPT_STR(NULL),
|
||||
TAG_IF(cid, SIPTAG_HEADER_STR(cid)),
|
||||
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
|
||||
TAG_IF(!zstr(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), TAG_END());
|
||||
|
||||
sofia_set_flag_locked(tech_pvt, TFLAG_BYE);
|
||||
switch_safe_free(extra_headers);
|
||||
}
|
||||
} else if (code == 302 && !zstr(msg->string_arg)) {
|
||||
char *p;
|
||||
|
||||
if ((p = strchr(msg->string_arg, ' '))) {
|
||||
*p = '\0';
|
||||
msg->string_arg = p;
|
||||
}
|
||||
|
||||
msg->message_id = SWITCH_MESSAGE_INDICATE_REDIRECT;
|
||||
switch_core_session_receive_message(session, msg);
|
||||
goto end_lock;
|
||||
} else {
|
||||
if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
|
||||
char *sdp = (char *) msg->pointer_arg;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Responding with %d [%s]\n", code, reason);
|
||||
sofia_clear_flag(tech_pvt, TFLAG_REINVITED);
|
||||
|
||||
if (!zstr((sdp))) {
|
||||
if (!strcasecmp(sdp, "t38")) {
|
||||
switch_t38_options_t *t38_options = switch_channel_get_private(tech_pvt->channel, "t38_options");
|
||||
if (t38_options) {
|
||||
sofia_glue_set_image_sdp(tech_pvt, t38_options, 0);
|
||||
if (switch_rtp_ready(tech_pvt->rtp_session)) {
|
||||
sofia_clear_flag(tech_pvt, TFLAG_NOTIMER_DURING_BRIDGE);
|
||||
switch_rtp_udptl_mode(tech_pvt->rtp_session);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sofia_glue_tech_set_local_sdp(tech_pvt, sdp, SWITCH_TRUE);
|
||||
}
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
|
||||
sofia_glue_tech_patch_sdp(tech_pvt);
|
||||
sofia_glue_tech_proxy_remote_addr(tech_pvt, NULL);
|
||||
}
|
||||
if (sofia_use_soa(tech_pvt)) {
|
||||
nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
|
||||
SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
|
||||
SOATAG_REUSE_REJECTED(1),
|
||||
SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1),
|
||||
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
|
||||
} else {
|
||||
nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
|
||||
NUTAG_MEDIA_ENABLE(0),
|
||||
SIPTAG_CONTENT_TYPE_STR("application/sdp"),
|
||||
SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),
|
||||
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
|
||||
}
|
||||
if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) {
|
||||
/* Unlock the session signal to allow the ack to make it in */
|
||||
// Maybe we should timeout?
|
||||
switch_mutex_unlock(tech_pvt->sofia_mutex);
|
||||
|
||||
while (switch_channel_ready(channel) && !sofia_test_flag(tech_pvt, TFLAG_3PCC_HAS_ACK)) {
|
||||
switch_cond_next();
|
||||
}
|
||||
|
||||
/* Regain lock on sofia */
|
||||
switch_mutex_lock(tech_pvt->sofia_mutex);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Done waiting for ACK\n");
|
||||
sofia_clear_flag(tech_pvt, TFLAG_3PCC);
|
||||
sofia_clear_flag(tech_pvt, TFLAG_3PCC_HAS_ACK);
|
||||
switch_core_session_pass_indication(session, SWITCH_MESSAGE_INDICATE_ANSWER);
|
||||
}
|
||||
} else {
|
||||
nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
|
||||
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
|
||||
}
|
||||
switch_safe_free(extra_headers);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SWITCH_MESSAGE_INDICATE_RINGING:
|
||||
@@ -4919,6 +4935,8 @@ static void general_event_handler(switch_event_t *event)
|
||||
const char *body = switch_event_get_body(event);
|
||||
const char *to_uri = switch_event_get_header(event, "to-uri");
|
||||
const char *from_uri = switch_event_get_header(event, "from-uri");
|
||||
const char *extra_headers = switch_event_get_header(event, "extra-headers");
|
||||
|
||||
sofia_profile_t *profile;
|
||||
|
||||
|
||||
@@ -4977,7 +4995,8 @@ static void general_event_handler(switch_event_t *event)
|
||||
nua_notify(nh,
|
||||
NUTAG_NEWSUB(1), SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"),
|
||||
TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)),
|
||||
SIPTAG_EVENT_STR(es), TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), TAG_END());
|
||||
SIPTAG_EVENT_STR(es), TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)),
|
||||
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
|
||||
|
||||
|
||||
switch_safe_free(route_uri);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
* Paul D. Tinsley <pdt at jackhammer.org>
|
||||
* Bret McDanel <trixter AT 0xdecafbad.com>
|
||||
* Marcel Barbulescu <marcelbarbulescu@gmail.com>
|
||||
* Raymond Chandler <intralanman@gmail.com>
|
||||
*
|
||||
*
|
||||
* mod_sofia.h -- SOFIA SIP Endpoint
|
||||
@@ -92,7 +93,7 @@ typedef struct private_object private_object_t;
|
||||
|
||||
#define MULTICAST_EVENT "multicast::event"
|
||||
#define SOFIA_REPLACES_HEADER "_sofia_replaces_"
|
||||
#define SOFIA_USER_AGENT "FreeSWITCH-mod_sofia/" SWITCH_VERSION_MAJOR "." SWITCH_VERSION_MINOR "." SWITCH_VERSION_MICRO "-" SWITCH_VERSION_REVISION
|
||||
#define SOFIA_USER_AGENT "FreeSWITCH-mod_sofia/" SWITCH_VERSION_FULL
|
||||
#define SOFIA_CHAT_PROTO "sip"
|
||||
#define SOFIA_MULTIPART_PREFIX "sip_mp_"
|
||||
#define SOFIA_MULTIPART_PREFIX_T "~sip_mp_"
|
||||
@@ -517,7 +518,8 @@ struct sofia_gateway {
|
||||
typedef enum {
|
||||
PRES_TYPE_NONE = 0,
|
||||
PRES_TYPE_FULL = 1,
|
||||
PRES_TYPE_PASSIVE = 2
|
||||
PRES_TYPE_PASSIVE = 2,
|
||||
PRES_TYPE_PNP = 3
|
||||
} sofia_presence_type_t;
|
||||
|
||||
typedef enum {
|
||||
@@ -586,12 +588,15 @@ struct sofia_profile {
|
||||
char *rtcp_audio_interval_msec;
|
||||
char *rtcp_video_interval_msec;
|
||||
char *jb_msec;
|
||||
char *pnp_prov_url;
|
||||
char *pnp_notify_profile;
|
||||
sofia_cid_type_t cid_type;
|
||||
sofia_dtmf_t dtmf_type;
|
||||
int auto_restart;
|
||||
switch_port_t sip_port;
|
||||
switch_port_t tls_sip_port;
|
||||
int tls_version;
|
||||
unsigned int tls_timeout;
|
||||
char *inbound_codec_string;
|
||||
char *outbound_codec_string;
|
||||
int running;
|
||||
@@ -1111,7 +1116,7 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile);
|
||||
void sofia_glue_del_gateway(sofia_gateway_t *gp);
|
||||
void sofia_glue_gateway_list(sofia_profile_t *profile, switch_stream_handle_t *stream, int up);
|
||||
void sofia_glue_del_every_gateway(sofia_profile_t *profile);
|
||||
void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const char *host, const char *contact, const char *user_agent,
|
||||
void sofia_reg_send_reboot(sofia_profile_t *profile, const char *callid, const char *user, const char *host, const char *contact, const char *user_agent,
|
||||
const char *network_ip);
|
||||
void sofia_glue_restart_all_profiles(void);
|
||||
int sofia_glue_toggle_hold(private_object_t *tech_pvt, int sendonly);
|
||||
|
||||
@@ -2071,6 +2071,8 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
||||
TPTAG_TLS_VERIFY_SUBJECTS(profile->tls_verify_in_subjects)),
|
||||
TAG_IF(sofia_test_pflag(profile, PFLAG_TLS),
|
||||
TPTAG_TLS_VERSION(profile->tls_version)),
|
||||
TAG_IF(sofia_test_pflag(profile, PFLAG_TLS) && profile->tls_timeout,
|
||||
TPTAG_TLS_TIMEOUT(profile->tls_timeout)),
|
||||
TAG_IF(!strchr(profile->sipip, ':'),
|
||||
NTATAG_UDP_MTU(65535)),
|
||||
TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_SRV),
|
||||
@@ -2138,6 +2140,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
||||
TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("include-session-description")),
|
||||
TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("presence.winfo")),
|
||||
TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("message-summary")),
|
||||
TAG_IF(profile->pres_type == PRES_TYPE_PNP, NUTAG_ALLOW_EVENTS("ua-profile")),
|
||||
NUTAG_ALLOW_EVENTS("refer"), SIPTAG_SUPPORTED_STR(supported), SIPTAG_USER_AGENT_STR(profile->user_agent), TAG_END());
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set params for %s\n", profile->name);
|
||||
@@ -2251,7 +2254,11 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
||||
sofia_clear_pflag_locked(profile, PFLAG_SHUTDOWN);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Waiting for worker thread\n");
|
||||
|
||||
switch_thread_join(&st, worker_thread);
|
||||
if ( worker_thread ) {
|
||||
switch_thread_join(&st, worker_thread);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: Sofia worker thead failed to start\n");
|
||||
}
|
||||
|
||||
sanity = 4;
|
||||
while (profile->inuse) {
|
||||
@@ -3929,6 +3936,7 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
||||
profile->sip_force_expires = 0;
|
||||
profile->sip_expires_max_deviation = 0;
|
||||
profile->tls_version = 0;
|
||||
profile->tls_timeout = 300;
|
||||
profile->mflags = MFLAG_REFER | MFLAG_REGISTER;
|
||||
profile->server_rport_level = 1;
|
||||
profile->client_rport_level = 1;
|
||||
@@ -4417,10 +4425,16 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
||||
} else if (!strcasecmp(val, "bypass-media-after-att-xfer")) {
|
||||
profile->media_options |= MEDIA_OPT_BYPASS_AFTER_ATT_XFER;
|
||||
}
|
||||
} else if (!strcasecmp(var, "pnp-provision-url")) {
|
||||
profile->pnp_prov_url = switch_core_strdup(profile->pool, val);
|
||||
} else if (!strcasecmp(var, "pnp-notify-profile")) {
|
||||
profile->pnp_notify_profile = switch_core_strdup(profile->pool, val);
|
||||
} else if (!strcasecmp(var, "manage-presence")) {
|
||||
if (!strcasecmp(val, "passive")) {
|
||||
profile->pres_type = PRES_TYPE_PASSIVE;
|
||||
|
||||
} else if (!strcasecmp(val, "pnp")) {
|
||||
profile->pres_type = PRES_TYPE_PNP;
|
||||
} else if (switch_true(val)) {
|
||||
profile->pres_type = PRES_TYPE_FULL;
|
||||
}
|
||||
@@ -4743,6 +4757,9 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
||||
} else {
|
||||
profile->tls_version = 0;
|
||||
}
|
||||
} else if (!strcasecmp(var, "tls-timeout")) {
|
||||
int v = atoi(val);
|
||||
profile->tls_timeout = v > 0 ? (unsigned int)v : 300;
|
||||
} else if (!strcasecmp(var, "timer-T1")) {
|
||||
int v = atoi(val);
|
||||
if (v > 0) {
|
||||
@@ -4813,7 +4830,8 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
||||
}
|
||||
}
|
||||
|
||||
if (sofia_test_flag(profile, TFLAG_ZRTP_PASSTHRU)) {
|
||||
if (sofia_test_flag(profile, TFLAG_ZRTP_PASSTHRU) && !sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "ZRTP passthrough implictly enables inbound-late-negotiation\n");
|
||||
sofia_set_flag(profile, TFLAG_LATE_NEGOTIATION);
|
||||
}
|
||||
|
||||
@@ -4874,6 +4892,23 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
||||
profile->sipdomain = switch_core_strdup(profile->pool, profile->sipip);
|
||||
}
|
||||
|
||||
if (profile->pres_type == PRES_TYPE_PNP) {
|
||||
if (!profile->pnp_prov_url) {
|
||||
profile->pnp_prov_url = switch_core_sprintf(profile->pool, "http://%s/provision/", mod_sofia_globals.guess_ip);
|
||||
}
|
||||
|
||||
if (!profile->pnp_notify_profile) {
|
||||
profile->pnp_notify_profile = switch_core_strdup(profile->pool, mod_sofia_globals.guess_ip);
|
||||
}
|
||||
|
||||
if (!profile->extsipip) {
|
||||
profile->extsipip = switch_core_strdup(profile->pool, mod_sofia_globals.guess_ip);
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "we're configured to provision to [%s] on profile [%s]\n",
|
||||
profile->pnp_prov_url, profile->pnp_notify_profile);
|
||||
}
|
||||
|
||||
config_sofia_profile_urls(profile);
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_TLS) && !profile->tls_cert_dir) {
|
||||
@@ -5815,7 +5850,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
||||
tech_pvt->remote_sdp_str = switch_core_session_strdup(session, r_sdp);
|
||||
switch_channel_set_variable(channel, SWITCH_R_SDP_VARIABLE, r_sdp);
|
||||
|
||||
if (sofia_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) && (parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
|
||||
if ((sofia_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) || switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) && (parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
|
||||
if ((sdp = sdp_session(parser))) {
|
||||
sofia_glue_set_r_sdp_codec_string(session, sofia_glue_get_codec_string(tech_pvt), sdp);
|
||||
}
|
||||
@@ -6797,6 +6832,9 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
||||
|
||||
nua_respond(nh, SIP_202_ACCEPTED, NUTAG_WITH_THIS_MSG(de->data->e_msg), SIPTAG_EXPIRES_STR("60"), TAG_END());
|
||||
|
||||
|
||||
switch_channel_set_variable(tech_pvt->channel, SOFIA_REPLACES_HEADER, NULL);
|
||||
|
||||
if (sip->sip_referred_by) {
|
||||
full_ref_by = sip_header_as_string(home, (void *) sip->sip_referred_by);
|
||||
}
|
||||
@@ -7641,6 +7679,11 @@ void sofia_handle_sip_i_reinvite(switch_core_session_t *session,
|
||||
tagi_t tags[])
|
||||
{
|
||||
char *call_info = NULL;
|
||||
switch_channel_t *channel = NULL;
|
||||
|
||||
if (session) {
|
||||
channel = switch_core_session_get_channel(session);
|
||||
}
|
||||
|
||||
if (session && profile && sip && sofia_test_pflag(profile, PFLAG_TRACK_CALLS)) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
@@ -7665,7 +7708,6 @@ void sofia_handle_sip_i_reinvite(switch_core_session_t *session,
|
||||
}
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
if (channel && sip->sip_call_info) {
|
||||
char *p;
|
||||
if ((call_info = sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_call_info))) {
|
||||
@@ -7679,6 +7721,14 @@ void sofia_handle_sip_i_reinvite(switch_core_session_t *session,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (channel) {
|
||||
if (sip->sip_payload && sip->sip_payload->pl_data) {
|
||||
switch_channel_set_variable(channel, "sip_reinvite_sdp", sip->sip_payload->pl_data);
|
||||
}
|
||||
switch_channel_execute_on(channel, "execute_on_sip_reinvite");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
|
||||
|
||||
@@ -350,7 +350,7 @@ static void generate_m(private_object_t *tech_pvt, char *buf, size_t buflen,
|
||||
tech_pvt->local_sdp_audio_zrtp_hash);
|
||||
}
|
||||
|
||||
if (sr) {
|
||||
if (!zstr(sr)) {
|
||||
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=%s\n", sr);
|
||||
}
|
||||
}
|
||||
@@ -375,7 +375,7 @@ void sofia_glue_check_dtmf_type(private_object_t *tech_pvt)
|
||||
|
||||
void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch_port_t port, const char *sr, int force)
|
||||
{
|
||||
char buf[2048];
|
||||
char buf[65536];
|
||||
int ptime = 0;
|
||||
uint32_t rate = 0;
|
||||
uint32_t v_port;
|
||||
@@ -434,7 +434,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
|
||||
verbose_sdp = 1;
|
||||
}
|
||||
|
||||
if (!force && !ip && !sr
|
||||
if (!force && !ip && zstr(sr)
|
||||
&& (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) || switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA))) {
|
||||
return;
|
||||
}
|
||||
@@ -465,7 +465,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
|
||||
sofia_glue_sdp_map(b_sdp, &map, &ptmap);
|
||||
}
|
||||
|
||||
if (!sr) {
|
||||
if (zstr(sr)) {
|
||||
if ((var_val = switch_channel_get_variable(tech_pvt->channel, "media_audio_mode"))) {
|
||||
sr = var_val;
|
||||
} else {
|
||||
@@ -485,7 +485,9 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
|
||||
|
||||
if ((tech_pvt->profile->ndlb & PFLAG_NDLB_SENDRECV_IN_SESSION) ||
|
||||
((var_val = switch_channel_get_variable(tech_pvt->channel, "ndlb_sendrecv_in_session")) && switch_true(var_val))) {
|
||||
switch_snprintf(srbuf, sizeof(srbuf), "a=%s\n", sr);
|
||||
if (!zstr(sr)) {
|
||||
switch_snprintf(srbuf, sizeof(srbuf), "a=%s\n", sr);
|
||||
}
|
||||
sr = NULL;
|
||||
}
|
||||
|
||||
@@ -554,7 +556,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
|
||||
tech_pvt->local_sdp_audio_zrtp_hash);
|
||||
}
|
||||
|
||||
if (sr) {
|
||||
if (!zstr(sr)) {
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=%s\n", sr);
|
||||
}
|
||||
|
||||
@@ -619,7 +621,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
|
||||
cur_ptime = this_ptime;
|
||||
|
||||
if ((!zstr(tech_pvt->local_crypto_key) && sofia_test_flag(tech_pvt, TFLAG_SECURE))) {
|
||||
generate_m(tech_pvt, buf, sizeof(buf), port, cur_ptime, append_audio, sr, use_cng, cng_type, map, verbose_sdp, 1);
|
||||
generate_m(tech_pvt, bp, sizeof(buf) - strlen(buf), port, cur_ptime, append_audio, sr, use_cng, cng_type, map, verbose_sdp, 1);
|
||||
bp = (buf + strlen(buf));
|
||||
|
||||
/* asterisk can't handle AVP and SAVP in sep streams, way to blow off the spec....*/
|
||||
@@ -776,19 +778,23 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
|
||||
|
||||
const char *sofia_glue_get_codec_string(private_object_t *tech_pvt)
|
||||
{
|
||||
const char *codec_string = NULL, *preferred = NULL, *fallback = NULL;
|
||||
|
||||
if (switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
|
||||
preferred = tech_pvt->profile->outbound_codec_string;
|
||||
fallback = tech_pvt->profile->inbound_codec_string;
|
||||
} else {
|
||||
preferred = tech_pvt->profile->inbound_codec_string;
|
||||
fallback = tech_pvt->profile->outbound_codec_string;
|
||||
const char *preferred = NULL, *fallback = NULL;
|
||||
|
||||
if (!(preferred = switch_channel_get_variable(tech_pvt->channel, "absolute_codec_string"))) {
|
||||
preferred = switch_channel_get_variable(tech_pvt->channel, "codec_string");
|
||||
}
|
||||
|
||||
if (!preferred) {
|
||||
if (switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
|
||||
preferred = tech_pvt->profile->outbound_codec_string;
|
||||
fallback = tech_pvt->profile->inbound_codec_string;
|
||||
} else {
|
||||
preferred = tech_pvt->profile->inbound_codec_string;
|
||||
fallback = tech_pvt->profile->outbound_codec_string;
|
||||
}
|
||||
}
|
||||
|
||||
codec_string = !zstr(preferred) ? preferred : fallback;
|
||||
|
||||
return codec_string;
|
||||
return !zstr(preferred) ? preferred : fallback;
|
||||
}
|
||||
|
||||
void sofia_glue_tech_prepare_codecs(private_object_t *tech_pvt)
|
||||
@@ -2087,7 +2093,9 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
}
|
||||
|
||||
|
||||
rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER);
|
||||
if ((rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER))) {
|
||||
switch_channel_set_variable(channel, SOFIA_REPLACES_HEADER, NULL);
|
||||
}
|
||||
|
||||
switch_assert(tech_pvt != NULL);
|
||||
|
||||
@@ -2590,6 +2598,11 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
tech_pvt->session_refresher = nua_no_refresher;
|
||||
}
|
||||
|
||||
if (tech_pvt->local_sdp_str) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG,
|
||||
"Local SDP:\n%s\n", tech_pvt->local_sdp_str);
|
||||
}
|
||||
|
||||
if (sofia_use_soa(tech_pvt)) {
|
||||
nua_invite(tech_pvt->nh,
|
||||
NUTAG_AUTOANSWER(0),
|
||||
@@ -3856,10 +3869,21 @@ static void add_audio_codec(sdp_rtpmap_t *map, int ptime, char *buf, switch_size
|
||||
|
||||
void sofia_glue_pass_zrtp_hash2(switch_core_session_t *aleg_session, switch_core_session_t *bleg_session)
|
||||
{
|
||||
switch_channel_t *aleg_channel = switch_core_session_get_channel(aleg_session);
|
||||
private_object_t *aleg_tech_pvt = switch_core_session_get_private(aleg_session);
|
||||
switch_channel_t *bleg_channel = switch_core_session_get_channel(bleg_session);
|
||||
private_object_t *bleg_tech_pvt = switch_core_session_get_private(bleg_session);
|
||||
switch_channel_t *aleg_channel;
|
||||
private_object_t *aleg_tech_pvt;
|
||||
switch_channel_t *bleg_channel;
|
||||
private_object_t *bleg_tech_pvt;
|
||||
|
||||
if (!switch_core_session_compare(aleg_session, bleg_session)) {
|
||||
/* since this digs into channel internals its only compatible with sofia sessions*/
|
||||
return;
|
||||
}
|
||||
|
||||
aleg_channel = switch_core_session_get_channel(aleg_session);
|
||||
aleg_tech_pvt = switch_core_session_get_private(aleg_session);
|
||||
bleg_channel = switch_core_session_get_channel(bleg_session);
|
||||
bleg_tech_pvt = switch_core_session_get_private(bleg_session);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_channel), SWITCH_LOG_DEBUG, "Deciding whether to pass zrtp-hash between a-leg and b-leg\n");
|
||||
if (!(switch_channel_test_flag(aleg_tech_pvt->channel, CF_ZRTP_PASSTHRU_REQ))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(aleg_channel), SWITCH_LOG_DEBUG, "CF_ZRTP_PASSTHRU_REQ not set on a-leg, so not propagating zrtp-hash\n");
|
||||
@@ -4155,6 +4179,7 @@ int sofia_glue_toggle_hold(private_object_t *tech_pvt, int sendonly)
|
||||
int changed = 0;
|
||||
|
||||
if (sofia_test_flag(tech_pvt, TFLAG_SLA_BARGE) || sofia_test_flag(tech_pvt, TFLAG_SLA_BARGING)) {
|
||||
switch_channel_mark_hold(tech_pvt->channel, sendonly);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -4697,10 +4722,6 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (switch_channel_test_app_flag_key("T38", tech_pvt->channel, CF_APP_T38)) {
|
||||
sofia_set_flag(tech_pvt, TFLAG_NOREPLY);
|
||||
}
|
||||
|
||||
if (switch_true(switch_channel_get_variable(channel, "refuse_t38"))) {
|
||||
switch_channel_clear_app_flag_key("T38", tech_pvt->channel, CF_APP_T38);
|
||||
match = 0;
|
||||
@@ -4709,6 +4730,11 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
|
||||
const char *var = switch_channel_get_variable(channel, "t38_passthru");
|
||||
int pass = sofia_test_pflag(tech_pvt->profile, PFLAG_T38_PASSTHRU);
|
||||
|
||||
|
||||
if (switch_channel_test_app_flag_key("T38", tech_pvt->channel, CF_APP_T38)) {
|
||||
sofia_set_flag(tech_pvt, TFLAG_NOREPLY);
|
||||
}
|
||||
|
||||
if (var) {
|
||||
if (!(pass = switch_true(var))) {
|
||||
if (!strcasecmp(var, "once")) {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
* Ken Rice <krice@freeswitch.org>
|
||||
* Paul D. Tinsley <pdt at jackhammer.org>
|
||||
* Bret McDanel <trixter AT 0xdecafbad.com>
|
||||
* Raymond Chandler <intralanman@gmail.com>
|
||||
*
|
||||
*
|
||||
* sofia_presence.c -- SOFIA SIP Endpoint (presence code)
|
||||
@@ -537,16 +538,16 @@ static void actual_sofia_presence_mwi_event_handler(switch_event_t *event)
|
||||
sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from,"
|
||||
"full_via,expires,user_agent,accept,profile_name,network_ip"
|
||||
",'%q',full_to,network_ip,network_port from sip_subscriptions "
|
||||
"where hostname='%q' and profile_name='%q' and event='message-summary' "
|
||||
"where hostname='%q' and event='message-summary' "
|
||||
"and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%')",
|
||||
stream.data, mod_sofia_globals.hostname, profile->name, user, host, host);
|
||||
stream.data, mod_sofia_globals.hostname, user, host, host);
|
||||
} else if (sub_call_id) {
|
||||
sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from,"
|
||||
"full_via,expires,user_agent,accept,profile_name,network_ip"
|
||||
",'%q',full_to,network_ip,network_port from sip_subscriptions where "
|
||||
"hostname='%q' and profile_name='%q' and event='message-summary' "
|
||||
"hostname='%q' and event='message-summary' "
|
||||
"and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%') and call_id='%q'",
|
||||
stream.data, mod_sofia_globals.hostname, profile->name, user, host, host, sub_call_id);
|
||||
stream.data, mod_sofia_globals.hostname, user, host, host, sub_call_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -559,12 +560,12 @@ static void actual_sofia_presence_mwi_event_handler(switch_event_t *event)
|
||||
|
||||
if (for_everyone) {
|
||||
sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,network_ip,'%q',call_id "
|
||||
"from sip_registrations where hostname='%q' and profile_name='%q' and mwi_user='%q' and mwi_host='%q'",
|
||||
stream.data, mod_sofia_globals.hostname, profile->name, user, host);
|
||||
"from sip_registrations where hostname='%q' and mwi_user='%q' and mwi_host='%q'",
|
||||
stream.data, mod_sofia_globals.hostname, user, host);
|
||||
} else if (call_id) {
|
||||
sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,network_ip,'%q',call_id "
|
||||
"from sip_registrations where hostname='%q' and profile_name='%q' and call_id='%q'",
|
||||
stream.data, mod_sofia_globals.hostname, profile->name, call_id);
|
||||
"from sip_registrations where hostname='%q' and call_id='%q'",
|
||||
stream.data, mod_sofia_globals.hostname, call_id);
|
||||
}
|
||||
|
||||
if (sql) {
|
||||
@@ -3273,7 +3274,9 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
int sent_reply = 0;
|
||||
sip_contact_t const *contact;
|
||||
const char *ipv6;
|
||||
const char *contact_user;
|
||||
const char *contact_user = NULL;
|
||||
const char *contact_host = NULL;
|
||||
const char *contact_port = NULL;
|
||||
sofia_nat_parse_t np = { { 0 } };
|
||||
int found_proto = 0;
|
||||
char to_tag[13] = "";
|
||||
@@ -3295,8 +3298,11 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
|
||||
switch_stun_random_string(to_tag, 12, NULL);
|
||||
|
||||
//contact_host = sip->sip_contact->m_url->url_host;
|
||||
contact_user = sip->sip_contact->m_url->url_user;
|
||||
if ( sip->sip_contact && sip->sip_contact->m_url ) {
|
||||
contact_host = sip->sip_contact->m_url->url_host;
|
||||
contact_port = sip->sip_contact->m_url->url_port;
|
||||
contact_user = sip->sip_contact->m_url->url_user;
|
||||
}
|
||||
|
||||
//tl_gets(tags, NUTAG_SUBSTATE_REF(sub_state), TAG_END());
|
||||
|
||||
@@ -3645,6 +3651,38 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
}
|
||||
}
|
||||
|
||||
if ( sip->sip_event && sip->sip_event->o_type && !strcasecmp(sip->sip_event->o_type, "ua-profile") && contact_host ) {
|
||||
switch_event_t *params;
|
||||
char *uri = NULL;
|
||||
char *extra_headers = NULL;
|
||||
|
||||
if ( contact_port ) {
|
||||
uri = switch_mprintf("sip:%s:%s", contact_host, contact_port);
|
||||
} else {
|
||||
uri = switch_mprintf("sip:%s", contact_host);
|
||||
}
|
||||
|
||||
if ( uri ) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "sending pnp NOTIFY to %s\n", uri);
|
||||
|
||||
/* Grandstream REALLY uses a header called Message Body */
|
||||
extra_headers = switch_mprintf("MessageBody: %s\r\n", profile->pnp_prov_url);
|
||||
|
||||
switch_event_create(¶ms, SWITCH_EVENT_NOTIFY);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "profile", profile->pnp_notify_profile);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "event-string", sip->sip_event->o_type);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "to-uri", uri);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "from-uri", uri);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "extra-headers", extra_headers);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "content-type", "application/url");
|
||||
switch_event_add_body(params, "%s", profile->pnp_prov_url);
|
||||
switch_event_fire(¶ms);
|
||||
|
||||
switch_safe_free(uri);
|
||||
switch_safe_free(extra_headers);
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
|
||||
if (strcasecmp(event, "call-info") && strcasecmp(event, "line-seize")) {
|
||||
|
||||
@@ -572,7 +572,7 @@ int sofia_reg_nat_callback(void *pArg, int argc, char **argv, char **columnNames
|
||||
}
|
||||
|
||||
|
||||
void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const char *host, const char *contact, const char *user_agent,
|
||||
void sofia_reg_send_reboot(sofia_profile_t *profile, const char *callid, const char *user, const char *host, const char *contact, const char *user_agent,
|
||||
const char *network_ip)
|
||||
{
|
||||
const char *event = "check-sync";
|
||||
@@ -587,7 +587,7 @@ void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const cha
|
||||
event = "reboot";
|
||||
}
|
||||
|
||||
sofia_glue_send_notify(profile, user, host, event, contenttype, body, contact, network_ip, NULL);
|
||||
sofia_glue_send_notify(profile, user, host, event, contenttype, body, contact, network_ip, callid);
|
||||
}
|
||||
|
||||
int sofia_sla_dialog_del_callback(void *pArg, int argc, char **argv, char **columnNames)
|
||||
@@ -608,7 +608,7 @@ int sofia_reg_del_callback(void *pArg, int argc, char **argv, char **columnNames
|
||||
sofia_profile_t *profile = (sofia_profile_t *) pArg;
|
||||
|
||||
if (argc > 12 && atoi(argv[12]) == 1) {
|
||||
sofia_reg_send_reboot(profile, argv[1], argv[2], argv[3], argv[7], argv[11]);
|
||||
sofia_reg_send_reboot(profile, argv[0], argv[1], argv[2], argv[3], argv[7], argv[11]);
|
||||
}
|
||||
|
||||
if (argc >= 3) {
|
||||
@@ -787,7 +787,7 @@ int sofia_reg_check_callback(void *pArg, int argc, char **argv, char **columnNam
|
||||
{
|
||||
sofia_profile_t *profile = (sofia_profile_t *) pArg;
|
||||
|
||||
sofia_reg_send_reboot(profile, argv[1], argv[2], argv[3], argv[7], argv[11]);
|
||||
sofia_reg_send_reboot(profile, argv[0], argv[1], argv[2], argv[3], argv[7], argv[11]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1028,6 +1028,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
|
||||
sip_contact_t const *contact = NULL;
|
||||
char *sql;
|
||||
switch_event_t *s_event;
|
||||
const char *reg_meta = NULL;
|
||||
const char *to_user = NULL;
|
||||
const char *to_host = NULL;
|
||||
char *mwi_account = NULL;
|
||||
@@ -1485,6 +1486,10 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
|
||||
to_user = var;
|
||||
}
|
||||
|
||||
if (v_event && *v_event && (var = switch_event_get_header(*v_event, "registration_metadata"))) {
|
||||
reg_meta = var;
|
||||
}
|
||||
|
||||
if (v_event && *v_event && (mwi_account = switch_event_get_header(*v_event, "mwi-account"))) {
|
||||
dup_mwi_account = strdup(mwi_account);
|
||||
switch_assert(dup_mwi_account != NULL);
|
||||
@@ -1559,7 +1564,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
|
||||
url = switch_mprintf("sofia/%q/sip:%q", profile->name, sofia_glue_strip_proto(contact));
|
||||
|
||||
switch_core_add_registration(to_user, reg_host, call_id, url, (long) switch_epoch_time_now(NULL) + (long) exptime + 60,
|
||||
network_ip, network_port_c, is_tls ? "tls" : is_tcp ? "tcp" : "udp");
|
||||
network_ip, network_port_c, is_tls ? "tls" : is_tcp ? "tcp" : "udp", reg_meta);
|
||||
|
||||
switch_safe_free(url);
|
||||
switch_safe_free(contact);
|
||||
@@ -2119,6 +2124,10 @@ void sofia_reg_handle_sip_r_challenge(int status,
|
||||
|
||||
switch_event_add_header_string(locate_params, SWITCH_STACK_BOTTOM, "action", "reverse-auth-lookup");
|
||||
|
||||
if ( sip->sip_call_id ) {
|
||||
switch_event_add_header_string(locate_params, SWITCH_STACK_BOTTOM, "sip_call_id", sip->sip_call_id->i_id);
|
||||
}
|
||||
|
||||
if (switch_xml_locate_user_merged("id", sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host, NULL,
|
||||
&x_user, locate_params) == SWITCH_STATUS_SUCCESS) {
|
||||
if ((x_params = switch_xml_child(x_user, "params"))) {
|
||||
|
||||
Reference in new issue
Block a user