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
January 2008
- 8 participants
- 390 discussions
06 Jan '08
Author: mikej
Date: Sun Jan 6 17:18:47 2008
New Revision: 7111
Modified:
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
Log:
arg checking.
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Sun Jan 6 17:18:47 2008
@@ -3952,8 +3952,8 @@
uint32_t flags = 0;
conference_member_t member = { 0 };
conference_obj_t *conference = NULL;
- switch_channel_t *channel = NULL;
- char *mydata = switch_core_session_strdup(session, data);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ char *mydata = NULL;
char *conf_name = NULL;
char *bridge_prefix = "bridge:";
char *flags_prefix = "+flags{";
@@ -3968,9 +3968,15 @@
conf_xml_cfg_t xml_cfg = { 0 };
char *params = NULL;
- channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
+ if (switch_strlen_zero(data)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Invalid arguments\n");
+ return;
+ }
+
+ mydata = switch_core_session_strdup(session, data);
+
if (!mydata) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
return;
1
0
06 Jan '08
Author: mikej
Date: Sun Jan 6 17:14:10 2008
New Revision: 7110
Modified:
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
Log:
better error checking, code review, cleanup.
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Sun Jan 6 17:14:10 2008
@@ -44,7 +44,7 @@
int argc;
char *lbuf = NULL;
- if (data && (lbuf = switch_core_session_strdup(session, data))
+ if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data))
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
if (!strcasecmp(argv[0], "grammar") && argc >= 1) {
switch_ivr_detect_speech_load_grammar(session, argv[1], argv[2]);
@@ -62,25 +62,18 @@
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", DETECT_SPEECH_SYNTAX);
}
-
}
#define EXE_SYNTAX "<extension> <dialplan> <context>"
SWITCH_STANDARD_APP(exe_function)
{
- char *argv[4];
+ char *argv[4] = { 0 };
int argc;
char *lbuf = NULL;
- char *extension;
- char *context;
- char *dialplan;
- if (data && (lbuf = switch_core_session_strdup(session, data))
+ if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data))
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
- extension = argv[0];
- dialplan = argv[1];
- context = argv[2];
- switch_core_session_execute_exten(session, extension, dialplan, context);
+ switch_core_session_execute_exten(session, argv[0], argv[1], argv[2]);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", EXE_SYNTAX);
}
@@ -92,28 +85,16 @@
switch_ivr_intercept_session(session, data);
}
-
#define eavesdrop_SYNTAX "<uuid>"
SWITCH_STANDARD_APP(eavesdrop_function)
{
- char *argv[4];
- int argc;
- char *lbuf = NULL;
- char *uuid;
-
- if (data && (lbuf = switch_core_session_strdup(session, data))
- && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
- uuid = argv[0];
-
- switch_ivr_eavesdrop_session(session, uuid, ED_DTMF);
-
- } else {
+ if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", eavesdrop_SYNTAX);
+ } else {
+ switch_ivr_eavesdrop_session(session, data, ED_DTMF);
}
}
-
-
#define SET_USER_SYNTAX "<user>@<domain>"
SWITCH_STANDARD_APP(set_user_function)
{
@@ -122,7 +103,7 @@
switch_channel_t *channel;
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_assert(channel != NULL);
if (switch_strlen_zero(data)) {
goto error;
@@ -165,20 +146,16 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No user@domain specified.\n");
done:
-
if (xml) {
switch_xml_free(xml);
}
-
-
}
-
SWITCH_STANDARD_APP(ring_ready_function)
{
switch_channel_t *channel;
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_assert(channel != NULL);
switch_channel_ring_ready(channel);
}
@@ -186,7 +163,7 @@
{
switch_channel_t *channel;
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_assert(channel != NULL);
switch_channel_set_flag(channel, CF_BREAK);
}
@@ -198,11 +175,10 @@
if (!switch_strlen_zero(data)) {
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_assert(channel != NULL);
for (p = (char *)data; p && *p; p++) {
dtmf.digit = *p;
switch_channel_queue_dtmf(channel, &dtmf);
- p++;
}
}
}
@@ -213,7 +189,7 @@
char *argv[4] = { 0 };
char *mydata;
- if (data && (mydata = switch_core_session_strdup(session, data))) {
+ if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) {
if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) {
switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]);
} else {
@@ -228,7 +204,7 @@
char *argv[4] = { 0 };
char *mydata;
- if (data && (mydata = switch_core_session_strdup(session, data))) {
+ if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) {
if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 2) {
time_t when;
@@ -251,7 +227,7 @@
char *argv[5] = { 0 };
char *mydata;
- if (data && (mydata = switch_core_session_strdup(session, data))) {
+ if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) {
if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) {
time_t when;
switch_call_cause_t cause = SWITCH_CAUSE_ALLOTTED_TIMEOUT;
@@ -278,14 +254,13 @@
}
}
-
SWITCH_STANDARD_APP(sched_broadcast_function)
{
int argc;
char *argv[6] = { 0 };
char *mydata;
- if (data && (mydata = switch_core_session_strdup(session, data))) {
+ if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) {
if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 2) {
time_t when;
switch_media_flag_t flags = SMF_NONE;
@@ -317,7 +292,6 @@
SWITCH_STANDARD_APP(sleep_function)
{
-
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No timeout specified.\n");
} else {
@@ -337,7 +311,6 @@
}
switch_ivr_delay_echo(session, len);
-
}
SWITCH_STANDARD_APP(eval_function)
@@ -351,9 +324,9 @@
char *mydata = NULL;
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_assert(channel != NULL);
- if ((mydata = switch_core_session_strdup(session, data))) {
+ if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) {
const char *lang;
char *macro = mydata;
char *mdata = NULL;
@@ -364,23 +337,21 @@
lang = switch_channel_get_variable(channel, "language");
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Execute %s(%s) lang %s\n", macro, mdata, lang);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Execute %s(%s) lang %s\n", macro, switch_str_nil(mdata), switch_str_nil(lang));
switch_ivr_phrase_macro(session, macro, mdata, lang, NULL);
}
-
}
-
SWITCH_STANDARD_APP(hangup_function)
{
switch_channel_t *channel;
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_assert(channel != NULL);
- if (!switch_strlen_zero((char *) data)) {
- cause = switch_channel_str2cause((char *) data);
+ if (!switch_strlen_zero(data)) {
+ cause = switch_channel_str2cause(data);
}
switch_channel_hangup(channel, cause);
@@ -389,18 +360,18 @@
SWITCH_STANDARD_APP(answer_function)
{
switch_channel_t *channel;
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ channel = switch_core_session_get_channel(session);
+ switch_assert(channel != NULL);
switch_channel_answer(channel);
}
SWITCH_STANDARD_APP(pre_answer_function)
{
switch_channel_t *channel;
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ channel = switch_core_session_get_channel(session);
+ switch_assert(channel != NULL);
switch_channel_pre_answer(channel);
}
@@ -413,7 +384,6 @@
msg.string_arg = data;
msg.message_id = SWITCH_MESSAGE_INDICATE_REDIRECT;
switch_core_session_receive_message(session, &msg);
-
}
SWITCH_STANDARD_APP(respond_function)
@@ -425,19 +395,17 @@
msg.string_arg = data;
msg.message_id = SWITCH_MESSAGE_INDICATE_RESPOND;
switch_core_session_receive_message(session, &msg);
-
}
SWITCH_STANDARD_APP(deflect_function)
{
switch_core_session_message_t msg = { 0 };
- /* Tell the channel to respond the call */
+ /* Tell the channel to deflect the call */
msg.from = __FILE__;
msg.string_arg = data;
msg.message_id = SWITCH_MESSAGE_INDICATE_DEFLECT;
switch_core_session_receive_message(session, &msg);
-
}
@@ -447,7 +415,7 @@
char *var, *val = NULL;
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_assert(channel != NULL);
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
@@ -491,7 +459,6 @@
}
}
-
SWITCH_STANDARD_APP(set_profile_var_function)
{
switch_channel_t *channel;
@@ -499,7 +466,7 @@
char *name, *val = NULL;
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_assert(channel != NULL);
caller_profile = switch_channel_get_caller_profile(channel);
@@ -572,7 +539,6 @@
}
}
-
SWITCH_STANDARD_APP(export_function)
{
switch_channel_t *channel;
@@ -581,7 +547,7 @@
int local = 1;
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_assert(channel != NULL);
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
@@ -627,7 +593,7 @@
switch_channel_t *channel;
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_assert(channel != NULL);
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
@@ -643,7 +609,7 @@
char *level, *log_str;
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_assert(channel != NULL);
if (data && (level = strdup(data))) {
switch_log_level_t ltype = SWITCH_LOG_DEBUG;
@@ -663,7 +629,6 @@
}
}
-
SWITCH_STANDARD_APP(info_function)
{
switch_channel_t *channel;
@@ -671,7 +636,7 @@
char *buf;
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_assert(channel != NULL);
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
@@ -681,25 +646,22 @@
switch_event_destroy(&event);
free(buf);
}
-
}
-
-
SWITCH_STANDARD_APP(event_function)
{
switch_channel_t *channel;
switch_event_t *event;
- char *argv[25];
+ char *argv[25] = { 0 };
int argc = 0;
char *lbuf;
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_assert(channel != NULL);
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_APPLICATION) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
- if (data && (lbuf = switch_core_session_strdup(session, data))
+ if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data))
&& (argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) {
int x = 0;
@@ -721,59 +683,52 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, var, "%s", val);
}
}
-
}
}
-
switch_event_fire(&event);
}
-
}
-
SWITCH_STANDARD_APP(privacy_function)
{
switch_channel_t *channel;
switch_caller_profile_t *caller_profile;
- char *arg;
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_assert(channel != NULL);
caller_profile = switch_channel_get_caller_profile(channel);
if (switch_strlen_zero(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No privacy mode specified.\n");
} else {
- arg = switch_core_session_strdup(session, data);
-
switch_set_flag(caller_profile, SWITCH_CPF_SCREEN);
- if (!strcasecmp(arg, "no")) {
+ if (!strcasecmp(data, "no")) {
switch_clear_flag(caller_profile, SWITCH_CPF_HIDE_NAME);
switch_clear_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER);
- } else if (!strcasecmp(arg, "yes")) {
+ } else if (!strcasecmp(data, "yes")) {
switch_set_flag(caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
- } else if (!strcasecmp(arg, "full")) {
+ } else if (!strcasecmp(data, "full")) {
switch_set_flag(caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
- } else if (!strcasecmp(arg, "name")) {
+ } else if (!strcasecmp(data, "name")) {
switch_set_flag(caller_profile, SWITCH_CPF_HIDE_NAME);
- } else if (!strcasecmp(arg, "number")) {
+ } else if (!strcasecmp(data, "number")) {
switch_set_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID privacy mode specified. Use a valid mode [no|yes|name|full|number].\n");
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Privacy to %s [%d]\n", arg, caller_profile->flags);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Privacy to %s [%d]\n", data, caller_profile->flags);
}
}
SWITCH_STANDARD_APP(strftime_function)
{
- char *argv[2];
+ char *argv[2] = { 0 };
int argc;
char *lbuf;
- if (data && (lbuf = switch_core_session_strdup(session, data))
+ if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data))
&& (argc = switch_separate_string(lbuf, '=', argv, (sizeof(argv) / sizeof(argv[0])))) > 1) {
switch_size_t retsize;
switch_time_exp_t tm;
@@ -790,7 +745,6 @@
}
}
-
SWITCH_STANDARD_API(strepoch_api_function)
{
switch_time_t out;
@@ -808,7 +762,6 @@
SWITCH_STANDARD_API(strftime_api_function)
{
-
switch_size_t retsize;
switch_time_exp_t tm;
char date[80] = "";
@@ -834,7 +787,7 @@
int argc = 0;
switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN;
- if (cmd && (lbuf = strdup(cmd))
+ if (!switch_strlen_zero(cmd) && (lbuf = strdup(cmd))
&& (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) > 0) {
if (!strcasecmp(argv[0], "out")) {
type = SWITCH_EVENT_PRESENCE_OUT;
@@ -859,17 +812,15 @@
} else {
stream->write_function(stream, "Invalid");
}
-
return SWITCH_STATUS_SUCCESS;
}
-
SWITCH_STANDARD_API(chat_api_function)
{
char *lbuf, *argv[4];
int argc = 0;
- if (cmd && (lbuf = strdup(cmd))
+ if (!switch_strlen_zero(cmd) && (lbuf = strdup(cmd))
&& (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
switch_chat_interface_t *ci;
@@ -906,7 +857,7 @@
switch_channel_t *channel = switch_core_session_get_channel(session);
char *params,*chanvars;
- if (channel && data && (params = switch_core_session_strdup(session, data))) {
+ if (channel && !switch_strlen_zero(data) && (params = switch_core_session_strdup(session, data))) {
switch_xml_t cxml = NULL, cfg = NULL, xml_menus = NULL, xml_menu = NULL;
// Open the config from the xml registry
@@ -946,13 +897,11 @@
}
}
-
SWITCH_STANDARD_APP(dtmf_session_function)
{
switch_ivr_inband_dtmf_session(session);
}
-
SWITCH_STANDARD_APP(stop_dtmf_session_function)
{
switch_ivr_stop_inband_dtmf_session(session);
@@ -966,12 +915,10 @@
if (!strcasecmp(data, "write")) {
do_read = SWITCH_FALSE;
}
- }
-
+ }
switch_ivr_inband_dtmf_generate_session(session, do_read);
}
-
SWITCH_STANDARD_APP(stop_dtmf_session_generate_function)
{
switch_ivr_stop_inband_dtmf_generate_session(session);
@@ -997,10 +944,16 @@
char *mydata = NULL;
time_t to = 0;
- mydata = switch_core_session_strdup(session, data);
+ if (switch_strlen_zero(data) || !(mydata = switch_core_session_strdup(session, data))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID ARGS!\n");
+ return;
+ }
+
if ((argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0]))) < 2) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID ARGS!\n");
+ return;
}
+
if (argv[3]) {
uint32_t mto;
if (*argv[3] == '+') {
@@ -1036,13 +989,11 @@
SWITCH_STANDARD_APP(park_function)
{
switch_ivr_park(session, NULL);
-
}
SWITCH_STANDARD_APP(park_state_function)
{
switch_ivr_park_session(session);
-
}
/********************************************************************************/
@@ -1055,8 +1006,6 @@
*/
static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
{
-
-
switch (itype) {
case SWITCH_INPUT_TYPE_DTMF:
{
@@ -1065,7 +1014,7 @@
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *p;
- assert(channel);
+ switch_assert(channel);
if (!(terminators = switch_channel_get_variable(channel, SWITCH_PLAYBACK_TERMINATORS_VARIABLE))) {
terminators = "*";
@@ -1096,7 +1045,8 @@
SWITCH_STANDARD_APP(speak_function)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_codec_t *codec = switch_core_session_get_read_codec(session);
char buf[10];
char *argv[4] = { 0 };
int argc;
@@ -1104,19 +1054,22 @@
const char *voice = NULL;
char *text = NULL;
char *mydata = NULL;
- switch_codec_t *codec;
switch_input_args_t args = { 0 };
- codec = switch_core_session_get_read_codec(session);
- assert(codec != NULL);
+ switch_assert(codec != NULL);
+ switch_assert(channel != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ if (switch_strlen_zero(data) || !(mydata = switch_core_session_strdup(session, data))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Params!\n");
+ return;
+ }
- mydata = switch_core_session_strdup(session, data);
argc = switch_separate_string(mydata, '|', argv, sizeof(argv) / sizeof(argv[0]));
- if (argc == 1) {
+ if (argc == 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Params!\n");
+ return;
+ } else if (argc == 1) {
text = argv[0];
} else if (argc == 2) {
voice = argv[0];
@@ -1155,25 +1108,19 @@
args.buf = buf;
args.buflen = sizeof(buf);
switch_ivr_speak_text(session, engine, voice, text, &args);
-
}
SWITCH_STANDARD_APP(playback_function)
{
- switch_channel_t *channel;
- char *file_name = NULL;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_input_args_t args = { 0 };
- file_name = switch_core_session_strdup(session, data);
-
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_assert(channel != NULL);
switch_channel_pre_answer(channel);
args.input_callback = on_dtmf;
- switch_ivr_play_file(session, NULL, file_name, &args);
-
+ switch_ivr_play_file(session, NULL, data, &args);
}
SWITCH_STANDARD_APP(gentones_function)
@@ -1184,10 +1131,15 @@
char *l;
int32_t loops = 0;
+ if (switch_strlen_zero(data) || !(tone_script = switch_core_session_strdup(session, data))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Params!\n");
+ return;
+ }
+
tone_script = switch_core_session_strdup(session, data);
channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_assert(channel != NULL);
switch_channel_pre_answer(channel);
@@ -1202,23 +1154,18 @@
args.input_callback = on_dtmf;
switch_ivr_gentones(session, tone_script, loops, &args);
-
}
SWITCH_STANDARD_APP(displace_session_function)
{
- switch_channel_t *channel;
char *path = NULL;
uint32_t limit = 0;
- char *argv[6];
+ char *argv[6] = { 0 };
int x, argc;
char *lbuf = NULL;
char *flags = NULL;
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
-
- if (data && (lbuf = switch_core_session_strdup(session, data))
+ if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data))
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
path = argv[0];
for(x = 1; x < argc; x++) {
@@ -1232,20 +1179,14 @@
}
}
-
SWITCH_STANDARD_APP(stop_displace_session_function)
{
- switch_channel_t *channel;
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
-
switch_ivr_stop_displace_session(session, data);
}
-
SWITCH_STANDARD_APP(record_function)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status;
uint32_t limit = 0;
char *path;
@@ -1257,10 +1198,9 @@
const char *tmp;
int rate;
- channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
- if (data && (mydata = switch_core_session_strdup(session, data))) {
+ if (!switch_strlen_zero(data) && (mydata = switch_core_session_strdup(session, data))) {
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No file specified.\n");
@@ -1281,7 +1221,6 @@
}
}
}
-
if (argv[2]) {
fh.thresh = atoi(argv[2]);
@@ -1312,15 +1251,13 @@
}
}
-
SWITCH_STANDARD_APP(record_session_function)
{
- switch_channel_t *channel;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
char *p, *path = NULL;
uint32_t limit = 0;
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_assert(channel != NULL);
path = switch_core_session_strdup(session, data);
if ((p = strchr(path, '+'))) {
@@ -1332,17 +1269,11 @@
*p++ = '\0';
limit = atoi(p);
}
-
switch_ivr_record_session(session, path, limit, NULL);
}
-
SWITCH_STANDARD_APP(stop_record_session_function)
{
- switch_channel_t *channel;
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
-
switch_ivr_stop_record_session(session, data);
}
@@ -1352,20 +1283,19 @@
SWITCH_STANDARD_APP(audio_bridge_function)
{
- switch_channel_t *caller_channel;
+ switch_channel_t *caller_channel = switch_core_session_get_channel(session);
switch_core_session_t *peer_session = NULL;
unsigned int timelimit = 60;
const char *var, *continue_on_fail = NULL;
uint8_t no_media_bridge = 0;
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
+ assert(caller_channel != NULL);
+
if (switch_strlen_zero(data)) {
return;
}
- caller_channel = switch_core_session_get_channel(session);
- assert(caller_channel != NULL);
-
if ((var = switch_channel_get_variable(caller_channel, "call_timeout"))) {
timelimit = atoi(var);
}
@@ -1453,8 +1383,6 @@
}
}
-
-
/* fake chan_user */
switch_endpoint_interface_t *user_endpoint_interface;
static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
@@ -1479,6 +1407,10 @@
unsigned int timelimit = 60;
switch_channel_t *new_channel = NULL;
+ if (switch_strlen_zero(outbound_profile->destination_number)) {
+ goto done;
+ }
+
user = switch_core_session_strdup(session, outbound_profile->destination_number);
if (!(domain = strchr(user, '@'))) {
@@ -1501,7 +1433,6 @@
dest = val;
break;
}
-
}
}
@@ -1514,7 +1445,6 @@
dest = val;
break;
}
-
}
}
@@ -1551,7 +1481,6 @@
cp->context = switch_core_strdup(cp->pool, context);
}
}
-
switch_core_session_rwunlock(*new_session);
}
@@ -1576,7 +1505,6 @@
switch_channel_set_variable(new_channel, var, val);
}
}
-
}
if (xml) {
@@ -1585,10 +1513,8 @@
return cause;
-
}
-
#define SPEAK_DESC "Speak text to a channel via the tts interface"
#define DISPLACE_DESC "Displace audio from a file to the channels input"
#define SESS_REC_DESC "Starts a background recording of the entire session"
@@ -1616,8 +1542,7 @@
user_endpoint_interface->interface_name = "USER";
user_endpoint_interface->io_routines = &user_io_routines;
-
- SWITCH_ADD_API(api_interface, "strepoch", "Convert a date string into epoch time", strepoch_api_function, "<string>");
+ SWITCH_ADD_API(api_interface, "strepoch", "Convert a date string into epoch time", strepoch_api_function, "<string>");
SWITCH_ADD_API(api_interface, "chat", "chat", chat_api_function, "<proto>|<from>|<to>|<message>");
SWITCH_ADD_API(api_interface, "strftime", "strftime", strftime_api_function, "<format_string>");
SWITCH_ADD_API(api_interface, "presence", "presence", presence_api_function, "<user> <rpid> <message>");
1
0
[commit] r7109 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua libsofia-sip-ua-glib libsofia-sip-ua/docs libsofia-sip-ua/nta libsofia-sip-ua/nua libsofia-sip-ua/stun libsofia-sip-ua/tport m4 scripts tests
by Freeswitch SVN 06 Jan '08
by Freeswitch SVN 06 Jan '08
06 Jan '08
Author: mikej
Date: Sun Jan 6 15:15:11 2008
New Revision: 7109
Added:
freeswitch/trunk/libs/sofia-sip/scripts/hide_emails.sh
Removed:
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/docs/hide_emails.sh
Modified:
freeswitch/trunk/libs/sofia-sip/.update
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/Makefile.am
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/Makefile.am
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/outbound.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_tag.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c
freeswitch/trunk/libs/sofia-sip/m4/sac-su2.m4
freeswitch/trunk/libs/sofia-sip/tests/check_sofia.c
Log:
Merge current sofia-sip darcs tree:
Thu Dec 13 09:15:04 EST 2007 Pekka.Pessi(a)nokia.com
* libsofia-sip-ua/docs/hide_emails.sh: moved to scripts/ subdir
Thu Dec 13 09:15:34 EST 2007 Pekka.Pessi(a)nokia.com
* check_sofia.c: pass xml result file as optional parameter to check_sofia
Thu Dec 20 08:13:37 EST 2007 Pekka.Pessi(a)nokia.com
* stun.c: try to avoid using stun handle after returning from discovery callback
Crash reported and partial patch by Daniele Rondina.
Thu Jan 3 07:11:27 EST 2008 Pekka.Pessi(a)nokia.com
* tport_type_udp.c: using SO_RCVBUFFORCE and SO_SNDBUFFORCE to set rmem/wmem on udp sockets
Referring reader to Linux sysctls to TPTAG_UDP_RMEM and TPTAG_UDP_WMEM
documentation.
Thu Jan 3 07:11:47 EST 2008 Pekka.Pessi(a)nokia.com
* m4/sac-su2.m4: checks for SO_RCVBUFFORCE and SO_SNDBUFFORCE
Thu Jan 3 08:19:04 EST 2008 Pekka.Pessi(a)nokia.com
* nta.c: calculate next timeout only after completing current timeout
Thanks to Mike Jerris for reporting this problem.
Thu Jan 3 11:02:11 EST 2008 Pekka.Pessi(a)nokia.com
* sac-su2.m4: checking for IP_ADD_MEMBERSHIP and IP_MULTICAST_LOOP
Thu Jan 3 12:08:39 EST 2008 Pekka.Pessi(a)nokia.com
* tport_type_udp.c: when binding to multicast address, join to the group, too.
Use "canonic" IP address (from host-part of the SIP URI) to specify
interface.
Mon Nov 19 15:01:09 EST 2007 Pekka Pessi <first.lastname(a)nokia.com>
* tport_type_udp.c: made IP_ADD_MEMBERSHIP as portable
Fri Jan 4 13:19:01 EST 2008 Pekka.Pessi(a)nokia.com
* test_nta.c: added check for request merging (with both 3261 and 2543 proxies)
Fri Jan 4 13:20:35 EST 2008 Pekka.Pessi(a)nokia.com
* nta.c: fixed request merging with RFC 2543 proxies
Updated matching of PRACKs with outstanding 100rel, too.
Fri Jan 4 15:27:01 EST 2008 Pekka.Pessi(a)nokia.com
* nta.c: follow more closely RFC 3261 request matching rules
Fri Jan 4 15:31:22 EST 2008 Pekka.Pessi(a)nokia.com
* nua_session.c: do not clear soa when an overlapping INVITE is received
Fri Jan 4 15:32:58 EST 2008 Pekka.Pessi(a)nokia.com
* nua/outbound.c: reduce logging
Fri Jan 4 16:51:00 EST 2008 Pekka.Pessi(a)nokia.com
* nua_subnotref.c: accept NOTIFY without Event header
Fri Jan 4 16:53:20 EST 2008 Pekka.Pessi(a)nokia.com
* nua_notifier.c: fix problem handing expiration time if NOTIFY is sent before SUBSCRIBE has been responded
Fri Jan 4 16:54:08 EST 2008 Pekka.Pessi(a)nokia.com
* nua_notifier.c: allow notifier handle to be shut down if SUBSCRIBE has been accpeted but no NOTIFY has been sent
Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update (original)
+++ freeswitch/trunk/libs/sofia-sip/.update Sun Jan 6 15:15:11 2008
@@ -1 +1 @@
-Thu Oct 11 15:56:47 EDT 2007
+Sun Jan 6 15:11:42 EST 2008
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/Makefile.am (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua-glib/Makefile.am Sun Jan 6 15:15:11 2008
@@ -40,7 +40,7 @@
&& ${DOXYGEN} \
&& popd > /dev/null ; \
done
- ${top_srcdir}/libsofia-sip-ua/docs/hide_emails.sh docs/html
+ ${top_srcdir}/scripts/hide_emails.sh docs/html
PHONY = doxygen
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/Makefile.am (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/Makefile.am Sun Jan 6 15:15:11 2008
@@ -101,7 +101,7 @@
docs/$$d.doxytags > docs/$$d.doxytags.tmp && \
mv -f docs/$$d.doxytags.tmp docs/$$d.doxytags ; \
done
- ${srcdir}/docs/hide_emails.sh docs/html
+ ${top_srcdir}/scripts/hide_emails.sh docs/html
if HAVE_LCOV
include $(top_srcdir)/rules/lcov.am
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Sun Jan 6 15:15:11 2008
@@ -202,11 +202,12 @@
incoming_queue_t *queue,
unsigned timeout);
-su_inline
-nta_incoming_t *incoming_find(nta_agent_t const *agent, sip_t const *sip,
- sip_via_t const *v,
- nta_incoming_t **merge,
- nta_incoming_t **ack);
+static nta_incoming_t *incoming_find(nta_agent_t const *agent,
+ sip_t const *sip,
+ sip_via_t const *v,
+ nta_incoming_t **merge,
+ nta_incoming_t **ack,
+ nta_incoming_t **cancel);
static int incoming_reply(nta_incoming_t *irq, msg_t *msg, sip_t *sip);
su_inline int incoming_recv(nta_incoming_t *irq, msg_t *msg, sip_t *sip,
tport_t *tport);
@@ -214,10 +215,11 @@
tport_t *tport);
su_inline int incoming_cancel(nta_incoming_t *irq, msg_t *msg, sip_t *sip,
tport_t *tport);
-su_inline int incoming_merge(nta_incoming_t *irq, msg_t *msg, sip_t *sip,
- tport_t *tport);
+static void request_merge(nta_agent_t *,
+ msg_t *msg, sip_t *sip, tport_t *tport,
+ char const *to_tag);
su_inline int incoming_timestamp(nta_incoming_t *, msg_t *, sip_t *);
-su_inline su_duration_t incoming_timer(nta_agent_t *, su_duration_t);
+static void incoming_timer(nta_agent_t *);
static nta_reliable_t *reliable_mreply(nta_incoming_t *,
nta_prack_f *, nta_reliable_magic_t *,
@@ -225,7 +227,8 @@
static int reliable_send(nta_incoming_t *, nta_reliable_t *, msg_t *, sip_t *);
static int reliable_final(nta_incoming_t *irq, msg_t *msg, sip_t *sip);
static msg_t *reliable_response(nta_incoming_t *irq);
-static int reliable_recv(nta_incoming_t *, msg_t *, sip_t *, tport_t *);
+static nta_reliable_t *reliable_find(nta_agent_t const *, sip_t const *);
+static int reliable_recv(nta_reliable_t *rel, msg_t *, sip_t *, tport_t *);
static void reliable_flush(nta_incoming_t *irq);
static void reliable_timeout(nta_incoming_t *irq, int timeout);
@@ -251,7 +254,7 @@
sip_via_t const *v);
static int outgoing_recv(nta_outgoing_t *orq, int status, msg_t *, sip_t *);
static void outgoing_default_recv(nta_outgoing_t *, int, msg_t *, sip_t *);
-su_inline su_duration_t outgoing_timer(nta_agent_t *, su_duration_t);
+static void outgoing_timer(nta_agent_t *);
static int outgoing_recv_reliable(nta_outgoing_t *orq, msg_t *msg, sip_t *sip);
/* Internal message passing */
@@ -725,9 +728,6 @@
return -(agent->sa_timer == NULL);
}
-#define NEXT_TIMEOUT(next, p, f, now) \
- (p && p->f - (next) < 0 ? (p->f - (now) > 0 ? p->f : (now)) : (next))
-
/**
* Agent timer routine.
*/
@@ -739,20 +739,43 @@
now += now == 0;
+ agent->sa_next = 0;
+
agent->sa_now = stamp;
agent->sa_millisec = now;
- agent->sa_next = 0;
agent->sa_in_timer = 1;
- next = now + SU_DURATION_MAX;
- next = outgoing_timer(agent, next);
- next = incoming_timer(agent, next);
+ outgoing_timer(agent);
+ incoming_timer(agent);
+ /* agent->sa_now is used only if sa_millisec != 0 */
agent->sa_millisec = 0;
agent->sa_in_timer = 0;
+ /* Calculate next timeout */
+ next = now + SU_DURATION_MAX;
+
+#define NEXT_TIMEOUT(next, p, f, now) \
+ (void)(p && p->f - (next) < 0 && ((next) = (p->f - (now) > 0 ? p->f : (now))))
+
+ NEXT_TIMEOUT(next, agent->sa_out.re_list, orq_retry, now);
+ NEXT_TIMEOUT(next, agent->sa_out.inv_completed->q_head, orq_timeout, now);
+ NEXT_TIMEOUT(next, agent->sa_out.completed->q_head, orq_timeout, now);
+ NEXT_TIMEOUT(next, agent->sa_out.inv_calling->q_head, orq_timeout, now);
+ if (agent->sa_out.inv_proceeding->q_timeout)
+ NEXT_TIMEOUT(next, agent->sa_out.inv_proceeding->q_head, orq_timeout, now);
+ NEXT_TIMEOUT(next, agent->sa_out.trying->q_head, orq_timeout, now);
+
+ NEXT_TIMEOUT(next, agent->sa_in.preliminary->q_head, irq_timeout, now);
+ NEXT_TIMEOUT(next, agent->sa_in.inv_completed->q_head, irq_timeout, now);
+ NEXT_TIMEOUT(next, agent->sa_in.inv_confirmed->q_head, irq_timeout, now);
+ NEXT_TIMEOUT(next, agent->sa_in.completed->q_head, irq_timeout, now);
+ NEXT_TIMEOUT(next, agent->sa_in.re_list, irq_retry, now);
+
if (agent->sa_next)
- next = NEXT_TIMEOUT(next, agent, sa_next, now);
+ NEXT_TIMEOUT(next, agent, sa_next, now);
+
+#undef NEXT_TIMEOUT
if (next == now + SU_DURATION_MAX) {
/* Do not set timer */
@@ -2199,7 +2222,7 @@
tport_t *tport)
{
nta_leg_t *leg;
- nta_incoming_t *irq, *merge = NULL, *ack = NULL;
+ nta_incoming_t *irq, *merge = NULL, *ack = NULL, *cancel = NULL;
sip_method_t method = sip->sip_request->rq_method;
char const *method_name = sip->sip_request->rq_method_name;
url_t url[1];
@@ -2337,7 +2360,15 @@
}
/* First, try existing incoming requests */
- irq = incoming_find(agent, sip, sip->sip_via, &merge, &ack);
+ irq = incoming_find(agent, sip, sip->sip_via,
+ agent->sa_merge_482 &&
+ !sip->sip_to->a_tag &&
+ method != sip_method_ack
+ ? &merge
+ : NULL,
+ method == sip_method_ack ? &ack : NULL,
+ method == sip_method_cancel ? &cancel : NULL);
+
if (irq) {
/* Match - this is a retransmission */
SU_DEBUG_5(("nta: %s (%u) going to existing %s transaction\n",
@@ -2346,31 +2377,36 @@
return;
}
else if (ack) {
- /* Match - this is an ACK or CANCEL or PRACK */
SU_DEBUG_5(("nta: %s (%u) is going to %s (%u)\n",
method_name, cseq,
- ack->irq_rq->rq_method_name, ack->irq_cseq->cs_seq));
- if (method == sip_method_ack) {
- if (incoming_ack(ack, msg, sip, tport) >= 0)
- return;
- }
- else if (method == sip_method_cancel) {
- if (incoming_cancel(ack, msg, sip, tport) >= 0)
- return;
- }
- else if (method == sip_method_prack) {
- if (reliable_recv(ack, msg, sip, tport) >= 0)
- return;
- }
- else {
- assert(!method);
- }
+ ack->irq_cseq->cs_method_name, ack->irq_cseq->cs_seq));
+ if (incoming_ack(ack, msg, sip, tport) >= 0)
+ return;
+ }
+ else if (cancel) {
+ SU_DEBUG_5(("nta: %s (%u) is going to %s (%u)\n",
+ method_name, cseq,
+ cancel->irq_cseq->cs_method_name, cancel->irq_cseq->cs_seq));
+ if (incoming_cancel(cancel, msg, sip, tport) >= 0)
+ return;
}
else if (merge) {
SU_DEBUG_5(("nta: %s (%u) %s\n",
method_name, cseq, "is a merged request"));
- if (incoming_merge(merge, msg, sip, tport) >= 0)
+ request_merge(agent, msg, sip, tport, merge->irq_tag);
+ return;
+ }
+
+ if (method == sip_method_prack && sip->sip_rack) {
+ nta_reliable_t *rel = reliable_find(agent, sip);
+ if (rel) {
+ SU_DEBUG_5(("nta: %s (%u) is going to %s (%u)\n",
+ method_name, cseq,
+ rel->rel_irq->irq_cseq->cs_method_name,
+ rel->rel_irq->irq_cseq->cs_seq));
+ reliable_recv(rel, msg, sip, tport);
return;
+ }
}
*url = *sip->sip_request->rq_url;
@@ -5176,48 +5212,41 @@
sip_via_t const *v)
{
if (agent && sip && v)
- return incoming_find(agent, sip, v, NULL, NULL);
+ return incoming_find(agent, sip, v, NULL, NULL, NULL);
else
return NULL;
}
-su_inline
-int addr_match(sip_addr_t const *a, char const *a_tag, sip_addr_t const *b)
-{
- if (a_tag && b->a_tag)
- return strcasecmp(a_tag, b->a_tag) == 0;
- else if (a->a_tag && b->a_tag)
- return strcasecmp(a->a_tag, b->a_tag) == 0;
- else
- return
- str0casecmp(a->a_host, b->a_host) == 0 &&
- str0cmp(a->a_user, b->a_user) == 0;
-}
-
/** Find a matching server transaction object.
*
- *
+ * Check also for requests to merge, to ACK, or to CANCEL.
*/
-su_inline
-nta_incoming_t *incoming_find(nta_agent_t const *agent,
- sip_t const *sip,
- sip_via_t const *v,
- nta_incoming_t **return_merge,
- nta_incoming_t **return_ack)
+static nta_incoming_t *incoming_find(nta_agent_t const *agent,
+ sip_t const *sip,
+ sip_via_t const *v,
+ nta_incoming_t **return_merge,
+ nta_incoming_t **return_ack,
+ nta_incoming_t **return_cancel)
{
sip_cseq_t const *cseq = sip->sip_cseq;
sip_call_id_t const *i = sip->sip_call_id;
sip_to_t const *to = sip->sip_to;
sip_from_t const *from = sip->sip_from;
sip_request_t *rq = sip->sip_request;
- int is_uas_ack = return_ack &&
- agent->sa_is_a_uas && rq->rq_method == sip_method_ack;
incoming_htable_t const *iht = agent->sa_incoming;
hash_value_t hash = NTA_HASH(i, cseq->cs_seq);
+ char const *magic_branch;
+
+ nta_incoming_t **ii, *irq;
- nta_incoming_t **ii, *irq, *maybe;
+ int is_uas_ack = return_ack && agent->sa_is_a_uas;
- for (ii = incoming_htable_hash(iht, hash), maybe = NULL;
+ if (v->v_branch && strncasecmp(v->v_branch, "z9hG4bK", 7) == 0)
+ magic_branch = v->v_branch + 7;
+ else
+ magic_branch = NULL;
+
+ for (ii = incoming_htable_hash(iht, hash);
(irq = *ii);
ii = incoming_htable_next(iht, ii)) {
if (hash != irq->irq_hash ||
@@ -5229,96 +5258,84 @@
if (str0casecmp(irq->irq_from->a_tag, from->a_tag))
continue;
- if (str0casecmp(irq->irq_via->v_branch, v->v_branch) != 0 ||
- strcasecmp(irq->irq_via->v_host, v->v_host) != 0) {
- if (!agent->sa_is_a_uas)
- continue;
-
- if (is_uas_ack &&
- irq->irq_method == sip_method_invite &&
- 200 <= irq->irq_status && irq->irq_status < 300 &&
- addr_match(irq->irq_to, irq->irq_tag, to))
- *return_ack = irq;
- /* RFC3261 - section 8.2.2.2 Merged Requests */
- else if (return_merge && agent->sa_merge_482 &&
- irq->irq_cseq->cs_method == cseq->cs_method &&
- (irq->irq_cseq->cs_method != sip_method_unknown ||
- strcmp(irq->irq_cseq->cs_method_name,
- cseq->cs_method_name) == 0)) {
- *return_merge = irq;
- continue;
- }
- else
- continue;
- }
-
- if (is_uas_ack) {
- if (!addr_match(irq->irq_to, irq->irq_tag, to))
- continue;
- }
- else if (irq->irq_tag_set || !irq->irq_tag) {
- if (str0casecmp(irq->irq_to->a_host, to->a_host) != 0 ||
- str0cmp(irq->irq_to->a_user, to->a_user) != 0)
- continue;
+ if (is_uas_ack &&
+ irq->irq_method == sip_method_invite &&
+ 200 <= irq->irq_status && irq->irq_status < 300 &&
+ str0casecmp(irq->irq_tag, to->a_tag) == 0) {
+ *return_ack = irq;
+ return NULL;
}
- else if (str0casecmp(irq->irq_to->a_tag, to->a_tag))
- continue;
-
- if (!is_uas_ack && url_cmp(irq->irq_rq->rq_url, rq->rq_url))
- continue;
-
-#if 0
- if (irq->irq_terminated)
- continue;
-#endif
- if (irq->irq_method == rq->rq_method)
- break; /* found */
-
- if (!return_ack)
- continue;
+ if (magic_branch) {
+ /* RFC3261 17.2.3:
+ *
+ * The request matches a transaction if branch and sent-by in topmost
+ * the method of the request matches the one that created the
+ * transaction, except for ACK, where the method of the request
+ * that created the transaction is INVITE.
+ */
- if (irq->irq_method == sip_method_invite) {
- if (rq->rq_method == sip_method_cancel)
- *return_ack = irq;
- else if (rq->rq_method == sip_method_ack)
- *return_ack = irq;
+ if (irq->irq_via->v_branch &&
+ strcasecmp(irq->irq_via->v_branch + 7, magic_branch) == 0 &&
+ strcasecmp(irq->irq_via->v_host, v->v_host) == 0 &&
+ str0cmp(irq->irq_via->v_port, v->v_port) == 0) {
+ if (irq->irq_method == cseq->cs_method &&
+ strcmp(irq->irq_cseq->cs_method_name,
+ cseq->cs_method_name) == 0)
+ return irq;
+ if (return_ack && irq->irq_method == sip_method_invite)
+ return *return_ack = irq, NULL;
+ if (return_cancel && irq->irq_method != sip_method_ack)
+ return *return_cancel = irq, NULL;
+ }
}
- else if (rq->rq_method == sip_method_cancel && !irq->irq_terminated)
- *return_ack = irq;
- }
-
- if (irq)
- return irq;
+ else {
+ /* No magic branch */
- /* Check PRACKed requests */
- if (return_ack && rq->rq_method == sip_method_prack && sip->sip_rack) {
- sip_rack_t const *rack = sip->sip_rack;
- hash = NTA_HASH(i, rack->ra_cseq);
-
- for (ii = incoming_htable_hash(iht, hash);
- (irq = *ii);
- ii = incoming_htable_next(iht, ii)) {
- if (hash != irq->irq_hash)
- continue;
- if (irq->irq_call_id->i_hash != i->i_hash)
- continue;
- if (strcmp(irq->irq_call_id->i_id, i->i_id))
- continue;
- if (irq->irq_cseq->cs_seq != rack->ra_cseq)
- continue;
- if (!addr_match(irq->irq_to, NULL, to) ||
- !addr_match(irq->irq_from, NULL, from))
- continue;
- if (!irq->irq_from->a_tag != !from->a_tag)
- continue;
- *return_ack = irq;
+ /* INVITE request matches a transaction if
+ the Request-URI, To tag, From tag, Call-ID, CSeq, and
+ top Via header match */
+
+ /* From tag, Call-ID, and CSeq number has been matched above */
+
+ /* Match To tag */
+ if (str0casecmp(irq->irq_to->a_tag, to->a_tag) &&
+ /* Ignore failing match if tag has been set */
+ /* and retransmitted request had no to tag */
+ !(irq->irq_tag_set && to->a_tag == NULL))
+ ;
+ /* Match top Via header field */
+ else if (str0casecmp(irq->irq_via->v_branch, v->v_branch) == 0 &&
+ strcasecmp(irq->irq_via->v_host, v->v_host) == 0 &&
+ str0cmp(irq->irq_via->v_port, v->v_port) == 0)
+ ;
+ /* Match Request-URI */
+ else if (url_cmp(irq->irq_rq->rq_url, rq->rq_url))
+ ;
+ else {
+ /* Match CSeq */
+ if (irq->irq_method == cseq->cs_method &&
+ strcmp(irq->irq_cseq->cs_method_name,
+ cseq->cs_method_name) == 0)
+ return irq; /* found */
+
+ if (return_ack && irq->irq_method == sip_method_invite)
+ *return_ack = irq;
+ else if (return_cancel && irq->irq_method != sip_method_ack)
+ *return_cancel = irq;
+ }
+ }
- return NULL;
+ /* RFC3261 - section 8.2.2.2 Merged Requests */
+ if (return_merge) {
+ if (irq->irq_cseq->cs_method == cseq->cs_method &&
+ strcmp(irq->irq_cseq->cs_method_name,
+ cseq->cs_method_name) == 0)
+ *return_merge = irq, return_merge = NULL;
}
}
- return irq;
+ return NULL;
}
/** Process retransmitted requests. */
@@ -5397,23 +5414,26 @@
return 0;
}
+/** Respond to the CANCEL. */
su_inline
int incoming_cancel(nta_incoming_t *irq, msg_t *msg, sip_t *sip,
tport_t *tport)
{
nta_agent_t *agent = irq->irq_agent;
- /* Respond to the CANCEL */
-
- if (200 <= irq->irq_status && irq->irq_status < 300) {
- nta_msg_treply(agent, msg_ref_create(msg), SIP_481_NO_TRANSACTION,
+ /* According to the spec, this INVITE has been destroyed */
+ if (irq->irq_method == sip_method_invite &&
+ 200 <= irq->irq_status && irq->irq_status < 300) {
+ nta_msg_treply(agent, msg, SIP_481_NO_TRANSACTION,
NTATAG_TPORT(tport),
TAG_END());
+ return 0;
}
- else
- nta_msg_treply(agent, msg_ref_create(msg), SIP_200_OK,
- NTATAG_TPORT(tport),
- TAG_END());
+
+ nta_msg_treply(agent, msg_ref_create(msg), SIP_200_OK,
+ NTATAG_TPORT(tport),
+ SIPTAG_TO(irq->irq_to),
+ TAG_END());
/* We have already sent final response */
if (irq->irq_completed || irq->irq_method != sip_method_invite) {
@@ -5436,29 +5456,28 @@
return 0;
}
-/** Process merged requests */
-su_inline
-int incoming_merge(nta_incoming_t *irq, msg_t *msg, sip_t *sip, tport_t *tport)
+/** Merge request */
+static
+void request_merge(nta_agent_t *agent,
+ msg_t *msg, sip_t *sip, tport_t *tport,
+ char const *to_tag)
{
- nta_agent_t *agent = irq->irq_agent;
+ nta_incoming_t *irq;
agent->sa_stats->as_merged_request++;
- irq = incoming_create(irq->irq_agent, msg, sip, tport, irq->irq_tag);
+ irq = incoming_create(agent, msg, sip, tport, to_tag);
- if (!irq) {
- SU_DEBUG_3(("nta: incoming_merge(): cannot create transaction for %s\n",
+ if (irq) {
+ nta_incoming_treply(irq, 482, "Request merged", TAG_END());
+ nta_incoming_destroy(irq);
+ } else {
+ SU_DEBUG_3(("nta: request_merge(): cannot create transaction for %s\n",
sip->sip_request->rq_method_name));
nta_msg_treply(agent, msg, 482, "Request merged",
NTATAG_TPORT(tport),
TAG_END());
- return 0;
}
-
- nta_incoming_treply(irq, 482, "Request merged", TAG_END());
- nta_incoming_destroy(irq);
-
- return 0;
}
/**@typedef nta_ack_cancel_f
@@ -6097,8 +6116,7 @@
};
/** @internal Timer routine for the incoming request. */
-su_inline
-su_duration_t incoming_timer(nta_agent_t *sa, su_duration_t next)
+static void incoming_timer(nta_agent_t *sa)
{
su_duration_t now = sa->sa_millisec;
nta_incoming_t *irq, *irq_next;
@@ -6166,8 +6184,6 @@
}
}
- next = NEXT_TIMEOUT(next, irq, irq_retry, now);
-
while ((irq = sa->sa_in.final_failed->q_head)) {
incoming_remove(irq);
irq->irq_final_failed = 0;
@@ -6215,8 +6231,6 @@
reliable_timeout(irq, 1);
}
- next = NEXT_TIMEOUT(next, irq, irq_timeout, now);
-
while ((irq = sa->sa_in.inv_completed->q_head)) {
assert(irq->irq_status >= 200);
assert(irq->irq_timeout);
@@ -6245,8 +6259,6 @@
}
}
- next = NEXT_TIMEOUT(next, irq, irq_timeout, now);
-
while ((irq = sa->sa_in.inv_confirmed->q_head)) {
assert(irq->irq_timeout);
assert(irq->irq_status >= 200);
@@ -6268,8 +6280,6 @@
incoming_free_queue(rq, irq);
}
- next = NEXT_TIMEOUT(next, irq, irq_timeout, now);
-
while ((irq = sa->sa_in.completed->q_head)) {
assert(irq->irq_status >= 200);
assert(irq->irq_timeout);
@@ -6292,8 +6302,6 @@
incoming_free_queue(rq, irq);
}
- next = NEXT_TIMEOUT(next, irq, irq_timeout, now);
-
for (irq = sa->sa_in.terminated->q_head; irq; irq = irq_next) {
irq_next = irq->irq_next;
if (irq->irq_destroyed)
@@ -6312,8 +6320,6 @@
timeout, unconfirmed,
terminated, unterminated,
destroyed, total));
-
- return next;
}
/** Mass destroy server transactions */
@@ -7864,8 +7870,7 @@
/** @internal Outgoing transaction timer routine.
*
*/
-su_inline
-su_duration_t outgoing_timer(nta_agent_t *sa, su_duration_t next)
+static void outgoing_timer(nta_agent_t *sa)
{
su_duration_t now = sa->sa_millisec;
nta_outgoing_t *orq;
@@ -7877,7 +7882,6 @@
sa->sa_out.inv_calling->q_length;
size_t completed = sa->sa_out.completed->q_length +
sa->sa_out.inv_completed->q_length;
- outgoing_queue_t *proceeding = sa->sa_out.inv_proceeding;
outgoing_queue_init(sa->sa_out.free = rq, 0);
@@ -7920,25 +7924,15 @@
su_root_yield(sa->sa_root); /* Handle received packets */
}
- next = NEXT_TIMEOUT(next, orq, orq_retry, now);
-
terminated
= outgoing_timer_dk(sa->sa_out.inv_completed, "D", now)
+ outgoing_timer_dk(sa->sa_out.completed, "K", now);
- next = NEXT_TIMEOUT(next, sa->sa_out.inv_completed->q_head, orq_timeout, now);
- next = NEXT_TIMEOUT(next, sa->sa_out.completed->q_head, orq_timeout, now);
-
timeout
= outgoing_timer_bf(sa->sa_out.inv_calling, "B", now)
- + outgoing_timer_c(proceeding, "C", now)
+ + outgoing_timer_c(sa->sa_out.inv_proceeding, "C", now)
+ outgoing_timer_bf(sa->sa_out.trying, "F", now);
- next = NEXT_TIMEOUT(next, sa->sa_out.inv_calling->q_head, orq_timeout, now);
- if (proceeding->q_timeout)
- next = NEXT_TIMEOUT(next, proceeding->q_head, orq_timeout, now);
- next = NEXT_TIMEOUT(next, sa->sa_out.trying->q_head, orq_timeout, now);
-
destroyed = outgoing_mass_destroy(sa, rq);
sa->sa_out.free = NULL;
@@ -7954,8 +7948,6 @@
terminated, completed,
destroyed, total));
}
-
- return next;
}
/** @internal Retransmit the outgoing request. */
@@ -8246,13 +8238,8 @@
continue;
if (str0casecmp(orq->orq_from->a_tag, sip->sip_from->a_tag))
continue;
- if (!addr_match(orq->orq_to, NULL, sip->sip_to))
- continue;
- if (orq->orq_method == method ?
- /* Don't match if request To has a tag and response has no To tag */
- orq->orq_to->a_tag && !sip->sip_to->a_tag :
- /* Don't (with ACK) if request/response tag mismatch */
- !orq->orq_to->a_tag != !sip->sip_to->a_tag)
+ if (orq->orq_to->a_tag &&
+ str0casecmp(orq->orq_to->a_tag, sip->sip_to->a_tag))
continue;
if (orq->orq_method == sip_method_ack) {
@@ -9851,7 +9838,7 @@
nta_agent_t *agent;
agent = irq->irq_agent;
-
+
if (callback == NULL)
callback = nta_reliable_destroyed;
@@ -9976,24 +9963,54 @@
return rel->rel_unsent;
}
+/* Find un-PRACKed responses */
+static
+nta_reliable_t *reliable_find(nta_agent_t const *agent,
+ sip_t const *sip)
+{
+ incoming_htable_t const *iht = agent->sa_incoming;
+ nta_incoming_t *irq, **ii;
+ sip_call_id_t const *i = sip->sip_call_id;
+ sip_rack_t const *rack = sip->sip_rack;
+ hash_value_t hash = NTA_HASH(i, rack->ra_cseq);
+
+ /* XXX - add own hash table for 100rel */
+
+ for (ii = incoming_htable_hash(iht, hash);
+ (irq = *ii);
+ ii = incoming_htable_next(iht, ii)) {
+
+ if (hash == irq->irq_hash &&
+ irq->irq_call_id->i_hash == i->i_hash &&
+ irq->irq_cseq->cs_seq == rack->ra_cseq &&
+ irq->irq_method == sip_method_invite &&
+ strcmp(irq->irq_call_id->i_id, i->i_id) == 0 &&
+ (irq->irq_to->a_tag == NULL ||
+ str0casecmp(irq->irq_to->a_tag, sip->sip_to->a_tag) == 0) &&
+ str0casecmp(irq->irq_from->a_tag, sip->sip_from->a_tag) == 0) {
+
+ nta_reliable_t const *rel;
+
+ /* Found matching INVITE */
+ for (rel = irq->irq_reliable; rel; rel = rel->rel_next)
+ if (rel->rel_rseq == rack->ra_response)
+ return (nta_reliable_t *)rel;
+
+ return NULL;
+ }
+ }
+
+ return NULL;
+}
+
/** Process incoming PRACK with matching @RAck field */
static
-int reliable_recv(nta_incoming_t *irq, msg_t *msg, sip_t *sip, tport_t *tp)
+int reliable_recv(nta_reliable_t *rel, msg_t *msg, sip_t *sip, tport_t *tp)
{
- sip_rack_t *rack = sip->sip_rack;
- nta_reliable_t *rel;
+ nta_incoming_t *irq = rel->rel_irq;
nta_incoming_t *pr_irq;
int status;
- for (rel = irq->irq_reliable; rel; rel = rel->rel_next)
- if (rel->rel_pracked)
- return -1;
- else if (rel->rel_rseq == rack->ra_response)
- break;
-
- if (!rel)
- return -1; /* Process normally */
-
rel->rel_pracked = 1;
msg_ref_destroy(rel->rel_unsent), rel->rel_unsent = NULL;
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c Sun Jan 6 15:15:11 2008
@@ -176,10 +176,13 @@
msg_t *ag_probe_msg;
+ su_sockaddr_t ag_su_nta[1];
+ socklen_t ag_su_nta_len;
/* Dummy servers */
char const *ag_sink_port;
su_socket_t ag_sink_socket, ag_down_socket;
+ su_wait_t ag_sink_wait[1];
};
static int test_init(agent_t *ag, char const *resolv_conf);
@@ -558,8 +561,11 @@
TEST_1(bind(s, &su.su_sa, sulen) < 0 ? (perror("bind"), 0) : 1);
TEST_1(getsockname(s, &su.su_sa, &sulen) == 0);
- ag->ag_sink_port = su_sprintf(ag->ag_home, "%u", ntohs(su.su_sin.sin_port));
ag->ag_sink_socket = s;
+ su_wait_init(ag->ag_sink_wait);
+ su_wait_create(ag->ag_sink_wait, ag->ag_sink_socket, SU_WAIT_IN);
+
+ ag->ag_sink_port = su_sprintf(ag->ag_home, "%u", ntohs(su.su_sin.sin_port));
/* Down server */
s = su_socket(af, SOCK_STREAM, 0); TEST_1(s != INVALID_SOCKET);
@@ -591,13 +597,38 @@
sip_to_t to[1];
sip_contact_t m[1];
+ su_sockaddr_t *su = ag->ag_su_nta;
+
sip_from_init(from);
sip_to_init(to);
sip_contact_init(m);
+
TEST_1(ag->ag_contact = nta_agent_contact(ag->ag_agent));
*m->m_url = *ag->ag_contact->m_url;
+
+ if (host_is_ip4_address(m->m_url->url_host)) {
+ inet_pton(su->su_family = AF_INET,
+ m->m_url->url_host,
+ &su->su_sin.sin_addr);
+ ag->ag_su_nta_len = (sizeof su->su_sin);
+ }
+ else {
+ TEST_1(host_is_ip_address(m->m_url->url_host));
+ inet_pton(su->su_family = AF_INET6,
+ m->m_url->url_host,
+ &su->su_sin6.sin6_addr);
+ ag->ag_su_nta_len = (sizeof su->su_sin6);
+ }
+
+ su->su_port = htons(5060);
+ if (m->m_url->url_port && strlen(m->m_url->url_port)) {
+ unsigned long port = strtoul(m->m_url->url_port, NULL, 10);
+ su->su_port = htons(port);
+ }
+ TEST_1(su->su_port != 0);
+
m->m_url->url_user = "bob";
TEST_1(ag->ag_m_bob = sip_contact_dup(ag->ag_home, m));
@@ -651,11 +682,12 @@
NTATAG_ALIASES(ag->ag_aliases),
NTATAG_REL100(1),
NTATAG_UA(1),
+ NTATAG_MERGE_482(1),
NTATAG_USE_NAPTR(1),
NTATAG_USE_SRV(1),
NTATAG_MAX_FORWARDS(20),
TAG_END());
- TEST(err, 6);
+ TEST(err, 7);
err = nta_agent_set_params(ag->ag_agent,
NTATAG_ALIASES(ag->ag_aliases),
@@ -723,7 +755,11 @@
nta_agent_destroy(ag->ag_agent);
su_root_destroy(ag->ag_root);
- su_free(ag->ag_home, (void *)ag->ag_sink_port), ag->ag_sink_port = NULL;
+ if (ag->ag_sink_port) {
+ su_free(ag->ag_home, (void *)ag->ag_sink_port), ag->ag_sink_port = NULL;
+ su_wait_destroy(ag->ag_sink_wait);
+ su_close(ag->ag_sink_socket);
+ }
free(ag->ag_mclass), ag->ag_mclass = NULL;
@@ -1206,6 +1242,9 @@
ctx->c_extra = &used_tport;
+ *url = *ag->ag_aliases->m_url;
+ url->url_user = "alice";
+
TEST(tport_shutdown(tcp_tport, 1), 0); /* Not going to send anymore */
TEST_1(pl = test_payload(ag->ag_home, 512));
@@ -2217,6 +2256,302 @@
END();
}
+/* Test merging */
+
+int test_merging(agent_t *ag)
+{
+ BEGIN();
+
+ /*
+ * Test merging: send two messages with same
+ * from tag/call-id/cseq number to nta,
+ * expect 200 and 408.
+ */
+
+ char const rfc3261prefix[] = "z9hG4bK";
+
+ char const template[] =
+ "%s " URL_PRINT_FORMAT " SIP/2.0\r\n"
+ "Via: SIP/2.0/UDP 127.0.0.1:%s;branch=%s.%p\r\n"
+ "Via: SIP/2.0/TCP fake.address.for.via.example.net;branch=z9hG4bK.%p\r\n"
+ "CSeq: %u %s\r\n"
+ "Call-ID: dfsjfhsduifhsjfsfjkfsd.%p@dfsdhfsjkhsdjk\r\n"
+ "From: Evil Forker <sip:evel@forker.com>;tag=test_nta-%s\r\n"
+ "To: Bob the Builder <sip:bob@example.net>%s\r\n"
+ "Content-Length: 0\r\n"
+ "\r\n";
+
+ url_t u1[1], u2[2];
+
+ char m1[1024], m2[1024];
+ char r1[1024], r2[1024];
+
+ size_t len, l1, l2;
+ su_sockaddr_t *su = ag->ag_su_nta;
+ socklen_t sulen = ag->ag_su_nta_len;
+ int n;
+
+ /* Empty sink socket */
+ while (su_wait(ag->ag_sink_wait, 1, 0) == 0)
+ su_recv(ag->ag_sink_socket, m1, sizeof m1, MSG_TRUNC);
+
+ {
+ /* RFC 3261 8.2.2.2 Merged Requests:
+
+ If the request has no tag in the To header field, the UAS core MUST
+ check the request against ongoing transactions. If the From tag,
+ Call-ID, and CSeq exactly match those associated with an ongoing
+ transaction, but the request does not match that transaction (based
+ on the matching rules in Section 17.2.3), the UAS core SHOULD
+ generate a 482 (Loop Detected) response and pass it to the server
+ transaction.
+ */
+ nta_leg_bind(ag->ag_server_leg, leg_callback_200, ag);
+ ag->ag_expect_leg = ag->ag_server_leg;
+ ag->ag_latest_leg = NULL;
+
+ *u1 = *ag->ag_m_bob->m_url;
+ snprintf(m1, sizeof m1,
+ template,
+ "MESSAGE", URL_PRINT_ARGS(u1),
+ /* Via */ ag->ag_sink_port, rfc3261prefix, (void *)m1,
+ /* 2nd Via */ (void *)ag,
+ /* CSeq */ 13, "MESSAGE",
+ /* Call-ID */ (void *)ag,
+ /* From tag */ "2.5.1",
+ /* To tag */ "");
+ l1 = strlen(m1);
+
+ *u2 = *ag->ag_m_bob->m_url;
+
+ snprintf(m2, sizeof m2,
+ template,
+ "MESSAGE", URL_PRINT_ARGS(u2),
+ /* Via */ ag->ag_sink_port, rfc3261prefix, (void *)m2,
+ /* 2nd Via */ (void *)ag,
+ /* CSeq */ 13, "MESSAGE",
+ /* Call-ID */ (void *)ag,
+ /* From tag */ "2.5.1",
+ /* To tag */ "");
+ l2 = strlen(m2);
+
+ TEST_1((size_t)su_sendto(ag->ag_sink_socket, m1, l1, 0, su, sulen) == l1);
+ TEST_1((size_t)su_sendto(ag->ag_sink_socket, m2, l2, 0, su, sulen) == l2);
+
+ for (n = 0; n < 2; ) {
+ su_root_step(ag->ag_root, 10L);
+ if (su_wait(ag->ag_sink_wait, 1, 0) == 0) {
+ if (n == 0)
+ su_recv(ag->ag_sink_socket, r1, sizeof r1, MSG_TRUNC);
+ else
+ su_recv(ag->ag_sink_socket, r2, sizeof r2, MSG_TRUNC);
+ n++;
+ }
+ }
+ len = strlen("SIP/2.0 200 ");
+ TEST_1(memcmp(r1, "SIP/2.0 200 ", len) == 0);
+ TEST_1(memcmp(r2, "SIP/2.0 482 ", len) == 0);
+
+ TEST_P(ag->ag_latest_leg, ag->ag_server_leg);
+ }
+
+ {
+ /*
+ * Check that request with same call-id, cseq and from-tag
+ * are not merged if the method is different.
+ */
+ nta_leg_bind(ag->ag_server_leg, leg_callback_200, ag);
+ ag->ag_expect_leg = ag->ag_server_leg;
+ ag->ag_latest_leg = NULL;
+
+ *u1 = *ag->ag_m_bob->m_url;
+ snprintf(m1, sizeof m1,
+ template,
+ "MESSAGE", URL_PRINT_ARGS(u1),
+ /* Via */ ag->ag_sink_port, rfc3261prefix, (void *)m1,
+ /* 2nd Via */ (void *)ag,
+ /* CSeq */ 14, "MESSAGE",
+ /* Call-ID */ (void *)ag,
+ /* From tag */ "2.5.2",
+ /* To tag */ "");
+ l1 = strlen(m1);
+
+ *u2 = *ag->ag_m_bob->m_url;
+
+ snprintf(m2, sizeof m2,
+ template,
+ "OPTIONS", URL_PRINT_ARGS(u2),
+ /* Via */ ag->ag_sink_port, rfc3261prefix, (void *)m2,
+ /* 2nd Via */ (void *)ag,
+ /* CSeq */ 14, "OPTIONS",
+ /* Call-ID */ (void *)ag,
+ /* From tag */ "2.5.2",
+ /* To tag */ "");
+ l2 = strlen(m2);
+
+ TEST_1((size_t)su_sendto(ag->ag_sink_socket, m1, l1, 0, su, sulen) == l1);
+ TEST_1((size_t)su_sendto(ag->ag_sink_socket, m2, l2, 0, su, sulen) == l2);
+
+ for (n = 0; n < 2; ) {
+ su_root_step(ag->ag_root, 10L);
+ if (su_wait(ag->ag_sink_wait, 1, 0) == 0) {
+ if (n == 0)
+ su_recv(ag->ag_sink_socket, r1, sizeof r1, MSG_TRUNC);
+ else
+ su_recv(ag->ag_sink_socket, r2, sizeof r2, MSG_TRUNC);
+ n++;
+ }
+ }
+
+ len = strlen("SIP/2.0 200 ");
+ TEST_1(memcmp(r1, "SIP/2.0 200 ", len) == 0);
+ TEST_1(memcmp(r2, "SIP/2.0 482 ", len) != 0);
+
+ TEST_P(ag->ag_latest_leg, ag->ag_server_leg);
+ }
+
+ {
+ /* test with rfc2543 */
+
+ snprintf(m1, sizeof m1,
+ template,
+ "MASSAGE", URL_PRINT_ARGS(u1),
+ /* Via */ ag->ag_sink_port, "0.", (void *)0,
+ /* 2nd Via */ (void *)ag,
+ /* CSeq */ 14, "MASSAGE",
+ /* Call-ID */ (void *)(ag + 1),
+ /* From tag */ "2.5.3",
+ /* To tag */ "");
+ l1 = strlen(m1);
+
+ u2->url_user = "bob+2";
+
+ snprintf(m2, sizeof m2,
+ template,
+ "MASSAGE", URL_PRINT_ARGS(u2),
+ /* Via */ ag->ag_sink_port, "0.", (void *)0,
+ /* 2nd Via */ (void *)ag,
+ /* CSeq */ 14, "MASSAGE",
+ /* Call-ID */ (void *)(ag + 1),
+ /* From tag */ "2.5.3",
+ /* To tag */ "");
+ l2 = strlen(m2);
+
+ TEST_1((size_t)su_sendto(ag->ag_sink_socket, m1, l1, 0, su, sulen) == l1);
+ TEST_1((size_t)su_sendto(ag->ag_sink_socket, m2, l2, 0, su, sulen) == l2);
+
+ for (n = 0; n < 2; ) {
+ su_root_step(ag->ag_root, 10L);
+ if (su_wait(ag->ag_sink_wait, 1, 0) == 0) {
+ if (n == 0)
+ su_recv(ag->ag_sink_socket, r1, sizeof r1, MSG_TRUNC);
+ else
+ su_recv(ag->ag_sink_socket, r2, sizeof r2, MSG_TRUNC);
+ n++;
+ }
+ }
+ l1 = strlen("SIP/2.0 200 ");
+ TEST_1(memcmp(r1, "SIP/2.0 200 ", l1) == 0);
+ TEST_1(memcmp(r2, "SIP/2.0 482 ", l1) == 0);
+
+ TEST_P(ag->ag_latest_leg, ag->ag_server_leg);
+ }
+
+ {
+ /* test with to-tag */
+
+ snprintf(m1, sizeof m1,
+ template,
+ "MESSAGE", URL_PRINT_ARGS(u1),
+ /* Via */ ag->ag_sink_port, rfc3261prefix, (void *)m1,
+ /* 2nd Via */ (void *)ag,
+ /* CSeq */ 15, "MESSAGE",
+ /* Call-ID */ (void *)(ag + 2),
+ /* From tag */ "2.5.4",
+ /* To tag */ ";tag=in-dialog");
+ l1 = strlen(m1);
+
+ u2->url_user = "bob+2";
+
+ snprintf(m2, sizeof m2,
+ template,
+ "MESSAGE", URL_PRINT_ARGS(u2),
+ /* Via */ ag->ag_sink_port, rfc3261prefix, (void *)m2,
+ /* 2nd Via */ (void *)ag,
+ /* CSeq */ 15, "MESSAGE",
+ /* Call-ID */ (void *)(ag + 2),
+ /* From tag */ "2.5.4",
+ /* To tag */ ";tag=in-dialog");
+ l2 = strlen(m2);
+
+ TEST_1((size_t)su_sendto(ag->ag_sink_socket, m1, l1, 0, su, sulen) == l1);
+ TEST_1((size_t)su_sendto(ag->ag_sink_socket, m2, l2, 0, su, sulen) == l2);
+
+ for (n = 0; n < 2; ) {
+ su_root_step(ag->ag_root, 10L);
+ if (su_wait(ag->ag_sink_wait, 1, 0) == 0) {
+ if (n == 0)
+ su_recv(ag->ag_sink_socket, r1, sizeof r1, MSG_TRUNC);
+ else
+ su_recv(ag->ag_sink_socket, r2, sizeof r2, MSG_TRUNC);
+ n++;
+ }
+ }
+ l1 = strlen("SIP/2.0 200 ");
+ TEST_1(memcmp(r1, "SIP/2.0 200 ", l1) == 0);
+ TEST_1(memcmp(r2, "SIP/2.0 482 ", l1) != 0);
+
+ TEST_P(ag->ag_latest_leg, ag->ag_server_leg);
+ }
+
+ {
+ /* test with rfc2543 and to-tag */
+
+ snprintf(m1, sizeof m1,
+ template,
+ "MESSAGE", URL_PRINT_ARGS(u1),
+ /* Via */ ag->ag_sink_port, "0.", (void *)0,
+ /* 2nd Via */ (void *)ag,
+ /* CSeq */ 15, "MESSAGE",
+ /* Call-ID */ (void *)(ag + 2),
+ /* From tag */ "2.5.5",
+ /* To tag */ ";tag=in-dialog");
+ l1 = strlen(m1);
+
+ snprintf(m2, sizeof m2,
+ template,
+ "MESSAGE", URL_PRINT_ARGS(u2),
+ /* Via */ ag->ag_sink_port, "0.", (void *)0,
+ /* 2nd Via */ (void *)ag,
+ /* CSeq */ 15, "MESSAGE",
+ /* Call-ID */ (void *)(ag + 2),
+ /* From tag */ "2.5.5",
+ /* To tag */ ";tag=in-dialog");
+ l2 = strlen(m2);
+
+ TEST_1((size_t)su_sendto(ag->ag_sink_socket, m1, l1, 0, su, sulen) == l1);
+ TEST_1((size_t)su_sendto(ag->ag_sink_socket, m2, l2, 0, su, sulen) == l2);
+
+ for (n = 0; n < 2; ) {
+ su_root_step(ag->ag_root, 10L);
+ if (su_wait(ag->ag_sink_wait, 1, 0) == 0) {
+ if (n == 0)
+ su_recv(ag->ag_sink_socket, r1, sizeof r1, MSG_TRUNC);
+ else
+ su_recv(ag->ag_sink_socket, r2, sizeof r2, MSG_TRUNC);
+ n++;
+ }
+ }
+ l1 = strlen("SIP/2.0 200 ");
+ TEST_1(memcmp(r1, "SIP/2.0 200 ", l1) == 0);
+ TEST_1(memcmp(r2, "SIP/2.0 482 ", l1) != 0);
+
+ TEST_P(ag->ag_latest_leg, ag->ag_server_leg);
+ }
+
+ END();
+}
+
/* ---------------------------------------------------------------------- */
/* Test INVITE, dialogs */
@@ -3485,6 +3820,7 @@
if (retval == 0) {
retval |= test_bad_messages(ag); SINGLE_FAILURE_CHECK();
retval |= test_reinit(ag); SINGLE_FAILURE_CHECK();
+ retval |= test_merging(ag); SINGLE_FAILURE_CHECK();
retval |= test_tports(ag); SINGLE_FAILURE_CHECK();
retval |= test_destroy_incoming(ag); SINGLE_FAILURE_CHECK();
retval |= test_resolv(ag, argv[i]); SINGLE_FAILURE_CHECK();
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c Sun Jan 6 15:15:11 2008
@@ -498,10 +498,18 @@
else if (nu->nu_requested >= now + expires)
nu->nu_expires = nu->nu_requested = now + expires;
}
+ else {
+ if (nu->nu_requested >= nu->nu_expires)
+ nu->nu_expires = nu->nu_requested;
+ }
+
}
else {
enum nua_substate substate = nu->nu_substate;
+ if (nu->nu_requested >= nu->nu_expires)
+ nu->nu_expires = nu->nu_requested;
+
if (nu->nu_expires > now) {
tagi_t const *t = tl_find_last(tags, nutag_substate);
if (t)
@@ -794,8 +802,11 @@
return 0;
}
else {
- if (nua_client_create(nh, nua_r_notify,
- &nua_notify_client_methods, NULL) >= 0)
+ if (nua_client_tcreate(nh, nua_r_notify,
+ &nua_notify_client_methods,
+ SIPTAG_EVENT(du->du_event),
+ NUTAG_SUBSTATE(nua_substate_terminated),
+ TAG_END()) >= 0)
return 0;
}
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c Sun Jan 6 15:15:11 2008
@@ -2023,7 +2023,8 @@
reliable = 1, early_answer = 1;
}
else if (!nh->nh_soa || sr->sr_status >= 300) {
-
+ if (sr->sr_neutral)
+ return nua_base_server_respond(sr, tags);
}
else if (tags && 100 < sr->sr_status && sr->sr_status < 200 &&
!NHP_ISSET(nh->nh_prefs, early_answer)) {
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c Sun Jan 6 15:15:11 2008
@@ -581,7 +581,7 @@
sr->sr_usage = du;
eu = nua_dialog_usage_private(du); assert(eu);
eu->eu_notified++;
- if (!o->o_id)
+ if (!o || !o->o_id)
eu->eu_no_id = 1;
if (subs == NULL) {
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/outbound.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/outbound.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/outbound.c Sun Jan 6 15:15:11 2008
@@ -503,13 +503,13 @@
}
if (!nat_detected) {
- SU_DEBUG_1(("outbound(%p): detected NAT: %s != %s\n",
+ SU_DEBUG_5(("outbound(%p): detected NAT: %s != %s\n",
(void *)ob->ob_owner, v->v_host, received));
if (ob->ob_oo && ob->ob_oo->oo_status)
ob->ob_oo->oo_status(ob->ob_owner, ob, 101, "NAT detected", TAG_END());
}
else {
- SU_DEBUG_1(("outbound(%p): NAT binding changed: "
+ SU_DEBUG_5(("outbound(%p): NAT binding changed: "
"[%s]:%s != [%s]:%s\n",
(void *)ob->ob_owner, nat_detected, nat_port, received, rport));
if (ob->ob_oo && ob->ob_oo->oo_status)
@@ -860,8 +860,6 @@
else
loglevel = 3, failed = 1;
- loglevel = 1; /* XXX ... for now */
-
if (loglevel >= SU_LOG->log_level) {
sip_contact_t const *m = ob->ob_rcontact;
@@ -886,7 +884,7 @@
ob->ob_oo->oo_probe_error(ob->ob_owner, ob, status, phrase, TAG_END());
}
else if (status == 408) {
- SU_DEBUG_1(("outbound(%p): keepalive timeout\n", (void *)ob->ob_owner));
+ SU_DEBUG_3(("outbound(%p): keepalive timeout\n", (void *)ob->ob_owner));
ob->ob_oo->oo_keepalive_error(ob->ob_owner, ob, status, phrase, TAG_END());
return 0;
}
@@ -979,7 +977,7 @@
return 0;
if (ob->ob_keepalive.validating) {
- SU_DEBUG_1(("outbound(%p): registration check OPTIONS received\n",
+ SU_DEBUG_5(("outbound(%p): registration check OPTIONS received\n",
(void *)ob->ob_owner));
ob->ob_keepalive.validated = 1;
}
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/stun/stun.c Sun Jan 6 15:15:11 2008
@@ -1895,23 +1895,23 @@
if ((req->sr_state == stun_req_timeout) && (req->sr_from_y == -1)) {
SU_DEBUG_0(("%s: lifetime determination failed.\n", __func__));
sd->sd_state = stun_discovery_timeout;
+ req->sr_state = stun_req_dispose_me;
/* Use per discovery specific callback */
if (sd->sd_callback)
sd->sd_callback(sd->sd_magic, sh, sd, action, sd->sd_state);
- req->sr_state = stun_req_dispose_me;
return 0;
}
if (abs(sd->sd_lt_cur - sd->sd_lt) <= STUN_LIFETIME_CI) {
sd->sd_state = stun_discovery_done;
+ req->sr_state = stun_req_dispose_me;
/* Use per discovery specific callback */
if (sd->sd_callback)
sd->sd_callback(sd->sd_magic, sh, sd, action, sd->sd_state);
- req->sr_state = stun_req_dispose_me;
return 0;
}
@@ -1998,12 +1998,11 @@
memcpy(sd->sd_addr_seen_outside, sa, sizeof(su_sockaddr_t));
sd->sd_state = stun_discovery_done;
+ req->sr_state = stun_req_dispose_me;
if (sd->sd_callback)
sd->sd_callback(sd->sd_magic, sh, sd, action, sd->sd_state);
- req->sr_state = stun_req_dispose_me;
-
return 0;
}
@@ -2053,9 +2052,9 @@
stun_request_t *req)
{
sd->sd_state = stun_discovery_done;
+ req->sr_state = stun_req_dispose_me;
if (sd->sd_callback)
sd->sd_callback(sd->sd_magic, sh, sd, action, sd->sd_state);
- req->sr_state = stun_req_dispose_me;
}
/**
@@ -2290,12 +2289,12 @@
switch (action) {
case stun_action_binding_request:
sd->sd_state = stun_discovery_timeout;
+ req->sr_state = stun_req_dispose_me;
/* Use per discovery specific callback */
if (sd->sd_callback)
sd->sd_callback(sd->sd_magic, sh, sd, action, sd->sd_state);
- req->sr_state = stun_req_dispose_me;
break;
case stun_action_test_nattype:
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_tag.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_tag.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_tag.c Sun Jan 6 15:15:11 2008
@@ -311,6 +311,10 @@
*
* This is a parameter suitable for tuning.
*
+ * On Linux systems, the default value for receive buffer is set with
+ * the sysctl "net.core.rmem_default", and the maximum value is set with
+ * the sysctl "net.core.rmem_max".
+ *
* Use with tport_tbind(), nua_create(), nta_agent_create(),
* nta_agent_add_tport(), nth_engine_create(), or initial nth_site_create().
*/
@@ -322,6 +326,10 @@
*
* This is a parameter suitable for tuning.
*
+ * On Linux systems, the default value for receive buffer is set with
+ * the sysctl "net.core.wmem_default", and the maximum value is set with
+ * the sysctl "net.core.wmem_max".
+ *
* Use with tport_tbind(), nua_create(), nta_agent_create(),
* nta_agent_add_tport(), nth_engine_create(), or initial nth_site_create().
*/
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c Sun Jan 6 15:15:11 2008
@@ -35,6 +35,7 @@
#include "config.h"
#include "tport_internal.h"
+#include "sofia-sip/hostdomain.h"
#if HAVE_IP_RECVERR || HAVE_IPV6_RECVERR
#include <linux/types.h>
@@ -113,6 +114,8 @@
unsigned rmem = 0, wmem = 0;
int events = SU_WAIT_IN;
int s;
+ su_sockaddr_t *su = (su_sockaddr_t *)ai->ai_addr;
+ int const one = 1; (void)one;
s = su_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (s == INVALID_SOCKET)
@@ -125,20 +128,51 @@
tport_set_tos(s, ai, pri->pri_params->tpp_tos);
+#if HAVE_IP_ADD_MEMBERSHIP
+ if (ai->ai_family == AF_INET &&
+ IN_MULTICAST(ntohl(su->su_sin.sin_addr.s_addr))) {
+ /* Try to join to the multicast group */
+ /* Bind to the SIP address like
+ <sip:88.77.66.55:5060;maddr=224.0.1.75;transport=udp> */
+ struct ip_mreq imr[1];
+ struct in_addr iface;
+
+ memset(imr, 0, sizeof imr);
+
+ imr->imr_multiaddr = su->su_sin.sin_addr;
+
+ if (host_is_ip4_address(tpn->tpn_canon) &&
+ inet_pton(AF_INET, tpn->tpn_canon, &iface) > 0) {
+ imr->imr_interface = iface;
+ }
+
+ if (setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, imr, (sizeof imr)) < 0) {
+ SU_DEBUG_3(("setsockopt(%s): %s\n",
+ "IP_ADD_MEMBERSHIP", su_strerror(su_errno())));
+ }
+#if HAVE_IP_MULTICAST_LOOP
+ else
+ if (setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP, &one, sizeof one) < 0) {
+ SU_DEBUG_3(("setsockopt(%s): %s\n",
+ "IP_MULTICAST_LOOP", su_strerror(su_errno())));
+ }
+#endif
+ }
+#endif
+
#if HAVE_IP_RECVERR
if (ai->ai_family == AF_INET || ai->ai_family == AF_INET6) {
- int const one = 1;
- if (setsockopt(s, SOL_IP, IP_RECVERR, &one, sizeof(one)) < 0) {
+ if (setsockopt(s, IPPROTO_IP, IP_RECVERR, &one, sizeof(one)) < 0) {
if (ai->ai_family == AF_INET)
- SU_DEBUG_3(("setsockopt(IPVRECVERR): %s\n", su_strerror(su_errno())));
+ SU_DEBUG_3(("setsockopt(%s): %s\n",
+ "IPVRECVERR", su_strerror(su_errno())));
}
events |= SU_WAIT_ERR;
}
#endif
#if HAVE_IPV6_RECVERR
if (ai->ai_family == AF_INET6) {
- int const one = 1;
- if (setsockopt(s, SOL_IPV6, IPV6_RECVERR, &one, sizeof(one)) < 0)
+ if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVERR, &one, sizeof(one)) < 0)
SU_DEBUG_3(("setsockopt(IPV6_RECVERR): %s\n", su_strerror(su_errno())));
events |= SU_WAIT_ERR;
}
@@ -150,12 +184,18 @@
TAG_END());
if (rmem != 0 &&
+#if HAVE_SO_RCVBUFFORCE
+ setsockopt(s, SOL_SOCKET, SO_RCVBUFFORCE, (void *)&rmem, sizeof rmem) < 0 &&
+#endif
setsockopt(s, SOL_SOCKET, SO_RCVBUF, (void *)&rmem, sizeof rmem) < 0) {
SU_DEBUG_3(("setsockopt(SO_RCVBUF): %s\n",
su_strerror(su_errno())));
}
if (wmem != 0 &&
+#if HAVE_SO_SNDBUFFORCE
+ setsockopt(s, SOL_SOCKET, SO_SNDBUFFORCE, (void *)&wmem, sizeof wmem) < 0 &&
+#endif
setsockopt(s, SOL_SOCKET, SO_SNDBUF, (void *)&wmem, sizeof wmem) < 0) {
SU_DEBUG_3(("setsockopt(SO_SNDBUF): %s\n",
su_strerror(su_errno())));
@@ -409,10 +449,10 @@
for (c = CMSG_FIRSTHDR(msg); c; c = CMSG_NXTHDR(msg, c)) {
if (0
#if HAVE_IP_RECVERR
- || (c->cmsg_level == SOL_IP && c->cmsg_type == IP_RECVERR)
+ || (c->cmsg_level == IPPROTO_IP && c->cmsg_type == IP_RECVERR)
#endif
#if HAVE_IPV6_RECVERR
- || (c->cmsg_level == SOL_IPV6 && c->cmsg_type == IPV6_RECVERR)
+ || (c->cmsg_level == IPPROTO_IPV6 && c->cmsg_type == IPV6_RECVERR)
#endif
) {
char info[128];
Modified: freeswitch/trunk/libs/sofia-sip/m4/sac-su2.m4
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/m4/sac-su2.m4 (original)
+++ freeswitch/trunk/libs/sofia-sip/m4/sac-su2.m4 Sun Jan 6 15:15:11 2008
@@ -273,6 +273,28 @@
#include <sys/types.h>
#include <sys/socket.h>])
+AC_CHECK_DECL([SO_RCVBUFFORCE],
+AC_DEFINE([HAVE_SO_RCVBUFFORCE],1,[Define to 1 if you have socket option SO_RCVBUFFORCE]),,[
+#include <sys/types.h>
+#include <sys/socket.h>])
+
+AC_CHECK_DECL([SO_SNDBUFFORCE],
+AC_DEFINE([HAVE_SO_SNDBUFFORCE],1,[Define to 1 if you have socket option SO_SNDBUFFORCE]),,[
+#include <sys/types.h>
+#include <sys/socket.h>])
+
+AC_CHECK_DECL([IP_ADD_MEMBERSHIP],
+AC_DEFINE([HAVE_IP_ADD_MEMBERSHIP],1,[Define to 1 if you have IP_ADD_MEMBERSHIP]),,[
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>])
+
+AC_CHECK_DECL([IP_MULTICAST_LOOP],
+AC_DEFINE([HAVE_IP_MULTICAST_LOOP],1,[Define to 1 if you have IP_MULTICAST_LOOP]),,[
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>])
+
AC_CACHE_CHECK([for struct addrinfo],
[ac_cv_struct_addrinfo],[
ac_cv_struct_addrinfo=no
Added: freeswitch/trunk/libs/sofia-sip/scripts/hide_emails.sh
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/sofia-sip/scripts/hide_emails.sh Sun Jan 6 15:15:11 2008
@@ -0,0 +1,41 @@
+#!/bin/sh
+#
+# description: Mangle email addresses in the HTML documentation
+# author: Kai Vehmanen <kai.vehmanen(a)nokia.com>
+# version: 20050908-3
+#
+# --------------------------------------------------------------------
+#
+# This file is part of the Sofia-SIP package
+#
+# Copyright (C) 2005 Nokia Corporation.
+#
+# Contact: Pekka Pessi <pekka.pessi(a)nokia.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+#
+# --------------------------------------------------------------------
+
+echo "Postprocessing HTML in ${1:-.}: hiding email addresses, fixing links"
+
+find ${1:-.} -name '*.html' -print0 |
+xargs -0 \
+sed -r -i '
+# Hide e-mail addresses
+s/([:>;][a-z][-a-z.]*)((a)[a-z][a-z]*)\.[a-z][a-z]*(["<\&])/\1\2-email.address.hidden\3/gi;
+# Fix cross-module links
+s!doxygen="([a-z]*).doxytags:../\1/" href="../\1/\1_index.html"!doxygen="\1.doxytags:../\1/" href="../\1/index.html"!g;
+'
Modified: freeswitch/trunk/libs/sofia-sip/tests/check_sofia.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/tests/check_sofia.c (original)
+++ freeswitch/trunk/libs/sofia-sip/tests/check_sofia.c Sun Jan 6 15:15:11 2008
@@ -51,7 +51,9 @@
suite = suite_for_nua();
runner = srunner_create(suite);
- srunner_set_xml(runner, "/tmp/result.xml");
+ if (argv[1]) {
+ srunner_set_xml(runner, argv[1]);
+ }
srunner_run_all(runner, CK_NORMAL);
failed = srunner_ntests_failed(runner);
1
0
Author: stkn
Date: Sun Jan 6 13:03:32 2008
New Revision: 7108
Modified:
freeswitch/trunk/libs/js/configure.ac
Log:
Fix pthread configure check for js cli tool
Modified: freeswitch/trunk/libs/js/configure.ac
==============================================================================
--- freeswitch/trunk/libs/js/configure.ac (original)
+++ freeswitch/trunk/libs/js/configure.ac Sun Jan 6 13:03:32 2008
@@ -178,11 +178,13 @@
AC_CACHE_CHECK([whether to build with NSPR], [ac_cv_with_nspr], [ac_cv_with_nspr=no])
if test ".$ac_cv_with_nspr" = ".yes"; then
sinclude(nsprpub/config/nspr.m4)
+
+ AC_CHECK_LIB(pthread, pthread_create, [CLI_LIBS="$CLI_LIBS -lpthread"])
+
CPPFLAGS="$CPPFLAGS -DJS_THREADSAFE=1 -Insprpub/dist/include/nspr -Insprpub/pr/include"
LDFLAGS="$LDFLAGS -L./nsprpub/dist/lib"
LIBS="$LIBS -lnspr4"
LIBPATH="LD_LIBRARY_PATH=./nsprpub/dist/lib DYLD_LIBRARY_PATH=./nsprpub/dist/lib"
- AC_CHECK_LIB(pthread, pthread_create, [CLI_LIBS="$CLI_LIBS -lpthread"])
fi
AC_DEFUN([AX_COMPILER_VENDOR],
1
0
Author: mikej
Date: Sat Jan 5 21:17:20 2008
New Revision: 7107
Modified:
freeswitch/trunk/libs/win32/sqlite/sqlite.2008.vcproj
Log:
no need to build files that are not used.
Modified: freeswitch/trunk/libs/win32/sqlite/sqlite.2008.vcproj
==============================================================================
--- freeswitch/trunk/libs/win32/sqlite/sqlite.2008.vcproj (original)
+++ freeswitch/trunk/libs/win32/sqlite/sqlite.2008.vcproj Sat Jan 5 21:17:20 2008
@@ -381,6 +381,38 @@
<File
RelativePath="..\..\sqlite\src\os_unix.c"
>
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug DLL|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release DLL|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\..\sqlite\src\os_win.c"
1
0
Author: anthm
Date: Sat Jan 5 20:11:21 2008
New Revision: 7106
Modified:
freeswitch/trunk/libs/sqlite/.update
Log:
update
Modified: freeswitch/trunk/libs/sqlite/.update
==============================================================================
--- freeswitch/trunk/libs/sqlite/.update (original)
+++ freeswitch/trunk/libs/sqlite/.update Sat Jan 5 20:11:21 2008
@@ -1 +1 @@
-Sat Jan 5 15:55:07 EST 2008
+Sat Jan 5 20:11:10 EST 2008
1
0
Author: anthm
Date: Sat Jan 5 20:10:37 2008
New Revision: 7105
Modified:
freeswitch/trunk/libs/sqlite/src/sqliteInt.h
freeswitch/trunk/libs/sqlite/src/util.c
freeswitch/trunk/libs/sqlite/src/vdbefifo.c
freeswitch/trunk/src/switch_core.c
Log:
BSD fixes, thanks jontow for the use of your box
Modified: freeswitch/trunk/libs/sqlite/src/sqliteInt.h
==============================================================================
--- freeswitch/trunk/libs/sqlite/src/sqliteInt.h (original)
+++ freeswitch/trunk/libs/sqlite/src/sqliteInt.h Sat Jan 5 20:10:37 2008
@@ -281,20 +281,26 @@
return z;
}
+static inline char *strndup_lite(const char *s, size_t n)
+{
+ char *dup = malloc(n+1);
+ assert(dup);
+ memcpy(dup, s, n);
+ *(dup+n) = '\0';
+ return dup;
+}
#define ENTER_MALLOC 0
#define sqliteMalloc(x) zmalloc(x)//sqlite3Malloc(x,1)
#define sqliteMallocRaw(x) malloc(x)//sqlite3MallocRaw(x,1)
#define sqliteRealloc(x,y) realloc(x, y)//sqlite3Realloc(x,y)
#define sqliteStrDup(x) strdup(x)//sqlite3StrDup(x)
-#define sqliteStrNDup(x,y) sqlite3StrNDup(x,y)
-
+#define sqliteStrNDup(x,y) strndup_lite(x,y) //sqlite3StrNDup(x,y)
#define sqliteReallocOrFree(x,y) sqlite3ReallocOrFree(x,y)
#endif
-
-#define sqliteFree(x) if (x) { free((void *)x); x = NULL; } //sqlite3FreeX(x)
+#define sqliteFree(x) if (x) { free((void *)x); x = NULL;} //sqlite3FreeX(x)
#define sqliteAllocSize(x) sqlite3AllocSize(x)
Modified: freeswitch/trunk/libs/sqlite/src/util.c
==============================================================================
--- freeswitch/trunk/libs/sqlite/src/util.c (original)
+++ freeswitch/trunk/libs/sqlite/src/util.c Sat Jan 5 20:10:37 2008
@@ -729,7 +729,7 @@
char *sqlite3StrNDup(const char *z, int n){
char *zNew;
if( z==0 ) return 0;
- zNew = sqliteMallocRaw(n+1);
+ zNew = sqlite3MallocRaw(n+1, 1);
if( zNew ){
memcpy(zNew, z, n);
zNew[n] = 0;
Modified: freeswitch/trunk/libs/sqlite/src/vdbefifo.c
==============================================================================
--- freeswitch/trunk/libs/sqlite/src/vdbefifo.c (original)
+++ freeswitch/trunk/libs/sqlite/src/vdbefifo.c Sat Jan 5 20:10:37 2008
@@ -89,7 +89,7 @@
pFifo->pFirst = pPage->pNext;
sqliteFree(pPage);
if( pFifo->nEntry==0 ){
- assert( pFifo->pLast==pPage );
+ //assert( pFifo->pLast==pPage );
pFifo->pLast = 0;
}else{
assert( pFifo->pFirst!=0 );
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Sat Jan 5 20:10:37 2008
@@ -705,10 +705,19 @@
{
struct rlimit rlp;
+ /*
+ Setting the stack size on FreeBSD results in an instant crash.
+
+ If anyone knows how to fix this,
+ feel free to submit a patch to http://jira.freeswitch.org
+ */
+
+#ifndef __FreeBSD__
memset(&rlp, 0, sizeof(rlp));
rlp.rlim_cur = SWITCH_THREAD_STACKSIZE;
rlp.rlim_max = SWITCH_THREAD_STACKSIZE;
setrlimit(RLIMIT_STACK, &rlp);
+#endif
memset(&rlp, 0, sizeof(rlp));
rlp.rlim_cur = 999999;
1
0
Author: anthm
Date: Sat Jan 5 17:17:41 2008
New Revision: 7104
Modified:
freeswitch/trunk/src/switch_ivr_originate.c
Log:
remove duplicate code
Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c (original)
+++ freeswitch/trunk/src/switch_ivr_originate.c Sat Jan 5 17:17:41 2008
@@ -291,62 +291,6 @@
}
- if (ringback_data) {
- char *tmp_data = NULL;
-
- if (!switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(caller_channel, CF_ANSWERED)) {
- switch_channel_pre_answer(caller_channel);
- }
-
- switch_buffer_create_dynamic(&ringback.audio_buffer, 512, 1024, 0);
- switch_buffer_set_loops(ringback.audio_buffer, -1);
-
- if (switch_is_file_path(ringback_data)) {
- char *ext;
-
- if (strrchr(ringback_data, '.') || strstr(ringback_data, SWITCH_URL_SEPARATOR)) {
- switch_core_session_set_read_codec(session, &write_codec);
- } else {
- ringback.asis++;
- write_frame.codec = read_codec;
- ext = read_codec->implementation->iananame;
- tmp_data = switch_mprintf("%s.%s", ringback_data, ext);
- ringback_data = tmp_data;
- }
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Play Ringback File [%s]\n", ringback_data);
-
- ringback.fhb.channels = read_codec->implementation->number_of_channels;
- ringback.fhb.samplerate = read_codec->implementation->actual_samples_per_second;
- if (switch_core_file_open(&ringback.fhb,
- ringback_data,
- read_codec->implementation->number_of_channels,
- 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_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Playing File\n");
- switch_safe_free(tmp_data);
- goto done;
- }
- ringback.fh = &ringback.fhb;
-
-
- } else {
- teletone_init_session(&ringback.ts, 0, teletone_handler, &ringback);
- ringback.ts.rate = read_codec->implementation->actual_samples_per_second;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Play Ringback Tone [%s]\n", ringback_data);
- if (teletone_run(&ringback.ts, ringback_data)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Playing Tone\n");
- teletone_destroy_session(&ringback.ts);
- switch_buffer_destroy(&ringback.audio_buffer);
- ringback_data = NULL;
- }
- }
- switch_safe_free(tmp_data);
-
- }
-
-
if ((read_codec = switch_core_session_get_read_codec(session)) && (ringback_data || !switch_channel_test_flag(caller_channel, CF_BYPASS_MEDIA))) {
if (!(pass = (uint8_t) switch_test_flag(read_codec, SWITCH_CODEC_FLAG_PASSTHROUGH))) {
if (switch_core_codec_init(&write_codec,
1
0
[commit] r7103 - in freeswitch/trunk/src: . include mod/applications/mod_dptools mod/endpoints/mod_sofia
by Freeswitch SVN 05 Jan '08
by Freeswitch SVN 05 Jan '08
05 Jan '08
Author: anthm
Date: Sat Jan 5 17:17:26 2008
New Revision: 7103
Modified:
freeswitch/trunk/src/include/switch_channel.h
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
freeswitch/trunk/src/switch_channel.c
freeswitch/trunk/src/switch_ivr_bridge.c
Log:
update
Modified: freeswitch/trunk/src/include/switch_channel.h
==============================================================================
--- freeswitch/trunk/src/include/switch_channel.h (original)
+++ freeswitch/trunk/src/include/switch_channel.h Sat Jan 5 17:17:26 2008
@@ -75,7 +75,7 @@
SWITCH_DECLARE(uint8_t) switch_channel_ready(switch_channel_t *channel);
SWITCH_DECLARE(void) switch_channel_wait_for_state(switch_channel_t *channel, switch_channel_t *other_channel, switch_channel_state_t want_state);
-SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *channel, switch_channel_flag_t want_flag, uint32_t to);
+SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *channel, switch_channel_flag_t want_flag, switch_bool_t pres, uint32_t to);
SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_channel_t *channel,
const char *file, const char *func, int line, switch_channel_state_t state);
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Sat Jan 5 17:17:26 2008
@@ -1273,11 +1273,11 @@
if (l) {
if (*l == '+') {
l++;
- if (l) {
- limit = atoi(l);
- if (limit < 0) {
- limit = 0;
- }
+ }
+ if (l) {
+ limit = atoi(l);
+ if (limit < 0) {
+ limit = 0;
}
}
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Sat Jan 5 17:17:26 2008
@@ -252,11 +252,29 @@
cause = switch_channel_get_cause(channel);
if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD) && cause != SWITCH_CAUSE_ATTENDED_TRANSFER) {
+ const char *buuid;
+ switch_core_session_t *bsession;
+ switch_channel_t *bchannel;
+ const char *lost_ext;
if (tech_pvt->max_missed_packets) {
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets);
}
switch_channel_presence(tech_pvt->channel, "unknown", "unhold");
+
+ if ((buuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
+ if ((bsession = switch_core_session_locate(buuid))) {
+ bchannel = switch_core_session_get_channel(bsession);
+ if (switch_channel_test_flag(bchannel, CF_BROADCAST)) {
+ if ((lost_ext = switch_channel_get_variable(bchannel, "left_hanging_extension"))) {
+ switch_ivr_session_transfer(bsession, lost_ext, NULL, NULL);
+ }
+ switch_channel_stop_broadcast(bchannel);
+ }
+ switch_core_session_rwunlock(bsession);
+ }
+ }
+
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Sat Jan 5 17:17:26 2008
@@ -1395,24 +1395,35 @@
}
if (stream) {
- switch_ivr_displace_session(tech_pvt->session, stream, 0, "rl");
+ //switch_ivr_displace_session(tech_pvt->session, stream, 0, "rl");
+ switch_ivr_broadcast(switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE), stream, SMF_ECHO_ALEG | SMF_LOOP);
}
}
} else {
if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
- const char *stream;
+ const char *uuid;
+ switch_core_session_t *b_session;
+
+ //const char *stream;
if (tech_pvt->max_missed_packets) {
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets);
}
- if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
- stream = tech_pvt->profile->hold_music;
- }
+ if ((uuid = switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (b_session = switch_core_session_locate(uuid))) {
+ switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
+ switch_channel_stop_broadcast(b_channel);
+ switch_channel_wait_for_flag(b_channel, CF_BROADCAST, SWITCH_FALSE, 2000);
+ switch_core_session_rwunlock(b_session);
+ }
- if (stream) {
- switch_ivr_stop_displace_session(tech_pvt->session, stream);
- }
+ //if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
+ //stream = tech_pvt->profile->hold_music;
+ //}
+
+ //if (stream) {
+ //switch_ivr_stop_displace_session(tech_pvt->session, stream);
+ //}
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
switch_channel_presence(tech_pvt->channel, "unknown", "unhold");
Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c (original)
+++ freeswitch/trunk/src/switch_channel.c Sat Jan 5 17:17:26 2008
@@ -550,14 +550,24 @@
}
}
-SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *channel, switch_channel_flag_t want_flag, uint32_t to)
+SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *channel, switch_channel_flag_t want_flag, switch_bool_t pres, uint32_t to)
{
if (to) {
to++;
}
- while(!switch_test_flag(channel, want_flag)) {
+ for(;;) {
+ if (pres) {
+ if (switch_test_flag(channel, want_flag)) {
+ break;
+ }
+ } else {
+ if (!switch_test_flag(channel, want_flag)) {
+ break;
+ }
+ }
+
switch_yield(1000);
if (to && !--to) {
return SWITCH_STATUS_TIMEOUT;
Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c (original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c Sat Jan 5 17:17:26 2008
@@ -222,7 +222,6 @@
end:
switch_core_session_kill_channel(session_b, SWITCH_SIG_BREAK);
- switch_channel_stop_broadcast(chan_b);
switch_core_session_reset(session_a);
switch_channel_set_variable(chan_a, SWITCH_BRIDGE_VARIABLE, NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "BRIDGE THREAD DONE [%s]\n", switch_channel_get_name(chan_a));
1
0
Author: anthm
Date: Sat Jan 5 16:47:24 2008
New Revision: 7102
Modified:
freeswitch/trunk/src/switch_utils.c
Log:
update
Modified: freeswitch/trunk/src/switch_utils.c
==============================================================================
--- freeswitch/trunk/src/switch_utils.c (original)
+++ freeswitch/trunk/src/switch_utils.c Sat Jan 5 16:47:24 2008
@@ -70,7 +70,7 @@
switch_size_t total = 0;
p = buf;
- while (total + sizeof(c) < len && (cur = read(fd, &c, sizeof(c))) > 0) {
+ while (total + 2 < len && (cur = read(fd, &c, 1)) == 1) {
total += cur;
*p++ = c;
if (c == '\r' || c == '\n') {
@@ -79,6 +79,7 @@
}
*p++ = '\0';
+ assert(total < len);
return total;
}
1
0