Merge branch 'master' of ssh://git.freeswitch.org:222/freeswitch

This commit is contained in:
Michael S Collins 2012-07-11 11:10:33 -07:00
commit eb7e640b59
16 changed files with 679 additions and 386 deletions

View File

@ -916,15 +916,18 @@ static const char *banner =
"* Paypal Donations Appreciated: paypal@freeswitch.org *\n"
"* Brought to you by ClueCon http://www.cluecon.com/ *\n"
"*******************************************************\n"
"\n"
"Type /help <enter> to see a list of commands\n\n\n";
"\n";
static const char *inf = "Type /help <enter> to see a list of commands\n\n\n";
static void print_banner(FILE *stream)
{
#include <cc.h>
#ifndef WIN32
fprintf(stream, "%s%s", output_text_color, banner);
fprintf(stream, "%s%s%s\n%s", output_text_color, banner, cc, inf);
#else
fprintf(stream, "%s", banner);
fprintf(stream, "%s%s\n%s", banner, cc, inf);
#endif
}

View File

@ -35,6 +35,15 @@
#include <stdlib.h>
#include <esl.h>
#include <errno.h>
#include <sys/wait.h>
static void handle_SIGCHLD(int sig)
{
int status = 0;
wait(&status);
return;
}
static void my_forking_callback(esl_socket_t server_sock, esl_socket_t client_sock, struct sockaddr_in *addr)
{
@ -43,6 +52,8 @@ static void my_forking_callback(esl_socket_t server_sock, esl_socket_t client_so
const char *path;
char arg[64] = { 0 };
signal(SIGCHLD, handle_SIGCHLD);
if (fork()) {
close(client_sock);
return;

View File

@ -0,0 +1,3 @@
const char *cc = "\n.========================================================================================================.\n| ____ _____ ____ _ ____ _ _ ____ |\n| / ___|___ _ __ ___ ___ |_ _|__ / ___| |_ _ ___ / ___|___ _ __ ( ) |___ \\ |\n| | | / _ \\| '_ ` _ \\ / _ \\ | |/ _ \\ | | | | | | |/ _ \\ | / _ \\| '_ \\ |/| | __) | |\n| | |__| (_) | | | | | | __/ | | (_) | | |___| | |_| | __/ |__| (_) | | | | | |/ __/ |\n| \\____\\___/|_| |_| |_|\\___| |_|\\___/ \\____|_|\\__,_|\\___|\\____\\___/|_| |_| |_|_____| |\n| |\n| ____ _ _ _ _ ____ _ |\n| / ___| |__ (_) ___ __ _ __ _ ___ | | | / ___| / \\ |\n| | | | '_ \\| |/ __/ _` |/ _` |/ _ \\ | | | \\___ \\ / _ \\ |\n| | |___| | | | | (_| (_| | (_| | (_) | _ | |_| |___) / ___ \\ |\n| \\____|_| |_|_|\\___\\__,_|\\__, |\\___/ ( ) \\___/|____/_/ \\_\\ |\n| |___/ |/ |\n| _ _ _____ _ _ ___ _ _ ____ ___ _ ____ |\n| / \\ _ _ __ _ _ _ ___| |_ |___ | |_| |__ / _ \\| |_| |__ |___ \\ / _ \\/ |___ \\ |\n| / _ \\| | | |/ _` | | | / __| __| / /| __| '_ \\ _____ | (_) | __| '_ \\ __) | | | | | __) | |\n| / ___ \\ |_| | (_| | |_| \\__ \\ |_ / / | |_| | | | |_____| \\__, | |_| | | | / __/| |_| | |/ __/ |\n| /_/ \\_\\__,_|\\__, |\\__,_|___/\\__| /_/ \\__|_| |_| /_/ \\__|_| |_| |_____|\\___/|_|_____| |\n| |___/ |\n| _ |\n| __ ____ ____ __ ___| |_ _ ___ ___ ___ _ __ ___ ___ _ __ ___ |\n| \\ \\ /\\ / /\\ \\ /\\ / /\\ \\ /\\ / / / __| | | | |/ _ \\/ __/ _ \\| '_ \\ / __/ _ \\| '_ ` _ \\ |\n| \\ V V / \\ V V / \\ V V / _ | (__| | |_| | __/ (_| (_) | | | | _ | (_| (_) | | | | | | |\n| \\_/\\_/ \\_/\\_/ \\_/\\_/ (_) \\___|_|\\__,_|\\___|\\___\\___/|_| |_| (_) \\___\\___/|_| |_| |_| |\n| |\n.========================================================================================================.\n\n";

View File

@ -79,7 +79,8 @@ libfreetdm_la_SOURCES = \
$(SRC)/ftdm_buffer.c \
$(SRC)/ftdm_threadmutex.c \
$(SRC)/ftdm_dso.c \
$(SRC)/ftdm_cpu_monitor.c
$(SRC)/ftdm_cpu_monitor.c \
$(SRC)/ftdm_backtrace.c
library_include_HEADERS = \
$(SRC)/include/freetdm.h \

View File

@ -136,7 +136,7 @@ AC_CHECK_LIB([dl], [dlopen])
AC_CHECK_LIB([pthread], [pthread_create])
AC_CHECK_LIB([m], [cos])
AC_CHECK_HEADERS([netdb.h sys/select.h])
AC_CHECK_HEADERS([netdb.h sys/select.h execinfo.h])
AC_CHECK_FUNC([gethostbyname_r],
[], [AC_CHECK_LIB([nsl], [gethostbyname_r])]

View File

@ -35,13 +35,6 @@
#include "freetdm.h"
//#define CUDATEL_DEBUG
#ifdef CUDATEL_DEBUG
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
#endif
#include <execinfo.h>
#include <syscall.h>
#endif
#ifndef __FUNCTION__
#define __FUNCTION__ __SWITCH_FUNC__
@ -499,6 +492,21 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session)
return SWITCH_STATUS_SUCCESS;
}
#ifdef CUDATEL_DEBUG
struct cudatel_trace_priv {
const char *name;
int span_id;
int chan_id;
};
static void cudatel_trace(const int tid, const void *addr, const char *symbol, void *priv)
{
struct cudatel_trace_priv *data = priv;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%d:%d][tid:%d] %s -> %s\n",
data->span_id, data->chan_id, tid, data->name, symbol);
}
#endif
static switch_status_t channel_on_hangup(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
@ -558,19 +566,11 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
#ifdef CUDATEL_DEBUG
{
pid_t tid = 0;
size_t size = 0;
char **symbols = NULL;
void *stacktrace[50];
int si = 0;
size = backtrace(stacktrace, ftdm_array_len(stacktrace));
symbols = backtrace_symbols(stacktrace, size);
tid = syscall(SYS_gettid);
for (si = 0; si < size; si++) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%d:%d][tid:%d] %s -> %s\n",
span_id, chan_id, tid, name, symbols[si]);
}
free(symbols);
struct cudatel_trace_priv trace_data;
trace_data.name = name;
trace_data.span_id = span_id;
trace_data.chan_id = chan_id;
ftdm_backtrace_walk(&cudatel_trace, &trace_data);
}
#endif

View File

@ -0,0 +1,75 @@
/*
*
*
*/
#define _BSD_SOURCE
#include "private/ftdm_core.h"
#ifdef HAVE_EXECINFO_H
#include <stdlib.h>
#include <unistd.h>
#include <execinfo.h>
#include <syscall.h>
#define FTDM_BACKTRACE_MAX 50
FT_DECLARE(ftdm_status_t) ftdm_backtrace_walk(void (* callback)(const int tid, const void *addr, const char *symbol, void *priv), void *priv)
{
void *stacktrace[FTDM_BACKTRACE_MAX];
char **symbols = NULL;
size_t size = 0;
pid_t tid = 0;
int si = 0;
if (!callback) {
return FTDM_EINVAL;
}
tid = syscall(SYS_gettid);
size = backtrace(stacktrace, ftdm_array_len(stacktrace));
symbols = backtrace_symbols(stacktrace, size);
for (si = 0; si < size; si++) {
callback(tid, stacktrace[si], symbols[si], priv);
}
free(symbols);
return FTDM_SUCCESS;
}
#else /* !HAVE_EXECINFO_H */
FT_DECLARE(ftdm_status_t) ftdm_backtrace_walk(void (* callback)(const int tid, const void *addr, const char *symbol, void *priv), void *priv)
{
ftdm_log(FTDM_LOG_DEBUG, "Stack traces are not available on this platform!\n");
return FTDM_NOTIMPL;
}
#endif
static void span_backtrace(const int tid, const void *addr, const char *symbol, void *priv)
{
ftdm_span_t *span = priv;
ftdm_log(FTDM_LOG_DEBUG, "[%d][tid:%d] %p -> %s\n",
ftdm_span_get_id(span), tid, addr, symbol);
}
FT_DECLARE(ftdm_status_t) ftdm_backtrace_span(ftdm_span_t *span)
{
return ftdm_backtrace_walk(&span_backtrace, span);
}
static void chan_backtrace(const int tid, const void *addr, const char *symbol, void *priv)
{
ftdm_channel_t *chan = priv;
ftdm_log(FTDM_LOG_DEBUG, "[%d:%d][tid:%d] %p -> %s\n",
ftdm_channel_get_span_id(chan), ftdm_channel_get_id(chan), tid, addr, symbol);
}
FT_DECLARE(ftdm_status_t) ftdm_backtrace_chan(ftdm_channel_t *chan)
{
return ftdm_backtrace_walk(&chan_backtrace, chan);
}

View File

@ -262,9 +262,12 @@ FTDM_STR2ENUM(ftdm_str2ftdm_tonemap, ftdm_tonemap2str, ftdm_tonemap_t, TONEMAP_N
FTDM_ENUM_NAMES(OOB_NAMES, OOB_STRINGS)
FTDM_STR2ENUM(ftdm_str2ftdm_oob_event, ftdm_oob_event2str, ftdm_oob_event_t, OOB_NAMES, FTDM_OOB_INVALID)
FTDM_ENUM_NAMES(TRUNK_TYPE_NAMES, TRUNK_STRINGS)
FTDM_ENUM_NAMES(TRUNK_TYPE_NAMES, TRUNK_TYPE_STRINGS)
FTDM_STR2ENUM(ftdm_str2ftdm_trunk_type, ftdm_trunk_type2str, ftdm_trunk_type_t, TRUNK_TYPE_NAMES, FTDM_TRUNK_NONE)
FTDM_ENUM_NAMES(TRUNK_MODE_NAMES, TRUNK_MODE_STRINGS)
FTDM_STR2ENUM(ftdm_str2ftdm_trunk_mode, ftdm_trunk_mode2str, ftdm_trunk_mode_t, TRUNK_MODE_NAMES, FTDM_TRUNK_MODE_INVALID)
FTDM_ENUM_NAMES(START_TYPE_NAMES, START_TYPE_STRINGS)
FTDM_STR2ENUM(ftdm_str2ftdm_analog_start_type, ftdm_analog_start_type2str, ftdm_analog_start_type_t, START_TYPE_NAMES, FTDM_ANALOG_START_NA)
@ -816,6 +819,7 @@ FT_DECLARE(ftdm_status_t) ftdm_span_create(const char *iotype, const char *name,
ftdm_copy_string(new_span->tone_map[FTDM_TONEMAP_BUSY], "%(500,500,480,620)", FTDM_TONEMAP_LEN);
ftdm_copy_string(new_span->tone_map[FTDM_TONEMAP_ATTN], "%(100,100,1400,2060,2450,2600)", FTDM_TONEMAP_LEN);
new_span->trunk_type = FTDM_TRUNK_NONE;
new_span->trunk_mode = FTDM_TRUNK_MODE_CPE;
new_span->data_type = FTDM_TYPE_SPAN;
ftdm_mutex_lock(globals.span_mutex);
@ -1994,6 +1998,21 @@ FT_DECLARE(const char *) ftdm_span_get_trunk_type_str(const ftdm_span_t *span)
return ftdm_trunk_type2str(span->trunk_type);
}
FT_DECLARE(void) ftdm_span_set_trunk_mode(ftdm_span_t *span, ftdm_trunk_mode_t mode)
{
span->trunk_mode = mode;
}
FT_DECLARE(ftdm_trunk_mode_t) ftdm_span_get_trunk_mode(const ftdm_span_t *span)
{
return span->trunk_mode;
}
FT_DECLARE(const char *) ftdm_span_get_trunk_mode_str(const ftdm_span_t *span)
{
return ftdm_trunk_mode2str(span->trunk_mode);
}
FT_DECLARE(uint32_t) ftdm_span_get_id(const ftdm_span_t *span)
{
return span->span_id;
@ -4706,6 +4725,10 @@ static ftdm_status_t load_config(void)
ftdm_trunk_type_t trtype = ftdm_str2ftdm_trunk_type(val);
ftdm_span_set_trunk_type(span, trtype);
ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s'\n", ftdm_trunk_type2str(trtype));
} else if (!strcasecmp(var, "trunk_mode")) {
ftdm_trunk_mode_t trmode = ftdm_str2ftdm_trunk_mode(val);
ftdm_span_set_trunk_mode(span, trmode);
ftdm_log(FTDM_LOG_DEBUG, "setting trunk mode to '%s'\n", ftdm_trunk_mode2str(trmode));
} else if (!strcasecmp(var, "name")) {
if (!strcasecmp(val, "undef")) {
chan_config.name[0] = '\0';
@ -4729,9 +4752,10 @@ static ftdm_status_t load_config(void)
}
} else if (!strcasecmp(var, "fxo-channel")) {
if (span->trunk_type == FTDM_TRUNK_NONE) {
span->trunk_type = FTDM_TRUNK_FXO;
ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s' start(%s)\n", ftdm_trunk_type2str(span->trunk_type),
ftdm_analog_start_type2str(span->start_type));
span->trunk_type = FTDM_TRUNK_FXO;
span->trunk_mode = FTDM_TRUNK_MODE_CPE;
ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s' start(%s), mode(%s)\n", ftdm_trunk_type2str(span->trunk_type),
ftdm_analog_start_type2str(span->start_type), ftdm_trunk_mode2str(span->trunk_mode));
}
if (span->trunk_type == FTDM_TRUNK_FXO) {
unsigned chans_configured = 0;
@ -4745,8 +4769,9 @@ static ftdm_status_t load_config(void)
} else if (!strcasecmp(var, "fxs-channel")) {
if (span->trunk_type == FTDM_TRUNK_NONE) {
span->trunk_type = FTDM_TRUNK_FXS;
ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s' start(%s)\n", ftdm_trunk_type2str(span->trunk_type),
ftdm_analog_start_type2str(span->start_type));
span->trunk_mode = FTDM_TRUNK_MODE_NET;
ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s' start(%s), mode(%s)\n", ftdm_trunk_type2str(span->trunk_type),
ftdm_analog_start_type2str(span->start_type), ftdm_trunk_mode2str(span->trunk_mode));
}
if (span->trunk_type == FTDM_TRUNK_FXS) {
unsigned chans_configured = 0;
@ -4760,8 +4785,9 @@ static ftdm_status_t load_config(void)
} else if (!strcasecmp(var, "em-channel")) {
if (span->trunk_type == FTDM_TRUNK_NONE) {
span->trunk_type = FTDM_TRUNK_EM;
ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s' start(%s)\n", ftdm_trunk_type2str(span->trunk_type),
ftdm_analog_start_type2str(span->start_type));
span->trunk_mode = FTDM_TRUNK_MODE_CPE;
ftdm_log(FTDM_LOG_DEBUG, "setting trunk type to '%s' start(%s), mode(%s)\n", ftdm_trunk_type2str(span->trunk_type),
ftdm_analog_start_type2str(span->start_type), ftdm_trunk_mode2str(span->trunk_mode));
}
if (span->trunk_type == FTDM_TRUNK_EM) {
unsigned chans_configured = 0;

View File

@ -2462,9 +2462,15 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span)
memset(isdn_data, 0, sizeof(*isdn_data));
/* set some default values */
isdn_data->mode = PRI_CPE;
isdn_data->ton = PRI_UNKNOWN;
/* Use span's trunk_mode as a reference for the default libpri mode */
if (ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_NET) {
isdn_data->mode = PRI_NETWORK;
} else {
isdn_data->mode = PRI_CPE;
}
switch (ftdm_span_get_trunk_type(span)) {
case FTDM_TRUNK_BRI:
case FTDM_TRUNK_BRI_PTMP:
@ -2516,8 +2522,8 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span)
if (!strcasecmp(var, "node") || !strcasecmp(var, "mode")) {
if ((isdn_data->mode = parse_mode(val)) == -1) {
ftdm_log(FTDM_LOG_ERROR, "Unknown node type '%s', defaulting to CPE mode\n", val);
isdn_data->mode = PRI_CPE;
ftdm_log(FTDM_LOG_ERROR, "Unknown node type '%s'\n", val);
goto error;
}
}
else if (!strcasecmp(var, "switch") || !strcasecmp(var, "dialect")) {
@ -2563,6 +2569,16 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span)
}
}
/* Check if modes match and log a message if they do not. Just to be on the safe side. */
if (isdn_data->mode == PRI_CPE && ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_NET) {
ftdm_log(FTDM_LOG_WARNING, "Span '%s' signalling set up for TE/CPE/USER mode, while port is running in NT/NET mode. You may want to check your 'trunk_mode' settings.\n",
ftdm_span_get_name(span));
}
else if (isdn_data->mode == PRI_NETWORK && ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_CPE) {
ftdm_log(FTDM_LOG_WARNING, "Span '%s' signalling set up for NT/NET mode, while port is running in TE/CPE/USER mode. You may want to check your 'trunk_mode' settings.\n",
ftdm_span_get_name(span));
}
span->start = ftdm_libpri_start;
span->stop = ftdm_libpri_stop;
span->signal_cb = sig_cb;

View File

@ -1432,12 +1432,12 @@ static ftdm_status_t misdn_open_range(ftdm_span_t *span, ftdm_chan_type_t type,
switch (ftdm_span_get_trunk_type(span)) {
case FTDM_TRUNK_E1:
d_protocol = ISDN_P_TE_E1;
d_protocol = ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_NET ? ISDN_P_NT_E1 : ISDN_P_TE_E1;
d_channel = 16;
break;
case FTDM_TRUNK_BRI:
case FTDM_TRUNK_BRI_PTMP:
d_protocol = ISDN_P_TE_S0;
d_protocol = ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_NET ? ISDN_P_NT_S0 : ISDN_P_TE_S0;
d_channel = 0;
break;
default:

View File

@ -484,11 +484,23 @@ typedef enum {
FTDM_TRUNK_GSM,
FTDM_TRUNK_NONE
} ftdm_trunk_type_t;
#define TRUNK_STRINGS "E1", "T1", "J1", "BRI", "BRI_PTMP", "FXO", "FXS", "EM", "GSM", "NONE"
#define TRUNK_TYPE_STRINGS "E1", "T1", "J1", "BRI", "BRI_PTMP", "FXO", "FXS", "EM", "GSM", "NONE"
/*! \brief Move from string to ftdm_trunk_type_t and viceversa */
FTDM_STR2ENUM_P(ftdm_str2ftdm_trunk_type, ftdm_trunk_type2str, ftdm_trunk_type_t)
/*! \brief Span trunk modes */
typedef enum {
FTDM_TRUNK_MODE_CPE,
FTDM_TRUNK_MODE_NET,
FTDM_TRUNK_MODE_INVALID
} ftdm_trunk_mode_t;
#define TRUNK_MODE_STRINGS "CPE", "NET", "INVALID"
/*! \brief Move from string to ftdm_trunk_mode_t and viceversa */
FTDM_STR2ENUM_P(ftdm_str2ftdm_trunk_mode, ftdm_trunk_mode2str, ftdm_trunk_mode_t)
/*! \brief Basic channel configuration provided to ftdm_configure_span_channels */
typedef struct ftdm_channel_config {
char name[FTDM_MAX_NAME_STR_SZ];
@ -1744,6 +1756,28 @@ FT_DECLARE(ftdm_trunk_type_t) ftdm_span_get_trunk_type(const ftdm_span_t *span);
/*! \brief For display debugging purposes you can display this string which describes the trunk type of a span */
FT_DECLARE(const char *) ftdm_span_get_trunk_type_str(const ftdm_span_t *span);
/*!
* Set the trunk mode for a span
* \note This must be called before configuring any channels within the span!
* \param[in] span The span
* \param[in] type The trunk mode
*/
FT_DECLARE(void) ftdm_span_set_trunk_mode(ftdm_span_t *span, ftdm_trunk_mode_t mode);
/*!
* Get the trunk mode for a span
* \param[in] span The span
* \return Span trunk mode
*/
FT_DECLARE(ftdm_trunk_mode_t) ftdm_span_get_trunk_mode(const ftdm_span_t *span);
/*!
* Get the trunk mode of a span in textual form
* \param[in] span The span
* \return Span mode name as a string
*/
FT_DECLARE(const char *) ftdm_span_get_trunk_mode_str(const ftdm_span_t *span);
/*!
* \brief Return the channel identified by the provided id
*
@ -1814,6 +1848,40 @@ FT_DECLARE(void) ftdm_global_set_config_directory(const char *path);
/*! \brief Check if the FTDM library is initialized and running */
FT_DECLARE(ftdm_bool_t) ftdm_running(void);
/**
* Generate a stack trace and invoke a callback function for each entry
* \param[in] callback Callback function, that is invoked for each stack symbol
* \param[in] priv (User-)Private data passed to the callback
* \retval
* FTDM_SUCCESS On success
* FTDM_NOTIMPL Backtraces are not available
* FTDM_EINVAL Invalid arguments (callback was NULL)
*/
FT_DECLARE(ftdm_status_t) ftdm_backtrace_walk(void (* callback)(const int tid, const void *addr, const char *symbol, void *priv), void *priv);
/**
* Convenience function to print a backtrace for a span.
* \note The backtrace is generated with FTDM_LOG_DEBUG log level.
* \param[in] span Span object
* \retval
* FTDM_SUCCESS On success
* FTDM_NOTIMPL Backtraces are not available
* FTDM_EINVAL Invalid arguments (e.g. span was NULL)
*/
FT_DECLARE(ftdm_status_t) ftdm_backtrace_span(ftdm_span_t *span);
/**
* Convenience function to print a backtrace for a channel.
* \note The backtrace is generated with FTDM_LOG_DEBUG log level.
* \param[in] chan Channel object
* \retval
* FTDM_SUCCESS On success
* FTDM_NOTIMPL Backtraces are not available
* FTDM_EINVAL Invalid arguments (e.g. chan was NULL)
*/
FT_DECLARE(ftdm_status_t) ftdm_backtrace_chan(ftdm_channel_t *chan);
FT_DECLARE_DATA extern ftdm_logger_t ftdm_log;
/*! \brief Basic transcoding function prototype */

View File

@ -104,10 +104,6 @@
#include <sys/time.h>
#endif
#ifdef __linux__
#include <execinfo.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -489,6 +485,7 @@ struct ftdm_span {
fio_event_cb_t event_callback;
ftdm_mutex_t *mutex;
ftdm_trunk_type_t trunk_type;
ftdm_trunk_mode_t trunk_mode;
ftdm_analog_start_type_t start_type;
ftdm_signal_type_t signal_type;
uint32_t last_used_index;

View File

@ -1074,13 +1074,15 @@ static void our_sofia_event_callback(nua_event_t event,
case nua_i_cancel:
switch_channel_set_variable(channel, "sip_hangup_disposition", "recv_cancel");
if (sip && channel) {
switch_channel_set_variable(channel, "sip_hangup_disposition", "recv_cancel");
if (sip && channel && sip->sip_reason) {
char *reason_header = sip_header_as_string(nh->nh_home, (void *) sip->sip_reason);
if (sip->sip_reason) {
char *reason_header = sip_header_as_string(nh->nh_home, (void *) sip->sip_reason);
if (!zstr(reason_header)) {
switch_channel_set_variable_partner(channel, "sip_reason", reason_header);
if (!zstr(reason_header)) {
switch_channel_set_variable_partner(channel, "sip_reason", reason_header);
}
}
}
@ -5039,11 +5041,13 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu
} else if (sofia_test_pflag(profile, PFLAG_UNREG_OPTIONS_FAIL) && (status != 200 && status != 486) && sip && sip->sip_to) {
char *sql;
time_t now = switch_epoch_time_now(NULL);
const char *call_id = sip->sip_call_id->i_id;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Expire registration '%s@%s' due to options failure\n",
sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host);
sql = switch_mprintf("update sip_registrations set expires=%ld where sip_user='%s' and sip_host='%s'",
(long) now, sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host);
sql = switch_mprintf("update sip_registrations set expires=%ld where sip_user='%s' and sip_host='%s' and call_id='%q'",
(long) now, sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host, call_id);
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
}
}

View File

@ -551,15 +551,16 @@ int sofia_reg_nat_callback(void *pArg, int argc, char **argv, char **columnNames
{
sofia_profile_t *profile = (sofia_profile_t *) pArg;
nua_handle_t *nh;
char to[128] = "";
char to[512] = "";
sofia_destination_t *dst = NULL;
switch_snprintf(to, sizeof(to), "sip:%s@%s", argv[1], argv[2]);
dst = sofia_glue_get_destination(argv[3]);
switch_assert(dst);
nh = nua_handle(profile->nua, NULL, SIPTAG_FROM_STR(profile->url), SIPTAG_TO_STR(to), NUTAG_URL(dst->contact), SIPTAG_CONTACT_STR(profile->url),
TAG_END());
SIPTAG_CALL_ID_STR(argv[0]), TAG_END());
nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
nua_options(nh,
NTATAG_SIP_T2(5000),

File diff suppressed because it is too large Load Diff

View File

@ -3577,7 +3577,9 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables_check(switch_channel_t *c
idx = atoi(ptr);
}
if (vtype == 3 || (sub_val = (char *) switch_channel_get_variable_dup(channel, vname, SWITCH_TRUE, idx))) {
if (!sub_val) sub_val = vname;
if ((sub_val = (char *) switch_channel_get_variable_dup(channel, vname, SWITCH_TRUE, idx))) {
if (var_list && !switch_event_check_permission_list(var_list, vname)) {
sub_val = "INVALID";
}