mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-16 00:04:13 +00:00
indent pass 2
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8689 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
9bbcabbbdd
commit
f930eaeec7
101 files changed
+31644
-31458
No files matched your search
@@ -139,8 +139,8 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_timer_name, globals.timer_name);
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_device_name, globals.device_name);
|
||||
|
||||
#define is_master(t) switch_test_flag(t, TFLAG_MASTER)
|
||||
static void add_pvt(private_t * tech_pvt, int master);
|
||||
static void remove_pvt(private_t * tech_pvt);
|
||||
static void add_pvt(private_t *tech_pvt, int master);
|
||||
static void remove_pvt(private_t *tech_pvt);
|
||||
static switch_status_t channel_on_init(switch_core_session_t *session);
|
||||
static switch_status_t channel_on_hangup(switch_core_session_t *session);
|
||||
static switch_status_t channel_on_routing(switch_core_session_t *session);
|
||||
@@ -356,7 +356,7 @@ static void deactivate_audio_device(void)
|
||||
|
||||
|
||||
|
||||
static void add_pvt(private_t * tech_pvt, int master)
|
||||
static void add_pvt(private_t *tech_pvt, int master)
|
||||
{
|
||||
private_t *tp;
|
||||
uint8_t in_list = 0;
|
||||
@@ -399,7 +399,7 @@ static void add_pvt(private_t * tech_pvt, int master)
|
||||
switch_mutex_unlock(globals.pvt_lock);
|
||||
}
|
||||
|
||||
static void remove_pvt(private_t * tech_pvt)
|
||||
static void remove_pvt(private_t *tech_pvt)
|
||||
{
|
||||
private_t *tp, *last = NULL;
|
||||
|
||||
@@ -562,8 +562,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
tech_pvt->hold_file,
|
||||
globals.read_codec.implementation->number_of_channels,
|
||||
globals.read_codec.implementation->actual_samples_per_second,
|
||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
|
||||
NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_core_codec_destroy(&tech_pvt->write_codec);
|
||||
tech_pvt->hold_file = NULL;
|
||||
goto cng;
|
||||
@@ -578,12 +577,12 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
|
||||
goto hold;
|
||||
}
|
||||
cng:
|
||||
cng:
|
||||
switch_yield(globals.read_codec.implementation->microseconds_per_frame);
|
||||
*frame = &globals.cng_frame;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
hold:
|
||||
hold:
|
||||
|
||||
{
|
||||
switch_size_t olen = globals.read_codec.implementation->samples_per_frame;
|
||||
@@ -612,7 +611,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
}
|
||||
|
||||
switch_mutex_lock(globals.device_lock);
|
||||
if ((samples = snd_pcm_readi (globals.audio_stream_in, globals.read_frame.data, globals.read_codec.implementation->samples_per_frame)) > 0) {
|
||||
if ((samples = snd_pcm_readi(globals.audio_stream_in, globals.read_frame.data, globals.read_codec.implementation->samples_per_frame)) > 0) {
|
||||
globals.read_frame.datalen = samples * 2;
|
||||
globals.read_frame.samples = samples;
|
||||
|
||||
@@ -887,7 +886,7 @@ static switch_status_t load_config(void)
|
||||
globals.codec_ms = tmp;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"codec-ms must be multipe of 10 and less than %d, Using default of 20\n", SWITCH_MAX_INTERVAL);
|
||||
"codec-ms must be multipe of 10 and less than %d, Using default of 20\n", SWITCH_MAX_INTERVAL);
|
||||
}
|
||||
} else if (!strcmp(var, "dialplan")) {
|
||||
set_global_dialplan(val);
|
||||
@@ -951,18 +950,18 @@ static switch_status_t engage_device(unsigned int sample_rate, int codec_ms)
|
||||
int err = 0;
|
||||
snd_pcm_hw_params_t *hw_params = NULL;
|
||||
char *device = globals.device_name;
|
||||
|
||||
|
||||
if (globals.audio_stream_in && globals.audio_stream_out) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
if (globals.audio_stream_in) {
|
||||
snd_pcm_close (globals.audio_stream_in);
|
||||
snd_pcm_close(globals.audio_stream_in);
|
||||
globals.audio_stream_in = NULL;
|
||||
}
|
||||
|
||||
if (globals.audio_stream_out) {
|
||||
snd_pcm_close (globals.audio_stream_out);
|
||||
snd_pcm_close(globals.audio_stream_out);
|
||||
globals.audio_stream_out = NULL;
|
||||
}
|
||||
|
||||
@@ -976,33 +975,30 @@ static switch_status_t engage_device(unsigned int sample_rate, int codec_ms)
|
||||
|
||||
if (switch_core_codec_init(&globals.read_codec,
|
||||
"L16",
|
||||
NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
|
||||
NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
} else {
|
||||
if (switch_core_codec_init(&globals.write_codec,
|
||||
"L16",
|
||||
NULL,
|
||||
sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
|
||||
NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
||||
switch_core_codec_destroy(&globals.read_codec);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (switch_core_timer_init(&globals.timer,
|
||||
globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_frame,
|
||||
module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_frame, module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
|
||||
switch_core_codec_destroy(&globals.read_codec);
|
||||
switch_core_codec_destroy(&globals.write_codec);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
globals.read_frame.rate = sample_rate;
|
||||
globals.read_frame.codec = &globals.read_codec;
|
||||
|
||||
@@ -1011,176 +1007,152 @@ static switch_status_t engage_device(unsigned int sample_rate, int codec_ms)
|
||||
switch_mutex_lock(globals.device_lock);
|
||||
/* LOCKED ************************************************************************************************** */
|
||||
|
||||
|
||||
if ((err = snd_pcm_open (&globals.audio_stream_out, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot open audio device %s (%s)\n",
|
||||
device,
|
||||
snd_strerror (err));
|
||||
|
||||
if ((err = snd_pcm_open(&globals.audio_stream_out, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot open audio device %s (%s)\n", device, snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_malloc (&hw_params)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot allocate hardware parameter structure (%s)\n",
|
||||
snd_strerror (err));
|
||||
if ((err = snd_pcm_hw_params_malloc(&hw_params)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot allocate hardware parameter structure (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_any (globals.audio_stream_out, hw_params)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot initialize hardware parameter structure (%s)\n",
|
||||
snd_strerror (err));
|
||||
|
||||
if ((err = snd_pcm_hw_params_any(globals.audio_stream_out, hw_params)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot initialize hardware parameter structure (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_access (globals.audio_stream_out, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set access type (%s)\n",
|
||||
snd_strerror (err));
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_access(globals.audio_stream_out, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set access type (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_format (globals.audio_stream_out, hw_params, SND_PCM_FORMAT_S16_LE)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set sample format (%s)\n",
|
||||
snd_strerror (err));
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_format(globals.audio_stream_out, hw_params, SND_PCM_FORMAT_S16_LE)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set sample format (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_rate_near (globals.audio_stream_out, hw_params, &sample_rate, 0)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set sample rate (%s)\n",
|
||||
snd_strerror (err));
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_rate_near(globals.audio_stream_out, hw_params, &sample_rate, 0)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set sample rate (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_channels (globals.audio_stream_out, hw_params, 1)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set channel count (%s)\n",
|
||||
snd_strerror (err));
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_channels(globals.audio_stream_out, hw_params, 1)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set channel count (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params (globals.audio_stream_out, hw_params)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set parameters (%s)\n",
|
||||
snd_strerror (err));
|
||||
|
||||
if ((err = snd_pcm_hw_params(globals.audio_stream_out, hw_params)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set parameters (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
snd_pcm_hw_params_free (hw_params);
|
||||
|
||||
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
hw_params = NULL;
|
||||
|
||||
|
||||
if ((err = snd_pcm_open (&globals.audio_stream_in, device, SND_PCM_STREAM_CAPTURE, 0)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot open audio device %s (%s)\n",
|
||||
device,
|
||||
snd_strerror (err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_malloc (&hw_params)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot allocate hardware parameter structure (%s)\n",
|
||||
snd_strerror (err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_any (globals.audio_stream_in, hw_params)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot initialize hardware parameter structure (%s)\n",
|
||||
snd_strerror (err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_access (globals.audio_stream_in, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set access type (%s)\n",
|
||||
snd_strerror (err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_format (globals.audio_stream_in, hw_params, SND_PCM_FORMAT_S16_LE)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set sample format (%s)\n",
|
||||
snd_strerror (err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_rate_near (globals.audio_stream_in, hw_params, &sample_rate, 0)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set sample rate (%s)\n",
|
||||
snd_strerror (err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_channels (globals.audio_stream_in, hw_params, 1)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set channel count (%s)\n",
|
||||
snd_strerror (err));
|
||||
if ((err = snd_pcm_open(&globals.audio_stream_in, device, SND_PCM_STREAM_CAPTURE, 0)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot open audio device %s (%s)\n", device, snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_period_time (globals.audio_stream_in, hw_params, globals.read_codec.implementation->microseconds_per_frame, 0)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set period time (%s)\n",
|
||||
snd_strerror (err));
|
||||
if ((err = snd_pcm_hw_params_malloc(&hw_params)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot allocate hardware parameter structure (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_period_size (globals.audio_stream_in, hw_params, globals.read_codec.implementation->samples_per_frame, 0)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set period size (%s)\n",
|
||||
snd_strerror (err));
|
||||
if ((err = snd_pcm_hw_params_any(globals.audio_stream_in, hw_params)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot initialize hardware parameter structure (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params (globals.audio_stream_in, hw_params)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set parameters (%s)\n",
|
||||
snd_strerror (err));
|
||||
if ((err = snd_pcm_hw_params_set_access(globals.audio_stream_in, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set access type (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_format(globals.audio_stream_in, hw_params, SND_PCM_FORMAT_S16_LE)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set sample format (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_rate_near(globals.audio_stream_in, hw_params, &sample_rate, 0)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set sample rate (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_channels(globals.audio_stream_in, hw_params, 1)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set channel count (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_period_time(globals.audio_stream_in, hw_params, globals.read_codec.implementation->microseconds_per_frame, 0)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set period time (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_period_size(globals.audio_stream_in, hw_params, globals.read_codec.implementation->samples_per_frame, 0)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set period size (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_hw_params(globals.audio_stream_in, hw_params)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set parameters (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (hw_params) {
|
||||
snd_pcm_hw_params_free (hw_params);
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
hw_params = NULL;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_prepare (globals.audio_stream_out)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot prepare audio interface for use (%s)\n",
|
||||
snd_strerror (err));
|
||||
if ((err = snd_pcm_prepare(globals.audio_stream_out)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot prepare audio interface for use (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_start (globals.audio_stream_out)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot start audio interface for use (%s)\n",
|
||||
snd_strerror (err));
|
||||
if ((err = snd_pcm_start(globals.audio_stream_out)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot start audio interface for use (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_prepare (globals.audio_stream_in)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot prepare audio interface for use (%s)\n",
|
||||
snd_strerror (err));
|
||||
if ((err = snd_pcm_prepare(globals.audio_stream_in)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot prepare audio interface for use (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((err = snd_pcm_start (globals.audio_stream_in)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot start audio interface for use (%s)\n",
|
||||
snd_strerror (err));
|
||||
if ((err = snd_pcm_start(globals.audio_stream_in)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot start audio interface for use (%s)\n", snd_strerror(err));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_unlock(globals.device_lock);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
|
||||
if (hw_params) {
|
||||
snd_pcm_hw_params_free (hw_params);
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
hw_params = NULL;
|
||||
}
|
||||
|
||||
switch_mutex_unlock(globals.device_lock);
|
||||
|
||||
if (globals.audio_stream_in) {
|
||||
snd_pcm_close (globals.audio_stream_in);
|
||||
snd_pcm_close(globals.audio_stream_in);
|
||||
}
|
||||
|
||||
if (globals.audio_stream_out) {
|
||||
snd_pcm_close (globals.audio_stream_out);
|
||||
snd_pcm_close(globals.audio_stream_out);
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open audio device!\n");
|
||||
switch_core_codec_destroy(&globals.read_codec);
|
||||
switch_core_codec_destroy(&globals.write_codec);
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
||||
|
||||
|
||||
@@ -1189,8 +1161,8 @@ static switch_status_t engage_device(unsigned int sample_rate, int codec_ms)
|
||||
static switch_status_t dtmf_call(char **argv, int argc, switch_stream_handle_t *stream)
|
||||
{
|
||||
char *dtmf_str = argv[0];
|
||||
switch_dtmf_t dtmf = {0, switch_core_default_dtmf_duration(0)};
|
||||
|
||||
switch_dtmf_t dtmf = { 0, switch_core_default_dtmf_duration(0) };
|
||||
|
||||
if (switch_strlen_zero(dtmf_str)) {
|
||||
stream->write_function(stream, "No DTMF Supplied!\n");
|
||||
} else {
|
||||
@@ -1198,7 +1170,7 @@ static switch_status_t dtmf_call(char **argv, int argc, switch_stream_handle_t *
|
||||
if (globals.call_list) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(globals.call_list->session);
|
||||
char *p = dtmf_str;
|
||||
while(p && *p) {
|
||||
while (p && *p) {
|
||||
dtmf.digit = *p;
|
||||
switch_channel_queue_dtmf(channel, &dtmf);
|
||||
p++;
|
||||
@@ -1250,7 +1222,7 @@ static switch_status_t switch_call(char **argv, int argc, switch_stream_handle_t
|
||||
stream->write_function(stream, "NO SUCH CALL\n");
|
||||
}
|
||||
|
||||
done:
|
||||
done:
|
||||
switch_mutex_unlock(globals.pvt_lock);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -1317,7 +1289,7 @@ static switch_status_t answer_call(char **argv, int argc, switch_stream_handle_t
|
||||
break;
|
||||
}
|
||||
}
|
||||
done:
|
||||
done:
|
||||
switch_mutex_unlock(globals.pvt_lock);
|
||||
|
||||
stream->write_function(stream, "Answered %d channels.\n", x);
|
||||
@@ -1371,7 +1343,7 @@ static switch_status_t do_flags(char **argv, int argc, switch_stream_handle_t *s
|
||||
goto bad;
|
||||
}
|
||||
|
||||
desc:
|
||||
desc:
|
||||
x = 0;
|
||||
stream->write_function(stream, "FLAGS: ");
|
||||
if (switch_test_flag((&globals), GFLAG_EAR)) {
|
||||
@@ -1388,9 +1360,9 @@ static switch_status_t do_flags(char **argv, int argc, switch_stream_handle_t *s
|
||||
|
||||
goto done;
|
||||
|
||||
bad:
|
||||
bad:
|
||||
stream->write_function(stream, "Usage: flags [on|off] <flags>\n");
|
||||
done:
|
||||
done:
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1487,12 +1459,9 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
|
||||
|
||||
if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
|
||||
NULL,
|
||||
dialplan, cid_name, cid_num,
|
||||
ip, NULL, NULL, NULL, (char *) modname, NULL,
|
||||
dest)) != 0) {
|
||||
dialplan, cid_name, cid_num, ip, NULL, NULL, NULL, (char *) modname, NULL, dest)) != 0) {
|
||||
char name[128];
|
||||
snprintf(name, sizeof(name), "Alsa/%s",
|
||||
tech_pvt->caller_profile->destination_number ? tech_pvt->caller_profile->destination_number : modname);
|
||||
snprintf(name, sizeof(name), "Alsa/%s", tech_pvt->caller_profile->destination_number ? tech_pvt->caller_profile->destination_number : modname);
|
||||
switch_channel_set_name(channel, name);
|
||||
|
||||
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
||||
@@ -1504,7 +1473,7 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
|
||||
switch_channel_set_state(channel, CS_INIT);
|
||||
|
||||
if (switch_core_session_thread_launch(tech_pvt->session) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n");
|
||||
switch_core_session_destroy(&session);
|
||||
stream->write_function(stream, "FAIL:Thread Error!\n");
|
||||
} else {
|
||||
@@ -1536,7 +1505,7 @@ SWITCH_STANDARD_API(pa_cmd)
|
||||
http = switch_event_get_header(stream->param_event, "http-host");
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char *usage_string = "USAGE:\n"
|
||||
"--------------------------------------------------------------------------------\n"
|
||||
"alsa help\n"
|
||||
@@ -1546,8 +1515,7 @@ SWITCH_STANDARD_API(pa_cmd)
|
||||
"alsa list\n"
|
||||
"alsa switch [<call_id>|none]\n"
|
||||
"alsa dtmf <digit string>\n"
|
||||
"alsa flags [on|off] [ear] [mouth]\n"
|
||||
"--------------------------------------------------------------------------------\n";
|
||||
"alsa flags [on|off] [ear] [mouth]\n" "--------------------------------------------------------------------------------\n";
|
||||
|
||||
if (http) {
|
||||
#if 0
|
||||
@@ -1638,14 +1606,13 @@ SWITCH_STANDARD_API(pa_cmd)
|
||||
stream->write_function(stream, "Unknown Command [%s]\n", argv[0]);
|
||||
}
|
||||
|
||||
done:
|
||||
done:
|
||||
|
||||
if (http) {
|
||||
|
||||
stream->write_function(stream,
|
||||
"<br><br><table align=center><tr><td><center><form method=post>\n"
|
||||
"<input type=text name=wcmd size=40><br><br>\n"
|
||||
|
||||
"<input name=action type=submit value=\"call\"> "
|
||||
"<input name=action type=submit value=\"hangup\"> "
|
||||
"<input name=action type=submit value=\"list\"> "
|
||||
@@ -1658,25 +1625,18 @@ SWITCH_STANDARD_API(pa_cmd)
|
||||
"<td><input name=action type=submit value=\"2\"></td>"
|
||||
"<td><input name=action type=submit value=\"3\"></td>\n"
|
||||
"<td><input name=action type=submit value=\"A\"></td></tr>\n"
|
||||
|
||||
"<tr><td><input name=action type=submit value=\"4\"></td>"
|
||||
"<td><input name=action type=submit value=\"5\"></td>"
|
||||
"<td><input name=action type=submit value=\"6\"></td>\n"
|
||||
"<td><input name=action type=submit value=\"B\"></td></tr>\n"
|
||||
|
||||
"<tr><td><input name=action type=submit value=\"7\"></td>"
|
||||
"<td><input name=action type=submit value=\"8\"></td>"
|
||||
"<td><input name=action type=submit value=\"9\"></td>\n"
|
||||
"<td><input name=action type=submit value=\"C\"></td></tr>\n"
|
||||
|
||||
"<tr><td><input name=action type=submit value=\"*\"></td>"
|
||||
"<td><input name=action type=submit value=\"0\"></td>"
|
||||
"<td><input name=action type=submit value=\"#\"></td>\n"
|
||||
"<td><input name=action type=submit value=\"D\"></td></tr>\n"
|
||||
"</table>"
|
||||
|
||||
"</form><br></center></td></tr></table>\n"
|
||||
);
|
||||
"<td><input name=action type=submit value=\"D\"></td></tr>\n" "</table>" "</form><br></center></td></tr></table>\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -53,11 +53,7 @@ switch_endpoint_interface_t *dingaling_endpoint_interface;
|
||||
|
||||
static char sub_sql[] =
|
||||
"CREATE TABLE jabber_subscriptions (\n"
|
||||
" sub_from VARCHAR(255),\n"
|
||||
" sub_to VARCHAR(255),\n"
|
||||
" show_pres VARCHAR(255),\n"
|
||||
" status VARCHAR(255)\n"
|
||||
");\n";
|
||||
" sub_from VARCHAR(255),\n" " sub_to VARCHAR(255),\n" " show_pres VARCHAR(255),\n" " status VARCHAR(255)\n" ");\n";
|
||||
|
||||
|
||||
typedef enum {
|
||||
@@ -215,9 +211,9 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
|
||||
|
||||
static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlsession, ldl_signal_t dl_signal,
|
||||
static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsession, ldl_signal_t dl_signal,
|
||||
char *to, char *from, char *subject, char *msg);
|
||||
static ldl_status handle_response(ldl_handle_t * handle, char *id);
|
||||
static ldl_status handle_response(ldl_handle_t *handle, char *id);
|
||||
static switch_status_t load_config(void);
|
||||
static int sin_callback(void *pArg, int argc, char **argv, char **columnNames);
|
||||
|
||||
@@ -270,9 +266,8 @@ static void mdl_execute_sql(mdl_profile_t *profile, char *sql, switch_mutex_t *m
|
||||
if (mutex) {
|
||||
switch_mutex_lock(mutex);
|
||||
}
|
||||
|
||||
#ifdef SWITCH_HAVE_ODBC
|
||||
if (profile->odbc_dsn) {
|
||||
if (profile->odbc_dsn) {
|
||||
SQLHSTMT stmt;
|
||||
if (switch_odbc_handle_exec(profile->master_odbc, sql, &stmt) != SWITCH_ODBC_SUCCESS) {
|
||||
char *err_str;
|
||||
@@ -292,11 +287,11 @@ static void mdl_execute_sql(mdl_profile_t *profile, char *sql, switch_mutex_t *m
|
||||
switch_core_db_close(db);
|
||||
|
||||
#ifdef SWITCH_HAVE_ODBC
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
end:
|
||||
end:
|
||||
if (mutex) {
|
||||
switch_mutex_unlock(mutex);
|
||||
}
|
||||
@@ -304,22 +299,18 @@ static void mdl_execute_sql(mdl_profile_t *profile, char *sql, switch_mutex_t *m
|
||||
|
||||
|
||||
static switch_bool_t mdl_execute_sql_callback(mdl_profile_t *profile,
|
||||
switch_mutex_t *mutex,
|
||||
char *sql,
|
||||
switch_core_db_callback_func_t callback,
|
||||
void *pdata)
|
||||
switch_mutex_t *mutex, char *sql, switch_core_db_callback_func_t callback, void *pdata)
|
||||
{
|
||||
switch_bool_t ret = SWITCH_FALSE;
|
||||
switch_core_db_t *db;
|
||||
char *errmsg = NULL;
|
||||
|
||||
if (mutex) {
|
||||
switch_mutex_lock(mutex);
|
||||
}
|
||||
|
||||
if (mutex) {
|
||||
switch_mutex_lock(mutex);
|
||||
}
|
||||
|
||||
#ifdef SWITCH_HAVE_ODBC
|
||||
if (profile->odbc_dsn) {
|
||||
if (profile->odbc_dsn) {
|
||||
switch_odbc_handle_callback_exec(profile->master_odbc, sql, callback, pdata);
|
||||
} else {
|
||||
#endif
|
||||
@@ -331,7 +322,7 @@ static switch_bool_t mdl_execute_sql_callback(mdl_profile_t *profile,
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch_core_db_exec(db, sql, callback, pdata, &errmsg);
|
||||
|
||||
if (errmsg) {
|
||||
@@ -342,18 +333,17 @@ static switch_bool_t mdl_execute_sql_callback(mdl_profile_t *profile,
|
||||
if (db) {
|
||||
switch_core_db_close(db);
|
||||
}
|
||||
|
||||
#ifdef SWITCH_HAVE_ODBC
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
end:
|
||||
end:
|
||||
|
||||
if (mutex) {
|
||||
switch_mutex_unlock(mutex);
|
||||
}
|
||||
|
||||
switch_mutex_unlock(mutex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return ret;
|
||||
@@ -418,11 +408,11 @@ static void pres_event_handler(switch_event_t *event)
|
||||
char *rpid = switch_event_get_header(event, "rpid");
|
||||
char *type = switch_event_get_header(event, "event_subtype");
|
||||
char *sql;
|
||||
|
||||
if (globals.running != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (globals.running != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!proto) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Missing 'proto' header\n");
|
||||
return;
|
||||
@@ -481,7 +471,8 @@ static void pres_event_handler(switch_event_t *event)
|
||||
}
|
||||
|
||||
|
||||
sql = switch_mprintf("select sub_from, sub_to,'%q','%q','%q','%q' from jabber_subscriptions where sub_to like '%%%q'", type, rpid, status, proto, from);
|
||||
sql =
|
||||
switch_mprintf("select sub_from, sub_to,'%q','%q','%q','%q' from jabber_subscriptions where sub_to like '%%%q'", type, rpid, status, proto, from);
|
||||
|
||||
|
||||
for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) {
|
||||
@@ -495,7 +486,7 @@ static void pres_event_handler(switch_event_t *event)
|
||||
|
||||
if (sql) {
|
||||
switch_bool_t worked = mdl_execute_sql_callback(profile, profile->mutex, sql, sub_callback, profile);
|
||||
|
||||
|
||||
if (!worked) {
|
||||
continue;
|
||||
}
|
||||
@@ -564,9 +555,9 @@ static void roster_event_handler(switch_event_t *event)
|
||||
void *val;
|
||||
char *sql;
|
||||
|
||||
if (globals.running != 1) {
|
||||
return;
|
||||
}
|
||||
if (globals.running != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (status && !strcasecmp(status, "n/a")) {
|
||||
status = NULL;
|
||||
@@ -697,7 +688,7 @@ static void terminate_session(switch_core_session_t **session, int line, switch_
|
||||
|
||||
tech_pvt = switch_core_session_get_private(*session);
|
||||
|
||||
|
||||
|
||||
if (tech_pvt && tech_pvt->profile && tech_pvt->profile->ip && tech_pvt->local_port) {
|
||||
switch_rtp_release_port(tech_pvt->profile->ip, tech_pvt->local_port);
|
||||
}
|
||||
@@ -748,8 +739,7 @@ static void dl_logger(char *file, const char *func, int line, int level, char *f
|
||||
xml = switch_xml_parse_str(xmltxt, strlen(xmltxt));
|
||||
form = switch_xml_toxml(xml, SWITCH_FALSE);
|
||||
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, level,
|
||||
"%s:\n-------------------------------------------------------------------------------\n"
|
||||
"%s\n", ll, form);
|
||||
"%s:\n-------------------------------------------------------------------------------\n" "%s\n", ll, form);
|
||||
switch_xml_free(xml);
|
||||
free(data);
|
||||
}
|
||||
@@ -774,8 +764,7 @@ static int get_codecs(struct private_object *tech_pvt)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
|
||||
return 0;
|
||||
}
|
||||
} else if (((tech_pvt->num_codecs =
|
||||
switch_loadable_module_get_codecs(tech_pvt->codecs, SWITCH_MAX_CODECS))) <= 0) {
|
||||
} else if (((tech_pvt->num_codecs = switch_loadable_module_get_codecs(tech_pvt->codecs, SWITCH_MAX_CODECS))) <= 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -786,7 +775,7 @@ static int get_codecs(struct private_object *tech_pvt)
|
||||
|
||||
|
||||
|
||||
static void *SWITCH_THREAD_FUNC handle_thread_run(switch_thread_t * thread, void *obj)
|
||||
static void *SWITCH_THREAD_FUNC handle_thread_run(switch_thread_t *thread, void *obj)
|
||||
{
|
||||
ldl_handle_t *handle = obj;
|
||||
mdl_profile_t *profile = NULL;
|
||||
@@ -805,7 +794,7 @@ static void *SWITCH_THREAD_FUNC handle_thread_run(switch_thread_t * thread, void
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void handle_thread_launch(ldl_handle_t * handle)
|
||||
static void handle_thread_launch(ldl_handle_t *handle)
|
||||
{
|
||||
switch_thread_t *thread;
|
||||
switch_threadattr_t *thd_attr = NULL;
|
||||
@@ -873,7 +862,7 @@ static int activate_rtp(struct private_object *tech_pvt)
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SETUP RTP %s:%d -> %s:%d\n", tech_pvt->profile->ip,
|
||||
tech_pvt->local_port, tech_pvt->remote_ip, tech_pvt->remote_port);
|
||||
|
||||
|
||||
flags = SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_GOOGLEHACK | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_RAW_WRITE | SWITCH_RTP_FLAG_AUTO_CNG;
|
||||
|
||||
if (switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
|
||||
@@ -1089,8 +1078,7 @@ static switch_status_t negotiate_media(switch_core_session_t *session)
|
||||
while (!(switch_test_flag(tech_pvt, TFLAG_CODEC_READY) &&
|
||||
switch_test_flag(tech_pvt, TFLAG_RTP_READY) &&
|
||||
switch_test_flag(tech_pvt, TFLAG_ANSWER) && switch_test_flag(tech_pvt, TFLAG_TRANSPORT_ACCEPT) &&
|
||||
tech_pvt->remote_ip && tech_pvt->remote_port
|
||||
&& switch_test_flag(tech_pvt, TFLAG_TRANSPORT))) {
|
||||
tech_pvt->remote_ip && tech_pvt->remote_port && switch_test_flag(tech_pvt, TFLAG_TRANSPORT))) {
|
||||
now = switch_timestamp_now();
|
||||
elapsed = (unsigned int) ((now - started) / 1000);
|
||||
|
||||
@@ -1140,9 +1128,9 @@ static switch_status_t negotiate_media(switch_core_session_t *session)
|
||||
|
||||
goto done;
|
||||
|
||||
out:
|
||||
out:
|
||||
terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
done:
|
||||
done:
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1222,7 +1210,7 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
|
||||
/* Dunno why, but if googletalk calls us for the first time, as soon as the call ends
|
||||
they think we are offline for no reason so we send this presence packet to stop it from happening
|
||||
We should find out why.....
|
||||
*/
|
||||
*/
|
||||
if ((tech_pvt->profile->user_flags & LDL_FLAG_COMPONENT) && is_special(tech_pvt->them)) {
|
||||
ldl_handle_send_presence(tech_pvt->profile->handle, tech_pvt->them, tech_pvt->us, NULL, NULL, "Click To Call", tech_pvt->profile->avatar);
|
||||
}
|
||||
@@ -1497,21 +1485,21 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
|
||||
break;
|
||||
case SWITCH_MESSAGE_INDICATE_BRIDGE:
|
||||
/*
|
||||
if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
|
||||
switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "De-activate timed RTP!\n");
|
||||
//switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_TIMER_RECLOCK);
|
||||
}
|
||||
*/
|
||||
if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
|
||||
switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "De-activate timed RTP!\n");
|
||||
//switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_TIMER_RECLOCK);
|
||||
}
|
||||
*/
|
||||
break;
|
||||
case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
|
||||
/*
|
||||
if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
|
||||
switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-activate timed RTP!\n");
|
||||
//switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_TIMER_RECLOCK);
|
||||
}
|
||||
*/
|
||||
if (tech_pvt->rtp_session && switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
|
||||
switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-activate timed RTP!\n");
|
||||
//switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_TIMER_RECLOCK);
|
||||
}
|
||||
*/
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -1618,7 +1606,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
||||
} else {
|
||||
if (!user) {
|
||||
const char *id_num;
|
||||
|
||||
|
||||
if (!(id_num = outbound_profile->caller_id_number)) {
|
||||
if (!(id_num = outbound_profile->caller_id_name)) {
|
||||
id_num = "nobody";
|
||||
@@ -1810,7 +1798,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dingaling_load)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static ldl_status handle_loop(ldl_handle_t * handle)
|
||||
static ldl_status handle_loop(ldl_handle_t *handle)
|
||||
{
|
||||
if (!globals.running) {
|
||||
return LDL_STATUS_FALSE;
|
||||
@@ -1829,7 +1817,7 @@ static switch_status_t init_profile(mdl_profile_t *profile, uint8_t login)
|
||||
|
||||
if (!(profile->login && profile->password && profile->dialplan && profile->message && profile->ip && profile->name && profile->exten)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"Invalid Profile\n" "login[%s]\n" "pass[%s]\n" "dialplan[%s]\n"
|
||||
"Invalid Profile\n" "login[%s]\n" "pass[%s]\n" "dialplan[%s]\n"
|
||||
"message[%s]\n" "rtp-ip[%s]\n" "name[%s]\n" "exten[%s]\n",
|
||||
profile->login, profile->password, profile->dialplan, profile->message, profile->ip, profile->name, profile->exten);
|
||||
|
||||
@@ -1886,7 +1874,8 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dingaling_shutdown)
|
||||
|
||||
static void set_profile_val(mdl_profile_t *profile, char *var, char *val)
|
||||
{
|
||||
if (!var) return;
|
||||
if (!var)
|
||||
return;
|
||||
|
||||
if (!strcasecmp(var, "login")) {
|
||||
profile->login = switch_core_strdup(module_pool, val);
|
||||
@@ -1903,8 +1892,7 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val)
|
||||
*profile->odbc_pass++ = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#else
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
|
||||
#endif
|
||||
@@ -1912,7 +1900,7 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val)
|
||||
switch_set_flag(profile, TFLAG_TIMER);
|
||||
} else if (!strcasecmp(var, "dialplan") && !switch_strlen_zero(val)) {
|
||||
profile->dialplan = switch_core_strdup(module_pool, val);
|
||||
#ifdef AUTO_REPLY // gotta fix looping on this
|
||||
#ifdef AUTO_REPLY // gotta fix looping on this
|
||||
} else if (!strcasecmp(var, "auto-reply")) {
|
||||
profile->auto_reply = switch_core_strdup(module_pool, val);
|
||||
#endif
|
||||
@@ -2182,7 +2170,7 @@ static switch_status_t load_config(void)
|
||||
if (!(profile->master_odbc = switch_odbc_handle_new(profile->odbc_dsn, profile->odbc_user, profile->odbc_pass))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n");
|
||||
continue;
|
||||
|
||||
|
||||
}
|
||||
if (switch_odbc_handle_connect(profile->master_odbc) != SWITCH_ODBC_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n");
|
||||
@@ -2292,7 +2280,7 @@ static void do_vcard(ldl_handle_t *handle, char *to, char *from, char *id)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
|
||||
}
|
||||
|
||||
end:
|
||||
end:
|
||||
|
||||
switch_event_destroy(¶ms);
|
||||
|
||||
@@ -2307,8 +2295,7 @@ static void do_vcard(ldl_handle_t *handle, char *to, char *from, char *id)
|
||||
switch_safe_free(xmlstr);
|
||||
}
|
||||
|
||||
static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlsession, ldl_signal_t dl_signal, char *to, char *from, char *subject,
|
||||
char *msg)
|
||||
static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsession, ldl_signal_t dl_signal, char *to, char *from, char *subject, char *msg)
|
||||
{
|
||||
mdl_profile_t *profile = NULL;
|
||||
switch_core_session_t *session = NULL;
|
||||
@@ -2350,11 +2337,8 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
mdl_execute_sql(profile, sql, NULL);
|
||||
switch_core_db_free(sql);
|
||||
}
|
||||
if ((sql = switch_mprintf("insert into jabber_subscriptions values('%q','%q','%q','%q');\n",
|
||||
switch_str_nil(from),
|
||||
switch_str_nil(to),
|
||||
switch_str_nil(msg),
|
||||
switch_str_nil(subject)))) {
|
||||
if ((sql = switch_mprintf("insert into jabber_subscriptions values('%q','%q','%q','%q');\n",
|
||||
switch_str_nil(from), switch_str_nil(to), switch_str_nil(msg), switch_str_nil(subject)))) {
|
||||
mdl_execute_sql(profile, sql, NULL);
|
||||
switch_core_db_free(sql);
|
||||
}
|
||||
@@ -2362,7 +2346,8 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
if (is_special(to)) {
|
||||
ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Click To Call", profile->avatar);
|
||||
} else {
|
||||
ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Authenticated.\nCome to ClueCon!\nhttp://www.cluecon.com", profile->avatar);
|
||||
ldl_handle_send_presence(profile->handle, to, from, NULL, NULL, "Authenticated.\nCome to ClueCon!\nhttp://www.cluecon.com",
|
||||
profile->avatar);
|
||||
}
|
||||
#if 0
|
||||
if (is_special(to)) {
|
||||
@@ -2400,7 +2385,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
break;
|
||||
case LDL_SIGNAL_PRESENCE_IN:
|
||||
|
||||
if ((sql = switch_mprintf("update jabber_subscriptions set show_pres='%q', status='%q' where sub_from='%q'",
|
||||
if ((sql = switch_mprintf("update jabber_subscriptions set show_pres='%q', status='%q' where sub_from='%q'",
|
||||
switch_str_nil(msg), switch_str_nil(subject), switch_str_nil(from)))) {
|
||||
mdl_execute_sql(profile, sql, profile->mutex);
|
||||
switch_core_db_free(sql);
|
||||
@@ -2435,7 +2420,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
|
||||
case LDL_SIGNAL_PRESENCE_OUT:
|
||||
|
||||
if ((sql = switch_mprintf("update jabber_subscriptions set show_pres='%q', status='%q' where sub_from='%q'",
|
||||
if ((sql = switch_mprintf("update jabber_subscriptions set show_pres='%q', status='%q' where sub_from='%q'",
|
||||
switch_str_nil(msg), switch_str_nil(subject), switch_str_nil(from)))) {
|
||||
mdl_execute_sql(profile, sql, profile->mutex);
|
||||
switch_core_db_free(sql);
|
||||
@@ -2454,45 +2439,45 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
|
||||
switch (dl_signal) {
|
||||
case LDL_SIGNAL_MSG:{
|
||||
switch_chat_interface_t *ci;
|
||||
char *proto = MDL_CHAT_PROTO;
|
||||
char *pproto = NULL, *ffrom = NULL;
|
||||
char *hint;
|
||||
switch_chat_interface_t *ci;
|
||||
char *proto = MDL_CHAT_PROTO;
|
||||
char *pproto = NULL, *ffrom = NULL;
|
||||
char *hint;
|
||||
#ifdef AUTO_REPLY
|
||||
if (profile->auto_reply) {
|
||||
ldl_handle_send_msg(handle,
|
||||
(profile->user_flags & LDL_FLAG_COMPONENT) ? to : ldl_handle_get_login(profile->handle), from, "",
|
||||
profile->auto_reply);
|
||||
}
|
||||
if (profile->auto_reply) {
|
||||
ldl_handle_send_msg(handle,
|
||||
(profile->user_flags & LDL_FLAG_COMPONENT) ? to : ldl_handle_get_login(profile->handle), from, "",
|
||||
profile->auto_reply);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (strchr(to, '+')) {
|
||||
pproto = strdup(to);
|
||||
if ((to = strchr(pproto, '+'))) {
|
||||
*to++ = '\0';
|
||||
if (strchr(to, '+')) {
|
||||
pproto = strdup(to);
|
||||
if ((to = strchr(pproto, '+'))) {
|
||||
*to++ = '\0';
|
||||
}
|
||||
proto = pproto;
|
||||
}
|
||||
proto = pproto;
|
||||
}
|
||||
|
||||
hint = from;
|
||||
hint = from;
|
||||
|
||||
if (strchr(from, '/') && (ffrom = strdup(from))) {
|
||||
char *p;
|
||||
if ((p = strchr(ffrom, '/'))) {
|
||||
*p = '\0';
|
||||
if (strchr(from, '/') && (ffrom = strdup(from))) {
|
||||
char *p;
|
||||
if ((p = strchr(ffrom, '/'))) {
|
||||
*p = '\0';
|
||||
}
|
||||
from = ffrom;
|
||||
}
|
||||
from = ffrom;
|
||||
}
|
||||
|
||||
if ((ci = switch_loadable_module_get_chat_interface(proto))) {
|
||||
ci->chat_send(MDL_CHAT_PROTO, from, to, subject, msg, hint);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto);
|
||||
}
|
||||
if ((ci = switch_loadable_module_get_chat_interface(proto))) {
|
||||
ci->chat_send(MDL_CHAT_PROTO, from, to, subject, msg, hint);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto);
|
||||
}
|
||||
|
||||
switch_safe_free(pproto);
|
||||
switch_safe_free(ffrom);
|
||||
}
|
||||
switch_safe_free(pproto);
|
||||
switch_safe_free(ffrom);
|
||||
}
|
||||
break;
|
||||
case LDL_SIGNAL_LOGIN_SUCCESS:
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DL_EVENT_LOGIN_SUCCESS) == SWITCH_STATUS_SUCCESS) {
|
||||
@@ -2547,7 +2532,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
}
|
||||
if ((session = switch_core_session_request(dingaling_endpoint_interface, NULL)) != 0) {
|
||||
switch_core_session_add_stream(session, NULL);
|
||||
|
||||
|
||||
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) {
|
||||
char *exten;
|
||||
char *context;
|
||||
@@ -2641,10 +2626,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
ldl_session_get_ip(dlsession),
|
||||
ldl_session_get_value(dlsession, "ani"),
|
||||
ldl_session_get_value(dlsession, "aniii"),
|
||||
ldl_session_get_value(dlsession, "rdnis"),
|
||||
modname,
|
||||
context,
|
||||
exten)) != 0) {
|
||||
ldl_session_get_value(dlsession, "rdnis"), modname, context, exten)) != 0) {
|
||||
char name[128];
|
||||
switch_snprintf(name, sizeof(name), "DingaLing/%s", tech_pvt->caller_profile->destination_number);
|
||||
switch_channel_set_name(channel, name);
|
||||
@@ -2669,8 +2651,8 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n");
|
||||
terminate_session(&session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
status = LDL_STATUS_FALSE;
|
||||
goto done;
|
||||
status = LDL_STATUS_FALSE;
|
||||
goto done;
|
||||
}
|
||||
} else {
|
||||
status = LDL_STATUS_FALSE;
|
||||
@@ -2832,7 +2814,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%u candidates\n", len);
|
||||
|
||||
|
||||
if (profile->acl_count) {
|
||||
for (x = 0; x < len; x++) {
|
||||
uint32_t y = 0;
|
||||
@@ -2843,18 +2825,18 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "candidate %s:%d PASS ACL %s\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "candidate %s:%d PASS ACL %s\n",
|
||||
candidates[x].address, candidates[x].port, profile->acl[y]);
|
||||
break;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "candidate %s:%d FAIL ACL %s\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "candidate %s:%d FAIL ACL %s\n",
|
||||
candidates[x].address, candidates[x].port, profile->acl[y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (x = 0; x < len; x++) {
|
||||
|
||||
|
||||
if (profile->lanaddr) {
|
||||
lanaddr = strncasecmp(candidates[x].address, profile->lanaddr, strlen(profile->lanaddr)) ? 0 : 1;
|
||||
}
|
||||
@@ -2879,9 +2861,8 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
strncasecmp(candidates[x].address, "172.2", 5) &&
|
||||
strncasecmp(candidates[x].address, "172.30.", 7) &&
|
||||
strncasecmp(candidates[x].address, "172.31.", 7) &&
|
||||
strncasecmp(candidates[x].address, "192.0.2.", 8) &&
|
||||
strncasecmp(candidates[x].address, "169.254.", 8)
|
||||
))) {
|
||||
strncasecmp(candidates[x].address, "192.0.2.", 8) && strncasecmp(candidates[x].address, "169.254.", 8)
|
||||
))) {
|
||||
choice = x;
|
||||
ok = 1;
|
||||
}
|
||||
@@ -2893,7 +2874,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
|
||||
memset(payloads, 0, sizeof(payloads));
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"Acceptable Candidate %s:%d\n", candidates[choice].address, candidates[choice].port);
|
||||
|
||||
if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
|
||||
@@ -2934,7 +2915,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
status = LDL_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
goto done;
|
||||
goto done;
|
||||
|
||||
}
|
||||
break;
|
||||
@@ -2961,14 +2942,14 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
done:
|
||||
|
||||
done:
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static ldl_status handle_response(ldl_handle_t * handle, char *id)
|
||||
static ldl_status handle_response(ldl_handle_t *handle, char *id)
|
||||
{
|
||||
return LDL_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ mutex_status_t iax_mutex_create(mutex_t **mutex)
|
||||
#endif
|
||||
mutex_t *check = NULL;
|
||||
|
||||
check = (mutex_t *)malloc(sizeof(**mutex));
|
||||
check = (mutex_t *) malloc(sizeof(**mutex));
|
||||
if (!check)
|
||||
goto done;
|
||||
#ifdef WIN32
|
||||
@@ -64,16 +64,16 @@ mutex_status_t iax_mutex_create(mutex_t **mutex)
|
||||
|
||||
goto success;
|
||||
|
||||
fail:
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
goto done;
|
||||
fail:
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
goto done;
|
||||
|
||||
success:
|
||||
success:
|
||||
#endif
|
||||
*mutex = check;
|
||||
status = MUTEX_SUCCESS;
|
||||
|
||||
done:
|
||||
done:
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
+710
-850
File diff suppressed because it is too large.
Load diff
@@ -40,12 +40,12 @@ static int oframes = 0;
|
||||
#ifdef ALIGN32
|
||||
static unsigned int get_uint32(unsigned char *p)
|
||||
{
|
||||
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
|
||||
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
|
||||
}
|
||||
|
||||
static unsigned short get_uint16(unsigned char *p)
|
||||
{
|
||||
return (p[0] << 8) | p[1] ;
|
||||
return (p[0] << 8) | p[1];
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -64,8 +64,8 @@ static void internalerror(const char *str)
|
||||
fprintf(stderr, "WARNING: %s", str);
|
||||
}
|
||||
|
||||
static void (*outputf)(const char *str) = internaloutput;
|
||||
static void (*errorf)(const char *str) = internalerror;
|
||||
static void (*outputf) (const char *str) = internaloutput;
|
||||
static void (*errorf) (const char *str) = internalerror;
|
||||
|
||||
static void dump_addr(char *output, int maxlen, void *value, int len)
|
||||
{
|
||||
@@ -83,21 +83,21 @@ static void dump_string(char *output, int maxlen, void *value, int len)
|
||||
maxlen--;
|
||||
if (maxlen > len)
|
||||
maxlen = len;
|
||||
strncpy(output,value, maxlen);
|
||||
strncpy(output, value, maxlen);
|
||||
output[maxlen] = '\0';
|
||||
}
|
||||
|
||||
static void dump_int(char *output, int maxlen, void *value, int len)
|
||||
{
|
||||
if (len == (int)sizeof(unsigned int))
|
||||
snprintf(output, maxlen, "%lu", (unsigned long)ntohl(get_uint32(value)));
|
||||
if (len == (int) sizeof(unsigned int))
|
||||
snprintf(output, maxlen, "%lu", (unsigned long) ntohl(get_uint32(value)));
|
||||
else
|
||||
snprintf(output, maxlen, "Invalid INT");
|
||||
}
|
||||
|
||||
static void dump_short(char *output, int maxlen, void *value, int len)
|
||||
{
|
||||
if (len == (int)sizeof(unsigned short))
|
||||
if (len == (int) sizeof(unsigned short))
|
||||
snprintf(output, maxlen, "%d", ntohs(get_uint16(value)));
|
||||
else
|
||||
snprintf(output, maxlen, "Invalid SHORT");
|
||||
@@ -105,8 +105,8 @@ static void dump_short(char *output, int maxlen, void *value, int len)
|
||||
|
||||
static void dump_byte(char *output, int maxlen, void *value, int len)
|
||||
{
|
||||
if (len == (int)sizeof(unsigned char))
|
||||
snprintf(output, maxlen, "%d", *((unsigned char *)value));
|
||||
if (len == (int) sizeof(unsigned char))
|
||||
snprintf(output, maxlen, "%d", *((unsigned char *) value));
|
||||
else
|
||||
snprintf(output, maxlen, "Invalid BYTE");
|
||||
}
|
||||
@@ -115,7 +115,7 @@ static void dump_byte(char *output, int maxlen, void *value, int len)
|
||||
static void dump_ipaddr(char *output, int maxlen, void *value, int len)
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
if (len == (int)sizeof(unsigned int)) {
|
||||
if (len == (int) sizeof(unsigned int)) {
|
||||
memcpy(&sin.sin_addr, value, len);
|
||||
snprintf(output, maxlen, "%s", inet_ntoa(sin.sin_addr));
|
||||
} else
|
||||
@@ -124,9 +124,8 @@ static void dump_ipaddr(char *output, int maxlen, void *value, int len)
|
||||
|
||||
static void dump_prov_flags(char *output, int maxlen, void *value, int len)
|
||||
{
|
||||
if (len == (int)sizeof(unsigned int))
|
||||
snprintf(output, maxlen, "%lu (%s)", (unsigned long)ntohl(get_uint32(value)),
|
||||
"PROVISION_PARSING_NOT_IMPLEMENTED");
|
||||
if (len == (int) sizeof(unsigned int))
|
||||
snprintf(output, maxlen, "%lu (%s)", (unsigned long) ntohl(get_uint32(value)), "PROVISION_PARSING_NOT_IMPLEMENTED");
|
||||
else
|
||||
snprintf(output, maxlen, "Invalid INT");
|
||||
}
|
||||
@@ -134,10 +133,10 @@ static void dump_prov_flags(char *output, int maxlen, void *value, int len)
|
||||
|
||||
static void dump_samprate(char *output, int maxlen, void *value, int len)
|
||||
{
|
||||
char tmp[256]="";
|
||||
char tmp[256] = "";
|
||||
int sr;
|
||||
if (len == (int)sizeof(unsigned short)) {
|
||||
sr = ntohs(*((unsigned short *)value));
|
||||
if (len == (int) sizeof(unsigned short)) {
|
||||
sr = ntohs(*((unsigned short *) value));
|
||||
if (sr & IAX_RATE_8KHZ)
|
||||
strcat(tmp, ",8khz");
|
||||
if (sr & IAX_RATE_11KHZ)
|
||||
@@ -170,61 +169,61 @@ static void dump_prov(char *output, int maxlen, void *value, int len)
|
||||
static struct iax2_ie {
|
||||
int ie;
|
||||
char *name;
|
||||
void (*dump)(char *output, int maxlen, void *value, int len);
|
||||
void (*dump) (char *output, int maxlen, void *value, int len);
|
||||
} ies[] = {
|
||||
{ IAX_IE_CALLED_NUMBER, "CALLED NUMBER", dump_string },
|
||||
{ IAX_IE_CALLING_NUMBER, "CALLING NUMBER", dump_string },
|
||||
{ IAX_IE_CALLING_ANI, "ANI", dump_string },
|
||||
{ IAX_IE_CALLING_NAME, "CALLING NAME", dump_string },
|
||||
{ IAX_IE_CALLED_CONTEXT, "CALLED CONTEXT", dump_string },
|
||||
{ IAX_IE_USERNAME, "USERNAME", dump_string },
|
||||
{ IAX_IE_PASSWORD, "PASSWORD", dump_string },
|
||||
{ IAX_IE_CAPABILITY, "CAPABILITY", dump_int },
|
||||
{ IAX_IE_FORMAT, "FORMAT", dump_int },
|
||||
{ IAX_IE_LANGUAGE, "LANGUAGE", dump_string },
|
||||
{ IAX_IE_CODEC_PREFS, "CODEC_PREFS", dump_string },
|
||||
{ IAX_IE_VERSION, "VERSION", dump_short },
|
||||
{ IAX_IE_ADSICPE, "ADSICPE", dump_short },
|
||||
{ IAX_IE_DNID, "DNID", dump_string },
|
||||
{ IAX_IE_AUTHMETHODS, "AUTHMETHODS", dump_short },
|
||||
{ IAX_IE_CHALLENGE, "CHALLENGE", dump_string },
|
||||
{ IAX_IE_MD5_RESULT, "MD5 RESULT", dump_string },
|
||||
{ IAX_IE_RSA_RESULT, "RSA RESULT", dump_string },
|
||||
{ IAX_IE_APPARENT_ADDR, "APPARENT ADDRESS", dump_addr },
|
||||
{ IAX_IE_REFRESH, "REFRESH", dump_short },
|
||||
{ IAX_IE_DPSTATUS, "DIALPLAN STATUS", dump_short },
|
||||
{ IAX_IE_CALLNO, "CALL NUMBER", dump_short },
|
||||
{ IAX_IE_CAUSE, "CAUSE", dump_string },
|
||||
{ IAX_IE_IAX_UNKNOWN, "UNKNOWN IAX CMD", dump_byte },
|
||||
{ IAX_IE_MSGCOUNT, "MESSAGE COUNT", dump_short },
|
||||
{ IAX_IE_AUTOANSWER, "AUTO ANSWER REQ" },
|
||||
{ IAX_IE_TRANSFERID, "TRANSFER ID", dump_int },
|
||||
{ IAX_IE_RDNIS, "REFERRING DNIS", dump_string },
|
||||
{ IAX_IE_PROVISIONING, "PROVISIONING", dump_prov },
|
||||
{ IAX_IE_AESPROVISIONING, "AES PROVISIONG" },
|
||||
{ IAX_IE_DATETIME, "DATE TIME", dump_int },
|
||||
{ IAX_IE_DEVICETYPE, "DEVICE TYPE", dump_string },
|
||||
{ IAX_IE_SERVICEIDENT, "SERVICE IDENT", dump_string },
|
||||
{ IAX_IE_FIRMWAREVER, "FIRMWARE VER", dump_short },
|
||||
{ IAX_IE_FWBLOCKDESC, "FW BLOCK DESC", dump_int },
|
||||
{ IAX_IE_FWBLOCKDATA, "FW BLOCK DATA" },
|
||||
{ IAX_IE_PROVVER, "PROVISIONG VER", dump_int },
|
||||
{ IAX_IE_CALLINGPRES, "CALLING PRESNTN", dump_byte },
|
||||
{ IAX_IE_CALLINGTON, "CALLING TYPEOFNUM", dump_byte },
|
||||
{ IAX_IE_CALLINGTNS, "CALLING TRANSITNET", dump_short },
|
||||
{ IAX_IE_SAMPLINGRATE, "SAMPLINGRATE", dump_samprate },
|
||||
{ IAX_IE_RR_JITTER, "RR_JITTER", dump_int },
|
||||
{ IAX_IE_RR_LOSS, "RR_LOSS", dump_int },
|
||||
{ IAX_IE_RR_PKTS, "RR_PKTS", dump_int },
|
||||
{ IAX_IE_RR_DELAY, "RR_DELAY", dump_short },
|
||||
{ IAX_IE_RR_DROPPED, "RR_DROPPED", dump_int },
|
||||
{ IAX_IE_RR_OOO, "RR_OOO", dump_int },
|
||||
};
|
||||
{
|
||||
IAX_IE_CALLED_NUMBER, "CALLED NUMBER", dump_string}, {
|
||||
IAX_IE_CALLING_NUMBER, "CALLING NUMBER", dump_string}, {
|
||||
IAX_IE_CALLING_ANI, "ANI", dump_string}, {
|
||||
IAX_IE_CALLING_NAME, "CALLING NAME", dump_string}, {
|
||||
IAX_IE_CALLED_CONTEXT, "CALLED CONTEXT", dump_string}, {
|
||||
IAX_IE_USERNAME, "USERNAME", dump_string}, {
|
||||
IAX_IE_PASSWORD, "PASSWORD", dump_string}, {
|
||||
IAX_IE_CAPABILITY, "CAPABILITY", dump_int}, {
|
||||
IAX_IE_FORMAT, "FORMAT", dump_int}, {
|
||||
IAX_IE_LANGUAGE, "LANGUAGE", dump_string}, {
|
||||
IAX_IE_CODEC_PREFS, "CODEC_PREFS", dump_string}, {
|
||||
IAX_IE_VERSION, "VERSION", dump_short}, {
|
||||
IAX_IE_ADSICPE, "ADSICPE", dump_short}, {
|
||||
IAX_IE_DNID, "DNID", dump_string}, {
|
||||
IAX_IE_AUTHMETHODS, "AUTHMETHODS", dump_short}, {
|
||||
IAX_IE_CHALLENGE, "CHALLENGE", dump_string}, {
|
||||
IAX_IE_MD5_RESULT, "MD5 RESULT", dump_string}, {
|
||||
IAX_IE_RSA_RESULT, "RSA RESULT", dump_string}, {
|
||||
IAX_IE_APPARENT_ADDR, "APPARENT ADDRESS", dump_addr}, {
|
||||
IAX_IE_REFRESH, "REFRESH", dump_short}, {
|
||||
IAX_IE_DPSTATUS, "DIALPLAN STATUS", dump_short}, {
|
||||
IAX_IE_CALLNO, "CALL NUMBER", dump_short}, {
|
||||
IAX_IE_CAUSE, "CAUSE", dump_string}, {
|
||||
IAX_IE_IAX_UNKNOWN, "UNKNOWN IAX CMD", dump_byte}, {
|
||||
IAX_IE_MSGCOUNT, "MESSAGE COUNT", dump_short}, {
|
||||
IAX_IE_AUTOANSWER, "AUTO ANSWER REQ"}, {
|
||||
IAX_IE_TRANSFERID, "TRANSFER ID", dump_int}, {
|
||||
IAX_IE_RDNIS, "REFERRING DNIS", dump_string}, {
|
||||
IAX_IE_PROVISIONING, "PROVISIONING", dump_prov}, {
|
||||
IAX_IE_AESPROVISIONING, "AES PROVISIONG"}, {
|
||||
IAX_IE_DATETIME, "DATE TIME", dump_int}, {
|
||||
IAX_IE_DEVICETYPE, "DEVICE TYPE", dump_string}, {
|
||||
IAX_IE_SERVICEIDENT, "SERVICE IDENT", dump_string}, {
|
||||
IAX_IE_FIRMWAREVER, "FIRMWARE VER", dump_short}, {
|
||||
IAX_IE_FWBLOCKDESC, "FW BLOCK DESC", dump_int}, {
|
||||
IAX_IE_FWBLOCKDATA, "FW BLOCK DATA"}, {
|
||||
IAX_IE_PROVVER, "PROVISIONG VER", dump_int}, {
|
||||
IAX_IE_CALLINGPRES, "CALLING PRESNTN", dump_byte}, {
|
||||
IAX_IE_CALLINGTON, "CALLING TYPEOFNUM", dump_byte}, {
|
||||
IAX_IE_CALLINGTNS, "CALLING TRANSITNET", dump_short}, {
|
||||
IAX_IE_SAMPLINGRATE, "SAMPLINGRATE", dump_samprate}, {
|
||||
IAX_IE_RR_JITTER, "RR_JITTER", dump_int}, {
|
||||
IAX_IE_RR_LOSS, "RR_LOSS", dump_int}, {
|
||||
IAX_IE_RR_PKTS, "RR_PKTS", dump_int}, {
|
||||
IAX_IE_RR_DELAY, "RR_DELAY", dump_short}, {
|
||||
IAX_IE_RR_DROPPED, "RR_DROPPED", dump_int}, {
|
||||
IAX_IE_RR_OOO, "RR_OOO", dump_int},};
|
||||
|
||||
const char *iax_ie2str(int ie)
|
||||
{
|
||||
int x;
|
||||
for (x=0;x<(int)sizeof(ies) / (int)sizeof(ies[0]); x++) {
|
||||
for (x = 0; x < (int) sizeof(ies) / (int) sizeof(ies[0]); x++) {
|
||||
if (ies[x].ie == ie)
|
||||
return ies[x].name;
|
||||
}
|
||||
@@ -240,22 +239,25 @@ static void dump_prov_ies(char *output, int maxlen, unsigned char *iedata, int l
|
||||
char tmp[256];
|
||||
if (len < 2)
|
||||
return;
|
||||
strcpy(output, "\n");
|
||||
maxlen -= (int)strlen(output); output += strlen(output);
|
||||
while(len > 2) {
|
||||
strcpy(output, "\n");
|
||||
maxlen -= (int) strlen(output);
|
||||
output += strlen(output);
|
||||
while (len > 2) {
|
||||
ie = iedata[0];
|
||||
ielen = iedata[1];
|
||||
if (ielen + 2> len) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Total Prov IE length of %d bytes exceeds remaining prov frame length of %d bytes\n", ielen + 2, len);
|
||||
if (ielen + 2 > len) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Total Prov IE length of %d bytes exceeds remaining prov frame length of %d bytes\n", ielen + 2, len);
|
||||
strncpy(output, tmp, maxlen - 1);
|
||||
maxlen -= (int)strlen(output); output += strlen(output);
|
||||
maxlen -= (int) strlen(output);
|
||||
output += strlen(output);
|
||||
return;
|
||||
}
|
||||
found = 0;
|
||||
if (!found) {
|
||||
snprintf(tmp, (int)sizeof(tmp), " Unknown Prov IE %03d : Present\n", ie);
|
||||
snprintf(tmp, (int) sizeof(tmp), " Unknown Prov IE %03d : Present\n", ie);
|
||||
strncpy(output, tmp, maxlen - 1);
|
||||
maxlen -= (int)strlen(output); output += strlen(output);
|
||||
maxlen -= (int) strlen(output);
|
||||
output += strlen(output);
|
||||
}
|
||||
iedata += (2 + ielen);
|
||||
len -= (2 + ielen);
|
||||
@@ -272,34 +274,34 @@ static void dump_ies(unsigned char *iedata, int len)
|
||||
char tmp[1024];
|
||||
if (len < 2)
|
||||
return;
|
||||
while(len > 2) {
|
||||
while (len > 2) {
|
||||
ie = iedata[0];
|
||||
ielen = iedata[1];
|
||||
if (ielen + 2> len) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Total IE length of %d bytes exceeds remaining frame length of %d bytes\n", ielen + 2, len);
|
||||
if (ielen + 2 > len) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Total IE length of %d bytes exceeds remaining frame length of %d bytes\n", ielen + 2, len);
|
||||
outputf(tmp);
|
||||
return;
|
||||
}
|
||||
found = 0;
|
||||
for (x=0;x<(int)sizeof(ies) / (int)sizeof(ies[0]); x++) {
|
||||
for (x = 0; x < (int) sizeof(ies) / (int) sizeof(ies[0]); x++) {
|
||||
if (ies[x].ie == ie) {
|
||||
if (ies[x].dump) {
|
||||
ies[x].dump(interp, (int)sizeof(interp), iedata + 2, ielen);
|
||||
snprintf(tmp, (int)sizeof(tmp), " %-15.15s : %s\n", ies[x].name, interp);
|
||||
ies[x].dump(interp, (int) sizeof(interp), iedata + 2, ielen);
|
||||
snprintf(tmp, (int) sizeof(tmp), " %-15.15s : %s\n", ies[x].name, interp);
|
||||
outputf(tmp);
|
||||
} else {
|
||||
if (ielen)
|
||||
snprintf(interp, (int)sizeof(interp), "%d bytes", ielen);
|
||||
snprintf(interp, (int) sizeof(interp), "%d bytes", ielen);
|
||||
else
|
||||
strcpy(interp, "Present");
|
||||
snprintf(tmp, (int)sizeof(tmp), " %-15.15s : %s\n", ies[x].name, interp);
|
||||
snprintf(tmp, (int) sizeof(tmp), " %-15.15s : %s\n", ies[x].name, interp);
|
||||
outputf(tmp);
|
||||
}
|
||||
found++;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
snprintf(tmp, (int)sizeof(tmp), " Unknown IE %03d : Present\n", ie);
|
||||
snprintf(tmp, (int) sizeof(tmp), " Unknown IE %03d : Present\n", ie);
|
||||
outputf(tmp);
|
||||
}
|
||||
iedata += (2 + ielen);
|
||||
@@ -319,7 +321,8 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
|
||||
"NULL ",
|
||||
"IAX ",
|
||||
"TEXT ",
|
||||
"IMAGE " };
|
||||
"IMAGE "
|
||||
};
|
||||
const char *iaxs[] = {
|
||||
"(0?)",
|
||||
"NEW ",
|
||||
@@ -368,7 +371,8 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
|
||||
"ANSWER ",
|
||||
"BUSY ",
|
||||
"TKOFFHK ",
|
||||
"OFFHOOK" };
|
||||
"OFFHOOK"
|
||||
};
|
||||
struct ast_iax2_full_hdr *fh;
|
||||
char retries[20];
|
||||
char class2[20];
|
||||
@@ -379,7 +383,7 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
|
||||
|
||||
if (f) {
|
||||
fh = f->data;
|
||||
snprintf(retries, (int)sizeof(retries), "%03d", f->retries);
|
||||
snprintf(retries, (int) sizeof(retries), "%03d", f->retries);
|
||||
} else {
|
||||
fh = fhi;
|
||||
if (ntohs(fh->dcallno) & IAX_FLAG_RETRANS)
|
||||
@@ -391,43 +395,41 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
|
||||
/* Don't mess with mini-frames */
|
||||
return;
|
||||
}
|
||||
if (fh->type > ((int)sizeof(frames)/(int)sizeof(char *)) - 1) {
|
||||
snprintf(class2, (int)sizeof(class2), "(%d?)", fh->type);
|
||||
if (fh->type > ((int) sizeof(frames) / (int) sizeof(char *)) - 1) {
|
||||
snprintf(class2, (int) sizeof(class2), "(%d?)", fh->type);
|
||||
class = class2;
|
||||
} else {
|
||||
class = frames[(int)fh->type];
|
||||
class = frames[(int) fh->type];
|
||||
}
|
||||
if (fh->type == AST_FRAME_DTMF) {
|
||||
sprintf(subclass2, "%c", fh->csub);
|
||||
subclass = subclass2;
|
||||
} else if (fh->type == AST_FRAME_IAX) {
|
||||
if (fh->csub >= (int)sizeof(iaxs)/(int)sizeof(iaxs[0])) {
|
||||
snprintf(subclass2, (int)sizeof(subclass2), "(%d?)", fh->csub);
|
||||
if (fh->csub >= (int) sizeof(iaxs) / (int) sizeof(iaxs[0])) {
|
||||
snprintf(subclass2, (int) sizeof(subclass2), "(%d?)", fh->csub);
|
||||
subclass = subclass2;
|
||||
} else {
|
||||
subclass = iaxs[(int)fh->csub];
|
||||
subclass = iaxs[(int) fh->csub];
|
||||
}
|
||||
} else if (fh->type == AST_FRAME_CONTROL) {
|
||||
if (fh->csub > (int)sizeof(cmds)/(int)sizeof(char *)) {
|
||||
snprintf(subclass2, (int)sizeof(subclass2), "(%d?)", fh->csub);
|
||||
if (fh->csub > (int) sizeof(cmds) / (int) sizeof(char *)) {
|
||||
snprintf(subclass2, (int) sizeof(subclass2), "(%d?)", fh->csub);
|
||||
subclass = subclass2;
|
||||
} else {
|
||||
subclass = cmds[(int)fh->csub];
|
||||
subclass = cmds[(int) fh->csub];
|
||||
}
|
||||
} else {
|
||||
snprintf(subclass2, (int)sizeof(subclass2), "%d", fh->csub);
|
||||
snprintf(subclass2, (int) sizeof(subclass2), "%d", fh->csub);
|
||||
subclass = subclass2;
|
||||
}
|
||||
snprintf(tmp, (int)sizeof(tmp),
|
||||
"%s-Frame Retry[%s] -- OSeqno: %3.3d ISeqno: %3.3d Type: %s Subclass: %s\n",
|
||||
(rx ? "Rx" : "Tx"),
|
||||
retries, fh->oseqno, fh->iseqno, class, subclass);
|
||||
snprintf(tmp, (int) sizeof(tmp),
|
||||
"%s-Frame Retry[%s] -- OSeqno: %3.3d ISeqno: %3.3d Type: %s Subclass: %s\n",
|
||||
(rx ? "Rx" : "Tx"), retries, fh->oseqno, fh->iseqno, class, subclass);
|
||||
outputf(tmp);
|
||||
snprintf(tmp, (int)sizeof(tmp),
|
||||
" Timestamp: %05lums SCall: %5.5d DCall: %5.5d [%s:%d]\n",
|
||||
(unsigned long)ntohl(fh->ts),
|
||||
ntohs(fh->scallno) & ~IAX_FLAG_FULL, ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS,
|
||||
inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
|
||||
snprintf(tmp, (int) sizeof(tmp),
|
||||
" Timestamp: %05lums SCall: %5.5d DCall: %5.5d [%s:%d]\n",
|
||||
(unsigned long) ntohl(fh->ts),
|
||||
ntohs(fh->scallno) & ~IAX_FLAG_FULL, ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS, inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
|
||||
outputf(tmp);
|
||||
if (fh->type == AST_FRAME_IAX)
|
||||
dump_ies(fh->iedata, datalen);
|
||||
@@ -436,13 +438,14 @@ snprintf(tmp, (int)sizeof(tmp),
|
||||
int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen)
|
||||
{
|
||||
char tmp[256];
|
||||
if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Out of space for ie '%s' (%d), need %d have %d\n", iax_ie2str(ie), ie, datalen, (int)sizeof(ied->buf) - ied->pos);
|
||||
if (datalen > ((int) sizeof(ied->buf) - ied->pos)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Out of space for ie '%s' (%d), need %d have %d\n", iax_ie2str(ie), ie, datalen,
|
||||
(int) sizeof(ied->buf) - ied->pos);
|
||||
errorf(tmp);
|
||||
return -1;
|
||||
}
|
||||
ied->buf[ied->pos++] = ie;
|
||||
ied->buf[ied->pos++] = (unsigned char)datalen;
|
||||
ied->buf[ied->pos++] = (unsigned char) datalen;
|
||||
memcpy(ied->buf + ied->pos, data, datalen);
|
||||
ied->pos += datalen;
|
||||
return 0;
|
||||
@@ -450,26 +453,26 @@ int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *dat
|
||||
|
||||
int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, struct sockaddr_in *sin)
|
||||
{
|
||||
return iax_ie_append_raw(ied, ie, sin, (int)sizeof(struct sockaddr_in));
|
||||
return iax_ie_append_raw(ied, ie, sin, (int) sizeof(struct sockaddr_in));
|
||||
}
|
||||
|
||||
int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value)
|
||||
int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value)
|
||||
{
|
||||
unsigned int newval;
|
||||
newval = htonl(value);
|
||||
return iax_ie_append_raw(ied, ie, &newval, (int)sizeof(newval));
|
||||
return iax_ie_append_raw(ied, ie, &newval, (int) sizeof(newval));
|
||||
}
|
||||
|
||||
int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value)
|
||||
int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value)
|
||||
{
|
||||
unsigned short newval;
|
||||
newval = htons(value);
|
||||
return iax_ie_append_raw(ied, ie, &newval, (int)sizeof(newval));
|
||||
return iax_ie_append_raw(ied, ie, &newval, (int) sizeof(newval));
|
||||
}
|
||||
|
||||
int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, const unsigned char *str)
|
||||
{
|
||||
return iax_ie_append_raw(ied, ie, str, (int)strlen((char *) str));
|
||||
return iax_ie_append_raw(ied, ie, str, (int) strlen((char *) str));
|
||||
}
|
||||
|
||||
int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat)
|
||||
@@ -477,17 +480,17 @@ int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char
|
||||
return iax_ie_append_raw(ied, ie, &dat, 1);
|
||||
}
|
||||
|
||||
int iax_ie_append(struct iax_ie_data *ied, unsigned char ie)
|
||||
int iax_ie_append(struct iax_ie_data *ied, unsigned char ie)
|
||||
{
|
||||
return iax_ie_append_raw(ied, ie, NULL, 0);
|
||||
}
|
||||
|
||||
void iax_set_output(void (*func)(const char *))
|
||||
void iax_set_output(void (*func) (const char *))
|
||||
{
|
||||
outputf = func;
|
||||
}
|
||||
|
||||
void iax_set_error(void (*func)(const char *))
|
||||
void iax_set_error(void (*func) (const char *))
|
||||
{
|
||||
errorf = func;
|
||||
}
|
||||
@@ -498,21 +501,21 @@ int iax_parse_ies(struct iax_ies *my_ies, unsigned char *data, int datalen)
|
||||
int len;
|
||||
int ie;
|
||||
char tmp[256];
|
||||
memset(my_ies, 0, (int)sizeof(struct iax_ies));
|
||||
memset(my_ies, 0, (int) sizeof(struct iax_ies));
|
||||
my_ies->msgcount = -1;
|
||||
my_ies->firmwarever = -1;
|
||||
my_ies->calling_ton = -1;
|
||||
my_ies->calling_tns = -1;
|
||||
my_ies->calling_pres = -1;
|
||||
my_ies->samprate = IAX_RATE_8KHZ;
|
||||
while(datalen >= 2) {
|
||||
while (datalen >= 2) {
|
||||
ie = data[0];
|
||||
len = data[1];
|
||||
if (len > datalen - 2) {
|
||||
errorf("Information element length exceeds message size\n");
|
||||
return -1;
|
||||
}
|
||||
switch(ie) {
|
||||
switch (ie) {
|
||||
case IAX_IE_CALLED_NUMBER:
|
||||
my_ies->called_number = (char *) data + 2;
|
||||
break;
|
||||
@@ -535,15 +538,15 @@ int iax_parse_ies(struct iax_ies *my_ies, unsigned char *data, int datalen)
|
||||
my_ies->password = (char *) data + 2;
|
||||
break;
|
||||
case IAX_IE_CAPABILITY:
|
||||
if (len != (int)sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expecting capability to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
|
||||
if (len != (int) sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expecting capability to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
|
||||
errorf(tmp);
|
||||
} else
|
||||
my_ies->capability = ntohl(get_uint32(data + 2));
|
||||
break;
|
||||
case IAX_IE_FORMAT:
|
||||
if (len != (int)sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expecting format to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
|
||||
if (len != (int) sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expecting format to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
|
||||
errorf(tmp);
|
||||
} else
|
||||
my_ies->format = ntohl(get_uint32(data + 2));
|
||||
@@ -555,22 +558,22 @@ int iax_parse_ies(struct iax_ies *my_ies, unsigned char *data, int datalen)
|
||||
my_ies->codec_prefs = (char *) data + 2;
|
||||
break;
|
||||
case IAX_IE_VERSION:
|
||||
if (len != (int)sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expecting version to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
|
||||
if (len != (int) sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expecting version to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
|
||||
errorf(tmp);
|
||||
} else
|
||||
my_ies->version = ntohs(get_uint16(data + 2));
|
||||
break;
|
||||
case IAX_IE_ADSICPE:
|
||||
if (len != (int)sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expecting adsicpe to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
|
||||
if (len != (int) sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expecting adsicpe to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
|
||||
errorf(tmp);
|
||||
} else
|
||||
my_ies->adsicpe = ntohs(get_uint16(data + 2));
|
||||
break;
|
||||
case IAX_IE_SAMPLINGRATE:
|
||||
if (len != (int)sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expecting samplingrate to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
|
||||
if (len != (int) sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expecting samplingrate to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
|
||||
errorf(tmp);
|
||||
} else
|
||||
my_ies->samprate = ntohs(get_uint16(data + 2));
|
||||
@@ -582,8 +585,8 @@ int iax_parse_ies(struct iax_ies *my_ies, unsigned char *data, int datalen)
|
||||
my_ies->rdnis = (char *) data + 2;
|
||||
break;
|
||||
case IAX_IE_AUTHMETHODS:
|
||||
if (len != (int)sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expecting authmethods to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
|
||||
if (len != (int) sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expecting authmethods to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
|
||||
errorf(tmp);
|
||||
} else
|
||||
my_ies->authmethods = ntohs(get_uint16(data + 2));
|
||||
@@ -598,25 +601,25 @@ int iax_parse_ies(struct iax_ies *my_ies, unsigned char *data, int datalen)
|
||||
my_ies->rsa_result = (char *) data + 2;
|
||||
break;
|
||||
case IAX_IE_APPARENT_ADDR:
|
||||
my_ies->apparent_addr = ((struct sockaddr_in *)(data + 2));
|
||||
my_ies->apparent_addr = ((struct sockaddr_in *) (data + 2));
|
||||
break;
|
||||
case IAX_IE_REFRESH:
|
||||
if (len != (int)sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expecting refresh to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
|
||||
if (len != (int) sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expecting refresh to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
|
||||
errorf(tmp);
|
||||
} else
|
||||
my_ies->refresh = ntohs(get_uint16(data + 2));
|
||||
break;
|
||||
case IAX_IE_DPSTATUS:
|
||||
if (len != (int)sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expecting dpstatus to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
|
||||
if (len != (int) sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expecting dpstatus to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
|
||||
errorf(tmp);
|
||||
} else
|
||||
my_ies->dpstatus = ntohs(get_uint16(data + 2));
|
||||
break;
|
||||
case IAX_IE_CALLNO:
|
||||
if (len != (int)sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expecting callno to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
|
||||
if (len != (int) sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expecting callno to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
|
||||
errorf(tmp);
|
||||
} else
|
||||
my_ies->callno = ntohs(get_uint16(data + 2));
|
||||
@@ -626,7 +629,7 @@ int iax_parse_ies(struct iax_ies *my_ies, unsigned char *data, int datalen)
|
||||
break;
|
||||
case IAX_IE_CAUSECODE:
|
||||
if (len != 1) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expecting causecode to be single byte but was %d\n", len);
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expecting causecode to be single byte but was %d\n", len);
|
||||
errorf(tmp);
|
||||
} else {
|
||||
my_ies->causecode = data[2];
|
||||
@@ -636,16 +639,16 @@ int iax_parse_ies(struct iax_ies *my_ies, unsigned char *data, int datalen)
|
||||
if (len == 1)
|
||||
my_ies->iax_unknown = data[2];
|
||||
else {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expected single byte Unknown command, but was %d long\n", len);
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expected single byte Unknown command, but was %d long\n", len);
|
||||
errorf(tmp);
|
||||
}
|
||||
break;
|
||||
case IAX_IE_MSGCOUNT:
|
||||
if (len != (int)sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expecting msgcount to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
|
||||
if (len != (int) sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expecting msgcount to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
|
||||
errorf(tmp);
|
||||
} else
|
||||
my_ies->msgcount = ntohs(get_uint16(data + 2));
|
||||
my_ies->msgcount = ntohs(get_uint16(data + 2));
|
||||
break;
|
||||
case IAX_IE_AUTOANSWER:
|
||||
my_ies->autoanswer = 1;
|
||||
@@ -654,25 +657,25 @@ int iax_parse_ies(struct iax_ies *my_ies, unsigned char *data, int datalen)
|
||||
my_ies->musiconhold = 1;
|
||||
break;
|
||||
case IAX_IE_TRANSFERID:
|
||||
if (len != (int)sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expecting transferid to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
|
||||
if (len != (int) sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expecting transferid to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
|
||||
errorf(tmp);
|
||||
} else
|
||||
my_ies->transferid = ntohl(get_uint32(data + 2));
|
||||
break;
|
||||
case IAX_IE_DATETIME:
|
||||
if (len != (int)sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expecting date/time to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
|
||||
if (len != (int) sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expecting date/time to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
|
||||
errorf(tmp);
|
||||
} else
|
||||
my_ies->datetime = ntohl(get_uint32(data + 2));
|
||||
break;
|
||||
case IAX_IE_FIRMWAREVER:
|
||||
if (len != (int)sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expecting firmwarever to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
|
||||
if (len != (int) sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expecting firmwarever to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
|
||||
errorf(tmp);
|
||||
} else
|
||||
my_ies->firmwarever = ntohs(get_uint16(data + 2));
|
||||
my_ies->firmwarever = ntohs(get_uint16(data + 2));
|
||||
break;
|
||||
case IAX_IE_DEVICETYPE:
|
||||
my_ies->devicetype = (char *) data + 2;
|
||||
@@ -681,19 +684,19 @@ int iax_parse_ies(struct iax_ies *my_ies, unsigned char *data, int datalen)
|
||||
my_ies->serviceident = (char *) data + 2;
|
||||
break;
|
||||
case IAX_IE_FWBLOCKDESC:
|
||||
if (len != (int)sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expected block desc to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
|
||||
if (len != (int) sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expected block desc to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
|
||||
errorf(tmp);
|
||||
} else
|
||||
my_ies->fwdesc = ntohl(get_uint32(data + 2));
|
||||
break;
|
||||
case IAX_IE_FWBLOCKDATA:
|
||||
my_ies->fwdata = data + 2;
|
||||
my_ies->fwdatalen = (unsigned char)len;
|
||||
my_ies->fwdatalen = (unsigned char) len;
|
||||
break;
|
||||
case IAX_IE_PROVVER:
|
||||
if (len != (int)sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expected provisioning version to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
|
||||
if (len != (int) sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expected provisioning version to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
|
||||
errorf(tmp);
|
||||
} else {
|
||||
my_ies->provverpres = 1;
|
||||
@@ -704,7 +707,7 @@ int iax_parse_ies(struct iax_ies *my_ies, unsigned char *data, int datalen)
|
||||
if (len == 1)
|
||||
my_ies->calling_pres = data[2];
|
||||
else {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expected single byte callingpres, but was %d long\n", len);
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expected single byte callingpres, but was %d long\n", len);
|
||||
errorf(tmp);
|
||||
}
|
||||
break;
|
||||
@@ -712,67 +715,67 @@ int iax_parse_ies(struct iax_ies *my_ies, unsigned char *data, int datalen)
|
||||
if (len == 1)
|
||||
my_ies->calling_ton = data[2];
|
||||
else {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expected single byte callington, but was %d long\n", len);
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expected single byte callington, but was %d long\n", len);
|
||||
errorf(tmp);
|
||||
}
|
||||
break;
|
||||
case IAX_IE_CALLINGTNS:
|
||||
if (len != (int)sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expecting callingtns to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
|
||||
if (len != (int) sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expecting callingtns to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
|
||||
errorf(tmp);
|
||||
} else
|
||||
my_ies->calling_tns = ntohs(get_uint16(data + 2));
|
||||
my_ies->calling_tns = ntohs(get_uint16(data + 2));
|
||||
break;
|
||||
case IAX_IE_RR_JITTER:
|
||||
if (len != (int)sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expected jitter rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
|
||||
if (len != (int) sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expected jitter rr to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
|
||||
errorf(tmp);
|
||||
} else {
|
||||
my_ies->rr_jitter = ntohl(get_uint32(data + 2));
|
||||
}
|
||||
break;
|
||||
case IAX_IE_RR_LOSS:
|
||||
if (len != (int)sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expected loss rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
|
||||
if (len != (int) sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expected loss rr to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
|
||||
errorf(tmp);
|
||||
} else {
|
||||
my_ies->rr_loss = ntohl(get_uint32(data + 2));
|
||||
}
|
||||
break;
|
||||
case IAX_IE_RR_PKTS:
|
||||
if (len != (int)sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expected packets rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
|
||||
if (len != (int) sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expected packets rr to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
|
||||
errorf(tmp);
|
||||
} else {
|
||||
my_ies->rr_pkts = ntohl(get_uint32(data + 2));
|
||||
}
|
||||
break;
|
||||
case IAX_IE_RR_DELAY:
|
||||
if (len != (int)sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expected loss rr to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
|
||||
if (len != (int) sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expected loss rr to be %d bytes long but was %d\n", (int) sizeof(unsigned short), len);
|
||||
errorf(tmp);
|
||||
} else {
|
||||
my_ies->rr_delay = ntohs(get_uint16(data + 2));
|
||||
}
|
||||
break;
|
||||
case IAX_IE_RR_DROPPED:
|
||||
if (len != (int)sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expected packets rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
|
||||
if (len != (int) sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expected packets rr to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
|
||||
errorf(tmp);
|
||||
} else {
|
||||
my_ies->rr_dropped = ntohl(get_uint32(data + 2));
|
||||
}
|
||||
break;
|
||||
case IAX_IE_RR_OOO:
|
||||
if (len != (int)sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expected packets rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
|
||||
if (len != (int) sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int) sizeof(tmp), "Expected packets rr to be %d bytes long but was %d\n", (int) sizeof(unsigned int), len);
|
||||
errorf(tmp);
|
||||
} else {
|
||||
my_ies->rr_ooo = ntohl(get_uint32(data + 2));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
snprintf(tmp, (int)sizeof(tmp), "Ignoring unknown information element '%s' (%d) of length %d\n", iax_ie2str(ie), ie, len);
|
||||
snprintf(tmp, (int) sizeof(tmp), "Ignoring unknown information element '%s' (%d) of length %d\n", iax_ie2str(ie), ie, len);
|
||||
outputf(tmp);
|
||||
}
|
||||
/* Overwrite information element with 0, to null terminate previous portion */
|
||||
@@ -793,20 +796,20 @@ void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f)
|
||||
{
|
||||
fr->af.frametype = f->frametype;
|
||||
fr->af.subclass = f->subclass;
|
||||
fr->af.mallocd = 0; /* Our frame is static relative to the container */
|
||||
fr->af.mallocd = 0; /* Our frame is static relative to the container */
|
||||
fr->af.datalen = f->datalen;
|
||||
fr->af.samples = f->samples;
|
||||
fr->af.offset = AST_FRIENDLY_OFFSET;
|
||||
fr->af.src = f->src;
|
||||
fr->af.data = fr->afdata;
|
||||
if (fr->af.datalen)
|
||||
if (fr->af.datalen)
|
||||
memcpy(fr->af.data, f->data, fr->af.datalen);
|
||||
}
|
||||
|
||||
struct iax_frame *iax_frame_new(int direction, int datalen)
|
||||
{
|
||||
struct iax_frame *fr;
|
||||
fr = malloc((int)sizeof(struct iax_frame) + datalen);
|
||||
fr = malloc((int) sizeof(struct iax_frame) + datalen);
|
||||
if (fr) {
|
||||
fr->direction = direction;
|
||||
fr->retrans = -1;
|
||||
@@ -835,6 +838,15 @@ void iax_frame_free(struct iax_frame *fr)
|
||||
frame_count--;
|
||||
}
|
||||
|
||||
int iax_get_frames(void) { return frame_count; }
|
||||
int iax_get_iframes(void) { return iframes; }
|
||||
int iax_get_oframes(void) { return oframes; }
|
||||
int iax_get_frames(void)
|
||||
{
|
||||
return frame_count;
|
||||
}
|
||||
int iax_get_iframes(void)
|
||||
{
|
||||
return iframes;
|
||||
}
|
||||
int iax_get_oframes(void)
|
||||
{
|
||||
return oframes;
|
||||
}
|
||||
@@ -32,9 +32,9 @@
|
||||
#define jb_dbg if (dbgf) dbgf
|
||||
|
||||
#ifdef DEEP_DEBUG
|
||||
#define jb_dbg2 if (dbgf) dbgf
|
||||
#define jb_dbg2 if (dbgf) dbgf
|
||||
#else
|
||||
#define jb_dbg2 if (0) dbgf
|
||||
#define jb_dbg2 if (0) dbgf
|
||||
#endif
|
||||
|
||||
#else
|
||||
@@ -60,17 +60,17 @@ void jb_setoutput(jb_output_function_t err, jb_output_function_t warn, jb_output
|
||||
dbgf = dbg;
|
||||
}
|
||||
|
||||
static void increment_losspct(jitterbuf *jb)
|
||||
static void increment_losspct(jitterbuf * jb)
|
||||
{
|
||||
jb->info.losspct = (100000 + 499 * jb->info.losspct)/500;
|
||||
jb->info.losspct = (100000 + 499 * jb->info.losspct) / 500;
|
||||
}
|
||||
|
||||
static void decrement_losspct(jitterbuf *jb)
|
||||
static void decrement_losspct(jitterbuf * jb)
|
||||
{
|
||||
jb->info.losspct = (499 * jb->info.losspct)/500;
|
||||
jb->info.losspct = (499 * jb->info.losspct) / 500;
|
||||
}
|
||||
|
||||
void jb_reset(jitterbuf *jb)
|
||||
void jb_reset(jitterbuf * jb)
|
||||
{
|
||||
/* only save settings */
|
||||
jb_conf s = jb->info.conf;
|
||||
@@ -82,11 +82,12 @@ void jb_reset(jitterbuf *jb)
|
||||
jb->info.silence_begin_ts = -1;
|
||||
}
|
||||
|
||||
jitterbuf * jb_new()
|
||||
jitterbuf *jb_new()
|
||||
{
|
||||
jitterbuf *jb = (jitterbuf *)malloc(sizeof(*jb));
|
||||
jitterbuf *jb = (jitterbuf *) malloc(sizeof(*jb));
|
||||
|
||||
if (!jb) return NULL;
|
||||
if (!jb)
|
||||
return NULL;
|
||||
|
||||
jb->info.conf.target_extra = JB_TARGET_EXTRA;
|
||||
|
||||
@@ -95,7 +96,7 @@ jitterbuf * jb_new()
|
||||
return jb;
|
||||
}
|
||||
|
||||
void jb_destroy(jitterbuf *jb)
|
||||
void jb_destroy(jitterbuf * jb)
|
||||
{
|
||||
jb_frame *frame;
|
||||
|
||||
@@ -116,7 +117,7 @@ void jb_destroy(jitterbuf *jb)
|
||||
#if 0
|
||||
static int longcmp(const void *a, const void *b)
|
||||
{
|
||||
return *(long *)a - *(long *)b;
|
||||
return *(long *) a - *(long *) b;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -124,7 +125,7 @@ static int longcmp(const void *a, const void *b)
|
||||
/* maybe later we can make the history buckets variable size, or something? */
|
||||
/* drop parameter determines whether we will drop outliers to minimize
|
||||
* delay */
|
||||
static int history_put(jitterbuf *jb, time_in_ms_t ts, time_in_ms_t now)
|
||||
static int history_put(jitterbuf * jb, time_in_ms_t ts, time_in_ms_t now)
|
||||
{
|
||||
time_in_ms_t delay = now - (ts - jb->info.resync_offset);
|
||||
time_in_ms_t threshold = 2 * jb->info.jitter + jb->info.conf.resync_threshold;
|
||||
@@ -144,9 +145,10 @@ static int history_put(jitterbuf *jb, time_in_ms_t ts, time_in_ms_t now)
|
||||
jb->hist_ptr = 0;
|
||||
jb->hist_maxbuf_valid = 0;
|
||||
|
||||
jb_warn("Resyncing the jb. last_delay %ld, this delay %ld, threshold %ld, new offset %ld\n", jb->info.last_delay, delay, threshold, ts - now);
|
||||
jb_warn("Resyncing the jb. last_delay %ld, this delay %ld, threshold %ld, new offset %ld\n", jb->info.last_delay, delay, threshold,
|
||||
ts - now);
|
||||
jb->info.resync_offset = ts - now;
|
||||
jb->info.last_delay = delay = 0; /* after resync, frame is right on time */
|
||||
jb->info.last_delay = delay = 0; /* after resync, frame is right on time */
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
@@ -176,18 +178,18 @@ static int history_put(jitterbuf *jb, time_in_ms_t ts, time_in_ms_t now)
|
||||
goto invalidate;
|
||||
|
||||
/* if the new delay would go into min */
|
||||
if (delay < jb->hist_minbuf[JB_HISTORY_MAXBUF_SZ-1])
|
||||
if (delay < jb->hist_minbuf[JB_HISTORY_MAXBUF_SZ - 1])
|
||||
goto invalidate;
|
||||
|
||||
/* or max.. */
|
||||
if (delay > jb->hist_maxbuf[JB_HISTORY_MAXBUF_SZ-1])
|
||||
if (delay > jb->hist_maxbuf[JB_HISTORY_MAXBUF_SZ - 1])
|
||||
goto invalidate;
|
||||
|
||||
/* or the kicked delay would be in min */
|
||||
if (kicked <= jb->hist_minbuf[JB_HISTORY_MAXBUF_SZ-1])
|
||||
if (kicked <= jb->hist_minbuf[JB_HISTORY_MAXBUF_SZ - 1])
|
||||
goto invalidate;
|
||||
|
||||
if (kicked >= jb->hist_maxbuf[JB_HISTORY_MAXBUF_SZ-1])
|
||||
if (kicked >= jb->hist_maxbuf[JB_HISTORY_MAXBUF_SZ - 1])
|
||||
goto invalidate;
|
||||
|
||||
/* if we got here, we don't need to invalidate, 'cause this delay didn't
|
||||
@@ -196,21 +198,21 @@ static int history_put(jitterbuf *jb, time_in_ms_t ts, time_in_ms_t now)
|
||||
/* end optimization */
|
||||
|
||||
|
||||
invalidate:
|
||||
invalidate:
|
||||
jb->hist_maxbuf_valid = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void history_calc_maxbuf(jitterbuf *jb)
|
||||
static void history_calc_maxbuf(jitterbuf * jb)
|
||||
{
|
||||
int i,j;
|
||||
int i, j;
|
||||
|
||||
if (jb->hist_ptr == 0)
|
||||
return;
|
||||
|
||||
|
||||
/* initialize maxbuf/minbuf to the latest value */
|
||||
for (i=0;i<JB_HISTORY_MAXBUF_SZ;i++) {
|
||||
for (i = 0; i < JB_HISTORY_MAXBUF_SZ; i++) {
|
||||
/*
|
||||
* jb->hist_maxbuf[i] = jb->history[(jb->hist_ptr-1) % JB_HISTORY_SZ];
|
||||
* jb->hist_minbuf[i] = jb->history[(jb->hist_ptr-1) % JB_HISTORY_SZ];
|
||||
@@ -225,14 +227,14 @@ static void history_calc_maxbuf(jitterbuf *jb)
|
||||
/* start at the beginning, or JB_HISTORY_SZ frames ago */
|
||||
i = (jb->hist_ptr > JB_HISTORY_SZ) ? (jb->hist_ptr - JB_HISTORY_SZ) : 0;
|
||||
|
||||
for (;i<jb->hist_ptr;i++) {
|
||||
time_in_ms_t toins = jb->history[i % JB_HISTORY_SZ];
|
||||
for (; i < jb->hist_ptr; i++) {
|
||||
time_in_ms_t toins = jb->history[i % JB_HISTORY_SZ];
|
||||
|
||||
/* if the maxbuf should get this */
|
||||
if (toins > jb->hist_maxbuf[JB_HISTORY_MAXBUF_SZ-1]) {
|
||||
if (toins > jb->hist_maxbuf[JB_HISTORY_MAXBUF_SZ - 1]) {
|
||||
|
||||
/* insertion-sort it into the maxbuf */
|
||||
for (j=0;j<JB_HISTORY_MAXBUF_SZ;j++) {
|
||||
for (j = 0; j < JB_HISTORY_MAXBUF_SZ; j++) {
|
||||
/* found where it fits */
|
||||
if (toins > jb->hist_maxbuf[j]) {
|
||||
/* move over */
|
||||
@@ -246,10 +248,10 @@ static void history_calc_maxbuf(jitterbuf *jb)
|
||||
}
|
||||
|
||||
/* if the minbuf should get this */
|
||||
if (toins < jb->hist_minbuf[JB_HISTORY_MAXBUF_SZ-1]) {
|
||||
if (toins < jb->hist_minbuf[JB_HISTORY_MAXBUF_SZ - 1]) {
|
||||
|
||||
/* insertion-sort it into the maxbuf */
|
||||
for (j=0;j<JB_HISTORY_MAXBUF_SZ;j++) {
|
||||
for (j = 0; j < JB_HISTORY_MAXBUF_SZ; j++) {
|
||||
/* found where it fits */
|
||||
if (toins < jb->hist_minbuf[j]) {
|
||||
/* move over */
|
||||
@@ -261,15 +263,14 @@ static void history_calc_maxbuf(jitterbuf *jb)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
int k;
|
||||
fprintf(stderr, "toins = %ld\n", toins);
|
||||
fprintf(stderr, "maxbuf =");
|
||||
for (k=0;k<JB_HISTORY_MAXBUF_SZ;k++)
|
||||
for (k = 0; k < JB_HISTORY_MAXBUF_SZ; k++)
|
||||
fprintf(stderr, "%ld ", jb->hist_maxbuf[k]);
|
||||
fprintf(stderr, "\nminbuf =");
|
||||
for (k=0;k<JB_HISTORY_MAXBUF_SZ;k++)
|
||||
for (k = 0; k < JB_HISTORY_MAXBUF_SZ; k++)
|
||||
fprintf(stderr, "%ld ", jb->hist_minbuf[k]);
|
||||
fprintf(stderr, "\n");
|
||||
#endif
|
||||
@@ -278,9 +279,9 @@ static void history_calc_maxbuf(jitterbuf *jb)
|
||||
jb->hist_maxbuf_valid = 1;
|
||||
}
|
||||
|
||||
static void history_get(jitterbuf *jb)
|
||||
static void history_get(jitterbuf * jb)
|
||||
{
|
||||
time_in_ms_t max, min, jitter;
|
||||
time_in_ms_t max, min, jitter;
|
||||
int index;
|
||||
int count;
|
||||
|
||||
@@ -312,16 +313,16 @@ static void history_get(jitterbuf *jb)
|
||||
/* these debug stmts compare the difference between looking at the absolute jitter, and the
|
||||
* values we get by throwing away the outliers */
|
||||
/*
|
||||
fprintf(stderr, "[%d] min=%d, max=%d, jitter=%d\n", index, min, max, jitter);
|
||||
fprintf(stderr, "[%d] min=%d, max=%d, jitter=%d\n", 0, jb->hist_minbuf[0], jb->hist_maxbuf[0], jb->hist_maxbuf[0]-jb->hist_minbuf[0]);
|
||||
*/
|
||||
fprintf(stderr, "[%d] min=%d, max=%d, jitter=%d\n", index, min, max, jitter);
|
||||
fprintf(stderr, "[%d] min=%d, max=%d, jitter=%d\n", 0, jb->hist_minbuf[0], jb->hist_maxbuf[0], jb->hist_maxbuf[0]-jb->hist_minbuf[0]);
|
||||
*/
|
||||
|
||||
jb->info.min = min;
|
||||
jb->info.jitter = jitter;
|
||||
}
|
||||
|
||||
/* returns 1 if frame was inserted into head of queue, 0 otherwise */
|
||||
static int queue_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, time_in_ms_t ts)
|
||||
static int queue_put(jitterbuf * jb, void *data, const enum jb_frame_type type, long ms, time_in_ms_t ts)
|
||||
{
|
||||
jb_frame *frame = jb->free;
|
||||
jb_frame *p;
|
||||
@@ -331,7 +332,7 @@ static int queue_put(jitterbuf *jb, void *data, const enum jb_frame_type type, l
|
||||
if (frame) {
|
||||
jb->free = frame->next;
|
||||
} else {
|
||||
frame = (jb_frame *)malloc(sizeof(*frame));
|
||||
frame = (jb_frame *) malloc(sizeof(*frame));
|
||||
if (!frame) {
|
||||
jb_err("cannot allocate frame\n");
|
||||
return 0;
|
||||
@@ -350,7 +351,7 @@ static int queue_put(jitterbuf *jb, void *data, const enum jb_frame_type type, l
|
||||
* jb->frames->prev points to the highest ts
|
||||
*/
|
||||
|
||||
if (!jb->frames) { /* queue is empty */
|
||||
if (!jb->frames) { /* queue is empty */
|
||||
jb->frames = frame;
|
||||
frame->next = frame;
|
||||
frame->prev = frame;
|
||||
@@ -371,7 +372,8 @@ static int queue_put(jitterbuf *jb, void *data, const enum jb_frame_type type, l
|
||||
p = jb->frames;
|
||||
|
||||
/* frame is out of order */
|
||||
if (resync_ts < p->prev->ts) jb->info.frames_ooo++;
|
||||
if (resync_ts < p->prev->ts)
|
||||
jb->info.frames_ooo++;
|
||||
|
||||
while (resync_ts < p->prev->ts && p->prev != jb->frames)
|
||||
p = p->prev;
|
||||
@@ -385,7 +387,7 @@ static int queue_put(jitterbuf *jb, void *data, const enum jb_frame_type type, l
|
||||
return head;
|
||||
}
|
||||
|
||||
static time_in_ms_t queue_next(jitterbuf *jb)
|
||||
static time_in_ms_t queue_next(jitterbuf * jb)
|
||||
{
|
||||
if (jb->frames)
|
||||
return jb->frames->ts;
|
||||
@@ -393,7 +395,7 @@ static time_in_ms_t queue_next(jitterbuf *jb)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static time_in_ms_t queue_last(jitterbuf *jb)
|
||||
static time_in_ms_t queue_last(jitterbuf * jb)
|
||||
{
|
||||
if (jb->frames)
|
||||
return jb->frames->prev->ts;
|
||||
@@ -401,7 +403,7 @@ static time_in_ms_t queue_last(jitterbuf *jb)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static jb_frame *_queue_get(jitterbuf *jb, time_in_ms_t ts, int all)
|
||||
static jb_frame *_queue_get(jitterbuf * jb, time_in_ms_t ts, int all)
|
||||
{
|
||||
jb_frame *frame;
|
||||
frame = jb->frames;
|
||||
@@ -436,46 +438,41 @@ static jb_frame *_queue_get(jitterbuf *jb, time_in_ms_t ts, int all)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static jb_frame *queue_get(jitterbuf *jb, time_in_ms_t ts)
|
||||
static jb_frame *queue_get(jitterbuf * jb, time_in_ms_t ts)
|
||||
{
|
||||
return _queue_get(jb,ts,0);
|
||||
return _queue_get(jb, ts, 0);
|
||||
}
|
||||
|
||||
static jb_frame *queue_getall(jitterbuf *jb)
|
||||
static jb_frame *queue_getall(jitterbuf * jb)
|
||||
{
|
||||
return _queue_get(jb,0,1);
|
||||
return _queue_get(jb, 0, 1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* some diagnostics */
|
||||
static void jb_dbginfo(jitterbuf *jb)
|
||||
static void jb_dbginfo(jitterbuf * jb)
|
||||
{
|
||||
if (dbgf == NULL)
|
||||
return;
|
||||
|
||||
jb_dbg("\njb info: fin=%ld fout=%ld flate=%ld flost=%ld fdrop=%ld fcur=%ld\n",
|
||||
jb->info.frames_in, jb->info.frames_out, jb->info.frames_late, jb->info.frames_lost, jb->info.frames_dropped, jb->info.frames_cur);
|
||||
jb->info.frames_in, jb->info.frames_out, jb->info.frames_late, jb->info.frames_lost, jb->info.frames_dropped, jb->info.frames_cur);
|
||||
|
||||
jb_dbg("jitter=%ld current=%ld target=%ld min=%ld sil=%d len=%d len/fcur=%ld\n",
|
||||
jb->info.jitter, jb->info.current, jb->info.target, jb->info.min, jb->info.silence_begin_ts, jb->info.current - jb->info.min,
|
||||
jb->info.frames_cur ? (jb->info.current - jb->info.min)/jb->info.frames_cur : -8);
|
||||
jb->info.jitter, jb->info.current, jb->info.target, jb->info.min, jb->info.silence_begin_ts, jb->info.current - jb->info.min,
|
||||
jb->info.frames_cur ? (jb->info.current - jb->info.min) / jb->info.frames_cur : -8);
|
||||
if (jb->info.frames_in > 0)
|
||||
jb_dbg("jb info: Loss PCT = %ld%%, Late PCT = %ld%%\n",
|
||||
jb->info.frames_lost * 100/(jb->info.frames_in + jb->info.frames_lost),
|
||||
jb->info.frames_late * 100/jb->info.frames_in);
|
||||
jb->info.frames_lost * 100 / (jb->info.frames_in + jb->info.frames_lost), jb->info.frames_late * 100 / jb->info.frames_in);
|
||||
jb_dbg("jb info: queue %d -> %d. last_ts %d (queue len: %d) last_ms %d\n",
|
||||
queue_next(jb),
|
||||
queue_last(jb),
|
||||
jb->info.next_voice_ts,
|
||||
queue_last(jb) - queue_next(jb),
|
||||
jb->info.last_voice_ms);
|
||||
queue_next(jb), queue_last(jb), jb->info.next_voice_ts, queue_last(jb) - queue_next(jb), jb->info.last_voice_ms);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEEP_DEBUG
|
||||
static void jb_chkqueue(jitterbuf *jb)
|
||||
static void jb_chkqueue(jitterbuf * jb)
|
||||
{
|
||||
int i=0;
|
||||
int i = 0;
|
||||
jb_frame *p = jb->frames;
|
||||
|
||||
if (!p) {
|
||||
@@ -483,17 +480,17 @@ static void jb_chkqueue(jitterbuf *jb)
|
||||
}
|
||||
|
||||
do {
|
||||
if (p->next == NULL) {
|
||||
if (p->next == NULL) {
|
||||
jb_err("Queue is BROKEN at item [%d]", i);
|
||||
}
|
||||
i++;
|
||||
p=p->next;
|
||||
p = p->next;
|
||||
} while (p->next != jb->frames);
|
||||
}
|
||||
|
||||
static void jb_dbgqueue(jitterbuf *jb)
|
||||
static void jb_dbgqueue(jitterbuf * jb)
|
||||
{
|
||||
int i=0;
|
||||
int i = 0;
|
||||
jb_frame *p = jb->frames;
|
||||
|
||||
jb_dbg("queue: ");
|
||||
@@ -505,14 +502,14 @@ static void jb_dbgqueue(jitterbuf *jb)
|
||||
|
||||
do {
|
||||
jb_dbg("[%d]=%ld ", i++, p->ts);
|
||||
p=p->next;
|
||||
p = p->next;
|
||||
} while (p->next != jb->frames);
|
||||
|
||||
jb_dbg("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, time_in_ms_t ts, time_in_ms_t now)
|
||||
enum jb_return_code jb_put(jitterbuf * jb, void *data, const enum jb_frame_type type, long ms, time_in_ms_t ts, time_in_ms_t now)
|
||||
{
|
||||
jb->info.frames_in++;
|
||||
|
||||
@@ -522,12 +519,12 @@ enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type t
|
||||
* sending retransmitted control frames with their awkward
|
||||
* timestamps through
|
||||
*/
|
||||
if (history_put(jb,ts,now))
|
||||
if (history_put(jb, ts, now))
|
||||
return JB_DROP;
|
||||
}
|
||||
|
||||
/* if put into head of queue, caller needs to reschedule */
|
||||
if (queue_put(jb,data,type,ms,ts)) {
|
||||
if (queue_put(jb, data, type, ms, ts)) {
|
||||
return JB_SCHED;
|
||||
}
|
||||
|
||||
@@ -535,7 +532,7 @@ enum jb_return_code jb_put(jitterbuf *jb, void *data, const enum jb_frame_type t
|
||||
}
|
||||
|
||||
|
||||
static enum jb_return_code _jb_get(jitterbuf *jb, jb_frame *frameout, time_in_ms_t now, long interpl)
|
||||
static enum jb_return_code _jb_get(jitterbuf * jb, jb_frame * frameout, time_in_ms_t now, long interpl)
|
||||
{
|
||||
jb_frame *frame;
|
||||
time_in_ms_t diff;
|
||||
@@ -557,7 +554,7 @@ static enum jb_return_code _jb_get(jitterbuf *jb, jb_frame *frameout, time_in_ms
|
||||
diff = jb->info.target - jb->info.current;
|
||||
|
||||
/* jb_warn("diff = %d lms=%d last = %d now = %d\n", diff, */
|
||||
/* jb->info.last_voice_ms, jb->info.last_adjustment, now); */
|
||||
/* jb->info.last_voice_ms, jb->info.last_adjustment, now); */
|
||||
|
||||
/* let's work on non-silent case first */
|
||||
if (!jb->info.silence_begin_ts) {
|
||||
@@ -565,8 +562,8 @@ static enum jb_return_code _jb_get(jitterbuf *jb, jb_frame *frameout, time_in_ms
|
||||
if ((diff > 0) &&
|
||||
/* we haven't grown in the delay length */
|
||||
(((jb->info.last_adjustment + JB_ADJUST_DELAY) < now) ||
|
||||
/* we need to grow more than the "length" we have left */
|
||||
(diff > queue_last(jb) - queue_next(jb)) ) ) {
|
||||
/* we need to grow more than the "length" we have left */
|
||||
(diff > queue_last(jb) - queue_next(jb)))) {
|
||||
/* grow by interp frame length */
|
||||
jb->info.current += interpl;
|
||||
jb->info.next_voice_ts += interpl;
|
||||
@@ -619,7 +616,7 @@ static enum jb_return_code _jb_get(jitterbuf *jb, jb_frame *frameout, time_in_ms
|
||||
jb->info.frames_lost--;
|
||||
jb_dbg("l");
|
||||
/*jb_warn("\nlate: wanted=%ld, this=%ld, next=%ld\n", jb->info.next_voice_ts - jb->info.current, frame->ts, queue_next(jb));
|
||||
jb_warninfo(jb); */
|
||||
jb_warninfo(jb); */
|
||||
return JB_DROP;
|
||||
}
|
||||
}
|
||||
@@ -633,9 +630,7 @@ static enum jb_return_code _jb_get(jitterbuf *jb, jb_frame *frameout, time_in_ms
|
||||
/* unless we don't have a frame, then shrink 1 frame */
|
||||
/* every 80ms (though perhaps we can shrink even faster */
|
||||
/* in this case) */
|
||||
if (diff < -jb->info.conf.target_extra &&
|
||||
((!frame && jb->info.last_adjustment + 80 < now) ||
|
||||
(jb->info.last_adjustment + 500 < now))) {
|
||||
if (diff < -jb->info.conf.target_extra && ((!frame && jb->info.last_adjustment + 80 < now) || (jb->info.last_adjustment + 500 < now))) {
|
||||
|
||||
jb->info.last_adjustment = now;
|
||||
jb->info.cnt_contig_interp = 0;
|
||||
@@ -677,11 +672,11 @@ static enum jb_return_code _jb_get(jitterbuf *jb, jb_frame *frameout, time_in_ms
|
||||
* lost frame get interpolated two or more times, when there was "room" to grow, so it might
|
||||
* be a bit of a bad idea overall */
|
||||
/*if (diff > -1 * jb->info.last_voice_ms) {
|
||||
jb->info.current += jb->info.last_voice_ms;
|
||||
jb->info.last_adjustment = now;
|
||||
jb_warn("g");
|
||||
return JB_INTERP;
|
||||
} */
|
||||
jb->info.current += jb->info.last_voice_ms;
|
||||
jb->info.last_adjustment = now;
|
||||
jb_warn("g");
|
||||
return JB_INTERP;
|
||||
} */
|
||||
jb->info.frames_lost++;
|
||||
increment_losspct(jb);
|
||||
jb->info.next_voice_ts += interpl;
|
||||
@@ -712,8 +707,7 @@ static enum jb_return_code _jb_get(jitterbuf *jb, jb_frame *frameout, time_in_ms
|
||||
/* jb->info.silence_begin_ts = 0; */
|
||||
|
||||
/* shrink interpl len every 10ms during silence */
|
||||
if (diff < -jb->info.conf.target_extra &&
|
||||
jb->info.last_adjustment + 10 <= now) {
|
||||
if (diff < -jb->info.conf.target_extra && jb->info.last_adjustment + 10 <= now) {
|
||||
jb->info.current -= interpl;
|
||||
jb->info.last_adjustment = now;
|
||||
}
|
||||
@@ -736,7 +730,7 @@ static enum jb_return_code _jb_get(jitterbuf *jb, jb_frame *frameout, time_in_ms
|
||||
jb->info.frames_lost--;
|
||||
jb_dbg("l");
|
||||
/*jb_warn("\nlate: wanted=%ld, this=%ld, next=%ld\n", jb->info.next_voice_ts - jb->info.current, frame->ts, queue_next(jb));
|
||||
jb_warninfo(jb); */
|
||||
jb_warninfo(jb); */
|
||||
return JB_DROP;
|
||||
} else {
|
||||
/* voice frame */
|
||||
@@ -754,7 +748,7 @@ static enum jb_return_code _jb_get(jitterbuf *jb, jb_frame *frameout, time_in_ms
|
||||
}
|
||||
}
|
||||
|
||||
time_in_ms_t jb_next(jitterbuf *jb)
|
||||
time_in_ms_t jb_next(jitterbuf * jb)
|
||||
{
|
||||
if (jb->info.silence_begin_ts) {
|
||||
if (jb->frames) {
|
||||
@@ -764,28 +758,28 @@ time_in_ms_t jb_next(jitterbuf *jb)
|
||||
if (jb->info.target - jb->info.current < -jb->info.conf.target_extra)
|
||||
return jb->info.last_adjustment + 10;
|
||||
return next + jb->info.target;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return JB_LONGMAX;
|
||||
} else {
|
||||
return jb->info.next_voice_ts;
|
||||
}
|
||||
}
|
||||
|
||||
enum jb_return_code jb_get(jitterbuf *jb, jb_frame *frameout, time_in_ms_t now, long interpl)
|
||||
enum jb_return_code jb_get(jitterbuf * jb, jb_frame * frameout, time_in_ms_t now, long interpl)
|
||||
{
|
||||
enum jb_return_code ret = _jb_get(jb, frameout, now, interpl);
|
||||
#if 0
|
||||
static int lastts=0;
|
||||
static int lastts = 0;
|
||||
int thists = ((ret == JB_OK) || (ret == JB_DROP)) ? frameout->ts : 0;
|
||||
jb_warn("jb_get(%x,%x,%ld) = %d (%d)\n", jb, frameout, now, ret, thists);
|
||||
if (thists && thists < lastts) jb_warn("XXXX timestamp roll-back!!!\n");
|
||||
if (thists && thists < lastts)
|
||||
jb_warn("XXXX timestamp roll-back!!!\n");
|
||||
lastts = thists;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
enum jb_return_code jb_getall(jitterbuf *jb, jb_frame *frameout)
|
||||
enum jb_return_code jb_getall(jitterbuf * jb, jb_frame * frameout)
|
||||
{
|
||||
jb_frame *frame;
|
||||
frame = queue_getall(jb);
|
||||
@@ -799,7 +793,7 @@ enum jb_return_code jb_getall(jitterbuf *jb, jb_frame *frameout)
|
||||
}
|
||||
|
||||
|
||||
enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats)
|
||||
enum jb_return_code jb_getinfo(jitterbuf * jb, jb_info * stats)
|
||||
{
|
||||
history_get(jb);
|
||||
|
||||
@@ -808,7 +802,7 @@ enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats)
|
||||
return JB_OK;
|
||||
}
|
||||
|
||||
enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf)
|
||||
enum jb_return_code jb_setconf(jitterbuf * jb, jb_conf * conf)
|
||||
{
|
||||
/* take selected settings from the struct */
|
||||
|
||||
@@ -817,10 +811,8 @@ enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf)
|
||||
jb->info.conf.max_contig_interp = conf->max_contig_interp;
|
||||
|
||||
/* -1 indicates use of the default JB_TARGET_EXTRA value */
|
||||
jb->info.conf.target_extra = ( conf->target_extra == -1 )
|
||||
? JB_TARGET_EXTRA
|
||||
: conf->target_extra
|
||||
;
|
||||
jb->info.conf.target_extra = (conf->target_extra == -1)
|
||||
? JB_TARGET_EXTRA : conf->target_extra;
|
||||
|
||||
/* update these to match new target_extra setting */
|
||||
jb->info.current = jb->info.conf.target_extra;
|
||||
@@ -828,5 +820,3 @@ enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf)
|
||||
|
||||
return JB_OK;
|
||||
}
|
||||
|
||||
|
||||
+150
-151
@@ -3,13 +3,13 @@
|
||||
|
||||
#ifdef FREEBSD
|
||||
# include <machine/endian.h>
|
||||
#elif defined(LINUX)
|
||||
#elif defined(LINUX)
|
||||
# include <endian.h>
|
||||
# include <features.h>
|
||||
# include <sys/types.h>
|
||||
#elif defined(SOLARIS)
|
||||
/* each solaris is different -- this won't work on 2.6 or 2.7 */
|
||||
# include <sys/isa_defs.h> /* Defines either _LITTLE_ENDIAN or _BIG_ENDIAN */
|
||||
# include <sys/isa_defs.h> /* Defines either _LITTLE_ENDIAN or _BIG_ENDIAN */
|
||||
# define __BIG_ENDIAN 4321
|
||||
# define __LITTLE_ENDIAN 1234
|
||||
# define BIG_ENDIAN 4321
|
||||
@@ -59,7 +59,7 @@
|
||||
* needed on buffers full of bytes, and then call MD5Final, which
|
||||
* will fill a supplied 16-byte array with the digest.
|
||||
*/
|
||||
#include <string.h> /* for memcpy() */
|
||||
#include <string.h> /* for memcpy() */
|
||||
#include "md5.h"
|
||||
|
||||
#ifndef HIGHFIRST
|
||||
@@ -73,13 +73,12 @@ void byteReverse(unsigned char *buf, unsigned longs);
|
||||
*/
|
||||
void byteReverse(unsigned char *buf, unsigned longs)
|
||||
{
|
||||
uint32 t;
|
||||
do {
|
||||
t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
|
||||
((unsigned) buf[1] << 8 | buf[0]);
|
||||
*(uint32 *) buf = t;
|
||||
buf += 4;
|
||||
} while (--longs);
|
||||
uint32 t;
|
||||
do {
|
||||
t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | ((unsigned) buf[1] << 8 | buf[0]);
|
||||
*(uint32 *) buf = t;
|
||||
buf += 4;
|
||||
} while (--longs);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -90,13 +89,13 @@ void byteReverse(unsigned char *buf, unsigned longs)
|
||||
*/
|
||||
void MD5Init(struct MD5Context *ctx)
|
||||
{
|
||||
ctx->buf[0] = 0x67452301;
|
||||
ctx->buf[1] = 0xefcdab89;
|
||||
ctx->buf[2] = 0x98badcfe;
|
||||
ctx->buf[3] = 0x10325476;
|
||||
ctx->buf[0] = 0x67452301;
|
||||
ctx->buf[1] = 0xefcdab89;
|
||||
ctx->buf[2] = 0x98badcfe;
|
||||
ctx->buf[3] = 0x10325476;
|
||||
|
||||
ctx->bits[0] = 0;
|
||||
ctx->bits[1] = 0;
|
||||
ctx->bits[0] = 0;
|
||||
ctx->bits[1] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -105,46 +104,46 @@ void MD5Init(struct MD5Context *ctx)
|
||||
*/
|
||||
void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
|
||||
{
|
||||
uint32 t;
|
||||
uint32 t;
|
||||
|
||||
/* Update bitcount */
|
||||
/* Update bitcount */
|
||||
|
||||
t = ctx->bits[0];
|
||||
if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
|
||||
ctx->bits[1]++; /* Carry from low to high */
|
||||
ctx->bits[1] += len >> 29;
|
||||
t = ctx->bits[0];
|
||||
if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
|
||||
ctx->bits[1]++; /* Carry from low to high */
|
||||
ctx->bits[1] += len >> 29;
|
||||
|
||||
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
|
||||
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
|
||||
|
||||
/* Handle any leading odd-sized chunks */
|
||||
/* Handle any leading odd-sized chunks */
|
||||
|
||||
if (t) {
|
||||
unsigned char *p = (unsigned char *) ctx->in + t;
|
||||
if (t) {
|
||||
unsigned char *p = (unsigned char *) ctx->in + t;
|
||||
|
||||
t = 64 - t;
|
||||
if (len < t) {
|
||||
memcpy(p, buf, len);
|
||||
return;
|
||||
t = 64 - t;
|
||||
if (len < t) {
|
||||
memcpy(p, buf, len);
|
||||
return;
|
||||
}
|
||||
memcpy(p, buf, t);
|
||||
byteReverse(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
buf += t;
|
||||
len -= t;
|
||||
}
|
||||
memcpy(p, buf, t);
|
||||
byteReverse(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
buf += t;
|
||||
len -= t;
|
||||
}
|
||||
/* Process data in 64-byte chunks */
|
||||
/* Process data in 64-byte chunks */
|
||||
|
||||
while (len >= 64) {
|
||||
memcpy(ctx->in, buf, 64);
|
||||
byteReverse(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
buf += 64;
|
||||
len -= 64;
|
||||
}
|
||||
while (len >= 64) {
|
||||
memcpy(ctx->in, buf, 64);
|
||||
byteReverse(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
buf += 64;
|
||||
len -= 64;
|
||||
}
|
||||
|
||||
/* Handle any remaining bytes of data. */
|
||||
/* Handle any remaining bytes of data. */
|
||||
|
||||
memcpy(ctx->in, buf, len);
|
||||
memcpy(ctx->in, buf, len);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -153,43 +152,43 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
|
||||
*/
|
||||
void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
|
||||
{
|
||||
unsigned count;
|
||||
unsigned char *p;
|
||||
unsigned count;
|
||||
unsigned char *p;
|
||||
|
||||
/* Compute number of bytes mod 64 */
|
||||
count = (ctx->bits[0] >> 3) & 0x3F;
|
||||
/* Compute number of bytes mod 64 */
|
||||
count = (ctx->bits[0] >> 3) & 0x3F;
|
||||
|
||||
/* Set the first char of padding to 0x80. This is safe since there is
|
||||
always at least one byte free */
|
||||
p = ctx->in + count;
|
||||
*p++ = 0x80;
|
||||
/* Set the first char of padding to 0x80. This is safe since there is
|
||||
always at least one byte free */
|
||||
p = ctx->in + count;
|
||||
*p++ = 0x80;
|
||||
|
||||
/* Bytes of padding needed to make 64 bytes */
|
||||
count = 64 - 1 - count;
|
||||
/* Bytes of padding needed to make 64 bytes */
|
||||
count = 64 - 1 - count;
|
||||
|
||||
/* Pad out to 56 mod 64 */
|
||||
if (count < 8) {
|
||||
/* Two lots of padding: Pad the first block to 64 bytes */
|
||||
memset(p, 0, count);
|
||||
byteReverse(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
|
||||
/* Now fill the next block with 56 bytes */
|
||||
memset(ctx->in, 0, 56);
|
||||
} else {
|
||||
/* Pad block to 56 bytes */
|
||||
memset(p, 0, count - 8);
|
||||
}
|
||||
byteReverse(ctx->in, 14);
|
||||
|
||||
/* Append length in bits and transform */
|
||||
((uint32 *) ctx->in)[14] = ctx->bits[0];
|
||||
((uint32 *) ctx->in)[15] = ctx->bits[1];
|
||||
|
||||
/* Pad out to 56 mod 64 */
|
||||
if (count < 8) {
|
||||
/* Two lots of padding: Pad the first block to 64 bytes */
|
||||
memset(p, 0, count);
|
||||
byteReverse(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
|
||||
/* Now fill the next block with 56 bytes */
|
||||
memset(ctx->in, 0, 56);
|
||||
} else {
|
||||
/* Pad block to 56 bytes */
|
||||
memset(p, 0, count - 8);
|
||||
}
|
||||
byteReverse(ctx->in, 14);
|
||||
|
||||
/* Append length in bits and transform */
|
||||
((uint32 *) ctx->in)[14] = ctx->bits[0];
|
||||
((uint32 *) ctx->in)[15] = ctx->bits[1];
|
||||
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
byteReverse((unsigned char *) ctx->buf, 4);
|
||||
memcpy(digest, ctx->buf, 16);
|
||||
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
|
||||
byteReverse((unsigned char *) ctx->buf, 4);
|
||||
memcpy(digest, ctx->buf, 16);
|
||||
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
|
||||
}
|
||||
|
||||
#ifndef ASM_MD5
|
||||
@@ -213,85 +212,85 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
|
||||
*/
|
||||
void MD5Transform(uint32 buf[4], uint32 const in[16])
|
||||
{
|
||||
register uint32 a, b, c, d;
|
||||
register uint32 a, b, c, d;
|
||||
|
||||
a = buf[0];
|
||||
b = buf[1];
|
||||
c = buf[2];
|
||||
d = buf[3];
|
||||
a = buf[0];
|
||||
b = buf[1];
|
||||
c = buf[2];
|
||||
d = buf[3];
|
||||
|
||||
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
|
||||
|
||||
MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
|
||||
|
||||
MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
|
||||
|
||||
MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
|
||||
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -110,14 +110,14 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_ip, globals.ip);
|
||||
|
||||
|
||||
static char *IAXNAMES[] = { "IAX_EVENT_CONNECT", "IAX_EVENT_ACCEPT", "IAX_EVENT_HANGUP", "IAX_EVENT_REJECT", "IAX_EVENT_VOICE",
|
||||
"IAX_EVENT_DTMF", "IAX_EVENT_TIMEOUT", "IAX_EVENT_LAGRQ", "IAX_EVENT_LAGRP", "IAX_EVENT_RINGA",
|
||||
"IAX_EVENT_PING", "IAX_EVENT_PONG", "IAX_EVENT_BUSY", "IAX_EVENT_ANSWER", "IAX_EVENT_IMAGE",
|
||||
"IAX_EVENT_AUTHRQ", "IAX_EVENT_AUTHRP", "IAX_EVENT_REGREQ", "IAX_EVENT_REGACK",
|
||||
"IAX_EVENT_URL", "IAX_EVENT_LDCOMPLETE", "IAX_EVENT_TRANSFER", "IAX_EVENT_DPREQ",
|
||||
"IAX_EVENT_DPREP", "IAX_EVENT_DIAL", "IAX_EVENT_QUELCH", "IAX_EVENT_UNQUELCH",
|
||||
"IAX_EVENT_UNLINK", "IAX_EVENT_LINKREJECT", "IAX_EVENT_TEXT", "IAX_EVENT_REGREJ",
|
||||
"IAX_EVENT_LINKURL", "IAX_EVENT_CNG", "IAX_EVENT_REREQUEST", "IAX_EVENT_TXREPLY",
|
||||
"IAX_EVENT_TXREJECT", "IAX_EVENT_TXACCEPT", "IAX_EVENT_TXREADY"
|
||||
"IAX_EVENT_DTMF", "IAX_EVENT_TIMEOUT", "IAX_EVENT_LAGRQ", "IAX_EVENT_LAGRP", "IAX_EVENT_RINGA",
|
||||
"IAX_EVENT_PING", "IAX_EVENT_PONG", "IAX_EVENT_BUSY", "IAX_EVENT_ANSWER", "IAX_EVENT_IMAGE",
|
||||
"IAX_EVENT_AUTHRQ", "IAX_EVENT_AUTHRP", "IAX_EVENT_REGREQ", "IAX_EVENT_REGACK",
|
||||
"IAX_EVENT_URL", "IAX_EVENT_LDCOMPLETE", "IAX_EVENT_TRANSFER", "IAX_EVENT_DPREQ",
|
||||
"IAX_EVENT_DPREP", "IAX_EVENT_DIAL", "IAX_EVENT_QUELCH", "IAX_EVENT_UNQUELCH",
|
||||
"IAX_EVENT_UNLINK", "IAX_EVENT_LINKREJECT", "IAX_EVENT_TEXT", "IAX_EVENT_REGREJ",
|
||||
"IAX_EVENT_LINKURL", "IAX_EVENT_CNG", "IAX_EVENT_REREQUEST", "IAX_EVENT_TXREPLY",
|
||||
"IAX_EVENT_TXREJECT", "IAX_EVENT_TXACCEPT", "IAX_EVENT_TXREADY"
|
||||
};
|
||||
|
||||
|
||||
@@ -129,24 +129,24 @@ struct ast_iana {
|
||||
|
||||
//999 means it's wrong nad i dont know the real one
|
||||
static struct ast_iana AST_IANA[] = { {AST_FORMAT_G723_1, 4, "g723.1"},
|
||||
{AST_FORMAT_GSM, 3, "gsm"},
|
||||
{AST_FORMAT_ULAW, 0, "ulaw"},
|
||||
{AST_FORMAT_ALAW, 8, "alaw"},
|
||||
{AST_FORMAT_G726, 999, "g726"},
|
||||
{AST_FORMAT_ADPCM, 999, "adpcm"},
|
||||
{AST_FORMAT_SLINEAR, 10, "slinear"},
|
||||
{AST_FORMAT_LPC10, 7, "lpc10"},
|
||||
{AST_FORMAT_G729A, 18, "g729"},
|
||||
{AST_FORMAT_SPEEX, 97, "speex"},
|
||||
{AST_FORMAT_SPEEX, 98, "speex"},
|
||||
{AST_FORMAT_ILBC, 102, "ilbc"},
|
||||
{AST_FORMAT_MAX_AUDIO, 999, ""},
|
||||
{AST_FORMAT_JPEG, 999, ""},
|
||||
{AST_FORMAT_PNG, 999, ""},
|
||||
{AST_FORMAT_H261, 999, ""},
|
||||
{AST_FORMAT_H263, 999, ""},
|
||||
{AST_FORMAT_MAX_VIDEO, 999, ""},
|
||||
{0, 0}
|
||||
{AST_FORMAT_GSM, 3, "gsm"},
|
||||
{AST_FORMAT_ULAW, 0, "ulaw"},
|
||||
{AST_FORMAT_ALAW, 8, "alaw"},
|
||||
{AST_FORMAT_G726, 999, "g726"},
|
||||
{AST_FORMAT_ADPCM, 999, "adpcm"},
|
||||
{AST_FORMAT_SLINEAR, 10, "slinear"},
|
||||
{AST_FORMAT_LPC10, 7, "lpc10"},
|
||||
{AST_FORMAT_G729A, 18, "g729"},
|
||||
{AST_FORMAT_SPEEX, 97, "speex"},
|
||||
{AST_FORMAT_SPEEX, 98, "speex"},
|
||||
{AST_FORMAT_ILBC, 102, "ilbc"},
|
||||
{AST_FORMAT_MAX_AUDIO, 999, ""},
|
||||
{AST_FORMAT_JPEG, 999, ""},
|
||||
{AST_FORMAT_PNG, 999, ""},
|
||||
{AST_FORMAT_H261, 999, ""},
|
||||
{AST_FORMAT_H263, 999, ""},
|
||||
{AST_FORMAT_MAX_VIDEO, 999, ""},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
static char *ast2str(int ast)
|
||||
@@ -214,7 +214,7 @@ typedef enum {
|
||||
IAX_QUERY = 2
|
||||
} iax_io_t;
|
||||
|
||||
static switch_status_t iax_set_codec(private_t * tech_pvt, struct iax_session *iax_session,
|
||||
static switch_status_t iax_set_codec(private_t *tech_pvt, struct iax_session *iax_session,
|
||||
unsigned int *format, unsigned int *cababilities, unsigned short *samprate, iax_io_t io)
|
||||
{
|
||||
char *dname = NULL;
|
||||
@@ -281,8 +281,8 @@ static switch_status_t iax_set_codec(private_t * tech_pvt, struct iax_session *i
|
||||
char pref_str[256] = "(";
|
||||
|
||||
for (x = 0; x < len; x++) {
|
||||
strncat(pref_str, ast2str(prefs[x]), sizeof(pref_str)-1);
|
||||
strncat(pref_str, x == len - 1 ? ")" : ",", sizeof(pref_str)-1);
|
||||
strncat(pref_str, ast2str(prefs[x]), sizeof(pref_str) - 1);
|
||||
strncat(pref_str, x == len - 1 ? ")" : ",", sizeof(pref_str) - 1);
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Codec Prefs Detected: %s\n", pref_str);
|
||||
@@ -439,7 +439,7 @@ static void iax_out_cb(const char *s)
|
||||
}
|
||||
}
|
||||
|
||||
static void tech_init(private_t * tech_pvt, switch_core_session_t *session)
|
||||
static void tech_init(private_t *tech_pvt, switch_core_session_t *session)
|
||||
{
|
||||
tech_pvt->read_frame.data = tech_pvt->databuf;
|
||||
tech_pvt->read_frame.buflen = sizeof(tech_pvt->databuf);
|
||||
@@ -619,7 +619,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
||||
cng:
|
||||
cng:
|
||||
data = (switch_byte_t *) tech_pvt->read_frame.data;
|
||||
data[0] = 65;
|
||||
data[1] = 0;
|
||||
@@ -791,7 +791,7 @@ switch_io_routines_t iax_io_routines = {
|
||||
/*.write_frame */ channel_write_frame,
|
||||
/*.kill_channel */ channel_kill_channel,
|
||||
/*.send_dtmf */ channel_send_dtmf,
|
||||
/*.receive_message*/ channel_receive_message,
|
||||
/*.receive_message */ channel_receive_message,
|
||||
/*.receive_event */ channel_receive_event
|
||||
};
|
||||
|
||||
@@ -867,7 +867,7 @@ static switch_status_t load_config(void)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t tech_media(private_t * tech_pvt, struct iax_event *iaxevent)
|
||||
static switch_status_t tech_media(private_t *tech_pvt, struct iax_event *iaxevent)
|
||||
{
|
||||
unsigned int cap = iax_session_get_capability(iaxevent->session);
|
||||
unsigned int format = iaxevent->ies.format;
|
||||
@@ -1025,8 +1025,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
|
||||
NULL,
|
||||
NULL,
|
||||
modname,
|
||||
iaxevent->ies.called_context,
|
||||
iaxevent->ies.called_number)) != 0) {
|
||||
iaxevent->ies.called_context, iaxevent->ies.called_number)) != 0) {
|
||||
char name[128];
|
||||
switch_snprintf(name, sizeof(name), "IAX/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
|
||||
switch_channel_set_name(channel, name);
|
||||
@@ -1062,7 +1061,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
|
||||
switch_clear_flag(tech_pvt, TFLAG_VOICE);
|
||||
switch_mutex_unlock(tech_pvt->flag_mutex);
|
||||
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hangup %s\n", switch_channel_get_name(channel));
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
|
||||
switch_channel_hangup(channel, iaxevent->etype == IAX_EVENT_HANGUP ? SWITCH_CAUSE_NORMAL_CLEARING : SWITCH_CAUSE_FACILITY_REJECTED);
|
||||
@@ -1102,7 +1101,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
|
||||
break;
|
||||
case IAX_EVENT_DTMF:
|
||||
if (channel) {
|
||||
switch_dtmf_t dtmf = { (char) iaxevent->subclass , switch_core_default_dtmf_duration(0) };
|
||||
switch_dtmf_t dtmf = { (char) iaxevent->subclass, switch_core_default_dtmf_duration(0) };
|
||||
if (globals.debug) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%c DTMF %s\n", dtmf.digit, switch_channel_get_name(channel));
|
||||
}
|
||||
@@ -1118,7 +1117,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
|
||||
break;
|
||||
}
|
||||
iax_event_free(iaxevent);
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
if (tech_pvt && tech_pvt->session) {
|
||||
switch_core_session_signal_unlock(tech_pvt->session);
|
||||
}
|
||||
|
||||
@@ -136,8 +136,8 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_hold_file, globals.hold_file);
|
||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_timer_name, globals.timer_name);
|
||||
#define is_master(t) switch_test_flag(t, TFLAG_MASTER)
|
||||
|
||||
static void add_pvt(private_t * tech_pvt, int master);
|
||||
static void remove_pvt(private_t * tech_pvt);
|
||||
static void add_pvt(private_t *tech_pvt, int master);
|
||||
static void remove_pvt(private_t *tech_pvt);
|
||||
static switch_status_t channel_on_init(switch_core_session_t *session);
|
||||
static switch_status_t channel_on_hangup(switch_core_session_t *session);
|
||||
static switch_status_t channel_on_routing(switch_core_session_t *session);
|
||||
@@ -234,7 +234,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
|
||||
|
||||
while (switch_channel_get_state(channel) == CS_INIT && !switch_test_flag(tech_pvt, TFLAG_ANSWER)) {
|
||||
switch_size_t olen = globals.timer.samples;
|
||||
|
||||
|
||||
if (switch_timestamp_now() - last >= waitsec) {
|
||||
char buf[512];
|
||||
switch_event_t *event;
|
||||
@@ -250,7 +250,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s\n", buf);
|
||||
last = switch_timestamp_now();
|
||||
}
|
||||
|
||||
|
||||
if (ring_file) {
|
||||
if (switch_core_timer_next(&globals.timer) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_core_file_close(&fh);
|
||||
@@ -324,7 +324,7 @@ static void deactivate_ring_device(void)
|
||||
|
||||
|
||||
|
||||
static void add_pvt(private_t * tech_pvt, int master)
|
||||
static void add_pvt(private_t *tech_pvt, int master)
|
||||
{
|
||||
private_t *tp;
|
||||
uint8_t in_list = 0;
|
||||
@@ -367,7 +367,7 @@ static void add_pvt(private_t * tech_pvt, int master)
|
||||
switch_mutex_unlock(globals.pvt_lock);
|
||||
}
|
||||
|
||||
static void remove_pvt(private_t * tech_pvt)
|
||||
static void remove_pvt(private_t *tech_pvt)
|
||||
{
|
||||
private_t *tp, *last = NULL;
|
||||
|
||||
@@ -485,8 +485,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
tech_pvt->hold_file,
|
||||
globals.read_codec.implementation->number_of_channels,
|
||||
globals.read_codec.implementation->actual_samples_per_second,
|
||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
|
||||
NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
tech_pvt->hold_file = NULL;
|
||||
goto cng;
|
||||
}
|
||||
@@ -500,12 +499,12 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
|
||||
goto hold;
|
||||
}
|
||||
cng:
|
||||
cng:
|
||||
switch_yield(globals.read_codec.implementation->microseconds_per_frame);
|
||||
*frame = &globals.cng_frame;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
hold:
|
||||
hold:
|
||||
{
|
||||
switch_size_t olen = globals.read_codec.implementation->samples_per_frame;
|
||||
if (switch_core_timer_next(&globals.timer) != SWITCH_STATUS_SUCCESS) {
|
||||
@@ -531,13 +530,12 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
|
||||
switch_mutex_lock(globals.device_lock);
|
||||
|
||||
get_samples:
|
||||
get_samples:
|
||||
|
||||
if ((samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data,
|
||||
globals.read_codec.implementation->samples_per_frame,
|
||||
&globals.timer)) == 0) {
|
||||
switch_yield(1000);
|
||||
goto get_samples;
|
||||
if ((samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data,
|
||||
globals.read_codec.implementation->samples_per_frame, &globals.timer)) == 0) {
|
||||
switch_yield(1000);
|
||||
goto get_samples;
|
||||
} else {
|
||||
globals.read_frame.datalen = samples * 2;
|
||||
globals.read_frame.samples = samples;
|
||||
@@ -576,8 +574,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
|
||||
|
||||
if (globals.audio_stream) {
|
||||
if (switch_test_flag((&globals), GFLAG_EAR)) {
|
||||
WriteAudioStream(globals.audio_stream, (short *) frame->data, (int) (frame->datalen / sizeof(SAMPLE)),
|
||||
&globals.timer);
|
||||
WriteAudioStream(globals.audio_stream, (short *) frame->data, (int) (frame->datalen / sizeof(SAMPLE)), &globals.timer);
|
||||
}
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -667,7 +664,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
||||
if (outbound_profile->destination_number && !strcasecmp(outbound_profile->destination_number, "auto_answer")) {
|
||||
switch_set_flag(tech_pvt, TFLAG_ANSWER);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh! no caller profile\n");
|
||||
switch_core_session_destroy(new_session);
|
||||
@@ -775,7 +772,7 @@ static switch_status_t load_config(void)
|
||||
globals.codec_ms = tmp;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"codec-ms must be multipe of 10 and less than %d, Using default of 20\n", SWITCH_MAX_INTERVAL);
|
||||
"codec-ms must be multipe of 10 and less than %d, Using default of 20\n", SWITCH_MAX_INTERVAL);
|
||||
}
|
||||
} else if (!strcmp(var, "dialplan")) {
|
||||
set_global_dialplan(val);
|
||||
@@ -936,7 +933,8 @@ static void PrintSupportedStandardSampleRates(const PaStreamParameters * inputPa
|
||||
int i, printCount, cr = 7;
|
||||
PaError err;
|
||||
static double standardSampleRates[] = { 8000.0, 9600.0, 11025.0, 12000.0, 16000.0, 22050.0, 24000.0, 32000.0,
|
||||
44100.0, 48000.0, 88200.0, 96000.0, 192000.0, -1};
|
||||
44100.0, 48000.0, 88200.0, 96000.0, 192000.0, -1
|
||||
};
|
||||
|
||||
printCount = cr;
|
||||
for (i = 0; standardSampleRates[i] > 0; i++) {
|
||||
@@ -1077,7 +1075,7 @@ static int dump_info(void)
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
error:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "An error occured while using the portaudio stream\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Error number: %d\n", err);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Error message: %s\n", Pa_GetErrorText(err));
|
||||
@@ -1140,7 +1138,7 @@ static switch_status_t engage_device(int sample_rate, int codec_ms)
|
||||
outputParameters.sampleFormat = SAMPLE_TYPE;
|
||||
outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
|
||||
outputParameters.hostApiSpecificStreamInfo = NULL;
|
||||
err = OpenAudioStream(&globals.audio_stream, &inputParameters, &outputParameters, sample_rate, paClipOff,
|
||||
err = OpenAudioStream(&globals.audio_stream, &inputParameters, &outputParameters, sample_rate, paClipOff,
|
||||
globals.read_codec.implementation->samples_per_frame);
|
||||
/* UNLOCKED ************************************************************************************************* */
|
||||
switch_mutex_unlock(globals.device_lock);
|
||||
@@ -1174,8 +1172,7 @@ static switch_status_t engage_ring_device(int sample_rate, int channels)
|
||||
outputParameters.sampleFormat = SAMPLE_TYPE;
|
||||
outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
|
||||
outputParameters.hostApiSpecificStreamInfo = NULL;
|
||||
err = OpenAudioStream(&globals.ring_stream, NULL, &outputParameters, sample_rate, paClipOff,
|
||||
globals.read_codec.implementation->samples_per_frame);
|
||||
err = OpenAudioStream(&globals.ring_stream, NULL, &outputParameters, sample_rate, paClipOff, globals.read_codec.implementation->samples_per_frame);
|
||||
/* UNLOCKED ************************************************************************************************* */
|
||||
switch_mutex_unlock(globals.device_lock);
|
||||
|
||||
@@ -1192,8 +1189,8 @@ static switch_status_t engage_ring_device(int sample_rate, int channels)
|
||||
static switch_status_t dtmf_call(char **argv, int argc, switch_stream_handle_t *stream)
|
||||
{
|
||||
char *dtmf_str = argv[0];
|
||||
switch_dtmf_t dtmf = {0, switch_core_default_dtmf_duration(0)};
|
||||
|
||||
switch_dtmf_t dtmf = { 0, switch_core_default_dtmf_duration(0) };
|
||||
|
||||
if (switch_strlen_zero(dtmf_str)) {
|
||||
stream->write_function(stream, "No DTMF Supplied!\n");
|
||||
} else {
|
||||
@@ -1201,7 +1198,7 @@ static switch_status_t dtmf_call(char **argv, int argc, switch_stream_handle_t *
|
||||
if (globals.call_list) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(globals.call_list->session);
|
||||
char *p = dtmf_str;
|
||||
while(p && *p) {
|
||||
while (p && *p) {
|
||||
dtmf.digit = *p;
|
||||
switch_channel_queue_dtmf(channel, &dtmf);
|
||||
p++;
|
||||
@@ -1253,7 +1250,7 @@ static switch_status_t switch_call(char **argv, int argc, switch_stream_handle_t
|
||||
stream->write_function(stream, "NO SUCH CALL\n");
|
||||
}
|
||||
|
||||
done:
|
||||
done:
|
||||
switch_mutex_unlock(globals.pvt_lock);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -1317,7 +1314,7 @@ static switch_status_t answer_call(char **argv, int argc, switch_stream_handle_t
|
||||
break;
|
||||
}
|
||||
}
|
||||
done:
|
||||
done:
|
||||
switch_mutex_unlock(globals.pvt_lock);
|
||||
stream->write_function(stream, "Answered %d channels.\n", x);
|
||||
|
||||
@@ -1368,7 +1365,7 @@ static switch_status_t do_flags(char **argv, int argc, switch_stream_handle_t *s
|
||||
goto bad;
|
||||
}
|
||||
|
||||
desc:
|
||||
desc:
|
||||
x = 0;
|
||||
stream->write_function(stream, "FLAGS: ");
|
||||
if (switch_test_flag((&globals), GFLAG_EAR)) {
|
||||
@@ -1385,9 +1382,9 @@ static switch_status_t do_flags(char **argv, int argc, switch_stream_handle_t *s
|
||||
|
||||
goto done;
|
||||
|
||||
bad:
|
||||
bad:
|
||||
stream->write_function(stream, "Usage: flags [on|off] <flags>\n");
|
||||
done:
|
||||
done:
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1474,20 +1471,18 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
|
||||
if (!switch_strlen_zero(argv[4])) {
|
||||
tech_pvt->sample_rate = atoi(argv[4]);
|
||||
}
|
||||
|
||||
|
||||
if (!switch_strlen_zero(argv[5])) {
|
||||
tech_pvt->codec_ms = atoi(argv[5]);
|
||||
}
|
||||
|
||||
|
||||
switch_find_local_ip(ip, sizeof(ip), AF_INET);
|
||||
|
||||
if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
|
||||
NULL, dialplan, cid_name, cid_num,
|
||||
ip, NULL, NULL, NULL, modname, NULL,
|
||||
dest)) != 0) {
|
||||
NULL, dialplan, cid_name, cid_num, ip, NULL, NULL, NULL, modname, NULL, dest)) != 0) {
|
||||
char name[128];
|
||||
switch_snprintf(name, sizeof(name), "PortAudio/%s",
|
||||
tech_pvt->caller_profile->destination_number ? tech_pvt->caller_profile->destination_number : modname);
|
||||
tech_pvt->caller_profile->destination_number ? tech_pvt->caller_profile->destination_number : modname);
|
||||
switch_channel_set_name(channel, name);
|
||||
|
||||
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
|
||||
@@ -1498,7 +1493,7 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t
|
||||
switch_channel_mark_answered(channel);
|
||||
switch_channel_set_state(channel, CS_INIT);
|
||||
if (switch_core_session_thread_launch(tech_pvt->session) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n");
|
||||
switch_core_session_destroy(&session);
|
||||
stream->write_function(stream, "FAIL:Thread Error!\n");
|
||||
} else {
|
||||
@@ -1674,7 +1669,7 @@ SWITCH_STANDARD_API(pa_cmd)
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
done:
|
||||
if (http) {
|
||||
stream->write_function(stream,
|
||||
"<br><br><table align=center><tr><td><center><form method=post>\n"
|
||||
@@ -1691,25 +1686,18 @@ SWITCH_STANDARD_API(pa_cmd)
|
||||
"<td><input name=action type=submit value=\"2\"></td>"
|
||||
"<td><input name=action type=submit value=\"3\"></td>\n"
|
||||
"<td><input name=action type=submit value=\"A\"></td></tr>\n"
|
||||
|
||||
"<tr><td><input name=action type=submit value=\"4\"></td>"
|
||||
"<td><input name=action type=submit value=\"5\"></td>"
|
||||
"<td><input name=action type=submit value=\"6\"></td>\n"
|
||||
"<td><input name=action type=submit value=\"B\"></td></tr>\n"
|
||||
|
||||
"<tr><td><input name=action type=submit value=\"7\"></td>"
|
||||
"<td><input name=action type=submit value=\"8\"></td>"
|
||||
"<td><input name=action type=submit value=\"9\"></td>\n"
|
||||
"<td><input name=action type=submit value=\"C\"></td></tr>\n"
|
||||
|
||||
"<tr><td><input name=action type=submit value=\"*\"></td>"
|
||||
"<td><input name=action type=submit value=\"0\"></td>"
|
||||
"<td><input name=action type=submit value=\"#\"></td>\n"
|
||||
"<td><input name=action type=submit value=\"D\"></td></tr>\n"
|
||||
"</table>"
|
||||
|
||||
"</form><br></center></td></tr></table>\n"
|
||||
);
|
||||
"<td><input name=action type=submit value=\"D\"></td></tr>\n" "</table>" "</form><br></center></td></tr></table>\n");
|
||||
}
|
||||
|
||||
switch_safe_free(mycmd);
|
||||
|
||||
@@ -72,7 +72,7 @@ static int blockingIOCallback(const void *inputBuffer, void *outputBuffer,
|
||||
{
|
||||
PABLIO_Stream *data = (PABLIO_Stream *) userData;
|
||||
long numBytes = data->bytesPerFrame * framesPerBuffer;
|
||||
|
||||
|
||||
/* This may get called with NULL inputBuffer during initial setup. */
|
||||
if (inputBuffer != NULL) {
|
||||
if (PaUtil_WriteRingBuffer(&data->inFIFO, inputBuffer, numBytes) != numBytes) {
|
||||
@@ -146,26 +146,26 @@ long ReadAudioStream(PABLIO_Stream * aStream, void *data, long numFrames, switch
|
||||
long bytesRead = 0;
|
||||
char *p = (char *) data;
|
||||
long avail, totalBytes = 0, neededBytes = aStream->bytesPerFrame * numFrames;
|
||||
|
||||
for(;;) {
|
||||
|
||||
for (;;) {
|
||||
avail = PaUtil_GetRingBufferReadAvailable(&aStream->inFIFO);
|
||||
|
||||
|
||||
if (switch_core_timer_check(timer, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (avail >= neededBytes * 6) {
|
||||
|
||||
if (avail >= neededBytes * 6) {
|
||||
PaUtil_FlushRingBuffer(&aStream->inFIFO);
|
||||
avail = 0;
|
||||
}
|
||||
|
||||
|
||||
bytesRead = 0;
|
||||
|
||||
if (totalBytes < neededBytes && avail >= neededBytes) {
|
||||
bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, neededBytes);
|
||||
totalBytes += bytesRead;
|
||||
}
|
||||
|
||||
|
||||
if (bytesRead) {
|
||||
p += bytesRead;
|
||||
} else {
|
||||
@@ -201,7 +201,7 @@ static unsigned long RoundUpToNextPowerOf2(unsigned long n)
|
||||
{
|
||||
long numBits = 0;
|
||||
if (((n - 1) & n) == 0)
|
||||
return n;
|
||||
return n;
|
||||
while (n > 0) {
|
||||
n = n >> 1;
|
||||
numBits++;
|
||||
@@ -217,11 +217,8 @@ static unsigned long RoundUpToNextPowerOf2(unsigned long n)
|
||||
*
|
||||
*/
|
||||
PaError OpenAudioStream(PABLIO_Stream ** rwblPtr,
|
||||
const PaStreamParameters *inputParameters,
|
||||
const PaStreamParameters *outputParameters,
|
||||
double sampleRate,
|
||||
PaStreamFlags streamFlags,
|
||||
long samples_per_frame)
|
||||
const PaStreamParameters * inputParameters,
|
||||
const PaStreamParameters * outputParameters, double sampleRate, PaStreamFlags streamFlags, long samples_per_frame)
|
||||
{
|
||||
long bytesPerSample = 2;
|
||||
PaError err;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_reference_load);
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_reference_shutdown);
|
||||
//SWITCH_MODULE_RUNTIME_FUNCTION(mod_reference_runtime);
|
||||
SWITCH_MODULE_DEFINITION(mod_reference, mod_reference_load, mod_reference_shutdown, NULL);//mod_reference_runtime);
|
||||
SWITCH_MODULE_DEFINITION(mod_reference, mod_reference_load, mod_reference_shutdown, NULL); //mod_reference_runtime);
|
||||
|
||||
|
||||
switch_endpoint_interface_t *reference_endpoint_interface;
|
||||
@@ -112,7 +112,7 @@ static switch_status_t channel_kill_channel(switch_core_session_t *session, int
|
||||
|
||||
|
||||
|
||||
static void tech_init(private_t * tech_pvt, switch_core_session_t *session)
|
||||
static void tech_init(private_t *tech_pvt, switch_core_session_t *session)
|
||||
{
|
||||
tech_pvt->read_frame.data = tech_pvt->databuf;
|
||||
tech_pvt->read_frame.buflen = sizeof(tech_pvt->databuf);
|
||||
@@ -140,9 +140,9 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_IO);
|
||||
|
||||
/* Move channel's state machine to ROUTING. This means the call is trying
|
||||
to get from the initial start where the call because, to the point
|
||||
where a destination has been identified. If the channel is simply
|
||||
left in the initial state, nothing will happen. */
|
||||
to get from the initial start where the call because, to the point
|
||||
where a destination has been identified. If the channel is simply
|
||||
left in the initial state, nothing will happen. */
|
||||
switch_channel_set_state(channel, CS_ROUTING);
|
||||
switch_mutex_lock(globals.mutex);
|
||||
globals.calls++;
|
||||
@@ -315,7 +315,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
||||
cng:
|
||||
cng:
|
||||
data = (switch_byte_t *) tech_pvt->read_frame.data;
|
||||
data[0] = 65;
|
||||
data[1] = 0;
|
||||
@@ -346,7 +346,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
|
||||
switch_swap_linear(frame->data, (int) frame->datalen / 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
@@ -363,7 +363,7 @@ static switch_status_t channel_answer_channel(switch_core_session_t *session)
|
||||
tech_pvt = switch_core_session_get_private(session);
|
||||
assert(tech_pvt != NULL);
|
||||
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
|
||||
|
||||
tech_pvt = (private_t *) switch_core_session_get_private(session);
|
||||
assert(tech_pvt != NULL);
|
||||
|
||||
@@ -471,7 +471,7 @@ switch_io_routines_t reference_io_routines = {
|
||||
/*.write_frame */ channel_write_frame,
|
||||
/*.kill_channel */ channel_kill_channel,
|
||||
/*.send_dtmf */ channel_send_dtmf,
|
||||
/*.receive_message*/ channel_receive_message,
|
||||
/*.receive_message */ channel_receive_message,
|
||||
/*.receive_event */ channel_receive_event
|
||||
};
|
||||
|
||||
@@ -531,7 +531,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_reference_load)
|
||||
{
|
||||
|
||||
module_pool = pool;
|
||||
|
||||
|
||||
load_config();
|
||||
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
@@ -540,7 +540,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_reference_load)
|
||||
reference_endpoint_interface->io_routines = &reference_io_routines;
|
||||
reference_endpoint_interface->state_handler = &reference_state_handlers;
|
||||
|
||||
|
||||
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
@@ -98,14 +98,14 @@ static switch_status_t sofia_on_init(switch_core_session_t *session)
|
||||
|
||||
if (sofia_glue_do_invite(session) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
assert( switch_channel_get_state(channel) != CS_INIT);
|
||||
assert(switch_channel_get_state(channel) != CS_INIT);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Move channel's state machine to ROUTING */
|
||||
switch_channel_set_state(channel, CS_ROUTING);
|
||||
assert( switch_channel_get_state(channel) != CS_INIT);
|
||||
assert(switch_channel_get_state(channel) != CS_INIT);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ static switch_status_t sofia_on_routing(switch_core_session_t *session)
|
||||
switch_assert(tech_pvt != NULL);
|
||||
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA ROUTING\n", switch_channel_get_name(switch_core_session_get_channel(session)));
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -128,7 +128,7 @@ static switch_status_t sofia_on_reset(switch_core_session_t *session)
|
||||
switch_assert(tech_pvt != NULL);
|
||||
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA RESET\n", switch_channel_get_name(switch_core_session_get_channel(session)));
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -141,7 +141,7 @@ static switch_status_t sofia_on_hibernate(switch_core_session_t *session)
|
||||
switch_assert(tech_pvt != NULL);
|
||||
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA HIBERNATE\n", switch_channel_get_name(switch_core_session_get_channel(session)));
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -160,7 +160,7 @@ static switch_status_t sofia_on_execute(switch_core_session_t *session)
|
||||
|
||||
/* map QSIG cause codes to SIP from RFC4497 section 8.4.1 */
|
||||
static int hangup_cause_to_sip(switch_call_cause_t cause)
|
||||
{
|
||||
{
|
||||
switch (cause) {
|
||||
case SWITCH_CAUSE_NO_ROUTE_TRANSIT_NET:
|
||||
case SWITCH_CAUSE_NO_ROUTE_DESTINATION:
|
||||
@@ -223,11 +223,11 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
|
||||
switch_call_cause_t cause = switch_channel_get_cause(channel);
|
||||
int sip_cause = hangup_cause_to_sip(cause);
|
||||
const char *ps_cause = switch_channel_get_variable(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE);
|
||||
|
||||
|
||||
if (!switch_strlen_zero(ps_cause) && !strncasecmp(ps_cause, "sip:", 4)) {
|
||||
int new_cause = atoi(ps_cause + 4);
|
||||
if (new_cause) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Overriding SIP cause %d with %d from the other leg\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Overriding SIP cause %d with %d from the other leg\n",
|
||||
switch_channel_get_name(channel), sip_cause, new_cause);
|
||||
sip_cause = new_cause;
|
||||
}
|
||||
@@ -262,7 +262,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
|
||||
sofia_glue_deactivate_rtp(tech_pvt);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel %s hanging up, cause: %s\n",
|
||||
switch_channel_get_name(channel), switch_channel_cause2str(cause));
|
||||
switch_channel_get_name(channel), switch_channel_cause2str(cause));
|
||||
|
||||
if (tech_pvt->hash_key) {
|
||||
switch_core_hash_delete(tech_pvt->profile->chat_hash, tech_pvt->hash_key);
|
||||
@@ -282,7 +282,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
|
||||
|
||||
switch_mutex_lock(tech_pvt->profile->flag_mutex);
|
||||
|
||||
if (tech_pvt->nh && !switch_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
if (tech_pvt->nh && !switch_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
char reason[128] = "";
|
||||
if (cause > 1 && cause < 128) {
|
||||
switch_snprintf(reason, sizeof(reason), "Q.850;cause=%d;text=\"%s\"", cause, switch_channel_cause2str(cause));
|
||||
@@ -291,7 +291,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
|
||||
} else {
|
||||
switch_snprintf(reason, sizeof(reason), "FreeSWITCH;cause=%d;text=\"%s\"", cause, switch_channel_cause2str(cause));
|
||||
}
|
||||
|
||||
|
||||
if (switch_test_flag(tech_pvt, TFLAG_ANS)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending BYE to %s\n", switch_channel_get_name(channel));
|
||||
nua_bye(tech_pvt->nh, SIPTAG_REASON_STR(reason), TAG_END());
|
||||
@@ -349,7 +349,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
|
||||
|
||||
b_sdp = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE);
|
||||
is_proxy = (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA));
|
||||
|
||||
|
||||
if (b_sdp && is_proxy) {
|
||||
tech_pvt->local_sdp_str = switch_core_session_strdup(session, b_sdp);
|
||||
|
||||
@@ -373,7 +373,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
|
||||
const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
|
||||
tech_pvt->num_codecs = 0;
|
||||
sofia_glue_tech_prepare_codecs(tech_pvt);
|
||||
|
||||
|
||||
if (sofia_glue_tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
|
||||
//nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
|
||||
@@ -394,8 +394,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
|
||||
|
||||
if (tech_pvt->nh) {
|
||||
if (tech_pvt->local_sdp_str) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Local SDP %s:\n%s\n", switch_channel_get_name(channel),
|
||||
tech_pvt->local_sdp_str);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Local SDP %s:\n%s\n", switch_channel_get_name(channel), tech_pvt->local_sdp_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -406,16 +405,16 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
|
||||
session_timeout = v_session_timeout;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (switch_test_flag(tech_pvt, TFLAG_NAT) ||
|
||||
(val = switch_channel_get_variable(channel, "sip-force-contact")) ||
|
||||
(val = switch_channel_get_variable(channel, "sip-force-contact")) ||
|
||||
((val = switch_channel_get_variable(channel, "sip_sticky_contact")) && switch_true(val))) {
|
||||
sticky = tech_pvt->record_route;
|
||||
session_timeout = SOFIA_NAT_SESSION_TIMEOUT;
|
||||
switch_channel_set_variable(channel, "sip_nat_detected", "true");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
nua_respond(tech_pvt->nh, SIP_200_OK,
|
||||
NUTAG_AUTOANSWER(0),
|
||||
@@ -423,11 +422,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
|
||||
NUTAG_SESSION_TIMER(session_timeout),
|
||||
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
|
||||
SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
|
||||
SOATAG_REUSE_REJECTED(1),
|
||||
SOATAG_ORDERED_USER(1),
|
||||
SOATAG_AUDIO_AUX("cn telephone-event"),
|
||||
NUTAG_INCLUDE_EXTRA_SDP(1),
|
||||
TAG_END());
|
||||
SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END());
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -474,7 +469,7 @@ static switch_status_t sofia_read_video_frame(switch_core_session_t *session, sw
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
payload = tech_pvt->video_read_frame.payload;
|
||||
|
||||
if (tech_pvt->video_read_frame.datalen > 0) {
|
||||
@@ -524,13 +519,13 @@ static switch_status_t sofia_write_video_frame(switch_core_session_t *session, s
|
||||
if (!switch_test_flag(frame, SFF_CNG)) {
|
||||
switch_rtp_write_frame(tech_pvt->video_rtp_session, frame);
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
|
||||
{
|
||||
private_object_t *tech_pvt = switch_core_session_get_private(session);
|
||||
private_object_t *tech_pvt = switch_core_session_get_private(session);
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
int payload = 0;
|
||||
|
||||
@@ -558,7 +553,7 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
|
||||
|
||||
if (switch_test_flag(tech_pvt, TFLAG_IO)) {
|
||||
switch_status_t status;
|
||||
|
||||
|
||||
if (!switch_test_flag(tech_pvt, TFLAG_RTP)) {
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
@@ -570,22 +565,22 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
|
||||
tech_pvt->read_frame.flags = SFF_NONE;
|
||||
|
||||
status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame, flags);
|
||||
|
||||
|
||||
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
|
||||
if (status == SWITCH_STATUS_TIMEOUT) {
|
||||
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_MEDIA_TIMEOUT);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
payload = tech_pvt->read_frame.payload;
|
||||
|
||||
if (switch_rtp_has_dtmf(tech_pvt->rtp_session)) {
|
||||
switch_dtmf_t dtmf = {0};
|
||||
switch_dtmf_t dtmf = { 0 };
|
||||
switch_rtp_dequeue_dtmf(tech_pvt->rtp_session, &dtmf);
|
||||
switch_channel_queue_dtmf(channel, &dtmf);
|
||||
}
|
||||
|
||||
|
||||
if (tech_pvt->read_frame.datalen > 0) {
|
||||
size_t bytes = 0;
|
||||
int frames = 1;
|
||||
@@ -712,10 +707,7 @@ static switch_status_t sofia_send_dtmf(switch_core_session_t *session, const swi
|
||||
|
||||
case DTMF_INFO:
|
||||
snprintf(message, sizeof(message), "Signal=%c\r\nDuration=%d\r\n", dtmf->digit, dtmf->duration / 8);
|
||||
nua_info(tech_pvt->nh,
|
||||
SIPTAG_CONTENT_TYPE_STR("application/dtmf-relay"),
|
||||
SIPTAG_PAYLOAD_STR(message),
|
||||
TAG_END());
|
||||
nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("application/dtmf-relay"), SIPTAG_PAYLOAD_STR(message), TAG_END());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -750,18 +742,11 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
" <media_control>\r\n"
|
||||
" <vc_primitive>\r\n"
|
||||
" <to_encoder>\r\n"
|
||||
" <picture_fast_update>\r\n"
|
||||
" </picture_fast_update>\r\n"
|
||||
" </to_encoder>\r\n"
|
||||
" </vc_primitive>\r\n"
|
||||
" </media_control>\r\n";
|
||||
|
||||
nua_info(tech_pvt->nh,
|
||||
SIPTAG_CONTENT_TYPE_STR("application/media_control+xml"),
|
||||
SIPTAG_PAYLOAD_STR(pl),
|
||||
TAG_END());
|
||||
" <picture_fast_update>\r\n" " </picture_fast_update>\r\n" " </to_encoder>\r\n" " </vc_primitive>\r\n" " </media_control>\r\n";
|
||||
|
||||
nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("application/media_control+xml"), SIPTAG_PAYLOAD_STR(pl), TAG_END());
|
||||
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY:
|
||||
@@ -770,31 +755,27 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833);
|
||||
}
|
||||
break;
|
||||
case SWITCH_MESSAGE_INDICATE_BROADCAST: {
|
||||
const char *ip = NULL, *port = NULL;
|
||||
ip = switch_channel_get_variable(channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE);
|
||||
port = switch_channel_get_variable(channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE);
|
||||
if (ip && port) {
|
||||
sofia_glue_set_local_sdp(tech_pvt, ip, atoi(port), msg->string_arg, 1);
|
||||
case SWITCH_MESSAGE_INDICATE_BROADCAST:{
|
||||
const char *ip = NULL, *port = NULL;
|
||||
ip = switch_channel_get_variable(channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE);
|
||||
port = switch_channel_get_variable(channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE);
|
||||
if (ip && port) {
|
||||
sofia_glue_set_local_sdp(tech_pvt, ip, atoi(port), msg->string_arg, 1);
|
||||
}
|
||||
nua_respond(tech_pvt->nh, SIP_200_OK,
|
||||
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
|
||||
SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
|
||||
SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END());
|
||||
switch_channel_mark_answered(channel);
|
||||
}
|
||||
nua_respond(tech_pvt->nh, SIP_200_OK,
|
||||
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
|
||||
SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
|
||||
SOATAG_REUSE_REJECTED(1),
|
||||
SOATAG_ORDERED_USER(1),
|
||||
SOATAG_AUDIO_AUX("cn telephone-event"),
|
||||
NUTAG_INCLUDE_EXTRA_SDP(1),
|
||||
TAG_END());
|
||||
switch_channel_mark_answered(channel);
|
||||
}
|
||||
break;
|
||||
case SWITCH_MESSAGE_INDICATE_NOMEDIA:
|
||||
case SWITCH_MESSAGE_INDICATE_NOMEDIA:
|
||||
{
|
||||
const char *uuid;
|
||||
switch_core_session_t *other_session;
|
||||
switch_channel_t *other_channel;
|
||||
const char *ip = NULL, *port = NULL;
|
||||
|
||||
|
||||
switch_channel_set_flag(channel, CF_PROXY_MODE);
|
||||
tech_pvt->local_sdp_str = NULL;
|
||||
if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
|
||||
@@ -826,14 +807,14 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
case SWITCH_MESSAGE_INDICATE_MEDIA:
|
||||
{
|
||||
uint32_t send_invite = 1;
|
||||
|
||||
|
||||
switch_channel_clear_flag(channel, CF_PROXY_MODE);
|
||||
tech_pvt->local_sdp_str = NULL;
|
||||
|
||||
if (!switch_channel_media_ready(channel)) {
|
||||
if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) {
|
||||
const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
|
||||
|
||||
|
||||
tech_pvt->num_codecs = 0;
|
||||
sofia_glue_tech_prepare_codecs(tech_pvt);
|
||||
if (sofia_glue_tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
|
||||
@@ -882,7 +863,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case SWITCH_MESSAGE_INDICATE_UNHOLD:
|
||||
{
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
|
||||
@@ -890,7 +871,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
}
|
||||
break;
|
||||
case SWITCH_MESSAGE_INDICATE_BRIDGE:
|
||||
|
||||
|
||||
if (switch_test_flag(tech_pvt, TFLAG_XFER)) {
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_XFER);
|
||||
if (msg->pointer_arg) {
|
||||
@@ -918,19 +899,19 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_TIMER)) {
|
||||
switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "De-activate timed RTP!\n");
|
||||
}
|
||||
*/
|
||||
if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_TIMER)) {
|
||||
switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "De-activate timed RTP!\n");
|
||||
}
|
||||
*/
|
||||
break;
|
||||
case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
|
||||
/*
|
||||
if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_TIMER)) {
|
||||
switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-activate timed RTP!\n");
|
||||
}
|
||||
*/
|
||||
if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_TIMER)) {
|
||||
switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-activate timed RTP!\n");
|
||||
}
|
||||
*/
|
||||
break;
|
||||
case SWITCH_MESSAGE_INDICATE_REDIRECT:
|
||||
if (msg->string_arg) {
|
||||
@@ -962,7 +943,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
if (code) {
|
||||
reason = msg->string_arg;
|
||||
} else {
|
||||
if (!switch_strlen_zero(msg->string_arg)){
|
||||
if (!switch_strlen_zero(msg->string_arg)) {
|
||||
if ((code = atoi(msg->string_arg))) {
|
||||
if ((reason = strchr(msg->string_arg, ' '))) {
|
||||
reason++;
|
||||
@@ -974,14 +955,14 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
if (!code) {
|
||||
code = 488;
|
||||
}
|
||||
|
||||
|
||||
if (switch_strlen_zero(reason) && code != 407) {
|
||||
reason = sip_status_phrase(code);
|
||||
if (switch_strlen_zero(reason)) {
|
||||
reason = "Because";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (code == 407 && !msg->numeric_arg) {
|
||||
const char *to_uri = switch_channel_get_variable(channel, "sip_to_uri");
|
||||
const char *to_host = reason;
|
||||
@@ -990,14 +971,14 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
to_host = switch_channel_get_variable(channel, "sip_to_host");
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Challenging call %s\n", to_uri);
|
||||
sofia_reg_auth_challange(NULL, tech_pvt->profile, tech_pvt->nh, REG_INVITE, to_host, 0);
|
||||
sofia_reg_auth_challange(NULL, tech_pvt->profile, tech_pvt->nh, REG_INVITE, to_host, 0);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_USER_CHALLENGE);
|
||||
} else if (code == 484 && msg->numeric_arg) {
|
||||
const char *to = switch_channel_get_variable(channel, "sip_to_uri");
|
||||
const char *max_forwards = switch_channel_get_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE);
|
||||
|
||||
|
||||
char *to_uri = NULL;
|
||||
|
||||
|
||||
if (to) {
|
||||
char *p;
|
||||
to_uri = switch_core_session_sprintf(session, "sip:%s", to);
|
||||
@@ -1015,9 +996,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding with %d [%s]\n", code, reason);
|
||||
|
||||
if (!switch_strlen_zero(((char *)msg->pointer_arg))) {
|
||||
tech_pvt->local_sdp_str = switch_core_session_strdup(tech_pvt->session, (char *)msg->pointer_arg);
|
||||
|
||||
if (!switch_strlen_zero(((char *) msg->pointer_arg))) {
|
||||
tech_pvt->local_sdp_str = switch_core_session_strdup(tech_pvt->session, (char *) msg->pointer_arg);
|
||||
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
|
||||
sofia_glue_tech_patch_sdp(tech_pvt);
|
||||
sofia_glue_tech_proxy_remote_addr(tech_pvt);
|
||||
@@ -1025,10 +1006,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
nua_respond(tech_pvt->nh, code, reason, SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
|
||||
SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
|
||||
SOATAG_REUSE_REJECTED(1),
|
||||
SOATAG_ORDERED_USER(1),
|
||||
SOATAG_AUDIO_AUX("cn telephone-event"),
|
||||
NUTAG_INCLUDE_EXTRA_SDP(1),
|
||||
TAG_END());
|
||||
SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END());
|
||||
} else {
|
||||
nua_respond(tech_pvt->nh, code, reason, SIPTAG_CONTACT_STR(tech_pvt->reply_contact), TAG_END());
|
||||
}
|
||||
@@ -1036,11 +1014,11 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_BYE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case SWITCH_MESSAGE_INDICATE_RINGING:
|
||||
if (!switch_channel_test_flag(channel, CF_RING_READY) &&
|
||||
if (!switch_channel_test_flag(channel, CF_RING_READY) &&
|
||||
!switch_channel_test_flag(channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(channel, CF_ANSWERED)) {
|
||||
nua_respond(tech_pvt->nh, SIP_180_RINGING, SIPTAG_CONTACT_STR(tech_pvt->reply_contact), TAG_END());
|
||||
switch_channel_mark_ring_ready(channel);
|
||||
@@ -1055,10 +1033,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
const char *val = NULL;
|
||||
|
||||
if (!switch_test_flag(tech_pvt, TFLAG_ANS) && !switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
|
||||
|
||||
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Asked to send early media by %s\n", msg->from);
|
||||
|
||||
|
||||
/* Transmit 183 Progress with SDP */
|
||||
if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
|
||||
const char *sdp = NULL;
|
||||
@@ -1105,7 +1083,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
|
||||
|
||||
if (switch_test_flag(tech_pvt, TFLAG_NAT) ||
|
||||
(val = switch_channel_get_variable(channel, "sip-force-contact")) ||
|
||||
(val = switch_channel_get_variable(channel, "sip-force-contact")) ||
|
||||
((val = switch_channel_get_variable(channel, "sip_sticky_contact")) && switch_true(val))) {
|
||||
sticky = tech_pvt->record_route;
|
||||
switch_channel_set_variable(channel, "sip_nat_detected", "true");
|
||||
@@ -1117,8 +1095,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
TAG_IF(sticky, NUTAG_PROXY(tech_pvt->record_route)),
|
||||
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
|
||||
SOATAG_REUSE_REJECTED(1),
|
||||
SOATAG_ORDERED_USER(1),
|
||||
SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"), TAG_END());
|
||||
SOATAG_ORDERED_USER(1), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"), TAG_END());
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1126,10 +1103,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
break;
|
||||
}
|
||||
|
||||
end:
|
||||
|
||||
end:
|
||||
|
||||
return status;
|
||||
|
||||
|
||||
}
|
||||
|
||||
static switch_status_t sofia_receive_event(switch_core_session_t *session, switch_event_t *event)
|
||||
@@ -1158,14 +1135,15 @@ static switch_status_t sofia_receive_event(switch_core_session_t *session, switc
|
||||
typedef switch_status_t (*sofia_command_t) (char **argv, int argc, switch_stream_handle_t *stream);
|
||||
|
||||
static const char *sofia_state_names[] = { "UNREGED",
|
||||
"TRYING",
|
||||
"REGISTER",
|
||||
"REGED",
|
||||
"UNREGISTER",
|
||||
"FAILED",
|
||||
"EXPIRED",
|
||||
"NOREG",
|
||||
NULL};
|
||||
"TRYING",
|
||||
"REGISTER",
|
||||
"REGED",
|
||||
"UNREGISTER",
|
||||
"FAILED",
|
||||
"EXPIRED",
|
||||
"NOREG",
|
||||
NULL
|
||||
};
|
||||
|
||||
struct cb_helper {
|
||||
sofia_profile_t *profile;
|
||||
@@ -1188,17 +1166,14 @@ static int show_reg_callback(void *pArg, int argc, char **argv, char **columnNam
|
||||
switch_strftime(exp_buf, &retsize, sizeof(exp_buf), "%Y-%m-%d %T", &tm);
|
||||
}
|
||||
|
||||
cb->stream->write_function(cb->stream,
|
||||
cb->stream->write_function(cb->stream,
|
||||
"Call-ID \t%s\n"
|
||||
"User \t%s@%s\n"
|
||||
"Contact \t%s\n"
|
||||
"Agent \t%s\n"
|
||||
"Status \t%s(%s) EXP(%s)\n\n",
|
||||
switch_str_nil(argv[0]), switch_str_nil(argv[1]), switch_str_nil(argv[2]), switch_str_nil(argv[3]),
|
||||
switch_str_nil(argv[7]),
|
||||
switch_str_nil(argv[4]),
|
||||
switch_str_nil(argv[5]),
|
||||
exp_buf);
|
||||
"Status \t%s(%s) EXP(%s)\n\n",
|
||||
switch_str_nil(argv[0]), switch_str_nil(argv[1]), switch_str_nil(argv[2]), switch_str_nil(argv[3]),
|
||||
switch_str_nil(argv[7]), switch_str_nil(argv[4]), switch_str_nil(argv[5]), exp_buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1254,24 +1229,24 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
|
||||
stream->write_function(stream, "Name \t%s\n", switch_str_nil(argv[1]));
|
||||
stream->write_function(stream, "Domain Name\t%s\n", switch_str_nil(profile->domain_name));
|
||||
if (strcasecmp(argv[1], profile->name)) {
|
||||
stream->write_function(stream, "Alias Of \t%s\n", switch_str_nil(profile->name));
|
||||
stream->write_function(stream, "Alias Of \t%s\n", switch_str_nil(profile->name));
|
||||
}
|
||||
stream->write_function(stream, "DBName \t%s\n", switch_str_nil(profile->dbname));
|
||||
stream->write_function(stream, "Dialplan \t%s\n", switch_str_nil(profile->dialplan));
|
||||
stream->write_function(stream, "RTP-IP \t%s\n", switch_str_nil(profile->rtpip));
|
||||
if (profile->extrtpip) {
|
||||
stream->write_function(stream, "Ext-RTP-IP \t%s\n", profile->extrtpip);
|
||||
stream->write_function(stream, "Ext-RTP-IP \t%s\n", profile->extrtpip);
|
||||
}
|
||||
|
||||
|
||||
stream->write_function(stream, "SIP-IP \t%s\n", switch_str_nil(profile->sipip));
|
||||
if (profile->extsipip) {
|
||||
stream->write_function(stream, "Ext-SIP-IP \t%s\n", profile->extsipip);
|
||||
stream->write_function(stream, "Ext-SIP-IP \t%s\n", profile->extsipip);
|
||||
}
|
||||
stream->write_function(stream, "URL \t%s\n", switch_str_nil(profile->url));
|
||||
stream->write_function(stream, "BIND-URL \t%s\n", switch_str_nil(profile->bindurl));
|
||||
if (sofia_test_pflag(profile, PFLAG_TLS)) {
|
||||
stream->write_function(stream, "TLS-URL \t%s\n", switch_str_nil(profile->tls_url));
|
||||
stream->write_function(stream, "TLS-BIND-URL \t%s\n", switch_str_nil(profile->tls_bindurl));
|
||||
stream->write_function(stream, "TLS-URL \t%s\n", switch_str_nil(profile->tls_url));
|
||||
stream->write_function(stream, "TLS-BIND-URL \t%s\n", switch_str_nil(profile->tls_bindurl));
|
||||
}
|
||||
stream->write_function(stream, "HOLD-MUSIC \t%s\n", switch_str_nil(profile->hold_music));
|
||||
stream->write_function(stream, "CODECS \t%s\n", switch_str_nil(profile->codec_string));
|
||||
@@ -1283,10 +1258,8 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
|
||||
|
||||
cb.profile = profile;
|
||||
cb.stream = stream;
|
||||
|
||||
sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex,
|
||||
"select * from sip_registrations",
|
||||
show_reg_callback, &cb);
|
||||
|
||||
sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, "select * from sip_registrations", show_reg_callback, &cb);
|
||||
|
||||
stream->write_function(stream, "%s\n", line);
|
||||
|
||||
@@ -1308,7 +1281,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
|
||||
switch_hash_this(hi, &vvar, NULL, &val);
|
||||
profile = (sofia_profile_t *) val;
|
||||
if (sofia_test_pflag(profile, PFLAG_RUNNING)) {
|
||||
|
||||
|
||||
if (strcmp(vvar, profile->name)) {
|
||||
ac++;
|
||||
stream->write_function(stream, "%25s\t%s\t %32s\t%s\n", vvar, " alias", profile->name, "ALIASED");
|
||||
@@ -1317,8 +1290,8 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
|
||||
sofia_test_pflag(profile, PFLAG_RUNNING) ? "RUNNING" : "DOWN", profile->inuse);
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_TLS)) {
|
||||
stream->write_function(stream, "%25s\t%s\t %32s\t%s (%u) (TLS)\n", profile->name, "profile", profile->tls_url,
|
||||
sofia_test_pflag(profile, PFLAG_RUNNING) ? "RUNNING" : "DOWN", profile->inuse);
|
||||
stream->write_function(stream, "%25s\t%s\t %32s\t%s (%u) (TLS)\n", profile->name, "profile", profile->tls_url,
|
||||
sofia_test_pflag(profile, PFLAG_RUNNING) ? "RUNNING" : "DOWN", profile->inuse);
|
||||
}
|
||||
|
||||
c++;
|
||||
@@ -1366,12 +1339,12 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
if (switch_strlen_zero(profile_name) || !(profile = sofia_glue_find_profile(profile_name))) {
|
||||
stream->write_function(stream, "Invalid Profile [%s]", switch_str_nil(profile_name));
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
if (!strcasecmp(argv[1], "flush_inbound_reg")) {
|
||||
if (argc > 2) {
|
||||
sofia_reg_expire_call_id(profile, argv[2]);
|
||||
@@ -1407,7 +1380,7 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
|
||||
} else {
|
||||
stream->write_function(stream, "Invalid gateway!\n");
|
||||
}
|
||||
|
||||
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -1442,7 +1415,7 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
|
||||
int diff = (int) (switch_timestamp(NULL) - profile->started);
|
||||
int remain = rsec - diff;
|
||||
if (diff < rsec) {
|
||||
stream->write_function(stream, "Profile %s must be up for at least %d seconds to stop/restart.\nPlease wait %d second%s\n",
|
||||
stream->write_function(stream, "Profile %s must be up for at least %d seconds to stop/restart.\nPlease wait %d second%s\n",
|
||||
profile->name, rsec, remain, remain == 1 ? "" : "s");
|
||||
} else {
|
||||
|
||||
@@ -1467,7 +1440,7 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
|
||||
|
||||
stream->write_function(stream, "-ERR Unknown command!\n");
|
||||
|
||||
done:
|
||||
done:
|
||||
if (profile) {
|
||||
sofia_glue_release_profile(profile);
|
||||
}
|
||||
@@ -1524,14 +1497,14 @@ SWITCH_STANDARD_API(sofia_contact_function)
|
||||
if ((domain = strchr(user, '@'))) {
|
||||
*domain++ = '\0';
|
||||
}
|
||||
|
||||
|
||||
if (!profile_name && domain) {
|
||||
profile_name = domain;
|
||||
}
|
||||
|
||||
if (user && profile_name) {
|
||||
char *sql;
|
||||
|
||||
|
||||
if (!(profile = sofia_glue_find_profile(profile_name))) {
|
||||
profile_name = domain;
|
||||
domain = NULL;
|
||||
@@ -1544,7 +1517,7 @@ SWITCH_STANDARD_API(sofia_contact_function)
|
||||
if (profile) {
|
||||
struct cb_helper cb;
|
||||
switch_stream_handle_t mystream = { 0 };
|
||||
|
||||
|
||||
if (!domain || !strchr(domain, '.')) {
|
||||
domain = profile->name;
|
||||
}
|
||||
@@ -1553,9 +1526,9 @@ SWITCH_STANDARD_API(sofia_contact_function)
|
||||
switch_assert(mystream.data);
|
||||
cb.profile = profile;
|
||||
cb.stream = &mystream;
|
||||
|
||||
|
||||
if (exclude_contact) {
|
||||
sql = switch_mprintf("select contact from sip_registrations where sip_user='%q' and sip_host='%q' and contact not like '%%%s%%'",
|
||||
sql = switch_mprintf("select contact from sip_registrations where sip_user='%q' and sip_host='%q' and contact not like '%%%s%%'",
|
||||
user, domain, exclude_contact);
|
||||
} else {
|
||||
sql = switch_mprintf("select contact from sip_registrations where sip_user='%q' and sip_host='%q'", user, domain);
|
||||
@@ -1573,7 +1546,7 @@ SWITCH_STANDARD_API(sofia_contact_function)
|
||||
switch_safe_free(mystream.data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (reply) {
|
||||
stream->write_function(stream, "%s", reply);
|
||||
}
|
||||
@@ -1600,13 +1573,12 @@ SWITCH_STANDARD_API(sofia_function)
|
||||
"sofia help\n"
|
||||
"sofia profile <profile_name> [start|stop|restart|flush_inbound_reg [<call_id>]|[register|unregister] [<gateway name>|all]] [reloadxml]\n"
|
||||
"sofia status [[profile | gateway] <name>]\n"
|
||||
"sofia loglevel [0-9]\n"
|
||||
"--------------------------------------------------------------------------------\n";
|
||||
|
||||
"sofia loglevel [0-9]\n" "--------------------------------------------------------------------------------\n";
|
||||
|
||||
if (session) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (switch_strlen_zero(cmd)) {
|
||||
stream->write_function(stream, "%s", usage_string);
|
||||
goto done;
|
||||
@@ -1621,7 +1593,7 @@ SWITCH_STANDARD_API(sofia_function)
|
||||
stream->write_function(stream, "%s", usage_string);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
if (!strcasecmp(argv[0], "profile")) {
|
||||
func = cmd_profile;
|
||||
} else if (!strcasecmp(argv[0], "status")) {
|
||||
@@ -1664,9 +1636,9 @@ switch_io_routines_t sofia_io_routines = {
|
||||
/*.send_dtmf */ sofia_send_dtmf,
|
||||
/*.receive_message */ sofia_receive_message,
|
||||
/*.receive_event */ sofia_receive_event,
|
||||
/*.state_change*/ NULL,
|
||||
/*.read_video_frame*/ sofia_read_video_frame,
|
||||
/*.write_video_frame*/ sofia_write_video_frame
|
||||
/*.state_change */ NULL,
|
||||
/*.read_video_frame */ sofia_read_video_frame,
|
||||
/*.write_video_frame */ sofia_write_video_frame
|
||||
};
|
||||
|
||||
switch_state_handler_table_t sofia_event_handlers = {
|
||||
@@ -1677,8 +1649,8 @@ switch_state_handler_table_t sofia_event_handlers = {
|
||||
/*.on_exchange_media */ sofia_on_exchange_media,
|
||||
/*.on_soft_execute */ sofia_on_soft_execute,
|
||||
/*.on_consume_media */ NULL,
|
||||
/*.on_hibernate*/ sofia_on_hibernate,
|
||||
/*.on_reset*/ sofia_on_reset
|
||||
/*.on_hibernate */ sofia_on_hibernate,
|
||||
/*.on_reset */ sofia_on_reset
|
||||
};
|
||||
|
||||
static switch_status_t sofia_manage(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen)
|
||||
@@ -1698,7 +1670,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
private_object_t *tech_pvt = NULL;
|
||||
switch_channel_t *nchannel;
|
||||
char *host = NULL, *dest_to = NULL;
|
||||
|
||||
|
||||
*new_session = NULL;
|
||||
|
||||
if (!(nsession = switch_core_session_request(sofia_endpoint_interface, pool))) {
|
||||
@@ -1758,14 +1730,14 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
* invite contact.
|
||||
*
|
||||
* TODO:
|
||||
* - Add parameters back to destination url?
|
||||
* - Add parameters back to destination url?
|
||||
*/
|
||||
if ((params = strchr(dest, ';'))) {
|
||||
char *tp_param;
|
||||
|
||||
*params++ = '\0';
|
||||
|
||||
if ((tp_param = (char *)switch_stristr("port=", params))) {
|
||||
if ((tp_param = (char *) switch_stristr("port=", params))) {
|
||||
tp_param += 5;
|
||||
tech_pvt->transport = sofia_glue_str2transport(tp_param);
|
||||
if (tech_pvt->transport == SOFIA_TRANSPORT_UNKNOWN) {
|
||||
@@ -1776,7 +1748,8 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
}
|
||||
|
||||
if (tech_pvt->transport != gateway_ptr->register_transport) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "You are trying to use a different transport type for this gateway (overriding the register-transport), this is unsupported!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"You are trying to use a different transport type for this gateway (overriding the register-transport), this is unsupported!\n");
|
||||
cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
|
||||
goto error;
|
||||
}
|
||||
@@ -1860,7 +1833,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
tech_pvt->dest_to = switch_core_session_sprintf(nsession, "sip:%s@%s", dest_to, host);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!tech_pvt->dest_to) {
|
||||
tech_pvt->dest_to = tech_pvt->dest;
|
||||
@@ -1961,7 +1934,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
|
||||
switch_core_hash_init(&mod_sofia_globals.profile_hash, mod_sofia_globals.pool);
|
||||
switch_core_hash_init(&mod_sofia_globals.gateway_hash, mod_sofia_globals.pool);
|
||||
switch_mutex_init(&mod_sofia_globals.hash_mutex, SWITCH_MUTEX_NESTED, mod_sofia_globals.pool);
|
||||
|
||||
|
||||
switch_mutex_lock(mod_sofia_globals.mutex);
|
||||
mod_sofia_globals.running = 1;
|
||||
switch_mutex_unlock(mod_sofia_globals.mutex);
|
||||
@@ -2034,7 +2007,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown)
|
||||
{
|
||||
int sanity = 0;
|
||||
|
||||
|
||||
switch_mutex_lock(mod_sofia_globals.mutex);
|
||||
if (mod_sofia_globals.running == 1) {
|
||||
mod_sofia_globals.running = 0;
|
||||
|
||||
+203
-281
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -127,7 +127,8 @@ void sofia_presence_cancel(void)
|
||||
void *val;
|
||||
struct presence_helper helper = { 0 };
|
||||
|
||||
if (!mod_sofia_globals.profile_hash) return;
|
||||
if (!mod_sofia_globals.profile_hash)
|
||||
return;
|
||||
|
||||
if ((sql = switch_mprintf("select *,-1,'unavailable','unavailable' from sip_subscriptions where event='presence'"))) {
|
||||
switch_mutex_lock(mod_sofia_globals.hash_mutex);
|
||||
@@ -151,16 +152,15 @@ void sofia_presence_cancel(void)
|
||||
void sofia_presence_establish_presence(sofia_profile_t *profile)
|
||||
{
|
||||
|
||||
if (sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex,
|
||||
"select sip_user,sip_host,'Registered','unknown','' from sip_registrations",
|
||||
if (sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex,
|
||||
"select sip_user,sip_host,'Registered','unknown','' from sip_registrations",
|
||||
sofia_presence_resub_callback, profile) != SWITCH_TRUE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex,
|
||||
"select sub_to_user,sub_to_host,'Online','unknown',proto from sip_subscriptions "
|
||||
"where proto='ext' or proto='user' or proto='conf'",
|
||||
sofia_presence_resub_callback, profile) != SWITCH_TRUE) {
|
||||
"where proto='ext' or proto='user' or proto='conf'", sofia_presence_resub_callback, profile) != SWITCH_TRUE) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -172,7 +172,7 @@ char *sofia_presence_translate_rpid(char *in, char *ext)
|
||||
if (in && (switch_stristr("null", in))) {
|
||||
in = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (!in) {
|
||||
in = ext;
|
||||
}
|
||||
@@ -233,7 +233,7 @@ static void actual_sofia_presence_mwi_event_handler(switch_event_t *event)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (profile->domain_name && profile->domain_name != host) {
|
||||
host = profile->domain_name;
|
||||
}
|
||||
@@ -251,43 +251,32 @@ static void actual_sofia_presence_mwi_event_handler(switch_event_t *event)
|
||||
if (!strcasecmp(hp->name, "mwi-message-account") && strncasecmp(hp->value, "sip:", 4)) {
|
||||
tmp = switch_mprintf("sip:%s", hp->value);
|
||||
value = tmp;
|
||||
}
|
||||
}
|
||||
stream.write_function(&stream, "%s: %s\r\n", hp->name + 4, value);
|
||||
switch_safe_free(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
stream.write_function(&stream, "\r\n");
|
||||
|
||||
sql = switch_mprintf("select *,'%q' from sip_subscriptions where event='message-summary' and sub_to_user='%q' and sub_to_host='%q'",
|
||||
stream.data, user, host);
|
||||
|
||||
|
||||
switch_assert (sql != NULL);
|
||||
sofia_glue_execute_sql_callback(profile,
|
||||
SWITCH_FALSE,
|
||||
profile->ireg_mutex,
|
||||
sql,
|
||||
sofia_presence_mwi_callback,
|
||||
&h);
|
||||
sql = switch_mprintf("select *,'%q' from sip_subscriptions where event='message-summary' and sub_to_user='%q' and sub_to_host='%q'",
|
||||
stream.data, user, host);
|
||||
|
||||
|
||||
switch_assert(sql != NULL);
|
||||
sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, sofia_presence_mwi_callback, &h);
|
||||
|
||||
switch_safe_free(sql);
|
||||
|
||||
|
||||
|
||||
sql = switch_mprintf("select sip_user,sip_host,contact,'%q' from sip_registrations where sip_user='%q' and sip_host='%q'",
|
||||
stream.data, user, host);
|
||||
|
||||
|
||||
|
||||
switch_assert (sql != NULL);
|
||||
sofia_glue_execute_sql_callback(profile,
|
||||
SWITCH_FALSE,
|
||||
profile->ireg_mutex,
|
||||
sql,
|
||||
sofia_presence_mwi_callback2,
|
||||
&h);
|
||||
|
||||
sql = switch_mprintf("select sip_user,sip_host,contact,'%q' from sip_registrations where sip_user='%q' and sip_host='%q'", stream.data, user, host);
|
||||
|
||||
|
||||
|
||||
switch_assert(sql != NULL);
|
||||
sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, sofia_presence_mwi_callback2, &h);
|
||||
|
||||
switch_safe_free(sql);
|
||||
|
||||
switch_safe_free(stream.data);
|
||||
@@ -312,11 +301,11 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
|
||||
char *sql = NULL;
|
||||
char *euser = NULL, *user = NULL, *host = NULL;
|
||||
|
||||
|
||||
|
||||
if (!mod_sofia_globals.running) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (rpid && !strcasecmp(rpid, "n/a")) {
|
||||
rpid = NULL;
|
||||
}
|
||||
@@ -350,8 +339,9 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
|
||||
if (event->event_id == SWITCH_EVENT_ROSTER) {
|
||||
struct presence_helper helper = { 0 };
|
||||
|
||||
if (!mod_sofia_globals.profile_hash) return;
|
||||
|
||||
if (!mod_sofia_globals.profile_hash)
|
||||
return;
|
||||
|
||||
if (from) {
|
||||
sql = switch_mprintf("select *,1,'%q','%q' from sip_subscriptions where event='presence' and full_from like '%%%q%%'", status, rpid, from);
|
||||
} else {
|
||||
@@ -367,13 +357,8 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
|
||||
continue;
|
||||
}
|
||||
helper.profile = profile;
|
||||
helper.event = NULL;
|
||||
sofia_glue_execute_sql_callback(profile,
|
||||
SWITCH_FALSE,
|
||||
profile->ireg_mutex,
|
||||
sql,
|
||||
sofia_presence_sub_callback,
|
||||
&helper);
|
||||
helper.event = NULL;
|
||||
sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, sofia_presence_sub_callback, &helper);
|
||||
}
|
||||
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
|
||||
free(sql);
|
||||
@@ -387,7 +372,7 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
|
||||
if (switch_strlen_zero(alt_event_type)) {
|
||||
alt_event_type = "presence";
|
||||
}
|
||||
|
||||
|
||||
if ((user = strdup(from))) {
|
||||
if ((host = strchr(user, '@'))) {
|
||||
char *p;
|
||||
@@ -432,15 +417,9 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
|
||||
"from sip_registrations left join sip_dialogs on "
|
||||
"(sip_dialogs.sip_from_user = sip_registrations.sip_user) "
|
||||
"and sip_dialogs.sip_from_host = sip_registrations.sip_host "
|
||||
"where sip_registrations.sip_user='%q' and sip_registrations.sip_host='%q'",
|
||||
probe_euser, probe_host);
|
||||
"where sip_registrations.sip_user='%q' and sip_registrations.sip_host='%q'", probe_euser, probe_host);
|
||||
switch_assert(sql);
|
||||
sofia_glue_execute_sql_callback(profile,
|
||||
SWITCH_FALSE,
|
||||
profile->ireg_mutex,
|
||||
sql,
|
||||
sofia_presence_resub_callback,
|
||||
profile);
|
||||
sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, sofia_presence_resub_callback, profile);
|
||||
|
||||
sofia_glue_release_profile(profile);
|
||||
switch_safe_free(sql);
|
||||
@@ -465,7 +444,8 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!mod_sofia_globals.profile_hash) goto done;
|
||||
if (!mod_sofia_globals.profile_hash)
|
||||
goto done;
|
||||
|
||||
switch_mutex_lock(mod_sofia_globals.hash_mutex);
|
||||
for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
|
||||
@@ -478,31 +458,27 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
|
||||
if (sql) {
|
||||
struct presence_helper helper = { 0 };
|
||||
helper.profile = profile;
|
||||
helper.event = event;
|
||||
helper.event = event;
|
||||
SWITCH_STANDARD_STREAM(helper.stream);
|
||||
switch_assert(helper.stream.data);
|
||||
|
||||
sofia_glue_execute_sql_callback(profile,
|
||||
SWITCH_FALSE,
|
||||
sofia_glue_execute_sql_callback(profile, SWITCH_FALSE,
|
||||
//profile->ireg_mutex,
|
||||
NULL,
|
||||
sql,
|
||||
sofia_presence_sub_callback,
|
||||
&helper);
|
||||
|
||||
if (!switch_strlen_zero((char *)helper.stream.data)) {
|
||||
char *this = (char *)helper.stream.data;
|
||||
NULL, sql, sofia_presence_sub_callback, &helper);
|
||||
|
||||
if (!switch_strlen_zero((char *) helper.stream.data)) {
|
||||
char *this = (char *) helper.stream.data;
|
||||
char *next = NULL;
|
||||
char *last = NULL;
|
||||
|
||||
|
||||
do {
|
||||
if ((next = strchr(this, ';'))) {
|
||||
*next++ = '\0';
|
||||
while(*next == '\n' || *next == ' ' || *next == '\r') {
|
||||
while (*next == '\n' || *next == ' ' || *next == '\r') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!switch_strlen_zero(this) && (!last || strcmp(last, this))) {
|
||||
sofia_glue_execute_sql(profile, &this, SWITCH_FALSE);
|
||||
last = this;
|
||||
@@ -516,7 +492,7 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
|
||||
}
|
||||
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
|
||||
|
||||
done:
|
||||
done:
|
||||
switch_safe_free(sql);
|
||||
switch_safe_free(user);
|
||||
}
|
||||
@@ -543,10 +519,10 @@ void *SWITCH_THREAD_FUNC sofia_presence_event_thread_run(switch_thread_t *thread
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Event Thread Started\n");
|
||||
|
||||
|
||||
while (mod_sofia_globals.running == 1) {
|
||||
int count = 0;
|
||||
|
||||
|
||||
if (switch_queue_trypop(mod_sofia_globals.presence_queue, &pop) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_t *event = (switch_event_t *) pop;
|
||||
|
||||
@@ -580,7 +556,7 @@ void *SWITCH_THREAD_FUNC sofia_presence_event_thread_run(switch_thread_t *thread
|
||||
switch_event_t *event = (switch_event_t *) pop;
|
||||
switch_event_destroy(&event);
|
||||
}
|
||||
|
||||
|
||||
while (switch_queue_trypop(mod_sofia_globals.mwi_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
|
||||
switch_event_t *event = (switch_event_t *) pop;
|
||||
switch_event_destroy(&event);
|
||||
@@ -592,7 +568,7 @@ void *SWITCH_THREAD_FUNC sofia_presence_event_thread_run(switch_thread_t *thread
|
||||
mod_sofia_globals.threads--;
|
||||
EVENT_THREAD_RUNNING = EVENT_THREAD_STARTED = 0;
|
||||
switch_mutex_unlock(mod_sofia_globals.mutex);
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -728,7 +704,7 @@ static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "astate", "%s", state);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-direction", "%s", direction);
|
||||
}
|
||||
|
||||
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
@@ -738,7 +714,7 @@ static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char
|
||||
static char *translate_rpid(char *in)
|
||||
{
|
||||
char *r = in;
|
||||
|
||||
|
||||
if (in && (strstr(in, "null") || strstr(in, "NULL"))) {
|
||||
in = NULL;
|
||||
}
|
||||
@@ -762,7 +738,7 @@ static char *translate_rpid(char *in)
|
||||
r = "busy";
|
||||
}
|
||||
|
||||
end:
|
||||
end:
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -792,17 +768,17 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||
char *prpid;
|
||||
int done = 0;
|
||||
const char *ct = "no/idea";
|
||||
time_t exptime = switch_timestamp(NULL) + 3600;
|
||||
char exp[80] = "";
|
||||
time_t exptime = switch_timestamp(NULL) + 3600;
|
||||
char exp[80] = "";
|
||||
int is_dialog = 0;
|
||||
|
||||
if (expires) {
|
||||
long tmp = atol(expires);
|
||||
if (tmp > 0) {
|
||||
exptime = tmp - switch_timestamp(NULL);
|
||||
if (expires) {
|
||||
long tmp = atol(expires);
|
||||
if (tmp > 0) {
|
||||
exptime = tmp - switch_timestamp(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!(nh = nua_handle_by_call_id(profile->nua, call_id))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Cannot find handle for %s\n", call_id);
|
||||
return 0;
|
||||
@@ -817,7 +793,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||
if (in < 0) {
|
||||
done = 1;
|
||||
in = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcasecmp(proto, SOFIA_CHAT_PROTO)) {
|
||||
clean_id = switch_mprintf("sip:%s@%s", sub_to_user, sub_to_host);
|
||||
@@ -838,7 +814,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||
to = switch_mprintf("sip:%s@%s", user, host);
|
||||
|
||||
is_dialog = !strcmp(event, "dialog");
|
||||
|
||||
|
||||
if (helper->event) {
|
||||
switch_stream_handle_t stream = { 0 };
|
||||
const char *direction = switch_str_nil(switch_event_get_header(helper->event, "call-direction"));
|
||||
@@ -854,7 +830,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||
const char *clean_to_user = NULL;
|
||||
const char *clean_from_user = NULL;
|
||||
|
||||
|
||||
|
||||
if (is_dialog) {
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
}
|
||||
@@ -866,43 +842,43 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||
direction = "initiator";
|
||||
dft_state = "confirmed";
|
||||
}
|
||||
|
||||
|
||||
if (!strcasecmp(state, "cs_execute") && !strstr(event_status, "hold")) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!strcasecmp(event_status, "Registered")) {
|
||||
answer_state = "resubscribe";
|
||||
}
|
||||
|
||||
if (is_dialog) {
|
||||
stream.write_function(&stream,
|
||||
stream.write_function(&stream,
|
||||
"<?xml version=\"1.0\"?>\n"
|
||||
"<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" "
|
||||
"version=\"%s\" state=\"%s\" entity=\"%s\">\n",
|
||||
"version=\"%s\" state=\"%s\" entity=\"%s\">\n",
|
||||
switch_str_nil(switch_event_get_header(helper->event, "event_count")),
|
||||
!strcasecmp(answer_state, "resubscribe") ? "partial" : "full", clean_id);
|
||||
}
|
||||
|
||||
|
||||
if (strcasecmp(answer_state, "resubscribe")) {
|
||||
|
||||
if (!strcasecmp(state, "cs_hangup")) {
|
||||
astate = "terminated";
|
||||
} else if (switch_strlen_zero(astate)) {
|
||||
} else if (switch_strlen_zero(astate)) {
|
||||
astate = switch_str_nil(switch_event_get_header(helper->event, "answer-state"));
|
||||
if (switch_strlen_zero(astate)) {
|
||||
if (switch_strlen_zero(astate)) {
|
||||
astate = dft_state;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!strcasecmp(event_status, "hold")) {
|
||||
astate = "early";
|
||||
}
|
||||
|
||||
|
||||
if (!strcasecmp(astate, "answered")) {
|
||||
astate = "confirmed";
|
||||
}
|
||||
|
||||
|
||||
if (!strcasecmp(astate, "ringing")) {
|
||||
if (!strcasecmp(direction, "recipient")) {
|
||||
astate = "early";
|
||||
@@ -915,7 +891,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||
stream.write_function(&stream, "<state>%s</state>\n", astate);
|
||||
}
|
||||
if (!strcasecmp(astate, "early") || !strcasecmp(astate, "confirmed")) {
|
||||
|
||||
|
||||
clean_to_user = switch_mprintf("%s", sub_to_user ? sub_to_user : to_user);
|
||||
clean_from_user = switch_mprintf("%s", from_id ? from_id : from_user);
|
||||
|
||||
@@ -923,24 +899,26 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||
if (!switch_strlen_zero(clean_to_user) && !switch_strlen_zero(clean_from_user)) {
|
||||
stream.write_function(&stream, "<local>\n<identity display=\"%s\">sip:%s@%s</identity>\n", clean_to_user, clean_to_user, host);
|
||||
stream.write_function(&stream, "<target uri=\"sip:%s@%s\">\n", clean_to_user, host);
|
||||
stream.write_function(&stream, "<param pname=\"+sip.rendering\" pvalue=\"%s\"/>\n", !strcasecmp(event_status, "hold") ? "no" : "yes" );
|
||||
stream.write_function(&stream, "</target>\n</local>\n");
|
||||
stream.write_function(&stream, "<remote>\n<identity display=\"%s\">sip:%s@%s</identity>\n", clean_from_user, clean_from_user, host);
|
||||
stream.write_function(&stream, "<param pname=\"+sip.rendering\" pvalue=\"%s\"/>\n",
|
||||
!strcasecmp(event_status, "hold") ? "no" : "yes");
|
||||
stream.write_function(&stream, "</target>\n</local>\n");
|
||||
stream.write_function(&stream, "<remote>\n<identity display=\"%s\">sip:%s@%s</identity>\n", clean_from_user, clean_from_user,
|
||||
host);
|
||||
stream.write_function(&stream, "<target uri=\"sip:**%s@%s\"/>\n", clean_to_user, host);
|
||||
stream.write_function(&stream, "</remote>\n");
|
||||
} else if (!strcasecmp(proto, "park")) {
|
||||
stream.write_function(&stream, "<local>\n<identity display=\"parking\">sip:parking@%s;fifo=%s</identity>\n",
|
||||
stream.write_function(&stream, "<local>\n<identity display=\"parking\">sip:parking@%s;fifo=%s</identity>\n",
|
||||
host, !switch_strlen_zero(clean_to_user) ? clean_to_user : "unknown");
|
||||
stream.write_function(&stream, "<target uri=\"sip:parking@%s\">\n", host);
|
||||
stream.write_function(&stream, "<param pname=\"+sip.rendering\" pvalue=\"no\"/>\n</target>\n</local>\n");
|
||||
stream.write_function(&stream, "<param pname=\"+sip.rendering\" pvalue=\"no\"/>\n</target>\n</local>\n");
|
||||
stream.write_function(&stream, "<remote>\n<identity display=\"parking\">sip:%s</identity>\n", uuid);
|
||||
stream.write_function(&stream, "<target uri=\"sip:park+%s\"/>\n", uuid);
|
||||
stream.write_function(&stream, "</remote>\n");
|
||||
} else if (!strcasecmp(proto, "conf")) {
|
||||
stream.write_function(&stream, "<local>\n<identity display=\"conference\">sip:conference@%s;conference=%s</identity>\n",
|
||||
stream.write_function(&stream, "<local>\n<identity display=\"conference\">sip:conference@%s;conference=%s</identity>\n",
|
||||
host, !switch_strlen_zero(clean_to_user) ? clean_to_user : "unknown");
|
||||
stream.write_function(&stream, "<target uri=\"sip:conference@%s\">\n", host);
|
||||
stream.write_function(&stream, "<param pname=\"+sip.rendering\" pvalue=\"yes\"/>\n</target>\n</local>\n");
|
||||
stream.write_function(&stream, "<param pname=\"+sip.rendering\" pvalue=\"yes\"/>\n</target>\n</local>\n");
|
||||
stream.write_function(&stream, "<remote>\n<identity display=\"conference\">sip:%s@%s</identity>\n", uuid, host);
|
||||
stream.write_function(&stream, "<target uri=\"sip:conf+%s@%s\"/>\n", uuid, host);
|
||||
stream.write_function(&stream, "</remote>\n");
|
||||
@@ -948,7 +926,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||
}
|
||||
}
|
||||
if (is_dialog) {
|
||||
stream.write_function(&stream, "</dialog>\n");
|
||||
stream.write_function(&stream, "</dialog>\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -957,10 +935,10 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||
pl = stream.data;
|
||||
ct = "application/dialog-info+xml";
|
||||
}
|
||||
|
||||
|
||||
if (!switch_strlen_zero(astate) && !switch_strlen_zero(uuid) && helper && helper->stream.data && strcmp(helper->last_uuid, uuid)) {
|
||||
helper->stream.write_function(&helper->stream, "update sip_dialogs set state='%s' where uuid='%s';", astate, uuid);
|
||||
|
||||
|
||||
switch_copy_string(helper->last_uuid, uuid, sizeof(helper->last_uuid));
|
||||
}
|
||||
|
||||
@@ -968,7 +946,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||
if (!is_dialog) {
|
||||
if (in) {
|
||||
char status_line[256] = "";
|
||||
|
||||
|
||||
if (!strcmp(astate, "early")) {
|
||||
switch_snprintf(status_line, sizeof(status_line), "R %s", switch_str_nil(from_id));
|
||||
rpid = "on-the-phone";
|
||||
@@ -976,8 +954,8 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||
char *dest = switch_event_get_header(helper->event, "Caller-Destination-Number");
|
||||
if (switch_strlen_zero(from_id) && !switch_strlen_zero(dest)) {
|
||||
from_id = dest;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (switch_strlen_zero(from_id)) {
|
||||
switch_snprintf(status_line, sizeof(status_line), "Available");
|
||||
} else {
|
||||
@@ -994,7 +972,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||
note = NULL;
|
||||
open = "closed";
|
||||
}
|
||||
|
||||
|
||||
prpid = translate_rpid(rpid);
|
||||
pl = switch_mprintf("<?xml version='1.0' encoding='UTF-8'?>\r\n"
|
||||
"<presence xmlns='urn:ietf:params:xml:ns:pidf'\r\n"
|
||||
@@ -1017,11 +995,8 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||
"</status>\r\n"
|
||||
"</tuple>\r\n"
|
||||
"<dm:person id='p06360c4a'>\r\n"
|
||||
"<rpid:activities>\r\n" "<rpid:%s/>\r\n"
|
||||
"</rpid:activities>%s</dm:person>\r\n"
|
||||
"</presence>", id,
|
||||
id, profile->url, open, status, prpid,
|
||||
open, rpid, note);
|
||||
"<rpid:activities>\r\n" "<rpid:%s/>\r\n"
|
||||
"</rpid:activities>%s</dm:person>\r\n" "</presence>", id, id, profile->url, open, status, prpid, open, rpid, note);
|
||||
ct = "application/pidf+xml";
|
||||
}
|
||||
|
||||
@@ -1055,21 +1030,16 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||
"</status>\r\n"
|
||||
"</tuple>\r\n"
|
||||
"<dm:person id='p06360c4a'>\r\n"
|
||||
"<rpid:activities>\r\n" "<rpid:%s/>\r\n"
|
||||
"</rpid:activities>%s</dm:person>\r\n"
|
||||
"</presence>", id,
|
||||
id, profile->url, open, status, prpid,
|
||||
open, rpid, note);
|
||||
"<rpid:activities>\r\n" "<rpid:%s/>\r\n"
|
||||
"</rpid:activities>%s</dm:person>\r\n" "</presence>", id, id, profile->url, open, status, prpid, open, rpid, note);
|
||||
ct = "application/pidf+xml";
|
||||
}
|
||||
|
||||
switch_snprintf(exp, sizeof(exp), "active;expires=%ld", (long) exptime);
|
||||
switch_snprintf(exp, sizeof(exp), "active;expires=%ld", (long) exptime);
|
||||
nua_handle_bind(nh, &mod_sofia_globals.keep_private);
|
||||
nua_notify(nh,
|
||||
SIPTAG_SUBSCRIPTION_STATE_STR(exp),
|
||||
SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR(ct), SIPTAG_PAYLOAD_STR(pl), TAG_END());
|
||||
nua_notify(nh, SIPTAG_SUBSCRIPTION_STATE_STR(exp), SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR(ct), SIPTAG_PAYLOAD_STR(pl), TAG_END());
|
||||
|
||||
end:
|
||||
end:
|
||||
|
||||
switch_safe_free(id);
|
||||
switch_safe_free(clean_id);
|
||||
@@ -1101,15 +1071,15 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char *
|
||||
int expire_sec = atoi(expires);
|
||||
//int *total = (int *) pArg;
|
||||
struct mwi_helper *h = (struct mwi_helper *) pArg;
|
||||
|
||||
|
||||
|
||||
|
||||
if (!(nh = nua_handle_by_call_id(h->profile->nua, call_id))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find handle for %s\n", call_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
id = switch_mprintf("sip:%s@%s", sub_to_user, sub_to_host);
|
||||
expire_sec = (int)(expire_sec - switch_timestamp(NULL));
|
||||
expire_sec = (int) (expire_sec - switch_timestamp(NULL));
|
||||
if (expire_sec < 0) {
|
||||
expire_sec = 3600;
|
||||
}
|
||||
@@ -1118,7 +1088,7 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char *
|
||||
nua_notify(nh,
|
||||
SIPTAG_SUBSCRIPTION_STATE_STR(exp),
|
||||
SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"), SIPTAG_PAYLOAD_STR(body), TAG_END());
|
||||
|
||||
|
||||
switch_safe_free(id);
|
||||
switch_safe_free(exp);
|
||||
|
||||
@@ -1139,33 +1109,29 @@ static int sofia_presence_mwi_callback2(void *pArg, int argc, char **argv, char
|
||||
char *id = NULL;
|
||||
nua_handle_t *nh;
|
||||
struct mwi_helper *h = (struct mwi_helper *) pArg;
|
||||
|
||||
|
||||
|
||||
|
||||
id = switch_mprintf("sip:%s@%s", sub_to_user, sub_to_host);
|
||||
|
||||
contact = sofia_glue_get_url_from_contact(o_contact, 1);
|
||||
|
||||
nh = nua_handle(h->profile->nua, NULL,
|
||||
NUTAG_URL(contact),
|
||||
SIPTAG_FROM_STR(id),
|
||||
SIPTAG_TO_STR(id),
|
||||
SIPTAG_CONTACT_STR(h->profile->url),
|
||||
TAG_END());
|
||||
|
||||
|
||||
nh = nua_handle(h->profile->nua, NULL, NUTAG_URL(contact), SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id), SIPTAG_CONTACT_STR(h->profile->url), TAG_END());
|
||||
|
||||
nua_notify(nh,
|
||||
NUTAG_NEWSUB(1),
|
||||
TAG_IF(strstr(o_contact, ";nat"), NUTAG_PROXY(contact)),
|
||||
SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"), SIPTAG_PAYLOAD_STR(body), TAG_END());
|
||||
|
||||
|
||||
switch_safe_free(contact);
|
||||
switch_safe_free(id);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
char const *phrase,
|
||||
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
|
||||
char const *phrase,
|
||||
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
|
||||
tagi_t tags[])
|
||||
{
|
||||
if (sip) {
|
||||
long exp, exp_raw;
|
||||
@@ -1205,15 +1171,14 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
get_addr(network_ip, sizeof(network_ip), &((struct sockaddr_in *) my_addrinfo->ai_addr)->sin_addr);
|
||||
network_port = ntohs(((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_port);
|
||||
|
||||
tl_gets(tags,
|
||||
NUTAG_SUBSTATE_REF(sub_state), TAG_END());
|
||||
tl_gets(tags, NUTAG_SUBSTATE_REF(sub_state), TAG_END());
|
||||
|
||||
event = sip_header_as_string(profile->home, (void *) sip->sip_event);
|
||||
|
||||
port = (char *) contact->m_url->url_port;
|
||||
contact_host = sip->sip_contact->m_url->url_host;
|
||||
contact_user = sip->sip_contact->m_url->url_user;
|
||||
|
||||
|
||||
display = contact->m_display;
|
||||
|
||||
if (switch_strlen_zero(display)) {
|
||||
@@ -1226,12 +1191,12 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
} else {
|
||||
display = "\"user\"";
|
||||
}
|
||||
|
||||
|
||||
if ((profile->pflags & PFLAG_AGGRESSIVE_NAT_DETECTION)) {
|
||||
if (sip && sip->sip_via) {
|
||||
const char *v_port = sip->sip_via->v_port;
|
||||
const char *v_host = sip->sip_via->v_host;
|
||||
|
||||
|
||||
if (v_host && sip->sip_via->v_received) {
|
||||
is_nat = "via received";
|
||||
} else if (v_host && strcmp(network_ip, v_host)) {
|
||||
@@ -1241,27 +1206,27 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!is_nat && profile->nat_acl_count) {
|
||||
uint32_t x = 0;
|
||||
int ok = 1;
|
||||
char *last_acl = NULL;
|
||||
|
||||
|
||||
if (!switch_strlen_zero(contact_host)) {
|
||||
for (x = 0 ; x < profile->nat_acl_count; x++) {
|
||||
for (x = 0; x < profile->nat_acl_count; x++) {
|
||||
last_acl = profile->nat_acl[x];
|
||||
if (!(ok = switch_check_network_list_ip(contact_host, last_acl))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ok) {
|
||||
is_nat = last_acl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (is_nat) {
|
||||
contact_host = network_ip;
|
||||
switch_snprintf(new_port, sizeof(new_port), ":%d", network_port);
|
||||
@@ -1272,14 +1237,14 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
if (port) {
|
||||
switch_snprintf(new_port, sizeof(new_port), ":%s", port);
|
||||
}
|
||||
|
||||
|
||||
if (contact->m_url->url_params) {
|
||||
contact_str = switch_mprintf("%s <sip:%s@%s%s;%s>%s",
|
||||
display, contact->m_url->url_user, contact_host, new_port, contact->m_url->url_params, is_nat ? ";nat" : "");
|
||||
} else {
|
||||
contact_str = switch_mprintf("%s <sip:%s@%s%s>%s", display, contact->m_url->url_user, contact_host, new_port, is_nat ? ";nat" : "");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (to) {
|
||||
to_str = switch_mprintf("sip:%s@%s", to->a_url->url_user, to->a_url->url_host); //, to->a_url->url_port);
|
||||
@@ -1306,7 +1271,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
if ((p = strchr(protocol, '+'))) {
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
|
||||
if (switch_event_create(&sevent, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "proto", protocol);
|
||||
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "login", "%s", profile->name);
|
||||
@@ -1315,7 +1280,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "status", "Click To Call");
|
||||
switch_event_fire(&sevent);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
if (switch_event_create(&sevent, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
|
||||
@@ -1358,12 +1323,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
} else {
|
||||
sql = switch_mprintf("delete from sip_subscriptions where "
|
||||
"proto='%q' and sip_user='%q' and sip_host='%q' and sub_to_user='%q' and sub_to_host='%q' and event='%q'",
|
||||
proto,
|
||||
from_user,
|
||||
from_host,
|
||||
to_user,
|
||||
to_host, event
|
||||
);
|
||||
proto, from_user, from_host, to_user, to_host, event);
|
||||
}
|
||||
|
||||
|
||||
@@ -1377,34 +1337,30 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
sip_accept_t *ap = sip->sip_accept;
|
||||
char accept[256] = "";
|
||||
full_agent = sip_header_as_string(profile->home, (void *) sip->sip_user_agent);
|
||||
while(ap) {
|
||||
while (ap) {
|
||||
switch_snprintf(accept + strlen(accept), sizeof(accept) - strlen(accept), "%s%s ", ap->ac_type, ap->ac_next ? "," : "");
|
||||
ap = ap->ac_next;
|
||||
}
|
||||
sql = switch_mprintf("insert into sip_subscriptions values ('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld,'%q','%q')",
|
||||
proto, from_user, from_host, to_user, to_host, event,
|
||||
contact_str, call_id, full_from, full_via, exp, full_agent, accept);
|
||||
|
||||
proto, from_user, from_host, to_user, to_host, event, contact_str, call_id, full_from, full_via, exp, full_agent, accept);
|
||||
|
||||
switch_assert(sql != NULL);
|
||||
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
|
||||
|
||||
sstr = switch_mprintf("active;expires=%ld", exp_raw);
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_unlock(profile->ireg_mutex);
|
||||
|
||||
|
||||
if (status < 200) {
|
||||
char *sticky = NULL;
|
||||
|
||||
|
||||
if (is_nat) {
|
||||
sticky = switch_mprintf("sip:%s@%s:%d", contact_user, network_ip, network_port);
|
||||
}
|
||||
|
||||
nua_respond(nh, SIP_202_ACCEPTED,
|
||||
NUTAG_WITH_THIS(nua),
|
||||
SIPTAG_SUBSCRIPTION_STATE_STR(sstr),
|
||||
TAG_IF(sticky, NUTAG_PROXY(sticky)),
|
||||
nua_respond(nh, SIP_202_ACCEPTED, NUTAG_WITH_THIS(nua), SIPTAG_SUBSCRIPTION_STATE_STR(sstr), TAG_IF(sticky, NUTAG_PROXY(sticky)),
|
||||
//SIPTAG_FROM(sip->sip_to),
|
||||
//SIPTAG_TO(sip->sip_from),
|
||||
//SIPTAG_CONTACT_STR(contact_str),
|
||||
@@ -1413,32 +1369,26 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
switch_safe_free(sticky);
|
||||
|
||||
}
|
||||
|
||||
|
||||
sent_reply++;
|
||||
|
||||
#if 0
|
||||
|
||||
nua_notify(nh,
|
||||
nua_notify(nh,
|
||||
NUTAG_NEWSUB(1),
|
||||
SIPTAG_SUBSCRIPTION_STATE_STR(sstr), SIPTAG_EVENT_STR(event),
|
||||
SIPTAG_SUBSCRIPTION_STATE_STR(sstr), SIPTAG_EVENT_STR(event),
|
||||
SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
|
||||
SIPTAG_PAYLOAD_STR("Note: Come to ClueCon http://www.cluecon.com\n\n"),
|
||||
TAG_END());
|
||||
SIPTAG_PAYLOAD_STR("Note: Come to ClueCon http://www.cluecon.com\n\n"), TAG_END());
|
||||
#endif
|
||||
|
||||
switch_safe_free(sstr);
|
||||
|
||||
if ((sql = switch_mprintf("select * from sip_subscriptions where sip_user='%q' and sip_host='%q'", to_user, to_host))) {
|
||||
sofia_glue_execute_sql_callback(profile,
|
||||
SWITCH_FALSE,
|
||||
profile->ireg_mutex,
|
||||
sql,
|
||||
sofia_presence_sub_reg_callback,
|
||||
profile);
|
||||
sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, sofia_presence_sub_reg_callback, profile);
|
||||
|
||||
switch_safe_free(sql);
|
||||
}
|
||||
end:
|
||||
end:
|
||||
|
||||
if (event) {
|
||||
su_free(profile->home, event);
|
||||
@@ -1466,13 +1416,15 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
}
|
||||
|
||||
void sofia_presence_handle_sip_r_subscribe(int status,
|
||||
char const *phrase,
|
||||
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
|
||||
char const *phrase,
|
||||
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
|
||||
tagi_t tags[])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
|
||||
void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
|
||||
tagi_t tags[])
|
||||
{
|
||||
if (sip) {
|
||||
sip_from_t const *from = sip->sip_from;
|
||||
@@ -1573,8 +1525,9 @@ void sofia_presence_set_hash_key(char *hash_key, int32_t len, sip_t const *sip)
|
||||
}
|
||||
|
||||
void sofia_presence_handle_sip_i_message(int status,
|
||||
char const *phrase,
|
||||
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
|
||||
char const *phrase,
|
||||
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
|
||||
tagi_t tags[])
|
||||
{
|
||||
if (sip) {
|
||||
sip_from_t const *from = sip->sip_from;
|
||||
@@ -1692,7 +1645,7 @@ void sofia_presence_set_chat_hash(private_object_t *tech_pvt, sip_t const *sip)
|
||||
|
||||
if (sofia_reg_find_reg_url(tech_pvt->profile, sip->sip_from->a_url->url_user, sip->sip_from->a_url->url_host, buf, sizeof(buf))) {
|
||||
home = su_home_new(sizeof(*home));
|
||||
switch_assert(home != NULL);
|
||||
switch_assert(home != NULL);
|
||||
tech_pvt->chat_from = sip_header_as_string(home, (const sip_header_t *) sip->sip_to);
|
||||
tech_pvt->chat_to = switch_core_session_strdup(tech_pvt->session, buf);
|
||||
sofia_presence_set_hash_key(hash_key, sizeof(hash_key), sip);
|
||||
@@ -1706,6 +1659,7 @@ void sofia_presence_set_chat_hash(private_object_t *tech_pvt, sip_t const *sip)
|
||||
switch_core_hash_insert(tech_pvt->profile->chat_hash, tech_pvt->hash_key, tech_pvt);
|
||||
|
||||
}
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
@@ -38,21 +38,21 @@
|
||||
|
||||
static void sofia_reg_kill_reg(sofia_gateway_t *gateway_ptr, int unreg)
|
||||
{
|
||||
if (gateway_ptr->nh) {
|
||||
if (unreg) {
|
||||
nua_unregister(gateway_ptr->nh,
|
||||
NUTAG_URL(gateway_ptr->register_url),
|
||||
SIPTAG_FROM_STR(gateway_ptr->register_from),
|
||||
SIPTAG_TO_STR(gateway_ptr->register_from),
|
||||
SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
|
||||
SIPTAG_EXPIRES_STR(gateway_ptr->expires_str),
|
||||
NUTAG_REGISTRAR(gateway_ptr->register_proxy),
|
||||
NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL());
|
||||
}
|
||||
nua_handle_bind(gateway_ptr->nh, NULL);
|
||||
nua_handle_destroy(gateway_ptr->nh);
|
||||
gateway_ptr->nh = NULL;
|
||||
}
|
||||
if (gateway_ptr->nh) {
|
||||
if (unreg) {
|
||||
nua_unregister(gateway_ptr->nh,
|
||||
NUTAG_URL(gateway_ptr->register_url),
|
||||
SIPTAG_FROM_STR(gateway_ptr->register_from),
|
||||
SIPTAG_TO_STR(gateway_ptr->register_from),
|
||||
SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
|
||||
SIPTAG_EXPIRES_STR(gateway_ptr->expires_str),
|
||||
NUTAG_REGISTRAR(gateway_ptr->register_proxy),
|
||||
NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL());
|
||||
}
|
||||
nua_handle_bind(gateway_ptr->nh, NULL);
|
||||
nua_handle_destroy(gateway_ptr->nh);
|
||||
gateway_ptr->nh = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ void sofia_reg_unregister(sofia_profile_t *profile)
|
||||
free(gateway_ptr->sofia_private);
|
||||
gateway_ptr->sofia_private = NULL;
|
||||
}
|
||||
sofia_reg_kill_reg(gateway_ptr, 1);
|
||||
sofia_reg_kill_reg(gateway_ptr, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
||||
gateway_ptr->pinging = 1;
|
||||
nua_options(nh, TAG_END());
|
||||
}
|
||||
|
||||
|
||||
switch (ostate) {
|
||||
case REG_STATE_NOREG:
|
||||
gateway_ptr->status = SOFIA_GATEWAY_UP;
|
||||
@@ -107,12 +107,12 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
||||
break;
|
||||
|
||||
case REG_STATE_UNREGISTER:
|
||||
sofia_reg_kill_reg(gateway_ptr, 1);
|
||||
sofia_reg_kill_reg(gateway_ptr, 1);
|
||||
gateway_ptr->state = REG_STATE_NOREG;
|
||||
break;
|
||||
case REG_STATE_UNREGED:
|
||||
gateway_ptr->status = SOFIA_GATEWAY_DOWN;
|
||||
sofia_reg_kill_reg(gateway_ptr, 1);
|
||||
sofia_reg_kill_reg(gateway_ptr, 1);
|
||||
|
||||
if ((gateway_ptr->nh = nua_handle(gateway_ptr->profile->nua, NULL,
|
||||
NUTAG_URL(gateway_ptr->register_proxy),
|
||||
@@ -120,10 +120,10 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
||||
NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "registering %s\n", gateway_ptr->name);
|
||||
|
||||
if (!gateway_ptr->sofia_private) {
|
||||
gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private));
|
||||
switch_assert(gateway_ptr->sofia_private);
|
||||
}
|
||||
if (!gateway_ptr->sofia_private) {
|
||||
gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private));
|
||||
switch_assert(gateway_ptr->sofia_private);
|
||||
}
|
||||
memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private));
|
||||
|
||||
gateway_ptr->sofia_private->gateway = gateway_ptr;
|
||||
@@ -159,7 +159,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
||||
break;
|
||||
|
||||
case REG_STATE_FAILED:
|
||||
sofia_reg_kill_reg(gateway_ptr, 0);
|
||||
sofia_reg_kill_reg(gateway_ptr, 0);
|
||||
gateway_ptr->status = SOFIA_GATEWAY_DOWN;
|
||||
case REG_STATE_TRYING:
|
||||
if (gateway_ptr->retry && now >= gateway_ptr->retry) {
|
||||
@@ -201,7 +201,7 @@ int sofia_reg_nat_callback(void *pArg, int argc, char **argv, char **columnNames
|
||||
nua_options(nh, TAG_END());
|
||||
|
||||
switch_safe_free(contact);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -242,15 +242,10 @@ void sofia_reg_expire_call_id(sofia_profile_t *profile, const char *call_id)
|
||||
{
|
||||
char sql[1024];
|
||||
char *psql = sql;
|
||||
|
||||
|
||||
switch_snprintf(sql, sizeof(sql), "select *,'%s' from sip_registrations where call_id='%s'", profile->name, call_id);
|
||||
switch_mutex_lock(profile->ireg_mutex);
|
||||
sofia_glue_execute_sql_callback(profile,
|
||||
SWITCH_TRUE,
|
||||
NULL,
|
||||
sql,
|
||||
sofia_reg_del_callback,
|
||||
NULL);
|
||||
sofia_glue_execute_sql_callback(profile, SWITCH_TRUE, NULL, sql, sofia_reg_del_callback, NULL);
|
||||
switch_mutex_unlock(profile->ireg_mutex);
|
||||
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_registrations where call_id='%s'", call_id);
|
||||
@@ -262,19 +257,19 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now)
|
||||
char sql[1024];
|
||||
|
||||
#ifdef SWITCH_HAVE_ODBC
|
||||
if (profile->odbc_dsn) {
|
||||
if (!profile->master_odbc) {
|
||||
if (profile->odbc_dsn) {
|
||||
if (!profile->master_odbc) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
if (!profile->master_db) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
|
||||
return;
|
||||
}
|
||||
#ifdef SWITCH_HAVE_ODBC
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -286,12 +281,7 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now)
|
||||
switch_snprintf(sql, sizeof(sql), "select *,'%s' from sip_registrations where expires > 0", profile->name);
|
||||
}
|
||||
|
||||
sofia_glue_execute_sql_callback(profile,
|
||||
SWITCH_TRUE,
|
||||
NULL,
|
||||
sql,
|
||||
sofia_reg_del_callback,
|
||||
NULL);
|
||||
sofia_glue_execute_sql_callback(profile, SWITCH_TRUE, NULL, sql, sofia_reg_del_callback, NULL);
|
||||
if (now) {
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and expires <= %ld", (long) now);
|
||||
} else {
|
||||
@@ -299,7 +289,7 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now)
|
||||
}
|
||||
|
||||
sofia_glue_actually_execute_sql(profile, SWITCH_FALSE, sql, NULL);
|
||||
|
||||
|
||||
if (now) {
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and expires <= %ld", (long) now);
|
||||
} else {
|
||||
@@ -307,7 +297,7 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now)
|
||||
}
|
||||
|
||||
sofia_glue_actually_execute_sql(profile, SWITCH_FALSE, sql, NULL);
|
||||
|
||||
|
||||
|
||||
|
||||
if (now) {
|
||||
@@ -316,12 +306,7 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now)
|
||||
switch_snprintf(sql, sizeof(sql), "select call_id from sip_subscriptions where expires > 0");
|
||||
}
|
||||
|
||||
sofia_glue_execute_sql_callback(profile,
|
||||
SWITCH_TRUE,
|
||||
NULL,
|
||||
sql,
|
||||
sofia_sub_del_callback,
|
||||
profile);
|
||||
sofia_glue_execute_sql_callback(profile, SWITCH_TRUE, NULL, sql, sofia_sub_del_callback, profile);
|
||||
|
||||
if (now) {
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_subscriptions where expires > 0 and expires <= %ld", (long) now);
|
||||
@@ -330,16 +315,11 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now)
|
||||
}
|
||||
|
||||
sofia_glue_actually_execute_sql(profile, SWITCH_FALSE, sql, NULL);
|
||||
|
||||
|
||||
|
||||
if (now) {
|
||||
switch_snprintf(sql, sizeof(sql), "select * from sip_registrations where status like '%%AUTO-NAT%%'");
|
||||
sofia_glue_execute_sql_callback(profile,
|
||||
SWITCH_TRUE,
|
||||
NULL,
|
||||
sql,
|
||||
sofia_reg_nat_callback,
|
||||
profile);
|
||||
sofia_glue_execute_sql_callback(profile, SWITCH_TRUE, NULL, sql, sofia_reg_nat_callback, profile);
|
||||
}
|
||||
|
||||
switch_mutex_unlock(profile->ireg_mutex);
|
||||
@@ -365,12 +345,7 @@ char *sofia_reg_find_reg_url(sofia_profile_t *profile, const char *user, const c
|
||||
}
|
||||
|
||||
|
||||
sofia_glue_execute_sql_callback(profile,
|
||||
SWITCH_FALSE,
|
||||
profile->ireg_mutex,
|
||||
val,
|
||||
sofia_reg_find_callback,
|
||||
&cbt);
|
||||
sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, val, sofia_reg_find_callback, &cbt);
|
||||
|
||||
|
||||
if (cbt.matches) {
|
||||
@@ -390,30 +365,24 @@ void sofia_reg_auth_challange(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
||||
switch_uuid_get(&uuid);
|
||||
switch_uuid_format(uuid_str, &uuid);
|
||||
|
||||
sql = switch_mprintf("insert into sip_authentication (nonce, expires) values('%q', %ld)",
|
||||
uuid_str, switch_timestamp(NULL) + profile->nonce_ttl);
|
||||
sql = switch_mprintf("insert into sip_authentication (nonce, expires) values('%q', %ld)", uuid_str, switch_timestamp(NULL) + profile->nonce_ttl);
|
||||
switch_assert(sql != NULL);
|
||||
sofia_glue_actually_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex);
|
||||
switch_safe_free(sql);
|
||||
//sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
|
||||
|
||||
auth_str =
|
||||
switch_mprintf("Digest realm=\"%q\", nonce=\"%q\",%s algorithm=MD5, qop=\"auth\"", realm, uuid_str, stale ? " stale=\"true\"," : "");
|
||||
auth_str = switch_mprintf("Digest realm=\"%q\", nonce=\"%q\",%s algorithm=MD5, qop=\"auth\"", realm, uuid_str, stale ? " stale=\"true\"," : "");
|
||||
|
||||
if (regtype == REG_REGISTER) {
|
||||
nua_respond(nh,
|
||||
SIP_401_UNAUTHORIZED,
|
||||
TAG_IF(nua, NUTAG_WITH_THIS(nua)), SIPTAG_WWW_AUTHENTICATE_STR(auth_str), TAG_END());
|
||||
nua_respond(nh, SIP_401_UNAUTHORIZED, TAG_IF(nua, NUTAG_WITH_THIS(nua)), SIPTAG_WWW_AUTHENTICATE_STR(auth_str), TAG_END());
|
||||
} else if (regtype == REG_INVITE) {
|
||||
nua_respond(nh,
|
||||
SIP_407_PROXY_AUTH_REQUIRED,
|
||||
TAG_IF(nua, NUTAG_WITH_THIS(nua)), SIPTAG_PROXY_AUTHENTICATE_STR(auth_str), TAG_END());
|
||||
nua_respond(nh, SIP_407_PROXY_AUTH_REQUIRED, TAG_IF(nua, NUTAG_WITH_THIS(nua)), SIPTAG_PROXY_AUTHENTICATE_STR(auth_str), TAG_END());
|
||||
}
|
||||
|
||||
switch_safe_free(auth_str);
|
||||
}
|
||||
|
||||
uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_handle_t * nh, sip_t const *sip, sofia_regtype_t regtype, char *key,
|
||||
uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, sofia_regtype_t regtype, char *key,
|
||||
uint32_t keylen, switch_event_t **v_event, const char *is_nat)
|
||||
{
|
||||
sip_to_t const *to = NULL;
|
||||
@@ -446,7 +415,7 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
||||
|
||||
get_addr(network_ip, sizeof(network_ip), &((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_addr);
|
||||
network_port = ntohs(((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_port);
|
||||
|
||||
|
||||
expires = sip->sip_expires;
|
||||
authorization = sip->sip_authorization;
|
||||
contact = sip->sip_contact;
|
||||
@@ -468,14 +437,14 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
||||
char new_port[25] = "";
|
||||
const char *contact_host = contact->m_url->url_host;
|
||||
display = contact->m_display;
|
||||
|
||||
|
||||
if (is_nat) {
|
||||
reg_desc = "Registered(AUTO-NAT)";
|
||||
contact_host = network_ip;
|
||||
switch_snprintf(new_port, sizeof(new_port), ":%d", network_port);
|
||||
port = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (switch_strlen_zero(display)) {
|
||||
if (to) {
|
||||
display = to->a_display;
|
||||
@@ -495,13 +464,10 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
||||
|
||||
if (contact->m_url->url_params) {
|
||||
switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s%s;%s>%s%s",
|
||||
display, contact->m_url->url_user, contact_host, new_port, contact->m_url->url_params,
|
||||
received_data,
|
||||
is_nat ? ";nat" : "");
|
||||
display, contact->m_url->url_user, contact_host, new_port, contact->m_url->url_params, received_data, is_nat ? ";nat" : "");
|
||||
} else {
|
||||
switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s%s>%s%s", display, contact->m_url->url_user, contact_host, new_port,
|
||||
received_data,
|
||||
is_nat ? ";nat" : "");
|
||||
switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s%s>%s%s", display, contact->m_url->url_user, contact_host, new_port,
|
||||
received_data, is_nat ? ";nat" : "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -524,37 +490,38 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
||||
|
||||
if (authorization) {
|
||||
char *v_contact_str;
|
||||
if ((auth_res = sofia_reg_parse_auth(profile, authorization, sip, sip->sip_request->rq_method_name,
|
||||
if ((auth_res = sofia_reg_parse_auth(profile, authorization, sip, sip->sip_request->rq_method_name,
|
||||
key, keylen, network_ip, v_event, exptime, regtype, to_user)) == AUTH_STALE) {
|
||||
stale = 1;
|
||||
}
|
||||
|
||||
|
||||
if (exptime && v_event && *v_event) {
|
||||
char *exp_var;
|
||||
|
||||
register_gateway = switch_event_get_header(*v_event, "sip-register-gateway");
|
||||
|
||||
|
||||
/* Allow us to force the SIP user to be something specific - needed if
|
||||
* we - for example - want to be able to ensure that the username a UA can
|
||||
* be contacted at is the same one that they used for authentication.
|
||||
*/
|
||||
*/
|
||||
if ((force_user = switch_event_get_header(*v_event, "sip-force-user"))) {
|
||||
to_user = force_user;
|
||||
}
|
||||
|
||||
|
||||
if ((v_contact_str = switch_event_get_header(*v_event, "sip-force-contact"))) {
|
||||
|
||||
if (*received_data && (profile->pflags & PFLAG_RECIEVED_IN_NAT_REG_CONTACT)) {
|
||||
switch_snprintf(received_data, sizeof(received_data), ";received=\"%s:%d\"", network_ip, network_port);
|
||||
}
|
||||
|
||||
if (!strcasecmp(v_contact_str, "nat-connectile-dysfunction") ||
|
||||
if (!strcasecmp(v_contact_str, "nat-connectile-dysfunction") ||
|
||||
!strcasecmp(v_contact_str, "NDLB-connectile-dysfunction") || !strcasecmp(v_contact_str, "NDLB-tls-connectile-dysfunction")) {
|
||||
if (contact->m_url->url_params) {
|
||||
switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%d;%s>%s;nat",
|
||||
display, contact->m_url->url_user, network_ip, network_port, contact->m_url->url_params, received_data);
|
||||
} else {
|
||||
switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%d>%s;nat", display, contact->m_url->url_user, network_ip, network_port, received_data);
|
||||
switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%d>%s;nat", display, contact->m_url->url_user, network_ip,
|
||||
network_port, received_data);
|
||||
}
|
||||
if (strstr(v_contact_str, "tls")) {
|
||||
reg_desc = "Registered(TLSHACK)";
|
||||
@@ -566,14 +533,14 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
||||
} else {
|
||||
char *p;
|
||||
switch_copy_string(contact_str, v_contact_str, sizeof(contact_str));
|
||||
for(p = contact_str; p && *p; p++) {
|
||||
for (p = contact_str; p && *p; p++) {
|
||||
if (*p == '\'' || *p == '[' || *p == ']') {
|
||||
*p = '"';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((exp_var = switch_event_get_header(*v_event, "sip-force-expires"))) {
|
||||
int tmp = atoi(exp_var);
|
||||
if (tmp > 0) {
|
||||
@@ -585,13 +552,9 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
||||
if (auth_res != AUTH_OK && !stale) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "send %s for [%s@%s]\n", forbidden ? "forbidden" : "challange", to_user, to_host);
|
||||
if (auth_res == AUTH_FORBIDDEN) {
|
||||
nua_respond(nh,
|
||||
SIP_403_FORBIDDEN,
|
||||
NUTAG_WITH_THIS(nua), TAG_END());
|
||||
nua_respond(nh, SIP_403_FORBIDDEN, NUTAG_WITH_THIS(nua), TAG_END());
|
||||
} else {
|
||||
nua_respond(nh,
|
||||
SIP_401_UNAUTHORIZED,
|
||||
NUTAG_WITH_THIS(nua), TAG_END());
|
||||
nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS(nua), TAG_END());
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -604,13 +567,13 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
reg:
|
||||
reg:
|
||||
|
||||
if (regtype != REG_REGISTER) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
call_id = sip->sip_call_id->i_id; //sip_header_as_string(profile->home, (void *) sip->sip_call_id);
|
||||
call_id = sip->sip_call_id->i_id; //sip_header_as_string(profile->home, (void *) sip->sip_call_id);
|
||||
switch_assert(call_id);
|
||||
|
||||
if (exptime) {
|
||||
@@ -627,10 +590,9 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
||||
}
|
||||
switch_mutex_lock(profile->ireg_mutex);
|
||||
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
|
||||
|
||||
|
||||
sql = switch_mprintf("insert into sip_registrations values ('%q', '%q','%q','%q','%q', '%q', %ld, '%q')", call_id,
|
||||
to_user, to_host, contact_str, reg_desc,
|
||||
rpid, (long) switch_timestamp(NULL) + (long) exptime * 2, agent);
|
||||
to_user, to_host, contact_str, reg_desc, rpid, (long) switch_timestamp(NULL) + (long) exptime * 2, agent);
|
||||
if (sql) {
|
||||
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
|
||||
}
|
||||
@@ -647,7 +609,7 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
||||
switch_event_fire(&s_event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (profile->debug) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
@@ -676,7 +638,7 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
||||
if ((sql = switch_mprintf("delete from sip_subscriptions where call_id='%q'", call_id))) {
|
||||
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
|
||||
}
|
||||
|
||||
|
||||
if ((sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id))) {
|
||||
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
|
||||
}
|
||||
@@ -685,7 +647,7 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
||||
if ((sql = switch_mprintf("delete from sip_subscriptions where sip_user='%q' and sip_host='%q'", to_user, to_host))) {
|
||||
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
|
||||
}
|
||||
|
||||
|
||||
if ((sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'", to_user, to_host))) {
|
||||
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
|
||||
}
|
||||
@@ -709,22 +671,22 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if (call_id) {
|
||||
su_free(profile->home, call_id);
|
||||
}
|
||||
*/
|
||||
if (call_id) {
|
||||
su_free(profile->home, call_id);
|
||||
}
|
||||
*/
|
||||
|
||||
if (regtype == REG_REGISTER) {
|
||||
char *new_contact = NULL;
|
||||
char new_port[30] = "";
|
||||
char exp_param[128] = "";
|
||||
|
||||
|
||||
if (exptime) {
|
||||
switch_snprintf(exp_param, sizeof(exp_param), ";expires=%ld", exptime);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (contact->m_url->url_port) {
|
||||
switch_snprintf(new_port, sizeof(new_port), ":%s", contact->m_url->url_port);
|
||||
@@ -732,17 +694,12 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
||||
|
||||
if (contact->m_url->url_params) {
|
||||
new_contact = switch_mprintf("%s <sip:%s@%s%s;%s>%s",
|
||||
display, contact->m_url->url_user, contact->m_url->url_host, new_port, contact->m_url->url_params,
|
||||
exp_param);
|
||||
display, contact->m_url->url_user, contact->m_url->url_host, new_port, contact->m_url->url_params, exp_param);
|
||||
} else {
|
||||
new_contact = switch_mprintf("%s <sip:%s@%s%s>%s",
|
||||
display, contact->m_url->url_user, contact->m_url->url_host, new_port,
|
||||
exp_param);
|
||||
new_contact = switch_mprintf("%s <sip:%s@%s%s>%s", display, contact->m_url->url_user, contact->m_url->url_host, new_port, exp_param);
|
||||
}
|
||||
|
||||
nua_respond(nh,
|
||||
SIP_200_OK,
|
||||
SIPTAG_CONTACT_STR(new_contact), NUTAG_WITH_THIS(nua), TAG_END());
|
||||
|
||||
nua_respond(nh, SIP_200_OK, SIPTAG_CONTACT_STR(new_contact), NUTAG_WITH_THIS(nua), TAG_END());
|
||||
switch_safe_free(new_contact);
|
||||
|
||||
if (exptime) {
|
||||
@@ -763,7 +720,7 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -773,7 +730,8 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
||||
|
||||
|
||||
|
||||
void sofia_reg_handle_sip_i_register(nua_t * nua, sofia_profile_t *profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
|
||||
void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
|
||||
tagi_t tags[])
|
||||
{
|
||||
char key[128] = "";
|
||||
switch_event_t *v_event = NULL;
|
||||
@@ -785,7 +743,7 @@ void sofia_reg_handle_sip_i_register(nua_t * nua, sofia_profile_t *profile, nua_
|
||||
|
||||
get_addr(network_ip, sizeof(network_ip), &((struct sockaddr_in *) my_addrinfo->ai_addr)->sin_addr);
|
||||
network_port = ntohs(((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_port);
|
||||
|
||||
|
||||
|
||||
if (!(sip->sip_contact && sip->sip_contact->m_url)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO CONTACT!\n");
|
||||
@@ -794,9 +752,7 @@ void sofia_reg_handle_sip_i_register(nua_t * nua, sofia_profile_t *profile, nua_
|
||||
}
|
||||
|
||||
if (!(profile->mflags & MFLAG_REGISTER)) {
|
||||
nua_respond(nh,
|
||||
SIP_403_FORBIDDEN,
|
||||
NUTAG_WITH_THIS(nua), TAG_END());
|
||||
nua_respond(nh, SIP_403_FORBIDDEN, NUTAG_WITH_THIS(nua), TAG_END());
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -804,7 +760,7 @@ void sofia_reg_handle_sip_i_register(nua_t * nua, sofia_profile_t *profile, nua_
|
||||
if (sip && sip->sip_via) {
|
||||
const char *port = sip->sip_via->v_port;
|
||||
const char *host = sip->sip_via->v_host;
|
||||
|
||||
|
||||
if (host && sip->sip_via->v_received) {
|
||||
is_nat = "via received";
|
||||
} else if (host && strcmp(network_ip, host)) {
|
||||
@@ -826,13 +782,13 @@ void sofia_reg_handle_sip_i_register(nua_t * nua, sofia_profile_t *profile, nua_
|
||||
}
|
||||
|
||||
if (!switch_strlen_zero(contact_host)) {
|
||||
for (x = 0 ; x < profile->nat_acl_count; x++) {
|
||||
for (x = 0; x < profile->nat_acl_count; x++) {
|
||||
last_acl = profile->nat_acl[x];
|
||||
if (!(ok = switch_check_network_list_ip(contact_host, last_acl))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ok) {
|
||||
is_nat = last_acl;
|
||||
}
|
||||
@@ -844,29 +800,25 @@ void sofia_reg_handle_sip_i_register(nua_t * nua, sofia_profile_t *profile, nua_
|
||||
int ok = 1;
|
||||
char *last_acl = NULL;
|
||||
|
||||
for (x = 0 ; x < profile->reg_acl_count; x++) {
|
||||
for (x = 0; x < profile->reg_acl_count; x++) {
|
||||
last_acl = profile->reg_acl[x];
|
||||
if (!(ok = switch_check_network_list_ip(network_ip, last_acl))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ok && !(profile->pflags & PFLAG_BLIND_REG)) {
|
||||
type = REG_AUTO_REGISTER;
|
||||
} else if (!ok) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "IP %s Rejected by acl %s\n", network_ip, profile->reg_acl[x]);
|
||||
nua_respond(nh,
|
||||
SIP_403_FORBIDDEN,
|
||||
NUTAG_WITH_THIS(nua), TAG_END());
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "IP %s Rejected by acl %s\n", network_ip, profile->reg_acl[x]);
|
||||
nua_respond(nh, SIP_403_FORBIDDEN, NUTAG_WITH_THIS(nua), TAG_END());
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!sip || !sip->sip_request || !sip->sip_request->rq_method_name) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received an invalid packet!\n");
|
||||
nua_respond(nh,
|
||||
SIP_500_INTERNAL_SERVER_ERROR,
|
||||
TAG_END());
|
||||
nua_respond(nh, SIP_500_INTERNAL_SERVER_ERROR, TAG_END());
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -876,7 +828,7 @@ void sofia_reg_handle_sip_i_register(nua_t * nua, sofia_profile_t *profile, nua_
|
||||
switch_event_fire(&v_event);
|
||||
}
|
||||
|
||||
end:
|
||||
end:
|
||||
|
||||
nua_handle_destroy(nh);
|
||||
|
||||
@@ -885,7 +837,8 @@ void sofia_reg_handle_sip_i_register(nua_t * nua, sofia_profile_t *profile, nua_
|
||||
|
||||
void sofia_reg_handle_sip_r_register(int status,
|
||||
char const *phrase,
|
||||
nua_t * nua, sofia_profile_t *profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
|
||||
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
|
||||
tagi_t tags[])
|
||||
{
|
||||
if (sofia_private && sofia_private->gateway) {
|
||||
switch (status) {
|
||||
@@ -915,7 +868,7 @@ void sofia_reg_handle_sip_r_register(int status,
|
||||
|
||||
void sofia_reg_handle_sip_r_challenge(int status,
|
||||
char const *phrase,
|
||||
nua_t * nua, sofia_profile_t *profile, nua_handle_t * nh,
|
||||
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh,
|
||||
switch_core_session_t *session, sofia_gateway_t *gateway, sip_t const *sip, tagi_t tags[])
|
||||
{
|
||||
sip_www_authenticate_t const *authenticate = NULL;
|
||||
@@ -976,17 +929,17 @@ void sofia_reg_handle_sip_r_challenge(int status,
|
||||
|
||||
return;
|
||||
|
||||
cancel:
|
||||
cancel:
|
||||
|
||||
if (session) {
|
||||
switch_channel_hangup(switch_core_session_get_channel(session), SWITCH_CAUSE_MANDATORY_IE_MISSING);
|
||||
} else {
|
||||
nua_cancel(nh, TAG_END());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t const *authorization, sip_t const *sip, const char *regstr,
|
||||
auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t const *authorization, sip_t const *sip, const char *regstr,
|
||||
char *np, size_t nplen, char *ip, switch_event_t **v_event, long exptime, sofia_regtype_t regtype, const char *to_user)
|
||||
{
|
||||
int indexnum;
|
||||
@@ -1001,13 +954,13 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
|
||||
const char *a1_hash = NULL;
|
||||
char *sql;
|
||||
char *mailbox = NULL;
|
||||
switch_xml_t domain, xml = NULL, user, param, uparams, dparams;
|
||||
switch_xml_t domain, xml = NULL, user, param, uparams, dparams;
|
||||
char hexdigest[2 * SU_MD5_DIGEST_SIZE + 1] = "";
|
||||
char *domain_name = NULL;
|
||||
switch_event_t *params = NULL;
|
||||
|
||||
username = realm = nonce = uri = qop = cnonce = nc = response = NULL;
|
||||
|
||||
|
||||
if (authorization->au_params) {
|
||||
for (indexnum = 0; (cur = authorization->au_params[indexnum]); indexnum++) {
|
||||
char *var, *val, *p, *work;
|
||||
@@ -1052,7 +1005,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
|
||||
ret = AUTH_STALE;
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
/* Optional check that auth name == SIP username */
|
||||
if ((regtype == REG_REGISTER) && (profile->pflags & PFLAG_CHECKUSER)) {
|
||||
if (switch_strlen_zero(username) || switch_strlen_zero(to_user) || strcasecmp(to_user, username)) {
|
||||
@@ -1072,44 +1025,45 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
|
||||
goto end;
|
||||
}
|
||||
free(sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
switch_event_create(¶ms, SWITCH_EVENT_MESSAGE);
|
||||
switch_assert(params);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "action", "sip_auth");
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "sip_profile", profile->name);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "sip_user_agent", (sip && sip->sip_user_agent) ? sip->sip_user_agent->g_string : "unknown");
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "sip_user_agent",
|
||||
(sip && sip->sip_user_agent) ? sip->sip_user_agent->g_string : "unknown");
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "sip_auth_username", username);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "sip_auth_realm", realm);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "sip_auth_nonce", nonce);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "sip_auth_uri", uri);
|
||||
if (qop) {
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "sip_auth_qop", qop);
|
||||
}
|
||||
if (cnonce) {
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "sip_auth_cnonce", cnonce);
|
||||
}
|
||||
if (nc) {
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "sip_auth_nc", nc);
|
||||
}
|
||||
if (qop) {
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "sip_auth_qop", qop);
|
||||
}
|
||||
if (cnonce) {
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "sip_auth_cnonce", cnonce);
|
||||
}
|
||||
if (nc) {
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "sip_auth_nc", nc);
|
||||
}
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "sip_auth_response", response);
|
||||
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "sip_auth_method", (sip && sip->sip_request) ? sip->sip_request->rq_method_name : NULL);
|
||||
|
||||
|
||||
|
||||
if (!switch_strlen_zero(profile->reg_domain)) {
|
||||
domain_name = profile->reg_domain;
|
||||
} else {
|
||||
domain_name = realm;
|
||||
}
|
||||
|
||||
|
||||
if (switch_xml_locate_user("id", username, domain_name, ip, &xml, &domain, &user, params) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", username, domain_name);
|
||||
ret = AUTH_FORBIDDEN;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!(mailbox = (char *)switch_xml_attr(user, "mailbox"))) {
|
||||
if (!(mailbox = (char *) switch_xml_attr(user, "mailbox"))) {
|
||||
mailbox = username;
|
||||
}
|
||||
|
||||
@@ -1125,11 +1079,11 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
|
||||
for (param = switch_xml_child(dparams, "param"); param; param = param->next) {
|
||||
const char *var = switch_xml_attr_soft(param, "name");
|
||||
const char *val = switch_xml_attr_soft(param, "value");
|
||||
|
||||
|
||||
if (!strcasecmp(var, "password")) {
|
||||
passwd = val;
|
||||
}
|
||||
|
||||
|
||||
if (!strcasecmp(var, "a1-hash")) {
|
||||
a1_hash = val;
|
||||
}
|
||||
@@ -1140,11 +1094,11 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
|
||||
for (param = switch_xml_child(uparams, "param"); param; param = param->next) {
|
||||
const char *var = switch_xml_attr_soft(param, "name");
|
||||
const char *val = switch_xml_attr_soft(param, "value");
|
||||
|
||||
|
||||
if (!strcasecmp(var, "password")) {
|
||||
passwd = val;
|
||||
}
|
||||
|
||||
|
||||
if (!strcasecmp(var, "a1-hash")) {
|
||||
a1_hash = val;
|
||||
}
|
||||
@@ -1164,10 +1118,10 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
|
||||
su_md5_deinit(&ctx);
|
||||
switch_safe_free(input);
|
||||
a1_hash = hexdigest;
|
||||
|
||||
|
||||
}
|
||||
|
||||
for_the_sake_of_interop:
|
||||
for_the_sake_of_interop:
|
||||
|
||||
if ((input = switch_mprintf("%s:%q", regstr, uri))) {
|
||||
su_md5_init(&ctx);
|
||||
@@ -1176,38 +1130,38 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
|
||||
su_md5_deinit(&ctx);
|
||||
}
|
||||
|
||||
if (nc && cnonce && qop) {
|
||||
input2 = switch_mprintf("%q:%q:%q:%q:%q:%q", a1_hash, nonce, nc, cnonce, qop, uridigest);
|
||||
} else {
|
||||
input2 = switch_mprintf("%q:%q:%q", a1_hash, nonce, uridigest);
|
||||
}
|
||||
if (nc && cnonce && qop) {
|
||||
input2 = switch_mprintf("%q:%q:%q:%q:%q:%q", a1_hash, nonce, nc, cnonce, qop, uridigest);
|
||||
} else {
|
||||
input2 = switch_mprintf("%q:%q:%q", a1_hash, nonce, uridigest);
|
||||
}
|
||||
|
||||
switch_assert(input2);
|
||||
switch_assert(input2);
|
||||
|
||||
memset(&ctx, 0, sizeof(ctx));
|
||||
su_md5_init(&ctx);
|
||||
su_md5_strupdate(&ctx, input2);
|
||||
su_md5_hexdigest(&ctx, bigdigest);
|
||||
su_md5_deinit(&ctx);
|
||||
memset(&ctx, 0, sizeof(ctx));
|
||||
su_md5_init(&ctx);
|
||||
su_md5_strupdate(&ctx, input2);
|
||||
su_md5_hexdigest(&ctx, bigdigest);
|
||||
su_md5_deinit(&ctx);
|
||||
|
||||
if (!strcasecmp(bigdigest, response)) {
|
||||
ret = AUTH_OK;
|
||||
} else {
|
||||
if ((profile->ndlb & PFLAG_NDLB_BROKEN_AUTH_HASH) && strcasecmp(regstr, "REGISTER") && strcasecmp(regstr, "INVITE")) {
|
||||
/* some clients send an ACK with the method 'INVITE' in the hash which will break auth so we will
|
||||
try again with INVITE so we don't get people complaining to us when someone else's client has a bug......
|
||||
*/
|
||||
switch_safe_free(input);
|
||||
switch_safe_free(input2);
|
||||
regstr = "INVITE";
|
||||
goto for_the_sake_of_interop;
|
||||
}
|
||||
if (!strcasecmp(bigdigest, response)) {
|
||||
ret = AUTH_OK;
|
||||
} else {
|
||||
if ((profile->ndlb & PFLAG_NDLB_BROKEN_AUTH_HASH) && strcasecmp(regstr, "REGISTER") && strcasecmp(regstr, "INVITE")) {
|
||||
/* some clients send an ACK with the method 'INVITE' in the hash which will break auth so we will
|
||||
try again with INVITE so we don't get people complaining to us when someone else's client has a bug......
|
||||
*/
|
||||
switch_safe_free(input);
|
||||
switch_safe_free(input2);
|
||||
regstr = "INVITE";
|
||||
goto for_the_sake_of_interop;
|
||||
}
|
||||
|
||||
ret = AUTH_FORBIDDEN;
|
||||
}
|
||||
|
||||
ret = AUTH_FORBIDDEN;
|
||||
}
|
||||
|
||||
skip_auth:
|
||||
|
||||
skip_auth:
|
||||
|
||||
if (first && ret == AUTH_OK) {
|
||||
if (v_event) {
|
||||
@@ -1223,7 +1177,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
|
||||
switch_event_add_header(*v_event, SWITCH_STACK_BOTTOM, "mailbox", "%s", mailbox);
|
||||
switch_event_add_header(*v_event, SWITCH_STACK_BOTTOM, "user_name", "%s", username);
|
||||
switch_event_add_header(*v_event, SWITCH_STACK_BOTTOM, "domain_name", "%s", realm);
|
||||
|
||||
|
||||
if ((dparams = switch_xml_child(domain, "variables"))) {
|
||||
xparams[i++] = dparams;
|
||||
}
|
||||
@@ -1243,7 +1197,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
|
||||
|
||||
if (!switch_strlen_zero(var) && !switch_strlen_zero(val)) {
|
||||
switch_event_add_header(*v_event, SWITCH_STACK_BOTTOM, var, "%s", val);
|
||||
|
||||
|
||||
if (!strcasecmp(var, "register-gateway")) {
|
||||
if (!strcasecmp(val, "all")) {
|
||||
switch_xml_t gateways_tag, gateway_tag;
|
||||
@@ -1253,7 +1207,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
|
||||
if (switch_strlen_zero(name)) {
|
||||
name = "anonymous";
|
||||
}
|
||||
|
||||
|
||||
if ((gateway_ptr = sofia_reg_find_gateway(name))) {
|
||||
gateway_ptr->retry = 0;
|
||||
if (exptime) {
|
||||
@@ -1263,7 +1217,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
|
||||
}
|
||||
sofia_reg_release_gateway(gateway_ptr);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -1272,11 +1226,11 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
|
||||
|
||||
mydata = strdup(val);
|
||||
switch_assert(mydata != NULL);
|
||||
|
||||
|
||||
argc = switch_separate_string(mydata, ',', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
for (x = 0; x < argc; x++) {
|
||||
if ((gateway_ptr = sofia_reg_find_gateway((char *)argv[x]))) {
|
||||
if ((gateway_ptr = sofia_reg_find_gateway((char *) argv[x]))) {
|
||||
gateway_ptr->retry = 0;
|
||||
if (exptime) {
|
||||
gateway_ptr->state = REG_STATE_UNREGED;
|
||||
@@ -1298,7 +1252,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
|
||||
}
|
||||
}
|
||||
}
|
||||
end:
|
||||
end:
|
||||
|
||||
switch_event_destroy(¶ms);
|
||||
|
||||
@@ -1329,7 +1283,7 @@ sofia_gateway_t *sofia_reg_find_gateway__(const char *file, const char *func, in
|
||||
switch_mutex_lock(mod_sofia_globals.hash_mutex);
|
||||
if ((gateway = (sofia_gateway_t *) switch_core_hash_find(mod_sofia_globals.gateway_hash, key))) {
|
||||
if (!(gateway->profile->pflags & PFLAG_RUNNING)) {
|
||||
gateway = NULL;
|
||||
gateway = NULL;
|
||||
goto done;
|
||||
}
|
||||
if (switch_thread_rwlock_tryrdlock(gateway->profile->rwlock) != SWITCH_STATUS_SUCCESS) {
|
||||
@@ -1343,7 +1297,7 @@ sofia_gateway_t *sofia_reg_find_gateway__(const char *file, const char *func, in
|
||||
#endif
|
||||
}
|
||||
|
||||
done:
|
||||
done:
|
||||
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
|
||||
return gateway;
|
||||
}
|
||||
|
||||
@@ -39,16 +39,16 @@
|
||||
#define RANGE_CHANNEL 0x1
|
||||
|
||||
|
||||
char read_enable=0;
|
||||
char write_enable=0;
|
||||
char primary_enable=0;
|
||||
int tx_cnt=1;
|
||||
int rx_cnt=0;
|
||||
int tx_size=10;
|
||||
int tx_delay=0;
|
||||
int tx_data=-1;
|
||||
int tx_ss7_type=0;
|
||||
int rx_ss7_timer=0;
|
||||
char read_enable = 0;
|
||||
char write_enable = 0;
|
||||
char primary_enable = 0;
|
||||
int tx_cnt = 1;
|
||||
int rx_cnt = 0;
|
||||
int tx_size = 10;
|
||||
int tx_delay = 0;
|
||||
int tx_data = -1;
|
||||
int tx_ss7_type = 0;
|
||||
int rx_ss7_timer = 0;
|
||||
|
||||
unsigned char card_name[WAN_IFNAME_SZ];
|
||||
unsigned char if_name[WAN_IFNAME_SZ];
|
||||
@@ -63,343 +63,343 @@ unsigned char daddr[TX_ADDR_STR_SZ];
|
||||
unsigned char saddr[TX_ADDR_STR_SZ];
|
||||
unsigned char udata[TX_ADDR_STR_SZ];
|
||||
|
||||
int files_used=0;
|
||||
int verbose=0;
|
||||
int files_used = 0;
|
||||
int verbose = 0;
|
||||
|
||||
int tx_connections;
|
||||
int tx_connections;
|
||||
|
||||
int ds_prot=0;
|
||||
int ds_prot_opt=0;
|
||||
int ds_max_mult_cnt=0;
|
||||
unsigned int ds_active_ch=0;
|
||||
int ds_7bit_hdlc=0;
|
||||
int direction=-1;
|
||||
int ds_prot = 0;
|
||||
int ds_prot_opt = 0;
|
||||
int ds_max_mult_cnt = 0;
|
||||
unsigned int ds_active_ch = 0;
|
||||
int ds_7bit_hdlc = 0;
|
||||
int direction = -1;
|
||||
|
||||
int tx_channels=1;
|
||||
int cause=0;
|
||||
int diagn=0;
|
||||
int tx_channels = 1;
|
||||
int cause = 0;
|
||||
int diagn = 0;
|
||||
|
||||
int card_cnt=0;
|
||||
int i_cnt=0;
|
||||
int card_cnt = 0;
|
||||
int i_cnt = 0;
|
||||
|
||||
unsigned long parse_active_channel(char* val);
|
||||
unsigned long parse_active_channel(char *val);
|
||||
|
||||
int init_args(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
int c_cnt=0;
|
||||
int c_cnt = 0;
|
||||
|
||||
sprintf(daddr,"111");
|
||||
sprintf(saddr,"222");
|
||||
sprintf(udata,"C9");
|
||||
|
||||
for (i = 0; i < argc; i++){
|
||||
|
||||
if (!strcmp(argv[i],"-i")){
|
||||
sprintf(daddr, "111");
|
||||
sprintf(saddr, "222");
|
||||
sprintf(udata, "C9");
|
||||
|
||||
if (i+1 > argc-1){
|
||||
for (i = 0; i < argc; i++) {
|
||||
|
||||
if (!strcmp(argv[i], "-i")) {
|
||||
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid Interface Name!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
strncpy(if_name, argv[i+1],WAN_IFNAME_SZ);
|
||||
i_cnt=1;
|
||||
|
||||
}else if (!strcmp(argv[i],"-si")){
|
||||
if (i+1 > argc-1){
|
||||
strncpy(if_name, argv[i + 1], WAN_IFNAME_SZ);
|
||||
i_cnt = 1;
|
||||
|
||||
} else if (!strcmp(argv[i], "-si")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid Switch Interface Name!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
strncpy(sw_if_name, argv[i+1], WAN_IFNAME_SZ);
|
||||
|
||||
}else if (!strcmp(argv[i],"-c")){
|
||||
if (i+1 > argc-1){
|
||||
strncpy(sw_if_name, argv[i + 1], WAN_IFNAME_SZ);
|
||||
|
||||
} else if (!strcmp(argv[i], "-c")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid Card Name!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
strncpy(card_name, argv[i+1], WAN_IFNAME_SZ);
|
||||
card_cnt=1;
|
||||
|
||||
}else if (!strcmp(argv[i],"-sc")){
|
||||
if (i+1 > argc-1){
|
||||
|
||||
strncpy(card_name, argv[i + 1], WAN_IFNAME_SZ);
|
||||
card_cnt = 1;
|
||||
|
||||
} else if (!strcmp(argv[i], "-sc")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid Switch Card Name!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
strncpy(sw_card_name, argv[i+1], WAN_IFNAME_SZ);
|
||||
|
||||
}else if (!strcmp(argv[i],"-r")){
|
||||
read_enable=1;
|
||||
c_cnt=1;
|
||||
|
||||
}else if (!strcmp(argv[i],"-w")){
|
||||
write_enable=1;
|
||||
c_cnt=1;
|
||||
strncpy(sw_card_name, argv[i + 1], WAN_IFNAME_SZ);
|
||||
|
||||
}else if (!strcmp(argv[i],"-pri")){
|
||||
primary_enable=1;
|
||||
|
||||
}else if (!strcmp(argv[i],"-txcnt")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid tx cnt!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
} else if (!strcmp(argv[i], "-r")) {
|
||||
read_enable = 1;
|
||||
c_cnt = 1;
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
tx_cnt = atoi(argv[i+1]);
|
||||
}else{
|
||||
} else if (!strcmp(argv[i], "-w")) {
|
||||
write_enable = 1;
|
||||
c_cnt = 1;
|
||||
|
||||
} else if (!strcmp(argv[i], "-pri")) {
|
||||
primary_enable = 1;
|
||||
|
||||
} else if (!strcmp(argv[i], "-txcnt")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid tx cnt!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
}else if (!strcmp(argv[i],"-rxcnt")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid rx cnt!\n");
|
||||
if (isdigit(argv[i + 1][0])) {
|
||||
tx_cnt = atoi(argv[i + 1]);
|
||||
} else {
|
||||
printf("ERROR: Invalid tx cnt!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
rx_cnt = atoi(argv[i+1]);
|
||||
}else{
|
||||
} else if (!strcmp(argv[i], "-rxcnt")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid rx cnt!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
}else if (!strcmp(argv[i],"-txsize")){
|
||||
if (i+1 > argc-1){
|
||||
if (isdigit(argv[i + 1][0])) {
|
||||
rx_cnt = atoi(argv[i + 1]);
|
||||
} else {
|
||||
printf("ERROR: Invalid rx cnt!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
} else if (!strcmp(argv[i], "-txsize")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid tx size!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
tx_size = atoi(argv[i+1]);
|
||||
}else{
|
||||
if (isdigit(argv[i + 1][0])) {
|
||||
tx_size = atoi(argv[i + 1]);
|
||||
} else {
|
||||
printf("ERROR: Invalid tx size, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}else if (!strcmp(argv[i],"-txdelay")){
|
||||
if (i+1 > argc-1){
|
||||
} else if (!strcmp(argv[i], "-txdelay")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid tx delay!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
tx_delay = atoi(argv[i+1]);
|
||||
}else{
|
||||
if (isdigit(argv[i + 1][0])) {
|
||||
tx_delay = atoi(argv[i + 1]);
|
||||
} else {
|
||||
printf("ERROR: Invalid tx delay, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}else if (!strcmp(argv[i],"-txdata")){
|
||||
if (i+1 > argc-1){
|
||||
} else if (!strcmp(argv[i], "-txdata")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid tx data!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
tx_data = atoi(argv[i+1]);
|
||||
}else{
|
||||
if (isdigit(argv[i + 1][0])) {
|
||||
tx_data = atoi(argv[i + 1]);
|
||||
} else {
|
||||
printf("ERROR: Invalid tx data, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}else if (!strcmp(argv[i],"-tx_ss7_type")){
|
||||
if (i+1 > argc-1){
|
||||
} else if (!strcmp(argv[i], "-tx_ss7_type")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid tx ss7 type!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
tx_ss7_type = atoi(argv[i+1]);
|
||||
}else{
|
||||
|
||||
if (isdigit(argv[i + 1][0])) {
|
||||
tx_ss7_type = atoi(argv[i + 1]);
|
||||
} else {
|
||||
printf("ERROR: Invalid tx ss7 type, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
}else if (!strcmp(argv[i],"-rx_ss7_timer")){
|
||||
if (i+1 > argc-1){
|
||||
|
||||
} else if (!strcmp(argv[i], "-rx_ss7_timer")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid rx ss7 timer!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
rx_ss7_timer = atoi(argv[i+1]);
|
||||
}else{
|
||||
|
||||
if (isdigit(argv[i + 1][0])) {
|
||||
rx_ss7_timer = atoi(argv[i + 1]);
|
||||
} else {
|
||||
printf("ERROR: Invalid tx ss7 type, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
}else if (!strcmp(argv[i],"-txfile")){
|
||||
|
||||
if (i+1 > argc-1){
|
||||
} else if (!strcmp(argv[i], "-txfile")) {
|
||||
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid Tx File Name!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
strncpy(tx_file, argv[i+1],WAN_IFNAME_SZ);
|
||||
strncpy(tx_file, argv[i + 1], WAN_IFNAME_SZ);
|
||||
files_used |= TX_FILE_USED;
|
||||
|
||||
}else if (!strcmp(argv[i],"-rxfile")){
|
||||
|
||||
if (i+1 > argc-1){
|
||||
} else if (!strcmp(argv[i], "-rxfile")) {
|
||||
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid Rx File Name!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
strncpy(rx_file, argv[i+1],WAN_IFNAME_SZ);
|
||||
strncpy(rx_file, argv[i + 1], WAN_IFNAME_SZ);
|
||||
files_used |= RX_FILE_USED;
|
||||
|
||||
}else if (!strcmp(argv[i],"-daddr")){
|
||||
} else if (!strcmp(argv[i], "-daddr")) {
|
||||
|
||||
if (i+1 > argc-1){
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid daddr str!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
strncpy(daddr, argv[i+1],TX_ADDR_STR_SZ);
|
||||
|
||||
}else if (!strcmp(argv[i],"-saddr")){
|
||||
strncpy(daddr, argv[i + 1], TX_ADDR_STR_SZ);
|
||||
|
||||
if (i+1 > argc-1){
|
||||
} else if (!strcmp(argv[i], "-saddr")) {
|
||||
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid saddr str!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
strncpy(saddr, argv[i+1],TX_ADDR_STR_SZ);
|
||||
|
||||
}else if (!strcmp(argv[i],"-udata")){
|
||||
strncpy(saddr, argv[i + 1], TX_ADDR_STR_SZ);
|
||||
|
||||
if (i+1 > argc-1){
|
||||
} else if (!strcmp(argv[i], "-udata")) {
|
||||
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid udata str!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
strncpy(udata, argv[i+1],TX_ADDR_STR_SZ);
|
||||
strncpy(udata, argv[i + 1], TX_ADDR_STR_SZ);
|
||||
|
||||
}else if (!strcmp(argv[i],"-verbose")){
|
||||
verbose=1;
|
||||
} else if (!strcmp(argv[i], "-verbose")) {
|
||||
verbose = 1;
|
||||
|
||||
}else if (!strcmp(argv[i],"-prot")){
|
||||
if (i+1 > argc-1){
|
||||
} else if (!strcmp(argv[i], "-prot")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid prot!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
ds_prot = atoi(argv[i+1]);
|
||||
}else{
|
||||
if (isdigit(argv[i + 1][0])) {
|
||||
ds_prot = atoi(argv[i + 1]);
|
||||
} else {
|
||||
printf("ERROR: Invalid prot, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
}else if (!strcmp(argv[i],"-prot_opt")){
|
||||
if (i+1 > argc-1){
|
||||
|
||||
} else if (!strcmp(argv[i], "-prot_opt")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid prot_opt!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
ds_prot_opt = atoi(argv[i+1]);
|
||||
}else{
|
||||
if (isdigit(argv[i + 1][0])) {
|
||||
ds_prot_opt = atoi(argv[i + 1]);
|
||||
} else {
|
||||
printf("ERROR: Invalid prot_opt, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}else if (!strcmp(argv[i],"-max_mult_cnt")){
|
||||
if (i+1 > argc-1){
|
||||
} else if (!strcmp(argv[i], "-max_mult_cnt")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid max_mult_cnt!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
ds_max_mult_cnt = atoi(argv[i+1]);
|
||||
}else{
|
||||
if (isdigit(argv[i + 1][0])) {
|
||||
ds_max_mult_cnt = atoi(argv[i + 1]);
|
||||
} else {
|
||||
printf("ERROR: Invalid max_mult_cnt, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}else if (!strcmp(argv[i],"-active_ch")){
|
||||
if (i+1 > argc-1){
|
||||
} else if (!strcmp(argv[i], "-active_ch")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid active ch!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
ds_active_ch = parse_active_channel(argv[i+1]);
|
||||
}else if (!strcmp(argv[i],"-txchan")){
|
||||
if (i+1 > argc-1){
|
||||
ds_active_ch = parse_active_channel(argv[i + 1]);
|
||||
} else if (!strcmp(argv[i], "-txchan")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid channels!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
tx_channels = atoi(argv[i+1]);
|
||||
}else{
|
||||
if (isdigit(argv[i + 1][0])) {
|
||||
tx_channels = atoi(argv[i + 1]);
|
||||
} else {
|
||||
printf("ERROR: Invalid channels, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}else if (!strcmp(argv[i],"-diagn")){
|
||||
if (i+1 > argc-1){
|
||||
} else if (!strcmp(argv[i], "-diagn")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid diagn!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
diagn = atoi(argv[i+1]);
|
||||
}else{
|
||||
if (isdigit(argv[i + 1][0])) {
|
||||
diagn = atoi(argv[i + 1]);
|
||||
} else {
|
||||
printf("ERROR: Invalid diagn, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
}else if (!strcmp(argv[i],"-cause")){
|
||||
if (i+1 > argc-1){
|
||||
|
||||
} else if (!strcmp(argv[i], "-cause")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid cause!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
cause = atoi(argv[i+1]);
|
||||
}else{
|
||||
if (isdigit(argv[i + 1][0])) {
|
||||
cause = atoi(argv[i + 1]);
|
||||
} else {
|
||||
printf("ERROR: Invalid cause, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
}else if (!strcmp(argv[i],"-7bit_hdlc")){
|
||||
if (i+1 > argc-1){
|
||||
} else if (!strcmp(argv[i], "-7bit_hdlc")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid 7bit hdlc value!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
ds_7bit_hdlc = atoi(argv[i+1]);
|
||||
}else{
|
||||
if (isdigit(argv[i + 1][0])) {
|
||||
ds_7bit_hdlc = atoi(argv[i + 1]);
|
||||
} else {
|
||||
printf("ERROR: Invalid 7bit hdlc, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
}else if (!strcmp(argv[i],"-dir")){
|
||||
if (i+1 > argc-1){
|
||||
} else if (!strcmp(argv[i], "-dir")) {
|
||||
if (i + 1 > argc - 1) {
|
||||
printf("ERROR: Invalid direction value!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
direction = atoi(argv[i+1]);
|
||||
}else{
|
||||
if (isdigit(argv[i + 1][0])) {
|
||||
direction = atoi(argv[i + 1]);
|
||||
} else {
|
||||
printf("ERROR: Invalid direction, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!i_cnt){
|
||||
if (!i_cnt) {
|
||||
printf("ERROR: No Interface Name!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
if (!card_cnt){
|
||||
if (!card_cnt) {
|
||||
printf("ERROR: No Card name!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
if (!c_cnt){
|
||||
if (!c_cnt) {
|
||||
printf("ERROR: No Read or Write Command!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
@@ -407,69 +407,66 @@ int init_args(int argc, char *argv[])
|
||||
return WAN_TRUE;
|
||||
}
|
||||
|
||||
static unsigned char api_usage[]="\n"
|
||||
"\n"
|
||||
"<options>:\n"
|
||||
" -i <ifname> #interface name\n"
|
||||
" -c <card name> #card name\n"
|
||||
" -r #read enable\n"
|
||||
" -w #write eable\n"
|
||||
"\n"
|
||||
"<extra options>\n"
|
||||
" -txcnt <digit> #number of tx packets (Dflt: 1)\n"
|
||||
" -txsize <digit> #tx packet size (Dflt: 10)\n"
|
||||
" -txdelay <digit> #delay in sec after each tx packet (Dflt: 0)\n"
|
||||
" -txdata <digit> #data to tx <1-255>\n"
|
||||
"\n"
|
||||
" -txfile <file> #Use file to tx instead\n"
|
||||
" -rxfile <file> #Save all rx data to a file\n"
|
||||
" \n"
|
||||
"\n"
|
||||
" -tx_ss7_type <digit> # 1=FISU 2=LSSU (repeating)\n"
|
||||
" -rx_ss7_timer <digit> #Force receive timeout value \n"
|
||||
"\n"
|
||||
" -rxcnt <digit> #number of rx packets before exit\n"
|
||||
" #this number overwrites the txcnt\n"
|
||||
" #Thus, app will only exit after it\n"
|
||||
" #receives the rxcnt number of packets.\n"
|
||||
" \n"
|
||||
" -verbose #Enable verbose mode\n"
|
||||
"\n"
|
||||
"<datascope options>\n"
|
||||
"\n"
|
||||
" -prot <digit> #Protocol Bit map: \n"
|
||||
" #1=FISU, 2=LSSU, 4=MSU, 8=RAW HDLC\n"
|
||||
" \n"
|
||||
" -prot_opt <digit> #Protocol bit map\n"
|
||||
" #0=None, 1=Delta, 2=Max Multiple\n"
|
||||
"\n"
|
||||
" -active_ch <digit> #Active channel\n"
|
||||
" #ALL = all channels \n"
|
||||
" #1 24 = 1 to 24 \n"
|
||||
" #1.24 = 1 and 24 \n"
|
||||
" #1-4.7-15 = 1 to 4 and 7 to 15\n"
|
||||
" \n"
|
||||
" -max_mult_cnt <digit> #If Prot_opt == 2 \n"
|
||||
" #max_mult_cnt is the number of \n"
|
||||
" #consecutive duplicate frames \n"
|
||||
" #received before pass up the stack.\n"
|
||||
" \n"
|
||||
" -7bit_hdlc <digit> #Enable 7 Bit Hdlc Engine\n"
|
||||
" #1=Enable 0=Disable\n"
|
||||
" \n"
|
||||
" -dir <digit> #Direction 0: Rx 1: Tx none: All\n"
|
||||
"\n"
|
||||
"<x25 protocol options>\n"
|
||||
"\n"
|
||||
" -txchan <digit> #Number of channels (dflt=1)\n"
|
||||
" -cause <digit> #disconnect cause (dflt=0)\n"
|
||||
" -diagn <digit> #disconnect diagnostic (dflt=0)\n"
|
||||
"\n";
|
||||
static unsigned char api_usage[] = "\n"
|
||||
"\n"
|
||||
"<options>:\n"
|
||||
" -i <ifname> #interface name\n"
|
||||
" -c <card name> #card name\n"
|
||||
" -r #read enable\n"
|
||||
" -w #write eable\n"
|
||||
"\n"
|
||||
"<extra options>\n"
|
||||
" -txcnt <digit> #number of tx packets (Dflt: 1)\n"
|
||||
" -txsize <digit> #tx packet size (Dflt: 10)\n"
|
||||
" -txdelay <digit> #delay in sec after each tx packet (Dflt: 0)\n"
|
||||
" -txdata <digit> #data to tx <1-255>\n"
|
||||
"\n"
|
||||
" -txfile <file> #Use file to tx instead\n"
|
||||
" -rxfile <file> #Save all rx data to a file\n"
|
||||
" \n"
|
||||
"\n"
|
||||
" -tx_ss7_type <digit> # 1=FISU 2=LSSU (repeating)\n"
|
||||
" -rx_ss7_timer <digit> #Force receive timeout value \n"
|
||||
"\n"
|
||||
" -rxcnt <digit> #number of rx packets before exit\n"
|
||||
" #this number overwrites the txcnt\n"
|
||||
" #Thus, app will only exit after it\n"
|
||||
" #receives the rxcnt number of packets.\n"
|
||||
" \n"
|
||||
" -verbose #Enable verbose mode\n"
|
||||
"\n"
|
||||
"<datascope options>\n"
|
||||
"\n"
|
||||
" -prot <digit> #Protocol Bit map: \n"
|
||||
" #1=FISU, 2=LSSU, 4=MSU, 8=RAW HDLC\n"
|
||||
" \n"
|
||||
" -prot_opt <digit> #Protocol bit map\n"
|
||||
" #0=None, 1=Delta, 2=Max Multiple\n"
|
||||
"\n"
|
||||
" -active_ch <digit> #Active channel\n"
|
||||
" #ALL = all channels \n"
|
||||
" #1 24 = 1 to 24 \n"
|
||||
" #1.24 = 1 and 24 \n"
|
||||
" #1-4.7-15 = 1 to 4 and 7 to 15\n"
|
||||
" \n"
|
||||
" -max_mult_cnt <digit> #If Prot_opt == 2 \n"
|
||||
" #max_mult_cnt is the number of \n"
|
||||
" #consecutive duplicate frames \n"
|
||||
" #received before pass up the stack.\n"
|
||||
" \n"
|
||||
" -7bit_hdlc <digit> #Enable 7 Bit Hdlc Engine\n"
|
||||
" #1=Enable 0=Disable\n"
|
||||
" \n"
|
||||
" -dir <digit> #Direction 0: Rx 1: Tx none: All\n"
|
||||
"\n"
|
||||
"<x25 protocol options>\n"
|
||||
"\n"
|
||||
" -txchan <digit> #Number of channels (dflt=1)\n"
|
||||
" -cause <digit> #disconnect cause (dflt=0)\n" " -diagn <digit> #disconnect diagnostic (dflt=0)\n" "\n";
|
||||
|
||||
void usage(unsigned char *api_name)
|
||||
{
|
||||
printf ("\n\nAPI %s USAGE:\n\n%s <options> <extra options>\n\n%s\n",
|
||||
api_name,api_name,api_usage);
|
||||
printf("\n\nAPI %s USAGE:\n\n%s <options> <extra options>\n\n%s\n", api_name, api_name, api_usage);
|
||||
}
|
||||
|
||||
|
||||
@@ -483,30 +480,30 @@ unsigned long get_active_channels(int channel_flag, int start_channel, int stop_
|
||||
|
||||
if ((channel_flag & (SINGLE_CHANNEL | RANGE_CHANNEL)) == 0)
|
||||
return tmp;
|
||||
if (channel_flag & RANGE_CHANNEL) { /* Range of channels */
|
||||
for(i = start_channel; i <= stop_channel; i++) {
|
||||
if (channel_flag & RANGE_CHANNEL) { /* Range of channels */
|
||||
for (i = start_channel; i <= stop_channel; i++) {
|
||||
mask = 1 << (i - 1);
|
||||
tmp |=mask;
|
||||
tmp |= mask;
|
||||
}
|
||||
} else { /* Single channel */
|
||||
} else { /* Single channel */
|
||||
mask = 1 << (stop_channel - 1);
|
||||
tmp |= mask;
|
||||
tmp |= mask;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
unsigned long parse_active_channel(char* val)
|
||||
unsigned long parse_active_channel(char *val)
|
||||
{
|
||||
int channel_flag = 0;
|
||||
char* ptr = val;
|
||||
char *ptr = val;
|
||||
int channel = 0, start_channel = 0;
|
||||
unsigned long tmp = 0;
|
||||
|
||||
if (strcmp(val,"ALL") == 0)
|
||||
if (strcmp(val, "ALL") == 0)
|
||||
return ENABLE_ALL_CHANNELS;
|
||||
|
||||
while(*ptr != '\0') {
|
||||
while (*ptr != '\0') {
|
||||
if (isdigit(*ptr)) {
|
||||
channel = strtoul(ptr, &ptr, 10);
|
||||
channel_flag |= SINGLE_CHANNEL;
|
||||
@@ -521,7 +518,7 @@ unsigned long parse_active_channel(char* val)
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
if (channel_flag){
|
||||
if (channel_flag) {
|
||||
tmp |= get_active_channels(channel_flag, start_channel, channel);
|
||||
}
|
||||
return tmp;
|
||||
@@ -531,7 +528,7 @@ void u_delay(int usec)
|
||||
{
|
||||
struct timeval tv;
|
||||
tv.tv_usec = usec;
|
||||
tv.tv_sec=0;
|
||||
tv.tv_sec = 0;
|
||||
|
||||
select(0,NULL,NULL, NULL, &tv);
|
||||
select(0, NULL, NULL, NULL, &tv);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -56,7 +56,7 @@ static struct ss7boost_client_map ss7boost_client_table[] = {
|
||||
|
||||
|
||||
|
||||
static switch_status_t create_udp_socket(ss7boost_client_connection_t * mcon, char *local_ip, int local_port, char *ip, int port)
|
||||
static switch_status_t create_udp_socket(ss7boost_client_connection_t *mcon, char *local_ip, int local_port, char *ip, int port)
|
||||
{
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "connect %s:%d->%s:%d\n", local_ip, local_port, ip, port);
|
||||
@@ -88,7 +88,7 @@ static switch_status_t create_udp_socket(ss7boost_client_connection_t * mcon, ch
|
||||
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client_connection_t * mcon)
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client_connection_t *mcon)
|
||||
{
|
||||
switch_socket_close(mcon->socket);
|
||||
mcon->socket = NULL;
|
||||
@@ -97,7 +97,7 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_close(ss7boost_client
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_connection_t * mcon,
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_connection_t *mcon,
|
||||
char *local_ip, int local_port, char *ip, int port, switch_memory_pool_t *pool)
|
||||
{
|
||||
memset(mcon, 0, sizeof(*mcon));
|
||||
@@ -112,7 +112,7 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_open(ss7boost_client_
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_connection_t * mcon, ss7boost_client_event_t ** event)
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_connection_t *mcon, ss7boost_client_event_t **event)
|
||||
{
|
||||
unsigned int fromlen = sizeof(struct sockaddr_in);
|
||||
switch_size_t bytes = 0;
|
||||
@@ -138,7 +138,7 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_read(ss7boost_client_
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client_connection_t * mcon, ss7boost_client_event_t * event)
|
||||
SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client_connection_t *mcon, ss7boost_client_event_t *event)
|
||||
{
|
||||
int err;
|
||||
switch_size_t len;
|
||||
@@ -200,7 +200,7 @@ SWITCH_DECLARE(switch_status_t) ss7boost_client_connection_write(ss7boost_client
|
||||
return err ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t * event, char *calling, char *called, int setup_id)
|
||||
SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t *event, char *calling, char *called, int setup_id)
|
||||
{
|
||||
memset(event, 0, sizeof(ss7boost_client_event_t));
|
||||
event->event_id = SIGBOOST_EVENT_CALL_START;
|
||||
@@ -219,7 +219,7 @@ SWITCH_DECLARE(void) ss7boost_client_call_init(ss7boost_client_event_t * event,
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) ss7boost_client_event_init(ss7boost_client_event_t * event, ss7boost_client_event_id_t event_id, int chan, int span)
|
||||
SWITCH_DECLARE(void) ss7boost_client_event_init(ss7boost_client_event_t *event, ss7boost_client_event_id_t event_id, int chan, int span)
|
||||
{
|
||||
memset(event, 0, sizeof(ss7boost_client_event_t));
|
||||
event->event_id = event_id;
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
#include <libsangoma.h>
|
||||
#include "lib_api.h"
|
||||
|
||||
#define MAX_TX_DATA 5000 /* Size of tx data */
|
||||
#define MAX_FRAMES 5000 /* Number of frames to transmit */
|
||||
#define MAX_TX_DATA 5000 /* Size of tx data */
|
||||
#define MAX_FRAMES 5000 /* Number of frames to transmit */
|
||||
|
||||
#define MAX_RX_DATA 5000
|
||||
|
||||
@@ -46,12 +46,12 @@ unsigned char Tx_data[MAX_TX_DATA + sizeof(wp_tdm_api_rx_hdr_t)];
|
||||
|
||||
/* Prototypes */
|
||||
int MakeConnection(void);
|
||||
void handle_span_chan( void);
|
||||
void handle_span_chan(void);
|
||||
void sig_end(int sigid);
|
||||
|
||||
int dev_fd;
|
||||
FILE *tx_fd=NULL,*rx_fd=NULL;
|
||||
wanpipe_tdm_api_t tdm_api;
|
||||
FILE *tx_fd = NULL, *rx_fd = NULL;
|
||||
wanpipe_tdm_api_t tdm_api;
|
||||
|
||||
|
||||
/***************************************************
|
||||
@@ -114,263 +114,246 @@ wanpipe_tdm_api_t tdm_api;
|
||||
*
|
||||
*/
|
||||
|
||||
void handle_span_chan(void)
|
||||
void handle_span_chan(void)
|
||||
{
|
||||
unsigned int Rx_count,Tx_count,Tx_length;
|
||||
wp_tdm_api_rx_element_t* api_rx_el;
|
||||
wp_tdm_api_tx_element_t * api_tx_el;
|
||||
fd_set ready,write,oob;
|
||||
int err,i;
|
||||
|
||||
unsigned int Rx_count, Tx_count, Tx_length;
|
||||
wp_tdm_api_rx_element_t *api_rx_el;
|
||||
wp_tdm_api_tx_element_t *api_tx_el;
|
||||
fd_set ready, write, oob;
|
||||
int err, i;
|
||||
|
||||
#if 0
|
||||
int rlen;
|
||||
int stream_sync=0;
|
||||
int stream_sync = 0;
|
||||
#endif
|
||||
|
||||
|
||||
Rx_count = 0;
|
||||
Tx_count = 0;
|
||||
|
||||
if (tdm_api.wp_tdm_cmd.hdlc) {
|
||||
Tx_length = tx_size;
|
||||
Tx_length = tx_size;
|
||||
} else {
|
||||
Tx_length = tdm_api.wp_tdm_cmd.usr_mtu_mru;
|
||||
}
|
||||
|
||||
printf("\n\nSocket Handler: Rx=%d Tx=%i TxCnt=%i TxLen=%i TxDelay=%i\n",
|
||||
read_enable,write_enable,tx_cnt,tx_size,tx_delay);
|
||||
|
||||
printf("\n\nSocket Handler: Rx=%d Tx=%i TxCnt=%i TxLen=%i TxDelay=%i\n", read_enable, write_enable, tx_cnt, tx_size, tx_delay);
|
||||
|
||||
/* Initialize the Tx Data buffer */
|
||||
memset(&Tx_data[0],0,MAX_TX_DATA + sizeof(wp_tdm_api_rx_hdr_t));
|
||||
memset(&Tx_data[0], 0, MAX_TX_DATA + sizeof(wp_tdm_api_rx_hdr_t));
|
||||
|
||||
/* Cast the Tx data packet with the tx element
|
||||
* structure. We must insert a 16 byte
|
||||
* driver header, which driver will remove
|
||||
* before passing packet out the physical port */
|
||||
api_tx_el = (wp_tdm_api_tx_element_t*)&Tx_data[0];
|
||||
|
||||
api_tx_el = (wp_tdm_api_tx_element_t *) &Tx_data[0];
|
||||
|
||||
|
||||
/* Create a Tx packet based on user info, or
|
||||
* by deafult incrementing number starting from 0 */
|
||||
for (i=0;i<Tx_length;i++){
|
||||
if (tx_data == -1){
|
||||
api_tx_el->data[i] = (unsigned char)i;
|
||||
}else{
|
||||
for (i = 0; i < Tx_length; i++) {
|
||||
if (tx_data == -1) {
|
||||
api_tx_el->data[i] = (unsigned char) i;
|
||||
} else {
|
||||
#if 0
|
||||
api_tx_el->data[i] = (unsigned char)tx_data+(i%4);
|
||||
api_tx_el->data[i] = (unsigned char) tx_data + (i % 4);
|
||||
#else
|
||||
api_tx_el->data[i] = (unsigned char)tx_data;
|
||||
api_tx_el->data[i] = (unsigned char) tx_data;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
sangoma_tdm_enable_rxhook_events(dev_fd, &tdm_api);
|
||||
sangoma_tdm_enable_rxhook_events(dev_fd, &tdm_api);
|
||||
|
||||
/* Main Rx Tx OOB routine */
|
||||
for(;;) {
|
||||
for (;;) {
|
||||
|
||||
/* Initialize all select() descriptors */
|
||||
FD_ZERO(&ready);
|
||||
FD_ZERO(&write);
|
||||
FD_ZERO(&oob);
|
||||
FD_SET(dev_fd,&oob);
|
||||
FD_SET(dev_fd,&ready);
|
||||
FD_SET(dev_fd, &oob);
|
||||
FD_SET(dev_fd, &ready);
|
||||
|
||||
if (write_enable){
|
||||
FD_SET(dev_fd,&write);
|
||||
if (write_enable) {
|
||||
FD_SET(dev_fd, &write);
|
||||
}
|
||||
|
||||
/* Select will block, until:
|
||||
* 1: OOB event, link level change
|
||||
* 2: Rx data available
|
||||
* 3: Interface able to Tx */
|
||||
|
||||
if(select(dev_fd + 1,&ready, &write, &oob, NULL)){
|
||||
* 1: OOB event, link level change
|
||||
* 2: Rx data available
|
||||
* 3: Interface able to Tx */
|
||||
|
||||
if (select(dev_fd + 1, &ready, &write, &oob, NULL)) {
|
||||
|
||||
fflush(stdout);
|
||||
if (FD_ISSET(dev_fd, &oob)) {
|
||||
|
||||
fflush(stdout);
|
||||
if (FD_ISSET(dev_fd,&oob)){
|
||||
|
||||
/* An OOB event is pending, usually indicating
|
||||
* a link level change */
|
||||
|
||||
err=sangoma_tdm_read_event(dev_fd,&tdm_api);
|
||||
|
||||
if(err < 0 ) {
|
||||
err = sangoma_tdm_read_event(dev_fd, &tdm_api);
|
||||
|
||||
if (err < 0) {
|
||||
printf("Failed to receive OOB %i , %i\n", Rx_count, err);
|
||||
err = ioctl(dev_fd,SIOC_WANPIPE_SOCK_STATE,0);
|
||||
printf("Sock state is %s\n",
|
||||
(err == 0) ? "CONNECTED" :
|
||||
(err == 1) ? "DISCONNECTED" :
|
||||
"CONNECTING");
|
||||
err = ioctl(dev_fd, SIOC_WANPIPE_SOCK_STATE, 0);
|
||||
printf("Sock state is %s\n", (err == 0) ? "CONNECTED" : (err == 1) ? "DISCONNECTED" : "CONNECTING");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
printf("GOT OOB EXCEPTION CMD Exiting\n");
|
||||
}
|
||||
|
||||
|
||||
if (FD_ISSET(dev_fd,&ready)){
|
||||
|
||||
|
||||
if (FD_ISSET(dev_fd, &ready)) {
|
||||
|
||||
/* An Rx packet is pending
|
||||
* 1: Read the rx packet into the Rx_data
|
||||
* buffer. Confirm len > 0
|
||||
* 1: Read the rx packet into the Rx_data
|
||||
* buffer. Confirm len > 0
|
||||
*
|
||||
* 2: Cast Rx_data to the api_rx_element.
|
||||
* Thus, removing a 16 byte header
|
||||
* attached by the driver.
|
||||
* 2: Cast Rx_data to the api_rx_element.
|
||||
* Thus, removing a 16 byte header
|
||||
* attached by the driver.
|
||||
*
|
||||
* 3. Check error_flag:
|
||||
* CRC,Abort..etc
|
||||
* 3. Check error_flag:
|
||||
* CRC,Abort..etc
|
||||
*/
|
||||
|
||||
memset(Rx_data, 0, sizeof(Rx_data));
|
||||
|
||||
err = sangoma_readmsg_tdm(dev_fd,
|
||||
Rx_data,
|
||||
sizeof(wp_tdm_api_rx_hdr_t),
|
||||
&Rx_data[sizeof(wp_tdm_api_rx_hdr_t)],
|
||||
MAX_RX_DATA, 0);
|
||||
err = sangoma_readmsg_tdm(dev_fd, Rx_data, sizeof(wp_tdm_api_rx_hdr_t), &Rx_data[sizeof(wp_tdm_api_rx_hdr_t)], MAX_RX_DATA, 0);
|
||||
|
||||
|
||||
if (!read_enable){
|
||||
if (!read_enable) {
|
||||
goto bitstrm_skip_read;
|
||||
}
|
||||
|
||||
/* err indicates bytes received */
|
||||
if(err <= 0) {
|
||||
if (err <= 0) {
|
||||
printf("\nError receiving data\n");
|
||||
break;
|
||||
}
|
||||
|
||||
api_rx_el = (wp_tdm_api_rx_element_t*)&Rx_data[0];
|
||||
api_rx_el = (wp_tdm_api_rx_element_t *) & Rx_data[0];
|
||||
|
||||
/* Check the packet length */
|
||||
Rx_lgth = err;
|
||||
if(Rx_lgth<=0) {
|
||||
printf("\nShort frame received (%d)\n",
|
||||
Rx_lgth);
|
||||
if (Rx_lgth <= 0) {
|
||||
printf("\nShort frame received (%d)\n", Rx_lgth);
|
||||
return;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (api_rx_el->data[0] == tx_data && api_rx_el->data[1] == (tx_data+1)){
|
||||
if (!stream_sync){
|
||||
printf("GOT SYNC %x\n",api_rx_el->data[0]);
|
||||
if (api_rx_el->data[0] == tx_data && api_rx_el->data[1] == (tx_data + 1)) {
|
||||
if (!stream_sync) {
|
||||
printf("GOT SYNC %x\n", api_rx_el->data[0]);
|
||||
}
|
||||
stream_sync=1;
|
||||
}else{
|
||||
if (stream_sync){
|
||||
printf("OUT OF SYNC: %x\n",api_rx_el->data[0]);
|
||||
stream_sync = 1;
|
||||
} else {
|
||||
if (stream_sync) {
|
||||
printf("OUT OF SYNC: %x\n", api_rx_el->data[0]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
++Rx_count;
|
||||
|
||||
if (verbose){
|
||||
if (verbose) {
|
||||
#if 0
|
||||
printf("Received %i Length = %i\n",
|
||||
Rx_count,Rx_lgth);
|
||||
printf("Received %i Length = %i\n", Rx_count, Rx_lgth);
|
||||
|
||||
printf("Data: ");
|
||||
for(i=0;i<Rx_lgth; i ++) {
|
||||
for (i = 0; i < Rx_lgth; i++) {
|
||||
printf("0x%02X ", api_rx_el->data[i]);
|
||||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
}else{
|
||||
} else {
|
||||
//putchar('R');
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
switch(api_rx_el->hdr.wp_api_event_type){
|
||||
switch (api_rx_el->hdr.wp_api_event_type) {
|
||||
case WP_TDM_EVENT_DTMF:
|
||||
printf("DTMV Event: %c (%s:%s)!\n",
|
||||
api_rx_el->hdr.wp_api_event_dtmf_digit,
|
||||
(api_rx_el->hdr.wp_api_event_dtmf_type&WP_TDM_EVENT_DTMF_ROUT)?"ROUT":"SOUT",
|
||||
(api_rx_el->hdr.wp_api_event_dtmf_type&WP_TDM_EVENT_DTMF_PRESET)?"PRESET":"STOP");
|
||||
api_rx_el->hdr.wp_api_event_dtmf_digit,
|
||||
(api_rx_el->hdr.wp_api_event_dtmf_type & WP_TDM_EVENT_DTMF_ROUT) ? "ROUT" : "SOUT",
|
||||
(api_rx_el->hdr.wp_api_event_dtmf_type & WP_TDM_EVENT_DTMF_PRESET) ? "PRESET" : "STOP");
|
||||
break;
|
||||
case WP_TDM_EVENT_RXHOOK:
|
||||
printf("RXHOOK Event: %s!\n",
|
||||
(api_rx_el->hdr.wp_api_event_rxhook_state&WP_TDM_EVENT_RXHOOK_OFF)?"OFF-HOOK":"ON-HOOK");
|
||||
printf("RXHOOK Event: %s!\n", (api_rx_el->hdr.wp_api_event_rxhook_state & WP_TDM_EVENT_RXHOOK_OFF) ? "OFF-HOOK" : "ON-HOOK");
|
||||
break;
|
||||
case WP_TDM_EVENT_RING:
|
||||
printf("RING Event: %s!\n",
|
||||
(api_rx_el->hdr.wp_api_event_ring_state&WP_TDM_EVENT_RING_PRESENT)?"PRESENT":"STOP");
|
||||
printf("RING Event: %s!\n", (api_rx_el->hdr.wp_api_event_ring_state & WP_TDM_EVENT_RING_PRESENT) ? "PRESENT" : "STOP");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (rx_cnt > 0 && Rx_count >= rx_cnt){
|
||||
if (rx_cnt > 0 && Rx_count >= rx_cnt) {
|
||||
break;
|
||||
}
|
||||
bitstrm_skip_read:
|
||||
;
|
||||
}
|
||||
|
||||
if (FD_ISSET(dev_fd,&write)){
|
||||
bitstrm_skip_read:
|
||||
;
|
||||
}
|
||||
|
||||
if (FD_ISSET(dev_fd, &write)) {
|
||||
|
||||
|
||||
err = sangoma_writemsg_tdm(dev_fd,
|
||||
Tx_data,16,
|
||||
&Tx_data[16], Tx_length,
|
||||
0);
|
||||
if (err <= 0){
|
||||
if (errno == EBUSY){
|
||||
if (verbose){
|
||||
err = sangoma_writemsg_tdm(dev_fd, Tx_data, 16, &Tx_data[16], Tx_length, 0);
|
||||
if (err <= 0) {
|
||||
if (errno == EBUSY) {
|
||||
if (verbose) {
|
||||
printf("Sock busy try again!\n");
|
||||
}
|
||||
/* Socket busy try sending again !*/
|
||||
}else{
|
||||
printf("Faild to send %i \n",errno);
|
||||
/* Socket busy try sending again ! */
|
||||
} else {
|
||||
printf("Faild to send %i \n", errno);
|
||||
perror("Send: ");
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
|
||||
++Tx_count;
|
||||
|
||||
if (verbose){
|
||||
|
||||
if (verbose) {
|
||||
//printf("Packet sent: Sent %i : %i\n",
|
||||
// err,Tx_count);
|
||||
}else{
|
||||
// err,Tx_count);
|
||||
} else {
|
||||
//putchar('T');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tx_delay){
|
||||
if (tx_delay) {
|
||||
usleep(tx_delay);
|
||||
}
|
||||
|
||||
if (tx_cnt && tx_size && Tx_count >= tx_cnt && !(files_used & TX_FILE_USED)){
|
||||
|
||||
write_enable=0;
|
||||
if (rx_cnt > 0){
|
||||
if (tx_cnt && tx_size && Tx_count >= tx_cnt && !(files_used & TX_FILE_USED)) {
|
||||
|
||||
write_enable = 0;
|
||||
if (rx_cnt > 0) {
|
||||
/* Dont break let rx finish */
|
||||
}else{
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sangoma_tdm_disable_rxhook_events(dev_fd, &tdm_api);
|
||||
if (tx_fd){
|
||||
sangoma_tdm_disable_rxhook_events(dev_fd, &tdm_api);
|
||||
if (tx_fd) {
|
||||
fclose(tx_fd);
|
||||
}
|
||||
if (rx_fd){
|
||||
if (rx_fd) {
|
||||
fclose(rx_fd);
|
||||
}
|
||||
close (dev_fd);
|
||||
close(dev_fd);
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int rxhook_event (int fd, unsigned char state)
|
||||
int rxhook_event(int fd, unsigned char state)
|
||||
{
|
||||
printf("%d: RXHOOK Event: %s!\n",
|
||||
fd, (state & WAN_EVENT_RXHOOK_OFF)?"OFF-HOOK":"ON-HOOK");
|
||||
printf("%d: RXHOOK Event: %s!\n", fd, (state & WAN_EVENT_RXHOOK_OFF) ? "OFF-HOOK" : "ON-HOOK");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -383,37 +366,34 @@ int rxhook_event (int fd, unsigned char state)
|
||||
**************************************************************/
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int proceed;
|
||||
|
||||
proceed=init_args(argc,argv);
|
||||
if (proceed != WAN_TRUE){
|
||||
proceed = init_args(argc, argv);
|
||||
if (proceed != WAN_TRUE) {
|
||||
usage(argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT,&sig_end);
|
||||
memset(&tdm_api,0,sizeof(tdm_api));
|
||||
signal(SIGINT, &sig_end);
|
||||
memset(&tdm_api, 0, sizeof(tdm_api));
|
||||
tdm_api.wp_tdm_event.wp_rxhook_event = &rxhook_event;
|
||||
|
||||
printf("TDM RXHOOK PTR = %p\n",tdm_api.wp_tdm_event.wp_rxhook_event);
|
||||
|
||||
dev_fd =-1;
|
||||
|
||||
dev_fd = sangoma_open_tdmapi_span_chan(atoi(card_name),atoi(if_name));
|
||||
if( dev_fd < 0){
|
||||
printf("Failed to open span chan (%s:%s:%d:%d)\n",
|
||||
card_name, if_name,
|
||||
atoi(card_name),atoi(if_name));
|
||||
exit (1);
|
||||
|
||||
printf("TDM RXHOOK PTR = %p\n", tdm_api.wp_tdm_event.wp_rxhook_event);
|
||||
|
||||
dev_fd = -1;
|
||||
|
||||
dev_fd = sangoma_open_tdmapi_span_chan(atoi(card_name), atoi(if_name));
|
||||
if (dev_fd < 0) {
|
||||
printf("Failed to open span chan (%s:%s:%d:%d)\n", card_name, if_name, atoi(card_name), atoi(if_name));
|
||||
exit(1);
|
||||
}
|
||||
printf("HANDLING SPAN %i CHAN %i FD=%i\n",
|
||||
atoi(card_name),atoi(if_name),dev_fd);
|
||||
|
||||
sangoma_tdm_set_codec(dev_fd,&tdm_api,WP_NONE);
|
||||
printf("HANDLING SPAN %i CHAN %i FD=%i\n", atoi(card_name), atoi(if_name), dev_fd);
|
||||
|
||||
sangoma_tdm_set_codec(dev_fd, &tdm_api, WP_NONE);
|
||||
sangoma_get_full_cfg(dev_fd, &tdm_api);
|
||||
|
||||
|
||||
handle_span_chan();
|
||||
close(dev_fd);
|
||||
return 0;
|
||||
@@ -425,24 +405,21 @@ int main(int argc, char* argv[])
|
||||
void sig_end(int sigid)
|
||||
{
|
||||
|
||||
printf("Got Signal %i\n",sigid);
|
||||
|
||||
printf("Got Signal %i\n", sigid);
|
||||
|
||||
sangoma_tdm_disable_rxhook_events(dev_fd, &tdm_api);
|
||||
|
||||
if (tx_fd){
|
||||
if (tx_fd) {
|
||||
fclose(tx_fd);
|
||||
}
|
||||
if (rx_fd){
|
||||
if (rx_fd) {
|
||||
fclose(rx_fd);
|
||||
}
|
||||
|
||||
if (dev_fd){
|
||||
close (dev_fd);
|
||||
if (dev_fd) {
|
||||
close(dev_fd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -180,16 +180,16 @@ static switch_status_t woomera_read_frame(switch_core_session_t *session, switch
|
||||
static switch_status_t woomera_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t woomera_kill_channel(switch_core_session_t *session, int sig);
|
||||
static void tech_destroy(private_object * tech_pvt);
|
||||
static void woomera_printf(woomera_profile * profile, switch_socket_t * socket, char *fmt, ...);
|
||||
static void woomera_printf(woomera_profile * profile, switch_socket_t *socket, char *fmt, ...);
|
||||
static char *woomera_message_header(woomera_message * wmsg, char *key);
|
||||
static int woomera_enqueue_event(woomera_event_queue * event_queue, woomera_message * wmsg);
|
||||
static int woomera_dequeue_event(woomera_event_queue * event_queue, woomera_message * wmsg);
|
||||
static int woomera_message_parse(switch_socket_t * fd, woomera_message * wmsg, int timeout, woomera_profile * profile, woomera_event_queue * event_queue);
|
||||
static int connect_woomera(switch_socket_t ** new_sock, woomera_profile * profile, int flags);
|
||||
static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, int timeout, woomera_profile * profile, woomera_event_queue * event_queue);
|
||||
static int connect_woomera(switch_socket_t **new_sock, woomera_profile * profile, int flags);
|
||||
static int woomera_profile_thread_running(woomera_profile * profile, int set, int new);
|
||||
static int woomera_locate_socket(woomera_profile * profile, switch_socket_t ** woomera_socket);
|
||||
static int woomera_locate_socket(woomera_profile * profile, switch_socket_t **woomera_socket);
|
||||
static int tech_create_read_socket(private_object * tech_pvt);
|
||||
static void *woomera_channel_thread_run(switch_thread_t * thread, void *obj);
|
||||
static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj);
|
||||
static void *woomera_thread_run(void *obj);
|
||||
static int tech_activate(private_object * tech_pvt);
|
||||
|
||||
@@ -264,7 +264,7 @@ static switch_status_t woomera_on_hangup(switch_core_session_t *session)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void woomera_socket_close(switch_socket_t ** socket)
|
||||
static void woomera_socket_close(switch_socket_t **socket)
|
||||
{
|
||||
if (*socket) {
|
||||
switch_socket_close(*socket);
|
||||
@@ -330,7 +330,7 @@ static switch_status_t woomera_read_frame(switch_core_session_t *session, switch
|
||||
|
||||
switch_assert(tech_pvt != NULL);
|
||||
|
||||
for(;;) {
|
||||
for (;;) {
|
||||
if (switch_test_flag(tech_pvt, TFLAG_ABORT) || !tech_pvt->udp_socket) {
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
@@ -364,7 +364,7 @@ static switch_status_t woomera_write_frame(switch_core_session_t *session, switc
|
||||
switch_size_t len;
|
||||
|
||||
switch_assert(tech_pvt != NULL);
|
||||
|
||||
|
||||
if (switch_test_flag(tech_pvt, TFLAG_ABORT) || !tech_pvt->udp_socket) {
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
@@ -469,7 +469,7 @@ static void tech_destroy(private_object * tech_pvt)
|
||||
}
|
||||
|
||||
|
||||
static void woomera_printf(woomera_profile * profile, switch_socket_t * socket, char *fmt, ...)
|
||||
static void woomera_printf(woomera_profile * profile, switch_socket_t *socket, char *fmt, ...)
|
||||
{
|
||||
char *stuff = NULL;
|
||||
size_t res = 0, len = 0;
|
||||
@@ -558,7 +558,7 @@ static int woomera_dequeue_event(woomera_event_queue * event_queue, woomera_mess
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int woomera_message_parse(switch_socket_t * fd, woomera_message * wmsg, int timeout, woomera_profile * profile, woomera_event_queue * event_queue)
|
||||
static int woomera_message_parse(switch_socket_t *fd, woomera_message * wmsg, int timeout, woomera_profile * profile, woomera_event_queue * event_queue)
|
||||
{
|
||||
char *cur, *cr, *next = NULL;
|
||||
char buf[2048] = "", *ptr;
|
||||
@@ -719,7 +719,7 @@ static int woomera_message_parse(switch_socket_t * fd, woomera_message * wmsg, i
|
||||
}
|
||||
|
||||
|
||||
static int connect_woomera(switch_socket_t ** new_sock, woomera_profile * profile, int flags)
|
||||
static int connect_woomera(switch_socket_t **new_sock, woomera_profile * profile, int flags)
|
||||
{
|
||||
|
||||
switch_sockaddr_t *sa;
|
||||
@@ -764,7 +764,7 @@ static int woomera_profile_thread_running(woomera_profile * profile, int set, in
|
||||
|
||||
}
|
||||
|
||||
static int woomera_locate_socket(woomera_profile * profile, switch_socket_t ** woomera_socket)
|
||||
static int woomera_locate_socket(woomera_profile * profile, switch_socket_t **woomera_socket)
|
||||
{
|
||||
woomera_message wmsg;
|
||||
|
||||
@@ -823,7 +823,7 @@ static int tech_create_read_socket(private_object * tech_pvt)
|
||||
} else {
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_ABORT);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -872,7 +872,7 @@ static int tech_activate(private_object * tech_pvt)
|
||||
|
||||
|
||||
|
||||
static void *woomera_channel_thread_run(switch_thread_t * thread, void *obj)
|
||||
static void *woomera_channel_thread_run(switch_thread_t *thread, void *obj)
|
||||
{
|
||||
switch_core_session_t *session = obj;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
@@ -976,15 +976,7 @@ static void *woomera_channel_thread_run(switch_thread_t * thread, void *obj)
|
||||
if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
|
||||
NULL,
|
||||
tech_pvt->profile->dialplan,
|
||||
cid_name,
|
||||
cid_num,
|
||||
ip,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
modname,
|
||||
NULL,
|
||||
exten)) != 0) {
|
||||
cid_name, cid_num, ip, NULL, NULL, NULL, modname, NULL, exten)) != 0) {
|
||||
char name[128];
|
||||
switch_snprintf(name, sizeof(name), "Woomera/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
|
||||
switch_channel_set_name(channel, name);
|
||||
|
||||
Reference in new issue
Block a user