Merge branch 'master' into smgmaster

This commit is contained in:
Moises Silva 2011-09-15 09:53:55 -04:00
commit ccdd76b126
47 changed files with 1601 additions and 900 deletions

View File

@ -566,6 +566,7 @@ update-clean: clean modwipe uninstall libs/openzap/Makefile python-reconf
cd libs/portaudio && $(MAKE) clean
cd libs/speex && $(MAKE) clean
cd libs/esl && $(MAKE) clean
cd libs/sqlite && $(MAKE) clean
swigall:
@echo reswigging all

View File

@ -4,6 +4,7 @@
<param name="log-level" value="0"/>
<!-- <param name="auto-restart" value="false"/> -->
<param name="debug-presence" value="0"/>
<!-- <param name="capture-server" value="udp:homer.domain.com:5060"/> -->
</global_settings>
<!--

View File

@ -21,6 +21,7 @@
<!-- If you want FreeSWITCH to shutdown if this profile fails to load, uncomment the next line. -->
<!-- <param name="shutdown-on-fail" value="true"/> -->
<param name="sip-trace" value="no"/>
<param name="sip-capture" value="no"/>
<param name="rfc2833-pt" value="101"/>
<param name="sip-port" value="$${external_sip_port}"/>
<param name="dialplan" value="XML"/>

View File

@ -42,6 +42,7 @@
<!-- If you want FreeSWITCH to shutdown if this profile fails to load, uncomment the next line. -->
<!-- <param name="shutdown-on-fail" value="true"/> -->
<param name="sip-trace" value="no"/>
<param name="sip-capture" value="no"/>
<!-- Don't be picky about negotiated DTMF just always offer 2833 and accept both 2833 and INFO -->

View File

@ -34,6 +34,12 @@ trunk_type => FXS
; add FXS channels from 3 to 4 at wanpipe span 1 to this freetdm span
fxs-channel => 1:3-4
; IO stats. Defaults to yes, you can print the stats with ftdm iostats print <span> <chan>
; This feature depends on the span IO type, currently only Wanpipe spans support it
; This may cause a warning to be printed once in a while if audio is not provided fast enough
; and causes the driver to transmit an idle frame (when there is no data provided by the application)
iostats => yes
[span wanpipe myWanpipe2]
trunk_type => FXO
; This number will be used as DNIS for FXO devices

File diff suppressed because it is too large Load Diff

View File

@ -2825,9 +2825,9 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_command(ftdm_channel_t *ftdmchan, ftdm_co
ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "No channel\n");
ftdm_assert_return(ftdmchan->fio != NULL, FTDM_FAIL, "No IO attached to channel\n");
ftdm_mutex_lock(ftdmchan->mutex);
ftdm_channel_lock(ftdmchan);
switch(command) {
switch (command) {
case FTDM_COMMAND_ENABLE_CALLERID_DETECT:
{
@ -3278,12 +3278,31 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_command(ftdm_channel_t *ftdmchan, ftdm_co
GOTO_STATUS(done, FTDM_SUCCESS);
}
break;
case FTDM_COMMAND_GET_IOSTATS:
{
if (!obj) {
GOTO_STATUS(done, FTDM_EINVAL);
}
memcpy(obj, &ftdmchan->iostats, sizeof(ftdmchan->iostats));
GOTO_STATUS(done, FTDM_SUCCESS);
}
break;
case FTDM_COMMAND_SWITCH_IOSTATS:
{
ftdm_bool_t enable = *(ftdm_bool_t *)obj;
if (enable) {
ftdm_channel_set_feature(ftdmchan, FTDM_CHANNEL_FEATURE_IO_STATS);
} else {
ftdm_channel_clear_feature(ftdmchan, FTDM_CHANNEL_FEATURE_IO_STATS);
}
GOTO_STATUS(done, FTDM_SUCCESS);
}
break;
default:
break;
}
if (!ftdmchan->fio->command) {
snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "method not implemented");
ftdm_log(FTDM_LOG_ERROR, "no command function defined by the I/O freetdm module!\n");
GOTO_STATUS(done, FTDM_FAIL);
}
@ -3291,11 +3310,12 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_command(ftdm_channel_t *ftdmchan, ftdm_co
status = ftdmchan->fio->command(ftdmchan, command, obj);
if (status == FTDM_NOTIMPL) {
snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "I/O command %d not implemented in backend", command);
ftdm_log(FTDM_LOG_ERROR, "I/O backend does not support command %d!\n", command);
}
done:
ftdm_mutex_unlock(ftdmchan->mutex);
ftdm_channel_unlock(ftdmchan);
return status;
}
@ -4564,14 +4584,20 @@ FT_DECLARE(ftdm_status_t) ftdm_configure_span_channels(ftdm_span_t *span, const
return FTDM_FAIL;
}
if (chan_config->debugdtmf) {
for (chan_index = currindex+1; chan_index <= span->chan_count; chan_index++) {
if (!FTDM_IS_VOICE_CHANNEL(span->channels[chan_index])) {
continue;
}
span->channels[chan_index]->dtmfdbg.requested = 1;
for (chan_index = currindex + 1; chan_index <= span->chan_count; chan_index++) {
if (chan_config->iostats) {
ftdm_channel_set_feature(span->channels[chan_index], FTDM_CHANNEL_FEATURE_IO_STATS);
}
if (!FTDM_IS_VOICE_CHANNEL(span->channels[chan_index])) {
continue;
}
if (chan_config->debugdtmf) {
span->channels[chan_index]->dtmfdbg.requested = 1;
}
}
return FTDM_SUCCESS;
}
@ -4638,6 +4664,8 @@ static ftdm_status_t load_config(void)
/* it is confusing that parameters from one span affect others, so let's clear them */
memset(&chan_config, 0, sizeof(chan_config));
sprintf(chan_config.group_name, "__default");
/* default to storing iostats */
chan_config.iostats = FTDM_TRUE;
} else {
ftdm_log(FTDM_LOG_CRIT, "failure creating span of type %s\n", type);
span = NULL;
@ -4764,6 +4792,13 @@ static ftdm_status_t load_config(void)
} else if (!strcasecmp(var, "debugdtmf")) {
chan_config.debugdtmf = ftdm_true(val);
ftdm_log(FTDM_LOG_DEBUG, "Setting debugdtmf to '%s'\n", chan_config.debugdtmf ? "yes" : "no");
} else if (!strncasecmp(var, "iostats", sizeof("iostats")-1)) {
if (ftdm_true(val)) {
chan_config.iostats = FTDM_TRUE;
} else {
chan_config.iostats = FTDM_FALSE;
}
ftdm_log(FTDM_LOG_DEBUG, "Setting iostats to '%s'\n", chan_config.iostats ? "yes" : "no");
} else if (!strcasecmp(var, "group")) {
len = strlen(val);
if (len >= FTDM_MAX_NAME_STR_SZ) {

View File

@ -111,7 +111,7 @@ FT_DECLARE(void) ftdm_thread_override_default_stacksize(ftdm_size_t size)
static void * FTDM_THREAD_CALLING_CONVENTION thread_launch(void *args)
{
void *exit_val;
ftdm_thread_t *thread = (ftdm_thread_t *)args;
ftdm_thread_t *thread = (ftdm_thread_t *)args;
exit_val = thread->function(thread, thread->private_data);
#ifndef WIN32
pthread_attr_destroy(&thread->attribute);
@ -247,6 +247,10 @@ FT_DECLARE(ftdm_status_t) ftdm_mutex_destroy(ftdm_mutex_t **mutex)
FT_DECLARE(ftdm_status_t) _ftdm_mutex_lock(const char *file, int line, const char *func, ftdm_mutex_t *mutex)
{
#ifdef WIN32
UNREFERENCED_PARAMETER(file);
UNREFERENCED_PARAMETER(line);
UNREFERENCED_PARAMETER(func);
EnterCriticalSection(&mutex->mutex);
#else
int err;
@ -264,6 +268,10 @@ FT_DECLARE(ftdm_status_t) _ftdm_mutex_lock(const char *file, int line, const cha
FT_DECLARE(ftdm_status_t) _ftdm_mutex_trylock(const char *file, int line, const char *func, ftdm_mutex_t *mutex)
{
#ifdef WIN32
UNREFERENCED_PARAMETER(file);
UNREFERENCED_PARAMETER(line);
UNREFERENCED_PARAMETER(func);
if (!TryEnterCriticalSection(&mutex->mutex))
return FTDM_FAIL;
#else
@ -297,6 +305,10 @@ FT_DECLARE(ftdm_status_t) _ftdm_mutex_unlock(const char *file, int line, const c
mutex->reentrancy--;
#endif
#ifdef WIN32
UNREFERENCED_PARAMETER(file);
UNREFERENCED_PARAMETER(line);
UNREFERENCED_PARAMETER(func);
LeaveCriticalSection(&mutex->mutex);
#else
if (pthread_mutex_unlock(&mutex->mutex)) {

View File

@ -63,6 +63,10 @@
#define SNGISDN_NUM_LOCAL_NUMBERS 8
#define SNGISDN_DCHAN_QUEUE_LEN 200
#ifndef MI_NOTIFY
#define MI_NOTIFY 0x14
#endif
/* TODO: rename all *_cc_* to *_an_* */
typedef enum {
@ -380,6 +384,7 @@ void sngisdn_snd_setup_ack(ftdm_channel_t *ftdmchan);
void sngisdn_snd_proceed(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind);
void sngisdn_snd_progress(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind);
void sngisdn_snd_alert(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind);
void sngisdn_snd_notify_req(ftdm_channel_t *ftdmchan);
void sngisdn_snd_connect(ftdm_channel_t *ftdmchan);
void sngisdn_snd_disconnect(ftdm_channel_t *ftdmchan);
void sngisdn_snd_release(ftdm_channel_t *ftdmchan, uint8_t glare);
@ -480,7 +485,7 @@ ftdm_status_t set_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr
ftdm_status_t set_facility_ie_str(ftdm_channel_t *ftdmchan, uint8_t *data, uint8_t *data_len);
ftdm_status_t set_user_to_user_ie(ftdm_channel_t *ftdmchan, UsrUsr *usrUsr);
ftdm_status_t set_cause_ie(ftdm_channel_t *ftdmchan, CauseDgn *causeDgn);
ftdm_status_t set_not_ind_ie(ftdm_channel_t *ftdmchan, NotInd *notInd);
ftdm_status_t sngisdn_add_var(sngisdn_chan_data_t *sngisdn_info, const char* var, const char* val);
ftdm_status_t sngisdn_add_raw_data(sngisdn_chan_data_t *sngisdn_info, uint8_t* data, ftdm_size_t data_len);

View File

@ -361,8 +361,9 @@ void sngisdn_process_cnst_ind (sngisdn_event_data_t *sngisdn_event)
(evntType == MI_CALLPROC)?"PROCEED":
(evntType == MI_PROGRESS)?"PROGRESS":
(evntType == MI_SETUPACK)?"SETUP ACK":
(evntType == MI_INFO)?"INFO":"UNKNOWN",
suId, suInstId, spInstId, ces);
(evntType == MI_NOTIFY)?"NOTIFY":
(evntType == MI_INFO)?"INFO":"UNKNOWN",
suId, suInstId, spInstId, ces);
switch(evntType) {
case MI_CALLPROC:
@ -493,7 +494,10 @@ void sngisdn_process_cnst_ind (sngisdn_event_data_t *sngisdn_event)
break;
}
}
break;
case MI_NOTIFY:
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Processing NOTIFY (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId);
/* Do nothing */
break;
default:
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Unhandled STATUS event\n");

View File

@ -317,10 +317,6 @@ void sngisdn_snd_info_req(ftdm_channel_t *ftdmchan)
}
memset(&cnStEvnt, 0, sizeof(cnStEvnt));
//ftdm_log_chan_msg(ftdmchan, FTDM_LOG_INFO, "Sending INFO REQ\n");
ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending INFO REQ (suId:%d dchan:%d ces:%d)\n", signal_data->cc_id, signal_data->dchan_id, sngisdn_info->ces);
@ -330,6 +326,32 @@ void sngisdn_snd_info_req(ftdm_channel_t *ftdmchan)
return;
}
void sngisdn_snd_notify_req(ftdm_channel_t *ftdmchan)
{
CnStEvnt cnStEvnt;
sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data;
sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data;
if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) {
ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Sending NOTIFY, but no call data, aborting (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId);
sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT);
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
return;
}
memset(&cnStEvnt, 0, sizeof(cnStEvnt));
set_not_ind_ie(ftdmchan, &cnStEvnt.notInd);
ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending NOTIFY (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces);
if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId,&cnStEvnt, MI_NOTIFY, signal_data->dchan_id, sngisdn_info->ces)) {
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused NOTIFY request\n");
}
return;
}
void sngisdn_snd_status_enq(ftdm_channel_t *ftdmchan)
{

View File

@ -168,7 +168,8 @@ void sngisdn_rcv_cnst_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, C
(evntType == MI_CALLPROC)?"PROCEED":
(evntType == MI_PROGRESS)?"PROGRESS":
(evntType == MI_SETUPACK)?"SETUP ACK":
(evntType == MI_INFO)?"INFO":"UNKNOWN",
(evntType == MI_NOTIFY)?"NOTIFY":
(evntType == MI_INFO)?"INFO":"UNKNOWN",
suId, suInstId, spInstId, ces);
sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event));

View File

@ -1021,6 +1021,14 @@ ftdm_status_t set_restart_ind_ie(ftdm_channel_t *ftdmchan, RstInd *rstInd)
return FTDM_SUCCESS;
}
ftdm_status_t set_not_ind_ie(ftdm_channel_t *ftdmchan, NotInd *notInd)
{
notInd->eh.pres = PRSNT_NODEF;
notInd->notDesc.pres = PRSNT_NODEF;
notInd->notDesc.val = 0x71; /* Call information event */
return FTDM_SUCCESS;
}
void sngisdn_t3_timeout(void *p_sngisdn_info)
{
sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)p_sngisdn_info;

View File

@ -737,8 +737,16 @@ uint32_t sngisdn_decode_ie(char *str, uint32_t *str_len, uint8_t current_codeset
calling_subaddr_string, (j-1), get_code_2_str(type, dcodQ931TypeOfSubaddressTable), type);
}
break;
case PROT_Q931_IE_REDIRECTION_NUMBER:
case PROT_Q931_IE_NOTIFICATION_IND:
{
uint8_t desc;
desc = get_bits(OCTET(3),1,7);
*str_len += sprintf(&str[*str_len], "%s (%d)\n",
get_code_2_str(desc, dcodQ931NotificationIndTable), desc);
}
break;
case PROT_Q931_IE_REDIRECTION_NUMBER:
case PROT_Q931_IE_DATE_TIME:
case PROT_Q931_IE_INFORMATION_REQUEST:
case PROT_Q931_IE_SIGNAL:

View File

@ -591,4 +591,9 @@ struct code2str dcodQ931AssocInfoTable[] = {
{ -1, "Invalid"},
};
struct code2str dcodQ931NotificationIndTable[] = {
{ 0x71, "Call Information/event"},
{ -1, "Invalid"},
};
#endif /* __FTMOD_SANGOMA_ISDN_TRACE_H__ */

View File

@ -656,10 +656,10 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
/* inform the user there is media avai */
sngss7_send_signal(sngss7_info, FTDM_SIGEVENT_PROGRESS_MEDIA);
} else {
ft_to_sngss7_cpg(ftdmchan);
}
/* nothing to do at this time */
break;
/**************************************************************************/
case FTDM_CHANNEL_STATE_UP: /*call is accpeted...both incoming and outgoing */

View File

@ -751,6 +751,7 @@ int ftmod_ss7_isup_ckt_sta(uint32_t id, unsigned char *state);
/* in ftmod_sangoma_ss7_out.c */
void ft_to_sngss7_iam(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_acm(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_cpg (ftdm_channel_t *ftdmchan);
void ft_to_sngss7_anm(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_rel(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_rlc(ftdm_channel_t *ftdmchan);

View File

@ -36,6 +36,8 @@
/******************************************************************************/
/* DEFINES ********************************************************************/
#define SNGSS7_EVNTINFO_IND_INBAND_AVAIL 0x03
/******************************************************************************/
/* GLOBALS ********************************************************************/
@ -171,6 +173,7 @@ void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan)
acm.optBckCalInd.simpleSegmInd.pres = PRSNT_DEF;
acm.optBckCalInd.mlppUserInd.pres = PRSNT_DEF;
acm.optBckCalInd.usrNetIneractInd.pres = PRSNT_DEF;
acm.optBckCalInd.netExcDelInd.pres = PRSNT_DEF;
} /* if (sngss7_test_options(isup_intf, SNGSS7_ACM_OBCI_BITA)) */
/* send the ACM request to LibSngSS7 */
@ -187,6 +190,32 @@ void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan)
return;
}
void ft_to_sngss7_cpg (ftdm_channel_t *ftdmchan)
{
SiCnStEvnt cpg;
SS7_FUNC_TRACE_ENTER (__FUNCTION__);
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
memset (&cpg, 0, sizeof (cpg));
cpg.evntInfo.eh.pres = PRSNT_NODEF;
cpg.evntInfo.evntInd.pres = PRSNT_NODEF;
cpg.evntInfo.evntInd.val = SNGSS7_EVNTINFO_IND_INBAND_AVAIL; /* Event Indicator = In-band info is now available */
cpg.evntInfo.evntPresResInd.pres = PRSNT_NODEF;
cpg.evntInfo.evntPresResInd.val = 0; /* Event presentation restricted indicator = no indication */
/* send the CPG request to LibSngSS7 */
sng_cc_con_status (1, sngss7_info->suInstId, sngss7_info->spInstId, sngss7_info->circuit->id, &cpg, PROGRESS);
ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "[CIC:%d]Tx CPG\n", sngss7_info->circuit->cic);
ftdm_call_clear_vars(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
void ft_to_sngss7_anm (ftdm_channel_t * ftdmchan)
{
SS7_FUNC_TRACE_ENTER (__FUNCTION__);

View File

@ -144,14 +144,16 @@ ftdm_status_t copy_cgPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *cg
ftdm_status_t copy_cgPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *cgPtyNum)
{
const char *val;
const char *val = NULL;
const char *clg_nadi = NULL;
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
ftdm_caller_data_t *caller_data = &ftdmchan->caller_data;
cgPtyNum->eh.pres = PRSNT_NODEF;
cgPtyNum->natAddrInd.pres = PRSNT_NODEF;
cgPtyNum->natAddrInd.val = 0x03;
cgPtyNum->natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].clg_nadi;
cgPtyNum->scrnInd.pres = PRSNT_NODEF;
@ -178,6 +180,14 @@ ftdm_status_t copy_cgPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *cgPt
cgPtyNum->niInd.pres = PRSNT_NODEF;
cgPtyNum->niInd.val = 0x00;
/* check if the user would like a custom NADI value for the calling Pty Num */
clg_nadi = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_clg_nadi");
if (!ftdm_strlen_zero(clg_nadi)) {
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Calling NADI value \"%s\"\n", clg_nadi);
cgPtyNum->natAddrInd.val = atoi(clg_nadi);
}
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Calling Party Number Presentation Ind %d\n", cgPtyNum->presRest.val);
return copy_tknStr_to_sngss7(caller_data->cid_num.digits, &cgPtyNum->addrSig, &cgPtyNum->oddEven);
}

View File

@ -487,6 +487,7 @@ typedef struct ftdm_channel_config {
float rxgain;
float txgain;
uint8_t debugdtmf;
uint8_t iostats;
} ftdm_channel_config_t;
/*!
@ -707,7 +708,10 @@ typedef enum {
FTDM_COMMAND_FLUSH_TX_BUFFERS = 45,
FTDM_COMMAND_FLUSH_RX_BUFFERS = 46,
FTDM_COMMAND_FLUSH_BUFFERS = 47,
/*!< Flush IO statistics */
FTDM_COMMAND_FLUSH_IOSTATS = 48,
FTDM_COMMAND_SET_PRE_BUFFER_SIZE = 49,
FTDM_COMMAND_SET_LINK_STATUS = 50,
FTDM_COMMAND_GET_LINK_STATUS = 51,
@ -719,6 +723,11 @@ typedef enum {
FTDM_COMMAND_START_MF_PLAYBACK = 57,
FTDM_COMMAND_STOP_MF_PLAYBACK = 58,
/*!< Get a copy of the current IO stats */
FTDM_COMMAND_GET_IOSTATS = 59,
/*!< Enable/disable IO stats in the channel */
FTDM_COMMAND_SWITCH_IOSTATS = 60,
FTDM_COMMAND_COUNT,
} ftdm_command_t;
@ -903,6 +912,37 @@ typedef enum {
FTDM_MF_DIRECTION_BACKWARD = (1 << 9)
} ftdm_mf_direction_flag_t;
/*! \brief IO Error statistics */
typedef enum {
FTDM_IOSTATS_ERROR_CRC = (1 << 0),
FTDM_IOSTATS_ERROR_FRAME = (1 << 1),
FTDM_IOSTATS_ERROR_ABORT = (1 << 2),
FTDM_IOSTATS_ERROR_FIFO = (1 << 3),
FTDM_IOSTATS_ERROR_DMA = (1 << 4),
FTDM_IOSTATS_ERROR_QUEUE_THRES = (1 << 5), /* Queue reached high threshold */
FTDM_IOSTATS_ERROR_QUEUE_FULL = (1 << 6), /* Queue is full */
} ftdm_iostats_error_type_t;
/*! \brief IO statistics */
typedef struct {
struct {
uint32_t errors;
uint16_t flags;
uint8_t queue_size; /*!< max queue size configured */
uint8_t queue_len; /*!< Current number of elements in queue */
uint64_t packets;
} rx;
struct {
uint32_t errors;
uint16_t flags;
uint8_t idle_packets;
uint8_t queue_size; /*!< max queue size configured */
uint8_t queue_len; /*!< Current number of elements in queue */
uint64_t packets;
} tx;
} ftdm_channel_iostats_t;
/*! \brief Override the default queue handler */
FT_DECLARE(ftdm_status_t) ftdm_global_set_queue_handler(ftdm_queue_handler_t *handler);

View File

@ -359,35 +359,6 @@ typedef struct {
ftdm_mutex_t *mutex;
} ftdm_dtmf_debug_t;
typedef enum {
FTDM_IOSTATS_ERROR_CRC = (1 << 0),
FTDM_IOSTATS_ERROR_FRAME = (1 << 1),
FTDM_IOSTATS_ERROR_ABORT = (1 << 2),
FTDM_IOSTATS_ERROR_FIFO = (1 << 3),
FTDM_IOSTATS_ERROR_DMA = (1 << 4),
FTDM_IOSTATS_ERROR_QUEUE_THRES = (1 << 5), /* Queue reached high threshold */
FTDM_IOSTATS_ERROR_QUEUE_FULL = (1 << 6), /* Queue is full */
} ftdm_iostats_error_type_t;
typedef struct {
struct {
uint32_t errors;
uint16_t flags;
uint8_t queue_size; /* max queue size configured */
uint8_t queue_len; /* Current number of elements in queue */
uint64_t packets;
} rx;
struct {
uint32_t errors;
uint16_t flags;
uint8_t idle_packets;
uint8_t queue_size; /* max queue size configured */
uint8_t queue_len; /* Current number of elements in queue */
uint64_t packets;
} tx;
} ftdm_channel_iostats_t;
/* 2^8 table size, one for each byte (sample) value */
#define FTDM_GAINS_TABLE_SIZE 256
struct ftdm_channel {

View File

@ -1 +1 @@
Wed Jul 6 15:11:41 CDT 2011
Tue Aug 2 13:51:40 CDT 2011

View File

@ -114,6 +114,29 @@ struct msg_buffer_s {
msg_payload_t *b_chunks; /**< List of body chunks */
};
struct hep_hdr{
uint8_t hp_v; /* version */
uint8_t hp_l; /* length */
uint8_t hp_f; /* family */
uint8_t hp_p; /* protocol */
uint16_t hp_sport; /* source port */
uint16_t hp_dport; /* destination port */
};
struct hep_iphdr{
struct in_addr hp_src;
struct in_addr hp_dst; /* source and dest address */
};
#if SU_HAVE_IN6
struct hep_ip6hdr {
struct in6_addr hp6_src; /* source address */
struct in6_addr hp6_dst; /* destination address */
};
#endif
/** Maximum size when streaming. */
#define MSG_SSIZE_MAX (USIZE_MAX)

View File

@ -301,6 +301,12 @@ TPORT_DLL extern tag_typedef_t tptag_dump;
TPORT_DLL extern tag_typedef_t tptag_dump_ref;
#define TPTAG_DUMP_REF(x) tptag_dump_ref, tag_str_vr(&(x))
TPORT_DLL extern tag_typedef_t tptag_capt;
#define TPTAG_CAPT(x) tptag_capt, tag_str_v((x))
TPORT_DLL extern tag_typedef_t tptag_capt_ref;
#define TPTAG_CAPT_REF(x) tptag_capt_ref, tag_str_vr(&(x))
SOFIA_END_DECLS
#endif /* !defined TPORT_TAG_H */

View File

@ -3555,6 +3555,10 @@ ssize_t tport_vsend(tport_t *self,
if (n > 0 && self->tp_master->mr_dump_file)
tport_dump_iovec(self, msg, n, iov, iovused, "sent", "to");
if (n > 0 && self->tp_master->mr_capt_sock)
tport_capt_msg(self, msg, n, iov, iovused, "sent");
if (tport_log->log_level >= 7) {
size_t i, m = 0;

View File

@ -300,6 +300,9 @@ struct tport_master {
/** FILE to dump received and sent data */
FILE *mr_dump_file;
char *mr_dump; /**< Filename for dumping received/sent data */
/** SOCK to dump received and sent data */
su_socket_t mr_capt_sock;
char *mr_capt_name; /**< Servername for capturing received/sent data */
tport_primary_t *mr_primaries; /**< List of primary contacts */
tport_params_t mr_params[1];
@ -478,6 +481,9 @@ void tport_dump_iovec(tport_t const *self, msg_t *msg,
size_t n, su_iovec_t const iov[], size_t iovused,
char const *what, char const *how);
void tport_capt_msg(tport_t const *self, msg_t *msg, size_t n,
su_iovec_t const iov[], size_t iovused, char const *what);
int tport_tcp_ping(tport_t *self, su_time_t now);
int tport_tcp_pong(tport_t *self);

View File

@ -33,9 +33,11 @@
*/
#include "config.h"
#include "msg_internal.h"
#include "tport_internal.h"
#include <sofia-sip/su.h>
#include <sofia-sip/su_string.h>
#include <stdlib.h>
#include <time.h>
@ -70,6 +72,21 @@ extern char const TPORT_LOG[]; /* dummy declaration for Doxygen */
extern char const TPORT_DUMP[]; /* dummy declaration for Doxygen */
#endif
/**@var TPORT_CAPT
*
* Environment variable for transport data capturing.
*
* The received and sent data is dumped to the capture server specified by TPORT_CAPT
* environment variable. This can be used to save message traces into database and help
* hairy debugging tasks.
*
* @sa TPORT_LOG, TPORT_DEBUG, TPORT_CAPT, tport_log
*/
#ifdef DOXYGEN
extern char const TPORT_CAPT[]; /* dummy declaration for Doxygen */
#endif
/**@var TPORT_DEBUG
*
* Environment variable determining the debug log level for @b tport module.
@ -93,27 +110,136 @@ su_log_t tport_log[] = {
};
/** Initialize logging. */
int tport_open_log(tport_master_t *mr, tagi_t *tags)
{
int n;
int log_msg = mr->mr_log != 0;
char const *dump = NULL;
int n;
char const *capt = NULL;;
if(mr->mr_capt_name) capt = mr->mr_capt_name;
n = tl_gets(tags,
TPTAG_LOG_REF(log_msg),
TPTAG_DUMP_REF(dump),
TPTAG_CAPT_REF(capt),
TAG_END());
if (getenv("MSG_STREAM_LOG") != NULL || getenv("TPORT_LOG") != NULL)
log_msg = 1;
mr->mr_log = log_msg ? MSG_DO_EXTRACT_COPY : 0;
if (getenv("TPORT_CAPT"))
capt = getenv("TPORT_CAPT");
if (getenv("MSG_DUMP"))
dump = getenv("MSG_DUMP");
if (getenv("TPORT_DUMP"))
dump = getenv("TPORT_DUMP");
if(capt) {
char *captname, *p, *host_s;
char port[10];
su_addrinfo_t *ai = NULL, hints[1] = {{ 0 }};
unsigned len =0;
if (mr->mr_capt_name && mr->mr_capt_sock && strcmp(capt, mr->mr_capt_name) == 0)
return n;
captname = su_strdup(mr->mr_home, capt);
if (captname == NULL)
return n;
if(strncmp(captname, "udp:",4) != 0) {
su_log("tport_open_log: capturing. Only udp protocol supported [%s]\n", captname);
return n;
}
/* separate proto and host */
p = captname+4;
if( (*(p)) == '\0') {
su_log("malformed ip address\n");
return n;
}
host_s = p;
if( (p = strrchr(p+1, ':')) == 0 ) {
su_log("no host or port specified\n");
return n;
}
/*the address contains a port number*/
*p = '\0';
p++;
if (atoi(p) <1024 || atoi(p)>65536)
{
su_log("invalid port number; must be in [1024,65536]\n");
return n;
}
memcpy(port, p, sizeof(p));
*p = '\0';
/* check if we have [] */
if (host_s[0] == '[') {
len = strlen(host_s + 1) - 1;
if(host_s[len+1] != ']') {
su_log("bracket not closed\n");
return n;
}
memmove(host_s, host_s + 1, len);
host_s[len] = '\0';
}
/* and again */
captname = su_strdup(mr->mr_home, capt);
if (captname == NULL) return n;
su_free(mr->mr_home, mr->mr_capt_name);
mr->mr_capt_name = captname;
if (mr->mr_capt_sock)
su_close(mr->mr_capt_sock), mr->mr_capt_sock = 0;
/* HINTS && getaddrinfo */
hints->ai_flags = AI_NUMERICSERV;
hints->ai_family = AF_UNSPEC;
hints->ai_socktype = SOCK_DGRAM;
hints->ai_protocol = IPPROTO_UDP;
if (su_getaddrinfo(host_s, port, hints, &ai)) {
su_perror("capture: su_getaddrinfo()");
return n;
}
mr->mr_capt_sock = su_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (mr->mr_capt_sock == INVALID_SOCKET) {
su_perror("capture: invalid socket");
return n;
}
su_setblocking(mr->mr_capt_sock, 0); /* Don't block */
if (connect(mr->mr_capt_sock, ai->ai_addr, (socklen_t)(ai->ai_addrlen)) == -1) {
if (errno != EINPROGRESS) {
su_perror("capture: socket connect");
return n;
}
}
su_freeaddrinfo(ai);
}
else if(mr->mr_capt_sock) {
/* close capture server*/
su_close(mr->mr_capt_sock);
mr->mr_capt_sock = 0;
}
if (dump) {
time_t now;
char *dumpname;
@ -213,6 +339,121 @@ void tport_dump_iovec(tport_t const *self, msg_t *msg,
fflush(mr->mr_dump_file);
}
/** Capture the data from the iovec */
void tport_capt_msg(tport_t const *self, msg_t *msg, size_t n,
su_iovec_t const iov[], size_t iovused, char const *what)
{
int buflen = 0, error;
su_sockaddr_t const *su, *su_self;
struct hep_hdr hep_header;
struct hep_iphdr hep_ipheader = {{0}};
#if SU_HAVE_IN6
struct hep_ip6hdr hep_ip6header = {{{{0}}}};
#endif
int eth_frame_len = 8000;
char* buffer;
size_t i, dst = 0;
tport_master_t *mr;
assert(self); assert(msg);
su = msg_addr(msg);
su_self = self->tp_addr;
mr = self->tp_master;
/* If we don't have socket, go out */
if (!mr->mr_capt_sock) {
su_log("error: capture socket is not open\n");
return;
}
/*buffer for ethernet frame*/
buffer = (void*)malloc(eth_frame_len);
/* VOIP Header */
hep_header.hp_v = 1;
hep_header.hp_f = su->su_family;
/* Header Length */
hep_header.hp_l = sizeof(struct hep_hdr);
/* PROTOCOL */
if(strcmp(self->tp_name->tpn_proto, "tcp") == 0) hep_header.hp_p = IPPROTO_TCP;
else if(strcmp(self->tp_name->tpn_proto, "tls") == 0) hep_header.hp_p = IPPROTO_IDP; /* FAKE*/
else if(strcmp(self->tp_name->tpn_proto, "sctp") == 0) hep_header.hp_p = IPPROTO_SCTP;
else hep_header.hp_p = IPPROTO_UDP; /* DEFAULT UDP */
/* Check destination */
if(strncmp("recv", what, 4) == 0) dst = 1;
/* copy destination and source IPs*/
if(su->su_family == AF_INET) {
memcpy(dst ? &hep_ipheader.hp_dst : &hep_ipheader.hp_src, &su->su_sin.sin_addr.s_addr, sizeof(su->su_sin.sin_addr.s_addr));
memcpy(dst ? &hep_ipheader.hp_src : &hep_ipheader.hp_dst, &su_self->su_sin.sin_addr.s_addr, sizeof(su_self->su_sin.sin_addr.s_addr));
hep_header.hp_l += sizeof(struct hep_iphdr);
}
#if SU_HAVE_IN6
else {
memcpy(dst ? &hep_ip6header.hp6_dst : &hep_ip6header.hp6_src, &su->su_sin.sin_addr.s_addr, sizeof(su->su_sin.sin_addr.s_addr));
memcpy(dst ? &hep_ip6header.hp6_src : &hep_ip6header.hp6_dst, &su_self->su_sin.sin_addr.s_addr, sizeof(su_self->su_sin.sin_addr.s_addr));
hep_header.hp_l += sizeof(struct hep_ip6hdr);
}
#endif
hep_header.hp_dport = dst ? su->su_port : htons(atoi(self->tp_port));
hep_header.hp_sport = dst ? htons(atoi(self->tp_port)) : su->su_port;
/* Copy hepheader */
memset(buffer, '\0', eth_frame_len);
memcpy(buffer, &hep_header, sizeof(struct hep_hdr));
buflen = sizeof(struct hep_hdr);
if(su->su_family == AF_INET) {
memcpy(buffer + buflen, &hep_ipheader, sizeof(struct hep_iphdr));
buflen += sizeof(struct hep_iphdr);
}
#if SU_HAVE_IN6
else if(su->su_family == AF_INET6) {
memcpy(buffer+buflen, &hep_ip6header, sizeof(struct hep_ip6hdr));
buflen += sizeof(struct hep_ip6hdr);
}
#endif
else {
su_perror("error: tport_logging: capture: unsupported protocol family");
goto done;
}
for (i = 0; i < iovused && n > 0; i++) {
size_t len = iov[i].mv_len;
if (len > n)
len = n;
/* if the packet too big for us */
if((buflen + len) > eth_frame_len)
break;
memcpy(buffer + buflen , (void*)iov[i].mv_base, len);
buflen +=len;
n -= len;
}
/* check if we have error i.e. capture server is down */
if ((error = su_soerror(mr->mr_capt_sock))) {
su_perror("error: tport_logging: capture socket error");
goto done;
}
su_send(mr->mr_capt_sock, buffer, buflen, 0);
done:
/* Now we release it */
if(buffer) free(buffer);
return;
}
/** Log the message. */
void tport_log_msg(tport_t *self, msg_t *msg,
char const *what, char const *via,
@ -224,6 +465,7 @@ void tport_log_msg(tport_t *self, msg_t *msg,
size_t linelen = 0, n, logged = 0, truncated = 0;
int skip_lf = 0;
#define MSG_SEPARATOR \
"------------------------------------------------------------------------\n"
#define MAX_LINELEN 2047

View File

@ -453,6 +453,10 @@ static int tport_recv_sigcomp_r(tport_t *self,
if (self->tp_master->mr_dump_file && !self->tp_pri->pri_threadpool)
tport_dump_iovec(self, msg, n, iovec, veclen, "recv", "from");
/* Send the received data to the capture server */
if (self->tp_master->mr_capt_sock && !self->tp_pri->pri_threadpool)
tport_dump_iovec(self, msg, 0);
msg_recv_commit(msg, dlen, eos); /* Mark buffer as used */
}
else {

View File

@ -554,6 +554,19 @@ tag_typedef_t tptag_log = INTTAG_TYPEDEF(log);
*/
tag_typedef_t tptag_dump = STRTAG_TYPEDEF(dump);
/**@def TPTAG_CAPT(x)
*
* URL for capturing unparsed messages from transport.
*
* Use with tport_tcreate(), nta_agent_create(), nua_create(),
* nth_engine_create(), or initial nth_site_create().
*
* @sa #TPORT_CAPT environment variable, TPTAG_LOG().
*
*/
tag_typedef_t tptag_capt = STRTAG_TYPEDEF(capt);
/** Mark transport as trusted.
*
* @note Not implemented by tport module.

View File

@ -260,6 +260,9 @@ int tport_recv_sctp(tport_t *self)
if (self->tp_master->mr_dump_file)
tport_dump_iovec(self, msg, N, iovec, veclen, "recv", "from");
if (self->tp_master->mr_capt_sock)
tport_capt_msg(self, msg, N, iovec, veclen, "recv");
msg_recv_commit(msg, N, 0); /* Mark buffer as used */
return 2;

View File

@ -335,6 +335,10 @@ int tport_recv_stream(tport_t *self)
if (self->tp_master->mr_dump_file)
tport_dump_iovec(self, msg, n, iovec, veclen, "recv", "from");
if (self->tp_master->mr_capt_sock)
tport_capt_msg(self, msg, n, iovec, veclen, "recv");
/* Mark buffer as used */
msg_recv_commit(msg, n, n == 0);

View File

@ -363,6 +363,9 @@ int tport_recv_dgram(tport_t *self)
if (self->tp_master->mr_dump_file)
tport_dump_iovec(self, msg, n, iovec, veclen, "recv", "from");
if (self->tp_master->mr_capt_sock)
tport_capt_msg(self, msg, n, iovec, veclen, "recv");
*sample = *((uint8_t *)iovec[0].mv_base);
/* Commit received data into buffer. This may relocate iovec contents */

View File

@ -1 +1 @@
Sat Jan 5 20:11:10 EST 2008
Tue Aug 2 13:04:55 CDT 2011

View File

@ -194,7 +194,8 @@ SRC += \
$(TOP)/ext/fts1/fts1_hash.h \
$(TOP)/ext/fts1/fts1_porter.c \
$(TOP)/ext/fts1/fts1_tokenizer.h \
$(TOP)/ext/fts1/fts1_tokenizer1.c
$(TOP)/ext/fts1/fts1_tokenizer1.c \
$(TOP)/src/sqliteInt.h
# Source code to the test files.

View File

@ -297,7 +297,7 @@ static inline char *strndup_lite(const char *s, size_t n)
#define sqliteMalloc(x) zmalloc(x)//sqlite3Malloc(x,1)
#define sqliteMallocRaw(x) malloc(x)//sqlite3MallocRaw(x,1)
#define sqliteRealloc(x,y) realloc(x, y)//sqlite3Realloc(x,y)
#define sqliteStrDup(x) (x?strdup(x):NULL)//sqlite3StrDup(x)
#define sqliteStrDup(x) (x?strdup(x):strdup(""))//sqlite3StrDup(x)
#define sqliteStrNDup(x,y) strndup_lite(x,y) //sqlite3StrNDup(x,y)
#define sqliteReallocOrFree(x,y) sqlite3ReallocOrFree(x,y)

View File

@ -2317,17 +2317,25 @@ SWITCH_STANDARD_API(dual_transfer_function)
dest1 = argv[1];
dest2= argv[2];
if ((dp1 = strchr(dest1, '/'))) {
if ((dp1 = strstr(dest1, "/inline")) && *(dp1 + 7) == '\0') {
*dp1++ = '\0';
if ((context1 = strchr(dp1, '/'))) {
*context1++ = '\0';
} else {
if ((dp1 = strchr(dest1, '/'))) {
*dp1++ = '\0';
if ((context1 = strchr(dp1, '/'))) {
*context1++ = '\0';
}
}
}
if ((dp2 = strchr(dest2, '/'))) {
if ((dp2 = strstr(dest1, "/inline")) && *(dp2 + 7) == '\0') {
*dp2++ = '\0';
if ((context2 = strchr(dp2, '/'))) {
*context2++ = '\0';
} else {
if ((dp2 = strchr(dest2, '/'))) {
*dp2++ = '\0';
if ((context2 = strchr(dp2, '/'))) {
*context2++ = '\0';
}
}
}
@ -3302,8 +3310,7 @@ SWITCH_STANDARD_API(break_function)
if (both) {
const char *quuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
if (quuid) {
qsession = switch_core_session_locate(quuid);
if (quuid && (qsession = switch_core_session_locate(quuid))) {
qchannel = switch_core_session_get_channel(qsession);
}
}
@ -3899,7 +3906,7 @@ SWITCH_STANDARD_API(alias_function)
return SWITCH_STATUS_SUCCESS;
}
#define SHOW_SYNTAX "codec|endpoint|application|api|dialplan|file|timer|calls [count]|channels [count|like <match string>]|distinct_channels|aliases|complete|chat|management|modules|nat_map|say|interfaces|interface_types|tasks|limits"
#define SHOW_SYNTAX "codec|endpoint|application|api|dialplan|file|timer|calls [count]|channels [count|like <match string>]|calls|detailed_calls|bridged_calls|detailed_bridged_calls|aliases|complete|chat|management|modules|nat_map|say|interfaces|interface_types|tasks|limits"
SWITCH_STANDARD_API(show_function)
{
char sql[1024];
@ -3988,7 +3995,7 @@ SWITCH_STANDARD_API(show_function)
sprintf(sql, "select name, description, syntax, ikey from interfaces where hostname='%s' and type = '%s' and description != '' order by type,name", hostname, command);
}
} else if (!strcasecmp(command, "calls")) {
sprintf(sql, "select * from calls where hostname='%s' order by call_created_epoch", hostname);
sprintf(sql, "select * from basic_calls where hostname='%s' order by call_created_epoch", hostname);
if (argv[1] && !strcasecmp(argv[1], "count")) {
holder.justcount = 1;
if (argv[3] && !strcasecmp(argv[2], "as")) {
@ -4036,14 +4043,18 @@ SWITCH_STANDARD_API(show_function)
as = argv[3];
}
}
} else if (!strcasecmp(command, "distinct_channels")) {
sprintf(sql, "select * from channels left join calls on "
"channels.uuid=calls.caller_uuid where channels.hostname='%s' and channels.uuid not in (select callee_uuid from calls where hostname='%s') order by created_epoch", hostname, hostname);
} else if (!strcasecmp(command, "detailed_calls")) {
sprintf(sql, "select * from detailed_calls where hostname='%s' order by created_epoch", hostname);
if (argv[2] && !strcasecmp(argv[1], "as")) {
as = argv[2];
}
} else if (!strcasecmp(command, "detailed_calls")) {
sprintf(sql, "select * from detailed_calls where hostname='%s' order by created_epoch", hostname);
} else if (!strcasecmp(command, "bridged_calls")) {
sprintf(sql, "select * from basic_calls where b_uuid is not null and hostname='%s' order by created_epoch", hostname);
if (argv[2] && !strcasecmp(argv[1], "as")) {
as = argv[2];
}
} else if (!strcasecmp(command, "detailed_bridged_calls")) {
sprintf(sql, "select * from detailed_calls where b_uuid is not null and hostname='%s' order by created_epoch", hostname);
if (argv[2] && !strcasecmp(argv[1], "as")) {
as = argv[2];
}
@ -4433,6 +4444,9 @@ SWITCH_STANDARD_API(uuid_fileman_function)
if (switch_ivr_get_file_handle(psession, &fh) == SWITCH_STATUS_SUCCESS) {
switch_ivr_process_fh(psession, cmd, fh);
switch_ivr_release_file_handle(psession, &fh);
stream->write_function(stream, "+OK\n");
} else {
stream->write_function(stream, "-ERR No File Handle!\n");
}
switch_core_session_rwunlock(psession);

View File

@ -5992,7 +5992,7 @@ SWITCH_STANDARD_APP(conference_function)
}
if (pstatus != SWITCH_STATUS_SUCCESS && pstatus != SWITCH_STATUS_BREAK) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot ask the user for a pin, ending call");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot ask the user for a pin, ending call\n");
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}

View File

@ -735,7 +735,9 @@ static void terminate_session(switch_core_session_t **session, int line, switch_
}
switch_mutex_lock(tech_pvt->flag_mutex);
switch_set_flag(tech_pvt, TFLAG_TERM);
if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
switch_set_flag(tech_pvt, TFLAG_TERM);
}
switch_set_flag(tech_pvt, TFLAG_BYE);
switch_clear_flag(tech_pvt, TFLAG_IO);
switch_mutex_unlock(tech_pvt->flag_mutex);

View File

@ -2016,8 +2016,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) {
const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "SEND");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Callee-Name", name);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Callee-Number", number);
switch_channel_set_profile_var(channel, "callee_id_name", name);
switch_channel_set_profile_var(channel, "callee_id_number", number);
if (uuid) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", uuid);
}
@ -3434,6 +3436,17 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
goto done;
}
if (!strcasecmp(argv[1], "capture")) {
if (argc > 2) {
int value = switch_true(argv[2]);
nua_set_params(profile->nua, TPTAG_CAPT(value ? mod_sofia_globals.capture_server : NULL), TAG_END());
stream->write_function(stream, "%s sip capturing on %s", value ? "Enabled" : "Disabled", profile->name);
} else {
stream->write_function(stream, "Usage: sofia profile <name> capture <on/off>\n");
}
goto done;
}
if (!strcasecmp(argv[1], "watchdog")) {
if (argc > 2) {
int value = switch_true(argv[2]);
@ -3995,6 +4008,7 @@ SWITCH_STANDARD_API(sofia_function)
static const char usage_string[] = "USAGE:\n"
"--------------------------------------------------------------------------------\n"
"sofia global siptrace <on|off>\n"
"sofia capture <on|off>\n"
" watchdog <on|off>\n\n"
"sofia profile <name> [start | stop | restart | rescan]\n"
" flush_inbound_reg [<call_id> | <[user]@domain>] [reboot]\n"
@ -4003,6 +4017,7 @@ SWITCH_STANDARD_API(sofia_function)
" killgw <gateway name>\n"
" [stun-auto-disable | stun-enabled] [true | false]]\n"
" siptrace <on|off>\n"
" capture <on|off>\n"
" watchdog <on|off>\n\n"
"sofia <status|xmlstatus> profile <name> [reg <contact str>] | [pres <pres str>] | [user <user@domain>]\n"
"sofia <status|xmlstatus> gateway <name>\n\n"
@ -4062,6 +4077,7 @@ SWITCH_STANDARD_API(sofia_function)
goto done;
} else if (!strcasecmp(argv[0], "global")) {
int ston = -1;
int cton = -1;
int wdon = -1;
if (argc > 1) {
@ -4098,6 +4114,12 @@ SWITCH_STANDARD_API(sofia_function)
}
}
if (!strcasecmp(argv[1], "capture")) {
if (argc > 2) {
cton = switch_true(argv[2]);
}
}
if (!strcasecmp(argv[1], "watchdog")) {
if (argc > 2) {
wdon = switch_true(argv[2]);
@ -4108,11 +4130,14 @@ SWITCH_STANDARD_API(sofia_function)
if (ston != -1) {
sofia_glue_global_siptrace(ston);
stream->write_function(stream, "+OK Global siptrace %s", ston ? "on" : "off");
} else if (cton != -1) {
sofia_glue_global_capture(cton);
stream->write_function(stream, "+OK Global capture %s", cton ? "on" : "off");
} else if (wdon != -1) {
sofia_glue_global_watchdog(wdon);
stream->write_function(stream, "+OK Global watchdog %s", wdon ? "on" : "off");
} else {
stream->write_function(stream, "-ERR Usage: siptrace <on|off>|watchdog <on|off>|debug <sla|presence|none");
stream->write_function(stream, "-ERR Usage: siptrace <on|off>|capture <on|off>|watchdog <on|off>|debug <sla|presence|none");
}
goto done;
@ -5305,6 +5330,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
switch_console_set_complete("add sofia tracelevel ::[console:alert:crit:err:warning:notice:info:debug");
switch_console_set_complete("add sofia global siptrace ::[on:off");
switch_console_set_complete("add sofia global capture ::[on:off");
switch_console_set_complete("add sofia global watchdog ::[on:off");
switch_console_set_complete("add sofia global debug ::[presence:sla:none");
@ -5325,6 +5351,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
switch_console_set_complete("add sofia profile ::sofia::list_profiles killgw ::sofia::list_profile_gateway");
switch_console_set_complete("add sofia profile ::sofia::list_profiles siptrace on");
switch_console_set_complete("add sofia profile ::sofia::list_profiles siptrace off");
switch_console_set_complete("add sofia profile ::sofia::list_profiles capture on");
switch_console_set_complete("add sofia profile ::sofia::list_profiles capture off");
switch_console_set_complete("add sofia profile ::sofia::list_profiles watchdog on");
switch_console_set_complete("add sofia profile ::sofia::list_profiles watchdog off");

View File

@ -257,7 +257,8 @@ typedef enum {
PFLAG_NDLB_TO_IN_200_CONTACT = (1 << 0),
PFLAG_NDLB_BROKEN_AUTH_HASH = (1 << 1),
PFLAG_NDLB_SENDRECV_IN_SESSION = (1 << 2),
PFLAG_NDLB_ALLOW_BAD_IANANAME = (1 << 3)
PFLAG_NDLB_ALLOW_BAD_IANANAME = (1 << 3),
PFLAG_NDLB_ALLOW_NONDUP_SDP = (1 << 4)
} sofia_NDLB_t;
typedef enum {
@ -314,12 +315,13 @@ typedef enum {
TFLAG_NOREPLY,
TFLAG_LIBERAL_DTMF,
TFLAG_GOT_ACK,
TFLAG_CAPTURE,
/* No new flags below this line */
TFLAG_MAX
} TFLAGS;
#define SOFIA_MAX_MSG_QUEUE 51
#define SOFIA_MSG_QUEUE_SIZE 1000
#define SOFIA_MSG_QUEUE_SIZE 5000
struct mod_sofia_globals {
switch_memory_pool_t *pool;
@ -353,6 +355,7 @@ struct mod_sofia_globals {
int auto_restart;
int auto_nat;
int tracelevel;
char *capture_server;
int rewrite_multicasted_fs_path;
};
extern struct mod_sofia_globals mod_sofia_globals;
@ -1114,6 +1117,7 @@ void sofia_glue_tech_simplify(private_object_t *tech_pvt);
switch_console_callback_match_t *sofia_reg_find_reg_url_multi(sofia_profile_t *profile, const char *user, const char *host);
switch_bool_t sofia_glue_profile_exists(const char *key);
void sofia_glue_global_siptrace(switch_bool_t on);
void sofia_glue_global_capture(switch_bool_t on);
void sofia_glue_global_watchdog(switch_bool_t on);
void sofia_glue_proxy_codec(switch_core_session_t *session, const char *r_sdp);
switch_status_t sofia_glue_sdp_map(const char *r_sdp, switch_event_t **fmtp, switch_event_t **pt);

View File

@ -665,7 +665,11 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro
return;
}
if (sip->sip_to) {
number = (char *) switch_channel_get_variable(channel, "callee_id_number");
name = (char *) switch_channel_get_variable(channel, "callee_id_name");
if (zstr(number) && sip->sip_to) {
number = sip->sip_to->a_url->url_user;
}
@ -738,18 +742,6 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro
goto end;
}
if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) {
const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "RECV");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Callee-Name", name);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Callee-Number", number);
if (uuid) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", uuid);
}
switch_channel_event_set_data(channel, event);
switch_event_fire(&event);
}
caller_profile = switch_channel_get_caller_profile(channel);
if (!strcmp(caller_profile->callee_id_name, name) && !strcmp(caller_profile->callee_id_number, number)) {
@ -766,6 +758,17 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro
}
if (send) {
if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) {
const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "RECV");
if (uuid) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", uuid);
}
switch_channel_event_set_data(channel, event);
switch_event_fire(&event);
}
sofia_send_callee_id(session, NULL, NULL);
}
@ -1789,6 +1792,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
NTATAG_SERVER_RPORT(profile->server_rport_level),
NTATAG_CLIENT_RPORT(profile->client_rport_level),
TPTAG_LOG(sofia_test_flag(profile, TFLAG_TPORT_LOG)),
TPTAG_CAPT(sofia_test_flag(profile, TFLAG_CAPTURE) ? mod_sofia_globals.capture_server : NULL),
TAG_IF(sofia_test_pflag(profile, PFLAG_SIPCOMPACT),
NTATAG_SIPFLAGS(MSG_DO_COMPACT)),
TAG_IF(profile->timer_t1, NTATAG_SIP_T1(profile->timer_t1)),
@ -2709,6 +2713,9 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
mod_sofia_globals.rewrite_multicasted_fs_path = SWITCH_FALSE;
}
}
else if (!strcasecmp(var, "capture-server")) {
mod_sofia_globals.capture_server = switch_core_strdup(mod_sofia_globals.pool, val);
}
}
}
@ -2787,6 +2794,13 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
sofia_clear_flag(profile, TFLAG_TPORT_LOG);
}
nua_set_params(profile->nua, TPTAG_LOG(sofia_test_flag(profile, TFLAG_TPORT_LOG)), TAG_END());
} else if (!strcasecmp(var, "sip-capture")) {
if (switch_true(val)) {
sofia_set_flag(profile, TFLAG_CAPTURE);
} else {
sofia_clear_flag(profile, TFLAG_CAPTURE);
}
nua_set_params(profile->nua, TPTAG_CAPT(sofia_test_flag(profile, TFLAG_CAPTURE) ? mod_sofia_globals.capture_server : NULL), TAG_END());
} else if (!strcasecmp(var, "send-message-query-on-register")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER);
@ -2954,6 +2968,12 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
} else {
profile->ndlb &= ~PFLAG_NDLB_ALLOW_BAD_IANANAME;
}
} else if (!strcasecmp(var, "NDLB-allow-nondup-sdp")) {
if (switch_true(val)) {
profile->ndlb |= PFLAG_NDLB_ALLOW_NONDUP_SDP;
} else {
profile->ndlb &= ~PFLAG_NDLB_ALLOW_NONDUP_SDP;
}
} else if (!strcasecmp(var, "aggressive-nat-detection")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION);
@ -3384,6 +3404,9 @@ switch_status_t config_sofia(int reload, char *profile_name)
mod_sofia_globals.rewrite_multicasted_fs_path = SWITCH_FALSE;
}
}
else if (!strcasecmp(var, "capture-server")) {
mod_sofia_globals.capture_server = switch_core_strdup(mod_sofia_globals.pool, val);
}
}
}
@ -3462,6 +3485,7 @@ switch_status_t config_sofia(int reload, char *profile_name)
profile->local_network = "localnet.auto";
sofia_set_flag(profile, TFLAG_ENABLE_SOA);
sofia_set_pflag(profile, PFLAG_CID_IN_1XX);
profile->ndlb |= PFLAG_NDLB_ALLOW_NONDUP_SDP;
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
@ -3475,6 +3499,9 @@ switch_status_t config_sofia(int reload, char *profile_name)
profile->shutdown_type = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "sip-trace") && switch_true(val)) {
sofia_set_flag(profile, TFLAG_TPORT_LOG);
} else if (!strcasecmp(var, "sip-capture") && switch_true(val)) {
sofia_set_flag(profile, TFLAG_CAPTURE);
nua_set_params(profile->nua, TPTAG_CAPT(mod_sofia_globals.capture_server), TAG_END());
} else if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) {
if (switch_odbc_available()) {
profile->odbc_dsn = switch_core_strdup(profile->pool, val);
@ -3952,6 +3979,12 @@ switch_status_t config_sofia(int reload, char *profile_name)
} else {
profile->ndlb &= ~PFLAG_NDLB_ALLOW_BAD_IANANAME;
}
} else if (!strcasecmp(var, "NDLB-allow-nondup-sdp")) {
if (switch_true(val)) {
profile->ndlb |= PFLAG_NDLB_ALLOW_NONDUP_SDP;
} else {
profile->ndlb &= ~PFLAG_NDLB_ALLOW_NONDUP_SDP;
}
} else if (!strcasecmp(var, "pass-rfc2833")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_PASS_RFC2833);
@ -5074,11 +5107,13 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
}
if (session) {
if ((switch_channel_test_flag(channel, CF_EARLY_MEDIA) || switch_channel_test_flag(channel, CF_ANSWERED)) && (status == 180 || status == 183)) {
if ((switch_channel_test_flag(channel, CF_EARLY_MEDIA) || switch_channel_test_flag(channel, CF_ANSWERED)) && (status == 180 || status == 183) && !r_sdp) {
/* Must you send 180 after 183 w/sdp ? sheesh */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Channel %s skipping state [%s][%d]\n",
switch_channel_get_name(channel), nua_callstate_name(ss_state), status);
goto done;
} else if (switch_channel_test_flag(channel, CF_EARLY_MEDIA) && (status == 180 || status == 183) && r_sdp) {
sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE);
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Channel %s entering state [%s][%d]\n",
@ -5088,7 +5123,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
sdp_parser_t *parser;
sdp_session_t *sdp;
if (!zstr(tech_pvt->remote_sdp_str) && !strcmp(tech_pvt->remote_sdp_str, r_sdp)) {
if (!(profile->ndlb & PFLAG_NDLB_ALLOW_NONDUP_SDP) || (!zstr(tech_pvt->remote_sdp_str) && !strcmp(tech_pvt->remote_sdp_str, r_sdp))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Duplicate SDP\n%s\n", r_sdp);
is_dup_sdp = 1;
} else {
@ -5176,7 +5211,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
sofia_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
switch_channel_mark_pre_answered(channel);
sofia_set_flag(tech_pvt, TFLAG_SDP);
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA) || sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
goto done;
}
@ -5597,6 +5632,8 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Processing updated SDP\n");
sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE);
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Error!\n");
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
@ -5804,6 +5841,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
switch_snprintf(st, sizeof(st), "%d", cause);
switch_channel_set_variable(channel, "sip_term_cause", st);
switch_channel_hangup(channel, cause);
ss_state = nua_callstate_terminated;
}

View File

@ -208,6 +208,7 @@ static void generate_m(private_object_t *tech_pvt, char *buf, size_t buflen,
if (!noptime) {
if (!cur_ptime) {
#if 0
if (ptime) {
if (ptime != imp->microseconds_per_packet / 1000) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
@ -225,6 +226,11 @@ static void generate_m(private_object_t *tech_pvt, char *buf, size_t buflen,
} else {
ptime = imp->microseconds_per_packet / 1000;
}
#else
if (!ptime) {
ptime = imp->microseconds_per_packet / 1000;
}
#endif
} else {
if ((imp->microseconds_per_packet / 1000) != cur_ptime) {
continue;
@ -544,7 +550,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
} else if (tech_pvt->num_codecs) {
int i;
int cur_ptime = 0, this_ptime = 0, cng_type = 0;
const char *mult;
if (!sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG) && tech_pvt->cng_pt && use_cng) {
cng_type = tech_pvt->cng_pt;
@ -554,7 +560,9 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
}
}
if (!switch_true(switch_channel_get_variable(tech_pvt->channel, "sdp_m_per_ptime"))) {
mult = switch_channel_get_variable(tech_pvt->channel, "sdp_m_per_ptime");
if (mult && switch_false(mult)) {
char *bp = buf;
if ((!zstr(tech_pvt->local_crypto_key) && sofia_test_flag(tech_pvt, TFLAG_SECURE))) {
@ -1855,7 +1863,12 @@ char *sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix
char *extra_headers = NULL;
switch_stream_handle_t stream = { 0 };
switch_event_header_t *hi = NULL;
const char *exclude_regex = NULL;
switch_regex_t *re = NULL;
int ovector[30] = {0};
int proceed;
exclude_regex = switch_channel_get_variable(channel, "exclude_outgoing_extra_header");
SWITCH_STANDARD_STREAM(stream);
if ((hi = switch_channel_variable_first(channel))) {
for (; hi; hi = hi->next) {
@ -1863,8 +1876,13 @@ char *sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix
char *value = (char *) hi->value;
if (!strncasecmp(name, prefix, strlen(prefix))) {
const char *hname = name + strlen(prefix);
stream.write_function(&stream, "%s: %s\r\n", hname, value);
if ( !exclude_regex || !(proceed = switch_regex_perform(name, exclude_regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
const char *hname = name + strlen(prefix);
stream.write_function(&stream, "%s: %s\r\n", hname, value);
switch_regex_safe_free(re);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Ignoring Extra Header [%s] , matches exclude_outgoing_extra_header [%s]\n", name, exclude_regex);
}
}
}
switch_channel_variable_last(channel);
@ -3031,7 +3049,6 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
flags &= ~SWITCH_RTP_FLAG_BYTESWAP;
}
if (tech_pvt->rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
//const char *ip = switch_channel_get_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE);
//const char *port = switch_channel_get_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE);
@ -3099,7 +3116,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
const char *rport = NULL;
switch_port_t remote_rtcp_port = 0;
sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
if ((rport = switch_channel_get_variable(tech_pvt->channel, "sip_remote_audio_rtcp_port"))) {
remote_rtcp_port = (switch_port_t)atoi(rport);
@ -3580,6 +3597,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
end:
sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
sofia_glue_tech_track(tech_pvt->profile, tech_pvt->session);
@ -5240,6 +5258,27 @@ void sofia_glue_global_siptrace(switch_bool_t on)
}
void sofia_glue_global_capture(switch_bool_t on)
{
switch_hash_index_t *hi;
const void *var;
void *val;
sofia_profile_t *pptr;
switch_mutex_lock(mod_sofia_globals.hash_mutex);
if (mod_sofia_globals.profile_hash) {
for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
switch_hash_this(hi, &var, NULL, &val);
if ((pptr = (sofia_profile_t *) val)) {
nua_set_params(pptr->nua, TPTAG_CAPT(on ? mod_sofia_globals.capture_server : NULL), TAG_END());
}
}
}
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
}
void sofia_glue_global_watchdog(switch_bool_t on)
{
switch_hash_index_t *hi;

View File

@ -1831,8 +1831,17 @@ void sofia_reg_handle_sip_r_register(int status,
const char *new_expires;
uint32_t expi;
if (contact->m_next) {
const char *sipip = profile->extsipip ? profile->extsipip : profile->sipip;
for (; contact && strcasecmp(contact->m_url->url_host, sipip); contact = contact->m_next);
char *full;
for (; contact; contact = contact->m_next) {
if ((full = sip_header_as_string(nh->nh_home, (void *) contact))) {
if (switch_stristr(sofia_private->gateway->register_contact, full)) {
break;
}
su_free(nh->nh_home, full);
}
}
}
if (!contact) {

View File

@ -2606,6 +2606,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_caller_extension_masquerade(switc
SWITCH_DECLARE(void) switch_channel_flip_cid(switch_channel_t *channel)
{
switch_event_t *event;
switch_mutex_lock(channel->profile_mutex);
if (channel->caller_profile->callee_id_name) {
switch_channel_set_variable(channel, "pre_transfer_caller_id_name", channel->caller_profile->caller_id_name);
@ -2620,6 +2622,19 @@ SWITCH_DECLARE(void) switch_channel_flip_cid(switch_channel_t *channel)
channel->caller_profile->callee_id_number = SWITCH_BLANK_STRING;
switch_mutex_unlock(channel->profile_mutex);
if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) {
const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "RECV");
if (uuid) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", uuid);
}
switch_channel_event_set_data(channel, event);
switch_event_fire(&event);
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel->session), SWITCH_LOG_INFO, "%s Flipping CID from \"%s\" <%s> to \"%s\" <%s>\n",
switch_channel_get_name(channel),
switch_str_nil(switch_channel_get_variable(channel, "pre_transfer_caller_id_name")),

View File

@ -503,7 +503,7 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
if (channel) {
const char *val;
switch_codec_t *vid_read_codec = NULL, *read_codec = switch_core_session_get_read_codec(session);
const char *max_forwards = switch_core_session_sprintf(session, "%d", forwardval);
const char *ep, *max_forwards = switch_core_session_sprintf(session, "%d", forwardval);
switch_channel_set_variable(peer_channel, SWITCH_MAX_FORWARDS_VARIABLE, max_forwards);
@ -523,6 +523,9 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
switch_snprintf(tmp, sizeof(tmp), "%s%s", rc, vrc);
switch_channel_set_variable(peer_channel, SWITCH_ORIGINATOR_CODEC_VARIABLE, tmp);
} else if ((ep = switch_channel_get_variable(channel, "ep_codec_string"))) {
printf("SET [%s] [%s]\n", switch_channel_get_name(peer_channel), ep);
switch_channel_set_variable(peer_channel, SWITCH_ORIGINATOR_CODEC_VARIABLE, ep);
}
switch_channel_set_variable(peer_channel, SWITCH_ORIGINATOR_VARIABLE, switch_core_session_get_uuid(session));

View File

@ -1206,28 +1206,20 @@ static void core_event_handler(switch_event_t *event)
const char *uuid = switch_event_get_header(event, "unique-id");
if (uuid) {
new_sql() = switch_mprintf("delete from channels where uuid='%q' and hostname='%q'",
uuid, switch_core_get_switchname());
new_sql() = switch_mprintf("delete from channels where uuid='%q'",
uuid);
new_sql() = switch_mprintf("delete from calls where (caller_uuid='%q' or callee_uuid='%q') and hostname='%q'",
uuid, uuid, switch_core_get_switchname());
new_sql() = switch_mprintf("delete from calls where (caller_uuid='%q' or callee_uuid='%q')",
uuid, uuid);
}
}
break;
case SWITCH_EVENT_CHANNEL_UUID:
{
new_sql() = switch_mprintf("update channels set uuid='%q' where uuid='%q' and hostname='%q';"
"update calls set caller_uuid='%q' where caller_uuid='%q' and hostname='%q';"
"update calls set callee_uuid='%q' where callee_uuid='%q' and hostname='%q'",
new_sql() = switch_mprintf("update channels set uuid='%q' where uuid='%q'",
switch_event_get_header_nil(event, "unique-id"),
switch_event_get_header_nil(event, "old-unique-id"),
switch_core_get_switchname(),
switch_event_get_header_nil(event, "unique-id"),
switch_event_get_header_nil(event, "old-unique-id"),
switch_core_get_switchname(),
switch_event_get_header_nil(event, "unique-id"),
switch_event_get_header_nil(event, "old-unique-id"), switch_core_get_switchname()
switch_event_get_header_nil(event, "old-unique-id")
);
break;
}
@ -1249,26 +1241,26 @@ static void core_event_handler(switch_event_t *event)
new_sql() =
switch_mprintf
("update channels set read_codec='%q',read_rate='%q',read_bit_rate='%q',write_codec='%q',write_rate='%q',write_bit_rate='%q' where uuid='%q' and hostname='%q'",
("update channels set read_codec='%q',read_rate='%q',read_bit_rate='%q',write_codec='%q',write_rate='%q',write_bit_rate='%q' where uuid='%q'",
switch_event_get_header_nil(event, "channel-read-codec-name"),
switch_event_get_header_nil(event, "channel-read-codec-rate"),
switch_event_get_header_nil(event, "channel-read-codec-bit-rate"),
switch_event_get_header_nil(event, "channel-write-codec-name"),
switch_event_get_header_nil(event, "channel-write-codec-rate"),
switch_event_get_header_nil(event, "channel-write-codec-bit-rate"),
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
switch_event_get_header_nil(event, "unique-id"));
break;
case SWITCH_EVENT_CHANNEL_HOLD:
case SWITCH_EVENT_CHANNEL_UNHOLD:
case SWITCH_EVENT_CHANNEL_EXECUTE: {
new_sql() = switch_mprintf("update channels set application='%q',application_data='%q',"
"presence_id='%q',presence_data='%q' where uuid='%q' and hostname='%q'",
"presence_id='%q',presence_data='%q' where uuid='%q'",
switch_event_get_header_nil(event, "application"),
switch_event_get_header_nil(event, "application-data"),
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname()
switch_event_get_header_nil(event, "unique-id")
);
}
@ -1278,20 +1270,20 @@ static void core_event_handler(switch_event_t *event)
{
if ((extra_cols = parse_presence_data_cols(event))) {
new_sql() = switch_mprintf("update channels set "
"presence_id='%q',presence_data='%q', call_uuid='%q',%s where uuid='%q' and hostname='%q'",
"presence_id='%q',presence_data='%q', call_uuid='%q',%s where uuid='%q'",
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
switch_event_get_header_nil(event, "channel-call-uuid"),
extra_cols,
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
switch_event_get_header_nil(event, "unique-id"));
free(extra_cols);
} else {
new_sql() = switch_mprintf("update channels set "
"presence_id='%q',presence_data='%q', call_uuid='%q' where uuid='%q' and hostname='%q'",
"presence_id='%q',presence_data='%q', call_uuid='%q' where uuid='%q'",
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
switch_event_get_header_nil(event, "channel-call-uuid"),
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
switch_event_get_header_nil(event, "unique-id"));
}
}
@ -1299,44 +1291,15 @@ static void core_event_handler(switch_event_t *event)
break;
case SWITCH_EVENT_CALL_UPDATE:
{
const char *name = NULL, *number = NULL, *direction;
int recv = 0;
direction = switch_event_get_header(event, "direction");
if (direction && strcasecmp(direction, "send")) {
recv = 1;
name = switch_event_get_header(event, "callee-name");
number = switch_event_get_header(event, "callee-number");
}
if (!name) {
name = switch_event_get_header(event, "caller-callee-id-name");
}
if (!number) {
number = switch_event_get_header(event, "caller-callee-id-number");
}
if (!zstr(name) && !zstr(number)) {
new_sql() = switch_mprintf("update channels set state='%s',callstate='%s',callee_name='%q',"
"callee_num='%q',callee_direction='%q' where uuid='%s' and hostname='%q'",
switch_event_get_header_nil(event, "channel-state"),
switch_event_get_header_nil(event, "channel-call-state"),
switch_str_nil(name),
switch_str_nil(number),
switch_event_get_header_nil(event, "direction"),
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
name = switch_event_get_header(event, "callee-name");
number = switch_event_get_header(event, "callee-number");
if (name && number && recv) {
new_sql() = switch_mprintf("update calls set callee_cid_name='%q',callee_cid_num='%q' where caller_uuid='%q'",
name, number, switch_event_get_header_nil(event, "unique-id"));
}
}
new_sql() = switch_mprintf("update channels set callee_name='%q',callee_num='%q',callee_direction='%q',"
"cid_name='%q',cid_num='%q' where uuid='%s'",
switch_event_get_header_nil(event, "caller-callee-id-name"),
switch_event_get_header_nil(event, "caller-callee-id-number"),
switch_event_get_header_nil(event, "direction"),
switch_event_get_header_nil(event, "caller-caller-id-name"),
switch_event_get_header_nil(event, "caller-caller-id-number"),
switch_event_get_header_nil(event, "unique-id")
);
}
break;
case SWITCH_EVENT_CHANNEL_CALLSTATE:
@ -1349,9 +1312,9 @@ static void core_event_handler(switch_event_t *event)
}
if (callstate != CCS_DOWN && callstate != CCS_HANGUP) {
new_sql() = switch_mprintf("update channels set callstate='%q' where uuid='%q' and hostname='%q'",
new_sql() = switch_mprintf("update channels set callstate='%q' where uuid='%q'",
switch_event_get_header_nil(event, "channel-call-state"),
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
switch_event_get_header_nil(event, "unique-id"));
}
}
@ -1373,12 +1336,14 @@ static void core_event_handler(switch_event_t *event)
break;
case CS_ROUTING:
if ((extra_cols = parse_presence_data_cols(event))) {
new_sql() = switch_mprintf("update channels set state='%s',cid_name='%q',cid_num='%q',"
new_sql() = switch_mprintf("update channels set state='%s',cid_name='%q',cid_num='%q',callee_name='%q',callee_num='%q',"
"ip_addr='%s',dest='%q',dialplan='%q',context='%q',presence_id='%q',presence_data='%q',%s "
"where uuid='%s' and hostname='%q'",
"where uuid='%s'",
switch_event_get_header_nil(event, "channel-state"),
switch_event_get_header_nil(event, "caller-caller-id-name"),
switch_event_get_header_nil(event, "caller-caller-id-number"),
switch_event_get_header_nil(event, "caller-callee-id-name"),
switch_event_get_header_nil(event, "caller-callee-id-number"),
switch_event_get_header_nil(event, "caller-network-addr"),
switch_event_get_header_nil(event, "caller-destination-number"),
switch_event_get_header_nil(event, "caller-dialplan"),
@ -1386,28 +1351,30 @@ static void core_event_handler(switch_event_t *event)
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
extra_cols,
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
switch_event_get_header_nil(event, "unique-id"));
free(extra_cols);
} else {
new_sql() = switch_mprintf("update channels set state='%s',cid_name='%q',cid_num='%q',"
new_sql() = switch_mprintf("update channels set state='%s',cid_name='%q',cid_num='%q',callee_name='%q',callee_num='%q',"
"ip_addr='%s',dest='%q',dialplan='%q',context='%q',presence_id='%q',presence_data='%q' "
"where uuid='%s' and hostname='%q'",
"where uuid='%s'",
switch_event_get_header_nil(event, "channel-state"),
switch_event_get_header_nil(event, "caller-caller-id-name"),
switch_event_get_header_nil(event, "caller-caller-id-number"),
switch_event_get_header_nil(event, "caller-callee-id-name"),
switch_event_get_header_nil(event, "caller-callee-id-number"),
switch_event_get_header_nil(event, "caller-network-addr"),
switch_event_get_header_nil(event, "caller-destination-number"),
switch_event_get_header_nil(event, "caller-dialplan"),
switch_event_get_header_nil(event, "caller-context"),
switch_event_get_header_nil(event, "channel-presence-id"),
switch_event_get_header_nil(event, "channel-presence-data"),
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
switch_event_get_header_nil(event, "unique-id"));
}
break;
default:
new_sql() = switch_mprintf("update channels set state='%s' where uuid='%s' and hostname='%q'",
new_sql() = switch_mprintf("update channels set state='%s' where uuid='%s'",
switch_event_get_header_nil(event, "channel-state"),
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
switch_event_get_header_nil(event, "unique-id"));
break;
}
@ -1417,60 +1384,19 @@ static void core_event_handler(switch_event_t *event)
}
case SWITCH_EVENT_CHANNEL_BRIDGE:
{
const char *callee_cid_name, *callee_cid_num, *direction;
char *func_name;
char *aleg_uuid, *bleg_uuid;
direction = switch_event_get_header(event, "other-leg-direction");
if (direction && !strcasecmp(direction, "outbound")) {
callee_cid_name = switch_event_get_header_nil(event, "Other-Leg-callee-id-name");
callee_cid_num = switch_event_get_header_nil(event, "Other-Leg-callee-id-number");
} else {
callee_cid_name = switch_event_get_header_nil(event, "Other-Leg-caller-id-name");
callee_cid_num = switch_event_get_header_nil(event, "Other-Leg-caller-id-number");
}
new_sql() = switch_mprintf("update channels set call_uuid='%q' where uuid='%s' and hostname='%q'",
new_sql() = switch_mprintf("update channels set call_uuid='%q' where uuid='%s'",
switch_event_get_header_nil(event, "channel-call-uuid"),
switch_event_get_header_nil(event, "unique-id"), switch_core_get_switchname());
switch_event_get_header_nil(event, "unique-id"));
if (runtime.odbc_dbtype == DBTYPE_DEFAULT) {
func_name = "function";
}
else {
func_name = "call_function";
}
aleg_uuid = switch_event_get_header_nil(event, "caller-unique-id");
bleg_uuid = switch_event_get_header_nil(event, "Other-Leg-unique-id");
new_sql() = switch_mprintf("update channels set originatee='%s' where uuid='%s'", bleg_uuid, aleg_uuid);
new_sql() = switch_mprintf("update channels set originator='%s' where uuid='%s'", aleg_uuid, bleg_uuid);
new_sql() = switch_mprintf("insert into calls (call_uuid,call_created,call_created_epoch,%s,caller_cid_name,"
"caller_cid_num,caller_dest_num,caller_chan_name,caller_uuid,callee_cid_name,"
"callee_cid_num,callee_dest_num,callee_chan_name,callee_uuid,hostname) "
"values ('%s', '%s', '%ld', '%s','%q','%q','%q','%q','%s','%q','%q','%q','%q','%s','%q')",
func_name,
new_sql() = switch_mprintf("insert into calls (call_uuid,call_created,call_created_epoch,"
"caller_uuid,callee_uuid,hostname) "
"values ('%s','%s','%ld','%q','%q','%q')",
switch_event_get_header_nil(event, "channel-call-uuid"),
switch_event_get_header_nil(event, "event-date-local"),
(long) switch_epoch_time_now(NULL),
switch_event_get_header_nil(event, "event-calling-function"),
switch_event_get_header_nil(event, "caller-caller-id-name"),
switch_event_get_header_nil(event, "caller-caller-id-number"),
switch_event_get_header_nil(event, "caller-destination-number"),
switch_event_get_header_nil(event, "caller-channel-name"),
aleg_uuid,
callee_cid_name,
callee_cid_num,
switch_event_get_header_nil(event, "Other-Leg-destination-number"),
switch_event_get_header_nil(event, "Other-Leg-channel-name"),
bleg_uuid,
switch_event_get_header_nil(event, "caller-unique-id"),
switch_event_get_header_nil(event, "Other-Leg-unique-id"),
switch_core_get_switchname()
);
}
@ -1479,12 +1405,8 @@ static void core_event_handler(switch_event_t *event)
{
char *uuid = switch_event_get_header_nil(event, "caller-unique-id");
new_sql() = switch_mprintf("delete from calls where (caller_uuid='%q' or callee_uuid='%q') and hostname='%q'",
uuid, uuid, switch_core_get_switchname());
new_sql() = switch_mprintf("update channels set originator=null,originatee=null where uuid='%s' or originator='%s' or originatee='%s'",
uuid, uuid, uuid);
new_sql() = switch_mprintf("delete from calls where (caller_uuid='%q' or callee_uuid='%q')",
uuid, uuid);
break;
}
case SWITCH_EVENT_SHUTDOWN:
@ -1531,8 +1453,8 @@ static void core_event_handler(switch_event_t *event)
if (zstr(type)) {
break;
}
new_sql() = switch_mprintf("update channels set secure='%s' where uuid='%s' and hostname='%q'",
type, switch_event_get_header_nil(event, "caller-unique-id"), switch_core_get_switchname()
new_sql() = switch_mprintf("update channels set secure='%s' where uuid='%s'",
type, switch_event_get_header_nil(event, "caller-unique-id")
);
break;
}
@ -1632,35 +1554,22 @@ static char create_channels_sql[] =
" callee_name VARCHAR(1024),\n"
" callee_num VARCHAR(256),\n"
" callee_direction VARCHAR(5),\n"
" call_uuid VARCHAR(256),\n"
" originator VARCHAR(256),\n"
" originatee VARCHAR(256)\n"
" call_uuid VARCHAR(256)\n"
");\n"
"create index ch_hn_index on channels (hostname);\n"
"create index chidx1 on channels (hostname);\n"
"create index uuindex on channels (uuid);\n"
"create index uuindex2 on channels (call_uuid);\n"
"create index uuindex3 on channels (originator);\n"
"create index uuindex4 on channels (originatee);\n";
"create index uuindex2 on channels (call_uuid);\n";
static char create_calls_sql[] =
"CREATE TABLE calls (\n"
" call_uuid VARCHAR(255),\n"
" call_created VARCHAR(128),\n"
" call_created_epoch INTEGER,\n"
" function VARCHAR(1024),\n"
" caller_cid_name VARCHAR(1024),\n"
" caller_cid_num VARCHAR(256),\n"
" caller_dest_num VARCHAR(256),\n"
" caller_chan_name VARCHAR(1024),\n"
" caller_uuid VARCHAR(256),\n"
" callee_cid_name VARCHAR(1024),\n"
" callee_cid_num VARCHAR(256),\n"
" callee_dest_num VARCHAR(256),\n"
" callee_chan_name VARCHAR(1024),\n"
" callee_uuid VARCHAR(256),\n"
" hostname VARCHAR(256)\n"
");\n"
"create index ca_hn_index on calls (hostname);\n"
"create index callsidx1 on calls (hostname);\n"
"create index eruuindex on calls (caller_uuid);\n"
"create index eeuuindex on calls (callee_uuid);\n"
"create index eeuuindex2 on calls (call_uuid);\n";
@ -1709,67 +1618,119 @@ static char create_registrations_sql[] =
"create index regindex1 on registrations (reg_user,realm,hostname);\n";
static char view_sql[] =
static char detailed_calls_sql[] =
"create view detailed_calls as select "
"a.uuid uuid,\n"
"a.direction direction,\n"
"a.created created,\n"
"a.created_epoch created_epoch,\n"
"a.name name,\n"
"a.state state,\n"
"a.cid_name cid_name,\n"
"a.cid_num cid_num,\n"
"a.ip_addr ip_addr,\n"
"a.dest dest,\n"
"a.application application,\n"
"a.application_data application_data,\n"
"a.dialplan dialplan,\n"
"a.context context,\n"
"a.read_codec read_codec,\n"
"a.read_rate read_rate,\n"
"a.read_bit_rate read_bit_rate,\n"
"a.write_codec write_codec,\n"
"a.write_rate write_rate,\n"
"a.write_bit_rate write_bit_rate,\n"
"a.secure secure,\n"
"a.hostname hostname,\n"
"a.presence_id presence_id,\n"
"a.presence_data presence_data,\n"
"a.callstate callstate,\n"
"a.callee_name callee_name,\n"
"a.callee_num callee_num,\n"
"a.callee_direction callee_direction,\n"
"a.call_uuid call_uuid,\n"
"b.uuid b_uuid,\n"
"b.direction b_direction,\n"
"b.created b_created,\n"
"b.created_epoch b_created_epoch,\n"
"b.name b_name,\n"
"b.state b_state,\n"
"b.cid_name b_cid_name,\n"
"b.cid_num b_cid_num,\n"
"b.ip_addr b_ip_addr,\n"
"b.dest b_dest,\n"
"b.application b_application,\n"
"b.application_data b_application_data,\n"
"b.dialplan b_dialplan,\n"
"b.context b_context,\n"
"b.read_codec b_read_codec,\n"
"b.read_rate b_read_rate,\n"
"b.read_bit_rate b_read_bit_rate,\n"
"b.write_codec b_write_codec,\n"
"b.write_rate b_write_rate,\n"
"b.write_bit_rate b_write_bit_rate,\n"
"b.secure b_secure,\n"
"b.hostname b_hostname,\n"
"b.presence_id b_presence_id,\n"
"b.presence_data b_presence_data,\n"
"b.callstate b_callstate,\n"
"b.callee_name b_callee_name,\n"
"b.callee_num b_callee_num,\n"
"b.callee_direction b_callee_direction,\n"
"b.call_uuid b_call_uuid\n"
"from channels a left join channels b on a.originatee = b.uuid where a.originator is null";
"a.uuid as uuid,"
"a.direction as direction,"
"a.created as created,"
"a.created_epoch as created_epoch,"
"a.name as name,"
"a.state as state,"
"a.cid_name as cid_name,"
"a.cid_num as cid_num,"
"a.ip_addr as ip_addr,"
"a.dest as dest,"
"a.application as application,"
"a.application_data as application_data,"
"a.dialplan as dialplan,"
"a.context as context,"
"a.read_codec as read_codec,"
"a.read_rate as read_rate,"
"a.read_bit_rate as read_bit_rate,"
"a.write_codec as write_codec,"
"a.write_rate as write_rate,"
"a.write_bit_rate as write_bit_rate,"
"a.secure as secure,"
"a.hostname as hostname,"
"a.presence_id as presence_id,"
"a.presence_data as presence_data,"
"a.callstate as callstate,"
"a.callee_name as callee_name,"
"a.callee_num as callee_num,"
"a.callee_direction as callee_direction,"
"a.call_uuid as call_uuid,"
"b.uuid as b_uuid,"
"b.direction as b_direction,"
"b.created as b_created,"
"b.created_epoch as b_created_epoch,"
"b.name as b_name,"
"b.state as b_state,"
"b.cid_name as b_cid_name,"
"b.cid_num as b_cid_num,"
"b.ip_addr as b_ip_addr,"
"b.dest as b_dest,"
"b.application as b_application,"
"b.application_data as b_application_data,"
"b.dialplan as b_dialplan,"
"b.context as b_context,"
"b.read_codec as b_read_codec,"
"b.read_rate as b_read_rate,"
"b.read_bit_rate as b_read_bit_rate,"
"b.write_codec as b_write_codec,"
"b.write_rate as b_write_rate,"
"b.write_bit_rate as b_write_bit_rate,"
"b.secure as b_secure,"
"b.hostname as b_hostname,"
"b.presence_id as b_presence_id,"
"b.presence_data as b_presence_data,"
"b.callstate as b_callstate,"
"b.callee_name as b_callee_name,"
"b.callee_num as b_callee_num,"
"b.callee_direction as b_callee_direction,"
"b.call_uuid as b_call_uuid,"
"c.call_created_epoch as call_created_epoch "
"from channels a "
"left join calls c on a.uuid = c.caller_uuid and a.hostname = c.hostname "
"left join channels b on b.uuid = c.callee_uuid and b.hostname = c.hostname "
"where a.uuid = c.caller_uuid or a.uuid not in (select callee_uuid from calls)";
static char basic_calls_sql[] =
"create view basic_calls as select "
"a.uuid as uuid,"
"a.direction as direction,"
"a.created as created,"
"a.created_epoch as created_epoch,"
"a.name as name,"
"a.state as state,"
"a.cid_name as cid_name,"
"a.cid_num as cid_num,"
"a.ip_addr as ip_addr,"
"a.dest as dest,"
"a.presence_id as presence_id,"
"a.presence_data as presence_data,"
"a.callstate as callstate,"
"a.callee_name as callee_name,"
"a.callee_num as callee_num,"
"a.callee_direction as callee_direction,"
"a.call_uuid as call_uuid,"
"a.hostname as hostname,"
"b.uuid as b_uuid,"
"b.direction as b_direction,"
"b.created as b_created,"
"b.created_epoch as b_created_epoch,"
"b.name as b_name,"
"b.state as b_state,"
"b.cid_name as b_cid_name,"
"b.cid_num as b_cid_num,"
"b.ip_addr as b_ip_addr,"
"b.dest as b_dest,"
"b.presence_id as b_presence_id,"
"b.presence_data as b_presence_data,"
"b.callstate as b_callstate,"
"b.callee_name as b_callee_name,"
"b.callee_num as b_callee_num,"
"b.callee_direction as b_callee_direction,"
"c.call_created_epoch as call_created_epoch "
"from channels a "
"left join calls c on a.uuid = c.caller_uuid and a.hostname = c.hostname "
"left join channels b on b.uuid = c.callee_uuid and b.hostname = c.hostname "
"where a.uuid = c.caller_uuid or a.uuid not in (select callee_uuid from calls)";
SWITCH_DECLARE(switch_status_t) switch_core_add_registration(const char *user, const char *realm, const char *token, const char *url, uint32_t expires,
@ -1911,8 +1872,9 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
case SCDB_TYPE_CORE_DB:
{
switch_cache_db_execute_sql(dbh, "drop table channels", NULL);
switch_cache_db_execute_sql(dbh, "drop view detailed_calls", NULL);
switch_cache_db_execute_sql(dbh, "drop table calls", NULL);
switch_cache_db_execute_sql(dbh, "drop view detailed_calls", NULL);
switch_cache_db_execute_sql(dbh, "drop view basic_calls", NULL);
switch_cache_db_execute_sql(dbh, "drop table interfaces", NULL);
switch_cache_db_execute_sql(dbh, "drop table tasks", NULL);
switch_cache_db_execute_sql(dbh, "PRAGMA synchronous=OFF;", NULL);
@ -1937,8 +1899,8 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
{
char *err;
switch_cache_db_test_reactive(dbh, "select call_uuid, read_bit_rate from channels", "DROP TABLE channels", create_channels_sql);
switch_cache_db_test_reactive(dbh, "select * from detailed_calls", NULL, view_sql);
switch_cache_db_test_reactive(dbh, "select * from detailed_calls", "DROP VIEW detailed_calls", detailed_calls_sql);
switch_cache_db_test_reactive(dbh, "select * from basic_calls", "DROP VIEW basic_call", basic_calls_sql);
if (runtime.odbc_dbtype == DBTYPE_DEFAULT) {
switch_cache_db_test_reactive(dbh, "select call_uuid from calls", "DROP TABLE calls", create_calls_sql);
} else {
@ -1971,11 +1933,11 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
case SCDB_TYPE_CORE_DB:
{
switch_cache_db_execute_sql(dbh, create_channels_sql, NULL);
switch_cache_db_execute_sql(dbh, view_sql, NULL);
switch_cache_db_execute_sql(dbh, create_calls_sql, NULL);
switch_cache_db_execute_sql(dbh, create_interfaces_sql, NULL);
switch_cache_db_execute_sql(dbh, create_tasks_sql, NULL);
switch_cache_db_execute_sql(dbh, detailed_calls_sql, NULL);
switch_cache_db_execute_sql(dbh, basic_calls_sql, NULL);
}
break;
}

View File

@ -1148,7 +1148,8 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_s
}
if (switch_socket_bind(new_sock, rtp_session->local_addr) != SWITCH_STATUS_SUCCESS) {
*err = "Bind Error!";
char *em = switch_core_sprintf(rtp_session->pool, "Bind Error! %s:%d", host, port);
*err = em;
goto done;
}