Freeswitch-svn
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
December 2007
- 13 participants
- 565 discussions
Author: mikej
Date: Tue Dec 18 13:14:00 2007
New Revision: 6870
Modified:
freeswitch/trunk/src/switch_cpp.cpp
Log:
wrong fix to avoid seg. The threadstate needs to be moved to the private so that it's not dependent on the switch_core_session_t like in python.
Modified: freeswitch/trunk/src/switch_cpp.cpp
==============================================================================
--- freeswitch/trunk/src/switch_cpp.cpp (original)
+++ freeswitch/trunk/src/switch_cpp.cpp Tue Dec 18 13:14:00 2007
@@ -326,7 +326,7 @@
// no valid channel. since the threadstate is stored in the channel, and there
// is none, if we try to call begin_alllow_threads it will fail miserably.
// use the 'a leg session' to do the thread swapping stuff.
- a_leg_session->begin_allow_threads();
+ if (a_leg_session) a_leg_session->begin_allow_threads();
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
@@ -347,11 +347,11 @@
}
- a_leg_session->end_allow_threads();
+ if (a_leg_session) a_leg_session->end_allow_threads();
return SWITCH_STATUS_SUCCESS;
failed:
- a_leg_session->end_allow_threads();
+ if (a_leg_session) a_leg_session->end_allow_threads();
return SWITCH_STATUS_FALSE;
}
1
0
Author: mikej
Date: Tue Dec 18 12:50:39 2007
New Revision: 6869
Modified:
freeswitch/trunk/libs/stfu/stfu.c
freeswitch/trunk/src/switch_ivr.c
freeswitch/trunk/src/switch_ivr_originate.c
freeswitch/trunk/src/switch_ivr_play_say.c
Log:
cleanups
Modified: freeswitch/trunk/libs/stfu/stfu.c
==============================================================================
--- freeswitch/trunk/libs/stfu/stfu.c (original)
+++ freeswitch/trunk/libs/stfu/stfu.c Tue Dec 18 12:50:39 2007
@@ -81,7 +81,9 @@
struct stfu_instance *i;
i = malloc(sizeof(*i));
- assert(i != NULL);
+ if (!i) {
+ return NULL;
+ }
memset(i, 0, sizeof(*i));
stfu_n_init_aqueue(&i->a_queue, qlen);
stfu_n_init_aqueue(&i->b_queue, qlen);
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Tue Dec 18 12:50:39 2007
@@ -441,7 +441,7 @@
switch_byte_t decoded[SWITCH_RECOMMENDED_BUFFER_SIZE];
uint32_t rate = read_codec->implementation->actual_samples_per_second;
uint32_t dlen = sizeof(decoded);
- switch_status_t status;
+ switch_status_t tstatus;
switch_byte_t *sendbuf = NULL;
uint32_t sendlen = 0;
@@ -452,9 +452,9 @@
status = SWITCH_STATUS_SUCCESS;
} else {
if (switch_test_flag(conninfo, SUF_NATIVE)) {
- status = SWITCH_STATUS_NOOP;
+ tstatus = SWITCH_STATUS_NOOP;
} else {
- status = switch_core_codec_decode(
+ tstatus = switch_core_codec_decode(
read_codec,
&conninfo->read_codec,
read_frame->data,
@@ -462,17 +462,17 @@
read_codec->implementation->actual_samples_per_second,
decoded, &dlen, &rate, &flags);
}
- switch (status) {
+ switch (tstatus) {
case SWITCH_STATUS_NOOP:
case SWITCH_STATUS_BREAK:
sendbuf = read_frame->data;
sendlen = read_frame->datalen;
- status = SWITCH_STATUS_SUCCESS;
+ tstatus = SWITCH_STATUS_SUCCESS;
break;
case SWITCH_STATUS_SUCCESS:
sendbuf = decoded;
sendlen = dlen;
- status = SWITCH_STATUS_SUCCESS;
+ tstatus = SWITCH_STATUS_SUCCESS;
break;
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Codec Error\n");
@@ -481,7 +481,7 @@
}
}
- if (status == SWITCH_STATUS_SUCCESS) {
+ if (tstatus == SWITCH_STATUS_SUCCESS) {
len = sendlen;
if (switch_socket_sendto(conninfo->socket, conninfo->remote_addr, 0, (void *)sendbuf, &len) != SWITCH_STATUS_SUCCESS) {
switch_ivr_deactivate_unicast(session);
Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c (original)
+++ freeswitch/trunk/src/switch_ivr_originate.c Tue Dec 18 12:50:39 2007
@@ -785,9 +785,9 @@
/* read from the channel while we wait if the audio is up on it */
if (session && (ringback_data || !switch_channel_test_flag(caller_channel, CF_BYPASS_MEDIA)) &&
(switch_channel_test_flag(caller_channel, CF_ANSWERED) || switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA))) {
- switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
+ switch_status_t tstatus = switch_core_session_read_frame(session, &read_frame, 1000, 0);
- if (!SWITCH_READ_ACCEPTABLE(status)) {
+ if (!SWITCH_READ_ACCEPTABLE(tstatus)) {
break;
}
Modified: freeswitch/trunk/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_play_say.c (original)
+++ freeswitch/trunk/src/switch_ivr_play_say.c Tue Dec 18 12:50:39 2007
@@ -1063,13 +1063,13 @@
}
} else { /* time off the channel (if you must) */
switch_frame_t *read_frame;
- switch_status_t status;
+ switch_status_t tstatus;
while (switch_channel_ready(channel) && switch_channel_test_flag(channel, CF_HOLD)) {
switch_yield(10000);
}
- status = switch_core_session_read_frame(session, &read_frame, -1, 0);
+ tstatus = switch_core_session_read_frame(session, &read_frame, -1, 0);
- if (!SWITCH_READ_ACCEPTABLE(status)) {
+ if (!SWITCH_READ_ACCEPTABLE(tstatus)) {
break;
}
@@ -1387,13 +1387,13 @@
}
} else {
switch_frame_t *read_frame;
- switch_status_t status = switch_core_session_read_frame(session, &read_frame, -1, 0);
+ switch_status_t tstatus = switch_core_session_read_frame(session, &read_frame, -1, 0);
while (switch_channel_ready(channel) && switch_channel_test_flag(channel, CF_HOLD)) {
switch_yield(10000);
}
- if (!SWITCH_READ_ACCEPTABLE(status)) {
+ if (!SWITCH_READ_ACCEPTABLE(tstatus)) {
break;
}
@@ -1450,13 +1450,13 @@
}
} else { /* time off the channel (if you must) */
switch_frame_t *read_frame;
- switch_status_t status = switch_core_session_read_frame(session, &read_frame, -1, 0);
+ switch_status_t tstatus = switch_core_session_read_frame(session, &read_frame, -1, 0);
while (switch_channel_ready(channel) && switch_channel_test_flag(channel, CF_HOLD)) {
switch_yield(10000);
}
- if (!SWITCH_READ_ACCEPTABLE(status)) {
+ if (!SWITCH_READ_ACCEPTABLE(tstatus)) {
break;
}
1
0
Author: anthm
Date: Tue Dec 18 12:43:38 2007
New Revision: 6868
Modified:
freeswitch/trunk/src/switch_ivr_play_say.c
Log:
opts
Modified: freeswitch/trunk/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_play_say.c (original)
+++ freeswitch/trunk/src/switch_ivr_play_say.c Tue Dec 18 12:43:38 2007
@@ -686,7 +686,7 @@
const char *timer_name;
const char *prebuf;
- switch_zmalloc(abuf, FILE_STARTSAMPLES);
+ switch_zmalloc(abuf, FILE_STARTSAMPLES * sizeof(*abuf));
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
@@ -925,6 +925,9 @@
}
if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
+ if (framelen > FILE_STARTSAMPLES) {
+ framelen = FILE_STARTSAMPLES;
+ }
memset(abuf, 0, framelen);
olen = ilen;
do_speed = 0;
1
0
Author: anthm
Date: Tue Dec 18 12:33:29 2007
New Revision: 6867
Modified:
freeswitch/trunk/src/switch_ivr.c
freeswitch/trunk/src/switch_ivr_originate.c
freeswitch/trunk/src/switch_ivr_play_say.c
freeswitch/trunk/src/switch_rtp.c
Log:
opts
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Tue Dec 18 12:33:29 2007
@@ -1146,7 +1146,9 @@
}
*dst = digit;
} else {
- stream->digits = realloc(stream->digits, len + 2);
+ char *tmp = realloc(stream->digits, len + 2);
+ switch_assert(tmp);
+ stream->digits = tmp;
*(stream->digits + (len++)) = digit;
*(stream->digits + len) = '\0';
stream->last_digit_time = switch_time_now() / 1000;
Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c (original)
+++ freeswitch/trunk/src/switch_ivr_originate.c Tue Dec 18 12:33:29 2007
@@ -233,7 +233,7 @@
return 0;
}
-#define MAX_PEERS 256
+#define MAX_PEERS 128
SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *session,
switch_core_session_t **bleg,
switch_call_cause_t *cause,
Modified: freeswitch/trunk/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_play_say.c (original)
+++ freeswitch/trunk/src/switch_ivr_play_say.c Tue Dec 18 12:33:29 2007
@@ -663,7 +663,7 @@
SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file, switch_input_args_t *args)
{
switch_channel_t *channel;
- int16_t abuf[FILE_STARTSAMPLES];
+ int16_t *abuf;
char dtmf[128];
uint32_t interval = 0, samples = 0, framelen, sample_start = 0;
uint32_t ilen = 0;
@@ -686,6 +686,8 @@
const char *timer_name;
const char *prebuf;
+ switch_zmalloc(abuf, FILE_STARTSAMPLES);
+
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
@@ -694,7 +696,8 @@
if (!file) {
- return SWITCH_STATUS_FALSE;
+ status = SWITCH_STATUS_FALSE;
+ goto end;
}
if (!prefix) {
@@ -741,7 +744,8 @@
read_codec->implementation->actual_samples_per_second,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_core_session_reset(session);
- return SWITCH_STATUS_NOTFOUND;
+ status = SWITCH_STATUS_NOTFOUND;
+ goto end;
}
if (switch_test_flag(fh, SWITCH_FILE_NATIVE)) {
asis = 1;
@@ -749,7 +753,7 @@
write_frame.data = abuf;
- write_frame.buflen = sizeof(abuf);
+ write_frame.buflen = FILE_STARTSAMPLES;
if (sample_start > 0) {
uint32_t pos = 0;
@@ -806,7 +810,8 @@
switch_core_file_close(fh);
switch_core_session_reset(session);
- return SWITCH_STATUS_GENERR;
+ status = SWITCH_STATUS_GENERR;
+ goto end;
}
}
@@ -831,7 +836,8 @@
"Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name, fh->samplerate, fh->channels, interval);
switch_core_file_close(fh);
switch_core_session_reset(session);
- return SWITCH_STATUS_GENERR;
+ status = SWITCH_STATUS_GENERR;
+ goto end;
}
samples = codec.implementation->samples_per_frame;
framelen = codec.implementation->bytes_per_frame;
@@ -847,7 +853,8 @@
switch_core_codec_destroy(&codec);
switch_core_file_close(fh);
switch_core_session_reset(session);
- return SWITCH_STATUS_GENERR;
+ status = SWITCH_STATUS_GENERR;
+ goto end;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success %u bytes per %d ms!\n", len, interval);
}
@@ -926,7 +933,7 @@
olen = asis ? framelen : ilen;
do_speed = 0;
} else {
- olen = sizeof(abuf);
+ olen = FILE_STARTSAMPLES;
if (!asis) {
olen /= 2;
}
@@ -1085,6 +1092,10 @@
switch_core_timer_destroy(&timer);
}
+
+ end:
+ free(abuf);
+
switch_core_session_reset(session);
return status;
}
Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c (original)
+++ freeswitch/trunk/src/switch_rtp.c Tue Dec 18 12:33:29 2007
@@ -171,6 +171,7 @@
stfu_instance_t *jb;
uint32_t max_missed_packets;
uint32_t missed_count;
+ rtp_msg_t write_msg;
};
static int global_init = 0;
@@ -1645,7 +1646,6 @@
uint32_t datalen,
uint8_t m, switch_payload_t payload, uint32_t ts, uint16_t mseq, uint32_t ssrc, switch_frame_flag_t *flags)
{
- rtp_msg_t send_msg = { {0} };
switch_size_t bytes;
if (!switch_rtp_ready(rtp_session)) {
@@ -1660,13 +1660,13 @@
return -1;
}
- send_msg = rtp_session->send_msg;
- send_msg.header.seq = htons(mseq);
- send_msg.header.ts = htonl(ts);
- send_msg.header.ssrc = htonl(ssrc);
- send_msg.header.pt = payload;
- send_msg.header.m = m ? 1 : 0;
- memcpy(send_msg.body, data, datalen);
+ rtp_session->write_msg = rtp_session->send_msg;
+ rtp_session->write_msg.header.seq = htons(mseq);
+ rtp_session->write_msg.header.ts = htonl(ts);
+ rtp_session->write_msg.header.ssrc = htonl(ssrc);
+ rtp_session->write_msg.header.pt = payload;
+ rtp_session->write_msg.header.m = m ? 1 : 0;
+ memcpy(rtp_session->write_msg.body, data, datalen);
bytes = rtp_header_len + datalen;
@@ -1675,7 +1675,7 @@
int sbytes = (int) bytes;
err_status_t stat;
- stat = srtp_protect(rtp_session->send_ctx, &send_msg.header, &sbytes);
+ stat = srtp_protect(rtp_session->send_ctx, &rtp_session->write_msg.header, &sbytes);
if (stat) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error: srtp protection failed with code %d\n", stat);
}
@@ -1683,7 +1683,7 @@
bytes = sbytes;
}
- if (switch_socket_sendto(rtp_session->sock, rtp_session->remote_addr, 0, (void *) &send_msg, &bytes) != SWITCH_STATUS_SUCCESS) {
+ if (switch_socket_sendto(rtp_session->sock, rtp_session->remote_addr, 0, (void *) &rtp_session->write_msg, &bytes) != SWITCH_STATUS_SUCCESS) {
return -1;
}
return (int) bytes;
1
0
[commit] r6866 - in freeswitch/trunk/conf: . autoload_configs dialplan sip_profiles
by Freeswitch SVN 18 Dec '07
by Freeswitch SVN 18 Dec '07
18 Dec '07
Author: brian
Date: Tue Dec 18 12:11:18 2007
New Revision: 6866
Modified:
freeswitch/trunk/conf/autoload_configs/conference.conf.xml
freeswitch/trunk/conf/dialplan/default.xml
freeswitch/trunk/conf/sip_profiles/default.xml
freeswitch/trunk/conf/sip_profiles/nat.xml
freeswitch/trunk/conf/sip_profiles/outbound.xml
freeswitch/trunk/conf/vars.xml
Log:
change moh to a var so you can change it with ease
Modified: freeswitch/trunk/conf/autoload_configs/conference.conf.xml
==============================================================================
--- freeswitch/trunk/conf/autoload_configs/conference.conf.xml (original)
+++ freeswitch/trunk/conf/autoload_configs/conference.conf.xml Tue Dec 18 12:11:18 2007
@@ -64,7 +64,9 @@
<!-- File to play if you are alone in the conference -->
<!--<param name="alone-sound" value="yactopitc.wav"/>-->
<!-- File to play endlessly (nobody will ever be able to talk) -->
- <!--<param name="perpetual-sound" value="local_stream://moh"/>-->
+ <!--<param name="perpetual-sound" value="perpetual.wav"/>-->
+ <!-- File to play when you're alone (music on hold)-->
+ <param name="moh-sound" value="$${moh_uri}"/>
<!-- File to play when you join the conference -->
<!--<param name="enter-sound" value="welcome.wav"/>-->
<!-- File to play when you leave the conference -->
Modified: freeswitch/trunk/conf/dialplan/default.xml
==============================================================================
--- freeswitch/trunk/conf/dialplan/default.xml (original)
+++ freeswitch/trunk/conf/dialplan/default.xml Tue Dec 18 12:11:18 2007
@@ -197,7 +197,7 @@
<extension name="hold_music">
<condition field="destination_number" expression="^9999$">
<action application="answer"/>
- <action application="playback" data="local_stream://moh"/>
+ <action application="playback" data="$${moh_uri}"/>
</condition>
</extension>
Modified: freeswitch/trunk/conf/sip_profiles/default.xml
==============================================================================
--- freeswitch/trunk/conf/sip_profiles/default.xml (original)
+++ freeswitch/trunk/conf/sip_profiles/default.xml Tue Dec 18 12:11:18 2007
@@ -28,7 +28,7 @@
<param name="rtp-timer-name" value="soft"/>
<param name="rtp-ip" value="$${local_ip_v4}"/>
<param name="sip-ip" value="$${local_ip_v4}"/>
- <param name="hold-music" value="local_stream://moh"/>
+ <param name="hold-music" value="$${moh_uri}"/>
<!--enable to use presense and mwi -->
<param name="manage-presence" value="true"/>
<!-- This setting is for AAL2 bitpacking on G726 -->
Modified: freeswitch/trunk/conf/sip_profiles/nat.xml
==============================================================================
--- freeswitch/trunk/conf/sip_profiles/nat.xml (original)
+++ freeswitch/trunk/conf/sip_profiles/nat.xml Tue Dec 18 12:11:18 2007
@@ -14,7 +14,7 @@
<param name="dtmf-duration" value="100"/>
<param name="codec-prefs" value="$${global_codec_prefs}"/>
<param name="use-rtp-timer" value="true"/>
- <param name="hold-music" value="local_stream://moh"/>
+ <param name="hold-music" value="$${moh_uri}"/>
<param name="rtp-timer-name" value="soft"/>
<param name="manage-presence" value="true"/>
<param name="inbound-codec-negotiation" value="generous"/>
Modified: freeswitch/trunk/conf/sip_profiles/outbound.xml
==============================================================================
--- freeswitch/trunk/conf/sip_profiles/outbound.xml (original)
+++ freeswitch/trunk/conf/sip_profiles/outbound.xml Tue Dec 18 12:11:18 2007
@@ -18,7 +18,7 @@
<param name="context" value="public"/>
<param name="dtmf-duration" value="100"/>
<param name="codec-prefs" value="$${global_codec_prefs}"/>
- <param name="hold-music" value="local_stream://moh"/>
+ <param name="hold-music" value="$${moh_uri}"/>
<param name="use-rtp-timer" value="true"/>
<param name="rtp-timer-name" value="soft"/>
<param name="manage-presence" value="true"/>
Modified: freeswitch/trunk/conf/vars.xml
==============================================================================
--- freeswitch/trunk/conf/vars.xml (original)
+++ freeswitch/trunk/conf/vars.xml Tue Dec 18 12:11:18 2007
@@ -2,6 +2,7 @@
These are introduced when configuration strings must be consistent across modules.
-->
<X-PRE-PROCESS cmd="set" data="domain=$${local_ip_v4}"/>
+ <X-PRE-PROCESS cmd="set" data="moh_uri=local_stream://moh"/>
<!-- sip_profile
Must be a domain name if you are being a registry server; otherwise
can be any string.
1
0
Author: mikej
Date: Tue Dec 18 12:00:42 2007
New Revision: 6865
Modified:
freeswitch/trunk/src/switch_core.c
Log:
don't include on windows.
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Tue Dec 18 12:00:42 2007
@@ -36,7 +36,9 @@
#include <switch.h>
#include <switch_version.h>
#include "private/switch_core_pvt.h"
+#ifndef WIN32
#include <switch_private.h>
+#endif
SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = { 0 };
1
0
Author: anthm
Date: Tue Dec 18 11:55:39 2007
New Revision: 6864
Modified:
freeswitch/trunk/src/switch.c
freeswitch/trunk/src/switch_core.c
Log:
add self-adjusting rlimit stuff for systems that support it
Modified: freeswitch/trunk/src/switch.c
==============================================================================
--- freeswitch/trunk/src/switch.c (original)
+++ freeswitch/trunk/src/switch.c Tue Dec 18 11:55:39 2007
@@ -235,6 +235,9 @@
"\t-g [group] -- specify group to switch to\n"
#endif
"\t-help -- this message\n"
+#ifdef HAVE_SETRLIMIT
+ "\t-core -- dump cores\n"
+#endif
"\t-hp -- enable high priority settings\n"
"\t-nosql -- disable internal sql scoreboard\n"
"\t-stop -- stop freeswitch\n"
@@ -307,6 +310,17 @@
known_opt++;
}
#endif
+#ifdef HAVE_SETRLIMIT
+ if (argv[x] && !strcmp(argv[x], "-core")) {
+ struct rlimit rlp;
+ memset(&rlp, 0, sizeof(rlp));
+ rlp.rlim_cur = RLIM_INFINITY;
+ rlp.rlim_max = RLIM_INFINITY;
+ setrlimit(RLIMIT_CORE, &rlp);
+ known_opt++;
+ }
+#endif
+
if (argv[x] && !strcmp(argv[x], "-hp")) {
high_prio++;
known_opt++;
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Tue Dec 18 11:55:39 2007
@@ -36,6 +36,7 @@
#include <switch.h>
#include <switch_version.h>
#include "private/switch_core_pvt.h"
+#include <switch_private.h>
SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = { 0 };
@@ -683,6 +684,33 @@
switch_core_set_variable("base_dir", SWITCH_GLOBAL_dirs.base_dir);
+#ifdef HAVE_SETRLIMIT
+ {
+ struct rlimit rlp;
+
+ memset(&rlp, 0, sizeof(rlp));
+ rlp.rlim_cur = SWITCH_THREAD_STACKSIZE;
+ rlp.rlim_max = SWITCH_THREAD_STACKSIZE;
+ setrlimit(RLIMIT_STACK, &rlp);
+
+ memset(&rlp, 0, sizeof(rlp));
+ rlp.rlim_cur = 999999;
+ rlp.rlim_max = 999999;
+ setrlimit(RLIMIT_NOFILE, &rlp);
+
+ memset(&rlp, 0, sizeof(rlp));
+ rlp.rlim_cur = RLIM_INFINITY;
+ rlp.rlim_max = RLIM_INFINITY;
+
+ setrlimit(RLIMIT_CPU, &rlp);
+ setrlimit(RLIMIT_DATA, &rlp);
+ setrlimit(RLIMIT_FSIZE, &rlp);
+ setrlimit(RLIMIT_AS, &rlp);
+ }
+
+#endif
+
+
if (switch_xml_init(runtime.memory_pool, err) != SWITCH_STATUS_SUCCESS) {
apr_terminate();
return SWITCH_STATUS_MEMERR;
@@ -712,6 +740,15 @@
switch_core_session_ctl(SCSC_LOGLEVEL, &level);
}
+#ifdef HAVE_SETRLIMIT
+ } else if (!strcasecmp(var, "dump-cores")) {
+ struct rlimit rlp;
+ memset(&rlp, 0, sizeof(rlp));
+ rlp.rlim_cur = RLIM_INFINITY;
+ rlp.rlim_max = RLIM_INFINITY;
+ setrlimit(RLIMIT_CORE, &rlp);
+#endif
+
} else if (!strcasecmp(var, "mailer-app")) {
runtime.mailer_app = switch_core_strdup(runtime.memory_pool, val);
} else if (!strcasecmp(var, "mailer-app-args")) {
1
0
18 Dec '07
Author: brian
Date: Tue Dec 18 11:31:05 2007
New Revision: 6863
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
Log:
remove whitespace madness thx stkn
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Tue Dec 18 11:31:05 2007
@@ -56,7 +56,8 @@
static void sofia_handle_sip_r_invite(switch_core_session_t *session, 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[]);
+
void sofia_handle_sip_r_notify(switch_core_session_t *session, 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[])
@@ -75,13 +76,13 @@
}
void sofia_handle_sip_i_notify(switch_core_session_t *session, 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[])
{
switch_channel_t *channel = NULL;
@@ -107,14 +108,14 @@
void sofia_event_callback(nua_event_t event,
- 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[])
+ 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[])
{
struct private_object *tech_pvt = NULL;
auth_res_t auth_res = AUTH_FORBIDDEN;
@@ -266,137 +267,137 @@
sofia_handle_sip_i_info(nua, profile, nh, session, sip, tags);
break;
case nua_r_refer:
- break;
- case nua_i_refer:
- if (session) {
- sofia_handle_sip_i_refer(nua, profile, nh, session, sip, tags);
- }
- break;
- case nua_r_subscribe:
- sofia_presence_handle_sip_r_subscribe(status, phrase, nua, profile, nh, sofia_private, sip, tags);
- break;
- case nua_i_subscribe:
- sofia_presence_handle_sip_i_subscribe(status, phrase, nua, profile, nh, sofia_private, sip, tags);
- break;
- default:
- if (status > 100) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s: unknown event %d: %03d %s\n", nua_event_name(event), event, status, phrase);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s: unknown event %d\n", nua_event_name(event), event);
- }
- break;
- }
-
- done:
-
- if (gateway) {
- sofia_reg_release_gateway(gateway);
- }
-
- if (session) {
- switch_core_session_rwunlock(session);
-
- }
- }
-
-
- void event_handler(switch_event_t *event)
- {
- char *subclass, *sql;
-
- if ((subclass = switch_event_get_header(event, "orig-event-subclass")) && !strcasecmp(subclass, MY_EVENT_REGISTER)) {
- char *from_user = switch_event_get_header(event, "orig-from-user");
- char *from_host = switch_event_get_header(event, "orig-from-host");
- char *contact_str = switch_event_get_header(event, "orig-contact");
- char *exp_str = switch_event_get_header(event, "orig-expires");
- char *rpid = switch_event_get_header(event, "orig-rpid");
- char *call_id = switch_event_get_header(event, "orig-call-id");
- char *user_agent = switch_event_get_header(event, "user-agent");
- long expires = (long) time(NULL) + atol(exp_str);
- char *profile_name = switch_event_get_header(event, "orig-profile-name");
- sofia_profile_t *profile = NULL;
-
- if (!rpid) {
- rpid = "unknown";
- }
-
- if (!profile_name || !(profile = sofia_glue_find_profile(profile_name))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Profile\n");
- return;
- }
- if (sofia_test_pflag(profile, PFLAG_MULTIREG)) {
- sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id);
- } else {
- sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'", from_user, from_host);
- }
-
- switch_mutex_lock(profile->ireg_mutex);
- sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, NULL);
- switch_safe_free(sql);
+ break;
+ case nua_i_refer:
+ if (session) {
+ sofia_handle_sip_i_refer(nua, profile, nh, session, sip, tags);
+ }
+ break;
+ case nua_r_subscribe:
+ sofia_presence_handle_sip_r_subscribe(status, phrase, nua, profile, nh, sofia_private, sip, tags);
+ break;
+ case nua_i_subscribe:
+ sofia_presence_handle_sip_i_subscribe(status, phrase, nua, profile, nh, sofia_private, sip, tags);
+ break;
+ default:
+ if (status > 100) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s: unknown event %d: %03d %s\n", nua_event_name(event), event, status, phrase);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s: unknown event %d\n", nua_event_name(event), event);
+ }
+ break;
+ }
+
+ done:
+
+ if (gateway) {
+ sofia_reg_release_gateway(gateway);
+ }
+
+ if (session) {
+ switch_core_session_rwunlock(session);
+
+ }
+}
+
+
+void event_handler(switch_event_t *event)
+{
+ char *subclass, *sql;
+
+ if ((subclass = switch_event_get_header(event, "orig-event-subclass")) && !strcasecmp(subclass, MY_EVENT_REGISTER)) {
+ char *from_user = switch_event_get_header(event, "orig-from-user");
+ char *from_host = switch_event_get_header(event, "orig-from-host");
+ char *contact_str = switch_event_get_header(event, "orig-contact");
+ char *exp_str = switch_event_get_header(event, "orig-expires");
+ char *rpid = switch_event_get_header(event, "orig-rpid");
+ char *call_id = switch_event_get_header(event, "orig-call-id");
+ char *user_agent = switch_event_get_header(event, "user-agent");
+ long expires = (long) time(NULL) + atol(exp_str);
+ char *profile_name = switch_event_get_header(event, "orig-profile-name");
+ sofia_profile_t *profile = NULL;
+
+ if (!rpid) {
+ rpid = "unknown";
+ }
+
+ if (!profile_name || !(profile = sofia_glue_find_profile(profile_name))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Profile\n");
+ return;
+ }
+ if (sofia_test_pflag(profile, PFLAG_MULTIREG)) {
+ sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id);
+ } else {
+ sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'", from_user, from_host);
+ }
+
+ switch_mutex_lock(profile->ireg_mutex);
+ sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, NULL);
+ switch_safe_free(sql);
- sql = switch_mprintf("insert into sip_registrations values ('%q', '%q','%q','%q','Registered', '%q', %ld, '%q')",
+ sql = switch_mprintf("insert into sip_registrations values ('%q', '%q','%q','%q','Registered', '%q', %ld, '%q')",
call_id, from_user, from_host, contact_str, rpid, expires, user_agent);
- if (sql) {
- sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, NULL);
- switch_safe_free(sql);
- sql = NULL;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Propagating registration for %s@%s->%s\n", from_user, from_host, contact_str);
- }
- switch_mutex_unlock(profile->ireg_mutex);
-
-
- if (profile) {
- sofia_glue_release_profile(profile);
- }
- }
- }
+ if (sql) {
+ sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, NULL);
+ switch_safe_free(sql);
+ sql = NULL;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Propagating registration for %s@%s->%s\n", from_user, from_host, contact_str);
+ }
+ switch_mutex_unlock(profile->ireg_mutex);
+
+
+ if (profile) {
+ sofia_glue_release_profile(profile);
+ }
+ }
+}
+
+
+
+void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void *obj)
+{
+ sofia_profile_t *profile = (sofia_profile_t *) obj;
+ switch_memory_pool_t *pool;
+ sip_alias_node_t *node;
+ uint32_t ireg_loops = 0;
+ uint32_t gateway_loops = 0;
+ switch_event_t *s_event;
+ int tportlog = 0;
+
+ switch_mutex_lock(mod_sofia_globals.mutex);
+ mod_sofia_globals.threads++;
+ switch_mutex_unlock(mod_sofia_globals.mutex);
+
+ profile->s_root = su_root_create(NULL);
+ profile->home = su_home_new(sizeof(*profile->home));
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating agent for %s\n", profile->name);
+
+ if (!sofia_glue_init_sql(profile)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open SQL Database [%s]!\n", profile->name);
+ sofia_glue_del_profile(profile);
+ goto end;
+ }
+ if (switch_test_flag(profile, TFLAG_TPORT_LOG)) {
+ tportlog = 1;
+ }
+ profile->nua = nua_create(profile->s_root, /* Event loop */
+ sofia_event_callback, /* Callback for processing events */
+ profile, /* Additional data to pass to callback */
+ NUTAG_URL(profile->bindurl), NTATAG_UDP_MTU(65536), TAG_IF(tportlog,TPTAG_LOG(1)), TAG_END()); /* Last tag should always finish the sequence */
- void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void *obj)
- {
- sofia_profile_t *profile = (sofia_profile_t *) obj;
- switch_memory_pool_t *pool;
- sip_alias_node_t *node;
- uint32_t ireg_loops = 0;
- uint32_t gateway_loops = 0;
- switch_event_t *s_event;
- int tportlog = 0;
-
- switch_mutex_lock(mod_sofia_globals.mutex);
- mod_sofia_globals.threads++;
- switch_mutex_unlock(mod_sofia_globals.mutex);
-
- profile->s_root = su_root_create(NULL);
- profile->home = su_home_new(sizeof(*profile->home));
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Creating agent for %s\n", profile->name);
-
- if (!sofia_glue_init_sql(profile)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open SQL Database [%s]!\n", profile->name);
- sofia_glue_del_profile(profile);
- goto end;
- }
-
- if (switch_test_flag(profile, TFLAG_TPORT_LOG)) {
- tportlog = 1;
- }
-
- profile->nua = nua_create(profile->s_root, /* Event loop */
- sofia_event_callback, /* Callback for processing events */
- profile, /* Additional data to pass to callback */
- NUTAG_URL(profile->bindurl), NTATAG_UDP_MTU(65536), TAG_IF(tportlog,TPTAG_LOG(1)), TAG_END()); /* Last tag should always finish the sequence */
-
- if (!profile->nua) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Creating SIP UA for profile: %s\n", profile->name);
- sofia_glue_del_profile(profile);
- goto end;
- }
+ if (!profile->nua) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Creating SIP UA for profile: %s\n", profile->name);
+ sofia_glue_del_profile(profile);
+ goto end;
+ }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created agent for %s\n", profile->name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created agent for %s\n", profile->name);
- nua_set_params(profile->nua,
+ nua_set_params(profile->nua,
NUTAG_APPL_METHOD("OPTIONS"),
NUTAG_APPL_METHOD("NOTIFY"),
NUTAG_APPL_METHOD("INFO"),
@@ -419,15 +420,15 @@
TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW_EVENTS("message-summary")),
SIPTAG_SUPPORTED_STR("100rel, precondition, timer"), SIPTAG_USER_AGENT_STR(profile->user_agent), TAG_END());
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set params for %s\n", profile->name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set params for %s\n", profile->name);
- for (node = profile->aliases; node; node = node->next) {
- node->nua = nua_create(profile->s_root, /* Event loop */
+ for (node = profile->aliases; node; node = node->next) {
+ node->nua = nua_create(profile->s_root, /* Event loop */
sofia_event_callback, /* Callback for processing events */
profile, /* Additional data to pass to callback */
NUTAG_URL(node->url), TAG_END()); /* Last tag should always finish the sequence */
- nua_set_params(node->nua,
+ nua_set_params(node->nua,
NUTAG_APPL_METHOD("OPTIONS"),
NUTAG_EARLY_MEDIA(1),
NUTAG_AUTOANSWER(0),
@@ -439,738 +440,738 @@
TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ENABLEMESSAGE(1)),
SIPTAG_SUPPORTED_STR("100rel, precondition"), SIPTAG_USER_AGENT_STR(profile->user_agent), TAG_END());
- }
+ }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "activated db for %s\n", profile->name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "activated db for %s\n", profile->name);
- switch_mutex_init(&profile->ireg_mutex, SWITCH_MUTEX_NESTED, profile->pool);
- switch_mutex_init(&profile->gateway_mutex, SWITCH_MUTEX_NESTED, profile->pool);
+ switch_mutex_init(&profile->ireg_mutex, SWITCH_MUTEX_NESTED, profile->pool);
+ switch_mutex_init(&profile->gateway_mutex, SWITCH_MUTEX_NESTED, profile->pool);
- ireg_loops = IREG_SECONDS;
- gateway_loops = GATEWAY_SECONDS;
+ ireg_loops = IREG_SECONDS;
+ gateway_loops = GATEWAY_SECONDS;
- if (switch_event_create(&s_event, SWITCH_EVENT_PUBLISH) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "service", "_sip._udp,_sip._tcp,_sip._sctp");
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "port", "%d", profile->sip_port);
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "module_name", "%s", "mod_sofia");
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "profile_name", "%s", profile->name);
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "profile_uri", "%s", profile->url);
- switch_event_fire(&s_event);
- }
+ if (switch_event_create(&s_event, SWITCH_EVENT_PUBLISH) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "service", "_sip._udp,_sip._tcp,_sip._sctp");
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "port", "%d", profile->sip_port);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "module_name", "%s", "mod_sofia");
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "profile_name", "%s", profile->name);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "profile_uri", "%s", profile->url);
+ switch_event_fire(&s_event);
+ }
- sofia_glue_add_profile(profile->name, profile);
+ sofia_glue_add_profile(profile->name, profile);
- if (profile->pflags & PFLAG_PRESENCE) {
- sofia_presence_establish_presence(profile);
- }
+ if (profile->pflags & PFLAG_PRESENCE) {
+ sofia_presence_establish_presence(profile);
+ }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Starting thread for %s\n", profile->name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Starting thread for %s\n", profile->name);
- profile->started = time(NULL);
- switch_yield(1000000);
+ profile->started = time(NULL);
+ switch_yield(1000000);
- sofia_set_pflag_locked(profile, PFLAG_RUNNING);
+ sofia_set_pflag_locked(profile, PFLAG_RUNNING);
- while (mod_sofia_globals.running == 1 && sofia_test_pflag(profile, PFLAG_RUNNING)) {
- if (++ireg_loops >= IREG_SECONDS) {
- sofia_reg_check_expire(profile, time(NULL));
- ireg_loops = 0;
- }
+ while (mod_sofia_globals.running == 1 && sofia_test_pflag(profile, PFLAG_RUNNING)) {
+ if (++ireg_loops >= IREG_SECONDS) {
+ sofia_reg_check_expire(profile, time(NULL));
+ ireg_loops = 0;
+ }
- if (++gateway_loops >= GATEWAY_SECONDS) {
- sofia_reg_check_gateway(profile, time(NULL));
- gateway_loops = 0;
- }
+ if (++gateway_loops >= GATEWAY_SECONDS) {
+ sofia_reg_check_gateway(profile, time(NULL));
+ gateway_loops = 0;
+ }
- su_root_step(profile->s_root, 1000);
- }
+ su_root_step(profile->s_root, 1000);
+ }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock %s\n", profile->name);
- switch_thread_rwlock_wrlock(profile->rwlock);
- sofia_reg_unregister(profile);
- nua_shutdown(profile->nua);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock %s\n", profile->name);
+ switch_thread_rwlock_wrlock(profile->rwlock);
+ sofia_reg_unregister(profile);
+ nua_shutdown(profile->nua);
- su_root_run(profile->s_root);
- nua_destroy(profile->nua);
+ su_root_run(profile->s_root);
+ nua_destroy(profile->nua);
- switch_mutex_lock(profile->ireg_mutex);
- switch_mutex_unlock(profile->ireg_mutex);
+ switch_mutex_lock(profile->ireg_mutex);
+ switch_mutex_unlock(profile->ireg_mutex);
- if (switch_event_create(&s_event, SWITCH_EVENT_UNPUBLISH) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "service", "_sip._udp,_sip._tcp,_sip._sctp");
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "port", "%d", profile->sip_port);
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "module_name", "%s", "mod_sofia");
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "profile_name", "%s", profile->name);
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "profile_uri", "%s", profile->url);
- switch_event_fire(&s_event);
- }
+ if (switch_event_create(&s_event, SWITCH_EVENT_UNPUBLISH) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "service", "_sip._udp,_sip._tcp,_sip._sctp");
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "port", "%d", profile->sip_port);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "module_name", "%s", "mod_sofia");
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "profile_name", "%s", profile->name);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "profile_uri", "%s", profile->url);
+ switch_event_fire(&s_event);
+ }
- sofia_glue_sql_close(profile);
- su_home_unref(profile->home);
- su_root_destroy(profile->s_root);
- pool = profile->pool;
+ sofia_glue_sql_close(profile);
+ su_home_unref(profile->home);
+ su_root_destroy(profile->s_root);
+ pool = profile->pool;
- sofia_glue_del_profile(profile);
- switch_core_hash_destroy(&profile->chat_hash);
- switch_core_hash_destroy(&profile->sub_hash);
+ sofia_glue_del_profile(profile);
+ switch_core_hash_destroy(&profile->chat_hash);
+ switch_core_hash_destroy(&profile->sub_hash);
- switch_thread_rwlock_unlock(profile->rwlock);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write unlock %s\n", profile->name);
+ switch_thread_rwlock_unlock(profile->rwlock);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write unlock %s\n", profile->name);
- if (sofia_test_pflag(profile, PFLAG_RESPAWN)) {
- config_sofia(1, profile->name);
- }
+ if (sofia_test_pflag(profile, PFLAG_RESPAWN)) {
+ config_sofia(1, profile->name);
+ }
- switch_core_destroy_memory_pool(&pool);
+ switch_core_destroy_memory_pool(&pool);
end:
- switch_mutex_lock(mod_sofia_globals.mutex);
- mod_sofia_globals.threads--;
- switch_mutex_unlock(mod_sofia_globals.mutex);
-
- return NULL;
- }
-
- void launch_sofia_profile_thread(sofia_profile_t *profile)
- {
- switch_thread_t *thread;
- switch_threadattr_t *thd_attr = NULL;
-
- switch_threadattr_create(&thd_attr, profile->pool);
- switch_threadattr_detach_set(thd_attr, 1);
- switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&thread, thd_attr, sofia_profile_thread_run, profile, profile->pool);
- }
-
- static void logger(void *logarg, char const *fmt, va_list ap)
- {
- char *data = NULL;
-
- if (fmt) {
- #ifdef HAVE_VASPRINTF
- int ret;
- ret = vasprintf(&data, fmt, ap);
- if ((ret == -1) || !data) {
- return;
- }
- #else
- data = (char *) malloc(2048);
- if (data) {
- vsnprintf(data, 2048, fmt, ap);
- } else {
- return;
- }
- #endif
- }
- if (data) {
- switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, (char *) "%s", data);
- free(data);
- }
- }
-
-
- static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
- {
- switch_xml_t gateway_tag, param;
- sofia_gateway_t *gp;
-
- for (gateway_tag = switch_xml_child(gateways_tag, "gateway"); gateway_tag; gateway_tag = gateway_tag->next) {
- char *name = (char *) switch_xml_attr_soft(gateway_tag, "name");
- sofia_gateway_t *gateway;
-
- if (switch_strlen_zero(name)) {
- name = "anonymous";
- }
-
- if ((gateway = switch_core_alloc(profile->pool, sizeof(*gateway)))) {
- char *register_str = "true", *scheme = "Digest",
- *realm = NULL,
- *username = NULL,
- *password = NULL,
- *caller_id_in_from = "false",
- *extension = NULL,
- *proxy = NULL,
- *context = "default",
- *expire_seconds = "3600",
- *retry_seconds = "30",
- *from_user = "",
- *from_domain = "",
- *register_proxy = NULL,
- *contact_params = NULL,
- *params = NULL,
- *register_transport = "udp";
-
- gateway->pool = profile->pool;
- gateway->profile = profile;
- gateway->name = switch_core_strdup(gateway->pool, name);
- gateway->freq = 0;
- gateway->next = NULL;
-
- for (param = switch_xml_child(gateway_tag, "param"); param; param = param->next) {
- char *var = (char *) switch_xml_attr_soft(param, "name");
- char *val = (char *) switch_xml_attr_soft(param, "value");
-
- if (!strcmp(var, "register")) {
- register_str = val;
- } else if (!strcmp(var, "scheme")) {
- scheme = val;
- } else if (!strcmp(var, "realm")) {
- realm = val;
- } else if (!strcmp(var, "username")) {
- username = val;
- } else if (!strcmp(var, "password")) {
- password = val;
- } else if (!strcmp(var, "caller-id-in-from")) {
- caller_id_in_from = val;
- } else if (!strcmp(var, "extension")) {
- extension = val;
- } else if (!strcmp(var, "proxy")) {
- proxy = val;
- } else if (!strcmp(var, "context")) {
- context = val;
- } else if (!strcmp(var, "expire-seconds")) {
- expire_seconds = val;
- } else if (!strcmp(var, "retry-seconds")) {
- retry_seconds = val;
- } else if (!strcmp(var, "from-user")) {
- from_user = val;
- } else if (!strcmp(var, "from-domain")) {
- from_domain = val;
- } else if (!strcmp(var, "register-proxy")) {
- register_proxy = val;
- } else if (!strcmp(var, "contact-params")) {
- contact_params = val;
- } else if (!strcmp(var, "register-transport")) {
- if (!strcasecmp(val, "udp") || !strcasecmp(val, "tcp")) {
- register_transport = val;
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: unsupported transport\n");
- goto skip;
- }
- }
- }
-
- if (switch_strlen_zero(realm)) {
- realm = name;
- }
-
- if (switch_strlen_zero(username)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: username param is REQUIRED!\n");
- goto skip;
- }
-
- if (switch_strlen_zero(password)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: password param is REQUIRED!\n");
- goto skip;
- }
-
- if (switch_strlen_zero(from_user)) {
- from_user = username;
- }
-
- if (switch_strlen_zero(extension)) {
- extension = username;
- }
-
- if (switch_strlen_zero(proxy)) {
- proxy = realm;
- }
-
- if (!switch_true(register_str)) {
- gateway->state = REG_STATE_NOREG;
- }
-
- if (switch_strlen_zero(from_domain)) {
- from_domain = realm;
- }
-
- if (switch_strlen_zero(register_proxy)) {
- register_proxy = proxy;
- }
-
- gateway->retry_seconds = atoi(retry_seconds);
- if (gateway->retry_seconds < 10) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "INVALID: retry_seconds correcting the value to 30\n");
- gateway->retry_seconds = 30;
- }
- gateway->register_scheme = switch_core_strdup(gateway->pool, scheme);
- gateway->register_context = switch_core_strdup(gateway->pool, context);
- gateway->register_realm = switch_core_strdup(gateway->pool, realm);
- gateway->register_username = switch_core_strdup(gateway->pool, username);
- gateway->register_password = switch_core_strdup(gateway->pool, password);
- if (switch_true(caller_id_in_from)) {
- switch_set_flag(gateway, REG_FLAG_CALLERID);
- }
- if (contact_params) {
- if (*contact_params == ';') {
- params = switch_core_sprintf(gateway->pool, "%s&transport=%s", contact_params, register_transport);
- } else {
- params = switch_core_sprintf(gateway->pool, ";%s&transport=%s", contact_params, register_transport);
- }
- } else {
- params = switch_core_sprintf(gateway->pool, ";transport=%s", register_transport);
- }
-
- gateway->register_url = switch_core_sprintf(gateway->pool, "sip:%s;transport=%s", register_proxy,register_transport);
- gateway->register_from = switch_core_sprintf(gateway->pool, "<sip:%s@%s;transport=%s>", from_user, from_domain, register_transport);
- gateway->register_contact = switch_core_sprintf(gateway->pool, "<sip:%s@%s:%d%s>", extension,
+ switch_mutex_lock(mod_sofia_globals.mutex);
+ mod_sofia_globals.threads--;
+ switch_mutex_unlock(mod_sofia_globals.mutex);
+
+ return NULL;
+}
+
+void launch_sofia_profile_thread(sofia_profile_t *profile)
+{
+ switch_thread_t *thread;
+ switch_threadattr_t *thd_attr = NULL;
+
+ switch_threadattr_create(&thd_attr, profile->pool);
+ switch_threadattr_detach_set(thd_attr, 1);
+ switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+ switch_thread_create(&thread, thd_attr, sofia_profile_thread_run, profile, profile->pool);
+}
+
+static void logger(void *logarg, char const *fmt, va_list ap)
+{
+ char *data = NULL;
+
+ if (fmt) {
+#ifdef HAVE_VASPRINTF
+ int ret;
+ ret = vasprintf(&data, fmt, ap);
+ if ((ret == -1) || !data) {
+ return;
+ }
+#else
+ data = (char *) malloc(2048);
+ if (data) {
+ vsnprintf(data, 2048, fmt, ap);
+ } else {
+ return;
+ }
+#endif
+ }
+ if (data) {
+ switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, (char *) "%s", data);
+ free(data);
+ }
+}
+
+
+static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
+{
+ switch_xml_t gateway_tag, param;
+ sofia_gateway_t *gp;
+
+ for (gateway_tag = switch_xml_child(gateways_tag, "gateway"); gateway_tag; gateway_tag = gateway_tag->next) {
+ char *name = (char *) switch_xml_attr_soft(gateway_tag, "name");
+ sofia_gateway_t *gateway;
+
+ if (switch_strlen_zero(name)) {
+ name = "anonymous";
+ }
+
+ if ((gateway = switch_core_alloc(profile->pool, sizeof(*gateway)))) {
+ char *register_str = "true", *scheme = "Digest",
+ *realm = NULL,
+ *username = NULL,
+ *password = NULL,
+ *caller_id_in_from = "false",
+ *extension = NULL,
+ *proxy = NULL,
+ *context = "default",
+ *expire_seconds = "3600",
+ *retry_seconds = "30",
+ *from_user = "",
+ *from_domain = "",
+ *register_proxy = NULL,
+ *contact_params = NULL,
+ *params = NULL,
+ *register_transport = "udp";
+
+ gateway->pool = profile->pool;
+ gateway->profile = profile;
+ gateway->name = switch_core_strdup(gateway->pool, name);
+ gateway->freq = 0;
+ gateway->next = NULL;
+
+ for (param = switch_xml_child(gateway_tag, "param"); param; param = param->next) {
+ char *var = (char *) switch_xml_attr_soft(param, "name");
+ char *val = (char *) switch_xml_attr_soft(param, "value");
+
+ if (!strcmp(var, "register")) {
+ register_str = val;
+ } else if (!strcmp(var, "scheme")) {
+ scheme = val;
+ } else if (!strcmp(var, "realm")) {
+ realm = val;
+ } else if (!strcmp(var, "username")) {
+ username = val;
+ } else if (!strcmp(var, "password")) {
+ password = val;
+ } else if (!strcmp(var, "caller-id-in-from")) {
+ caller_id_in_from = val;
+ } else if (!strcmp(var, "extension")) {
+ extension = val;
+ } else if (!strcmp(var, "proxy")) {
+ proxy = val;
+ } else if (!strcmp(var, "context")) {
+ context = val;
+ } else if (!strcmp(var, "expire-seconds")) {
+ expire_seconds = val;
+ } else if (!strcmp(var, "retry-seconds")) {
+ retry_seconds = val;
+ } else if (!strcmp(var, "from-user")) {
+ from_user = val;
+ } else if (!strcmp(var, "from-domain")) {
+ from_domain = val;
+ } else if (!strcmp(var, "register-proxy")) {
+ register_proxy = val;
+ } else if (!strcmp(var, "contact-params")) {
+ contact_params = val;
+ } else if (!strcmp(var, "register-transport")) {
+ if (!strcasecmp(val, "udp") || !strcasecmp(val, "tcp")) {
+ register_transport = val;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: unsupported transport\n");
+ goto skip;
+ }
+ }
+ }
+
+ if (switch_strlen_zero(realm)) {
+ realm = name;
+ }
+
+ if (switch_strlen_zero(username)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: username param is REQUIRED!\n");
+ goto skip;
+ }
+
+ if (switch_strlen_zero(password)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: password param is REQUIRED!\n");
+ goto skip;
+ }
+
+ if (switch_strlen_zero(from_user)) {
+ from_user = username;
+ }
+
+ if (switch_strlen_zero(extension)) {
+ extension = username;
+ }
+
+ if (switch_strlen_zero(proxy)) {
+ proxy = realm;
+ }
+
+ if (!switch_true(register_str)) {
+ gateway->state = REG_STATE_NOREG;
+ }
+
+ if (switch_strlen_zero(from_domain)) {
+ from_domain = realm;
+ }
+
+ if (switch_strlen_zero(register_proxy)) {
+ register_proxy = proxy;
+ }
+
+ gateway->retry_seconds = atoi(retry_seconds);
+ if (gateway->retry_seconds < 10) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "INVALID: retry_seconds correcting the value to 30\n");
+ gateway->retry_seconds = 30;
+ }
+ gateway->register_scheme = switch_core_strdup(gateway->pool, scheme);
+ gateway->register_context = switch_core_strdup(gateway->pool, context);
+ gateway->register_realm = switch_core_strdup(gateway->pool, realm);
+ gateway->register_username = switch_core_strdup(gateway->pool, username);
+ gateway->register_password = switch_core_strdup(gateway->pool, password);
+ if (switch_true(caller_id_in_from)) {
+ switch_set_flag(gateway, REG_FLAG_CALLERID);
+ }
+ if (contact_params) {
+ if (*contact_params == ';') {
+ params = switch_core_sprintf(gateway->pool, "%s&transport=%s", contact_params, register_transport);
+ } else {
+ params = switch_core_sprintf(gateway->pool, ";%s&transport=%s", contact_params, register_transport);
+ }
+ } else {
+ params = switch_core_sprintf(gateway->pool, ";transport=%s", register_transport);
+ }
+
+ gateway->register_url = switch_core_sprintf(gateway->pool, "sip:%s;transport=%s", register_proxy,register_transport);
+ gateway->register_from = switch_core_sprintf(gateway->pool, "<sip:%s@%s;transport=%s>", from_user, from_domain, register_transport);
+ gateway->register_contact = switch_core_sprintf(gateway->pool, "<sip:%s@%s:%d%s>", extension,
profile->extsipip ? profile->extsipip : profile->sipip, profile->sip_port, params);
- if (!strncasecmp(proxy, "sip:", 4)) {
- gateway->register_proxy = switch_core_strdup(gateway->pool, proxy);
- gateway->register_to = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy + 4);
- } else {
- gateway->register_proxy = switch_core_sprintf(gateway->pool, "sip:%s", proxy);
- gateway->register_to = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy);
- }
+ if (!strncasecmp(proxy, "sip:", 4)) {
+ gateway->register_proxy = switch_core_strdup(gateway->pool, proxy);
+ gateway->register_to = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy + 4);
+ } else {
+ gateway->register_proxy = switch_core_sprintf(gateway->pool, "sip:%s", proxy);
+ gateway->register_to = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy);
+ }
- gateway->expires_str = switch_core_strdup(gateway->pool, expire_seconds);
+ gateway->expires_str = switch_core_strdup(gateway->pool, expire_seconds);
- if ((gateway->freq = atoi(gateway->expires_str)) < 5) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+ if ((gateway->freq = atoi(gateway->expires_str)) < 5) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
"Invalid Freq: %d. Setting Register-Frequency to 3600\n", gateway->freq);
- gateway->freq = 3600;
- }
- gateway->freq -= 2;
-
- if ((gp = sofia_reg_find_gateway(gateway->name))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate gateway '%s'\n", gateway->name);
- sofia_reg_release_gateway(gp);
- } else {
- gateway->next = profile->gateways;
- profile->gateways = gateway;
- sofia_reg_add_gateway(gateway->name, gateway);
- }
- }
-
- skip:
- switch_assert(gateway_tag);
- }
-
- }
-
- switch_status_t config_sofia(int reload, char *profile_name)
- {
- char *cf = "sofia.conf";
- switch_xml_t cfg, xml = NULL, xprofile, param, settings, profiles, gateways_tag, domain_tag, domains_tag;
- switch_status_t status = SWITCH_STATUS_SUCCESS;
- sofia_profile_t *profile = NULL;
- char url[512] = "";
- int profile_found = 0;
-
- if (!reload) {
- su_init();
- if (sip_update_default_mclass(sip_extend_mclass(NULL)) < 0) {
- su_deinit();
- return SWITCH_STATUS_FALSE;
- }
-
- su_log_redirect(NULL, logger, NULL);
- su_log_redirect(tport_log, logger, NULL);
- }
-
- if (!switch_strlen_zero(profile_name) && (profile = sofia_glue_find_profile(profile_name))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile [%s] Already exists.\n", switch_str_nil(profile_name));
- status = SWITCH_STATUS_FALSE;
- sofia_glue_release_profile(profile);
- return status;
- }
-
- switch_snprintf(url, sizeof(url), "profile=%s", switch_str_nil(profile_name));
-
- if (!(xml = switch_xml_open_cfg(cf, &cfg, url))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
- status = SWITCH_STATUS_FALSE;
- goto done;
- }
-
- if ((settings = switch_xml_child(cfg, "global_settings"))) {
- for (param = switch_xml_child(settings, "param"); param; param = param->next) {
- char *var = (char *) switch_xml_attr_soft(param, "name");
- char *val = (char *) switch_xml_attr_soft(param, "value");
- if (!strcasecmp(var, "log-level")) {
- su_log_set_level(NULL, atoi(val));
- }
- }
- }
-
- if ((profiles = switch_xml_child(cfg, "profiles"))) {
- for (xprofile = switch_xml_child(profiles, "profile"); xprofile; xprofile = xprofile->next) {
- if (!(settings = switch_xml_child(xprofile, "settings"))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Settings, check the new config!\n");
- } else {
- char *xprofilename = (char *) switch_xml_attr_soft(xprofile, "name");
- switch_memory_pool_t *pool = NULL;
-
- if (!xprofilename) {
- xprofilename = "unnamed";
- }
-
- if (profile_name) {
- if (strcasecmp(profile_name, xprofilename)) {
- continue;
- } else {
- profile_found = 1;
- }
- }
-
- /* Setup the pool */
- if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
- goto done;
- }
-
- if (!(profile = (sofia_profile_t *) switch_core_alloc(pool, sizeof(*profile)))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
- goto done;
- }
-
- profile->pool = pool;
- profile->user_agent = SOFIA_USER_AGENT;
-
- profile->name = switch_core_strdup(profile->pool, xprofilename);
- switch_snprintf(url, sizeof(url), "sofia_reg_%s", xprofilename);
-
- profile->dbname = switch_core_strdup(profile->pool, url);
- switch_core_hash_init(&profile->chat_hash, profile->pool);
- switch_core_hash_init(&profile->sub_hash, profile->pool);
- switch_thread_rwlock_create(&profile->rwlock, profile->pool);
- switch_mutex_init(&profile->flag_mutex, SWITCH_MUTEX_NESTED, profile->pool);
- profile->dtmf_duration = 100;
-
- for (param = switch_xml_child(settings, "param"); param; param = param->next) {
- char *var = (char *) switch_xml_attr_soft(param, "name");
- char *val = (char *) switch_xml_attr_soft(param, "value");
-
- if (!strcasecmp(var, "debug")) {
- profile->debug = atoi(val);
- } else if (!strcasecmp(var, "use-rtp-timer") && switch_true(val)) {
- switch_set_flag(profile, TFLAG_TIMER);
- } else if (!strcasecmp(var, "sip-trace") && switch_true(val)) {
- switch_set_flag(profile, TFLAG_TPORT_LOG);
- } else if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) {
- #ifdef SWITCH_HAVE_ODBC
- profile->odbc_dsn = switch_core_strdup(profile->pool, val);
- if ((profile->odbc_user = strchr(profile->odbc_dsn, ':'))) {
- *profile->odbc_user++ = '\0';
- if ((profile->odbc_pass = strchr(profile->odbc_user, ':'))) {
- *profile->odbc_pass++ = '\0';
- }
- }
-
- #else
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
- #endif
-
- } else if (!strcasecmp(var, "user-agent-string")) {
- profile->user_agent = switch_core_strdup(profile->pool, val);;
- } else if (!strcasecmp(var, "inbound-no-media") && switch_true(val)) {
- switch_set_flag(profile, TFLAG_INB_NOMEDIA);
- } else if (!strcasecmp(var, "inbound-late-negotiation") && switch_true(val)) {
- switch_set_flag(profile, TFLAG_LATE_NEGOTIATION);
- } else if (!strcasecmp(var, "rfc2833-pt")) {
- profile->te = (switch_payload_t) atoi(val);
- } else if (!strcasecmp(var, "cng-pt")) {
- profile->cng_pt = (switch_payload_t) atoi(val);
- } else if (!strcasecmp(var, "sip-port")) {
- profile->sip_port = atoi(val);
- } else if (!strcasecmp(var, "vad")) {
- if (!strcasecmp(val, "in")) {
- switch_set_flag(profile, TFLAG_VAD_IN);
- } else if (!strcasecmp(val, "out")) {
- switch_set_flag(profile, TFLAG_VAD_OUT);
- } else if (!strcasecmp(val, "both")) {
- switch_set_flag(profile, TFLAG_VAD_IN);
- switch_set_flag(profile, TFLAG_VAD_OUT);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invald option %s for VAD\n", val);
- }
- } else if (!strcasecmp(var, "ext-rtp-ip")) {
- profile->extrtpip = switch_core_strdup(profile->pool, strcasecmp(val, "auto") ? val : mod_sofia_globals.guess_ip);
- } else if (!strcasecmp(var, "rtp-ip")) {
- profile->rtpip = switch_core_strdup(profile->pool, strcasecmp(val, "auto") ? val : mod_sofia_globals.guess_ip);
- } else if (!strcasecmp(var, "sip-ip")) {
- profile->sipip = switch_core_strdup(profile->pool, strcasecmp(val, "auto") ? val : mod_sofia_globals.guess_ip);
- } else if (!strcasecmp(var, "ext-sip-ip")) {
- if (!strcasecmp(val, "auto")) {
- profile->extsipip = switch_core_strdup(profile->pool, mod_sofia_globals.guess_ip);
- } else {
- char *ip = mod_sofia_globals.guess_ip;
- switch_port_t port = 0;
- if (sofia_glue_ext_address_lookup(&ip, &port, val, profile->pool) == SWITCH_STATUS_SUCCESS) {
-
- if (ip) {
- profile->extsipip = switch_core_strdup(profile->pool, ip);
- }
- }
- }
- } else if (!strcasecmp(var, "force-register-domain")) {
- profile->reg_domain = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "bind-params")) {
- profile->bind_params = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "sip-domain")) {
- profile->sipdomain = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "rtp-timer-name")) {
- profile->timer_name = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "hold-music")) {
- profile->hold_music = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "session-timeout")) {
- int v_session_timeout = atoi(val);
- if (v_session_timeout >= 0) {
- profile->session_timeout = v_session_timeout;
- }
- } else if (!strcasecmp(var, "max-proceeding")) {
- int v_max_proceeding = atoi(val);
- if (v_max_proceeding >= 0) {
- profile->max_proceeding = v_max_proceeding;
- }
- } else if (!strcasecmp(var, "rtp-timeout-sec")) {
- int v = atoi(val);
- if (v >= 0) {
- profile->rtp_timeout_sec = v;
- }
- } else if (!strcasecmp(var, "manage-presence")) {
- if (switch_true(val)) {
- profile->pflags |= PFLAG_PRESENCE;
- }
- } else if (!strcasecmp(var, "multiple-registrations")) {
- if (switch_true(val)) {
- profile->pflags |= PFLAG_MULTIREG;
- }
- } else if (!strcasecmp(var, "supress-cng")) {
- if (switch_true(val)) {
- profile->pflags |= PFLAG_SUPRESS_CNG;
- }
- } else if (!strcasecmp(var, "NDLB-to-in-200-contact")) {
- if (switch_true(val)) {
- profile->ndlb |= PFLAG_NDLB_TO_IN_200_CONTACT;
- }
- } else if (!strcasecmp(var, "NDLB-broken-auth-hash")) {
- if (switch_true(val)) {
- profile->ndlb |= PFLAG_NDLB_BROKEN_AUTH_HASH;
- }
- } else if (!strcasecmp(var, "pass-rfc2833")) {
- if (switch_true(val)) {
- profile->pflags |= PFLAG_PASS_RFC2833;
- }
- } else if (!strcasecmp(var, "inbound-codec-negotiation")) {
- if (!strcasecmp(val, "greedy")) {
- profile->pflags |= PFLAG_GREEDY;
- }
- } else if (!strcasecmp(var, "disable-transcoding")) {
- if (switch_true(val)) {
- profile->pflags |= PFLAG_DISABLE_TRANSCODING;
- }
- } else if (!strcasecmp(var, "rtp-rewrite-timestamps")) {
- if (switch_true(val)) {
- profile->pflags |= PFLAG_REWRITE_TIMESTAMPS;
- }
- } else if (!strcasecmp(var, "auth-calls")) {
- if (switch_true(val)) {
- profile->pflags |= PFLAG_AUTH_CALLS;
- }
- } else if (!strcasecmp(var, "nonce-ttl")) {
- profile->nonce_ttl = atoi(val);
- } else if (!strcasecmp(var, "accept-blind-reg")) {
- if (switch_true(val)) {
- profile->pflags |= PFLAG_BLIND_REG;
- }
- } else if (!strcasecmp(var, "auth-all-packets")) {
- if (switch_true(val)) {
- profile->pflags |= PFLAG_AUTH_ALL;
- }
- } else if (!strcasecmp(var, "full-id-in-dialplan")) {
- if (switch_true(val)) {
- profile->pflags |= PFLAG_FULL_ID;
- }
- } else if (!strcasecmp(var, "bitpacking")) {
- if (!strcasecmp(val, "aal2")) {
- profile->codec_flags = SWITCH_CODEC_FLAG_AAL2;
- }
- } else if (!strcasecmp(var, "username")) {
- profile->username = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "context")) {
- profile->context = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "alias")) {
- sip_alias_node_t *node;
- if ((node = switch_core_alloc(profile->pool, sizeof(*node)))) {
- if ((node->url = switch_core_strdup(profile->pool, val))) {
- node->next = profile->aliases;
- profile->aliases = node;
- }
- }
- } else if (!strcasecmp(var, "dialplan")) {
- profile->dialplan = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "max-calls")) {
- profile->max_calls = atoi(val);
- } else if (!strcasecmp(var, "codec-prefs")) {
- profile->codec_string = switch_core_strdup(profile->pool, val);
- } else if (!strcasecmp(var, "dtmf-duration")) {
- int dur = atoi(val);
- if (dur > 10 && dur < 8000) {
- profile->dtmf_duration = dur;
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Duration out of bounds!\n");
- }
- }
- }
-
- if (!profile->cng_pt) {
- profile->cng_pt = SWITCH_RTP_CNG_PAYLOAD;
- }
-
- if (!profile->sipip) {
- profile->sipip = switch_core_strdup(profile->pool, mod_sofia_globals.guess_ip);
- }
-
- if (!profile->rtpip) {
- profile->rtpip = switch_core_strdup(profile->pool, mod_sofia_globals.guess_ip);
- }
-
- if (profile->nonce_ttl < 60) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting nonce TTL to 60 seconds\n");
- profile->nonce_ttl = 60;
- }
-
- if (switch_test_flag(profile, TFLAG_TIMER) && !profile->timer_name) {
- profile->timer_name = switch_core_strdup(profile->pool, "soft");
- }
-
- if (!profile->username) {
- profile->username = switch_core_strdup(profile->pool, "FreeSWITCH");
- }
-
- if (!profile->rtpip) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Setting ip to '127.0.0.1'\n");
- profile->rtpip = switch_core_strdup(profile->pool, "127.0.0.1");
- }
-
- if (!profile->sip_port) {
- profile->sip_port = atoi(SOFIA_DEFAULT_PORT);
- }
-
- if (!profile->dialplan) {
- profile->dialplan = switch_core_strdup(profile->pool, "XML");
- }
-
- if (!profile->sipdomain) {
- profile->sipdomain = switch_core_strdup(profile->pool, profile->sipip);
- }
- if (profile->extsipip) {
- profile->url = switch_core_sprintf(profile->pool, "sip:mod_sofia@%s:%d", profile->extsipip, profile->sip_port);
- profile->bindurl = switch_core_sprintf(profile->pool, "%s;maddr=%s", profile->url, profile->sipip);
- } else {
- profile->url = switch_core_sprintf(profile->pool, "sip:mod_sofia@%s:%d", profile->sipip, profile->sip_port);
- profile->bindurl = profile->url;
- }
-
- if (profile->bind_params) {
- char *bindurl = profile->bindurl;
- profile->bindurl = switch_core_sprintf(profile->pool, "%s;%s", bindurl, profile->bind_params);
- }
-
- }
- if (profile) {
- switch_xml_t aliases_tag, alias_tag;
+ gateway->freq = 3600;
+ }
+ gateway->freq -= 2;
+
+ if ((gp = sofia_reg_find_gateway(gateway->name))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring duplicate gateway '%s'\n", gateway->name);
+ sofia_reg_release_gateway(gp);
+ } else {
+ gateway->next = profile->gateways;
+ profile->gateways = gateway;
+ sofia_reg_add_gateway(gateway->name, gateway);
+ }
+ }
+
+ skip:
+ switch_assert(gateway_tag);
+ }
+
+}
+
+switch_status_t config_sofia(int reload, char *profile_name)
+{
+ char *cf = "sofia.conf";
+ switch_xml_t cfg, xml = NULL, xprofile, param, settings, profiles, gateways_tag, domain_tag, domains_tag;
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+ sofia_profile_t *profile = NULL;
+ char url[512] = "";
+ int profile_found = 0;
- if ((gateways_tag = switch_xml_child(xprofile, "registrations"))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
+ if (!reload) {
+ su_init();
+ if (sip_update_default_mclass(sip_extend_mclass(NULL)) < 0) {
+ su_deinit();
+ return SWITCH_STATUS_FALSE;
+ }
+
+ su_log_redirect(NULL, logger, NULL);
+ su_log_redirect(tport_log, logger, NULL);
+ }
+
+ if (!switch_strlen_zero(profile_name) && (profile = sofia_glue_find_profile(profile_name))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile [%s] Already exists.\n", switch_str_nil(profile_name));
+ status = SWITCH_STATUS_FALSE;
+ sofia_glue_release_profile(profile);
+ return status;
+ }
+
+ switch_snprintf(url, sizeof(url), "profile=%s", switch_str_nil(profile_name));
+
+ if (!(xml = switch_xml_open_cfg(cf, &cfg, url))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
+ status = SWITCH_STATUS_FALSE;
+ goto done;
+ }
+
+ if ((settings = switch_xml_child(cfg, "global_settings"))) {
+ for (param = switch_xml_child(settings, "param"); param; param = param->next) {
+ char *var = (char *) switch_xml_attr_soft(param, "name");
+ char *val = (char *) switch_xml_attr_soft(param, "value");
+ if (!strcasecmp(var, "log-level")) {
+ su_log_set_level(NULL, atoi(val));
+ }
+ }
+ }
+
+ if ((profiles = switch_xml_child(cfg, "profiles"))) {
+ for (xprofile = switch_xml_child(profiles, "profile"); xprofile; xprofile = xprofile->next) {
+ if (!(settings = switch_xml_child(xprofile, "settings"))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Settings, check the new config!\n");
+ } else {
+ char *xprofilename = (char *) switch_xml_attr_soft(xprofile, "name");
+ switch_memory_pool_t *pool = NULL;
+
+ if (!xprofilename) {
+ xprofilename = "unnamed";
+ }
+
+ if (profile_name) {
+ if (strcasecmp(profile_name, xprofilename)) {
+ continue;
+ } else {
+ profile_found = 1;
+ }
+ }
+
+ /* Setup the pool */
+ if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+ goto done;
+ }
+
+ if (!(profile = (sofia_profile_t *) switch_core_alloc(pool, sizeof(*profile)))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
+ goto done;
+ }
+
+ profile->pool = pool;
+ profile->user_agent = SOFIA_USER_AGENT;
+
+ profile->name = switch_core_strdup(profile->pool, xprofilename);
+ switch_snprintf(url, sizeof(url), "sofia_reg_%s", xprofilename);
+
+ profile->dbname = switch_core_strdup(profile->pool, url);
+ switch_core_hash_init(&profile->chat_hash, profile->pool);
+ switch_core_hash_init(&profile->sub_hash, profile->pool);
+ switch_thread_rwlock_create(&profile->rwlock, profile->pool);
+ switch_mutex_init(&profile->flag_mutex, SWITCH_MUTEX_NESTED, profile->pool);
+ profile->dtmf_duration = 100;
+
+ for (param = switch_xml_child(settings, "param"); param; param = param->next) {
+ char *var = (char *) switch_xml_attr_soft(param, "name");
+ char *val = (char *) switch_xml_attr_soft(param, "value");
+
+ if (!strcasecmp(var, "debug")) {
+ profile->debug = atoi(val);
+ } else if (!strcasecmp(var, "use-rtp-timer") && switch_true(val)) {
+ switch_set_flag(profile, TFLAG_TIMER);
+ } else if (!strcasecmp(var, "sip-trace") && switch_true(val)) {
+ switch_set_flag(profile, TFLAG_TPORT_LOG);
+ } else if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) {
+#ifdef SWITCH_HAVE_ODBC
+ profile->odbc_dsn = switch_core_strdup(profile->pool, val);
+ if ((profile->odbc_user = strchr(profile->odbc_dsn, ':'))) {
+ *profile->odbc_user++ = '\0';
+ if ((profile->odbc_pass = strchr(profile->odbc_user, ':'))) {
+ *profile->odbc_pass++ = '\0';
+ }
+ }
+
+#else
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
+#endif
+
+ } else if (!strcasecmp(var, "user-agent-string")) {
+ profile->user_agent = switch_core_strdup(profile->pool, val);;
+ } else if (!strcasecmp(var, "inbound-no-media") && switch_true(val)) {
+ switch_set_flag(profile, TFLAG_INB_NOMEDIA);
+ } else if (!strcasecmp(var, "inbound-late-negotiation") && switch_true(val)) {
+ switch_set_flag(profile, TFLAG_LATE_NEGOTIATION);
+ } else if (!strcasecmp(var, "rfc2833-pt")) {
+ profile->te = (switch_payload_t) atoi(val);
+ } else if (!strcasecmp(var, "cng-pt")) {
+ profile->cng_pt = (switch_payload_t) atoi(val);
+ } else if (!strcasecmp(var, "sip-port")) {
+ profile->sip_port = atoi(val);
+ } else if (!strcasecmp(var, "vad")) {
+ if (!strcasecmp(val, "in")) {
+ switch_set_flag(profile, TFLAG_VAD_IN);
+ } else if (!strcasecmp(val, "out")) {
+ switch_set_flag(profile, TFLAG_VAD_OUT);
+ } else if (!strcasecmp(val, "both")) {
+ switch_set_flag(profile, TFLAG_VAD_IN);
+ switch_set_flag(profile, TFLAG_VAD_OUT);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invald option %s for VAD\n", val);
+ }
+ } else if (!strcasecmp(var, "ext-rtp-ip")) {
+ profile->extrtpip = switch_core_strdup(profile->pool, strcasecmp(val, "auto") ? val : mod_sofia_globals.guess_ip);
+ } else if (!strcasecmp(var, "rtp-ip")) {
+ profile->rtpip = switch_core_strdup(profile->pool, strcasecmp(val, "auto") ? val : mod_sofia_globals.guess_ip);
+ } else if (!strcasecmp(var, "sip-ip")) {
+ profile->sipip = switch_core_strdup(profile->pool, strcasecmp(val, "auto") ? val : mod_sofia_globals.guess_ip);
+ } else if (!strcasecmp(var, "ext-sip-ip")) {
+ if (!strcasecmp(val, "auto")) {
+ profile->extsipip = switch_core_strdup(profile->pool, mod_sofia_globals.guess_ip);
+ } else {
+ char *ip = mod_sofia_globals.guess_ip;
+ switch_port_t port = 0;
+ if (sofia_glue_ext_address_lookup(&ip, &port, val, profile->pool) == SWITCH_STATUS_SUCCESS) {
+
+ if (ip) {
+ profile->extsipip = switch_core_strdup(profile->pool, ip);
+ }
+ }
+ }
+ } else if (!strcasecmp(var, "force-register-domain")) {
+ profile->reg_domain = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "bind-params")) {
+ profile->bind_params = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "sip-domain")) {
+ profile->sipdomain = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "rtp-timer-name")) {
+ profile->timer_name = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "hold-music")) {
+ profile->hold_music = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "session-timeout")) {
+ int v_session_timeout = atoi(val);
+ if (v_session_timeout >= 0) {
+ profile->session_timeout = v_session_timeout;
+ }
+ } else if (!strcasecmp(var, "max-proceeding")) {
+ int v_max_proceeding = atoi(val);
+ if (v_max_proceeding >= 0) {
+ profile->max_proceeding = v_max_proceeding;
+ }
+ } else if (!strcasecmp(var, "rtp-timeout-sec")) {
+ int v = atoi(val);
+ if (v >= 0) {
+ profile->rtp_timeout_sec = v;
+ }
+ } else if (!strcasecmp(var, "manage-presence")) {
+ if (switch_true(val)) {
+ profile->pflags |= PFLAG_PRESENCE;
+ }
+ } else if (!strcasecmp(var, "multiple-registrations")) {
+ if (switch_true(val)) {
+ profile->pflags |= PFLAG_MULTIREG;
+ }
+ } else if (!strcasecmp(var, "supress-cng")) {
+ if (switch_true(val)) {
+ profile->pflags |= PFLAG_SUPRESS_CNG;
+ }
+ } else if (!strcasecmp(var, "NDLB-to-in-200-contact")) {
+ if (switch_true(val)) {
+ profile->ndlb |= PFLAG_NDLB_TO_IN_200_CONTACT;
+ }
+ } else if (!strcasecmp(var, "NDLB-broken-auth-hash")) {
+ if (switch_true(val)) {
+ profile->ndlb |= PFLAG_NDLB_BROKEN_AUTH_HASH;
+ }
+ } else if (!strcasecmp(var, "pass-rfc2833")) {
+ if (switch_true(val)) {
+ profile->pflags |= PFLAG_PASS_RFC2833;
+ }
+ } else if (!strcasecmp(var, "inbound-codec-negotiation")) {
+ if (!strcasecmp(val, "greedy")) {
+ profile->pflags |= PFLAG_GREEDY;
+ }
+ } else if (!strcasecmp(var, "disable-transcoding")) {
+ if (switch_true(val)) {
+ profile->pflags |= PFLAG_DISABLE_TRANSCODING;
+ }
+ } else if (!strcasecmp(var, "rtp-rewrite-timestamps")) {
+ if (switch_true(val)) {
+ profile->pflags |= PFLAG_REWRITE_TIMESTAMPS;
+ }
+ } else if (!strcasecmp(var, "auth-calls")) {
+ if (switch_true(val)) {
+ profile->pflags |= PFLAG_AUTH_CALLS;
+ }
+ } else if (!strcasecmp(var, "nonce-ttl")) {
+ profile->nonce_ttl = atoi(val);
+ } else if (!strcasecmp(var, "accept-blind-reg")) {
+ if (switch_true(val)) {
+ profile->pflags |= PFLAG_BLIND_REG;
+ }
+ } else if (!strcasecmp(var, "auth-all-packets")) {
+ if (switch_true(val)) {
+ profile->pflags |= PFLAG_AUTH_ALL;
+ }
+ } else if (!strcasecmp(var, "full-id-in-dialplan")) {
+ if (switch_true(val)) {
+ profile->pflags |= PFLAG_FULL_ID;
+ }
+ } else if (!strcasecmp(var, "bitpacking")) {
+ if (!strcasecmp(val, "aal2")) {
+ profile->codec_flags = SWITCH_CODEC_FLAG_AAL2;
+ }
+ } else if (!strcasecmp(var, "username")) {
+ profile->username = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "context")) {
+ profile->context = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "alias")) {
+ sip_alias_node_t *node;
+ if ((node = switch_core_alloc(profile->pool, sizeof(*node)))) {
+ if ((node->url = switch_core_strdup(profile->pool, val))) {
+ node->next = profile->aliases;
+ profile->aliases = node;
+ }
+ }
+ } else if (!strcasecmp(var, "dialplan")) {
+ profile->dialplan = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "max-calls")) {
+ profile->max_calls = atoi(val);
+ } else if (!strcasecmp(var, "codec-prefs")) {
+ profile->codec_string = switch_core_strdup(profile->pool, val);
+ } else if (!strcasecmp(var, "dtmf-duration")) {
+ int dur = atoi(val);
+ if (dur > 10 && dur < 8000) {
+ profile->dtmf_duration = dur;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Duration out of bounds!\n");
+ }
+ }
+ }
+
+ if (!profile->cng_pt) {
+ profile->cng_pt = SWITCH_RTP_CNG_PAYLOAD;
+ }
+
+ if (!profile->sipip) {
+ profile->sipip = switch_core_strdup(profile->pool, mod_sofia_globals.guess_ip);
+ }
+
+ if (!profile->rtpip) {
+ profile->rtpip = switch_core_strdup(profile->pool, mod_sofia_globals.guess_ip);
+ }
+
+ if (profile->nonce_ttl < 60) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting nonce TTL to 60 seconds\n");
+ profile->nonce_ttl = 60;
+ }
+
+ if (switch_test_flag(profile, TFLAG_TIMER) && !profile->timer_name) {
+ profile->timer_name = switch_core_strdup(profile->pool, "soft");
+ }
+
+ if (!profile->username) {
+ profile->username = switch_core_strdup(profile->pool, "FreeSWITCH");
+ }
+
+ if (!profile->rtpip) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Setting ip to '127.0.0.1'\n");
+ profile->rtpip = switch_core_strdup(profile->pool, "127.0.0.1");
+ }
+
+ if (!profile->sip_port) {
+ profile->sip_port = atoi(SOFIA_DEFAULT_PORT);
+ }
+
+ if (!profile->dialplan) {
+ profile->dialplan = switch_core_strdup(profile->pool, "XML");
+ }
+
+ if (!profile->sipdomain) {
+ profile->sipdomain = switch_core_strdup(profile->pool, profile->sipip);
+ }
+ if (profile->extsipip) {
+ profile->url = switch_core_sprintf(profile->pool, "sip:mod_sofia@%s:%d", profile->extsipip, profile->sip_port);
+ profile->bindurl = switch_core_sprintf(profile->pool, "%s;maddr=%s", profile->url, profile->sipip);
+ } else {
+ profile->url = switch_core_sprintf(profile->pool, "sip:mod_sofia@%s:%d", profile->sipip, profile->sip_port);
+ profile->bindurl = profile->url;
+ }
+
+ if (profile->bind_params) {
+ char *bindurl = profile->bindurl;
+ profile->bindurl = switch_core_sprintf(profile->pool, "%s;%s", bindurl, profile->bind_params);
+ }
+
+ }
+ if (profile) {
+ switch_xml_t aliases_tag, alias_tag;
+
+ if ((gateways_tag = switch_xml_child(xprofile, "registrations"))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
"The <registrations> syntax has been discontinued, please see the new syntax in the default configuration examples\n");
- } else if ((gateways_tag = switch_xml_child(xprofile, "gateways"))) {
- parse_gateways(profile, gateways_tag);
- }
-
- if ((domains_tag = switch_xml_child(xprofile, "domains"))) {
- for (domain_tag = switch_xml_child(domains_tag, "domain"); domain_tag; domain_tag = domain_tag->next) {
- switch_xml_t droot, actual_domain_tag, ut;
- char *dname = (char *) switch_xml_attr_soft(domain_tag, "name");
- char *parse = (char *) switch_xml_attr_soft(domain_tag, "parse");
-
- if (!switch_strlen_zero(dname)) {
- if (switch_true(parse)) {
- if (switch_xml_locate_domain(dname, NULL, &droot, &actual_domain_tag) == SWITCH_STATUS_SUCCESS) {
- for (ut = switch_xml_child(actual_domain_tag, "user"); ut; ut = ut->next) {
- if (((gateways_tag = switch_xml_child(ut, "gateways")))) {
- parse_gateways(profile, gateways_tag);
- }
- }
- switch_xml_free(droot);
- }
- }
- sofia_glue_add_profile(switch_core_strdup(profile->pool, dname), profile);
- }
- }
- }
-
- if ((aliases_tag = switch_xml_child(xprofile, "aliases"))) {
- for (alias_tag = switch_xml_child(aliases_tag, "alias"); alias_tag; alias_tag = alias_tag->next) {
- char *aname = (char *) switch_xml_attr_soft(alias_tag, "name");
- if (!switch_strlen_zero(aname)) {
-
- if (sofia_glue_add_profile(switch_core_strdup(profile->pool, aname), profile) == SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Alias [%s] for profile [%s]\n", aname, profile->name);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Adding Alias [%s] for profile [%s] (name in use)\n",
+ } else if ((gateways_tag = switch_xml_child(xprofile, "gateways"))) {
+ parse_gateways(profile, gateways_tag);
+ }
+
+ if ((domains_tag = switch_xml_child(xprofile, "domains"))) {
+ for (domain_tag = switch_xml_child(domains_tag, "domain"); domain_tag; domain_tag = domain_tag->next) {
+ switch_xml_t droot, actual_domain_tag, ut;
+ char *dname = (char *) switch_xml_attr_soft(domain_tag, "name");
+ char *parse = (char *) switch_xml_attr_soft(domain_tag, "parse");
+
+ if (!switch_strlen_zero(dname)) {
+ if (switch_true(parse)) {
+ if (switch_xml_locate_domain(dname, NULL, &droot, &actual_domain_tag) == SWITCH_STATUS_SUCCESS) {
+ for (ut = switch_xml_child(actual_domain_tag, "user"); ut; ut = ut->next) {
+ if (((gateways_tag = switch_xml_child(ut, "gateways")))) {
+ parse_gateways(profile, gateways_tag);
+ }
+ }
+ switch_xml_free(droot);
+ }
+ }
+ sofia_glue_add_profile(switch_core_strdup(profile->pool, dname), profile);
+ }
+ }
+ }
+
+ if ((aliases_tag = switch_xml_child(xprofile, "aliases"))) {
+ for (alias_tag = switch_xml_child(aliases_tag, "alias"); alias_tag; alias_tag = alias_tag->next) {
+ char *aname = (char *) switch_xml_attr_soft(alias_tag, "name");
+ if (!switch_strlen_zero(aname)) {
+
+ if (sofia_glue_add_profile(switch_core_strdup(profile->pool, aname), profile) == SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Alias [%s] for profile [%s]\n", aname, profile->name);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Adding Alias [%s] for profile [%s] (name in use)\n",
aname, profile->name);
- }
- }
- }
- }
-
- if (profile->sipip) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Started Profile %s [%s]\n", profile->name, url);
- launch_sofia_profile_thread(profile);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Unable to start Profile %s due to no configured sip-ip\n", profile->name);
- }
- profile = NULL;
- }
- if (profile_found) {
- break;
- }
- }
- }
- done:
- if (xml) {
- switch_xml_free(xml);
- }
-
- if (profile_name && !profile_found) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No Such Profile '%s'\n", profile_name);
- status = SWITCH_STATUS_FALSE;
- }
+ }
+ }
+ }
+ }
- return status;
+ if (profile->sipip) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Started Profile %s [%s]\n", profile->name, url);
+ launch_sofia_profile_thread(profile);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Unable to start Profile %s due to no configured sip-ip\n", profile->name);
+ }
+ profile = NULL;
+ }
+ if (profile_found) {
+ break;
+ }
+ }
+ }
+ done:
+ if (xml) {
+ switch_xml_free(xml);
+ }
+
+ if (profile_name && !profile_found) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No Such Profile '%s'\n", profile_name);
+ status = SWITCH_STATUS_FALSE;
+ }
- }
+ return status;
- static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status,
+}
+
+static void sofia_handle_sip_r_invite(switch_core_session_t *session, 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[])
- {
+{
- if (sip && session && (status == 180 || status == 183 || status == 200)) {
- switch_channel_t *channel = switch_core_session_get_channel(session);
- const char *astate = "early";
- url_t *from = NULL, *to = NULL, *contact = NULL;
-
- if (sip->sip_to) {
- to = sip->sip_to->a_url;
- }
- if (sip->sip_from) {
- from = sip->sip_from->a_url;
- }
- if (sip->sip_contact) {
- contact = sip->sip_contact->m_url;
- }
-
- if (status == 200) {
- astate = "confirmed";
- }
+ if (sip && session && (status == 180 || status == 183 || status == 200)) {
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ const char *astate = "early";
+ url_t *from = NULL, *to = NULL, *contact = NULL;
+
+ if (sip->sip_to) {
+ to = sip->sip_to->a_url;
+ }
+ if (sip->sip_from) {
+ from = sip->sip_from->a_url;
+ }
+ if (sip->sip_contact) {
+ contact = sip->sip_contact->m_url;
+ }
+
+ if (status == 200) {
+ astate = "confirmed";
+ }
- if (!switch_channel_test_flag(channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(channel, CF_ANSWERED) &&
- !switch_channel_test_flag(channel, CF_RING_READY)) {
+ if (!switch_channel_test_flag(channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(channel, CF_ANSWERED) &&
+ !switch_channel_test_flag(channel, CF_RING_READY)) {
const char *from_user = "", *from_host = "", *to_user = "", *to_host = "", *contact_user = "", *contact_host = "";
const char *user_agent = "", *call_id = "";
char *sql = NULL;
1
0
18 Dec '07
Author: brian
Date: Tue Dec 18 10:28:28 2007
New Revision: 6862
Modified:
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
Log:
Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Tue Dec 18 10:28:28 2007
@@ -2145,7 +2145,7 @@
SWITCH_ADD_API(commands_api_interface, "regex", "Eval a regex", regex_function, "<data>|<pattern>[|<subst string>]");
SWITCH_ADD_API(commands_api_interface, "uuid_chat", "Send a chat message", uuid_chat, UUID_CHAT_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "find_user_xml", "find a user", find_user_function, "<key> <user>@<domain>");
- SWITCH_ADD_API(commands_api_interface, "user_exists", "find a user", user_exists_function, "<key> <user>@<domain>");
+ SWITCH_ADD_API(commands_api_interface, "user_exists", "find a user", user_exists_function, "<key> <user> <domain>");
SWITCH_ADD_API(commands_api_interface, "xml_locate", "find some xml", xml_locate_function, "[root | <section> <tag> <tag_attr_name> <tag_attr_val>]");
SWITCH_ADD_API(commands_api_interface, "user_data", "find user data", user_data_function, "<user>@<domain> [var|param] <name>");
1
0
18 Dec '07
Author: brian
Date: Tue Dec 18 09:22:38 2007
New Revision: 6861
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
Log:
small tweak for calling party and hold events..
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Tue Dec 18 09:22:38 2007
@@ -670,7 +670,7 @@
dft_state = "confirmed";
}
- if (!strcasecmp(state, "cs_execute")) {
+ if (!strcasecmp(state, "cs_execute") && !strcasecmp(direction, "inbound") && !strcasecmp(event_status, "hold")) {
goto end;
} else if (!strcasecmp(state, "cs_hangup")) {
astate = "terminated";
1
0