Freeswitch-branches
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
- 1655 discussions
[commit] r4789 - freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr
by Freeswitch SVN 29 Mar '07
by Freeswitch SVN 29 Mar '07
29 Mar '07
Author: mikej
Date: Thu Mar 29 01:44:38 2007
New Revision: 4789
Modified:
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/Makefile.am
Log:
fix bsd make compile of mod_cdr
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/Makefile.am
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/Makefile.am (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/Makefile.am Thu Mar 29 01:44:38 2007
@@ -1,22 +1,9 @@
#we should set all these vars from configure, no reason to have these in each Makefile.am
-#LIBTOOL = compile=`echo $<|grep .c`;link=`echo $@|grep .la;echo $@|grep .so;echo $@|grep .dll`; if test -n "$$compile"; then echo Compiling $<;fi; if test -n "$$link"; then echo Creating $@;fi; `if test -z "$(VERBOSE)" ; then echo $(SHELL) $(switch_builddir)/quiet_libtool ;else echo $(switch_builddir)/libtool; fi;`
-#LIBTOOL=`if test -z "$(VERBOSE)" ; then echo $(SHELL) $(switch_builddir)/quiet_libtool ;else echo $(switch_builddir)/libtool; fi;`
-LIBTOOL = link=`echo $@|grep .la;echo $@|grep .so;echo $@|grep .dll`; \
- if test -n "$$link"; then echo Creating $@;fi; \
- `if test -z "$(VERBOSE)" ; \
- then echo $(SHELL) $(switch_builddir)/quiet_libtool ;\
- else echo $(switch_builddir)/libtool; fi;`
-
+LIBTOOL = echo "`link=\`echo $@|grep .la;echo $@|grep .so;echo $@|grep .dll\`;if test -n "$$link"; then echo Creating $@;fi`";`if test -z "$(VERBOSE)" ; \
+then echo $(SHELL) $(switch_builddir)/quiet_libtool ;else echo $(SHELL) $(switch_builddir)/libtool; fi`
AM_MAKEFLAGS=`test -n "$(VERBOSE)" || echo -s`
-
# Dirty trick to override the link output
-LIBS+=> $(MODNAME).log || error="yes" ; \
- if test -n "$(VERBOSE)" -o "$$error" = "yes"; then \
- cat $(MODNAME).log ; \
- fi ;\
- if test "$$error" = "yes"; then \
- exit 1 ;\
- fi
+LIBS+=> $(MODNAME).log || error="yes";if test -n "$(VERBOSE)" -o "$$error" = "yes";then cat $(MODNAME).log;fi;if test "$$error" = "yes";then exit 1;fi
moddir=$(prefix)/mod
1
0
[commit] r4788 - in freeswitch/branches/mikej/sofiasip-upgrade: . src src/include src/mod/applications/mod_commands src/mod/applications/mod_conference src/mod/applications/mod_dptools src/mod/applications/mod_ivrtest src/mod/event_handlers/mod_cdr
by Freeswitch SVN 29 Mar '07
by Freeswitch SVN 29 Mar '07
29 Mar '07
Author: mikej
Date: Thu Mar 29 00:30:19 2007
New Revision: 4788
Modified:
freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am
freeswitch/branches/mikej/sofiasip-upgrade/configure.in
freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_am_config.h.in
freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core.h
freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_ivr.h
freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_platform.h
freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_commands/mod_commands.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_conference/mod_conference.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_ivrtest/mod_ivrtest.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/Makefile.am
freeswitch/branches/mikej/sofiasip-upgrade/src/switch_channel.c
freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core.c
freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr.c
freeswitch/branches/mikej/sofiasip-upgrade/src/switch_resample.c
Log:
merged changes from trunk revisions 4781-4787.
Modified: freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am Thu Mar 29 00:30:19 2007
@@ -80,12 +80,12 @@
CORE_CFLAGS += -I$(switch_srcdir)/libs/pcre
CORE_CFLAGS += -I$(switch_srcdir)/libs/srtp/include
CORE_CFLAGS += -I$(switch_srcdir)/libs/srtp/crypto/include
-CORE_CFLAGS += -I$(switch_srcdir)/libs/libresample/include
+CORE_CFLAGS += $(RESAMPLE_CFLAGS)
CORE_CFLAGS += -I$(switch_srcdir)/libs/libteletone/src
CORE_LIBS = libs/apr/libapr-1.la libs/apr-util/libaprutil-1.la
CORE_LIBS += libs/sqlite/libsqlite3.la libs/pcre/libpcre.la
-CORE_LIBS += libs/srtp/libsrtp.la libs/libresample/libresample.la
+CORE_LIBS += libs/srtp/libsrtp.la $(RESAMPLE_LIB)
lib_LTLIBRARIES = libfreeswitch.la
libfreeswitch_la_CFLAGS = $(CORE_CFLAGS) $(AM_CFLAGS)
@@ -171,9 +171,11 @@
@cd libs/srtp && $(MAKE)
@$(TOUCH_TARGET)
+if USE_INTREE_RESAMPLE
libs/libresample/libresample.la: libs/libresample libs/libresample/.update
@cd libs/libresample && $(MAKE)
@$(TOUCH_TARGET)
+endif
core: libfreeswitch.la
Modified: freeswitch/branches/mikej/sofiasip-upgrade/configure.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/configure.in (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/configure.in Thu Mar 29 00:30:19 2007
@@ -57,9 +57,29 @@
AM_CONDITIONAL([WANT_DEBUG],[test "${enable_debug}" = "yes"])
+# Optional Features
+
+AC_ARG_ENABLE(resample,
+[AC_HELP_STRING([--enable-resample],[build with embedded resamper])],[enable_resample="$enable_resample"],[enable_resample="yes"])
+
+# We should add checking for out of tree libresample here
+RESAMPLE_LIB=
+RESAMPLE_CFLAGS=
+if test "${enable_resample}" = "yes"; then
+ RESAMPLE_LIB="libs/libresample/libresample.la"
+ RESAMPLE_CFLAGS="-I${switch_srcdir}/libs/libresample/include"
+else
+ AC_DEFINE([DISABLE_RESAMPLE],[],[Disable the embedded resampler])
+fi
+
+AC_SUBST(RESAMPLE_LIB)
+AC_SUBST(RESAMPLE_CFLAGS)
+
+AM_CONDITIONAL([USE_INTREE_RESAMPLE],[test "${enable_resample}" = "yes"])
+
# set defaults for use on all platforms
-SWITCH_AM_CFLAGS="-I${switch_srcdir}/src/include -I${prefix}/include"
-SWITCH_AM_CXXFLAGS="-I${switch_srcdir}/src/include -I${prefix}/include"
+SWITCH_AM_CFLAGS="-I${switch_srcdir}/src/include"
+SWITCH_AM_CXXFLAGS="-I${switch_srcdir}/src/include"
SWITCH_AM_LDFLAGS="-lm -L/usr/local/lib"
#set SOLINK variable based on compiler and host
@@ -151,6 +171,7 @@
AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(long long, 8)
+AC_CHECK_SIZEOF(time_t, 4)
AC_TYPE_SIZE_T
AC_CHECK_TYPE(ssize_t, int)
@@ -226,6 +247,16 @@
size_t_fmt='#error Can not determine the proper size for size_t'
fi
+if test "$ac_cv_sizeof_time_t" = "$ac_cv_sizeof_int"; then
+ time_t_fmt='#define TIME_T_FMT "d"'
+elif test "$ac_cv_sizeof_time_t" = "$ac_cv_sizeof_long"; then
+ time_t_fmt='#define TIME_T_FMT "ld"'
+elif test "$ac_cv_sizeof_time_t" = "$ac_cv_sizeof_long_long"; then
+ time_t_fmt='#define TIME_T_FMT "lld"'
+else
+ time_t_fmt='#error Can not determine the proper format specifier for time_t of size $ac_cv_sizeof_time_t'
+fi
+
# Basically, we have tried to figure out the correct format strings
# for SWITCH types which vary between platforms, but we don't always get
# it right. If you find that we don't get it right for your platform,
@@ -274,8 +305,7 @@
AC_SUBST(uint64_t_fmt)
AC_SUBST(ssize_t_fmt)
AC_SUBST(size_t_fmt)
-
-
+AC_SUBST(time_t_fmt)
AC_PATH_PROGS(ZCAT, gunzip gzcat gzip zcat)
AC_PATH_PROGS(TAR, gtar tar)
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_am_config.h.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_am_config.h.in (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_am_config.h.in Thu Mar 29 00:30:19 2007
@@ -15,5 +15,6 @@
@size_t_fmt@
@int64_t_fmt@
@uint64_t_fmt@
+@time_t_fmt@
#endif
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core.h Thu Mar 29 00:30:19 2007
@@ -104,17 +104,68 @@
struct switch_core_runtime;
struct switch_core_port_allocator;
+struct switch_core_scheduler_task {
+ time_t created;
+ time_t runtime;
+ uint32_t cmd_id;
+ char *group;
+ void *cmd_arg;
+ uint32_t task_id;
+};
+
+
/*!
\defgroup core1 Core Library
\ingroup FREESWITCH
\{
*/
-
///\defgroup mb1 Media Bugs
///\ingroup core1
///\{
+
+///\defgroup sched1 Scheduler
+///\ingroup core1
+///\{
+
+
+/*!
+ \brief Schedule a task in the future
+ \param runtime the time in epoch seconds to execute the task.
+ \param func the callback function to execute when the task is executed.
+ \param desc an arbitrary description of the task.
+ \param group a group id tag to link multiple tasks to a single entity.
+ \param cmd_id an arbitrary index number be used in the callback.
+ \param cmd_arg user data to be passed to the callback.
+ \param flags flags to alter behaviour
+ \return the id of the task
+*/
+SWITCH_DECLARE(uint32_t) switch_core_scheduler_add_task(time_t task_runtime,
+ switch_core_scheduler_func_t func,
+ char *desc,
+ char *group,
+ uint32_t cmd_id,
+ void *cmd_arg,
+ switch_scheduler_flag_t flags);
+
+/*!
+ \brief Delete a scheduled task
+ \param task_id the id of the task
+ \return SWITCH_STATUS_SUCCESS if the task was deleted.
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_scheduler_del_task_id(uint32_t task_id);
+
+/*!
+ \brief Delete a scheduled task based on the group name
+ \param group the group name
+ \return SWITCH_STATUS_SUCCESS if any tasks were deleted
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_scheduler_del_task_group(char *group);
+
+
+///\}
+
/*!
\brief Add a media bug to the session
\param session the session to add the bug to
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_ivr.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_ivr.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_ivr.h Thu Mar 29 00:30:19 2007
@@ -332,6 +332,28 @@
SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_t *session, char *extension, char *dialplan, char *context);
/*!
+ \brief Transfer an existing session to another location in the future
+ \param runtime the time (int epoch seconds) to transfer the call
+ \param uuid the uuid of the session to transfer
+ \param extension the new extension
+ \param dialplan the new dialplan (OPTIONAL, may be NULL)
+ \param context the new context (OPTIONAL, may be NULL)
+ \return the id of the task
+*/
+SWITCH_DECLARE(uint32_t) switch_ivr_schedule_transfer(time_t runtime, char *uuid, char *extension, char *dialplan, char *context);
+
+
+/*!
+ \brief Hangup an existing session in the future
+ \param runtime the time (int epoch seconds) to transfer the call
+ \param uuid the uuid of the session to hangup
+ \param cause the hanup cause code
+ \param bleg hangup up the B-Leg if possible
+ \return the id of the task
+*/
+SWITCH_DECLARE(uint32_t) switch_ivr_schedule_hangup(time_t runtime, char *uuid, switch_call_cause_t cause, switch_bool_t bleg);
+
+/*!
\brief Bridge two existing sessions
\param originator_uuid the uuid of the originator
\param originatee_uuid the uuid of the originator
@@ -384,6 +406,16 @@
SWITCH_DECLARE(switch_status_t) switch_ivr_unhold(switch_core_session_t *session);
/*!
+ \brief Signal the session to broadcast audio in the future
+ \param runtime when (in epoch time) to run the broadcast
+ \param uuid the uuid of the session to broadcast on
+ \param path the path data of the broadcast "/path/to/file.wav [<timer name>]" or "speak:<engine>|<voice>|<Text to say>"
+ \param flags flags to send to the request (SMF_ECHO_BRIDGED to send the broadcast to both sides of the call)
+ \return the id of the task
+*/
+SWITCH_DECLARE(uint32_t) switch_ivr_schedule_broadcast(time_t runtime, char *uuid, char *path, switch_media_flag_t flags);
+
+/*!
\brief Signal the session to broadcast audio
\param uuid the uuid of the session to broadcast on
\param path the path data of the broadcast "/path/to/file.wav [<timer name>]" or "speak:<engine>|<voice>|<Text to say>"
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_platform.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_platform.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_platform.h Thu Mar 29 00:30:19 2007
@@ -213,6 +213,12 @@
#define SWITCH_INT64_T_FMT "I64d"
#define SWITCH_UINT64_T_FMT "I64u"
+#ifdef _USE_32BIT_TIME_T
+#define TIME_T_FMT "d"
+#else
+#define TIME_T_FMT SWITCH_INT64_T_FMT
+#endif
+
#else
#ifndef SWITCH_SSIZE_T_FMT
#define SWITCH_SSIZE_T_FMT (sizeof (switch_ssize_t) == sizeof (long) ? "ld" : sizeof (switch_ssize_t) == sizeof (int) ? "d" : "lld")
@@ -230,6 +236,10 @@
#define SWITCH_UINT64_T_FMT (sizeof (long) == 8 ? "lu" : "llu")
#endif
+#ifndef TIME_T_FMT
+#define TIME_T_FMT "ld"
+#endif
+
#endif
#define SWITCH_TIME_T_FMT SWITCH_INT64_T_FMT
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h Thu Mar 29 00:30:19 2007
@@ -168,6 +168,12 @@
} switch_management_action_t;
typedef enum {
+ SSHF_NONE = 0,
+ SSHF_OWN_THREAD = (1 << 0),
+ SSHF_FREE_ARG = (1 << 1)
+} switch_scheduler_flag_t;
+
+typedef enum {
SMF_NONE = 0,
SMF_REBRIDGE = (1 << 0),
SMF_ECHO_ALEG = (1 << 1),
@@ -910,7 +916,8 @@
SWITCH_CAUSE_LOSE_RACE = 502,
SWITCH_CAUSE_MANAGER_REQUEST = 503,
SWITCH_CAUSE_BLIND_TRANSFER = 600,
- SWITCH_CAUSE_ATTENDED_TRANSFER = 601
+ SWITCH_CAUSE_ATTENDED_TRANSFER = 601,
+ SWITCH_CAUSE_ALLOTTED_TIMEOUT = 602
} switch_call_cause_t;
typedef enum {
@@ -979,6 +986,8 @@
typedef void (*switch_application_function_t)(switch_core_session_t *, char *);
typedef void (*switch_event_callback_t)(switch_event_t *);
typedef switch_caller_extension_t *(*switch_dialplan_hunt_function_t)(switch_core_session_t *, void *);
+typedef struct switch_core_scheduler_task switch_core_scheduler_task_t;
+typedef void (*switch_core_scheduler_func_t)(switch_core_scheduler_task_t *task);
typedef switch_status_t (*switch_state_handler_t)(switch_core_session_t *);
typedef switch_status_t (*switch_outgoing_channel_hook_t)(switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t *);
typedef switch_status_t (*switch_answer_channel_hook_t)(switch_core_session_t *);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_commands/mod_commands.c Thu Mar 29 00:30:19 2007
@@ -51,6 +51,9 @@
static switch_api_interface_t media_api_interface;
static switch_api_interface_t hold_api_interface;
static switch_api_interface_t broadcast_api_interface;
+static switch_api_interface_t sched_broadcast_api_interface;
+static switch_api_interface_t sched_transfer_api_interface;
+static switch_api_interface_t sched_hangup_api_interface;
static switch_status_t status_function(char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream)
{
@@ -245,6 +248,89 @@
return SWITCH_STATUS_SUCCESS;
}
+
+static switch_status_t sched_transfer_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
+{
+ switch_core_session_t *session = NULL;
+ char *argv[6] = {0};
+ int argc = 0;
+
+ if (isession) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+
+ if (switch_strlen_zero(cmd) || argc < 2 || argc > 5) {
+ stream->write_function(stream, "USAGE: %s\n", sched_transfer_api_interface.syntax);
+ } else {
+ char *uuid = argv[1];
+ char *dest = argv[2];
+ char *dp = argv[3];
+ char *context = argv[4];
+ time_t when;
+
+ if (*argv[0] == '+') {
+ when = time (NULL) + atol(argv[0] + 1);
+ } else {
+ when = atol(argv[0]);
+ }
+
+ if ((session = switch_core_session_locate(uuid))) {
+ switch_ivr_schedule_transfer(when, uuid, dest, dp, context);
+ stream->write_function(stream, "OK\n");
+ switch_core_session_rwunlock(session);
+ } else {
+ stream->write_function(stream, "No Such Channel!\n");
+ }
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t sched_hangup_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
+{
+ switch_core_session_t *session = NULL;
+ char *argv[4] = {0};
+ int argc = 0;
+
+ if (isession) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+
+ if (switch_strlen_zero(cmd) || argc < 1) {
+ stream->write_function(stream, "USAGE: %s\n", sched_hangup_api_interface.syntax);
+ } else {
+ char *uuid = argv[1];
+ char *cause_str = argv[2];
+ time_t when;
+ switch_call_cause_t cause = SWITCH_CAUSE_ALLOTTED_TIMEOUT;
+
+ if (*argv[0] == '+') {
+ when = time (NULL) + atol(argv[0] + 1);
+ } else {
+ when = atol(argv[0]);
+ }
+
+ if (cause_str) {
+ cause = switch_channel_str2cause(cause_str);
+ }
+
+ if ((session = switch_core_session_locate(uuid))) {
+ switch_ivr_schedule_hangup(when, uuid, cause, SWITCH_FALSE);
+ stream->write_function(stream, "OK\n");
+ switch_core_session_rwunlock(session);
+ } else {
+ stream->write_function(stream, "No Such Channel!\n");
+ }
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
static switch_status_t uuid_media_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{
char *argv[4] = {0};
@@ -313,6 +399,50 @@
return SWITCH_STATUS_SUCCESS;
}
+
+static switch_status_t sched_broadcast_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
+{
+ char *argv[4] = {0};
+ int argc = 0;
+ switch_status_t status = SWITCH_STATUS_FALSE;
+
+ if (isession) {
+ return status;
+ }
+
+ argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+
+ if (switch_strlen_zero(cmd) || argc < 3) {
+ stream->write_function(stream, "USAGE: %s\n", sched_broadcast_api_interface.syntax);
+ } else {
+ switch_media_flag_t flags = SMF_NONE;
+ time_t when;
+
+ if (*argv[0] == '+') {
+ when = time (NULL) + atol(argv[0] + 1);
+ } else {
+ when = atol(argv[0]);
+ }
+
+ if (argv[3]) {
+ if (!strcmp(argv[3], "both")) {
+ flags |= (SMF_ECHO_ALEG | SMF_ECHO_BLEG);
+ } else if (!strcmp(argv[3], "aleg")) {
+ flags |= SMF_ECHO_ALEG;
+ } else if (!strcmp(argv[3], "bleg")) {
+ flags |= SMF_ECHO_BLEG;
+ }
+ } else {
+ flags |= SMF_ECHO_ALEG;
+ }
+
+ status = switch_ivr_schedule_broadcast(when, argv[1], argv[2], flags);
+ stream->write_function(stream, "+OK Message Scheduled\n");
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
static switch_status_t uuid_hold_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{
char *argv[4] = {0};
@@ -707,12 +837,36 @@
return SWITCH_STATUS_SUCCESS;
}
+static switch_api_interface_t sched_transfer_api_interface = {
+ /*.interface_name */ "sched_transfer",
+ /*.desc */ "Schedule a broadcast event to a running call",
+ /*.function */ sched_transfer_function,
+ /*.syntax */ "[+]<time> <uuid> <extension> [<dialplan>] [<context>]",
+ /*.next */ NULL
+};
+
+static switch_api_interface_t sched_broadcast_api_interface = {
+ /*.interface_name */ "sched_broadcast",
+ /*.desc */ "Schedule a broadcast event to a running call",
+ /*.function */ sched_broadcast_function,
+ /*.syntax */ "[+]<time> <uuid> <path> [aleg|bleg|both]",
+ /*.next */ &sched_transfer_api_interface
+};
+
+static switch_api_interface_t sched_hangup_api_interface = {
+ /*.interface_name */ "sched_hangup",
+ /*.desc */ "Schedule a running call to hangup",
+ /*.function */ sched_hangup_function,
+ /*.syntax */ "[+]<time> <uuid> [<cause>]",
+ /*.next */ &sched_broadcast_api_interface
+};
+
static switch_api_interface_t version_api_interface = {
/*.interface_name */ "version",
/*.desc */ "Show version of the switch",
/*.function */ version_function,
/*.syntax */ "",
- /*.next */ NULL
+ /*.next */ &sched_hangup_api_interface
};
static switch_api_interface_t help_api_interface = {
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_conference/mod_conference.c Thu Mar 29 00:30:19 2007
@@ -4070,12 +4070,15 @@
switch_audio_resampler_t **resampler = read_codec->implementation->samples_per_second > conference->rate ?
&member.read_resampler : &member.mux_resampler;
- switch_resample_create(resampler,
+ if (switch_resample_create(resampler,
read_codec->implementation->samples_per_second,
read_codec->implementation->samples_per_second * 20,
conference->rate,
conference->rate * 20,
- member.pool);
+ member.pool) != SWITCH_STATUS_SUCCESS){
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to crete resampler!\n");
+ goto done;
+ }
/* Setup an audio buffer for the resampled audio */
if (switch_buffer_create_dynamic(&member.resample_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_dptools/mod_dptools.c Thu Mar 29 00:30:19 2007
@@ -96,6 +96,99 @@
}
}
+static void sched_transfer_function(switch_core_session_t *session, char *data)
+{
+ int argc;
+ char *argv[4] = {0};
+ char *mydata;
+
+ if (data && (mydata = switch_core_session_strdup(session, data))) {
+ if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 2) {
+ time_t when;
+
+ if (*argv[0] == '+') {
+ when = time (NULL) + atol(argv[0] + 1);
+ } else {
+ when = atol(argv[0]);
+ }
+
+ switch_ivr_schedule_transfer(when, switch_core_session_get_uuid(session), argv[1], argv[2], argv[3]);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Args\n");
+ }
+ }
+}
+
+static void sched_hangup_function(switch_core_session_t *session, char *data)
+{
+ int argc;
+ char *argv[5] = {0};
+ char *mydata;
+
+ if (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;
+ switch_bool_t bleg = SWITCH_FALSE;
+
+ if (*argv[0] == '+') {
+ when = time (NULL) + atol(argv[0] + 1);
+ } else {
+ when = atol(argv[0]);
+ }
+
+ if (argv[1]) {
+ cause = switch_channel_str2cause(argv[1]);
+ }
+
+ if (argv[2] && !strcasecmp(argv[2], "bleg")) {
+ bleg = SWITCH_TRUE;
+ }
+
+ switch_ivr_schedule_hangup(when, switch_core_session_get_uuid(session), cause, bleg);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No time specified.\n");
+ }
+ }
+}
+
+
+static void sched_broadcast_function(switch_core_session_t *session, char *data)
+{
+ int argc;
+ char *argv[6] = {0};
+ char *mydata;
+
+ if (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;
+
+ if (*argv[0] == '+') {
+ when = time (NULL) + atol(argv[0] + 1);
+ } else {
+ when = atol(argv[0]);
+ }
+
+ if (argv[2]) {
+ if (!strcmp(argv[2], "both")) {
+ flags |= (SMF_ECHO_ALEG | SMF_ECHO_BLEG);
+ } else if (!strcmp(argv[2], "aleg")) {
+ flags |= SMF_ECHO_ALEG;
+ } else if (!strcmp(argv[2], "bleg")) {
+ flags |= SMF_ECHO_BLEG;
+ }
+ } else {
+ flags |= SMF_ECHO_ALEG;
+ }
+
+ switch_ivr_schedule_broadcast(when, switch_core_session_get_uuid(session), argv[1], flags);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Args\n");
+ }
+ }
+}
+
static void sleep_function(switch_core_session_t *session, char *data)
{
@@ -509,6 +602,7 @@
}
}
+
static switch_api_interface_t strepoch_api_interface = {
/*.interface_name */ "strepoch",
/*.desc */ "Convert a date string into epoch time",
@@ -541,6 +635,39 @@
/*.next */ &dptools_api_interface
};
+
+
+static switch_application_interface_t sched_transfer_application_interface = {
+ /*.interface_name */ "sched_transfer",
+ /*.application_function */ sched_transfer_function,
+ /*.long_desc */ "Schedule a transfer in the future",
+ /*.short_desc */ "Schedule a transfer in the future",
+ /*.syntax */ "[+]<time> <extension> <dialplan> <context>",
+ /* flags */ SAF_SUPPORT_NOMEDIA,
+ /*.next */ NULL
+};
+
+static switch_application_interface_t sched_broadcast_application_interface = {
+ /*.interface_name */ "sched_broadcast",
+ /*.application_function */ sched_broadcast_function,
+ /*.long_desc */ "Schedule a broadcast in the future",
+ /*.short_desc */ "Schedule a broadcast in the future",
+ /*.syntax */ "[+]<time> <path> [aleg|bleg|both]",
+ /* flags */ SAF_SUPPORT_NOMEDIA,
+ /*.next */ &sched_transfer_application_interface
+};
+
+static switch_application_interface_t sched_hangup_application_interface = {
+ /*.interface_name */ "sched_hangup",
+ /*.application_function */ sched_hangup_function,
+ /*.long_desc */ "Schedule a hangup in the future",
+ /*.short_desc */ "Schedule a hangup in the future",
+ /*.syntax */ "[+]<time> [<cause>]",
+ /* flags */ SAF_SUPPORT_NOMEDIA,
+ /*.next */ &sched_broadcast_application_interface
+};
+
+
static const switch_application_interface_t queuedtmf_application_interface = {
/*.interface_name */ "queue_dtmf",
/*.application_function */ queue_dtmf_function,
@@ -548,7 +675,7 @@
/* short_desc */ "Queue dtmf to be sent",
/* syntax */ "<dtmf_data>",
/* flags */ SAF_SUPPORT_NOMEDIA,
- /*.next */ NULL
+ /*.next */ &sched_hangup_application_interface
};
static const switch_application_interface_t redirect_application_interface = {
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_ivrtest/mod_ivrtest.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_ivrtest/mod_ivrtest.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_ivrtest/mod_ivrtest.c Thu Mar 29 00:30:19 2007
@@ -233,6 +233,7 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Done\n");
}
+#ifdef BUGTEST
static switch_bool_t bug_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
{
switch_frame_t *frame;
@@ -249,9 +250,11 @@
return SWITCH_TRUE;
}
+#endif
static void bugtest_function(switch_core_session_t *session, char *data)
{
+#ifdef BUGTEST
switch_media_bug_t *bug;
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status;
@@ -264,6 +267,11 @@
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return;
}
+#endif
+ //switch_ivr_schedule_broadcast(time(NULL) + 10, switch_core_session_get_uuid(session), "/Users/anthm/sr8k.wav", SMF_ECHO_ALEG);
+ //switch_ivr_schedule_transfer(time(NULL) + 10, switch_core_session_get_uuid(session), "2000", NULL, NULL);
+ //switch_ivr_schedule_hangup(time(NULL) + 10, switch_core_session_get_uuid(session), SWITCH_CAUSE_ALLOTTED_TIMEOUT);
+
switch_ivr_play_file(session, NULL, data, NULL);
}
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/Makefile.am
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/Makefile.am (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/Makefile.am Thu Mar 29 00:30:19 2007
@@ -1,7 +1,16 @@
#we should set all these vars from configure, no reason to have these in each Makefile.am
-LIBTOOL=`if test -z "$(VERBOSE)" ; then echo $(SHELL) $(switch_builddir)/quiet_libtool ;else echo $(switch_builddir)/libtool; fi;`
+#LIBTOOL = compile=`echo $<|grep .c`;link=`echo $@|grep .la;echo $@|grep .so;echo $@|grep .dll`; if test -n "$$compile"; then echo Compiling $<;fi; if test -n "$$link"; then echo Creating $@;fi; `if test -z "$(VERBOSE)" ; then echo $(SHELL) $(switch_builddir)/quiet_libtool ;else echo $(switch_builddir)/libtool; fi;`
+#LIBTOOL=`if test -z "$(VERBOSE)" ; then echo $(SHELL) $(switch_builddir)/quiet_libtool ;else echo $(switch_builddir)/libtool; fi;`
+LIBTOOL = link=`echo $@|grep .la;echo $@|grep .so;echo $@|grep .dll`; \
+ if test -n "$$link"; then echo Creating $@;fi; \
+ `if test -z "$(VERBOSE)" ; \
+ then echo $(SHELL) $(switch_builddir)/quiet_libtool ;\
+ else echo $(switch_builddir)/libtool; fi;`
+
AM_MAKEFLAGS=`test -n "$(VERBOSE)" || echo -s`
-LINK_OUTPUT_REDIR=> $(MODNAME).log || error="yes" ; \
+
+# Dirty trick to override the link output
+LIBS+=> $(MODNAME).log || error="yes" ; \
if test -n "$(VERBOSE)" -o "$$error" = "yes"; then \
cat $(MODNAME).log ; \
fi ;\
@@ -11,8 +20,6 @@
moddir=$(prefix)/mod
-
-
MODNAME=mod_cdr
mod_LTLIBRARIES = mod_cdr.la
mod_cdr_la_SOURCES = mod_cdr.cpp cdrcontainer.cpp basecdr.cpp baseregistry.cpp pddcdr.cpp csvcdr.cpp xmlcdr.cpp sqlitecdr.cpp
@@ -30,12 +37,6 @@
#mod_cdr_la_CFLAGS += -DSWITCH_QUEUE_ENHANCED
#mod_cdr_la_LDFLAGS += -lcurl
-#Override link target so we can control the output
-
-$(MODNAME).la: $(mod_cdr_la_OBJECTS) $(mod_cdr_la_DEPENDENCIES)
- @echo Creating $(MODNAME).$(DYNAMIC_LIB_EXTEN)...
- @$(CXXLINK) -rpath $(moddir) $(mod_cdr_la_LDFLAGS) $(mod_cdr_la_OBJECTS) $(mod_cdr_la_LIBADD) $(LIBS) $(LINK_OUTPUT_REDIR)
-
#Override the linstall target so we just install the .so/.dylib
install-data-am: $(DESTDIR)$(PREFIX)/$(moddir)/$(MODNAME).$(DYNAMIC_LIB_EXTEN)
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_channel.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_channel.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_channel.c Thu Mar 29 00:30:19 2007
@@ -95,6 +95,7 @@
{ "MANAGER_REQUEST", SWITCH_CAUSE_MANAGER_REQUEST },
{ "BLIND_TRANSFER", SWITCH_CAUSE_BLIND_TRANSFER },
{ "ATTENDED_TRANSFER", SWITCH_CAUSE_ATTENDED_TRANSFER },
+ { "ALLOTTED_TIMEOUT", SWITCH_CAUSE_ALLOTTED_TIMEOUT},
{ NULL, 0 }
};
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core.c Thu Mar 29 00:30:19 2007
@@ -147,6 +147,19 @@
SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = {0};
+struct switch_core_scheduler_task_container {
+ switch_core_scheduler_task_t task;
+ time_t executed;
+ int in_thread;
+ int destroyed;
+ switch_core_scheduler_func_t func;
+ switch_memory_pool_t *pool;
+ uint32_t flags;
+ char *desc;
+ struct switch_core_scheduler_task_container *next;
+};
+typedef struct switch_core_scheduler_task_container switch_core_scheduler_task_container_t;
+
struct switch_core_runtime {
switch_time_t initiated;
uint32_t session_id;
@@ -169,6 +182,10 @@
uint32_t shutting_down;
uint8_t running;
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
+ switch_core_scheduler_task_container_t *task_list;
+ switch_mutex_t *task_mutex;
+ uint32_t task_id;
+ int task_thread_running;
};
/* Prototypes */
@@ -196,6 +213,238 @@
}
}
+static void send_heartbeat(void)
+{
+ switch_event_t *event;
+ switch_core_time_duration_t duration;
+
+ switch_core_measure_time(switch_core_uptime(), &duration);
+
+ if (switch_event_create(&event, SWITCH_EVENT_HEARTBEAT) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Event-Info", "System Ready");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Up-Time",
+ "%u year%s, "
+ "%u day%s, "
+ "%u hour%s, "
+ "%u minute%s, "
+ "%u second%s, "
+ "%u millisecond%s, "
+ "%u microsecond%s\n",
+ duration.yr, duration.yr == 1 ? "" : "s",
+ duration.day, duration.day == 1 ? "" : "s",
+ duration.hr, duration.hr == 1 ? "" : "s",
+ duration.min, duration.min == 1 ? "" : "s",
+ duration.sec, duration.sec == 1 ? "" : "s",
+ duration.ms, duration.ms == 1 ? "" : "s",
+ duration.mms, duration.mms == 1 ? "" : "s"
+ );
+
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Session-Count", "%u", switch_core_session_count());
+ switch_event_fire(&event);
+ }
+}
+
+static void heartbeat_callback(switch_core_scheduler_task_t *task)
+{
+ send_heartbeat();
+
+ /* reschedule this task */
+ task->runtime += 20;
+}
+
+static void switch_core_scheduler_execute(switch_core_scheduler_task_container_t *tp)
+{
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Executing task %u %s (%s)\n", tp->task.task_id, tp->desc, switch_str_nil(tp->task.group));
+
+ tp->func(&tp->task);
+
+ if (tp->task.runtime > tp->executed) {
+ tp->executed = 0;
+ } else {
+ tp->destroyed = 1;
+ }
+}
+
+static void *SWITCH_THREAD_FUNC task_own_thread(switch_thread_t *thread, void *obj)
+{
+ switch_core_scheduler_task_container_t *tp = (switch_core_scheduler_task_container_t *) obj;
+ switch_memory_pool_t *pool;
+
+ pool = tp->pool;
+ tp->pool = NULL;
+
+ switch_core_scheduler_execute(tp);
+ switch_core_destroy_memory_pool(&pool);
+ tp->in_thread = 0;
+
+ return NULL;
+}
+
+static int task_thread_loop(int done)
+{
+ switch_core_scheduler_task_container_t *tofree, *tp, *last = NULL;
+
+
+ switch_mutex_lock(runtime.task_mutex);
+ for (tp = runtime.task_list; tp; tp = tp->next) {
+ if (done) {
+ tp->destroyed = 1;
+ } else {
+ time_t now = time(NULL);
+ if (now >= tp->task.runtime && !tp->in_thread) {
+ tp->executed = now;
+ if (switch_test_flag(tp, SSHF_OWN_THREAD)) {
+ switch_thread_t *thread;
+ switch_threadattr_t *thd_attr;
+ assert(switch_core_new_memory_pool(&tp->pool) == SWITCH_STATUS_SUCCESS);
+ switch_threadattr_create(&thd_attr, tp->pool);
+ switch_threadattr_detach_set(thd_attr, 1);
+ tp->in_thread = 1;
+ switch_thread_create(&thread, thd_attr, task_own_thread, tp, tp->pool);
+ } else {
+ switch_core_scheduler_execute(tp);
+ }
+ }
+ }
+ }
+ switch_mutex_unlock(runtime.task_mutex);
+ switch_mutex_lock(runtime.task_mutex);
+ for (tp = runtime.task_list; tp; ) {
+ if (tp->destroyed && !tp->in_thread) {
+ tofree = tp;
+ tp = tp->next;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Deleting task %u %s (%s)\n",
+ tofree->task.task_id, tofree->desc, switch_str_nil(tofree->task.group));
+ if (last) {
+ last->next = tofree->next;
+ } else {
+ runtime.task_list = tofree->next;
+ }
+ switch_safe_free(tofree->task.group);
+ if (tofree->task.cmd_arg && switch_test_flag(tofree, SSHF_FREE_ARG)) {
+ free(tofree->task.cmd_arg);
+ }
+ switch_safe_free(tofree->desc);
+ free(tofree);
+ } else {
+ last = tp;
+ tp = tp->next;
+ }
+ }
+ switch_mutex_unlock(runtime.task_mutex);
+
+ return done;
+}
+
+static void *SWITCH_THREAD_FUNC switch_core_task_thread(switch_thread_t *thread, void *obj)
+{
+
+ runtime.task_thread_running = 1;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Starting task thread\n");
+ while(runtime.task_thread_running == 1) {
+ if (task_thread_loop(0)) {
+ break;
+ }
+ switch_yield(500000);
+ }
+
+ task_thread_loop(1);
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Task thread ending\n");
+ runtime.task_thread_running = 0;
+
+ return NULL;
+}
+
+static void switch_core_task_thread_launch(void)
+{
+ switch_thread_t *thread;
+ switch_threadattr_t *thd_attr;
+ switch_threadattr_create(&thd_attr, runtime.memory_pool);
+ switch_threadattr_detach_set(thd_attr, 1);
+ switch_thread_create(&thread, thd_attr, switch_core_task_thread, NULL, runtime.memory_pool);
+}
+
+SWITCH_DECLARE(uint32_t) switch_core_scheduler_add_task(time_t task_runtime,
+ switch_core_scheduler_func_t func,
+ char *desc,
+ char *group,
+ uint32_t cmd_id,
+ void *cmd_arg,
+ switch_scheduler_flag_t flags)
+{
+ switch_core_scheduler_task_container_t *container, *tp;
+
+ switch_mutex_lock(runtime.task_mutex);
+ assert((container = malloc(sizeof(*container))));
+ memset(container, 0, sizeof(*container));
+ assert(func);
+ container->func = func;
+ time(&container->task.created);
+ container->task.runtime = task_runtime;
+ container->task.group = strdup(group ? group : "none");
+ container->task.cmd_id = cmd_id;
+ container->task.cmd_arg = cmd_arg;
+ container->flags = flags;
+ container->desc = strdup(desc ? desc : "none");
+
+ for (tp = runtime.task_list; tp && tp->next; tp = tp->next);
+
+ if (tp) {
+ tp->next = container;
+ } else {
+ runtime.task_list = container;
+ }
+
+ for (container->task.task_id = 0; !container->task.task_id; container->task.task_id = ++runtime.task_id);
+
+ switch_mutex_unlock(runtime.task_mutex);
+
+ tp = container;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Added task %u %s (%s) to run at %"TIME_T_FMT"\n",
+ tp->task.task_id, tp->desc, switch_str_nil(tp->task.group), task_runtime);
+
+
+ return container->task.task_id;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_scheduler_del_task_id(uint32_t task_id)
+{
+ switch_core_scheduler_task_container_t *tp;
+ switch_status_t status = SWITCH_STATUS_FALSE;
+
+ switch_mutex_lock(runtime.task_mutex);
+ for (tp = runtime.task_list; tp; tp = tp->next) {
+ if (tp->task.task_id == task_id) {
+ tp->destroyed++;
+ status = SWITCH_STATUS_SUCCESS;
+ break;
+ }
+ }
+ switch_mutex_unlock(runtime.task_mutex);
+
+ return status;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_scheduler_del_task_group(char *group)
+{
+ switch_core_scheduler_task_container_t *tp;
+ switch_status_t status = SWITCH_STATUS_FALSE;
+
+ switch_mutex_lock(runtime.task_mutex);
+ for (tp = runtime.task_list; tp; tp = tp->next) {
+ if (!strcmp(tp->task.group, group)) {
+ tp->destroyed++;
+ status = SWITCH_STATUS_SUCCESS;
+ }
+ }
+ switch_mutex_unlock(runtime.task_mutex);
+
+ return status;
+}
+
+
static void switch_core_media_bug_destroy(switch_media_bug_t *bug)
{
switch_buffer_destroy(&bug->raw_read_buffer);
@@ -2148,7 +2397,8 @@
}
if (!session->read_codec && (*frame)->codec) {
- need_codec = TRUE;
+ status = SWITCH_STATUS_FALSE;
+ goto done;
}
if (session->bugs && !need_codec) {
@@ -2174,11 +2424,15 @@
switch (status) {
case SWITCH_STATUS_RESAMPLE:
if (!session->read_resampler) {
- switch_resample_create(&session->read_resampler,
+ if (switch_resample_create(&session->read_resampler,
read_frame->codec->implementation->samples_per_second,
read_frame->codec->implementation->bytes_per_frame * 20,
session->read_codec->implementation->samples_per_second,
- session->read_codec->implementation->bytes_per_frame * 20, session->pool);
+ session->read_codec->implementation->bytes_per_frame * 20, session->pool) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to allocate resampler\n");
+ status = SWITCH_STATUS_FALSE;
+ goto done;
+ }
}
case SWITCH_STATUS_SUCCESS:
session->raw_read_frame.samples = session->raw_read_frame.datalen / sizeof(int16_t);
@@ -2418,7 +2672,7 @@
}
if (!session->write_codec && frame->codec) {
- need_codec = TRUE;
+ return SWITCH_STATUS_FALSE;
}
if (session->bugs && !need_codec) {
@@ -2448,6 +2702,9 @@
session->write_codec->implementation->samples_per_second,
session->write_codec->implementation->bytes_per_frame * 20,
session->pool);
+ if (status != SWITCH_STATUS_SUCCESS) {
+ goto done;
+ }
}
break;
case SWITCH_STATUS_SUCCESS:
@@ -2652,6 +2909,9 @@
session->write_codec->implementation->samples_per_second,
session->write_codec->implementation->bytes_per_frame * 20,
session->pool);
+ if (status != SWITCH_STATUS_SUCCESS) {
+ goto done;
+ }
}
break;
case SWITCH_STATUS_SUCCESS:
@@ -3143,11 +3403,10 @@
switch_event_t *event;
const switch_application_interface_t *application_interface;
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Standard EXECUTE\n");
+
if ((extension = switch_channel_get_caller_extension(session->channel)) == 0) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Extension!\n");
- switch_channel_hangup(session->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+ switch_channel_hangup(session->channel, SWITCH_CAUSE_NORMAL_CLEARING);
return;
}
@@ -3721,6 +3980,8 @@
switch_event_t *event;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Close Channel %s\n", switch_channel_get_name((*session)->channel));
+
+ switch_core_scheduler_del_task_group((*session)->uuid_str);
switch_mutex_lock(runtime.session_table_mutex);
switch_core_hash_delete(runtime.session_table, (*session)->uuid_str);
@@ -4133,7 +4394,6 @@
char *sqlbuf = (char *) malloc(sql_len);
char *sql;
switch_size_t newlen;
- uint32_t loops = 0;
if (!runtime.event_db) {
runtime.event_db = switch_core_db_handle();
@@ -4188,38 +4448,6 @@
*sqlbuf = '\0';
}
- if (loops++ >= 5000) {
- switch_event_t *event;
- switch_core_time_duration_t duration;
-
- switch_core_measure_time(switch_core_uptime(), &duration);
-
- if (switch_event_create(&event, SWITCH_EVENT_HEARTBEAT) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Event-Info", "System Ready");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Up-Time",
- "%u year%s, "
- "%u day%s, "
- "%u hour%s, "
- "%u minute%s, "
- "%u second%s, "
- "%u millisecond%s, "
- "%u microsecond%s\n",
- duration.yr, duration.yr == 1 ? "" : "s",
- duration.day, duration.day == 1 ? "" : "s",
- duration.hr, duration.hr == 1 ? "" : "s",
- duration.min, duration.min == 1 ? "" : "s",
- duration.sec, duration.sec == 1 ? "" : "s",
- duration.ms, duration.ms == 1 ? "" : "s",
- duration.mms, duration.mms == 1 ? "" : "s"
- );
-
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Session-Count", "%u", switch_core_session_count());
- switch_event_fire(&event);
- }
-
- loops = 0;
- }
-
if (nothing_in_queue) {
switch_yield(1000);
}
@@ -4662,11 +4890,17 @@
runtime.running = 1;
switch_core_hash_init(&runtime.session_table, runtime.memory_pool);
switch_mutex_init(&runtime.session_table_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool);
+ switch_mutex_init(&runtime.task_mutex, SWITCH_MUTEX_NESTED, runtime.memory_pool);
#ifdef CRASH_PROT
switch_core_hash_init(&runtime.stack_table, runtime.memory_pool);
#endif
+
+
+ switch_core_task_thread_launch();
runtime.initiated = switch_time_now();
+ switch_core_scheduler_add_task(time(NULL), heartbeat_callback, "heartbeat", "core", 0, NULL, SSHF_NONE);
+
switch_uuid_get(&uuid);
switch_uuid_format(runtime.uuid_str, &uuid);
@@ -4826,11 +5060,28 @@
while (switch_queue_size(runtime.sql_queue) > 0) {
switch_yield(10000);
}
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping Task Thread\n");
+ if (runtime.task_thread_running == 1) {
+ int sanity = 0;
+
+ runtime.task_thread_running = -1;
+
+ while(runtime.task_thread_running) {
+ switch_yield(100000);
+ if (++sanity > 10) {
+ break;
+ }
+ }
+ }
+
switch_core_db_close(runtime.db);
switch_core_db_close(runtime.event_db);
switch_xml_destroy();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Finalizing Shutdown.\n");
switch_log_shutdown();
+
+
if(runtime.console != stdout && runtime.console != stderr) {
fclose(runtime.console);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr.c Thu Mar 29 00:30:19 2007
@@ -130,7 +130,7 @@
if (cause_name) {
cause = switch_channel_str2cause(cause_name);
}
-
+
switch_channel_hangup(channel, cause);
} else if (cmd_hash == CMD_NOMEDIA) {
char *uuid = switch_event_get_header(event, "nomedia-uuid");
@@ -3240,6 +3240,157 @@
return SWITCH_STATUS_SUCCESS;
}
+struct hangup_helper {
+ char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
+ switch_bool_t bleg;
+ switch_call_cause_t cause;
+};
+
+static void sch_hangup_callback(switch_core_scheduler_task_t *task)
+{
+ struct hangup_helper *helper;
+ switch_core_session_t *session, *other_session;
+ char *other_uuid;
+
+ assert(task);
+
+ helper = (struct hangup_helper *) task->cmd_arg;
+
+ if ((session = switch_core_session_locate(helper->uuid_str))) {
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+
+ if (helper->bleg) {
+ if ((other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) &&
+ (other_session = switch_core_session_locate(other_uuid))) {
+ switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
+ switch_channel_hangup(other_channel, helper->cause);
+ switch_core_session_rwunlock(other_session);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No channel to hangup\n");
+ }
+ } else {
+ switch_channel_hangup(channel, helper->cause);
+ }
+
+ switch_core_session_rwunlock(session);
+ }
+}
+
+SWITCH_DECLARE(uint32_t) switch_ivr_schedule_hangup(time_t runtime, char *uuid, switch_call_cause_t cause, switch_bool_t bleg)
+{
+ struct hangup_helper *helper;
+ size_t len = sizeof(*helper);
+
+ assert((helper = malloc(len)));
+ memset(helper, 0, len);
+
+ switch_copy_string(helper->uuid_str, uuid, sizeof(helper->uuid_str));
+ helper->cause = cause;
+ helper->bleg = bleg;
+
+ return switch_core_scheduler_add_task(runtime, sch_hangup_callback, (char *)__SWITCH_FUNC__, uuid, 0, helper, SSHF_FREE_ARG);
+}
+
+struct transfer_helper {
+ char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
+ char *extension;
+ char *dialplan;
+ char *context;
+};
+
+static void sch_transfer_callback(switch_core_scheduler_task_t *task)
+{
+ struct transfer_helper *helper;
+ switch_core_session_t *session;
+
+ assert(task);
+
+ helper = (struct transfer_helper *) task->cmd_arg;
+
+ if ((session = switch_core_session_locate(helper->uuid_str))) {
+ switch_ivr_session_transfer(session, helper->extension, helper->dialplan, helper->context);
+ switch_core_session_rwunlock(session);
+ }
+
+}
+
+SWITCH_DECLARE(uint32_t) switch_ivr_schedule_transfer(time_t runtime, char *uuid, char *extension, char *dialplan, char *context)
+{
+ struct transfer_helper *helper;
+ size_t len = sizeof(*helper);
+ char *cur = NULL;
+
+ if (extension) {
+ len += strlen(extension) + 1;
+ }
+
+ if (dialplan) {
+ len += strlen(dialplan) + 1;
+ }
+
+ if (context) {
+ len += strlen(context) + 1;
+ }
+
+ assert((helper = malloc(len)));
+ memset(helper, 0, len);
+
+ switch_copy_string(helper->uuid_str, uuid, sizeof(helper->uuid_str));
+
+ cur = (char *) helper + sizeof(*helper);
+
+ if (extension) {
+ helper->extension = cur;
+ switch_copy_string(helper->extension, extension, strlen(extension) + 1);
+ cur += strlen(helper->extension) + 1;
+ }
+
+ if (dialplan) {
+ helper->dialplan = cur;
+ switch_copy_string(helper->dialplan, dialplan, strlen(dialplan) + 1);
+ cur += strlen(helper->dialplan) + 1;
+ }
+
+ if (context) {
+ helper->context = cur;
+ switch_copy_string(helper->context, context, strlen(context)+1);
+ }
+
+ return switch_core_scheduler_add_task(runtime, sch_transfer_callback, (char *)__SWITCH_FUNC__, uuid, 0, helper, SSHF_FREE_ARG);
+}
+
+
+struct broadcast_helper {
+ char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
+ char *path;
+ switch_media_flag_t flags;
+};
+
+static void sch_broadcast_callback(switch_core_scheduler_task_t *task)
+{
+ struct broadcast_helper *helper;
+ assert(task);
+
+ helper = (struct broadcast_helper *) task->cmd_arg;
+ switch_ivr_broadcast(helper->uuid_str, helper->path, helper->flags);
+}
+
+SWITCH_DECLARE(uint32_t) switch_ivr_schedule_broadcast(time_t runtime, char *uuid, char *path, switch_media_flag_t flags)
+{
+ struct broadcast_helper *helper;
+ size_t len = sizeof(*helper) + strlen(path) + 1;
+
+ assert((helper = malloc(len)));
+ memset(helper, 0, len);
+
+ switch_copy_string(helper->uuid_str, uuid, sizeof(helper->uuid_str));
+ helper->flags = flags;
+ helper->path = (char *) helper + sizeof(*helper);
+ switch_copy_string(helper->path, path, len - sizeof(helper));
+
+
+ return switch_core_scheduler_add_task(runtime, sch_broadcast_callback, (char *)__SWITCH_FUNC__, uuid, 0, helper, SSHF_FREE_ARG);
+}
SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, switch_media_flag_t flags)
{
@@ -3249,9 +3400,15 @@
switch_event_t *event;
switch_core_session_t *other_session = NULL;
char *other_uuid = NULL;
+ char *app = "playback";
+
+ assert(path);
if ((session = switch_core_session_locate(uuid))) {
- char *app;
+ char *cause = NULL;
+ char *mypath = strdup(path);
+ char *p;
+
master = session;
channel = switch_core_session_get_channel(session);
@@ -3261,11 +3418,17 @@
switch_ivr_media(uuid, SMF_REBRIDGE);
}
- if (!strncasecmp(path, "speak:", 6)) {
- path += 6;
- app = "speak";
- } else {
- app = "playback";
+ if ((p = strchr(mypath, ':'))) {
+ app = mypath;
+ *p++ = '\0';
+ path = p;
+ }
+
+ if ((cause = strchr(app, '!'))) {
+ *cause++ = '\0';
+ if (!cause) {
+ cause = "normal_clearing";
+ }
}
if ((flags & SMF_ECHO_BLEG) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE))
@@ -3299,8 +3462,21 @@
}
}
+ if (cause) {
+ if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "hangup");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", cause);
+
+ switch_core_session_queue_private_event(session, &event);
+ }
+ }
+
switch_core_session_rwunlock(session);
+ switch_safe_free(mypath);
}
+
+
return SWITCH_STATUS_SUCCESS;
}
@@ -3449,11 +3625,16 @@
switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, NULL);
switch_channel_set_variable(other_channel, SWITCH_BRIDGE_VARIABLE, NULL);
- switch_channel_hangup(other_channel, switch_channel_get_cause(channel));
+ if (switch_channel_get_state(other_channel) < CS_HANGUP &&
+ switch_true(switch_channel_get_variable(other_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE))) {
+ switch_channel_hangup(other_channel, switch_channel_get_cause(channel));
+ } else {
+ switch_channel_set_state(other_channel, CS_EXECUTE);
+ }
switch_core_session_rwunlock(other_session);
}
-
+
return SWITCH_STATUS_SUCCESS;
}
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_resample.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_resample.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_resample.c Thu Mar 29 00:30:19 2007
@@ -31,7 +31,12 @@
*/
#include <switch.h>
#include <switch_resample.h>
+#ifndef WIN32
+#include <switch_private.h>
+#endif
+#ifndef DISABLE_RESAMPLE
#include <libresample.h>
+#endif
#define NORMFACT (float)0x8000
#define MAXSAMPLE (float)0x7FFF
#define MAXSAMPLEC (char)0x7F
@@ -52,6 +57,10 @@
switch_size_t from_size,
int to_rate, uint32_t to_size, switch_memory_pool_t *pool)
{
+#ifdef DISABLE_RESAMPLE
+ *new_resampler = NULL;
+ return SWITCH_STATUS_NOTIMPL;
+#else
switch_audio_resampler_t *resampler;
double lto_rate, lfrom_rate;
@@ -75,12 +84,16 @@
*new_resampler = resampler;
return SWITCH_STATUS_SUCCESS;
+#endif
}
SWITCH_DECLARE(uint32_t) switch_resample_process(switch_audio_resampler_t *resampler, float *src, int srclen, float *dst,
uint32_t dstlen, int last)
{
+#ifdef DISABLE_RESAMPLE
+ return 0;
+#else
int o = 0, srcused = 0, srcpos = 0, out = 0;
for (;;) {
@@ -99,11 +112,14 @@
}
}
return out;
+#endif
}
SWITCH_DECLARE(void) switch_resample_destroy(switch_audio_resampler_t *resampler)
{
+#ifndef DISABLE_RESAMPLE
resample_close(resampler->resampler);
+#endif
}
1
0
[commit] r4781 - in freeswitch/branches/mikej/sofiasip-upgrade: . libs/libdingaling/src src src/include src/mod/endpoints/mod_sofia src/mod/languages/mod_spidermonkey
by Freeswitch SVN 28 Mar '07
by Freeswitch SVN 28 Mar '07
28 Mar '07
Author: mikej
Date: Wed Mar 28 13:40:13 2007
New Revision: 4781
Modified:
freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am
freeswitch/branches/mikej/sofiasip-upgrade/libs/libdingaling/src/libdingaling.c
freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core.h
freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_module_interfaces.h
freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
freeswitch/branches/mikej/sofiasip-upgrade/src/switch_channel.c
freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core.c
freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr.c
Log:
merged changes from trunk revisions 4772-4780.
Modified: freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am Wed Mar 28 13:40:13 2007
@@ -221,3 +221,9 @@
megaclean: eclean modclean
rm -f `find ./libs -name \*.la`
+
+
+# Special targets
+
+coffee me_a_sandwich me_a_sammich:
+ @echo "Who do you think I am? Make it yourself!"
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/libdingaling/src/libdingaling.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/libdingaling/src/libdingaling.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/libdingaling/src/libdingaling.c Wed Mar 28 13:40:13 2007
@@ -1218,15 +1218,12 @@
static void on_log(ldl_handle_t *handle, const char *data, size_t size, int is_incoming)
{
- if (iks_is_secure(handle->parser)) {
- fprintf(stderr, "Sec");
+ if (globals.debug) {
+ globals.logger(DL_LOG_DEBUG, "\n%s%s[%s]\n",
+ iks_is_secure(handle->parser) ? "Sec" : "",
+ is_incoming ? "RECV" : "SEND",
+ data);
}
- if (is_incoming) {
- fprintf(stderr, "RECV");
- } else {
- fprintf(stderr, "SEND");
- }
- fprintf(stderr, "[%s]\n", data);
}
static void j_setup_filter(ldl_handle_t *handle)
@@ -1423,16 +1420,18 @@
break;
case IKS_NET_NODNS:
globals.logger(DL_LOG_DEBUG, "hostname lookup failed\n");
+ microsleep(1000);
+ goto fail;
case IKS_NET_NOCONN:
globals.logger(DL_LOG_DEBUG, "connection failed\n");
+ microsleep(1000);
+ goto fail;
default:
- globals.logger(DL_LOG_DEBUG, "io error %d\n", e);
- microsleep(500);
- continue;
+ globals.logger(DL_LOG_DEBUG, "io error 1 %d\n", e);
+ microsleep(1000);
+ goto fail;
}
-
-
handle->counter = opt_timeout;
if (ldl_test_flag(handle, LDL_FLAG_TLS)) {
launch_queue_thread(handle);
@@ -1456,9 +1455,9 @@
}
if (IKS_OK != e) {
- globals.logger(DL_LOG_DEBUG, "io error %d\n", e);
- microsleep(500);
- break;
+ globals.logger(DL_LOG_DEBUG, "io error 2 %d\n", e);
+ microsleep(1000);
+ goto fail;
}
@@ -1481,10 +1480,12 @@
}
}
+ fail:
iks_disconnect(handle->parser);
iks_parser_delete(handle->parser);
ldl_clear_flag_locked(handle, LDL_FLAG_CONNECTED);
ldl_clear_flag_locked(handle, LDL_FLAG_AUTHORIZED);
+ handle->state = CS_NEW;
}
ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_core.h Wed Mar 28 13:40:13 2007
@@ -856,6 +856,15 @@
\return SWITCH_STATUS_SUCCESS on suceess
*/
SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_send_dtmf(switch_core_session_t *session, switch_send_dtmf_hook_t send_dtmf);
+
+/*!
+ \brief Add an event hook to be executed when a session receives a state change signal
+ \param session session to bind hook to
+ \param state_change hook to bind
+ \return SWITCH_STATUS_SUCCESS on suceess
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_state_change(switch_core_session_t *session,
+ switch_answer_channel_hook_t state_change);
///\}
///\defgroup hashf Hash Functions
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_module_interfaces.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_module_interfaces.h Wed Mar 28 13:40:13 2007
@@ -145,6 +145,13 @@
struct switch_io_event_hook_send_dtmf *next;
};
+/*! \brief Node in which to store state change callback hooks */
+struct switch_io_event_hook_state_change {
+ /*! the send dtmf channel callback hook*/
+ switch_state_change_hook_t state_change;
+ struct switch_io_event_hook_state_change *next;
+};
+
/*! \brief A table of lists of io_event_hooks to store the event hooks associated with a session */
struct switch_io_event_hooks {
/*! a list of outgoing channel hooks */
@@ -167,6 +174,8 @@
switch_io_event_hook_waitfor_write_t *waitfor_write;
/*! a list of send dtmf hooks */
switch_io_event_hook_send_dtmf_t *send_dtmf;
+ /*! a list of state change hooks */
+ switch_io_event_hook_state_change_t *state_change;
};
/*! \brief A table of i/o routines that an endpoint interface can implement */
@@ -191,6 +200,8 @@
switch_status_t (*receive_message)(switch_core_session_t *, switch_core_session_message_t *);
/*! queue a message for another session*/
switch_status_t (*receive_event)(switch_core_session_t *, switch_event_t *);
+ /*! change a sessions channel state */
+ switch_status_t (*state_change)(switch_core_session_t *);
};
/*! \brief Abstraction of an module endpoint interface
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h Wed Mar 28 13:40:13 2007
@@ -954,6 +954,7 @@
typedef struct switch_io_event_hook_waitfor_read switch_io_event_hook_waitfor_read_t;
typedef struct switch_io_event_hook_waitfor_write switch_io_event_hook_waitfor_write_t;
typedef struct switch_io_event_hook_send_dtmf switch_io_event_hook_send_dtmf_t;
+typedef struct switch_io_event_hook_state_change switch_io_event_hook_state_change_t;
typedef struct switch_io_routines switch_io_routines_t;
typedef struct switch_io_event_hooks switch_io_event_hooks_t;
typedef struct switch_speech_handle switch_speech_handle_t;
@@ -989,6 +990,7 @@
typedef switch_status_t (*switch_waitfor_read_hook_t)(switch_core_session_t *, int, int);
typedef switch_status_t (*switch_waitfor_write_hook_t)(switch_core_session_t *, int, int);
typedef switch_status_t (*switch_send_dtmf_hook_t)(switch_core_session_t *, char *);
+typedef switch_status_t (*switch_state_change_hook_t)(switch_core_session_t *);
typedef struct switch_stream_handle switch_stream_handle_t;
typedef switch_status_t (*switch_stream_handle_write_function_t)(switch_stream_handle_t *handle, const char *fmt, ...);
typedef switch_status_t (*switch_api_function_t)(char *in, switch_core_session_t *session, switch_stream_handle_t *stream);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_sofia/mod_sofia.c Wed Mar 28 13:40:13 2007
@@ -2565,8 +2565,14 @@
for (map = m->m_rtpmaps; map; map = map->rm_next) {
int32_t i;
const switch_codec_implementation_t *mimp = NULL, *near_match = NULL;
+ const char * rm_encoding;
- if (!te && !strcasecmp(map->rm_encoding, "telephone-event")) {
+
+ if (!(rm_encoding = map->rm_encoding)) {
+ rm_encoding = "";
+ }
+
+ if (!te && !strcasecmp(rm_encoding, "telephone-event")) {
te = tech_pvt->te = (switch_payload_t)map->rm_pt;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set 2833 dtmf payload to %u\n", te);
if (tech_pvt->rtp_session) {
@@ -2574,7 +2580,7 @@
}
}
- if (!cng_pt && !strcasecmp(map->rm_encoding, "CN")) {
+ if (!cng_pt && !strcasecmp(rm_encoding, "CN")) {
cng_pt = tech_pvt->cng_pt = (switch_payload_t)map->rm_pt;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set comfort noise payload to %u\n", cng_pt);
if (tech_pvt->rtp_session) {
@@ -2593,11 +2599,11 @@
for (i = 0; i < tech_pvt->num_codecs; i++) {
const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Codec Compare [%s:%d]/[%s:%d]\n",
- map->rm_encoding, map->rm_pt, imp->iananame, imp->ianacode);
+ rm_encoding, map->rm_pt, imp->iananame, imp->ianacode);
if (map->rm_pt < 96) {
match = (map->rm_pt == imp->ianacode) ? 1 : 0;
} else {
- match = strcasecmp(map->rm_encoding, imp->iananame) ? 0 : 1;
+ match = strcasecmp(rm_encoding, imp->iananame) ? 0 : 1;
}
if (match && (map->rm_rate == imp->samples_per_second)) {
@@ -2639,7 +2645,7 @@
}
if (mimp) {
- if ((tech_pvt->rm_encoding = switch_core_session_strdup(session, (char *)map->rm_encoding))) {
+ if ((tech_pvt->rm_encoding = switch_core_session_strdup(session, (char *)rm_encoding))) {
char tmp[50];
tech_pvt->pt = (switch_payload_t)map->rm_pt;
tech_pvt->rm_rate = map->rm_rate;
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Wed Mar 28 13:40:13 2007
@@ -43,6 +43,7 @@
static void session_destroy(JSContext *cx, JSObject *obj);
static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
+static JSBool session_originate(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
static switch_api_interface_t js_run_interface;
static struct {
@@ -79,7 +80,8 @@
typedef struct sm_loadable_module sm_loadable_module_t;
typedef enum {
- S_HUP = (1 << 0)
+ S_HUP = (1 << 0),
+ S_FREE = (1 << 1)
} session_flag_t;
struct input_callback_state {
@@ -640,7 +642,8 @@
jsval argv[4];
JSObject *Event = NULL;
- if (!jss) {
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
return SWITCH_STATUS_FALSE;
}
@@ -822,15 +825,15 @@
switch_size_t has;
switch_channel_t *channel;
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
- if (!switch_channel_ready(channel)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
- *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
- return JS_TRUE;
- }
-
while ((has = switch_channel_has_dtmf(channel))) {
switch_channel_dequeue_dtmf(channel, buf, sizeof(buf));
}
@@ -845,14 +848,14 @@
switch_event_t *event;
switch_channel_t *channel;
+ if (!jss || !jss->session) {
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
- if (!switch_channel_ready(channel)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
- *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
- return JS_TRUE;
- }
while (switch_core_session_dequeue_event(jss->session, &event) == SWITCH_STATUS_SUCCESS) {
switch_event_destroy(&event);
@@ -877,6 +880,12 @@
int32 limit = 0;
switch_input_args_t args = {0};
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -953,6 +962,13 @@
JSFunction *function;
switch_input_args_t args = {0};
+
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -1014,6 +1030,12 @@
JSFunction *function;
switch_input_args_t args = {0};
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -1074,6 +1096,55 @@
return JS_TRUE;
}
+static void check_hangup_hook(struct js_session *jss)
+{
+ jsval argv[2] = {0};
+ int argc = 0;
+ jsval ret;
+ if (jss->on_hangup ) {
+ argv[argc++] = OBJECT_TO_JSVAL(jss->obj);
+ JS_CallFunction(jss->cx, jss->obj, jss->on_hangup, argc, argv, &ret);
+ }
+}
+
+static switch_status_t hanguphook(switch_core_session_t *session)
+{
+ switch_channel_t *channel;
+ struct js_session *jss = NULL;
+
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+ if (switch_channel_get_state(channel) == CS_HANGUP) {
+ if ((jss = switch_channel_get_private(channel, "jss"))) {
+ check_hangup_hook(jss);
+ }
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+static JSBool session_hanguphook(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+ JSFunction *function;
+ struct js_session *jss;
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+
+ if ((jss = JS_GetPrivate(cx, obj)) && jss->session) {
+ if (argc > 0) {
+ if ((function = JS_ValueToFunction(cx, argv[0]))) {
+ switch_channel_t *channel = switch_core_session_get_channel(jss->session);
+ assert(channel != NULL);
+ jss->on_hangup = function;
+ switch_channel_set_private(channel, "jss", jss);
+ switch_core_session_add_event_hook_state_change(jss->session, hanguphook);
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ }
+ }
+ }
+
+ return JS_TRUE;
+}
+
static JSBool session_streamfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
struct js_session *jss = JS_GetPrivate(cx, obj);
@@ -1088,6 +1159,12 @@
JSFunction *function;
switch_input_args_t args = {0};
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -1147,16 +1224,15 @@
struct js_session *jss = JS_GetPrivate(cx, obj);
switch_channel_t *channel;
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
- if (!switch_channel_ready(channel)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
- *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
- return JS_TRUE;
- }
-
-
if (argc > 1) {
char *var, *val;
@@ -1176,16 +1252,14 @@
struct js_session *jss = JS_GetPrivate(cx, obj);
switch_channel_t *channel;
+ if (!jss || !jss->session) {
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
- if (!switch_channel_ready(channel)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
- *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
- return JS_TRUE;
- }
-
-
if (argc > 0) {
char *var, *val;
@@ -1220,6 +1294,12 @@
JSFunction *function;
switch_input_args_t args = {0};
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -1286,6 +1366,12 @@
int32 digits = 0, timeout = 5000;
switch_channel_t *channel;
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -1321,11 +1407,42 @@
return JS_FALSE;
}
+static JSBool session_autohangup(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+ struct js_session *jss = JS_GetPrivate(cx, obj);
+ *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
+
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
+ if (argv[0]) {
+ JSBool tf;
+ JS_ValueToBoolean(cx, argv[0], &tf);
+ if (tf == JS_TRUE) {
+ switch_set_flag(jss, S_HUP);
+ } else {
+ switch_clear_flag(jss, S_HUP);
+ }
+ *rval = BOOLEAN_TO_JSVAL(tf);
+ }
+
+ return JS_TRUE;
+}
+
static JSBool session_answer(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
struct js_session *jss = JS_GetPrivate(cx, obj);
switch_channel_t *channel;
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -1349,6 +1466,11 @@
/*Always a pessimist... sheesh!*/
*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ return JS_TRUE;
+ }
+
if (switch_ivr_generate_xml_cdr(jss->session, &cdr) == SWITCH_STATUS_SUCCESS) {
char *xml_text;
if ((xml_text = switch_xml_toxml(cdr))) {
@@ -1366,6 +1488,12 @@
struct js_session *jss = JS_GetPrivate(cx, obj);
switch_channel_t *channel;
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -1384,6 +1512,12 @@
unsigned int elapsed;
int32 timeout = 60;
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -1419,6 +1553,12 @@
unsigned int elapsed;
int32 timeout = 60;
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -1451,6 +1591,12 @@
switch_channel_t *channel;
struct js_session *jss = JS_GetPrivate(cx, obj);
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -1468,6 +1614,12 @@
struct js_session *jss = JS_GetPrivate(cx, obj);
jsrefcount saveDepth;
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
if ((application_interface = switch_loadable_module_get_application_interface(app_name))) {
if (application_interface->application_function) {
saveDepth = JS_SuspendRequest(cx);
@@ -1486,17 +1638,12 @@
{
struct js_session *jss = JS_GetPrivate(cx, obj);
switch_event_t *event;
- switch_channel_t *channel;
-
- channel = switch_core_session_get_channel(jss->session);
- assert(channel != NULL);
-
- if (!switch_channel_ready(channel)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
- *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
- return JS_TRUE;
- }
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
if (switch_core_session_dequeue_event(jss->session, &event) == SWITCH_STATUS_SUCCESS) {
JSObject *Event;
@@ -1528,6 +1675,12 @@
JSObject *Event;
struct event_obj *eo;
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
if (argc > 0) {
if (JS_ValueToObject(cx, argv[0], &Event)) {
if ((eo = JS_GetPrivate(cx, Event))) {
@@ -1554,6 +1707,12 @@
char *cause_name = NULL;
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
+ if (!jss || !jss->session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+ return JS_TRUE;
+ }
+
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -1722,10 +1881,13 @@
/*********************************************************************************/
enum session_tinyid {
SESSION_NAME, SESSION_STATE,
- PROFILE_DIALPLAN, PROFILE_CID_NAME, PROFILE_CID_NUM, PROFILE_IP, PROFILE_ANI, PROFILE_ANI_II, PROFILE_DEST, SESSION_UUID
+ PROFILE_DIALPLAN, PROFILE_CID_NAME, PROFILE_CID_NUM, PROFILE_IP, PROFILE_ANI, PROFILE_ANI_II, PROFILE_DEST, SESSION_UUID, SESSION_CAUSE
};
static JSFunctionSpec session_methods[] = {
+ {"originate", session_originate, 2},
+ {"setHangupHook", session_hanguphook, 1},
+ {"setAutoHangup", session_autohangup, 1},
{"sayPhrase", session_sayphrase, 1},
{"streamFile", session_streamfile, 1},
{"collectInput", session_collect_input, 1},
@@ -1760,6 +1922,7 @@
{"aniii", PROFILE_ANI_II, JSPROP_READONLY|JSPROP_PERMANENT},
{"destination", PROFILE_DEST, JSPROP_READONLY|JSPROP_PERMANENT},
{"uuid", SESSION_UUID, JSPROP_READONLY|JSPROP_PERMANENT},
+ {"cause", SESSION_CAUSE, JSPROP_READONLY|JSPROP_PERMANENT},
{0}
};
@@ -1767,29 +1930,40 @@
{
struct js_session *jss = JS_GetPrivate(cx, obj);
int param = 0;
- JSBool res = JS_TRUE;
- switch_channel_t *channel;
- switch_caller_profile_t *caller_profile;
- char *name;
-
- if (!jss || !jss->session) {
- return JS_FALSE;
+ switch_channel_t *channel = NULL;
+ switch_caller_profile_t *caller_profile = NULL;
+ char *name = NULL;
+
+ if (jss && jss->session) {
+ channel = switch_core_session_get_channel(jss->session);
+ assert(channel != NULL);
+ caller_profile = switch_channel_get_caller_profile(channel);
}
- channel = switch_core_session_get_channel(jss->session);
- assert(channel != NULL);
-
- caller_profile = switch_channel_get_caller_profile(channel);
-
name = JS_GetStringBytes(JS_ValueToString(cx, id));
+
/* numbers are our props anything else is a method */
if (name[0] >= 48 && name[0] <= 57) {
param = atoi(name);
} else {
return JS_TRUE;
}
-
+
+ if (!channel) {
+ switch(param) {
+ case SESSION_CAUSE:
+ *vp = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, switch_channel_cause2str(jss->cause)));
+ break;
+ default:
+ *vp = BOOLEAN_TO_JSVAL(JS_FALSE);
+ }
+ return JS_TRUE;
+ }
+
switch(param) {
+ case SESSION_CAUSE:
+ *vp = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, switch_channel_cause2str(switch_channel_get_cause(channel))));
+ break;
case SESSION_NAME:
*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, switch_channel_get_name(channel)));
break;
@@ -1835,12 +2009,12 @@
}
break;
default:
- res = JS_FALSE;
+ *vp = BOOLEAN_TO_JSVAL(JS_FALSE);
break;
-
+
}
- return res;
+ return JS_TRUE;
}
JSClass session_class = {
@@ -1859,7 +2033,7 @@
jss->session = session;
jss->flags = flags;
jss->cx = cx;
- jss->obj = obj;
+ jss->obj = session_obj;
if ((JS_SetPrivate(cx, session_obj, jss) &&
JS_DefineProperties(cx, session_obj, session_props) &&
JS_DefineFunctions(cx, session_obj, session_methods))) {
@@ -1870,18 +2044,36 @@
return NULL;
}
-
/* Session Object */
/*********************************************************************************/
+
static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
+ struct js_session *jss = NULL;
+
+ assert((jss = malloc(sizeof(*jss))));
+ memset(jss, 0, sizeof(*jss));
+ jss->cx = cx;
+ jss->obj = obj;
+ switch_set_flag(jss, S_FREE);
+
+ JS_SetPrivate(cx, obj, jss);
+
+ return JS_TRUE;
+}
+
+static JSBool session_originate(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+ struct js_session *jss = NULL;
switch_memory_pool_t *pool = NULL;
+
+ jss = JS_GetPrivate(cx, obj);
+ jss->cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+
if (argc > 1) {
- switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
- struct js_session *jss = NULL;
JSObject *session_obj;
switch_core_session_t *session = NULL, *peer_session = NULL;
- switch_caller_profile_t *caller_profile = NULL;
+ switch_caller_profile_t *caller_profile = NULL, *orig_caller_profile = NULL;
char *dest = NULL;
char *dialplan = NULL;
char *cid_name = "";
@@ -1893,12 +2085,22 @@
char *context = "";
char *username = NULL;
char *to = NULL;
- *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+
+ *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
if (JS_ValueToObject(cx, argv[0], &session_obj)) {
struct js_session *old_jss = NULL;
if ((old_jss = JS_GetPrivate(cx, session_obj))) {
session = old_jss->session;
+ orig_caller_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(session));
+ dialplan = orig_caller_profile->dialplan;
+ cid_name = orig_caller_profile->caller_id_name;
+ cid_num = orig_caller_profile->caller_id_number;
+ ani = orig_caller_profile->ani;
+ aniii = orig_caller_profile->aniii;
+ rdnis = orig_caller_profile->rdnis;
+ context = orig_caller_profile->context;
+ username = orig_caller_profile->username;
}
}
@@ -1906,7 +2108,7 @@
if (!strchr(dest, '/')) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid Channel String\n");
- return JS_TRUE;
+ goto done;
}
if (argc > 2) {
@@ -1940,7 +2142,6 @@
to = JS_GetStringBytes(JS_ValueToString(cx, argv[11]));
}
-
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
return JS_FALSE;
@@ -1959,41 +2160,45 @@
context,
dest);
- if (switch_ivr_originate(session, &peer_session, &cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile) != SWITCH_STATUS_SUCCESS) {
+ if (switch_ivr_originate(session, &peer_session, &jss->cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot Create Outgoing Channel! [%s]\n", dest);
- return JS_TRUE;
+ goto done;
}
- *rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, switch_channel_cause2str(cause)));
-
- jss = switch_core_session_alloc(peer_session, sizeof(*jss));
jss->session = peer_session;
jss->flags = 0;
- jss->cx = cx;
- jss->obj = obj;
- JS_SetPrivate(cx, obj, jss);
- switch_set_flag(jss, S_HUP);
+
+ *rval = BOOLEAN_TO_JSVAL(JS_TRUE);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing Args\n");
}
+ done:
return JS_TRUE;
}
+
+
+
static void session_destroy(JSContext *cx, JSObject *obj)
{
struct js_session *jss;
+ switch_channel_t *channel = NULL;
if (cx && obj) {
if ((jss = JS_GetPrivate(cx, obj))) {
- if (switch_test_flag(jss, S_HUP)) {
- switch_channel_t *channel;
+ if (jss->session) {
+ channel = switch_core_session_get_channel(jss->session);
+ switch_channel_set_private(channel, "jss", NULL);
+ }
- if (jss->session) {
- channel = switch_core_session_get_channel(jss->session);
- switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
- }
+ if (channel && switch_test_flag(jss, S_HUP)) {
+ switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+ }
+
+ if (switch_test_flag(jss, S_FREE)) {
+ free(jss);
}
}
}
@@ -2073,8 +2278,9 @@
switch_size_t read = 0;
*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
-
- if (fio) {
+
+ if (!fio) {
+ *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
return JS_TRUE;
}
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h Wed Mar 28 13:40:13 2007
@@ -132,6 +132,8 @@
JSContext *cx;
JSObject *obj;
unsigned int flags;
+ switch_call_cause_t cause;
+ JSFunction *on_hangup;
};
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_channel.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_channel.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_channel.c Wed Mar 28 13:40:13 2007
@@ -948,11 +948,13 @@
SWITCH_DECLARE(switch_caller_extension_t *) switch_channel_get_caller_extension(switch_channel_t *channel)
{
- switch_caller_extension_t *extension;
+ switch_caller_extension_t *extension = NULL;
assert(channel != NULL);
switch_mutex_lock(channel->profile_mutex);
- extension = channel->caller_profile->caller_extension;
+ if (channel->caller_profile) {
+ extension = channel->caller_profile->caller_extension;
+ }
switch_mutex_unlock(channel->profile_mutex);
return extension;
}
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_core.c Wed Mar 28 13:40:13 2007
@@ -185,7 +185,6 @@
/* The main runtime obj we keep this hidden for ourselves */
static struct switch_core_runtime runtime;
-
static void db_pick_path(char *dbname, char *buf, switch_size_t size)
{
@@ -1835,20 +1834,22 @@
SWITCH_DECLARE(switch_status_t) switch_core_session_answer_channel(switch_core_session_t *session)
{
switch_io_event_hook_answer_channel_t *ptr;
- switch_status_t status = SWITCH_STATUS_FALSE;
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
assert(session != NULL);
+
if (session->endpoint_interface->io_routines->answer_channel) {
- if ((status = session->endpoint_interface->io_routines->answer_channel(session)) == SWITCH_STATUS_SUCCESS) {
- for (ptr = session->event_hooks.answer_channel; ptr; ptr = ptr->next) {
- if ((status = ptr->answer_channel(session)) != SWITCH_STATUS_SUCCESS) {
- break;
- }
+ status = session->endpoint_interface->io_routines->answer_channel(session);
+ }
+
+ if (status == SWITCH_STATUS_SUCCESS) {
+ for (ptr = session->event_hooks.answer_channel; ptr; ptr = ptr->next) {
+ if ((status = ptr->answer_channel(session)) != SWITCH_STATUS_SUCCESS) {
+ break;
}
}
- } else {
- status = SWITCH_STATUS_SUCCESS;
}
+
return status;
}
@@ -1856,19 +1857,23 @@
SWITCH_DECLARE(switch_status_t) switch_core_session_receive_message(switch_core_session_t *session, switch_core_session_message_t *message)
{
switch_io_event_hook_receive_message_t *ptr;
- switch_status_t status = SWITCH_STATUS_FALSE;
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
assert(session != NULL);
+
if (session->endpoint_interface->io_routines->receive_message) {
- if ((status =
- session->endpoint_interface->io_routines->receive_message(session, message)) == SWITCH_STATUS_SUCCESS) {
- for (ptr = session->event_hooks.receive_message; ptr; ptr = ptr->next) {
- if ((status = ptr->receive_message(session, message)) != SWITCH_STATUS_SUCCESS) {
- break;
- }
+ status = session->endpoint_interface->io_routines->receive_message(session, message);
+
+ }
+
+ if (status == SWITCH_STATUS_SUCCESS) {
+ for (ptr = session->event_hooks.receive_message; ptr; ptr = ptr->next) {
+ if ((status = ptr->receive_message(session, message)) != SWITCH_STATUS_SUCCESS) {
+ break;
}
}
}
+
switch_core_session_kill_channel(session, SWITCH_SIG_BREAK);
return status;
}
@@ -2874,6 +2879,31 @@
}
+SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_state_change(switch_core_session_t *session,
+ switch_answer_channel_hook_t state_change)
+
+
+{
+ switch_io_event_hook_state_change_t *hook, *ptr;
+
+ assert(state_change != NULL);
+ if ((hook = switch_core_session_alloc(session, sizeof(*hook))) != 0) {
+ hook->state_change = state_change;
+ if (!session->event_hooks.state_change) {
+ session->event_hooks.state_change = hook;
+ } else {
+ for (ptr = session->event_hooks.state_change; ptr && ptr->next; ptr = ptr->next);
+ ptr->next = hook;
+
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ return SWITCH_STATUS_MEMERR;
+
+}
+
SWITCH_DECLARE(switch_status_t) switch_core_session_add_event_hook_read_frame(switch_core_session_t *session,
switch_read_frame_hook_t read_frame)
{
@@ -3216,13 +3246,26 @@
SWITCH_DECLARE(void) switch_core_session_signal_state_change(switch_core_session_t *session)
{
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+ switch_io_event_hook_state_change_t *ptr;
/* If trylock fails the signal is already awake so we needn't bother */
if (switch_mutex_trylock(session->mutex) == SWITCH_STATUS_SUCCESS) {
switch_thread_cond_signal(session->cond);
switch_mutex_unlock(session->mutex);
}
-
+
+ if (session->endpoint_interface->io_routines->state_change) {
+ status = session->endpoint_interface->io_routines->state_change(session);
+ }
+
+ if (status == SWITCH_STATUS_SUCCESS) {
+ for (ptr = session->event_hooks.state_change; ptr; ptr = ptr->next) {
+ if ((status = ptr->state_change(session)) != SWITCH_STATUS_SUCCESS) {
+ break;
+ }
+ }
+ }
}
SWITCH_DECLARE(unsigned int) switch_core_session_running(switch_core_session_t *session)
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr.c Wed Mar 28 13:40:13 2007
@@ -2498,7 +2498,7 @@
switch_frame_t *read_frame = NULL;
switch_memory_pool_t *pool = NULL;
int r = 0, i, and_argc = 0, or_argc = 0;
- int32_t idx = IDX_NADA;
+ int32_t sleep_ms = 1000, try =0, retries = 1, idx = IDX_NADA;
switch_codec_t write_codec = {0};
switch_frame_t write_frame = {0};
uint8_t fdata[1024], pass = 0;
@@ -2512,6 +2512,8 @@
switch_event_t *var_event = NULL;
uint8_t fail_on_single_reject = 0;
uint8_t ring_ready = 0;
+ char *loop_data = NULL;
+
write_frame.data = fdata;
*bleg = NULL;
@@ -2605,7 +2607,7 @@
}
}
- // When using the AND operator, the fail_on_single_reject flage may be set in order to indicate that a single
+ // When using the AND operator, the fail_on_single_reject flag may be set in order to indicate that a single
// rejections should terminate the attempt rather than a timeout, answer, or rejection by all.
if ((var = switch_event_get_header(var_event, "fail_on_single_reject")) && switch_true(var)) {
fail_on_single_reject = 1;
@@ -2619,6 +2621,28 @@
early_ok = 0;
}
+ if ((var_val = switch_event_get_header(var_event, "originate_retries")) && switch_true(var_val)) {
+ int32_t tmp;
+ tmp = atoi(var_val);
+ if (tmp > 0 && tmp < 101) {
+ retries = tmp;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+ "Invalid originate_retries setting of %d ignored, value must be between 1 and 100\n", tmp);
+ }
+ }
+
+ if ((var_val = switch_event_get_header(var_event, "originate_retry_sleep_ms")) && switch_true(var_val)) {
+ int32_t tmp;
+ tmp = atoi(var_val);
+ if (tmp > 500 && tmp < 60000) {
+ sleep_ms = tmp;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+ "Invalid originate_retry_sleep_ms setting of %d ignored, value must be between 500 and 60000\n", tmp);
+ }
+ }
+
if (!cid_name_override) {
cid_name_override = switch_event_get_header(var_event, "origination_caller_id_name");
}
@@ -2628,517 +2652,528 @@
}
- or_argc = switch_separate_string(data, '|', pipe_names, (sizeof(pipe_names) / sizeof(pipe_names[0])));
-
- if (caller_channel && or_argc > 1 && !ringback_data) {
- switch_channel_ring_ready(caller_channel);
- sent_ring = 1;
- }
-
- for (r = 0; r < or_argc; r++) {
- uint32_t hups;
- reason = SWITCH_CAUSE_UNALLOCATED;
- memset(peer_names, 0, sizeof(peer_names));
- peer_session = NULL;
- memset(peer_sessions, 0, sizeof(peer_sessions));
- memset(peer_channels, 0, sizeof(peer_channels));
- memset(caller_profiles, 0, sizeof(caller_profiles));
- chan_type = NULL;
- chan_data = NULL;
- peer_channel = NULL;
- start = 0;
- read_frame = NULL;
- pool = NULL;
- pass = 0;
- file = NULL;
- key = NULL;
- var = NULL;
- to = 0;
- and_argc = switch_separate_string(pipe_names[r], ',', peer_names, (sizeof(peer_names) / sizeof(peer_names[0])));
-
- if (caller_channel && !sent_ring && and_argc > 1 && !ringback_data) {
+ for (try = 0; try < retries; try++) {
+ switch_safe_free(loop_data);
+ assert(loop_data = strdup(data));
+ or_argc = switch_separate_string(loop_data, '|', pipe_names, (sizeof(pipe_names) / sizeof(pipe_names[0])));
+
+ if (caller_channel && or_argc > 1 && !ringback_data) {
switch_channel_ring_ready(caller_channel);
sent_ring = 1;
}
- for (i = 0; i < and_argc; i++) {
-
- chan_type = peer_names[i];
- if ((chan_data = strchr(chan_type, '/')) != 0) {
- *chan_data = '\0';
- chan_data++;
+ for (r = 0; r < or_argc; r++) {
+ uint32_t hups;
+ reason = SWITCH_CAUSE_UNALLOCATED;
+ memset(peer_names, 0, sizeof(peer_names));
+ peer_session = NULL;
+ memset(peer_sessions, 0, sizeof(peer_sessions));
+ memset(peer_channels, 0, sizeof(peer_channels));
+ memset(caller_profiles, 0, sizeof(caller_profiles));
+ chan_type = NULL;
+ chan_data = NULL;
+ peer_channel = NULL;
+ start = 0;
+ read_frame = NULL;
+ pool = NULL;
+ pass = 0;
+ file = NULL;
+ key = NULL;
+ var = NULL;
+ to = 0;
+
+ if (try > 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Originate attempt %d/%d in %d ms\n", try + 1, retries, sleep_ms);
+ switch_yield(sleep_ms * 1000);
}
-
- if (session) {
- if (!switch_channel_ready(caller_channel)) {
- status = SWITCH_STATUS_FALSE;
- goto done;
- }
- caller_caller_profile = caller_profile_override ? caller_profile_override : switch_channel_get_caller_profile(caller_channel);
-
- if (!cid_name_override) {
- cid_name_override = caller_caller_profile->caller_id_name;
- }
- if (!cid_num_override) {
- cid_num_override = caller_caller_profile->caller_id_number;
- }
+ and_argc = switch_separate_string(pipe_names[r], ',', peer_names, (sizeof(peer_names) / sizeof(peer_names[0])));
+
+ if (caller_channel && !sent_ring && and_argc > 1 && !ringback_data) {
+ switch_channel_ring_ready(caller_channel);
+ sent_ring = 1;
+ }
- caller_profiles[i] = switch_caller_profile_new(switch_core_session_get_pool(session),
- caller_caller_profile->username,
- caller_caller_profile->dialplan,
- cid_name_override,
- cid_num_override,
- caller_caller_profile->network_addr,
- NULL,
- NULL,
- caller_caller_profile->rdnis,
- caller_caller_profile->source,
- caller_caller_profile->context,
- chan_data);
- caller_profiles[i]->flags = caller_caller_profile->flags;
- pool = NULL;
- } else {
- if (!cid_name_override) {
- cid_name_override = "FreeSWITCH";
- }
- if (!cid_num_override) {
- cid_num_override = "0000000000";
+ for (i = 0; i < and_argc; i++) {
+
+ chan_type = peer_names[i];
+ if ((chan_data = strchr(chan_type, '/')) != 0) {
+ *chan_data = '\0';
+ chan_data++;
}
+
+ if (session) {
+ if (!switch_channel_ready(caller_channel)) {
+ status = SWITCH_STATUS_FALSE;
+ goto done;
+ }
- if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
- status = SWITCH_STATUS_TERM;
- goto done;
- }
+ caller_caller_profile = caller_profile_override ? caller_profile_override : switch_channel_get_caller_profile(caller_channel);
+
+ if (!cid_name_override) {
+ cid_name_override = caller_caller_profile->caller_id_name;
+ }
+ if (!cid_num_override) {
+ cid_num_override = caller_caller_profile->caller_id_number;
+ }
- if (caller_profile_override) {
- caller_profiles[i] = switch_caller_profile_new(pool,
- caller_profile_override->username,
- caller_profile_override->dialplan,
- caller_profile_override->caller_id_name,
- caller_profile_override->caller_id_number,
- caller_profile_override->network_addr,
- caller_profile_override->ani,
- caller_profile_override->aniii,
- caller_profile_override->rdnis,
- caller_profile_override->source,
- caller_profile_override->context,
- chan_data);
- } else {
- caller_profiles[i] = switch_caller_profile_new(pool,
- NULL,
- NULL,
+ caller_profiles[i] = switch_caller_profile_new(switch_core_session_get_pool(session),
+ caller_caller_profile->username,
+ caller_caller_profile->dialplan,
cid_name_override,
cid_num_override,
+ caller_caller_profile->network_addr,
NULL,
- NULL,
- NULL,
- NULL,
- __FILE__,
NULL,
+ caller_caller_profile->rdnis,
+ caller_caller_profile->source,
+ caller_caller_profile->context,
chan_data);
+ caller_profiles[i]->flags = caller_caller_profile->flags;
+ pool = NULL;
+ } else {
+ if (!cid_name_override) {
+ cid_name_override = "FreeSWITCH";
+ }
+ if (!cid_num_override) {
+ cid_num_override = "0000000000";
+ }
+
+ if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
+ status = SWITCH_STATUS_TERM;
+ goto done;
+ }
+
+ if (caller_profile_override) {
+ caller_profiles[i] = switch_caller_profile_new(pool,
+ caller_profile_override->username,
+ caller_profile_override->dialplan,
+ caller_profile_override->caller_id_name,
+ caller_profile_override->caller_id_number,
+ caller_profile_override->network_addr,
+ caller_profile_override->ani,
+ caller_profile_override->aniii,
+ caller_profile_override->rdnis,
+ caller_profile_override->source,
+ caller_profile_override->context,
+ chan_data);
+ } else {
+ caller_profiles[i] = switch_caller_profile_new(pool,
+ NULL,
+ NULL,
+ cid_name_override,
+ cid_num_override,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ __FILE__,
+ NULL,
+ chan_data);
+ }
}
- }
- if ((reason = switch_core_session_outgoing_channel(session, chan_type, caller_profiles[i], &peer_sessions[i], &pool)) != SWITCH_CAUSE_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel! cause: %s\n", switch_channel_cause2str(reason));
- if (pool) {
- switch_core_destroy_memory_pool(&pool);
- }
- caller_profiles[i] = NULL;
- peer_channels[i] = NULL;
- peer_sessions[i] = NULL;
- continue;
- }
+ if ((reason = switch_core_session_outgoing_channel(session, chan_type, caller_profiles[i], &peer_sessions[i], &pool)) != SWITCH_CAUSE_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel! cause: %s\n", switch_channel_cause2str(reason));
+ if (pool) {
+ switch_core_destroy_memory_pool(&pool);
+ }
+ caller_profiles[i] = NULL;
+ peer_channels[i] = NULL;
+ peer_sessions[i] = NULL;
+ continue;
+ }
- switch_core_session_read_lock(peer_sessions[i]);
- pool = NULL;
+ switch_core_session_read_lock(peer_sessions[i]);
+ pool = NULL;
- peer_channels[i] = switch_core_session_get_channel(peer_sessions[i]);
- assert(peer_channels[i] != NULL);
+ peer_channels[i] = switch_core_session_get_channel(peer_sessions[i]);
+ assert(peer_channels[i] != NULL);
- if (!table) {
- table = &originate_state_handlers;
- }
+ if (!table) {
+ table = &originate_state_handlers;
+ }
- if (table) {
- switch_channel_add_state_handler(peer_channels[i], table);
- }
+ if (table) {
+ switch_channel_add_state_handler(peer_channels[i], table);
+ }
- if (switch_core_session_running(peer_sessions[i])) {
- switch_channel_set_state(peer_channels[i], CS_RING);
- } else {
- switch_core_session_thread_launch(peer_sessions[i]);
+ if (switch_core_session_running(peer_sessions[i])) {
+ switch_channel_set_state(peer_channels[i], CS_RING);
+ } else {
+ switch_core_session_thread_launch(peer_sessions[i]);
+ }
}
- }
- time(&start);
+ time(&start);
- for (;;) {
- uint32_t valid_channels = 0;
- for (i = 0; i < and_argc; i++) {
- int state;
+ for (;;) {
+ uint32_t valid_channels = 0;
+ for (i = 0; i < and_argc; i++) {
+ int state;
- if (!peer_channels[i]) {
- continue;
- }
- valid_channels++;
- state = switch_channel_get_state(peer_channels[i]);
+ if (!peer_channels[i]) {
+ continue;
+ }
+ valid_channels++;
+ state = switch_channel_get_state(peer_channels[i]);
- if (state >= CS_HANGUP) {
- goto notready;
- } else if (state >= CS_RING) {
- goto endfor1;
- }
+ if (state >= CS_HANGUP) {
+ goto notready;
+ } else if (state >= CS_RING) {
+ goto endfor1;
+ }
- if (caller_channel && !switch_channel_ready(caller_channel)) {
- goto notready;
- }
+ if (caller_channel && !switch_channel_ready(caller_channel)) {
+ goto notready;
+ }
- if ((time(NULL) - start) > (time_t)timelimit_sec) {
- to++;
- idx = IDX_CANCEL;
- goto notready;
+ if ((time(NULL) - start) > (time_t)timelimit_sec) {
+ to++;
+ idx = IDX_CANCEL;
+ goto notready;
+ }
+ switch_yield(1000);
}
- switch_yield(1000);
- }
- if (valid_channels == 0) {
- status = SWITCH_STATUS_GENERR;
- goto done;
- }
+ if (valid_channels == 0) {
+ status = SWITCH_STATUS_GENERR;
+ goto done;
+ }
- }
- endfor1:
+ }
+ endfor1:
- if (ringback_data && !switch_channel_test_flag(caller_channel, CF_ANSWERED) && !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
- switch_channel_pre_answer(caller_channel);
- }
+ if (ringback_data && !switch_channel_test_flag(caller_channel, CF_ANSWERED) && !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
+ switch_channel_pre_answer(caller_channel);
+ }
- if (session && (read_codec = switch_core_session_get_read_codec(session)) &&
- (ringback_data || !switch_channel_test_flag(caller_channel, CF_NOMEDIA))) {
+ if (session && (read_codec = switch_core_session_get_read_codec(session)) &&
+ (ringback_data || !switch_channel_test_flag(caller_channel, CF_NOMEDIA))) {
- if (!(pass = (uint8_t)switch_test_flag(read_codec, SWITCH_CODEC_FLAG_PASSTHROUGH))) {
- if (switch_core_codec_init(&write_codec,
- "L16",
- NULL,
- read_codec->implementation->samples_per_second,
- read_codec->implementation->microseconds_per_frame / 1000,
- 1,
- SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
- NULL,
- pool) == SWITCH_STATUS_SUCCESS) {
+ if (!(pass = (uint8_t)switch_test_flag(read_codec, SWITCH_CODEC_FLAG_PASSTHROUGH))) {
+ if (switch_core_codec_init(&write_codec,
+ "L16",
+ NULL,
+ read_codec->implementation->samples_per_second,
+ read_codec->implementation->microseconds_per_frame / 1000,
+ 1,
+ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+ NULL,
+ pool) == SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
- read_codec->implementation->samples_per_second,
- read_codec->implementation->microseconds_per_frame / 1000);
- write_frame.codec = &write_codec;
- write_frame.datalen = read_codec->implementation->bytes_per_frame;
- write_frame.samples = write_frame.datalen / 2;
- memset(write_frame.data, 255, write_frame.datalen);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
+ read_codec->implementation->samples_per_second,
+ read_codec->implementation->microseconds_per_frame / 1000);
+ write_frame.codec = &write_codec;
+ write_frame.datalen = read_codec->implementation->bytes_per_frame;
+ write_frame.samples = write_frame.datalen / 2;
+ memset(write_frame.data, 255, write_frame.datalen);
- if (ringback_data) {
- char *tmp_data = NULL;
+ if (ringback_data) {
+ char *tmp_data = NULL;
- switch_buffer_create_dynamic(&ringback.audio_buffer, 512, 1024, 0);
- switch_buffer_create_dynamic(&ringback.loop_buffer, 512, 1024, 0);
+ switch_buffer_create_dynamic(&ringback.audio_buffer, 512, 1024, 0);
+ switch_buffer_create_dynamic(&ringback.loop_buffer, 512, 1024, 0);
- if (*ringback_data == '/') {
- char *ext;
+ if (*ringback_data == '/') {
+ char *ext;
- if ((ext = strrchr(ringback_data, '.'))) {
- switch_core_session_set_read_codec(session, &write_codec);
- ext++;
- } 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;
- }
+ if ((ext = strrchr(ringback_data, '.'))) {
+ switch_core_session_set_read_codec(session, &write_codec);
+ ext++;
+ } 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);
+ 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->samples_per_second;
- if (switch_core_file_open(&ringback.fhb,
- ringback_data,
- read_codec->implementation->number_of_channels,
- read_codec->implementation->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 notready;
- }
- ringback.fh = &ringback.fhb;
+ ringback.fhb.channels = read_codec->implementation->number_of_channels;
+ ringback.fhb.samplerate = read_codec->implementation->samples_per_second;
+ if (switch_core_file_open(&ringback.fhb,
+ ringback_data,
+ read_codec->implementation->number_of_channels,
+ read_codec->implementation->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 notready;
+ }
+ ringback.fh = &ringback.fhb;
- } else {
- teletone_init_session(&ringback.ts, 0, teletone_handler, &ringback);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Play Ringback Tone [%s]\n", ringback_data);
- //ringback.ts.debug = 1;
- //ringback.ts.debug_stream = switch_core_get_console();
- 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);
- switch_buffer_destroy(&ringback.loop_buffer);
- ringback_data = NULL;
+ } else {
+ teletone_init_session(&ringback.ts, 0, teletone_handler, &ringback);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Play Ringback Tone [%s]\n", ringback_data);
+ //ringback.ts.debug = 1;
+ //ringback.ts.debug_stream = switch_core_get_console();
+ 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);
+ switch_buffer_destroy(&ringback.loop_buffer);
+ ringback_data = NULL;
+ }
}
+ switch_safe_free(tmp_data);
}
- switch_safe_free(tmp_data);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Error!");
+ switch_channel_hangup(caller_channel, SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE);
+ read_codec = NULL;
}
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Error!");
- switch_channel_hangup(caller_channel, SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE);
- read_codec = NULL;
}
}
- }
- if (ringback_data) {
- early_ok = 0;
- }
-
- while ((!caller_channel || switch_channel_ready(caller_channel)) &&
- check_channel_status(peer_channels, peer_sessions, and_argc, &idx, &hups, file, key, early_ok, &ring_ready)) {
-
- // When the AND operator is being used, and fail_on_single_reject is set, a hangup indicates that the call should fail.
- if ((to = (uint8_t)((time(NULL) - start) >= (time_t)timelimit_sec)) || (fail_on_single_reject && hups)) {
- idx = IDX_CANCEL;
- goto notready;
+ if (ringback_data) {
+ early_ok = 0;
}
- if (peer_sessions[0] && switch_core_session_dequeue_message(peer_sessions[0], &message) == SWITCH_STATUS_SUCCESS) {
- if (session && !ringback_data && or_argc == 1 && and_argc == 1) { /* when there is only 1 channel to call and bridge and no ringback */
- switch_core_session_receive_message(session, message);
+ while ((!caller_channel || switch_channel_ready(caller_channel)) &&
+ check_channel_status(peer_channels, peer_sessions, and_argc, &idx, &hups, file, key, early_ok, &ring_ready)) {
+
+ // When the AND operator is being used, and fail_on_single_reject is set, a hangup indicates that the call should fail.
+ if ((to = (uint8_t)((time(NULL) - start) >= (time_t)timelimit_sec)) || (fail_on_single_reject && hups)) {
+ idx = IDX_CANCEL;
+ goto notready;
}
+
+ if (peer_sessions[0] && switch_core_session_dequeue_message(peer_sessions[0], &message) == SWITCH_STATUS_SUCCESS) {
+ if (session && !ringback_data && or_argc == 1 && and_argc == 1) { /* when there is only 1 channel to call and bridge and no ringback */
+ switch_core_session_receive_message(session, message);
+ }
- if (switch_test_flag(message, SCSMF_DYNAMIC)) {
- switch_safe_free(message);
- } else {
- message = NULL;
+ if (switch_test_flag(message, SCSMF_DYNAMIC)) {
+ switch_safe_free(message);
+ } else {
+ message = NULL;
+ }
}
- }
- /* read from the channel while we wait if the audio is up on it */
- if (session && (ringback_data || !switch_channel_test_flag(caller_channel, CF_NOMEDIA)) &&
- (switch_channel_test_flag(caller_channel, CF_ANSWERED) || switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA))) {
- switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
+ /* read from the channel while we wait if the audio is up on it */
+ if (session && (ringback_data || !switch_channel_test_flag(caller_channel, CF_NOMEDIA)) &&
+ (switch_channel_test_flag(caller_channel, CF_ANSWERED) || switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA))) {
+ switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
- if (!SWITCH_READ_ACCEPTABLE(status)) {
- break;
- }
+ if (!SWITCH_READ_ACCEPTABLE(status)) {
+ break;
+ }
- if (ring_ready && read_frame && !pass && !switch_test_flag(read_frame, SFF_CNG) && read_frame->datalen > 1) {
- if (ringback.fh) {
- uint8_t abuf[1024];
- switch_size_t mlen, olen;
- unsigned int pos = 0;
+ if (ring_ready && read_frame && !pass && !switch_test_flag(read_frame, SFF_CNG) && read_frame->datalen > 1) {
+ if (ringback.fh) {
+ uint8_t abuf[1024];
+ switch_size_t mlen, olen;
+ unsigned int pos = 0;
- if (ringback.asis) {
- mlen = read_frame->datalen;
- } else {
- mlen = read_frame->datalen / 2;
- }
+ if (ringback.asis) {
+ mlen = read_frame->datalen;
+ } else {
+ mlen = read_frame->datalen / 2;
+ }
- olen = mlen;
- switch_core_file_read(ringback.fh, abuf, &olen);
-
- if (olen == 0) {
olen = mlen;
- ringback.fh->speed = 0;
- switch_core_file_seek(ringback.fh, &pos, 0, SEEK_SET);
switch_core_file_read(ringback.fh, abuf, &olen);
+
if (olen == 0) {
+ olen = mlen;
+ ringback.fh->speed = 0;
+ switch_core_file_seek(ringback.fh, &pos, 0, SEEK_SET);
+ switch_core_file_read(ringback.fh, abuf, &olen);
+ if (olen == 0) {
+ break;
+ }
+ }
+ write_frame.data = abuf;
+ write_frame.datalen = (uint32_t) (ringback.asis ? olen : olen * 2);
+ if (switch_core_session_write_frame(session, &write_frame, 1000, 0) != SWITCH_STATUS_SUCCESS) {
break;
}
- }
- write_frame.data = abuf;
- write_frame.datalen = (uint32_t) (ringback.asis ? olen : olen * 2);
- if (switch_core_session_write_frame(session, &write_frame, 1000, 0) != SWITCH_STATUS_SUCCESS) {
- break;
- }
- } else if (ringback.audio_buffer) {
- if ((write_frame.datalen = (uint32_t)switch_buffer_read(ringback.audio_buffer,
- write_frame.data,
- write_frame.codec->implementation->bytes_per_frame)) <= 0) {
- switch_buffer_t *tmp;
- tmp = ringback.audio_buffer;
- ringback.audio_buffer = ringback.loop_buffer;
- ringback.loop_buffer = tmp;
+ } else if (ringback.audio_buffer) {
if ((write_frame.datalen = (uint32_t)switch_buffer_read(ringback.audio_buffer,
write_frame.data,
write_frame.codec->implementation->bytes_per_frame)) <= 0) {
- break;
+ switch_buffer_t *tmp;
+ tmp = ringback.audio_buffer;
+ ringback.audio_buffer = ringback.loop_buffer;
+ ringback.loop_buffer = tmp;
+ if ((write_frame.datalen = (uint32_t)switch_buffer_read(ringback.audio_buffer,
+ write_frame.data,
+ write_frame.codec->implementation->bytes_per_frame)) <= 0) {
+ break;
+ }
}
}
- }
- if (switch_core_session_write_frame(session, &write_frame, 1000, 0) != SWITCH_STATUS_SUCCESS) {
- break;
- }
- if (ringback.loop_buffer) {
- switch_buffer_write(ringback.loop_buffer, write_frame.data, write_frame.datalen);
+ if (switch_core_session_write_frame(session, &write_frame, 1000, 0) != SWITCH_STATUS_SUCCESS) {
+ break;
+ }
+ if (ringback.loop_buffer) {
+ switch_buffer_write(ringback.loop_buffer, write_frame.data, write_frame.datalen);
+ }
}
- }
- } else {
- switch_yield(1000);
- }
+ } else {
+ switch_yield(1000);
+ }
- }
-
- notready:
+ }
- if (caller_channel && !switch_channel_ready(caller_channel)) {
- idx = IDX_CANCEL;
- }
+ notready:
- if (session && (ringback_data || !switch_channel_test_flag(caller_channel, CF_NOMEDIA))) {
- switch_core_session_reset(session);
- }
+ if (caller_channel && !switch_channel_ready(caller_channel)) {
+ idx = IDX_CANCEL;
+ }
- for (i = 0; i < and_argc; i++) {
- if (!peer_channels[i]) {
- continue;
+ if (session && (ringback_data || !switch_channel_test_flag(caller_channel, CF_NOMEDIA))) {
+ switch_core_session_reset(session);
}
- if (i != idx) {
- if (idx == IDX_CANCEL) {
- if (to) {
- reason = SWITCH_CAUSE_NO_ANSWER;
- } else {
- reason = SWITCH_CAUSE_ORIGINATOR_CANCEL;
- }
- } else {
- if (to) {
- reason = SWITCH_CAUSE_NO_ANSWER;
- } else if (and_argc > 1) {
- reason = SWITCH_CAUSE_LOSE_RACE;
+
+ for (i = 0; i < and_argc; i++) {
+ if (!peer_channels[i]) {
+ continue;
+ }
+ if (i != idx) {
+ if (idx == IDX_CANCEL) {
+ if (to) {
+ reason = SWITCH_CAUSE_NO_ANSWER;
+ } else {
+ reason = SWITCH_CAUSE_ORIGINATOR_CANCEL;
+ }
} else {
- reason = SWITCH_CAUSE_NO_ANSWER;
+ if (to) {
+ reason = SWITCH_CAUSE_NO_ANSWER;
+ } else if (and_argc > 1) {
+ reason = SWITCH_CAUSE_LOSE_RACE;
+ } else {
+ reason = SWITCH_CAUSE_NO_ANSWER;
+ }
}
- }
- switch_channel_hangup(peer_channels[i], reason);
+ switch_channel_hangup(peer_channels[i], reason);
+ }
}
- }
- if (idx > IDX_NADA) {
- peer_session = peer_sessions[idx];
- peer_channel = peer_channels[idx];
- } else {
- status = SWITCH_STATUS_FALSE;
- goto done;
- }
+ if (idx > IDX_NADA) {
+ peer_session = peer_sessions[idx];
+ peer_channel = peer_channels[idx];
+ } else {
+ status = SWITCH_STATUS_FALSE;
+ goto done;
+ }
- if (caller_channel) {
- if (switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
- switch_channel_answer(caller_channel);
- } else if (switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) {
- switch_channel_pre_answer(caller_channel);
+ if (caller_channel) {
+ if (switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
+ switch_channel_answer(caller_channel);
+ } else if (switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) {
+ switch_channel_pre_answer(caller_channel);
+ }
}
- }
- if (switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) {
- *bleg = peer_session;
- status = SWITCH_STATUS_SUCCESS;
- } else {
- status = SWITCH_STATUS_FALSE;
- }
+ if (switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) {
+ *bleg = peer_session;
+ status = SWITCH_STATUS_SUCCESS;
+ } else {
+ status = SWITCH_STATUS_FALSE;
+ }
- done:
- *cause = SWITCH_CAUSE_UNALLOCATED;
+ done:
+ *cause = SWITCH_CAUSE_UNALLOCATED;
- if (var_event) {
- if (peer_channel && !caller_channel) { /* install the vars from the {} params */
- switch_event_header_t *header;
- for (header = var_event->headers; header; header = header->next) {
- switch_channel_set_variable(peer_channel, header->name, header->value);
- }
- }
- switch_event_destroy(&var_event);
- }
+ if (var_event) {
+ if (peer_channel && !caller_channel) { /* install the vars from the {} params */
+ switch_event_header_t *header;
+ for (header = var_event->headers; header; header = header->next) {
+ switch_channel_set_variable(peer_channel, header->name, header->value);
+ }
+ }
+ switch_event_destroy(&var_event);
+ }
- if (status == SWITCH_STATUS_SUCCESS) {
- if (caller_channel) {
- switch_channel_set_variable(caller_channel, "originate_disposition", "call accepted");
- }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Originate Resulted in Success: [%s]\n", switch_channel_get_name(peer_channel));
- *cause = SWITCH_CAUSE_SUCCESS;
+ if (status == SWITCH_STATUS_SUCCESS) {
+ if (caller_channel) {
+ switch_channel_set_variable(caller_channel, "originate_disposition", "call accepted");
+ }
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Originate Resulted in Success: [%s]\n", switch_channel_get_name(peer_channel));
+ *cause = SWITCH_CAUSE_SUCCESS;
- } else {
- if (peer_channel) {
- *cause = switch_channel_get_cause(peer_channel);
} else {
- for (i = 0; i < and_argc; i++) {
- if (!peer_channels[i]) {
- continue;
+ if (peer_channel) {
+ *cause = switch_channel_get_cause(peer_channel);
+ } else {
+ for (i = 0; i < and_argc; i++) {
+ if (!peer_channels[i]) {
+ continue;
+ }
+ *cause = switch_channel_get_cause(peer_channels[i]);
+ break;
}
- *cause = switch_channel_get_cause(peer_channels[i]);
- break;
}
- }
- if (!*cause) {
- if (reason) {
- *cause = reason;
- } else if (caller_channel) {
- *cause = switch_channel_get_cause(caller_channel);
- } else {
- *cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
- }
- }
+ if (!*cause) {
+ if (reason) {
+ *cause = reason;
+ } else if (caller_channel) {
+ *cause = switch_channel_get_cause(caller_channel);
+ } else {
+ *cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+ }
+ }
- if (idx == IDX_CANCEL) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Originate Cancelled by originator termination Cause: %d [%s]\n",
- *cause, switch_channel_cause2str(*cause));
+ if (idx == IDX_CANCEL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Originate Cancelled by originator termination Cause: %d [%s]\n",
+ *cause, switch_channel_cause2str(*cause));
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Originate Resulted in Error Cause: %d [%s]\n",
- *cause, switch_channel_cause2str(*cause));
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Originate Resulted in Error Cause: %d [%s]\n",
+ *cause, switch_channel_cause2str(*cause));
+ }
}
- }
- if (caller_channel) {
- switch_channel_set_variable(caller_channel, "originate_disposition", switch_channel_cause2str(*cause));
- }
-
- if (!pass && write_codec.implementation) {
- switch_core_codec_destroy(&write_codec);
- }
+ if (caller_channel) {
+ switch_channel_set_variable(caller_channel, "originate_disposition", switch_channel_cause2str(*cause));
+ }
- if (ringback.fh) {
- switch_core_file_close(ringback.fh);
- ringback.fh = NULL;
- if (read_codec && !ringback.asis) {
- switch_core_session_set_read_codec(session, read_codec);
- switch_core_session_reset(session);
+ if (!pass && write_codec.implementation) {
+ switch_core_codec_destroy(&write_codec);
}
- } else if (ringback.audio_buffer) {
- teletone_destroy_session(&ringback.ts);
- switch_buffer_destroy(&ringback.audio_buffer);
- switch_buffer_destroy(&ringback.loop_buffer);
- }
- for (i = 0; i < and_argc; i++) {
- if (!peer_channels[i]) {
- continue;
+ if (ringback.fh) {
+ switch_core_file_close(ringback.fh);
+ ringback.fh = NULL;
+ if (read_codec && !ringback.asis) {
+ switch_core_session_set_read_codec(session, read_codec);
+ switch_core_session_reset(session);
+ }
+ } else if (ringback.audio_buffer) {
+ teletone_destroy_session(&ringback.ts);
+ switch_buffer_destroy(&ringback.audio_buffer);
+ switch_buffer_destroy(&ringback.loop_buffer);
}
- switch_core_session_rwunlock(peer_sessions[i]);
- }
- if (status == SWITCH_STATUS_SUCCESS) {
- break;
+ for (i = 0; i < and_argc; i++) {
+ if (!peer_channels[i]) {
+ continue;
+ }
+ switch_core_session_rwunlock(peer_sessions[i]);
+ }
+
+ if (status == SWITCH_STATUS_SUCCESS) {
+ goto outer_for;
+ }
}
}
-
+ outer_for:
+ switch_safe_free(loop_data);
switch_safe_free(odata);
return status;
}
1
0
28 Mar '07
Author: mikej
Date: Wed Mar 28 13:35:23 2007
New Revision: 4780
Modified:
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/RELEASE
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/configure.ac
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/iptsec/Doxyfile
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/sdp/run_test_sdp
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/sip/Doxyfile
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/sip/sip_util.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/su_timer.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/tport/tport_logging.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/packages/ (props changed)
Log:
sync up to sofia-sip 1.12.6 rc (1.12.5work3)
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/RELEASE
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/RELEASE (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/RELEASE Wed Mar 28 13:35:23 2007
@@ -5,28 +5,16 @@
Changes since last release
--------------------------
-<changes since last written in freshmeat.net "Changes:" style;
- and in less than 10 lines, written in 3rd person English, with
- complete sentences />
-
-Bugs in blaa and foo have been fixed. The stack now supports
-use of foobar...
+Numerous nua bugs introduced in the release 1.12.5 have been fixed. Support
+for nextnonce in Authentication-Info header has been added. The nua engine
+now fully supports application-driven SDP.
API/ABI changes and versioning
------------------------------
-<see previous release notes at
- http://sofia-sip.sourceforge.net/relnotes/ for examples ;
- - should include all changes to public headers, and
- other important information to developers;
- - and should be updated _continuously_! />
-
-**template**: New features in API are marked with Doxytag macro @VERSION_1_XX_X.
-
libsofia-sip-ua:
-- **template**: Added foobar() function (sofia-sip/foobar.h).
-- Added tag NUTAG_AUTH_CACHE() determining when to include credentials in
- the request
+- Added tag NUTAG_AUTH_CACHE() <sofia-sip/nua_tag.h> determining when to
+ include credentials in the request
- Added kqueue and /dev/poll interfaces (su_devpoll_port_create(),
su_devpoll_clone_start(), su_kqueue_port_create(), su_kqueue_clone_start()
in <sofia-sip/su_wait.h>)
@@ -48,19 +36,8 @@
Contributors to this release
----------------------------
-<list of people who contributed to _this_ release
- - update as people's patches are added, or when you commit stuff
- - current development team members (see AUTHORS) may be omitted,
- or listed at the end of the contribur list (depending on the scope
- of the work done since the last release)
- - name of the contributor should be enough (email addresses in AUTHORS),
- plus a _brief_ description of what was contributed
- - roughly sorted by number of patches accepted
-/>
-
-- **template**: First Surname (patch to nua/soa/msg)
-- Martti Mela (kqueue interface to Max OS X and FreeBSD)
- Pekka Pessi (/dev/poll interface to Solaris, kqueue)
+- Martti Mela (kqueue interface to Max OS X and FreeBSD)
- Michael Jerris (Solaris patches)
- Colin Whittaker (sresolv patch)
@@ -72,24 +49,25 @@
The Sofia-SIP has been compiled and tested on Solaris. The /dev/poll
interface (in su_devpoll_port.c) has been added for Solaris. Likewise, the
kqueue interface (in su_kqueue_port.c) has been added for FreeBSD and Mac OS
-X.
+X. There is also select-based reactor for systems without poll().
-<information about major new features
- - new/changed/removed functionality
- - links to further documentation
- - section may be omitted for minor releases
-/>
+The client authentication in nua has been updated. The nextnonce in
+Authentication-Info or Proxy-Authentication-Info headers is now. The
+NUTAG_AUTH_CACHE() policy determines how the cached credentials are used. By
+default, the credentials are included in each request within the dialog,
+however, with the NUTAG_AUTH_CACHE(nua_auth_cache_challenged) the client
+authenticates requests only after they have been challenged.
+
+The application can now fully control the SDP negotiation (when soa is
+disabled with NUTAG_MEDIA_ENABLE(0)). The application can send UPDATE and
+PRACK requests and respond to them.
Bugs fixed in this release
--------------------------
-< notable bugs fixed in this release
- - check the sf.net bug tracker; see closed bugs,
- sorted by closing date
- - other bugs as fixed in CVS/darcs
-/>
-
-- **template**: #9499652 sf.net bug item title
+- Fixed problem logging long lines from with TPORT_LOG.
+ Problem reported by Mike Murdock and Michael Jerris.
+- Nua now includes the SDP capabilities in the response to the OPTIONS
- Fixed assertion failure because BYE destroyed a session twice.
Problem reported by Michael Jerris.
- Fixed crash caused by a 0-length UDP datagram.
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/configure.ac
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/configure.ac (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/configure.ac Wed Mar 28 13:35:23 2007
@@ -11,14 +11,14 @@
dnl ---------------------------
dnl update both the version for AC_INIT and the LIBSOFIA_SIP_UA_MAJOR_MINOR
-AC_INIT([sofia-sip], [1.12.5work])
+AC_INIT([sofia-sip], [1.12.5work3])
AC_CONFIG_SRCDIR([libsofia-sip-ua/sip/sofia-sip/sip.h])
AC_SUBST(VER_LIBSOFIA_SIP_UA_MAJOR_MINOR, [1.12])
dnl Includedir specific to this sofia version
AC_SUBST(include_sofiadir, '${includedir}/sofia-sip-1.12')
-AC_SUBST(LIBVER_SOFIA_SIP_UA_CUR, [4])
+AC_SUBST(LIBVER_SOFIA_SIP_UA_CUR, [5])
AC_SUBST(LIBVER_SOFIA_SIP_UA_REV, [0])
-AC_SUBST(LIBVER_SOFIA_SIP_UA_AGE, [4])
+AC_SUBST(LIBVER_SOFIA_SIP_UA_AGE, [5])
AC_SUBST(LIBVER_SOFIA_SIP_UA_SOVER, [0]) # CUR-AGE
AC_SUBST(LIBVER_SOFIA_SIP_UA_GLIB_CUR, [3])
AC_SUBST(LIBVER_SOFIA_SIP_UA_GLIB_REV, [0])
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/iptsec/Doxyfile
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/iptsec/Doxyfile (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/iptsec/Doxyfile Wed Mar 28 13:35:23 2007
@@ -11,6 +11,7 @@
TAGFILES += ../docs/url.doxytags=../url
TAGFILES += ../docs/msg.doxytags=../msg
TAGFILES += ../docs/sip.doxytags=../sip
+TAGFILES += ../docs/http.doxytags=../http
TAGFILES += ../docs/sresolv.doxytags=../sresolv
TAGFILES += ../docs/tport.doxytags=../tport
TAGFILES += ../docs/nta.doxytags=../nta
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c Wed Mar 28 13:35:23 2007
@@ -185,22 +185,24 @@
/** Store authentication info to authenticators.
*
- * The function auc_info() feeds the authentication data from the
- * authentication info @a info to the list of authenticators @a auc_list.
+ * The function auc_info() feeds the authentication data from the @b
+ * Authentication-Info header @a info to the list of authenticators @a
+ * auc_list.
*
* @param[in,out] auc_list list of authenticators to be updated
- * @param[in] info info to be processed
- * @param[in] crcl corresponding credential class
+ * @param[in] info info header to be processed
+ * @param[in] credential_class corresponding credential class
*
- * The authentication info can be in either Authentication-Info or in
- * Proxy-Authentication-Info headers.
- * If the header is Authentication-Info, the @a crcl should be
- * #sip_authorization_class or #http_authorization_class.
- * Likewise, If the header is Proxy-Authentication-Info, the @a crcl should
- * be #sip_proxy_authorization_class or #http_proxy_authorization_class.
-
- * The authentication into usually contains next nonce or mutual
- * authentication information. We handle only nextnonce parameter.
+ * The authentication info can be in either @AuthenticationInfo or in
+ * @ProxyAuthenticationInfo headers. If the header is @AuthenticationInfo,
+ * the @a credential_class should be #sip_authorization_class or
+ * #http_authorization_class. Likewise, If the header is
+ * @ProxyAuthenticationInfo, the @a credential_class should be
+ * #sip_proxy_authorization_class or #http_proxy_authorization_class.
+
+ * The authentication into header usually contains next nonce or mutual
+ * authentication information. Currently, only the nextnonce parameter is
+ * processed.
*
* @bug
* The result can be quite unexpected if there are more than one
@@ -214,7 +216,7 @@
* @NEW_1_12_5
*/
int auc_info(auth_client_t **auc_list,
- msg_auth_info_t const *ai,
+ msg_auth_info_t const *info,
msg_hclass_t *credential_class)
{
auth_client_t *ca;
@@ -224,7 +226,7 @@
/* Update matching authenticator */
for (ca = *auc_list; ca; ca = ca->ca_next) {
- int updated = ca_info(ca, ai, credential_class);
+ int updated = ca_info(ca, info, credential_class);
if (updated < 0)
return -1;
if (updated >= 1)
@@ -243,12 +245,12 @@
*/
static
int ca_info(auth_client_t *ca,
- msg_auth_info_t const *ai,
+ msg_auth_info_t const *info,
msg_hclass_t *credential_class)
{
- assert(ca); assert(ai);
+ assert(ca); assert(info);
- if (!ca || !ai)
+ if (!ca || !info)
return -1;
if (!ca->ca_credential_class)
@@ -263,7 +265,7 @@
|| !ca->ca_auc->auc_info)
return 0;
- return ca->ca_auc->auc_info(ca, ai);
+ return ca->ca_auc->auc_info(ca, info);
}
@@ -735,7 +737,7 @@
msg_payload_t const *body,
msg_header_t **);
static int auc_digest_info(auth_client_t *ca,
- msg_auth_info_t const *ai);
+ msg_auth_info_t const *info);
static const auth_client_plugin_t ca_digest_plugin =
{
@@ -796,14 +798,14 @@
}
static int auc_digest_info(auth_client_t *ca,
- msg_auth_info_t const *ai)
+ msg_auth_info_t const *info)
{
auth_digest_client_t *cda = (auth_digest_client_t *)ca;
su_home_t *home = ca->ca_home;
char const *nextnonce = NULL;
issize_t n;
- n = auth_get_params(home, ai->ai_params,
+ n = auth_get_params(home, info->ai_params,
"nextnonce=", &nextnonce,
NULL);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Wed Mar 28 13:35:23 2007
@@ -1823,10 +1823,20 @@
if (self->sa_contact)
return 0;
- if (self->sa_vias)
- v1 = self->sa_vias;
- else
- v1 = self->sa_public_vias;
+ for (v1 = self->sa_vias ? self->sa_vias : self->sa_public_vias;
+ v1;
+ v1 = v1->v_next) {
+ if (host_is_ip_address(v1->v_host)) {
+ if (!host_is_local(v1->v_host))
+ break;
+ }
+ else if (!host_has_domain_invalid(v1->v_host)) {
+ break;
+ }
+ }
+
+ if (v1 == NULL)
+ v1 = self->sa_vias ? self->sa_vias : self->sa_public_vias;
if (!v1)
return -1;
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c Wed Mar 28 13:35:23 2007
@@ -4010,7 +4010,7 @@
else
*return_cd = NULL;
- if (!*return_pl || !*return_cd)
+ if (!*return_pl || !*return_ct)
return -1;
if (session && !*return_cd)
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h Wed Mar 28 13:35:23 2007
@@ -1262,7 +1262,9 @@
* - nua_auth_cache_challenged (1) - include credentials only when
* challenged
*
- * Corresponding tag taking reference parameter is NUTAG_AUTH_CACHE_REF()
+ * Corresponding tag taking reference parameter is NUTAG_AUTH_CACHE_REF().
+ *
+ * @NEW_1_12_6
*/
#define NUTAG_AUTH_CACHE(x) nutag_auth_cache, tag_int_v(x)
SOFIAPUBVAR tag_typedef_t nutag_auth_cache;
@@ -1270,7 +1272,7 @@
#define NUTAG_AUTH_CACHE_REF(x) nutag_auth_cache_ref, tag_int_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_auth_cache_ref;
-/** Authentication caching policy */
+/** Authentication caching policy. @NEW_1_12_6 */
enum nua_auth_cache {
/** Include credentials within dialog (default) */
nua_auth_cache_dialog = 0,
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/sdp/run_test_sdp
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/sdp/run_test_sdp (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/sdp/run_test_sdp Wed Mar 28 13:35:23 2007
@@ -6,7 +6,7 @@
#
test_sdp="${1:-./test_sdp}"
-tests="${2:-tests}"
+tests="${2:-${0%/*}/tests}"
if test -r $tests/message-1.sdp ; then
@@ -17,6 +17,7 @@
done
else
- echo "sdp run-tests: no tests found, skipping."
+ echo "sdp run-tests: no tests found in $tests, skipping."
+ exit 77
fi
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/sip/Doxyfile
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/sip/Doxyfile (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/sip/Doxyfile Wed Mar 28 13:35:23 2007
@@ -25,4 +25,6 @@
@INCLUDE = sip.doxyaliases
+PREDEFINED += SU_HAVE_EXPERIMENTAL=1
+
IMAGE_PATH += images
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/sip/sip_util.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/sip/sip_util.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/sip/sip_util.c Wed Mar 28 13:35:23 2007
@@ -247,8 +247,8 @@
if (port || host_is_ip_address(host))
transport = NULL;
}
- else if (port && host_is_ip_address(host) &&
- strcmp(port, SIP_DEFAULT_SERV) == 0) {
+ else if (port && strcmp(port, SIP_DEFAULT_SERV) == 0 &&
+ (host_is_ip_address(host) || host_has_domain_invalid(host))) {
port = NULL;
}
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/su_timer.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/su_timer.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/su_timer.c Wed Mar 28 13:35:23 2007
@@ -157,6 +157,7 @@
unsigned char sut_set; /**< Timer is set (inserted in tree) */
};
+/** @internal Timer running status */
enum sut_running {
reset = 0, /**< Timer is not running */
run_at_intervals = 1, /**< Compensate missed wakeup calls */
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/tport/tport_logging.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/tport/tport_logging.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/tport/tport_logging.c Wed Mar 28 13:35:23 2007
@@ -221,17 +221,17 @@
n = strncspn(s, end - s, "\r\n");
if (linelen + n > MAX_LINELEN) {
- n = MAX_LINELEN - n - linelen;
+ n = MAX_LINELEN - linelen;
truncated = logged + n;
}
- su_log("%s%.*s", linelen > n ? "" : " ", (int)n, s);
+ su_log("%s%.*s", linelen > 0 ? "" : " ", (int)n, s);
s += n, linelen += n, logged += n;
if (truncated)
break;
if (s == end)
- continue;
+ break;
linelen = 0;
su_log("\n");
1
0
[commit] r4772 - in freeswitch/branches/mikej/sofiasip-upgrade: libs libs/portaudio/test src/mod/dialplans/mod_dialplan_xml src/mod/event_handlers/mod_cdr
by Freeswitch SVN 26 Mar '07
by Freeswitch SVN 26 Mar '07
26 Mar '07
Author: mikej
Date: Mon Mar 26 17:46:00 2007
New Revision: 4772
Modified:
freeswitch/branches/mikej/sofiasip-upgrade/libs/ (props changed)
freeswitch/branches/mikej/sofiasip-upgrade/libs/portaudio/test/ (props changed)
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/ (props changed)
Log:
merged changes from trunk revisions 4768-4771.
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c Mon Mar 26 17:46:00 2007
@@ -368,6 +368,7 @@
switch_xml_free(xml);
+ xml = NULL;
if (extension) {
switch_channel_set_state(channel, CS_EXECUTE);
1
0
[commit] r4769 - in freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip: . libsofia-sip-ua/nta
by Freeswitch SVN 26 Mar '07
by Freeswitch SVN 26 Mar '07
26 Mar '07
Author: mikej
Date: Mon Mar 26 17:16:33 2007
New Revision: 4769
Modified:
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/RELEASE
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
Log:
update to sofia darcs tree
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/RELEASE
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/RELEASE (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/RELEASE Mon Mar 26 17:16:33 2007
@@ -25,6 +25,8 @@
libsofia-sip-ua:
- **template**: Added foobar() function (sofia-sip/foobar.h).
+- Added tag NUTAG_AUTH_CACHE() determining when to include credentials in
+ the request
- Added kqueue and /dev/poll interfaces (su_devpoll_port_create(),
su_devpoll_clone_start(), su_kqueue_port_create(), su_kqueue_clone_start()
in <sofia-sip/su_wait.h>)
@@ -58,7 +60,7 @@
- **template**: First Surname (patch to nua/soa/msg)
- Martti Mela (kqueue interface to Max OS X and FreeBSD)
-- Pekka Pessi (/dev/poll interface to Solaris)
+- Pekka Pessi (/dev/poll interface to Solaris, kqueue)
- Michael Jerris (Solaris patches)
- Colin Whittaker (sresolv patch)
@@ -88,8 +90,16 @@
/>
- **template**: #9499652 sf.net bug item title
+- Fixed assertion failure because BYE destroyed a session twice.
+ Problem reported by Michael Jerris.
+- Fixed crash caused by a 0-length UDP datagram.
+ Problem reported by Michael Jerris.
+- Fixed the 305 response handling by nua stack.
+ Bug #1676445 reported by Fabio Margarido.
+- Fixed authentication-related bugs #1685245 and #1570746.
+ #1685245 reported by Mikhail Zabaluev.
- Fixed problems resuming DNS after server or link downtime.
- Problem reported by Colin Whittaker.
+ Bug #1631198 reported and initial patch submitted by Colin Whittaker.
- Fixed NUTAG_APPL_METHOD() implementation for UPDATE and PRACK as documented
- Fixed crashes in nua state engines:
- when nua_invite() was called second time before receiving
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Mon Mar 26 17:16:33 2007
@@ -8006,10 +8006,11 @@
{
nta_agent_t *sa = orq->orq_agent;
short orq_status = orq->orq_status;
+ int internal = sip == NULL || (sip->sip_flags & NTA_INTERNAL_MSG) == 0;
if (status < 100) status = 100;
- if (sip && orq->orq_delay == UINT_MAX)
+ if (!internal && orq->orq_delay == UINT_MAX)
outgoing_estimate_delay(orq, sip);
if (orq->orq_cc)
@@ -8067,7 +8068,7 @@
}
else {
/* Final response */
- if (status >= 300)
+ if (status >= 300 && !internal)
outgoing_ack(orq, msg, sip);
if (!orq->orq_completed) {
1
0
Author: mikej
Date: Mon Mar 26 14:45:37 2007
New Revision: 4768
Added:
freeswitch/branches/mikej/sofiasip-upgrade/build/config/ax_lib_mysql.m4
- copied unchanged from r4767, /freeswitch/trunk/build/config/ax_lib_mysql.m4
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/
- copied from r4767, /freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/g711.h
- copied unchanged from r4767, /freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/g711.h
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.c
- copied unchanged from r4767, /freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.dsp
- copied unchanged from r4767, /freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.dsp
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.dsw
- copied unchanged from r4767, /freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.dsw
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.h
- copied unchanged from r4767, /freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.h
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.so.conf
- copied unchanged from r4767, /freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.so.conf
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.vcproj
- copied unchanged from r4767, /freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.vcproj
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.c
- copied unchanged from r4767, /freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.h
- copied unchanged from r4767, /freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.h
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/libsangoma/win_api_common.h
- copied unchanged from r4767, /freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/win_api_common.h
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/Makefile.am
- copied unchanged from r4767, /freeswitch/trunk/src/mod/event_handlers/mod_cdr/Makefile.am
Removed:
freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/build/apr_common.m4
freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/build/find_apr.m4
freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/build/get-version.sh
freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/build/install.sh
freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/xml/expat/acconfig.h
freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/xml/expat/config.h.in
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/event_handlers/mod_cdr/Makefile
Modified:
freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am
freeswitch/branches/mikej/sofiasip-upgrade/acinclude.m4
freeswitch/branches/mikej/sofiasip-upgrade/bootstrap.sh
freeswitch/branches/mikej/sofiasip-upgrade/build/getlib.sh.in
freeswitch/branches/mikej/sofiasip-upgrade/build/modmake.rules.in
freeswitch/branches/mikej/sofiasip-upgrade/configure.in
freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/ (props changed)
freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/build/ (props changed)
freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/include/private/ (props changed)
freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/xml/expat/ (props changed)
freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/xml/expat/configure.in
freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/xml/expat/lib/winconfig.h
freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/xml/expat/lib/xmlparse.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/apr/build/apr_common.m4
freeswitch/branches/mikej/sofiasip-upgrade/libs/codec/gsm/configure.in
freeswitch/branches/mikej/sofiasip-upgrade/libs/iksemel/include/ (props changed)
freeswitch/branches/mikej/sofiasip-upgrade/libs/js/ (props changed)
freeswitch/branches/mikej/sofiasip-upgrade/libs/libdingaling/src/ (props changed)
freeswitch/branches/mikej/sofiasip-upgrade/libs/libetpan/ (props changed)
freeswitch/branches/mikej/sofiasip-upgrade/libs/libresample/src/ (props changed)
freeswitch/branches/mikej/sofiasip-upgrade/libs/libsndfile/src/ (props changed)
freeswitch/branches/mikej/sofiasip-upgrade/libs/libteletone/configure.in
freeswitch/branches/mikej/sofiasip-upgrade/libs/pcre/ (props changed)
freeswitch/branches/mikej/sofiasip-upgrade/libs/portaudio/Makefile.in
freeswitch/branches/mikej/sofiasip-upgrade/libs/portaudio/src/common/pa_ringbuffer.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/ (props changed)
freeswitch/branches/mikej/sofiasip-upgrade/libs/srtp/ (props changed)
freeswitch/branches/mikej/sofiasip-upgrade/libs/srtp/doc/ (props changed)
freeswitch/branches/mikej/sofiasip-upgrade/libs/xmlrpc-c/configure.gnu
freeswitch/branches/mikej/sofiasip-upgrade/src/include/ (props changed)
freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch.h
freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_config.h
freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_log.h
freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_resample.h
freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/Makefile.am
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_conference/mod_conference.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/asr_tts/mod_lumenvox/Makefile
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g723_1/Makefile
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g729/Makefile
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_iax/mod_iax.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/Makefile
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/formats/mod_shout/Makefile
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_perl/Makefile
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey_odbc/Makefile
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey_teletone/Makefile
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/loggers/mod_console/mod_console.c
freeswitch/branches/mikej/sofiasip-upgrade/src/mod/xml_int/mod_xml_rpc/Makefile
freeswitch/branches/mikej/sofiasip-upgrade/src/switch_apr.c
freeswitch/branches/mikej/sofiasip-upgrade/src/switch_channel.c
freeswitch/branches/mikej/sofiasip-upgrade/src/switch_console.c
freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr.c
freeswitch/branches/mikej/sofiasip-upgrade/src/switch_resample.c
freeswitch/branches/mikej/sofiasip-upgrade/src/switch_rtp.c
freeswitch/branches/mikej/sofiasip-upgrade/w32/Library/FreeSwitchCore.vcproj
Log:
merged changes from trunk revisions 4706-4767, except for revision 4747 (was hack fix that is now corrected properly in sofia)
Modified: freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/Makefile.am Mon Mar 26 14:45:37 2007
@@ -25,7 +25,6 @@
src/switch_buffer.c \
src/switch_caller.c \
src/switch_channel.c \
-src/switch_config.c \
src/switch_console.c \
src/switch_core.c \
src/switch_core_db.c\
@@ -38,7 +37,10 @@
src/switch_ivr.c \
src/switch_stun.c\
src/switch_log.c\
-src/switch_xml.c
+src/switch_xml.c\
+libs/libteletone/src/libteletone_detect.c\
+libs/libteletone/src/libteletone_generate.c
+
library_includedir = $(PREFIX)/include
@@ -49,7 +51,6 @@
src/include/switch_buffer.h\
src/include/switch_caller.h\
src/include/switch_channel.h\
-src/include/switch_config.h\
src/include/switch_console.h\
src/include/switch_core.h\
src/include/switch_core_db.h\
@@ -66,7 +67,12 @@
src/include/switch_rtp.h\
src/include/switch_stun.h\
src/include/switch_log.h\
-src/include/switch_xml.h
+src/include/switch_xml.h\
+libs/libteletone/src/libteletone_detect.h\
+libs/libteletone/src/libteletone_generate.h\
+libs/libteletone/src/libteletone.h
+
+
CORE_CFLAGS = `$(switch_srcdir)/libs/apr/apr-1-config --cflags --cppflags --includes`
CORE_CFLAGS += `$(switch_srcdir)/libs/apr-util/apu-1-config --includes`
@@ -80,7 +86,6 @@
CORE_LIBS = libs/apr/libapr-1.la libs/apr-util/libaprutil-1.la
CORE_LIBS += libs/sqlite/libsqlite3.la libs/pcre/libpcre.la
CORE_LIBS += libs/srtp/libsrtp.la libs/libresample/libresample.la
-CORE_LIBS += libs/libteletone/libteletone.la
lib_LTLIBRARIES = libfreeswitch.la
libfreeswitch_la_CFLAGS = $(CORE_CFLAGS) $(AM_CFLAGS)
@@ -93,11 +98,12 @@
CLEANFILES = src/include/switch_version.h
BUILT_SOURCES = src/include/switch_version.h
-bin_PROGRAMS = freeswitch
-freeswitch_SOURCES = src/switch.c
+bin_PROGRAMS = freeswitch
+freeswitch_SOURCES = src/switch.c
nodist_freeswitch_SOURCES = src/include/switch_version.h
freeswitch_CFLAGS = $(AM_CFLAGS)
-freeswitch_LDADD = ${MOD_LINK} libs/apr/libapr-1.la
+freeswitch_LDFLAGS = $(AM_LDFLAGS) -rpath $(libdir)
+freeswitch_LDADD = libfreeswitch.la libs/apr/libapr-1.la
$(libfreeswitch_la_SOURCES): $(CORE_LIBS) $(switch_builddir)/quiet_libtool
@@ -112,11 +118,6 @@
@if [ ! -f $(DESTDIR)$(PREFIX)/conf/freeswitch.xml ] ; then \
$(INSTALL) conf/*.xml $(DESTDIR)$(PREFIX)/conf ; \
fi
- @if [ -f .libs/$(NAME) ] ; then \
- $(INSTALL) .libs/$(NAME) $(DESTDIR)$(PREFIX)/bin/$(NAME) ; \
- else \
- $(INSTALL) ./$(NAME) $(DESTDIR)$(PREFIX)/bin/$(NAME) ;\
- fi
.version:
touch .version
@@ -170,10 +171,6 @@
@cd libs/srtp && $(MAKE)
@$(TOUCH_TARGET)
-libs/libteletone/libteletone.la: libs/libteletone libs/libteletone/.update
- @cd libs/libteletone && $(MAKE)
- @$(TOUCH_TARGET)
-
libs/libresample/libresample.la: libs/libresample libs/libresample/.update
@cd libs/libresample && $(MAKE)
@$(TOUCH_TARGET)
Modified: freeswitch/branches/mikej/sofiasip-upgrade/acinclude.m4
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/acinclude.m4 (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/acinclude.m4 Mon Mar 26 14:45:37 2007
@@ -4,5 +4,6 @@
m4_include([build/config/ax_check_compiler_flags.m4])
m4_include([build/config/ac_gcc_archflag.m4])
m4_include([build/config/ac_gcc_x86_cpuid.m4])
+m4_include([build/config/ax_lib_mysql.m4])
m4_include([libs/apr/build/apr_common.m4])
m4_include([libs/curl/docs/libcurl/libcurl.m4])
Modified: freeswitch/branches/mikej/sofiasip-upgrade/bootstrap.sh
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/bootstrap.sh (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/bootstrap.sh Mon Mar 26 14:45:37 2007
@@ -60,7 +60,7 @@
lt_pversion=`$libtool --version 2>/dev/null|sed -e 's/([^)]*)//g;s/^[^0-9]*//;s/[- ].*//g;q'`
if test -z "$lt_pversion"; then
echo "bootstrap: libtool not found."
-echo " You need libtool version 1.5.7 or newer installed"
+echo " You need libtool version 1.5.14 or newer installed"
echo " to build FreeSWITCH from SVN."
exit 1
fi
@@ -68,16 +68,18 @@
IFS=.; set $lt_version; IFS=' '
lt_status="good"
-if test "$1" = "1"; then
- if test "$2" -lt "5" -o "$2" = "5" -a "$3" -lt "22" || test ; then
+if test "$1" -lt "2"; then
+ if test "$2" -lt "5" -o "$2" = "5" -a "$3" -lt "14" ; then
lt_status="bad"
fi
+else
+ lt_status="bad"
fi
if test $lt_status = "good"; then
echo "bootstrap: libtool version $lt_pversion (ok)"
else
echo "bootstrap: libtool version $lt_pversion found."
-echo " You need libtool version 1.5.7 or newer installed"
+echo " You need libtool version 1.5.14 or newer installed"
echo " to build FreeSWITCH from SVN."
exit 1
Modified: freeswitch/branches/mikej/sofiasip-upgrade/build/getlib.sh.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/build/getlib.sh.in (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/build/getlib.sh.in Mon Mar 26 14:45:37 2007
@@ -13,8 +13,14 @@
fi
fi
-base=http://svn.freeswitch.org/downloads/libs
+base=http://svn.freeswitch.org/downloads/libs/
tarfile=$1
+url=`echo $tarfile | grep "://"`
+
+if [ ! -z $url ] ; then
+ base=$tarfile/
+ tarfile=$2
+fi
if [ ! -d $tarfile ] ; then
uncompressed=`echo $tarfile | sed "s/\.tar\.gz//g"`
@@ -22,7 +28,7 @@
if [ ! -f $tarfile ] ; then
rm -fr $uncompressed
- $DOWNLOAD_CMD $base/$tarfile
+ $DOWNLOAD_CMD $base$tarfile
if [ ! -f $tarfile ] ; then
echo cannot find $tarfile
exit 1
Modified: freeswitch/branches/mikej/sofiasip-upgrade/build/modmake.rules.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/build/modmake.rules.in (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/build/modmake.rules.in Mon Mar 26 14:45:37 2007
@@ -117,7 +117,7 @@
fi;
mod_clean:
- @rm -fr *.$(DYNAMIC_LIB_EXTEN) *.o *.lo *~ .libs
+ @rm -fr *.$(DYNAMIC_LIB_EXTEN) *.o *.lo *~ .libs $(LOCAL_OBJS)
mod_install: $(DESTDIR)$(PREFIX)/mod/$(MODNAME).$(DYNAMIC_LIB_EXTEN)
Modified: freeswitch/branches/mikej/sofiasip-upgrade/configure.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/configure.in (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/configure.in Mon Mar 26 14:45:37 2007
@@ -291,11 +291,16 @@
AC_ARG_ENABLE(crash-protection,
[ --enable-crash-protection Compile with CRASH Protection],,[enable_crash_prot="no"])
+#AX_LIB_MYSQL([MINIMUM-VERSION])
+AX_LIB_MYSQL
+
AM_CONDITIONAL([CRASHPROT],[test "x$enable_crash_prot" != "xno"])
+AM_CONDITIONAL([HAVE_MYSQL],[test "$have_mysql" = "yes"])
AC_CONFIG_FILES([Makefile
src/Makefile
src/mod/Makefile
+ src/mod/event_handlers/mod_cdr/Makefile
src/include/switch_am_config.h
build/getlib.sh
build/modmake.rules])
@@ -308,7 +313,6 @@
AC_CONFIG_SUBDIRS(libs/srtp)
AC_CONFIG_SUBDIRS(libs/sqlite)
AC_CONFIG_SUBDIRS(libs/libresample)
-AC_CONFIG_SUBDIRS(libs/libteletone)
AC_CONFIG_SUBDIRS(libs/pcre)
AC_CONFIG_SUBDIRS(libs/apr)
AC_CONFIG_SUBDIRS(libs/apr-util)
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/xml/expat/configure.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/xml/expat/configure.in (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/xml/expat/configure.in Mon Mar 26 14:45:37 2007
@@ -86,9 +86,19 @@
if test "$cross_compiling" = "no"; then
AC_C_BIGENDIAN
else
- AC_DEFINE(AP_UNKNOWN_BYTE_ORDER,1,
- [byte order is unknown due to cross-compilation])
+ AC_DEFINE(AP_UNKNOWN_BYTE_ORDER,1,[byte order is unknown due to cross-compilation])
fi
+
+if test "$ac_cv_c_bigendian" = "yes"; then
+ AC_DEFINE(XML_BYTE_ORDER,21,[21 for big endian or 12 for little])
+else
+ AC_DEFINE(XML_BYTE_ORDER,12,[z])
+fi
+
+AC_DEFINE(XML_NS,,[Define me])
+AC_DEFINE(XML_DTD,,[Define me])
+AC_DEFINE(XML_CONTEXT_BYTES,1024,[1024])
+
AC_C_CONST
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/xml/expat/lib/winconfig.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/xml/expat/lib/winconfig.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/xml/expat/lib/winconfig.h Mon Mar 26 14:45:37 2007
@@ -23,5 +23,6 @@
#define XML_DTD 1
#define XML_BYTE_ORDER 12
#define XML_CONTEXT_BYTES 1024
+#define HAVE_MEMMOVE
#endif /* ndef WINCONFIG_H */
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/xml/expat/lib/xmlparse.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/xml/expat/lib/xmlparse.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/apr-util/xml/expat/lib/xmlparse.c Mon Mar 26 14:45:37 2007
@@ -14,6 +14,14 @@
#else
#include <config.h>
+#ifndef HAVE_MEMMOVE
+#ifdef HAVE_BCOPY
+#define memmove(d,s,l) bcopy((s),(d),(l))
+#else
+#define memmove(d,s,l) ;punting on memmove;
+#endif
+#endif
+
#ifdef HAVE_STRING_H
# include <string.h>
#endif
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/apr/build/apr_common.m4
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/apr/build/apr_common.m4 (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/apr/build/apr_common.m4 Mon Mar 26 14:45:37 2007
@@ -23,7 +23,7 @@
dnl
dnl Saves a snapshot of the configure command-line for later reuse
dnl
-AC_DEFUN(APR_CONFIG_NICE,[
+AC_DEFUN([APR_CONFIG_NICE],[
rm -f $1
cat >$1<<EOF
#! /bin/sh
@@ -80,7 +80,7 @@
dnl APR_MKDIR_P_CHECK(fallback-mkdir-p)
dnl checks whether mkdir -p works
-AC_DEFUN(APR_MKDIR_P_CHECK,[
+AC_DEFUN([APR_MKDIR_P_CHECK],[
AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[
test -d conftestdir && rm -rf conftestdir
mkdir -p conftestdir/somedir >/dev/null 2>&1
@@ -118,7 +118,7 @@
dnl Trying to optimize this is left as an exercise to the reader who wants
dnl to put up with more autoconf craziness. I give up.
dnl
-AC_DEFUN(APR_SUBDIR_CONFIG, [
+AC_DEFUN([APR_SUBDIR_CONFIG], [
# save our work to this point; this allows the sub-package to use it
AC_CACHE_SAVE
@@ -186,7 +186,7 @@
dnl
dnl Stores the variable (usually a Makefile macro) for later restoration
dnl
-AC_DEFUN(APR_SAVE_THE_ENVIRONMENT,[
+AC_DEFUN([APR_SAVE_THE_ENVIRONMENT],[
apr_ste_save_$1="$$1"
])dnl
@@ -198,7 +198,7 @@
dnl and restoring the original variable contents. This makes it possible
dnl for a user to override configure when it does something stupid.
dnl
-AC_DEFUN(APR_RESTORE_THE_ENVIRONMENT,[
+AC_DEFUN([APR_RESTORE_THE_ENVIRONMENT],[
if test "x$apr_ste_save_$1" = "x"; then
$2$1="$$1"
$1=
@@ -222,7 +222,7 @@
dnl
dnl Set variable iff it's currently null
dnl
-AC_DEFUN(APR_SETIFNULL,[
+AC_DEFUN([APR_SETIFNULL],[
if test -z "$$1"; then
test "x$silent" != "xyes" && echo " setting $1 to \"$2\""
$1="$2"
@@ -234,7 +234,7 @@
dnl
dnl Set variable no matter what
dnl
-AC_DEFUN(APR_SETVAR,[
+AC_DEFUN([APR_SETVAR],[
test "x$silent" != "xyes" && echo " forcing $1 to \"$2\""
$1="$2"
])dnl
@@ -244,7 +244,7 @@
dnl
dnl Add value to variable
dnl
-AC_DEFUN(APR_ADDTO,[
+AC_DEFUN([APR_ADDTO],[
if test "x$$1" = "x"; then
test "x$silent" != "xyes" && echo " setting $1 to \"$2\""
$1="$2"
@@ -271,7 +271,7 @@
dnl
dnl Remove a value from a variable
dnl
-AC_DEFUN(APR_REMOVEFROM,[
+AC_DEFUN([APR_REMOVEFROM],[
if test "x$$1" = "x$2"; then
test "x$silent" != "xyes" && echo " nulling $1"
$1=""
@@ -295,7 +295,7 @@
dnl
dnl APR_CHECK_DEFINE_FILES( symbol, header_file [header_file ...] )
dnl
-AC_DEFUN(APR_CHECK_DEFINE_FILES,[
+AC_DEFUN([APR_CHECK_DEFINE_FILES],[
AC_CACHE_CHECK([for $1 in $2],ac_cv_define_$1,[
ac_cv_define_$1=no
for curhdr in $2
@@ -317,7 +317,7 @@
dnl
dnl APR_CHECK_DEFINE(symbol, header_file)
dnl
-AC_DEFUN(APR_CHECK_DEFINE,[
+AC_DEFUN([APR_CHECK_DEFINE],[
AC_CACHE_CHECK([for $1 in $2],ac_cv_define_$1,[
AC_EGREP_CPP(YES_IS_DEFINED, [
#include <$2>
@@ -334,7 +334,7 @@
dnl
dnl APR_CHECK_APR_DEFINE( symbol )
dnl
-AC_DEFUN(APR_CHECK_APR_DEFINE,[
+AC_DEFUN([APR_CHECK_APR_DEFINE],[
apr_old_cppflags=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $INCLUDES"
AC_EGREP_CPP(YES_IS_DEFINED, [
@@ -450,7 +450,7 @@
dnl A variant of AC_CHECK_SIZEOF which allows the checking of
dnl sizes of non-builtin types
dnl
-AC_DEFUN(APR_CHECK_SIZEOF_EXTENDED,
+AC_DEFUN([APR_CHECK_SIZEOF_EXTENDED],
[changequote(<<,>>)dnl
dnl The name to #define
define(<<AC_TYPE_NAME>>, translit(sizeof_$2, [a-z *], [A-Z_P]))dnl
@@ -511,7 +511,7 @@
dnl string.
dnl
dnl
-AC_DEFUN(APR_CHECK_STRERROR_R_RC,[
+AC_DEFUN([APR_CHECK_STRERROR_R_RC],[
AC_MSG_CHECKING(for type of return code from strerror_r)
AC_TRY_RUN([
#include <errno.h>
@@ -546,7 +546,7 @@
dnl structure on this platform. Single UNIX Spec says d_ino,
dnl BSD uses d_fileno. Undef to find the real beast.
dnl
-AC_DEFUN(APR_CHECK_DIRENT_INODE, [
+AC_DEFUN([APR_CHECK_DIRENT_INODE], [
AC_CACHE_CHECK([for inode member of struct dirent], apr_cv_dirent_inode, [
apr_cv_dirent_inode=no
AC_TRY_COMPILE([
@@ -584,7 +584,7 @@
dnl Note that this is worthless without DT_xxx macros, so
dnl look for one while we are at it.
dnl
-AC_DEFUN(APR_CHECK_DIRENT_TYPE,[
+AC_DEFUN([APR_CHECK_DIRENT_TYPE],[
AC_CACHE_CHECK([for file type member of struct dirent], apr_cv_dirent_type,[
apr_cv_dirent_type=no
AC_TRY_COMPILE([
@@ -633,7 +633,7 @@
dnl all "." and "-" chars. If the 3rd parameter is "yes" then instead of
dnl setting to 1 or 0, we set FLAG-TO-SET to yes or no.
dnl
-AC_DEFUN(APR_FLAG_HEADERS,[
+AC_DEFUN([APR_FLAG_HEADERS],[
AC_CHECK_HEADERS($1)
for aprt_i in $1
do
@@ -654,7 +654,7 @@
dnl is "yes" then instead of setting to 1 or 0, we set FLAG-TO-SET
dnl to yes or no.
dnl
-AC_DEFUN(APR_FLAG_FUNCS,[
+AC_DEFUN([APR_FLAG_FUNCS],[
AC_CHECK_FUNCS($1)
for aprt_j in $1
do
@@ -679,7 +679,7 @@
dnl APR_EXPAND_VAR(fraz, $baz)
dnl $fraz is now "1/2/3"
dnl
-AC_DEFUN(APR_EXPAND_VAR,[
+AC_DEFUN([APR_EXPAND_VAR],[
ap_last=
ap_cur="$2"
while test "x${ap_cur}" != "x${ap_last}";
@@ -698,7 +698,7 @@
dnl orig_path="${prefix}/bar"
dnl APR_PATH_RELATIVE(final_path, $orig_path, $prefix)
dnl $final_path now contains "bar"
-AC_DEFUN(APR_PATH_RELATIVE,[
+AC_DEFUN([APR_PATH_RELATIVE],[
ap_stripped=`echo $2 | sed -e "s#^$3##"`
# check if the stripping was successful
if test "x$2" != "x${ap_stripped}"; then
@@ -716,12 +716,12 @@
dnl Note: this define must be on one line so that it can be properly returned
dnl as the help string. When using this macro with a multi-line RHS, ensure
dnl that you surround the macro invocation with []s
-AC_DEFUN(APR_HELP_STRING,[ifelse(regexp(AC_ACVERSION, 2\.1), -1, AC_HELP_STRING([$1],[$2]),[ ][$1] substr([ ],len($1))[$2])])
+AC_DEFUN([APR_HELP_STRING],[ifelse(regexp(AC_ACVERSION, 2\.1), -1, AC_HELP_STRING([$1],[$2]),[ ][$1] substr([ ],len($1))[$2])])
dnl
dnl APR_LAYOUT(configlayout, layoutname [, extravars])
dnl
-AC_DEFUN(APR_LAYOUT,[
+AC_DEFUN([APR_LAYOUT],[
if test ! -f $srcdir/config.layout; then
echo "** Error: Layout file $srcdir/config.layout not found"
echo "** Error: Cannot use undefined layout '$LAYOUT'"
@@ -784,7 +784,7 @@
dnl
dnl APR_ENABLE_LAYOUT(default layout name [, extra vars])
dnl
-AC_DEFUN(APR_ENABLE_LAYOUT,[
+AC_DEFUN([APR_ENABLE_LAYOUT],[
AC_ARG_ENABLE(layout,
[ --enable-layout=LAYOUT],[
LAYOUT=$enableval
@@ -805,7 +805,7 @@
dnl a reimplementation of autoconf's argument parser,
dnl used here to allow us to co-exist layouts and argument based
dnl set ups.
-AC_DEFUN(APR_PARSE_ARGUMENTS,[
+AC_DEFUN([APR_PARSE_ARGUMENTS],[
ac_prev=
# Retrieve the command-line arguments. The eval is needed because
# the arguments are quoted to preserve accuracy.
@@ -931,7 +931,7 @@
dnl
dnl Determine what program we can use to generate .deps-style dependencies
dnl
-AC_DEFUN(APR_CHECK_DEPEND,[
+AC_DEFUN([APR_CHECK_DEPEND],[
dnl Try to determine what depend program we can use
dnl All GCC-variants should have -MM.
dnl If not, then we can check on those, too.
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/codec/gsm/configure.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/codec/gsm/configure.in (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/codec/gsm/configure.in Mon Mar 26 14:45:37 2007
@@ -5,7 +5,6 @@
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AM_INIT_AUTOMAKE(libgsm,0.1)
AC_CONFIG_SRCDIR([src])
-#AC_CONFIG_HEADER([])
# Checks for programs.
AC_PROG_CC
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/libteletone/configure.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/libteletone/configure.in (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/libteletone/configure.in Mon Mar 26 14:45:37 2007
@@ -6,7 +6,6 @@
AC_CONFIG_AUX_DIR(build)
AM_INIT_AUTOMAKE(libteletone,0.1)
AC_CONFIG_SRCDIR([src])
-#AC_CONFIG_HEADER([])
# Checks for programs.
AC_PROG_CC
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/portaudio/Makefile.in
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/portaudio/Makefile.in (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/portaudio/Makefile.in Mon Mar 26 14:45:37 2007
@@ -57,61 +57,61 @@
src/common/pa_trace.o
TESTS = \
- bin/paqa_devs \
- bin/paqa_errs \
- bin/patest1 \
- bin/patest_buffer \
- bin/patest_callbackstop \
- bin/patest_clip \
- bin/patest_dither \
- bin/patest_hang \
- bin/patest_in_overflow \
- bin/patest_latency \
- bin/patest_leftright \
- bin/patest_longsine \
- bin/patest_many \
- bin/patest_maxsines \
- bin/patest_multi_sine \
- bin/patest_out_underflow \
- bin/patest_pink \
- bin/patest_prime \
- bin/patest_read_record \
- bin/patest_read_write_wire \
- bin/patest_record \
- bin/patest_ringmix \
- bin/patest_saw \
- bin/patest_sine8 \
- bin/patest_sine \
- bin/patest_sine_formats \
- bin/patest_sine_time \
- bin/patest_start_stop \
- bin/patest_stop \
- bin/patest_stop_playout \
- bin/patest_toomanysines \
- bin/patest_underflow \
- bin/patest_wire \
- bin/patest_write_sine \
- bin/pa_devs \
- bin/pa_fuzz \
- bin/pa_minlat
+ test/paqa_devs \
+ test/paqa_errs \
+ test/patest1 \
+ test/patest_buffer \
+ test/patest_callbackstop \
+ test/patest_clip \
+ test/patest_dither \
+ test/patest_hang \
+ test/patest_in_overflow \
+ test/patest_latency \
+ test/patest_leftright \
+ test/patest_longsine \
+ test/patest_many \
+ test/patest_maxsines \
+ test/patest_multi_sine \
+ test/patest_out_underflow \
+ test/patest_pink \
+ test/patest_prime \
+ test/patest_read_record \
+ test/patest_read_write_wire \
+ test/patest_record \
+ test/patest_ringmix \
+ test/patest_saw \
+ test/patest_sine8 \
+ test/patest_sine \
+ test/patest_sine_formats \
+ test/patest_sine_time \
+ test/patest_start_stop \
+ test/patest_stop \
+ test/patest_stop_playout \
+ test/patest_toomanysines \
+ test/patest_underflow \
+ test/patest_wire \
+ test/patest_write_sine \
+ test/pa_devs \
+ test/pa_fuzz \
+ test/pa_minlat
# Most of these don't compile yet. Put them in TESTS, above, if
# you want to try to compile them...
ALL_TESTS = \
$(TESTS) \
- bin/patest_sync \
- bin/debug_convert \
- bin/debug_dither_calc \
- bin/debug_dual \
- bin/debug_multi_in \
- bin/debug_multi_out \
- bin/debug_record \
- bin/debug_record_reuse \
- bin/debug_sine_amp \
- bin/debug_sine \
- bin/debug_sine_formats \
- bin/debug_srate \
- bin/debug_test1
+ test/patest_sync \
+ test/debug_convert \
+ test/debug_dither_calc \
+ test/debug_dual \
+ test/debug_multi_in \
+ test/debug_multi_out \
+ test/debug_record \
+ test/debug_record_reuse \
+ test/debug_sine_amp \
+ test/debug_sine \
+ test/debug_sine_formats \
+ test/debug_srate \
+ test/debug_test1
OBJS = $(COMMON_OBJS) $(OTHER_OBJS)
@@ -128,9 +128,8 @@
lib/$(PALIB): lib-stamp $(LTOBJS) $(MAKEFILE) $(PAINC)
$(LIBTOOL) --mode=link $(CC) $(PA_LDFLAGS) -o lib/$(PALIB) $(LTOBJS) $(DLL_LIBS)
-$(ALL_TESTS): bin/%: lib/$(PALIB) $(MAKEFILE) $(PAINC) test/%.c
- $(LIBTOOL) --mode=link $(CC) -o $@ $(CFLAGS) $(top_srcdir)/test/$*.c lib/$(PALIB) $(LIBS)
-
+$(ALL_TESTS): lib/$(PALIB) $(MAKEFILE) $(PAINC)
+ $(LIBTOOL) --mode=link $(CC) -o $@ $(CFLAGS) $(top_srcdir)/$@.c lib/$(PALIB) $(LIBS)
install: lib/$(PALIB) portaudio-2.0.pc
$(INSTALL) -d $(DESTDIR)$(libdir)
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/portaudio/src/common/pa_ringbuffer.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/portaudio/src/common/pa_ringbuffer.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/portaudio/src/common/pa_ringbuffer.c Mon Mar 26 14:45:37 2007
@@ -71,7 +71,7 @@
*
****************/
-#if defined(HAVE_LIBKERN_OSATOMIC_H) && defined(__APPLE__) || defined(__FreeBSD__)
+#if defined(HAVE_LIBKERN_OSATOMIC_H) && (defined(__APPLE__) || defined(__FreeBSD__))
# include <libkern/OSAtomic.h>
/* Here are the memory barrier functions. Mac OS X and FreeBSD only provide
full memory barriers, so the three types of barriers are the same. */
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/xmlrpc-c/configure.gnu
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/xmlrpc-c/configure.gnu (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/xmlrpc-c/configure.gnu Mon Mar 26 14:45:37 2007
@@ -1,2 +1,2 @@
#! /bin/sh
-./configure "$@" --disable-cplusplus --disable-wininet-client --disable-libwww-client --disable-shared --with-pic
+./configure "$@" --disable-cplusplus --disable-wininet-client --disable-libwww-client --disable-shared --with-pic --disable-curl-client
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch.h Mon Mar 26 14:45:37 2007
@@ -79,7 +79,6 @@
#include <switch_console.h>
#include <switch_utils.h>
#include <switch_caller.h>
-#include <switch_config.h>
#include <switch_frame.h>
#include <switch_module_interfaces.h>
#include <switch_channel.h>
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_config.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_config.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_config.h Mon Mar 26 14:45:37 2007
@@ -60,6 +60,8 @@
SWITCH_BEGIN_EXTERN_C
+typedef struct switch_config switch_config_t;
+
/*! \brief A simple file handle representing an open configuration file **/
struct switch_config {
/*! FILE stream buffer to the opened file */
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_log.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_log.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_log.h Mon Mar 26 14:45:37 2007
@@ -64,6 +64,9 @@
switch_time_t timestamp;
/*! A pointer to where the actual content of the message starts (skipping past the preformatted portion) */
char *content;
+
+ /* To maintain abi, only add new elements to the end of this struct and do not delete any elements */
+
} switch_log_node_t;
typedef switch_status_t (*switch_log_function_t)(const switch_log_node_t *node, switch_log_level_t level);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_resample.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_resample.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_resample.h Mon Mar 26 14:45:37 2007
@@ -155,6 +155,14 @@
SWITCH_DECLARE(void) switch_swap_linear(int16_t *buf, int len);
/*!
+ \brief Generate static noise
+ \param data the audio data buffer
+ \param samples the number of 2 byte samples
+ \param divisor the volume factor
+ */
+SWITCH_DECLARE(void) switch_generate_sln_silence(int16_t *data, uint32_t samples, uint32_t divisor);
+
+/*!
\brief Change the volume of a signed linear audio frame
\param data the audio data
\param samples the number of 2 byte samples
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/include/switch_types.h Mon Mar 26 14:45:37 2007
@@ -943,7 +943,6 @@
typedef struct switch_codec_implementation switch_codec_implementation_t;
typedef struct switch_buffer switch_buffer_t;
typedef struct switch_codec_settings switch_codec_settings_t;
-typedef struct switch_config switch_config_t;
typedef struct switch_io_event_hook_outgoing_channel switch_io_event_hook_outgoing_channel_t;
typedef struct switch_io_event_hook_answer_channel switch_io_event_hook_answer_channel_t;
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/Makefile.am
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/Makefile.am (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/Makefile.am Mon Mar 26 14:45:37 2007
@@ -1,9 +1,9 @@
CONF_MODULES=if test ! -f $(switch_builddir)/modules.conf ; then cp $(switch_builddir)/build/modules.conf.in $(switch_builddir)/modules.conf ; fi ; conf_modules=`grep -v "\#" $(switch_builddir)/modules.conf` ;
FOUND_MODULES=found_modules=`find . -type d -name mod_\* | sed -e 's|^\./||'` ;
-OUR_MODULES=if test -z "$(MODULES)" ; then our_modules=$$conf_modules ; else our_modules=$(MODULES) ; fi ;
+OUR_MODULES=if test -z "$(MODULES)" ; then our_modules=$$conf_modules ; else our_modules="$(MODULES)" ; fi ;
OUR_CLEAN_MODULES=if test -z "$(MODULES)" ; then tmp_clean_modules=`echo $$conf_modules $$found_modules`; \
our_clean_modules=`for i in $$tmp_clean_modules ; do echo $$i ; done | sort | uniq` ; \
- else our_clean_modules=$(MODULES) ; fi ;
+ else our_clean_modules="$(MODULES)" ; fi ;
MOD_NAME=`echo $$i | sed -e 's|^.*/||'`
MOD_DIR=`if test -d $(switch_srcdir)/src/mod/$$i ; then echo $(switch_srcdir)/src/mod/$$i ; else echo $$i ; fi;`
AM_MAKEFLAGS = `test -n "$(VERBOSE)" || echo -s`
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/applications/mod_conference/mod_conference.c Mon Mar 26 14:45:37 2007
@@ -735,7 +735,7 @@
if (conference->fnode->leadin) {
conference->fnode->leadin--;
} else {
- ready++;
+ file_sample_len = samples;
if (conference->fnode->type == NODE_TYPE_SPEECH) {
switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_BLOCKING;
uint32_t rate = conference->rate;
@@ -758,34 +758,40 @@
}
}
has_file_data = 1;
+ ready++;
} else {
has_file_data = 0;
}
if (conference->async_fnode) {
- switch_core_file_read(&conference->async_fnode->fh, async_file_frame, &file_sample_len);
-
- if (file_sample_len <= 0) {
- conference->async_fnode->done++;
+ /* Lead in time */
+ if (conference->async_fnode->leadin) {
+ conference->async_fnode->leadin--;
} else {
- if (has_file_data) {
- switch_size_t x;
- for (x = 0; x < file_sample_len; x++) {
- int32_t z;
- int16_t *bptr, *muxed;
-
- muxed = (int16_t *) file_frame;
- bptr = (int16_t *) async_file_frame;
- z = muxed[x] + bptr[x];
- switch_normalize_to_16bit(z);
- muxed[x] = (int16_t)z;
- }
+ file_sample_len = samples;
+ switch_core_file_read(&conference->async_fnode->fh, async_file_frame, &file_sample_len);
+ if (file_sample_len <= 0) {
+ conference->async_fnode->done++;
} else {
- memcpy(file_frame, async_file_frame, file_sample_len * 2);
- has_file_data = 1;
+ if (has_file_data) {
+ switch_size_t x;
+ for (x = 0; x < file_sample_len; x++) {
+ int32_t z;
+ int16_t *bptr, *muxed;
+
+ muxed = (int16_t *) file_frame;
+ bptr = (int16_t *) async_file_frame;
+ z = muxed[x] + bptr[x];
+ switch_normalize_to_16bit(z);
+ muxed[x] = (int16_t)z;
+ }
+ } else {
+ memcpy(file_frame, async_file_frame, file_sample_len * 2);
+ has_file_data = 1;
+ ready++;
+ }
}
}
-
}
if (ready) {
@@ -833,22 +839,22 @@
if (imember->read > imember->len) {
imember->len = imember->read;
}
-
+
bptr = (int16_t *) imember->frame;
muxed = (int16_t *) omember->mux_frame;
-
+
for (x = 0; x < imember->read / 2; x++) {
int32_t z = muxed[x] + bptr[x];
switch_normalize_to_16bit(z);
muxed[x] = (int16_t)z;
}
-
+
ready++;
}
}
}
-
+
/* Go back and write each member his dedicated copy of the audio frame that does not contain his own audio. */
for (imember = conference->members; imember; imember = imember->next) {
if (switch_test_flag(imember, MFLAG_RUNNING)) {
@@ -1466,7 +1472,7 @@
samples,
NULL) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer %s success interval: %u samples: %u\n",
- member->conference->timer_name, member->conference->interval, samples);
+ member->conference->timer_name, interval, samples);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed. Conference Cannot Start\n");
return;
@@ -1696,7 +1702,7 @@
} else {
if (switch_test_flag(member, MFLAG_WASTE_BANDWIDTH)) {
- memset(write_frame.data, 255, bytes);
+ switch_generate_sln_silence(write_frame.data, samples, 1400);
write_frame.datalen = bytes;
write_frame.samples = samples;
write_frame.timestamp = timer.samplecount;
@@ -1958,7 +1964,7 @@
}
}
- if (!strncasecmp(file, "say:", 4)) {
+ if (!async && !strncasecmp(file, "say:", 4)) {
status = conference_say(conference, file + 4, leadin);
goto done;
}
@@ -1969,10 +1975,12 @@
goto done;
}
file = dfile;
- } else {
+ } else if (!async) {
status = conference_say(conference, file, leadin);
goto done;
- }
+ } else {
+ goto done;
+ }
}
/* Setup a memory pool to use. */
@@ -2017,8 +2025,10 @@
conference->async_fnode = fnode;
if (nptr) {
- switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
- switch_core_speech_close(&conference->fnode->sh, &flags);
+ switch_memory_pool_t *pool;
+ switch_core_file_close(&nptr->fh);
+ pool = nptr->pool;
+ switch_core_destroy_memory_pool(&pool);
}
} else {
@@ -4046,10 +4056,12 @@
NULL,
member.pool) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
- conference->rate, conference->interval);
+ read_codec->implementation->samples_per_second,
+ read_codec->implementation->microseconds_per_frame / 1000);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
- conference->rate, conference->interval);
+ read_codec->implementation->samples_per_second,
+ read_codec->implementation->microseconds_per_frame / 1000);
flags = 0;
goto done;
}
@@ -4075,17 +4087,19 @@
if (switch_core_codec_init(&member.write_codec,
"L16",
NULL,
- conference->rate,
- conference->interval,
+ read_codec->implementation->samples_per_second,
+ read_codec->implementation->microseconds_per_frame / 1000,
1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL,
member.pool) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
- conference->rate, conference->interval);
+ read_codec->implementation->samples_per_second,
+ read_codec->implementation->microseconds_per_frame / 1000);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
- conference->rate, conference->interval);
+ read_codec->implementation->samples_per_second,
+ read_codec->implementation->microseconds_per_frame / 1000);
flags = 0;
goto codec_done2;
}
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/asr_tts/mod_lumenvox/Makefile
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/asr_tts/mod_lumenvox/Makefile (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/asr_tts/mod_lumenvox/Makefile Mon Mar 26 14:45:37 2007
@@ -3,9 +3,9 @@
# and define these variables to impact your build
-LOCAL_CFLAGS= -fpermissive -Wno-deprecated -Wno-conversion -fpermissive -Wno-unused -Wno-comment -Wno-sign-compare \
- -Wno-conversion -Wno-reorder -I/opt/lumenvox/eng\ine_7.0/include
-LOCAL_LDFLAGS= -L/opt/lumenvox/engine_7.0/lib -llv_lvspeechport
-LOCAL_OBJS=
+LVENGINE_DIR=/opt/lumenvox/engine_7.0
+LOCAL_CFLAGS= -fpermissive -Wno-deprecated -Wno-conversion -fpermissive -Wno-unused
+LOCAL_CFLAGS+= -Wno-comment -Wno-sign-compare -Wno-conversion -Wno-reorder -I$(LVINCLUDE)
+LOCAL_LDFLAGS= -L$(LVLIB) -llv_lvspeechport
include ../../../../build/modmake.rules
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g723_1/Makefile
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g723_1/Makefile (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g723_1/Makefile Mon Mar 26 14:45:37 2007
@@ -1,6 +1,8 @@
BASE=../../../..
+DIR=$(BASE)/libs/libg723_1
+A=$(DIR)/.libs/libg723.a
-LOCAL_INSERT_CFLAGS=if test -d $(BASE)/libs/libg723_1; then echo "-I$(PREFIX)/include/g723" ; else echo "-DG723_PASSTHROUGH" ; fi ;
-LOCAL_INSERT_LDFLAGS=test ! -d $(BASE)/libs/libg723_1 || echo "-lg723"
+LOCAL_INSERT_CFLAGS=if test -f $(A); then echo "-I$(DIR)/src/include" ; else echo "-DG723_PASSTHROUGH" ; fi ;
+LOCAL_INSERT_LDFLAGS=test ! -f $(A) || echo $(A)
include $(BASE)/build/modmake.rules
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g729/Makefile
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g729/Makefile (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/codecs/mod_g729/Makefile Mon Mar 26 14:45:37 2007
@@ -1,4 +1,7 @@
BASE=../../../..
-LOCAL_INSERT_CFLAGS=if test -d $(BASE)/libs/libg729; then echo "-I$(PREFIX)/include/libg729" ; else echo "-DG729_PASSTHROUGH" ; fi ;
-LOCAL_INSERT_LDFLAGS=test ! -d $(BASE)/libs/libg729 || echo "-lg729"
+DIR=$(BASE)/libs/libg729
+A=$(DIR)/.libs/libg729.a
+
+LOCAL_INSERT_CFLAGS=if test -f $(A); then echo "-I$(DIR)/src/include" ; else echo "-DG729_PASSTHROUGH" ; fi ;
+LOCAL_INSERT_LDFLAGS=test ! -f $(A) || echo $(A)
include $(BASE)/build/modmake.rules
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c Mon Mar 26 14:45:37 2007
@@ -34,11 +34,8 @@
#include <sys/stat.h>
#include <fcntl.h>
-
static const char modname[] = "mod_dialplan_xml";
-
-
typedef enum {
BREAK_ON_TRUE,
BREAK_ON_FALSE,
@@ -193,36 +190,26 @@
return proceed;
}
-static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session, void *arg)
+static switch_status_t dialplan_xml_locate(switch_core_session_t *session,
+ switch_caller_profile_t *caller_profile,
+ switch_xml_t *root,
+ switch_xml_t *node)
{
- switch_caller_profile_t *caller_profile;
- switch_caller_extension_t *extension = NULL;
+ switch_status_t status = SWITCH_STATUS_GENERR;
switch_channel_t *channel;
- switch_xml_t alt_root = NULL, cfg, xml, xcontext, xexten;
- char *context = NULL;
switch_stream_handle_t stream = {0};
switch_size_t encode_len = 1024, new_len = 0;
char *encode_buf = NULL;
char *prof[12] = {0}, *prof_names[12] = {0}, *e = NULL;
switch_hash_index_t *hi;
uint32_t x = 0;
- char *alt_path = (char *) arg;
channel = switch_core_session_get_channel(session);
- if ((caller_profile = switch_channel_get_caller_profile(channel))) {
- context = caller_profile->context ? caller_profile->context : "default";
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Obtaining Profile!\n");
- return NULL;
- }
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Processing %s->%s!\n", caller_profile->caller_id_name,
- caller_profile->destination_number);
SWITCH_STANDARD_STREAM(stream);
if (!(encode_buf = malloc(encode_len))) {
- return NULL;
+ goto done;
}
prof[0] = caller_profile->context;
@@ -250,6 +237,9 @@
prof_names[10] = "uuid";
for (x = 0; prof[x]; x++) {
+ if (switch_strlen_zero(prof[x])) {
+ continue;
+ }
new_len = (strlen(prof[x]) * 3) + 1;
if (encode_len < new_len) {
char *tmp;
@@ -257,8 +247,7 @@
encode_len = new_len;
if (!(tmp = realloc(encode_buf, encode_len))) {
- switch_safe_free(encode_buf);
- return NULL;
+ goto done;
}
encode_buf = tmp;
@@ -280,8 +269,7 @@
encode_len = new_len;
if (!(tmp = realloc(encode_buf, encode_len))) {
- switch_safe_free(encode_buf);
- return NULL;
+ goto done;
}
encode_buf = tmp;
@@ -298,11 +286,43 @@
*e = '\0';
}
- if (!switch_strlen_zero(alt_path)) {
+ status = switch_xml_locate("dialplan", NULL, NULL, NULL, root, node, stream.data);
+
+done:
+ switch_safe_free(stream.data);
+ switch_safe_free(encode_buf);
+ return status;
+}
+
+static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session, void *arg)
+{
+ switch_caller_profile_t *caller_profile;
+ switch_caller_extension_t *extension = NULL;
+ switch_channel_t *channel;
+ switch_xml_t alt_root = NULL, cfg, xml = NULL, xcontext, xexten;
+ char *alt_path = (char *) arg;
+
+ channel = switch_core_session_get_channel(session);
+
+ if ((caller_profile = switch_channel_get_caller_profile(channel))) {
+ if (!caller_profile->context) {
+ caller_profile->context = "default";
+ }
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Obtaining Profile!\n");
+ goto done;
+ }
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Processing %s->%s!\n", caller_profile->caller_id_name,
+ caller_profile->destination_number);
+
+ /* get our handle to the "dialplan" section of the config */
+
+ if (!switch_strlen_zero(alt_path)) {
switch_xml_t conf = NULL, tag = NULL;
if (!(alt_root = switch_xml_parse_file(alt_path))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of [%s] failed\n", alt_path);
- return NULL;
+ goto done;
}
if ((conf = switch_xml_find_child(alt_root, "section", "name", "dialplan")) &&
@@ -312,22 +332,20 @@
cfg = tag;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of dialplan failed\n");
- return NULL;
+ goto done;
}
- } else if (switch_xml_locate("dialplan", NULL, NULL, NULL, &xml, &cfg, stream.data) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of dialplan failed\n");
- return NULL;
+ } else {
+ if (dialplan_xml_locate(session, caller_profile, &xml, &cfg) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of dialplan failed\n");
+ goto done;
+ }
}
-
- switch_safe_free(stream.data);
- switch_safe_free(encode_buf);
-
- if (!(xcontext = switch_xml_find_child(cfg, "context", "name", context))) {
+ /* get a handle to the context tag */
+ if (!(xcontext = switch_xml_find_child(cfg, "context", "name", caller_profile->context))) {
if (!(xcontext = switch_xml_find_child(cfg, "context", "name", "global"))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "context %s not found\n", context);
- switch_xml_free(xml);
- return NULL;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "context %s not found\n", caller_profile->context);
+ goto done;
}
}
@@ -355,6 +373,8 @@
switch_channel_set_state(channel, CS_EXECUTE);
}
+done:
+ switch_xml_free(xml);
return extension;
}
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_iax/mod_iax.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_iax/mod_iax.c Mon Mar 26 14:45:37 2007
@@ -587,9 +587,7 @@
default:
break;
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL KILL\n", switch_channel_get_name(channel));
-
-
+
return SWITCH_STATUS_SUCCESS;
}
@@ -649,7 +647,8 @@
private_t *tech_pvt = NULL;
switch_time_t started = switch_time_now();
unsigned int elapsed;
-
+ switch_byte_t *data;
+
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -703,12 +702,14 @@
return SWITCH_STATUS_FALSE;
cng:
- tech_pvt->read_frame.datalen = 13;
- memset(tech_pvt->read_frame.data, 0, 13);
+ data = (switch_byte_t *) tech_pvt->read_frame.data;
+ data[0] = 65;
+ data[1] = 0;
+ tech_pvt->read_frame.datalen = 2;
tech_pvt->read_frame.flags = SFF_CNG;
*frame = &tech_pvt->read_frame;
return SWITCH_STATUS_SUCCESS;
-
+
}
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/Makefile
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/Makefile (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/Makefile Mon Mar 26 14:45:37 2007
@@ -1,10 +1,36 @@
BASE=../../../..
-LOCAL_CFLAGS =-I/usr/local/include -I/usr/src/libpri -I/usr/src/linux/include -I. -I/usr/include
-LOCAL_CFLAGS +=-D__LINUX__ -D_REENTRANT -D_GNU_SOURCE -DAFT_A104 -DWANPIPE_TDM_API -I$(switch_srcdir)/libs/libteletone/src
-LOCAL_CFLAGS +=-w
-LOCAL_LDFLAGS=-lsangoma $(BASE)/libs/libteletone/libteletone.la
-LOCAL_OBJS=ss7boost_client.o
-include $(BASE)/build/modmake.rules
+LIBPRI_HOST=http://ftp.digium.com/pub/libpri
+LIBPRI=libpri-1.2.4
+LIBPRI_FILE=$(LIBPRI).tar.gz
+LIBPRI_DIR=$(BASE)/libs/$(LIBPRI)
+WANPIPE=wanpipe-3.1.0.p13
+WANPIPE_HOST=ftp://ftp.sangoma.com/linux/custom/3.1
+WANPIPE_FILE=$(WANPIPE).tgz
+WANPIPE_DIR=$(BASE)/libs/$(WANPIPE)
+WANPIPE_INCLUDE=$(WANPIPE_DIR)/patches/kdrivers/include
+WANPIPE_KO=$(WANPIPE_DIR)/patches/kdrivers/src/net/wanpipe.ko
+WANPIPE_INSTALLED_KO=$(shell echo "/lib/modules/`uname -r`/kernel/drivers/net/wan/wanpipe.ko")
+LIBSANGOMA_DIR=$(WANPIPE_DIR)/api/libsangoma
+LOCAL_CFLAGS =-w -I$(WANPIPE_INCLUDE) -I$(LIBSANGOMA_DIR) -I/usr/local/include -I$(LIBPRI_DIR) -I/usr/src/linux/include -I. -I/usr/include
+LOCAL_CFLAGS +=-D__LINUX__ -D_REENTRANT -D_GNU_SOURCE -DAFT_A104 -DWANPIPE_TDM_API -I$(switch_srcdir)/libs/libteletone/src -D_GNUC_ -DWANPIPE_TDM_API
+LOCAL_OBJS = ss7boost_client.o $(LIBPRI_DIR)/copy_string.o $(LIBPRI_DIR)/pri.o $(LIBPRI_DIR)/q921.o $(LIBPRI_DIR)/prisched.o $(LIBPRI_DIR)/q931.o $(LIBPRI_DIR)/pri_facility.o $(LIBSANGOMA_DIR)/libsangoma.o $(LIBSANGOMA_DIR)/sangoma_pri.o
+
+include $(BASE)/build/modmake.rules
+
+$(LIBPRI_DIR):
+ $(GETLIB) $(LIBPRI_HOST) $(LIBPRI_FILE)
+
+$(WANPIPE_DIR):
+ $(GETLIB) $(WANPIPE_HOST) $(WANPIPE_FILE)
+
+$(WANPIPE_KO): $(WANPIPE_DIR)
+ cd $(WANPIPE_DIR) && $(MAKE)
+ @$(TOUCH_TARGET)
+
+$(WANPIPE_INSTALLED_KO): $(WANPIPE_KO)
+ cd $(WANPIPE_DIR) && $(MAKE) install
+
+local_depend: $(LIBPRI_DIR) $(WANPIPE_KO)
+
+local_install: $(WANPIPE_INSTALLED_KO)
-local_depend:
- MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install libsangoma --prefix=$(PREFIX) --with-libpri=/usr/src/libpri
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c Mon Mar 26 14:45:37 2007
@@ -80,7 +80,6 @@
char map[SANGOMA_MAX_CHAN_PER_SPAN][SWITCH_UUID_FORMATTED_LENGTH + 1];
};
-
unsigned int txseq=0;
unsigned int rxseq=0;
@@ -116,6 +115,8 @@
switch_mutex_t *hash_mutex;
switch_mutex_t *channel_mutex;
ss7boost_handle_t *ss7boost_handle;
+ uint32_t fxo_index;
+ uint32_t fxs_index;
} globals;
struct wanpipe_pri_span {
@@ -138,6 +139,37 @@
typedef struct wpsock wpsock_t;
+typedef enum {
+ ANALOG_TYPE_UNKNOWN,
+ ANALOG_TYPE_PHONE_FXS,
+ ANLOG_TYPE_LINE_FXO
+} analog_type_t;
+
+typedef enum {
+ ANALOG_STATE_DOWN,
+ ANALOG_STATE_ONHOOK,
+ ANALOG_STATE_OFFHOOK,
+ ANALOG_STATE_RING
+} analog_state_t;
+
+struct analog_channel {
+ analog_type_t a_type;
+ analog_state_t state;
+ wpsock_t *sock;
+ int chan;
+ int span;
+ char *device;
+ char *user;
+ char *domain;
+ char *cid_name;
+ char *cid_num;
+};
+typedef struct analog_channel analog_channel_t;
+
+#define MAX_ANALOG_CHANNELS 128
+static struct analog_channel *FXS_ANALOG_CHANNELS[MAX_ANALOG_CHANNELS];
+static struct analog_channel *FXO_ANALOG_CHANNELS[MAX_ANALOG_CHANNELS];
+
static struct wanpipe_pri_span *SPANS[MAX_SPANS];
struct private_object {
@@ -176,6 +208,105 @@
};
typedef struct private_object private_object_t;
+
+
+static int local_sangoma_tdm_read_event(sng_fd_t fd, wp_tdm_api_rx_hdr_t *rx_event)
+{
+ wanpipe_tdm_api_t tdm_api[1];
+
+#if defined(WIN32)
+ rx_event = &last_tdm_api_event_buffer;
+#else
+ int err;
+
+ tdm_api->wp_tdm_cmd.cmd = SIOC_WP_TDM_READ_EVENT;
+
+ if ((err = sangoma_tdm_cmd_exec(fd, tdm_api))) {
+ return err;
+ }
+
+ rx_event = &tdm_api->wp_tdm_cmd.event;
+#endif
+
+ return 0;
+}
+
+static int analog_set_state(analog_channel_t *alc, analog_state_t state)
+{
+ alc->state = state;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Changing State to %d\n", state);
+}
+
+static void analog_check_state(analog_channel_t *alc)
+{
+ wanpipe_tdm_api_t tdm_api;
+
+ switch(alc->state) {
+ case ANALOG_STATE_DOWN:
+ sangoma_tdm_enable_rxhook_events(alc->sock->fd, &tdm_api);
+ analog_set_state(alc, ANALOG_STATE_ONHOOK);
+ break;
+ default:
+ break;
+ }
+}
+
+static void analog_parse_event(analog_channel_t *alc)
+{
+ wp_tdm_api_rx_hdr_t rx_event;
+ int err = local_sangoma_tdm_read_event(alc->sock->fd, &rx_event);
+
+ if (err < 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error reading event!\n");
+ return;
+ }
+
+ switch (rx_event.wp_tdm_api_event_type) {
+ case WP_TDM_EVENT_RXHOOK:
+ printf("hook\n");
+ break;
+ }
+
+}
+
+static void *SWITCH_THREAD_FUNC fxs_thread_run(switch_thread_t *thread, void *obj)
+{
+
+ for(;;) {
+ int i = 0, sel_on = -1;
+ fd_set oob;
+ FD_ZERO(&oob);
+
+ for(i = 0; i < globals.fxs_index; i++) {
+ int fd;
+ assert(FXS_ANALOG_CHANNELS[i]);
+ assert(FXS_ANALOG_CHANNELS[i]->sock);
+
+ fd = FXS_ANALOG_CHANNELS[i]->sock->fd;
+
+ analog_check_state(FXS_ANALOG_CHANNELS[i]);
+
+ FD_SET(fd, &oob);
+
+ if (fd > sel_on) {
+ sel_on = fd;
+ }
+ }
+
+ if (sel_on > -1) {
+ if (select(++sel_on, NULL, NULL, &oob, NULL)) {
+ for(i = 0; i < globals.fxs_index; i++) {
+ int fd = FXS_ANALOG_CHANNELS[i]->sock->fd;
+ if (FD_ISSET(fd, &oob)) {
+ analog_parse_event(FXS_ANALOG_CHANNELS[i]);
+ }
+ }
+ }
+ }
+ }
+}
+
+
static int wp_close(private_object_t *tech_pvt)
{
int ret = 0;
@@ -190,7 +321,7 @@
return ret;
}
-static int wp_open(private_object_t *tech_pvt, int span, int chan)
+static wpsock_t *wp_open(private_object_t *tech_pvt, int span, int chan)
{
sng_fd_t fd;
wpsock_t *sock;
@@ -212,7 +343,7 @@
}
}
- if (sock) {
+ if (sock && tech_pvt) {
if (sock->tech_pvt) {
if (tech_pvt->session) {
switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session);
@@ -225,7 +356,7 @@
switch_mutex_unlock(globals.hash_mutex);
- return sock ? 1 : 0;
+ return sock;
}
static int wp_restart(int span, int chan)
@@ -2038,7 +2169,7 @@
{
char *cf = "wanpipe.conf";
int current_span = 0, min_span = 0, max_span = 0;
- switch_xml_t cfg, xml, settings, param, pri_spans, ss7boost_handles, span;
+ switch_xml_t cfg, xml, settings, param, pri_spans, ss7boost_handles, span, analog_channels, channel;
globals.samples_per_frame = DEFAULT_SAMPLES_PER_FRAME;
globals.dtmf_on = 150;
@@ -2112,6 +2243,102 @@
break;
}
+ analog_channels = switch_xml_child(cfg, "analog_channels");
+ for(channel = switch_xml_child(analog_channels, "channel"); channel; channel = channel->next) {
+ char *c_type = (char *) switch_xml_attr(channel, "type");
+ char *c_dev = (char *) switch_xml_attr(channel, "device");
+ char *user = NULL;
+ char *domain = NULL;
+ char *cid_name = NULL, *cid_num = NULL;
+ analog_channel_t *alc;
+ analog_type_t a_type = ANALOG_TYPE_UNKNOWN;
+ wpsock_t *sock;
+ int chan, span;
+
+ if (!c_type) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing required attribute 'type'\n");
+ continue;
+ }
+
+ if (!strcasecmp(c_type, "phone") || !strcasecmp(c_type, "fxs")) {
+ a_type = ANALOG_TYPE_PHONE_FXS;
+ } else if (!strcasecmp(c_type, "line") || !strcasecmp(c_type, "fxo")) {
+ a_type = ANLOG_TYPE_LINE_FXO;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid type '%s'\n", c_type);
+ continue;
+ }
+
+ if (!c_dev) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing required attribute 'device'\n");
+ continue;
+ }
+
+ if (!sangoma_span_chan_fromif(c_dev, &span, &chan)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid device name '%s'\n", c_dev);
+ continue;
+ }
+
+ if (!(sock = wp_open(NULL, span, chan))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot open device '%s' (%s)\n", c_dev, strerror(errno));
+ continue;
+ }
+
+ for (param = switch_xml_child(channel, "param"); param; param = param->next) {
+ char *var = (char *) switch_xml_attr_soft(param, "name");
+ char *val = (char *) switch_xml_attr_soft(param, "value");
+
+ if (!strcasecmp(var, "user")) {
+ user = var;
+ } else if (!strcasecmp(var, "domain")) {
+ domain = val;
+ } else if (!strcasecmp(var, "caller-id-name")) {
+ cid_name = val;
+ } else if (!strcasecmp(var, "caller-id-number")) {
+ cid_num = val;
+ }
+ }
+
+ assert((alc = malloc(sizeof(*alc))));
+ memset(alc, 0, sizeof(*alc));
+ if (user) {
+ alc->user = strdup(user);
+ }
+ if (domain) {
+ alc->domain = strdup(domain);
+ }
+ if (cid_name) {
+ alc->cid_name = strdup(cid_name);
+ }
+ if (cid_num) {
+ alc->cid_name = strdup(cid_num);
+ }
+
+ alc->a_type = a_type;
+ alc->sock = sock;
+ alc->chan = chan;
+ alc->span = span;
+
+ if (a_type == ANALOG_TYPE_PHONE_FXS) {
+ FXS_ANALOG_CHANNELS[globals.fxs_index++] = alc;
+ } else {
+ FXO_ANALOG_CHANNELS[globals.fxo_index++] = alc;
+ }
+ }
+
+
+ if (globals.fxs_index) {
+ switch_thread_t *thread;
+ switch_threadattr_t *thd_attr = NULL;
+
+ switch_threadattr_create(&thd_attr, module_pool);
+ switch_threadattr_detach_set(thd_attr, 1);
+ switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+ switch_thread_create(&thread, thd_attr, fxs_thread_run, NULL, module_pool);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Starting FXS Thread!\n");
+ }
+
+
pri_spans = switch_xml_child(cfg, "pri_spans");
for (span = switch_xml_child(pri_spans, "span"); span; span = span->next) {
char *id = (char *) switch_xml_attr(span, "id");
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/formats/mod_shout/Makefile
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/formats/mod_shout/Makefile (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/formats/mod_shout/Makefile Mon Mar 26 14:45:37 2007
@@ -11,8 +11,9 @@
SHOUTLA=$(SHOUT_DIR)/src/libshout.la
LOCAL_CFLAGS=-I$(SHOUT_DIR)/include -I$(LAME_DIR)/include
-LOCAL_LIBADD=$(LAMELA) $(SHOUTLA)
+LOCAL_LIBADD=$(LAMELA) $(SHOUTLA)
+LOCAL_LDFLAGS=`cat ../../../../libs/libshout-2.2.2/Makefile | grep SPEEX_LIBS | sed -e 's|^SPEEX_LIBS =||'`
MP3SOURCES=common.c dct64_i386.c decode_ntom.c layer3.c tabinit.c interface.c
MP3OBJS=common.o dct64_i386.o decode_ntom.o layer3.o tabinit.o interface.o
LOCAL_OBJS=$(MP3OBJS)
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_perl/Makefile
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_perl/Makefile (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_perl/Makefile Mon Mar 26 14:45:37 2007
@@ -3,18 +3,21 @@
# and define these variables to impact your build
-LOCAL_CFLAGS=-DMULTIPLICITY $(shell $(PERL) -MExtUtils::Embed -e ccopts) -DEMBED_PERL
+PERL = `which perl`
+PERL_LIBDIR =-L$(shell perl -MConfig -e 'print $$Config{archlib}')/CORE
+PERL_LIBS =$(shell perl -MConfig -e 'print $$Config{libs}')
+
+LOCAL_CFLAGS=-w -DMULTIPLICITY $(shell $(PERL) -MExtUtils::Embed -e ccopts) -DEMBED_PERL
LOCAL_LDFLAGS=$(shell $(PERL) -MExtUtils::Embed -e ldopts) $(shell $(PERL) -MConfig -e 'print $$Config{libs}')
LOCAL_OBJS=perlxsi.o
include ../../../../build/modmake.rules
-PERL = $(shell which perl)
-PERL_LIBDIR =-L$(shell perl -MConfig -e 'print $$Config{archlib}')/CORE
-PERL_LIBS =$(shell perl -MConfig -e 'print $$Config{libs}')
SWIGCFILE=../../../switch_swig.c
SWIGIFILE=../../../switch_swig.i
+
+
local_all: fs_perl.$(DYNAMIC_LIB_EXTEN)
.perlok:
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey_odbc/Makefile
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey_odbc/Makefile (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey_odbc/Makefile Mon Mar 26 14:45:37 2007
@@ -25,4 +25,4 @@
$(INST_ODBCLA): $(UNINST_ODBCLA)
cd $(ODBC_DIR) && $(MAKE) install
-
+ @$(TOUCH_TARGET)
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey_teletone/Makefile
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey_teletone/Makefile (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/languages/mod_spidermonkey_teletone/Makefile Mon Mar 26 14:45:37 2007
@@ -1,5 +1,4 @@
switch_srcdir=../../../..
LOCAL_CFLAGS=-I$(switch_srcdir)/libs/libteletone/src
-LOCAL_LIBADD=$(switch_srcdir)/libs/libteletone/libteletone.la
include ../mod_spidermonkey/sm.mak
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/loggers/mod_console/mod_console.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/loggers/mod_console/mod_console.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/loggers/mod_console/mod_console.c Mon Mar 26 14:45:37 2007
@@ -36,19 +36,19 @@
static int COLORIZE = 0;
#ifdef WIN32
static HANDLE hStdout;
-static WORD wOldColorAttrs;
-static CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
-static WORD COLORS[] =
- { FOREGROUND_RED | FOREGROUND_INTENSITY,
- FOREGROUND_RED | FOREGROUND_INTENSITY,
- FOREGROUND_RED | FOREGROUND_INTENSITY,
- FOREGROUND_RED | FOREGROUND_INTENSITY,
- FOREGROUND_BLUE | FOREGROUND_INTENSITY,
- FOREGROUND_BLUE | FOREGROUND_INTENSITY,
- FOREGROUND_GREEN | FOREGROUND_INTENSITY,
- FOREGROUND_GREEN | FOREGROUND_INTENSITY,
- FOREGROUND_GREEN | FOREGROUND_INTENSITY };
-#else
+static WORD wOldColorAttrs;
+static CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
+static WORD COLORS[] =
+ { FOREGROUND_RED | FOREGROUND_INTENSITY,
+ FOREGROUND_RED | FOREGROUND_INTENSITY,
+ FOREGROUND_RED | FOREGROUND_INTENSITY,
+ FOREGROUND_RED | FOREGROUND_INTENSITY,
+ FOREGROUND_BLUE | FOREGROUND_INTENSITY,
+ FOREGROUND_BLUE | FOREGROUND_INTENSITY,
+ FOREGROUND_GREEN | FOREGROUND_INTENSITY,
+ FOREGROUND_GREEN | FOREGROUND_INTENSITY,
+ FOREGROUND_GREEN | FOREGROUND_INTENSITY };
+#else
static const char *COLORS[] =
{ SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FMAGEN, SWITCH_SEQ_FCYAN, SWITCH_SEQ_FGREEN, SWITCH_SEQ_FYELLOW, "" };
#endif
@@ -170,7 +170,7 @@
if (COLORIZE) {
#ifdef WIN32
SetConsoleTextAttribute(hStdout, COLORS[node->level]);
- WriteFile(hStdout, node->data, (DWORD)strlen(node->data), NULL, NULL);
+ WriteFile(hStdout, node->data, (DWORD)strlen(node->data), NULL, NULL);
SetConsoleTextAttribute(hStdout, wOldColorAttrs);
#else
fprintf(handle, "%s%s%s", COLORS[node->level], node->data, SWITCH_SEQ_DEFAULT_COLOR);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/mod/xml_int/mod_xml_rpc/Makefile
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/mod/xml_int/mod_xml_rpc/Makefile (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/mod/xml_int/mod_xml_rpc/Makefile Mon Mar 26 14:45:37 2007
@@ -1,17 +1,18 @@
BASE=../../../..
XMLRPC_DIR=$(BASE)/libs/xmlrpc-c
-XMLRPCLAS = $(XMLRPC_DIR)/src/libxmlrpc.la $(XMLRPC_DIR)/src/libxmlrpc_server.la
+#XMLRPCLAS = $(XMLRPC_DIR)/src/libxmlrpc.la
+#dont ask...
+XMLRPCLAS = $(XMLRPC_DIR)/src/*.o
+XMLRPCLAS += $(XMLRPC_DIR)/src/libxmlrpc_server.la
XMLRPCLAS += $(XMLRPC_DIR)/src/libxmlrpc_server_abyss.la $(XMLRPC_DIR)/lib/abyss/src/libxmlrpc_abyss.la
-XMLRPCLAS += $(XMLRPC_DIR)/lib/expat/xmlparse/libxmlrpc_xmlparse.la
+XMLRPCLAS += $(XMLRPC_DIR)/lib/expat/xmlparse/libxmlrpc_xmlparse.la $(XMLRPC_DIR)/lib/expat/xmltok/libxmlrpc_xmltok.la
-LOCAL_LDFLAGS = $(XMLRPCLAS)
+LOCAL_LIBADD =$(XMLRPCLAS)
LOCAL_CFLAGS=-I$(XMLRPC_DIR)/include
include $(BASE)/build/modmake.rules
-local_depend: $(XMLRPCLAS)
-
$(XMLRPCLAS): $(XMLRPC_DIR) $(XMLRPC_DIR)/.update
cd $(XMLRPC_DIR) && $(MAKE)
$(TOUCH_TARGET)
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_apr.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_apr.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_apr.c Mon Mar 26 14:45:37 2007
@@ -608,57 +608,35 @@
return apr_queue_trypush(queue, data);
}
-#if 0
-/* Utility functions */
-struct switch_vasprintf_data {
- apr_vformatter_buff_t vbuff;
- switch_size_t len;
- switch_size_t block_size;
- char *buf;
-};
-
-static int vasprintf_flush(apr_vformatter_buff_t *buff)
+SWITCH_DECLARE(int) switch_vasprintf(char **ret, const char *fmt, va_list ap)
{
- struct switch_vasprintf_data *data = (struct switch_vasprintf_data *)buff;
-
- char *temp;
- switch_size_t len = data->vbuff.curpos - data->buf;
+#ifdef HAVE_VASPRINTF
+ return vasprintf(ret, fmt, ap);
+#else
+ char *buf;
+ int len;
+ size_t buflen;
+ va_list ap2;
- if ((temp = realloc(data->buf, data->len + data->block_size))) {
- data->buf = temp;
- data->vbuff.curpos = data->buf + len;
- data->len = data->len + data->block_size;
- data->vbuff.endpos = data->buf + data->len;
- return 0;
- }
-
- return -1;
-}
+#ifdef _MSC_VER
+ ap2 = ap;
+#else
+ va_copy(ap2, ap);
#endif
-SWITCH_DECLARE(int) switch_vasprintf(char **buf, const char *format, va_list ap)
-{
-#if 0
- struct switch_vasprintf_data data;
-
- data.block_size = 1024;
- data.buf = malloc(data.block_size);
+ len = vsnprintf(NULL, 0, fmt, ap2);
- if (data.buf == NULL) {
- *buf = NULL;
- return 0;
- }
+ if (len > 0 && (buf = malloc((buflen = (size_t)(len + 1)))) != NULL) {
+ len = vsnprintf(buf, buflen, fmt, ap);
+ *ret = buf;
+ } else {
+ *ret = NULL;
+ len = -1;
+ }
- data.vbuff.curpos = data.buf;
- data.vbuff.endpos = data.buf + data.block_size;
+ va_end(ap2);
+ return len;
- return apr_vformatter(vasprintf_flush, (apr_vformatter_buff_t *)&data, format, ap);
-#endif
-#ifdef HAVE_VASPRINTF
- return vasprintf(buf, format, ap);
-#else
- *buf = (char *) malloc(2048);
- return vsnprintf(*buf, 2048, format, ap);
#endif
}
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_channel.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_channel.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_channel.c Mon Mar 26 14:45:37 2007
@@ -1036,10 +1036,10 @@
switch_event_fire(&event);
}
- /* if we're in a bridge and the other channel is in a blocking read they will never realize we have answered so send
+ /* if we're the child of another channel and the other channel is in a blocking read they will never realize we have answered so send
a SWITCH_SIG_BREAK to interrupt any blocking reads on that channel
*/
- if ((uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
+ if ((uuid = switch_channel_get_variable(channel, SWITCH_ORIGINATOR_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
switch_core_session_kill_channel(other_session, SWITCH_SIG_BREAK);
switch_core_session_rwunlock(other_session);
}
@@ -1075,7 +1075,7 @@
msg.message_id = SWITCH_MESSAGE_INDICATE_PROGRESS;
msg.from = channel->name;
status = switch_core_session_message_send(uuid, &msg);
-
+
if (status == SWITCH_STATUS_SUCCESS) {
status = switch_channel_perform_mark_pre_answered(channel, file, func, line);
}
@@ -1148,11 +1148,11 @@
switch_channel_event_set_data(channel, event);
switch_event_fire(&event);
}
-
- /* if we're in a bridge and the other channel is in a blocking read they will never realize we have answered so send
+
+ /* if we're the child of another channel and the other channel is in a blocking read they will never realize we have answered so send
a SWITCH_SIG_BREAK to interrupt any blocking reads on that channel
*/
- if ((uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
+ if ((uuid = switch_channel_get_variable(channel, SWITCH_ORIGINATOR_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
switch_core_session_kill_channel(other_session, SWITCH_SIG_BREAK);
switch_core_session_rwunlock(other_session);
}
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_console.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_console.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_console.c Mon Mar 26 14:45:37 2007
@@ -41,7 +41,7 @@
char *buf = handle->data;
char *end = handle->end;
int ret = 0;
- char *data;
+ char *data = NULL;
if (handle->data_len >= handle->data_size) {
return SWITCH_STATUS_FALSE;
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_ivr.c Mon Mar 26 14:45:37 2007
@@ -2048,9 +2048,8 @@
switch_channel_answer(chan_a);
ans_a++;
} else if (!pre_b && switch_channel_test_flag(chan_b, CF_EARLY_MEDIA)) {
- if (switch_channel_pre_answer(chan_a) == SWITCH_STATUS_SUCCESS) {
- pre_b++;
- }
+ switch_channel_pre_answer(chan_a);
+ pre_b++;
}
if (!pre_b) {
switch_yield(10000);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_resample.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_resample.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_resample.c Mon Mar 26 14:45:37 2007
@@ -183,6 +183,27 @@
}
}
+SWITCH_DECLARE(void) switch_generate_sln_silence(int16_t *data, uint32_t samples, uint32_t divisor)
+{
+ int16_t rnd, x;
+ uint32_t i;
+ int sum_rnd = 0;
+
+ assert(divisor);
+
+ for(i = 0; i < samples; i++, sum_rnd = 0) {
+ for(x = 0; x < 7; x++) {
+ rnd = (int16_t) (rand() * sizeof(int16_t));
+ sum_rnd += rnd;
+ }
+ switch_normalize_to_16bit(sum_rnd);
+ *data = (int16_t)((int16_t)sum_rnd / (int)divisor);
+
+ data++;
+ }
+}
+
+
SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, int32_t vol)
{
double newrate = 0;
Modified: freeswitch/branches/mikej/sofiasip-upgrade/src/switch_rtp.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/src/switch_rtp.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/src/switch_rtp.c Mon Mar 26 14:45:37 2007
@@ -105,6 +105,7 @@
unsigned char out_digit_packet[4];
unsigned int out_digit_sofar;
unsigned int out_digit_dur;
+ uint16_t in_digit_seq;
uint16_t out_digit_seq;
uint32_t out_digit_ssrc;
int32_t timestamp_dtmf;
@@ -910,31 +911,36 @@
int end = packet[1]&0x80;
int duration = (packet[2]<<8) + packet[3];
char key = switch_rfc2833_to_char(packet[0]);
+ uint16_t in_digit_seq = ntohs((uint16_t)rtp_session->recv_msg.header.seq);
/* SHEESH.... Curse you RFC2833 inventors!!!!*/
if ((time(NULL) - rtp_session->dtmf_data.last_digit_time) > 2) {
rtp_session->dtmf_data.last_digit = 0;
rtp_session->dtmf_data.dc = 0;
}
+ if (in_digit_seq > rtp_session->dtmf_data.in_digit_seq) {
+ rtp_session->dtmf_data.in_digit_seq = in_digit_seq;
+
+ if (duration && end) {
+ if (key != rtp_session->dtmf_data.last_digit) {
+ char digit_str[] = {key, 0};
+ time(&rtp_session->dtmf_data.last_digit_time);
+ switch_rtp_queue_dtmf(rtp_session, digit_str);
+ }
+ if (++rtp_session->dtmf_data.dc >= 3) {
+ rtp_session->dtmf_data.last_digit = 0;
+ rtp_session->dtmf_data.dc = 0;
+ }
- if (duration && end) {
- if (key != rtp_session->dtmf_data.last_digit) {
- char digit_str[] = {key, 0};
- time(&rtp_session->dtmf_data.last_digit_time);
- switch_rtp_queue_dtmf(rtp_session, digit_str);
- }
- if (++rtp_session->dtmf_data.dc >= 3) {
+ rtp_session->dtmf_data.last_digit = key;
+ } else {
rtp_session->dtmf_data.last_digit = 0;
rtp_session->dtmf_data.dc = 0;
}
-
- rtp_session->dtmf_data.last_digit = key;
- } else {
- rtp_session->dtmf_data.last_digit = 0;
- rtp_session->dtmf_data.dc = 0;
}
continue;
+
}
break;
Modified: freeswitch/branches/mikej/sofiasip-upgrade/w32/Library/FreeSwitchCore.vcproj
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/w32/Library/FreeSwitchCore.vcproj (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/w32/Library/FreeSwitchCore.vcproj Mon Mar 26 14:45:37 2007
@@ -43,7 +43,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libresample\include;..\..\libs\libteletone\src"
+ AdditionalIncludeDirectories="..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libresample\include;..\..\libs\libteletone\src;..\..\libs\win32\sqlite;..\..\libs\pcre"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;PCRE_STATIC"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -136,7 +136,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libresample\include;..\..\libs\libteletone\src"
+ AdditionalIncludeDirectories="..\..\src\include;..\..\libs\include;..\..\libs\srtp\include;..\..\libs\srtp\crypto\include;..\..\libs\libresample\include;..\..\libs\libteletone\src;..\..\libs\win32\sqlite;..\..\libs\pcre"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;CRASH_PROT;PCRE_STATIC"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
@@ -240,10 +240,6 @@
>
</File>
<File
- RelativePath="..\..\src\switch_config.c"
- >
- </File>
- <File
RelativePath="..\..\src\switch_console.c"
>
</File>
@@ -322,10 +318,6 @@
>
</File>
<File
- RelativePath="..\..\src\include\switch_config.h"
- >
- </File>
- <File
RelativePath="..\..\src\include\switch_console.h"
>
</File>
1
0
[commit] r4767 - in freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua: iptsec msg nta nua nua/sofia-sip sip/tests su/sofia-sip tport url
by Freeswitch SVN 26 Mar '07
by Freeswitch SVN 26 Mar '07
26 Mar '07
Author: mikej
Date: Mon Mar 26 14:05:55 2007
New Revision: 4767
Added:
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/sip/tests/10052.txt
Modified:
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser_util.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/Doxyfile
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.h
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_100rel.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_call_reject.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_init.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.h
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua_params.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_register.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_wait.h
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/url/torture_url.c
Log:
upadte to sofia darcs
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c Mon Mar 26 14:05:55 2007
@@ -178,9 +178,9 @@
return -1;
if (!ca->ca_credential_class)
- stale = 1, ca->ca_credential_class = credential_class;
+ stale = 2, ca->ca_credential_class = credential_class;
- return stale ? 2 : 1;
+ return stale > 1 ? 2 : 1;
}
/** Store authentication info to authenticators.
@@ -748,6 +748,10 @@
};
/** Store a digest authorization challenge.
+ *
+ * @retval 2 if credentials need to be (re)sent
+ * @retval 1 if challenge was updated
+ * @retval -1 upon an error
*/
static int auc_digest_challenge(auth_client_t *ca, msg_auth_t const *ch)
{
@@ -765,7 +769,7 @@
if (ac->ac_qop && !ac->ac_auth && !ac->ac_auth_int)
goto error;
- stale = ac->ac_stale || str0cmp(ac->ac_nonce, cda->cda_ac->ac_nonce);
+ stale = ac->ac_stale || cda->cda_ac->ac_nonce == NULL;
if (ac->ac_qop && (cda->cda_cnonce == NULL || ac->ac_stale)) {
su_guid_t guid[1];
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser_util.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser_util.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/msg/msg_parser_util.c Mon Mar 26 14:05:55 2007
@@ -1974,6 +1974,8 @@
return NULL;
msg = msg_create(mc, flags);
+ if (msg == NULL)
+ return NULL;
su_home_preload(msg_home(msg), 1, len + 1024);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nta/test_nta.c Mon Mar 26 14:05:55 2007
@@ -663,6 +663,8 @@
static int test_bad_messages(agent_t *ag)
{
+ BEGIN();
+
#if HAVE_DIRENT_H
DIR *dir;
struct dirent *d;
@@ -687,13 +689,10 @@
if (dir == NULL) {
fprintf(stderr, "test_nta: cannot find sip torture messages\n");
fprintf(stderr, "test_nta: tried %s\n", name);
- return 0;
}
offset = strlen(name);
- BEGIN();
-
TEST_1(ag->ag_default_leg = nta_leg_tcreate(ag->ag_agent,
leg_callback_500,
ag,
@@ -720,7 +719,7 @@
sprintf(via, "v: SIP/2.0/UDP is.invalid:%u\r\n", ntohs(su->su_port));
vlen = strlen(via);
- for (d = readdir(dir); d; d = readdir(dir)) {
+ for (d = dir ? readdir(dir) : NULL; d; d = readdir(dir)) {
size_t len = strlen(d->d_name);
FILE *f;
int blen, n;
@@ -752,6 +751,8 @@
su_root_step(ag->ag_root, 1);
}
+ TEST_SIZE(su_sendto(s, "", 0, 0, ai->ai_addr, ai->ai_addrlen), 0);
+
su_close(s);
for (i = 0; i < 20; i++)
@@ -759,12 +760,12 @@
nta_leg_destroy(ag->ag_default_leg), ag->ag_default_leg = NULL;
- closedir(dir);
+ if (dir)
+ closedir(dir);
- END();
-#else
- return 0;
#endif /* HAVE_DIRENT_H */
+
+ END();
}
static unsigned char const code[] =
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/Doxyfile
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/Doxyfile (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/Doxyfile Mon Mar 26 14:05:55 2007
@@ -30,6 +30,9 @@
ALIASES += NUA_EVENT="@var nua_event_e::"
ALIASES += END_NUA_EVENT="@par "
+ALIASES += \
+ NUA_HPARAM_CALLS="nua_invite(), nua_respond(), nua_ack(), nua_prack(), nua_update(), nua_info(), nua_bye(), nua_options(), nua_message(), nua_register(), nua_publish(), nua_refer(),nua_subscribe(), nua_notify(), nua_refer(), nua_notifier()"
+
VERBATIM_HEADERS = NO
@INCLUDE = ../sip/sip.doxyaliases
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.h Mon Mar 26 14:05:55 2007
@@ -301,7 +301,8 @@
unsigned cr_contactize:1; /**< Request needs Contact */
/* Current state */
- unsigned cr_challenged:1; /**< Request was challenged, pending auth */
+ unsigned cr_challenged:1; /**< Request was challenged */
+ unsigned cr_wait_for_cred:1; /**< Request is pending authentication */
unsigned cr_restarting:1; /**< Request is being restarted */
unsigned cr_reporting:1; /**< Reporting in progress */
unsigned cr_terminating:1; /**< Request terminates the usage */
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c Mon Mar 26 14:05:55 2007
@@ -393,6 +393,7 @@
* NUTAG_ALLOW(), SIPTAG_ALLOW(), and SIPTAG_ALLOW_STR() \n
* NUTAG_ALLOW_EVENTS(), SIPTAG_ALLOW_EVENTS(), and
* SIPTAG_ALLOW_EVENTS_STR() \n
+ * NUTAG_AUTH_CACHE() \n
* NUTAG_AUTOACK() \n
* NUTAG_AUTOALERT() \n
* NUTAG_AUTOANSWER() \n
@@ -778,6 +779,11 @@
else if (tag == nutag_path_enable) {
NHP_SET(nhp, path_enable, value != 0);
}
+ /* NUTAG_AUTH_CACHE(auth_cache) */
+ else if (tag == nutag_auth_cache) {
+ if (value >= 0 && value < (tag_value_t)_nua_auth_cache_invalid)
+ NHP_SET(nhp, auth_cache, (int)value);
+ }
/* NUTAG_REFER_EXPIRES(refer_expires) */
else if (tag == nutag_refer_expires) {
NHP_SET(nhp, refer_expires, value);
@@ -1363,6 +1369,7 @@
* @param sip NULL
* @param tags
* NUTAG_APPL_METHOD() \n
+ * NUTAG_AUTH_CACHE() \n
* NUTAG_AUTOACK() \n
* NUTAG_AUTOALERT() \n
* NUTAG_AUTOANSWER() \n
@@ -1546,6 +1553,7 @@
TIF(NUTAG_MEDIA_FEATURES, media_features),
TIF(NUTAG_SERVICE_ROUTE_ENABLE, service_route_enable),
TIF(NUTAG_PATH_ENABLE, path_enable),
+ TIF(NUTAG_AUTH_CACHE, auth_cache),
TIF(NUTAG_REFER_EXPIRES, refer_expires),
TIF(NUTAG_REFER_WITH_ID, refer_with_id),
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h Mon Mar 26 14:05:55 2007
@@ -95,9 +95,11 @@
unsigned nhp_service_route_enable:1;
/** Enable Path */
unsigned nhp_path_enable:1;
+ /** Authentication cache policy */
+ unsigned nhp_auth_cache:1;
+
/** Always include id with Event: refer */
unsigned nhp_refer_with_id:1;
-
unsigned:0;
/* Default lifetime for implicit subscriptions created by REFER */
@@ -157,6 +159,7 @@
unsigned nhb_media_features:1;
unsigned nhb_service_route_enable:1;
unsigned nhb_path_enable:1;
+ unsigned nhb_auth_cache:1;
unsigned nhb_refer_with_id:1;
unsigned nhb_refer_expires:1;
unsigned nhb_substate:1;
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c Mon Mar 26 14:05:55 2007
@@ -1269,7 +1269,7 @@
/* No INVITE template */
cr == NULL ||
/* INVITE is in progress or being authenticated */
- cr->cr_orq || cr->cr_challenged)
+ cr->cr_orq || cr->cr_wait_for_cred)
return;
/* UPDATE in progress or being authenticated */
@@ -3533,10 +3533,13 @@
nua_callstate_terminated);
if (ss && !ss->ss_reporting) {
- if (nua_client_is_queued(du->du_cr) && du->du_cr->cr_status < 200)
- /* No final response to INVITE received yet */;
- else
+ if (du->du_cr == NULL ||
+ !nua_client_is_queued(du->du_cr) ||
+ du->du_cr->cr_status >= 200) {
+ /* INVITE is completed, we can zap the session... */;
+ cr->cr_usage = NULL;
nua_session_usage_destroy(nh, ss);
+ }
}
}
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c Mon Mar 26 14:05:55 2007
@@ -90,8 +90,6 @@
static int nh_authorize(nua_handle_t *nh,
tag_type_t tag, tag_value_t value, ...);
-static int nh_challenge(nua_handle_t *nh, sip_t const *sip);
-
static void nua_stack_timer(nua_t *nua, su_timer_t *t, su_timer_arg_t *a);
/* ---------------------------------------------------------------------- */
@@ -939,33 +937,6 @@
return retval;
}
-/**@internal
- * Collect challenges from response.
- *
- * @return Number of updated challenges, 0 if no updates found.
- * @retval -1 upon error.
- */
-static
-int nh_challenge(nua_handle_t *nh, sip_t const *sip)
-{
- int server = 0, proxy = 0;
-
- if (sip->sip_www_authenticate)
- server = auc_challenge(&nh->nh_auth, nh->nh_home,
- sip->sip_www_authenticate,
- sip_authorization_class);
-
- if (sip->sip_proxy_authenticate)
- proxy = auc_challenge(&nh->nh_auth, nh->nh_home,
- sip->sip_proxy_authenticate,
- sip_proxy_authorization_class);
-
- if (server < 0 || proxy < 0)
- return -1;
-
- return server + proxy;
-}
-
static inline
int can_redirect(sip_contact_t const *m, sip_method_t method)
{
@@ -1023,7 +994,7 @@
if (status > 0) {
nua_client_request_t *cr = nh->nh_ds->ds_cr;
- if (cr && cr->cr_challenged) {
+ if (cr && cr->cr_wait_for_cred) {
nua_client_restart_request(cr, cr->cr_terminating, tags);
}
else {
@@ -2043,6 +2014,8 @@
/** Restart the request message.
*
+ * A restarted request has not completed successfully.
+ *
* @retval 0 if request is pending
* @retval >=1 if error event has been sent
*/
@@ -2067,6 +2040,8 @@
/** Resend the request message.
*
+ * A resent request has completed once successfully - restarted has not.
+ *
* @retval 0 if request is pending
* @retval >=1 if error event has been sent
*/
@@ -2075,6 +2050,7 @@
{
if (cr) {
cr->cr_retry_count = 0;
+ cr->cr_challenged = 0;
if (nua_client_is_queued(cr)) {
if (terminating)
@@ -2223,7 +2199,7 @@
return -1;
}
- cr->cr_challenged = 0;
+ cr->cr_wait_for_cred = 0;
if (cr->cr_methods->crm_send)
return cr->cr_methods->crm_send(cr, msg, sip, NULL);
@@ -2264,8 +2240,13 @@
{
nua_handle_t *nh = cr->cr_owner;
- if (nh->nh_auth && auc_authorize(&nh->nh_auth, msg, sip) < 0)
- return nua_client_return(cr, 900, "Cannot add credentials", msg);
+ if (nh->nh_auth) {
+ if (cr->cr_challenged ||
+ NH_PGET(nh, auth_cache) == nua_auth_cache_dialog) {
+ if (auc_authorize(&nh->nh_auth, msg, sip) < 0)
+ return nua_client_return(cr, 900, "Cannot add credentials", msg);
+ }
+ }
cr->cr_seq = sip->sip_cseq->cs_seq; /* Save last sequence number */
@@ -2429,14 +2410,31 @@
/* XXX - handle Retry-After */
- if (status == 302) {
+ if (status == 302 || status == 305) {
+ sip_route_t r[1];
+
if (!can_redirect(sip->sip_contact, cr->cr_method))
return 0;
- if (nua_client_set_target(cr, sip->sip_contact->m_url) >= 0)
- return nua_client_restart(cr, 100, "Redirected");
+ switch (status) {
+ case 302:
+ if (nua_client_set_target(cr, sip->sip_contact->m_url) >= 0)
+ return nua_client_restart(cr, 100, "Redirected");
+ break;
+
+ case 305:
+ sip_route_init(r);
+ *r->r_url = *sip->sip_contact->m_url;
+ if (sip_add_dup(cr->cr_msg, cr->cr_sip, (sip_header_t *)r) >= 0)
+ return nua_client_restart(cr, 100, "Redirected via a proxy");
+ break;
+
+ default:
+ break;
+ }
}
+
if (status == 423) {
unsigned my_expires = 0;
@@ -2456,20 +2454,40 @@
}
}
- if (((status == 401 && sip->sip_www_authenticate) ||
- (status == 407 && sip->sip_proxy_authenticate)) &&
- nh_challenge(nh, sip) > 0) {
+ if ((status == 401 && sip->sip_www_authenticate) ||
+ (status == 407 && sip->sip_proxy_authenticate)) {
+ int server = 0, proxy = 0;
nta_outgoing_t *orq;
- if (auc_has_authorization(&nh->nh_auth))
- return nua_client_restart(cr, 100, "Request Authorized by Cache");
- orq = cr->cr_orq, cr->cr_orq = NULL;
- cr->cr_challenged = 1;
- cr->cr_retry_count++;
- nua_client_report(cr, status, phrase, NULL, orq, NULL);
- nta_outgoing_destroy(orq);
+ if (sip->sip_www_authenticate)
+ server = auc_challenge(&nh->nh_auth, nh->nh_home,
+ sip->sip_www_authenticate,
+ sip_authorization_class);
+
+ if (sip->sip_proxy_authenticate)
+ proxy = auc_challenge(&nh->nh_auth, nh->nh_home,
+ sip->sip_proxy_authenticate,
+ sip_proxy_authorization_class);
+
+ if (server >= 0 && proxy >= 0) {
+ int invalid = cr->cr_challenged && server + proxy == 0;
+
+ cr->cr_challenged = 1;
+
+ if (invalid)
+ /* Bad username/password */
+ auc_clear_credentials(&nh->nh_auth, NULL, NULL);
+ else if (auc_has_authorization(&nh->nh_auth))
+ return nua_client_restart(cr, 100, "Request Authorized by Cache");
+
+ orq = cr->cr_orq, cr->cr_orq = NULL;
+ cr->cr_wait_for_cred = 1;
+ cr->cr_retry_count++;
+ nua_client_report(cr, status, phrase, NULL, orq, NULL);
+ nta_outgoing_destroy(orq);
- return 1;
+ return 1;
+ }
}
return 0; /* This was a final response that cannot be restarted. */
@@ -2591,8 +2609,18 @@
cr->cr_reporting = 1, nh->nh_ds->ds_reporting = 1;
- if (status >= 200 && status < 300)
- nh_challenge(nh, sip); /* Collect nextnonce */
+ if (nh->nh_auth && sip &&
+ (sip->sip_authentication_info || sip->sip_proxy_authentication_info)) {
+ /* Collect nextnonce */
+ if (sip->sip_authentication_info)
+ auc_info(&nh->nh_auth,
+ sip->sip_authentication_info,
+ sip_authorization_class);
+ if (sip->sip_proxy_authentication_info)
+ auc_info(&nh->nh_auth,
+ sip->sip_proxy_authentication_info,
+ sip_proxy_authorization_class);
+ }
if ((method != sip_method_invite && status >= 200) || status >= 300)
nua_client_request_remove(cr);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c Mon Mar 26 14:05:55 2007
@@ -144,6 +144,7 @@
tag_typedef_t nutag_path_enable = BOOLTAG_TYPEDEF(path_enable);
tag_typedef_t nutag_service_route_enable =
BOOLTAG_TYPEDEF(service_route_enable);
+tag_typedef_t nutag_auth_cache = INTTAG_TYPEDEF(auth_cache);
tag_typedef_t nutag_detect_network_updates = UINTTAG_TYPEDEF(detect_network_updates);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h Mon Mar 26 14:05:55 2007
@@ -451,8 +451,8 @@
*
* @par Used with
* nua_invite() \n
- * nua_set_params() \n
- * nua_get_params()
+ * nua_set_params(), nua_set_hparams(),
+ * nua_get_params(), nua_get_hparams()
*
* @par Parameter type
* int (enum nua_af)
@@ -1247,6 +1247,38 @@
#define NUTAG_AUTH_REF(x) nutag_auth_ref, tag_str_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_auth_ref;
+/** Authentication caching policy
+ *
+ * @par Used with
+ * nua_set_params(), nua_set_hparams() \n
+ * nua_get_params(), nua_get_hparams() \n
+ * @NUA_HPARAM_CALLS
+ *
+ * @par Parameter type
+ * enum nua_auth_cache
+ *
+ * @par Values
+ * - nua_auth_cache_dialog (0) - include credentials within dialog
+ * - nua_auth_cache_challenged (1) - include credentials only when
+ * challenged
+ *
+ * Corresponding tag taking reference parameter is NUTAG_AUTH_CACHE_REF()
+ */
+#define NUTAG_AUTH_CACHE(x) nutag_auth_cache, tag_int_v(x)
+SOFIAPUBVAR tag_typedef_t nutag_auth_cache;
+
+#define NUTAG_AUTH_CACHE_REF(x) nutag_auth_cache_ref, tag_int_vr(&(x))
+SOFIAPUBVAR tag_typedef_t nutag_auth_cache_ref;
+
+/** Authentication caching policy */
+enum nua_auth_cache {
+ /** Include credentials within dialog (default) */
+ nua_auth_cache_dialog = 0,
+ /** Include credentials only when challenged */
+ nua_auth_cache_challenged = 1,
+ _nua_auth_cache_invalid
+};
+
/** Keepalive interval in milliseconds.
*
* This setting applies to OPTIONS/STUN keepalives. See documentation
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_100rel.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_100rel.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_100rel.c Mon Mar 26 14:05:55 2007
@@ -404,17 +404,21 @@
TEST_1(is_answer_recv(e->data->e_tags));
TEST_1(!is_offer_sent(e->data->e_tags));
- if (md5 && !md5sess) {
- TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
- TEST(e->data->e_status, 407);
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
+
+ if (e->data->e_status != 200 && md5 && !md5sess) {
+ if (e->data->e_status != 100) {
+ TEST(e->data->e_status, 407);
+ }
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_proceeding);
TEST_1(!is_answer_recv(e->data->e_tags));
TEST_1(!is_offer_sent(e->data->e_tags));
+
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
}
- TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_prack);
TEST(e->data->e_status, 200);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_call_reject.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_call_reject.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_call_reject.c Mon Mar 26 14:05:55 2007
@@ -261,7 +261,7 @@
/* ------------------------------------------------------------------------ */
-int reject_302(CONDITION_PARAMS);
+int reject_302(CONDITION_PARAMS), reject_305(CONDITION_PARAMS);
int reject_604(CONDITION_PARAMS);
/*
@@ -281,6 +281,7 @@
|<---604 Nowhere-----|
|--------ACK-------->|
*/
+
int reject_302(CONDITION_PARAMS)
{
if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
@@ -301,6 +302,33 @@
case nua_callstate_terminated:
if (call)
nua_handle_destroy(call->nh), call->nh = NULL;
+ ep->next_condition = reject_305;
+ return 0;
+ default:
+ return 0;
+ }
+}
+
+int reject_305(CONDITION_PARAMS)
+{
+ if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+ return 0;
+
+ save_event_in_list(ctx, event, ep, call);
+
+ switch (callstate(tags)) {
+ case nua_callstate_received:
+ {
+ sip_contact_t m[1];
+ *m = *ep->contact;
+ m->m_url->url_user = "305";
+ m->m_url->url_params = "lr=1";
+ RESPOND(ep, call, nh, SIP_305_USE_PROXY, SIPTAG_CONTACT(m), TAG_END());
+ }
+ return 0;
+ case nua_callstate_terminated:
+ if (call)
+ nua_handle_destroy(call->nh), call->nh = NULL;
ep->next_condition = reject_604;
return 0;
default:
@@ -308,6 +336,7 @@
}
}
+
int reject_604(CONDITION_PARAMS)
{
if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
@@ -338,6 +367,7 @@
struct endpoint *a = &ctx->a, *b = &ctx->b;
struct call *a_call = a->call, *b_call = b->call;
struct event *e;
+ sip_t const *sip;
/* Make call reject-3 */
if (print_headings)
@@ -388,6 +418,12 @@
TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
TEST_1(is_offer_sent(e->data->e_tags));
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+ TEST(e->data->e_status, 100);
+ TEST(sip_object(e->data->e_msg)->sip_status->st_status, 305);
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+ TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+ TEST_1(is_offer_sent(e->data->e_tags));
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
TEST(e->data->e_status, 180);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_proceeding); /* PROCEEDING */
@@ -415,6 +451,18 @@
TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
TEST_1(is_offer_recv(e->data->e_tags));
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+ TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_invite);
+ TEST(e->data->e_status, 100);
+ TEST_1(sip = sip_object(e->data->e_msg));
+ TEST_1(sip->sip_request);
+ TEST_S(sip->sip_request->rq_url->url_user, "302");
+ TEST_1(sip->sip_route);
+ TEST_S(sip->sip_route->r_url->url_user, "305");
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+ TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+ TEST_1(is_offer_recv(e->data->e_tags));
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_early); /* EARLY */
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
@@ -724,7 +772,7 @@
sip_t const *sip;
if (print_headings)
- printf("TEST NUA-4.6: invalid challenge \n");
+ printf("TEST NUA-4.6.1: invalid challenge \n");
a_call->sdp = "m=audio 5008 RTP/AVP 8";
b_call->sdp = "m=audio 5010 RTP/AVP 0 8";
@@ -773,7 +821,160 @@
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
if (print_headings)
- printf("TEST NUA-4.6: PASSED\n");
+ printf("TEST NUA-4.6.1: PASSED\n");
+
+ END();
+}
+
+
+/* ------------------------------------------------------------------------ */
+
+/* Reject call with 401, twice */
+
+/*
+ A reject-401-bad B
+ | |
+ |-------INVITE------>|
+ |<----100 Trying-----|
+ |<--------401--------|
+ |---------ACK------->|
+ | |
+ |-------INVITE------>|
+ |<----100 Trying-----|
+ |<--------401--------|
+ |---------ACK------->|
+*/
+
+int reject_401_bad(CONDITION_PARAMS)
+{
+ if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+ return 0;
+
+ save_event_in_list(ctx, event, ep, call);
+
+ switch (callstate(tags)) {
+ case nua_callstate_received:
+ RESPOND(ep, call, nh, SIP_401_UNAUTHORIZED,
+ /* Send a challenge that we do not grok */
+ SIPTAG_WWW_AUTHENTICATE_STR("Digest realm=\"No hope\", "
+ "nonce=\"goO541ftNrw327aWpu2\", "
+ "algorithm=MD5, "
+ "qop=\"auth\""),
+ TAG_END());
+ return 0;
+ case nua_callstate_terminated:
+ if (call)
+ nua_handle_destroy(call->nh), call->nh = NULL;
+ if (ep->flags.bit0) /* Terminate 2 calls */
+ return 1;
+ ep->flags.bit0 = 1;
+ return 0;
+ default:
+ return 0;
+ }
+}
+
+int authenticate_once(CONDITION_PARAMS)
+{
+ if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+ return 0;
+
+ save_event_in_list(ctx, event, ep, call);
+
+ if (event == nua_r_invite && status == 401) {
+ if (ep->flags.bit0) {
+ nua_handle_destroy(nh); if (call) call->nh = NULL;
+ return 1;
+ }
+ ep->flags.bit0 = 1;
+ AUTHENTICATE(ep, call, nh, NUTAG_AUTH("Digest:\"No hope\":jaska:secret"),
+ SIPTAG_SUBJECT_STR("Got 401"),
+ TAG_END());
+ return 0;
+ }
+
+ switch (callstate(tags)) {
+ case nua_callstate_terminated:
+ if (call)
+ nua_handle_destroy(call->nh), call->nh = NULL;
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+
+int test_reject_401_bad(struct context *ctx)
+{
+ BEGIN();
+
+ struct endpoint *a = &ctx->a, *b = &ctx->b;
+ struct call *a_call = a->call, *b_call = b->call;
+ struct event const *e;
+ sip_t const *sip;
+
+ if (print_headings)
+ printf("TEST NUA-4.6.2: bad username/password\n");
+
+ a_call->sdp = "m=audio 5008 RTP/AVP 8";
+
+ TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+ INVITE(a, a_call, a_call->nh,
+ TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
+ SIPTAG_SUBJECT_STR("reject-401-bad"),
+ SOATAG_USER_SDP_STR(a_call->sdp),
+ TAG_END());
+
+ run_ab_until(ctx, -1, authenticate_once, -1, reject_401_bad);
+
+ /*
+ Client transitions
+ INIT -(C1)-> CALLING -(C6a)-> TERMINATED/INIT
+ */
+ TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_state);
+ TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+ TEST_1(is_offer_sent(e->data->e_tags));
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+ TEST(sip_object(e->data->e_msg)->sip_status->st_status, 401);
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+ TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
+ TEST_1(is_offer_sent(e->data->e_tags));
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_invite);
+ TEST(sip_object(e->data->e_msg)->sip_status->st_status, 401);
+ TEST_1(!e->next);
+
+ free_events_in_list(ctx, a->events);
+
+ /*
+ Server transitions:
+ INIT -(S1)-> RECEIVED -(S6a)-> TERMINATED
+ */
+ TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_invite);
+ TEST_1(sip = sip_object(e->data->e_msg));
+ TEST(e->data->e_status, 100);
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+ TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+ TEST_1(is_offer_recv(e->data->e_tags));
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+ TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_invite);
+ TEST_1(sip = sip_object(e->data->e_msg));
+ TEST(e->data->e_status, 100);
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+ TEST(callstate(e->data->e_tags), nua_callstate_received); /* RECEIVED */
+ TEST_1(is_offer_recv(e->data->e_tags));
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
+ TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
+ TEST_1(!e->next);
+
+ free_events_in_list(ctx, b->events);
+
+ nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+ nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+ if (print_headings)
+ printf("TEST NUA-4.6.2: PASSED\n");
END();
}
@@ -976,7 +1177,7 @@
struct endpoint *a = &ctx->a, *b = &ctx->b;
struct call *a_call = a->call, *b_call = b->call;
struct event *e;
- struct nat_filter *f;
+ struct nat_filter *f, *f2;
if (print_headings)
printf("TEST NUA-4.7: check for error and timeout handling\n");
@@ -993,6 +1194,8 @@
TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
TEST_1(f = test_nat_add_filter(ctx->nat, filter_200_OK, NULL, nat_inbound));
+ TEST_1(f2 = test_nat_add_filter(ctx->nat, filter_200_OK,
+ NULL, nat_outbound));
INVITE(a, a_call, a_call->nh,
TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
@@ -1014,7 +1217,7 @@
| X-----200--------|
| |
|<--------BYE--------|
- |--------200 OK----->|
+ |--------200 OK---X |
*/
@@ -1052,6 +1255,7 @@
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_terminating); /* TERMINATING */
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_bye);
+ TEST(e->data->e_status, 408);
TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
TEST_1(!e->next);
@@ -1062,6 +1266,7 @@
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
TEST_1(test_nat_remove_filter(ctx->nat, f) == 0);
+ TEST_1(test_nat_remove_filter(ctx->nat, f2) == 0);
if (print_headings)
printf("TEST NUA-4.7.1: PASSED\n");
@@ -1262,3 +1467,19 @@
return event == nua_i_state && callstate(tags) == nua_callstate_terminated;
}
+
+/* ---------------------------------------------------------------------- */
+
+int test_rejects(struct context *ctx)
+{
+ return
+ test_reject_401_bad(ctx) ||
+ test_reject_a(ctx) ||
+ test_reject_b(ctx) ||
+ test_reject_302(ctx) ||
+ test_reject_401(ctx) ||
+ test_mime_negotiation(ctx) ||
+ test_call_timeouts(ctx) ||
+ test_reject_401_aka(ctx) ||
+ 0;
+}
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_init.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_init.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_init.c Mon Mar 26 14:05:55 2007
@@ -110,7 +110,8 @@
AUTHTAG_OPAQUE("kuik"),
AUTHTAG_DB(passwd_name),
AUTHTAG_QOP("auth-int"),
- AUTHTAG_ALGORITHM("md5-sess"),
+ AUTHTAG_ALGORITHM("md5"),
+ AUTHTAG_NEXT_EXPIRES(60),
TAG_IF(ctx->proxy_logging, TPTAG_LOG(1)),
TAG_END());
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.c Mon Mar 26 14:05:55 2007
@@ -307,13 +307,7 @@
while (retval == 0) {
retval |= test_basic_call(ctx); SINGLE_FAILURE_CHECK();
- retval |= test_reject_a(ctx); SINGLE_FAILURE_CHECK();
- retval |= test_reject_b(ctx); SINGLE_FAILURE_CHECK();
- retval |= test_reject_302(ctx); SINGLE_FAILURE_CHECK();
- retval |= test_reject_401(ctx); SINGLE_FAILURE_CHECK();
- retval |= test_mime_negotiation(ctx); SINGLE_FAILURE_CHECK();
- retval |= test_call_timeouts(ctx); SINGLE_FAILURE_CHECK();
- retval |= test_reject_401_aka(ctx); SINGLE_FAILURE_CHECK();
+ retval |= test_rejects(ctx); SINGLE_FAILURE_CHECK();
retval |= test_call_cancel(ctx); SINGLE_FAILURE_CHECK();
retval |= test_call_destroy(ctx); SINGLE_FAILURE_CHECK();
retval |= test_offer_answer(ctx); SINGLE_FAILURE_CHECK();
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.h Mon Mar 26 14:05:55 2007
@@ -330,10 +330,7 @@
int test_basic_call(struct context *ctx);
int test_offer_answer(struct context *ctx);
-int test_reject_a(struct context *ctx);
-int test_reject_b(struct context *ctx);
-int test_reject_302(struct context *ctx);
-int test_reject_401(struct context *ctx);
+int test_rejects(struct context *ctx);
int test_mime_negotiation(struct context *ctx);
int test_call_timeouts(struct context *ctx);
int test_reject_401_aka(struct context *ctx);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua_params.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua_params.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_nua_params.c Mon Mar 26 14:05:55 2007
@@ -193,6 +193,7 @@
NUTAG_MEDIA_FEATURES(1),
NUTAG_SERVICE_ROUTE_ENABLE(0),
NUTAG_PATH_ENABLE(0),
+ NUTAG_AUTH_CACHE(nua_auth_cache_challenged),
NUTAG_REFER_EXPIRES(333),
NUTAG_REFER_WITH_ID(0),
NUTAG_SUBSTATE(nua_substate_pending),
@@ -268,6 +269,7 @@
int media_features = -1;
int service_route_enable = -1;
int path_enable = -1;
+ int auth_cache = -1;
unsigned refer_expires = (unsigned)-1;
int refer_with_id = -1;
int substate = -1;
@@ -331,6 +333,7 @@
NUTAG_MEDIA_FEATURES_REF(media_features),
NUTAG_SERVICE_ROUTE_ENABLE_REF(service_route_enable),
NUTAG_PATH_ENABLE_REF(path_enable),
+ NUTAG_AUTH_CACHE_REF(auth_cache),
NUTAG_REFER_EXPIRES_REF(refer_expires),
NUTAG_REFER_WITH_ID_REF(refer_with_id),
NUTAG_SUBSTATE_REF(substate),
@@ -361,7 +364,7 @@
NUTAG_INSTANCE_REF(instance),
TAG_END());
- TEST(n, 47);
+ TEST(n, 48);
TEST_S(sip_header_as_string(tmphome, (void *)from), Alice);
TEST_S(from_str, Alice);
@@ -391,6 +394,7 @@
TEST(media_features, 1);
TEST(service_route_enable, 0);
TEST(path_enable, 0);
+ TEST(auth_cache, nua_auth_cache_challenged);
TEST(refer_expires, 333);
TEST(refer_with_id, 0);
TEST(substate, nua_substate_pending);
@@ -455,6 +459,7 @@
int media_features = -1;
int service_route_enable = -1;
int path_enable = -1;
+ int auth_cache = -1;
unsigned refer_expires = (unsigned)-1;
int refer_with_id = -1;
int substate = -1;
@@ -513,6 +518,7 @@
NUTAG_MEDIA_FEATURES_REF(media_features),
NUTAG_SERVICE_ROUTE_ENABLE_REF(service_route_enable),
NUTAG_PATH_ENABLE_REF(path_enable),
+ NUTAG_AUTH_CACHE_REF(auth_cache),
NUTAG_SUBSTATE_REF(substate),
SIPTAG_SUPPORTED_REF(supported),
@@ -565,6 +571,7 @@
TEST(media_features, -1);
TEST(service_route_enable, -1);
TEST(path_enable, -1);
+ TEST(auth_cache, -1);
TEST(refer_expires, (unsigned)-1);
TEST(refer_with_id, -1);
TEST(substate, -1);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_register.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_register.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/nua/test_register.c Mon Mar 26 14:05:55 2007
@@ -55,6 +55,7 @@
struct event *e;
sip_t const *sip;
sip_cseq_t cseq[1];
+ int seen_401;
if (ctx->p)
test_proxy_set_expiration(ctx->p, 5, 5, 10);
@@ -189,6 +190,8 @@
REGISTER(b, b_reg, b_reg->nh, SIPTAG_TO(b->to),
SIPTAG_CONTACT(m),
+ /* Do not include credentials unless challenged */
+ NUTAG_AUTH_CACHE(nua_auth_cache_challenged),
TAG_END());
}
run_ab_until(ctx, -1, save_events, -1, save_until_final_response);
@@ -213,7 +216,8 @@
TEST_1(sip->sip_contact);
TEST_S(sip->sip_contact->m_display, "B");
TEST_S(sip->sip_contact->m_url->url_user, "b");
-
+ free_events_in_list(ctx, b->events);
+
if (print_headings)
printf("TEST NUA-2.3.2: PASSED\n");
@@ -318,11 +322,21 @@
TEST_1(!e->next);
free_events_in_list(ctx, a->events);
+ seen_401 = 0;
+
for (e = b->events->head; e; e = e->next) {
TEST_E(e->data->e_event, nua_r_register);
- TEST(e->data->e_status, 200);
TEST_1(sip = sip_object(e->data->e_msg));
- TEST_1(sip->sip_contact);
+
+ if (e->data->e_status == 200) {
+ TEST(e->data->e_status, 200);
+ TEST_1(seen_401);
+ TEST_1(sip->sip_contact);
+ }
+ else if (sip->sip_status && sip->sip_status->st_status == 401) {
+ seen_401 = 1;
+ }
+
if (!e->next)
break;
}
@@ -680,6 +694,10 @@
run_b_until(ctx, -1, save_until_final_response);
TEST_1(e = b->events->head);
TEST_E(e->data->e_event, nua_r_unregister);
+ if (e->data->e_status == 100) {
+ TEST_1(e = e->next);
+ TEST_E(e->data->e_event, nua_r_unregister);
+ }
TEST(e->data->e_status, 200);
TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(!sip->sip_contact);
Added: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/sip/tests/10052.txt
==============================================================================
--- (empty file)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/sip/tests/10052.txt Mon Mar 26 14:05:55 2007
@@ -0,0 +1,20 @@
+INVITE sip:1234@10.50.71.28 SIP/2.0
+To: <sip:1234@10.50.71.28>
+From: "Displayname" <sip:1234@testaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.example.local:5060>;tag=10052
+Via: SIP/2.0/UDP 10.50.71.29:5060;branch=z9hG4bK10052t1174659568681
+Call-ID: s0c00010052i0t1174659568681(a)10.50.71.29
+Contact: "999" <sip:999@10.50.71.29;transport=udp>
+Content-Length: 180
+Content-Type: application/sdp
+CSeq: 1 INVITE
+Max-Forwards: 70
+
+v=0
+o=999 1 1 IN IP4 10.50.71.29
+s=Codenomicon SIP UAS Test Tool 3.0.2 (http://www.codenomicon.com/)
+c=IN IP4 10.50.71.29
+t=0 0
+m=audio 49152 RTP/AVP 0
+a=rtpmap:0 PCMU/8000
\ No newline at end of file
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_wait.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_wait.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/su_wait.h Mon Mar 26 14:05:55 2007
@@ -46,9 +46,7 @@
#include "sofia-sip/su_time.h"
#endif
-#if SU_HAVE_KQUEUE
-#include <sys/event.h>
-#elif SU_HAVE_POLL
+#if SU_HAVE_POLL
#include <sys/poll.h>
#endif
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_udp.c Mon Mar 26 14:05:55 2007
@@ -252,6 +252,11 @@
su_strerror(err), err));
return -1;
}
+ if (N == 0) {
+ su_recv(self->tp_socket, sample, 1, 0);
+ SU_DEBUG_3(("tport(%p): zero length packet", (void *)self));
+ return 0;
+ }
#endif
veclen = tport_recv_iovec(self, &self->tp_msg, iovec, N, 1);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/url/torture_url.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/url/torture_url.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/url/torture_url.c Mon Mar 26 14:05:55 2007
@@ -403,6 +403,10 @@
TEST_S(u->url_params, "isfocus");
TEST_1(!url_have_transport(u));
+ u = url_hdup(home, (void *)"sip:%22foo%22@172.21.55.55:5060");
+ TEST_1(u);
+ TEST_S(u->url_user, "%22foo%22");
+
a = url_hdup(home, (void *)"sip:172.21.55.55:5060");
b = url_hdup(home, (void *)"sip:172.21.55.55");
TEST_1(a); TEST_1(b);
1
0
[commit] r4752 - freeswitch/branches/mikej/sofiasip-upgrade/libs/win32/sofia
by Freeswitch SVN 23 Mar '07
by Freeswitch SVN 23 Mar '07
23 Mar '07
Author: mikej
Date: Fri Mar 23 13:08:51 2007
New Revision: 4752
Modified:
freeswitch/branches/mikej/sofiasip-upgrade/libs/win32/sofia/libsofia_sip_ua_static.vcproj
Log:
this project file should work... untested.
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/win32/sofia/libsofia_sip_ua_static.vcproj
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/win32/sofia/libsofia_sip_ua_static.vcproj (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/win32/sofia/libsofia_sip_ua_static.vcproj Fri Mar 23 13:08:51 2007
@@ -54,6 +54,7 @@
ProgramDataBaseFileName=".\Debug/"
BrowseInformation="1"
WarningLevel="4"
+ WarnAsError="true"
SuppressStartupBanner="true"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
@@ -133,6 +134,7 @@
ProgramDataBaseFileName=".\Release/"
BrowseInformation="1"
WarningLevel="4"
+ WarnAsError="true"
SuppressStartupBanner="true"
Detect64BitPortabilityProblems="true"
/>
@@ -207,6 +209,10 @@
>
</File>
<File
+ RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_base_port.c"
+ >
+ </File>
+ <File
RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_bm.c"
>
</File>
@@ -243,10 +249,18 @@
>
</File>
<File
+ RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_pthread_port.c"
+ >
+ </File>
+ <File
RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_root.c"
>
</File>
<File
+ RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_socket_port.c"
+ >
+ </File>
+ <File
RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_sprintf.c"
>
</File>
@@ -294,6 +308,10 @@
RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_wait.c"
>
</File>
+ <File
+ RelativePath="..\..\sofia-sip\libsofia-sip-ua\su\su_win32_port.c"
+ >
+ </File>
</Filter>
<Filter
Name="ipt"
1
0
[commit] r4729 - in freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip: . libsofia-sip-ua/su libsofia-sip-ua/su/sofia-sip m4
by Freeswitch SVN 22 Mar '07
by Freeswitch SVN 22 Mar '07
22 Mar '07
Author: mikej
Date: Thu Mar 22 10:41:43 2007
New Revision: 4729
Modified:
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/Makefile.am
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/htable.h
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/htable2.h
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/su_kqueue_port.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/test_htable.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/test_memmem.c
freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/m4/sac-tport.m4
Log:
updates from sofia-sip darcs tree:
Wed Mar 21 06:15:56 EDT 2007 Pekka Pessi <Pekka.Pessi(a)nokia.com>
* Makefile.am, m4/sac-tport.m4: fixes for Solaris
Wed Mar 21 06:40:04 EDT 2007 Pekka Pessi <first.lastname(a)nokia.com>
* sofia-sip/htable.h: do not fail assert in htable_remove() if entry is not found
Changed htable_remove() prototype, it now returns -1.
Wed Mar 21 11:36:40 EDT 2007 Pekka Pessi <first.lastname(a)nokia.com>
* test_memmem.c: warn about bad system memmem(), do not fail.
Wed Mar 21 11:37:18 EDT 2007 Pekka Pessi <first.lastname(a)nokia.com>
* su_kqueue_port.c: using correct kqueue semantics
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/Makefile.am
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/Makefile.am (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/Makefile.am Thu Mar 22 10:41:43 2007
@@ -49,6 +49,11 @@
CLEANFILES = $(dist_man_MANS)
coverage built-sources clean-built-sources valcheck doxygen:
- for i in libsofia-sip-ua $(GLIB_SUBDIRS) ; do $(MAKE) $(AM_MAKEFLAGS) -C $$i $@ ; done
+ @failcom='exit 1'; for f in x $$MAKEFLAGS; do \
+ case $$f in *=* | --[!k]*);; *k*) failcom='fail=yes';; esac; done; \
+ for i in libsofia-sip-ua $(GLIB_SUBDIRS) ; do \
+ (cd $$i && $(MAKE) $(AM_MAKEFLAGS) $@) || eval $$failcom; \
+ done ; \
+ test -z "$$fail"
-.PHONY: coverage built-sources clean-built-sources doxygen manpages
+.PHONY: coverage built-sources clean-built-sources valcheck doxygen manpages
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/htable.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/htable.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/htable.h Thu Mar 22 10:41:43 2007
@@ -106,7 +106,7 @@
HTABLE_SCOPE entry_t **prefix##_next(prefix##_t const *, entry_t * const *ee); \
HTABLE_SCOPE void prefix##_append(prefix##_t *pr, entry_t const *e); \
HTABLE_SCOPE void prefix##_insert(prefix##_t *pr, entry_t const *e); \
-HTABLE_SCOPE void prefix##_remove(prefix##_t *, entry_t const *e)
+HTABLE_SCOPE int prefix##_remove(prefix##_t *, entry_t const *e)
/** Hash table implementation.
*
@@ -220,13 +220,13 @@
} \
\
HTABLE_SCOPE \
-void prefix##_remove(prefix##_t *pr, entry_t const *e) \
+int prefix##_remove(prefix##_t *pr, entry_t const *e) \
{ \
size_t i, j, k; \
size_t size = pr->pr##_size; \
entry_t **htable = pr->pr##_table; \
\
- if (!e) return; \
+ if (!e) return -1; \
\
/* Search for entry */ \
for (i = hfun(e) % size; htable[i]; i = (i + 1) % size) \
@@ -234,7 +234,7 @@
break; \
\
/* Entry is not in table? */ \
- assert(htable[i]); if (!e) return; \
+ if (!htable[i]) return -1; \
\
/* Move table entries towards their primary place */ \
for (j = (i + 1) % size; htable[j]; j = (j + 1) % size) { \
@@ -252,6 +252,8 @@
pr->pr##_used--; \
\
htable[i] = NULL; \
+\
+ return 0; \
} \
extern int prefix##_dummy
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/htable2.h
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/htable2.h (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/sofia-sip/htable2.h Thu Mar 22 10:41:43 2007
@@ -240,7 +240,7 @@
if (is_equal(e, htable[i])) \
break; \
\
- assert(is_used(htable[i])); if (!is_used(htable[i])) return -1; \
+ if (!is_used(htable[i])) return -1; \
\
/* Move table entries towards their primary place */ \
for (j = (i + 1) % size; is_used(htable[j]); j = (j + 1) % size) { \
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/su_kqueue_port.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/su_kqueue_port.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/su_kqueue_port.c Thu Mar 22 10:41:43 2007
@@ -28,6 +28,7 @@
* Port implementation using kqueue()
*
* @author Martti Mela <Martti.Mela(a)nokia.com>
+ * @author Pekka Pessi <Pekka.Pessi(a)nokia.com>
*
* @date Created: Sun Feb 18 19:55:37 EET 2007 mela
*/
@@ -43,6 +44,8 @@
#include "sofia-sip/su_alloc.h"
+#include <sys/event.h>
+
#define SU_ENABLE_MULTISHOT_KQUEUE 1
#include <stdlib.h>
@@ -68,28 +71,21 @@
su_port_register() or
su_port_unregister()
*/
-
- int sup_n_waits; /**< Active su_wait_t in su_waits */
- int sup_size_waits; /**< Size of allocated su_waits */
- int sup_pri_offset; /**< Offset to prioritized waits */
+ int sup_n_registrations;
+ int sup_max_index; /**< Indexes are equal or smaller than this */
+ int sup_size_indices; /**< Size of allocated index table */
#define INDEX_MAX (0x7fffffff)
- /** Indices from index returned by su_root_register() to tables below.
- *
- * Free elements are negative. Free elements form a list, value of free
- * element is (0 - index of next free element).
- *
- * First element sup_indices[0] points to first free element.
- */
- int *sup_indices;
-
- int *sup_reverses; /** Reverse index */
- su_wakeup_f *sup_wait_cbs;
- su_wakeup_arg_t**sup_wait_args;
- su_root_t **sup_wait_roots;
- su_wait_t *sup_waits;
-
+ /** Structure containing registration data */
+ struct su_register {
+ struct su_register *ser_next; /* Next in free list */
+ su_wakeup_f ser_cb;
+ su_wakeup_arg_t*ser_arg;
+ su_root_t *ser_root;
+ int ser_id; /** registration identifier */
+ su_wait_t ser_wait[1];
+ } **sup_indices;
};
static void su_kqueue_port_decref(su_port_t *, int blocking, char const *who);
@@ -160,6 +156,8 @@
SU_DEBUG_9(("%s(%p) called\n", "su_kqueue_port_deinit", (void *)self));
su_socket_port_deinit(self->sup_base);
+
+ close(self->sup_kqueue);
}
static void su_kqueue_port_decref(su_port_t *self, int blocking, char const *who)
@@ -189,180 +187,137 @@
* or -1 upon an error.
*/
int su_kqueue_port_register(su_port_t *self,
- su_root_t *root,
- su_wait_t *wait,
- su_wakeup_f callback,
- su_wakeup_arg_t *arg,
- int priority)
+ su_root_t *root,
+ su_wait_t *wait,
+ su_wakeup_f callback,
+ su_wakeup_arg_t *arg,
+ int priority)
{
int i, j, n;
+ struct su_register *ser;
+ struct su_register **indices = self->sup_indices;
+ struct kevent ev[1];
+ int flags;
assert(su_port_own_thread(self));
- n = self->sup_n_waits;
+ n = self->sup_size_indices;
if (n >= SU_WAIT_MAX)
return su_seterrno(ENOMEM);
- if (n >= self->sup_size_waits) {
- su_home_t *h = self->sup_home;
- /* Reallocate size arrays */
- int size;
- int *indices;
- int *reverses;
- su_wait_t *waits;
- su_wakeup_f *wait_cbs;
- su_wakeup_arg_t **wait_args;
- su_root_t **wait_tasks;
-
- if (self->sup_size_waits == 0)
- size = su_root_size_hint;
- else
- size = 2 * self->sup_size_waits;
-
- if (size < SU_WAIT_MIN)
- size = SU_WAIT_MIN;
-
- /* Too large */
- if (-3 - size > 0)
- return (errno = ENOMEM), -1;
+ ser = indices[0];
+
+ if (!ser) {
+ su_home_t *h = su_port_home(self);
- indices = su_realloc(h, self->sup_indices, (size + 1) * sizeof(*indices));
- if (indices) {
+ i = self->sup_max_index, j = i == 0 ? 15 : i + 16;
+
+ if (j >= self->sup_size_indices) {
+ /* Reallocate index table */
+ n = n < 1024 ? 2 * n : n + 1024;
+ indices = su_realloc(h, indices, n * sizeof(indices[0]));
+ if (!indices)
+ return -1;
self->sup_indices = indices;
+ self->sup_size_indices = n;
+ }
- if (self->sup_size_waits == 0)
- indices[0] = -1;
+ /* Allocate registrations */
+ ser = su_zalloc(h, (j - i) * (sizeof *ser));
+ if (!ser)
+ return -1;
- for (i = self->sup_size_waits + 1; i <= size; i++)
- indices[i] = -1 - i;
- }
+ indices[0] = ser;
- reverses = su_realloc(h, self->sup_reverses, size * sizeof(*waits));
- if (reverses) {
- for (i = self->sup_size_waits; i < size; i++)
- reverses[i] = -1;
- self->sup_reverses = reverses;
+ for (i++; i <= j; i++) {
+ ser->ser_id = i;
+ ser->ser_next = i < j ? ser + 1 : NULL;
+ indices[i] = ser++;
}
-
- waits = su_realloc(h, self->sup_waits, size * sizeof(*waits));
- if (waits)
- self->sup_waits = waits;
-
- wait_cbs = su_realloc(h, self->sup_wait_cbs, size * sizeof(*wait_cbs));
- if (wait_cbs)
- self->sup_wait_cbs = wait_cbs;
-
- wait_args = su_realloc(h, self->sup_wait_args, size * sizeof(*wait_args));
- if (wait_args)
- self->sup_wait_args = wait_args;
-
- /* Add sup_wait_roots array, if needed */
- wait_tasks = su_realloc(h, self->sup_wait_roots, size * sizeof(*wait_tasks));
- if (wait_tasks)
- self->sup_wait_roots = wait_tasks;
- if (!(indices &&
- reverses && waits && wait_cbs && wait_args && wait_tasks)) {
- return -1;
- }
+ self->sup_max_index = j;
- self->sup_size_waits = size;
+ ser = indices[0];
}
- i = -self->sup_indices[0]; assert(i <= self->sup_size_waits);
+ i = ser->ser_id;
- if (priority > 0) {
- /* Insert */
- for (n = self->sup_n_waits; n > 0; n--) {
- j = self->sup_reverses[n-1]; assert(self->sup_indices[j] == n - 1);
- self->sup_indices[j] = n;
- self->sup_reverses[n] = j;
- self->sup_waits[n] = self->sup_waits[n-1];
- self->sup_wait_cbs[n] = self->sup_wait_cbs[n-1];
- self->sup_wait_args[n] = self->sup_wait_args[n-1];
- self->sup_wait_roots[n] = self->sup_wait_roots[n-1];
- }
-
- self->sup_pri_offset++;
- }
- else {
- /* Append - no need to move anything */
- n = self->sup_n_waits;
+ flags = (wait->events & SU_WAIT_IN) ? EV_ADD : EV_ADD | EV_DISABLE;
+ EV_SET(ev, wait->fd, EVFILT_READ, flags, 0, 0, (void *)i);
+ if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) {
+ SU_DEBUG_0(("kevent((%u, %s, %u, %p)) failed: %s\n",
+ wait->fd, "EVFILT_READ", flags, (void *)i, strerror(errno)));
+ return -1;
}
- self->sup_n_waits++;
+ flags = (wait->events & SU_WAIT_OUT) ? EV_ADD : EV_ADD | EV_DISABLE;
+ EV_SET(ev, wait->fd, EVFILT_WRITE, flags, 0, 0, (void *)i);
+ if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) {
+ int error = errno;
+ SU_DEBUG_0(("kevent((%u, %s, %u, %p)) failed: %s\n",
+ wait->fd, "EVFILT_WRITE", flags, (void *)i, strerror(error)));
- self->sup_indices[0] = self->sup_indices[i]; /* Free index */
- self->sup_indices[i] = n;
+ EV_SET(ev, wait->fd, EVFILT_READ, EV_DELETE, 0, 0, (void *)i);
+ kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL);
- self->sup_reverses[n] = i;
- self->sup_waits[n] = *wait;
- self->sup_wait_cbs[n] = callback;
- self->sup_wait_args[n] = arg;
- self->sup_wait_roots[n] = root;
+ errno = error;
+ return -1;
+ }
+ indices[0] = ser->ser_next;
- self->sup_registers++;
+ ser->ser_next = NULL;
+ *ser->ser_wait = *wait;
+ ser->ser_cb = callback;
+ ser->ser_arg = arg;
+ ser->ser_root = root;
- /* Just like epoll, we return -1 or positive integer */
+ self->sup_registers++;
+ self->sup_n_registrations++;
- return i;
+ return i; /* return index */
}
/** Deregister a su_wait_t object. */
static int su_kqueue_port_deregister0(su_port_t *self, int i, int destroy_wait)
{
- int n, N, *indices, *reverses;
+ struct su_register **indices = self->sup_indices;
+ struct su_register *ser;
+ struct kevent ev[1];
+ su_wait_t *wait;
+
+ ser = self->sup_indices[i];
+ if (ser == NULL || ser->ser_cb == NULL) {
+ su_seterrno(ENOENT);
+ return -1;
+ }
- indices = self->sup_indices;
- reverses = self->sup_reverses;
+ assert(ser->ser_id == i);
- n = indices[i]; assert(n >= 0);
+ wait = ser->ser_wait;
- if (destroy_wait)
- su_wait_destroy(&self->sup_waits[n]);
-
- N = --self->sup_n_waits;
-
- if (n < self->sup_pri_offset) {
- int j = --self->sup_pri_offset;
- if (n != j) {
- assert(reverses[j] > 0);
- assert(indices[reverses[j]] == j);
- indices[reverses[j]] = n;
- reverses[n] = reverses[j];
-
- self->sup_waits[n] = self->sup_waits[j];
- self->sup_wait_cbs[n] = self->sup_wait_cbs[j];
- self->sup_wait_args[n] = self->sup_wait_args[j];
- self->sup_wait_roots[n] = self->sup_wait_roots[j];
- n = j;
- }
+ EV_SET(ev, wait->fd, EVFILT_READ, EV_DELETE, 0, 0, (void *)i);
+ if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) {
+ SU_DEBUG_0(("remove kevent((%u, %s, %s, %p)) failed: %s\n",
+ wait->fd, "EVFILT_READ", "EV_DELETE", (void *)i,
+ strerror(errno)));
+ }
+
+ EV_SET(ev, wait->fd, EVFILT_WRITE, EV_DELETE, 0, 0, (void *)i);
+ if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) {
+ SU_DEBUG_0(("remove kevent((%u, %s, %s, %p)) failed: %s\n",
+ wait->fd, "EVFILT_WRITE", "EV_DELETE", (void *)i,
+ strerror(errno)));
}
- if (n < N) {
- assert(reverses[N] > 0);
- assert(indices[reverses[N]] == N);
-
- indices[reverses[N]] = n;
- reverses[n] = reverses[N];
-
- self->sup_waits[n] = self->sup_waits[N];
- self->sup_wait_cbs[n] = self->sup_wait_cbs[N];
- self->sup_wait_args[n] = self->sup_wait_args[N];
- self->sup_wait_roots[n] = self->sup_wait_roots[N];
- n = N;
- }
-
- reverses[n] = -1;
- memset(&self->sup_waits[n], 0, sizeof self->sup_waits[n]);
- self->sup_wait_cbs[n] = NULL;
- self->sup_wait_args[n] = NULL;
- self->sup_wait_roots[n] = NULL;
+ if (destroy_wait)
+ su_wait_destroy(wait);
- indices[i] = indices[0];
- indices[0] = -i;
+ memset(ser, 0, sizeof *ser);
+ ser->ser_id = i;
+ ser->ser_next = indices[0], indices[0] = ser;
+ self->sup_n_registrations--;
self->sup_registers++;
return i;
@@ -392,17 +347,22 @@
su_wakeup_f callback, /* XXX - ignored */
su_wakeup_arg_t *arg)
{
- int n, N;
+ int i, I;
+
+ struct su_register *ser;
assert(self);
assert(su_port_own_thread(self));
- N = self->sup_n_waits;
+ I = self->sup_max_index;
- for (n = 0; n < N; n++) {
- if (SU_WAIT_CMP(wait[0], self->sup_waits[n]) == 0) {
- return su_kqueue_port_deregister0(self, self->sup_reverses[n], 0);
- }
+ for (i = 1; i <= I; i++) {
+ ser = self->sup_indices[i];
+
+ if (ser->ser_cb &&
+ arg == ser->ser_arg &&
+ SU_WAIT_CMP(wait[0], ser->ser_wait[0]) == 0)
+ return su_kqueue_port_deregister0(self, ser->ser_id, 0);
}
su_seterrno(ENOENT);
@@ -423,28 +383,20 @@
*/
int su_kqueue_port_deregister(su_port_t *self, int i)
{
- su_wait_t wait[1] = { SU_WAIT_INIT };
- int retval;
+ struct su_register *ser;
- assert(self);
- assert(su_port_own_thread(self));
-
- if (i <= 0 || i > self->sup_size_waits)
+ if (i <= 0 || i > self->sup_max_index)
return su_seterrno(EBADF);
- if (self->sup_indices[i] < 0)
+ ser = self->sup_indices[i];
+ if (!ser->ser_cb)
return su_seterrno(EBADF);
-
- retval = su_kqueue_port_deregister0(self, i, 1);
- su_wait_destroy(wait);
-
- return retval;
+ return su_kqueue_port_deregister0(self, i, 1);
}
-
/** @internal
- * Unregister all su_wait_t objects.
+ * Unregister all su_wait_t objects belonging to a root.
*
* The function su_kqueue_port_unregister_all() unregisters all su_wait_t objects
* and destroys all queued timers associated with given root object.
@@ -457,60 +409,24 @@
int su_kqueue_port_unregister_all(su_port_t *self,
su_root_t *root)
{
- int i, j, index, N;
- int *indices, *reverses;
- su_wait_t *waits;
- su_wakeup_f *wait_cbs;
- su_wakeup_arg_t**wait_args;
- su_root_t **wait_roots;
+ int i, I, n;
- assert(su_port_own_thread(self));
+ struct su_register *ser;
- N = self->sup_n_waits;
- indices = self->sup_indices;
- reverses = self->sup_reverses;
- waits = self->sup_waits;
- wait_cbs = self->sup_wait_cbs;
- wait_args = self->sup_wait_args;
- wait_roots = self->sup_wait_roots;
-
- for (i = j = 0; i < N; i++) {
- index = reverses[i]; assert(index > 0 && indices[index] == i);
+ assert(self); assert(root);
+ assert(su_port_own_thread(self));
- if (wait_roots[i] == root) {
- /* XXX - we should free all resources associated with this, too */
- if (i < self->sup_pri_offset)
- self->sup_pri_offset--;
+ I = self->sup_max_index;
- indices[index] = indices[0];
- indices[0] = -index;
+ for (i = 1, n = 0; i <= I; i++) {
+ ser = self->sup_indices[i];
+ if (ser->ser_root != root)
continue;
- }
-
- if (i != j) {
- indices[index] = j;
- reverses[j] = reverses[i];
- waits[j] = waits[i];
- wait_cbs[j] = wait_cbs[i];
- wait_args[j] = wait_args[i];
- wait_roots[j] = wait_roots[i];
- }
-
- j++;
+ su_kqueue_port_deregister0(self, ser->ser_id, 0);
+ n++;
}
-
- for (i = j; i < N; i++) {
- reverses[i] = -1;
- wait_cbs[i] = NULL;
- wait_args[i] = NULL;
- wait_roots[i] = NULL;
- }
- memset(&waits[j], 0, (char *)&waits[N] - (char *)&waits[j]);
-
- self->sup_n_waits = j;
- self->sup_registers++;
- return N - j;
+ return n;
}
/**Set mask for a registered event. @internal
@@ -528,17 +444,43 @@
*/
int su_kqueue_port_eventmask(su_port_t *self, int index, int socket, int events)
{
- int n;
- assert(self);
- assert(su_port_own_thread(self));
+ struct su_register *ser;
+ struct kevent ev[1];
+ su_wait_t *wait;
+ int flags;
- if (index <= 0 || index > self->sup_size_waits)
+ if (index <= 0 || index > self->sup_max_index)
return su_seterrno(EBADF);
- n = self->sup_indices[index];
- if (n < 0)
+
+ ser = self->sup_indices[index];
+ if (!ser->ser_cb)
return su_seterrno(EBADF);
- return su_wait_mask(&self->sup_waits[n], socket, events);
+ wait = ser->ser_wait;
+
+ assert(socket == wait->fd);
+
+ wait->events = events;
+
+ flags = (wait->events & SU_WAIT_IN) ? EV_ADD | EV_ENABLE : EV_ADD | EV_DISABLE;
+ EV_SET(ev, wait->fd, EVFILT_READ, flags, 0, 0, (void *)index);
+ if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) {
+ SU_DEBUG_0(("modify kevent((%u, %s, %s, %p)) failed: %s\n",
+ wait->fd, "EVFILT_READ",
+ (events & SU_WAIT_IN) ? "EV_ENABLE" : "EV_DISABLE",
+ (void *)index, strerror(errno)));
+ }
+
+ flags = (wait->events & SU_WAIT_OUT) ? EV_ADD | EV_ENABLE : EV_ADD | EV_DISABLE;
+ EV_SET(ev, wait->fd, EVFILT_WRITE, flags, 0, 0, (void *)index);
+ if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) {
+ SU_DEBUG_0(("modify kevent((%u, %s, %s, %p)) failed: %s\n",
+ wait->fd, "EVFILT_WRITE",
+ (events & SU_WAIT_OUT) ? "EV_ENABLE" : "EV_DISABLE",
+ (void *)index, strerror(errno)));
+ }
+
+ return 0;
}
/** @internal Enable multishot mode.
@@ -578,108 +520,94 @@
static
int su_kqueue_port_wait_events(su_port_t *self, su_duration_t tout)
{
- int i, j, events = 0;
- su_wait_t *waits = self->sup_waits;
- int n = self->sup_n_waits;
- su_root_t *root;
+ int j, n, events = 0, index;
unsigned version = self->sup_registers;
- struct timespec timeout[1] = {{ 0 }};
- timeout->tv_nsec = tout;
+ int const M = 4;
+ struct kevent ev[M];
+
+ struct timespec ts;
- i = kevent(self->sup_kqueue,
- self->sup_waits, n, /* Active waits */
- self->sup_waits, self->sup_size_waits, /* Total waits */
- timeout);
-
- if (i >= 0 && i < n) {
- /* kqueue() can return events for multiple wait objects */
- if (self->sup_multishot) {
- for (j = 0; j < i; j++) {
- if (self->sup_waits[j].filter == EVFILT_READ ||
- self->sup_waits[j].filter == EVFILT_WRITE) {
- root = self->sup_wait_roots[i];
- self->sup_wait_cbs[i](root ? su_root_magic(root) : NULL,
- &waits[i],
- self->sup_wait_args[i]);
- events++;
- /* Callback function used su_register()/su_deregister() */
- if (version != self->sup_registers)
- break;
- }
- }
- }
- else {
- root = self->sup_wait_roots[i];
- self->sup_wait_cbs[i](root ? su_root_magic(root) : NULL,
- &self->sup_waits[i],
- self->sup_wait_args[i]);
+ ts.tv_sec = tout / 1000;
+ ts.tv_nsec = tout % 1000 * 1000000;
+
+ n = kevent(self->sup_kqueue, NULL, 0,
+ ev, self->sup_multishot ? M : 1,
+ tout < SU_DURATION_MAX ? &ts : NULL);
+
+ assert(n <= M);
+
+ for (j = 0; j < n; j++) {
+ struct su_register *ser;
+ su_root_magic_t *magic;
+
+ index = (int)ev[j].udata;
+ if (index <= 0 || self->sup_max_index < index)
+ continue;
+ ser = self->sup_indices[index];
+
+ magic = ser->ser_root ? su_root_magic(ser->ser_root) : NULL;
+ ser->ser_wait->revents =
+ (ser->ser_wait->events | SU_WAIT_HUP) &
+ (
+ ((ev[j].filter == EVFILT_READ) ? SU_WAIT_IN : 0) |
+ ((ev[j].filter == EVFILT_WRITE) ? SU_WAIT_OUT : 0) |
+ ((ev[j].flags & EV_EOF) ? SU_WAIT_HUP : 0)
+ );
+ if (ser->ser_wait->revents) {
+ ser->ser_cb(magic, ser->ser_wait, ser->ser_arg);
events++;
+ if (version != self->sup_registers)
+ /* Callback function used su_register()/su_deregister() */
+ return events;
}
- }
+ }
- return events;
+ return n;
}
-#if 0
-/** @internal
- * Prints out the contents of the port.
- *
- * @param self pointer to a port
- * @param f pointer to a file (if @c NULL, uses @c stdout).
- */
-void su_port_dump(su_port_t const *self, FILE *f)
-{
- int i;
-#define IS_WAIT_IN(x) (((x)->events & SU_WAIT_IN) ? "IN" : "")
-#define IS_WAIT_OUT(x) (((x)->events & SU_WAIT_OUT) ? "OUT" : "")
-#define IS_WAIT_ACCEPT(x) (((x)->events & SU_WAIT_ACCEPT) ? "ACCEPT" : "")
-
- if (f == NULL)
- f = stdout;
-
- fprintf(f, "su_port_t at %p:\n", self);
- fprintf(f, "\tport is%s running\n", self->sup_running ? "" : "not ");
-#if SU_HAVE_PTHREADS
- fprintf(f, "\tport tid %p\n", (void *)self->sup_tid);
- fprintf(f, "\tport mbox %d (%s%s%s)\n", self->sup_mbox[0],
- IS_WAIT_IN(&self->sup_mbox_wait),
- IS_WAIT_OUT(&self->sup_mbox_wait),
- IS_WAIT_ACCEPT(&self->sup_mbox_wait));
-#endif
- fprintf(f, "\t%d wait objects\n", self->sup_n_waits);
- for (i = 0; i < self->sup_n_waits; i++) {
-
- }
-}
-
-#endif
-/** Create a port using poll() or kqueue().
+/** Create a port using kqueue() (or poll()/select(), if kqueue() fails).
*/
su_port_t *su_kqueue_port_create(void)
{
- int kq = kqueue();
su_port_t *self = NULL;
+ int kq = kqueue();
- if (kq < 0);
- return self;
+ if (kq < 0) {
+#if HAVE_POLL
+ return su_poll_port_create();
+#else
+ return su_select_port_create();
+#endif
+ }
self = su_home_new(sizeof *self);
if (!self)
- return self;
+ goto failed;
if (su_home_destructor(su_port_home(self), su_kqueue_port_deinit) < 0)
- return su_home_unref(su_port_home(self)), NULL;
+ goto failed;
- self->sup_multishot = SU_ENABLE_MULTISHOT_KQUEUE;
+ self->sup_kqueue = kq, kq = -1;
+ self->sup_indices = su_zalloc(su_port_home(self),
+ (sizeof self->sup_indices[0]) *
+ (self->sup_size_indices = 64));
+ if (!self->sup_indices)
+ goto failed;
if (su_socket_port_init(self->sup_base, su_kqueue_port_vtable) < 0)
- return su_home_unref(su_port_home(self)), NULL;
+ goto failed;
- self->sup_kqueue = kq;
+ self->sup_multishot = SU_ENABLE_MULTISHOT_KQUEUE;
return self;
+
+ failed:
+ if (kq != -1)
+ close(kq);
+ su_home_unref(su_port_home(self));
+ return NULL;
}
int su_kqueue_clone_start(su_root_t *parent,
@@ -688,7 +616,7 @@
su_root_init_f init,
su_root_deinit_f deinit)
{
- return su_pthreaded_port_start(su_default_port_create,
+ return su_pthreaded_port_start(su_kqueue_port_create,
parent, return_clone, magic, init, deinit);
}
@@ -709,4 +637,3 @@
}
#endif /* HAVE_KQUEUE */
-
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/test_htable.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/test_htable.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/test_htable.c Thu Mar 22 10:41:43 2007
@@ -181,44 +181,46 @@
BEGIN();
- TEST0(c = context_create());
- TEST0(add(c, 0, 1)); TEST0(c->c_hash->ht_table[0]);
- TEST0(add(c, 1, 2)); TEST0(c->c_hash->ht_table[1]);
- TEST0(add(c, 2, 3)); TEST0(c->c_hash->ht_table[2]);
- TEST0(add(c, 0, 4)); TEST0(c->c_hash->ht_table[3]);
- TEST0(add(c, 2, 5)); TEST0(c->c_hash->ht_table[4]);
-
- TEST0(e = search(c, 1, 2, 0));
- zap(c, e);
- TEST0(c->c_hash->ht_table[0]);
- TEST0(c->c_hash->ht_table[1]);
- TEST0(c->c_hash->ht_table[2]);
- TEST0(c->c_hash->ht_table[3]);
- TEST0(c->c_hash->ht_table[4] == NULL);
+ TEST_1(c = context_create());
+ TEST_1(add(c, 0, 1)); TEST_1(c->c_hash->ht_table[0]);
+ TEST_1(add(c, 1, 2)); TEST_1(c->c_hash->ht_table[1]);
+ TEST_1(add(c, 2, 3)); TEST_1(c->c_hash->ht_table[2]);
+ TEST_1(add(c, 0, 4)); TEST_1(c->c_hash->ht_table[3]);
+ TEST_1(add(c, 2, 5)); TEST_1(c->c_hash->ht_table[4]);
+
+ TEST_1(e = search(c, 1, 2, 0));
+ TEST(htable_remove(c->c_hash, e), 0);
+ TEST(htable_remove(c->c_hash, e), -1);
+ su_free(c->c_home, e);
+ TEST_1(c->c_hash->ht_table[0]);
+ TEST_1(c->c_hash->ht_table[1]);
+ TEST_1(c->c_hash->ht_table[2]);
+ TEST_1(c->c_hash->ht_table[3]);
+ TEST_1(c->c_hash->ht_table[4] == NULL);
zap(c, c->c_hash->ht_table[0]);
- TEST0(c->c_hash->ht_table[0]);
- TEST0(c->c_hash->ht_table[1] == NULL);
- TEST0(c->c_hash->ht_table[2]);
- TEST0(c->c_hash->ht_table[3]);
- TEST0(c->c_hash->ht_table[4] == NULL);
+ TEST_1(c->c_hash->ht_table[0]);
+ TEST_1(c->c_hash->ht_table[1] == NULL);
+ TEST_1(c->c_hash->ht_table[2]);
+ TEST_1(c->c_hash->ht_table[3]);
+ TEST_1(c->c_hash->ht_table[4] == NULL);
- TEST0(add(c, 0, 6)); TEST0(c->c_hash->ht_table[1]);
- TEST0(add(c, 1, 7)); TEST0(c->c_hash->ht_table[4]);
+ TEST_1(add(c, 0, 6)); TEST_1(c->c_hash->ht_table[1]);
+ TEST_1(add(c, 1, 7)); TEST_1(c->c_hash->ht_table[4]);
/* Test that zapping entry 0 does not move 2 and 3 */
zap(c, c->c_hash->ht_table[0]);
- TEST0(c->c_hash->ht_table[4] == NULL);
+ TEST_1(c->c_hash->ht_table[4] == NULL);
{
/* Insert entries at the end of hash, then resize and check
for correct ordering */
hash_value_t size = c->c_hash->ht_size, h = size - 1;
- TEST0(add(c, h, 0)); TEST0(add(c, h, 1)); TEST0(add(c, h, 2));
- TEST0(add(c, h, 3)); TEST0(add(c, h, 4)); TEST0(add(c, h, 5));
- TEST0(add(c, h, 6)); TEST0(add(c, h, 7)); TEST0(add(c, h, 8));
+ TEST_1(add(c, h, 0)); TEST_1(add(c, h, 1)); TEST_1(add(c, h, 2));
+ TEST_1(add(c, h, 3)); TEST_1(add(c, h, 4)); TEST_1(add(c, h, 5));
+ TEST_1(add(c, h, 6)); TEST_1(add(c, h, 7)); TEST_1(add(c, h, 8));
TEST(count(c, h), 9);
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/test_memmem.c
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/test_memmem.c (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/libsofia-sip-ua/su/test_memmem.c Thu Mar 22 10:41:43 2007
@@ -78,14 +78,25 @@
TEST_P(memmem(haystack, 12, needle, 3), haystack + 2);
TEST_P(memmem(needle, 3, haystack, 12), NULL);
- TEST_P(memmem(haystack, 12, "", 0), haystack);
- TEST_P(memmem(haystack, 12, null, 0), haystack);
- TEST_P(memmem(haystack, 0, "", 0), haystack);
- TEST_P(memmem(haystack, 0, null, 0), haystack);
+
+#if HAVE_MEMMEM
+ if (memmem(haystack, 12, "", 0) == NULL) {
+ fprintf(stderr, "test_memmem.c: "
+ "*** WARNING: system memmem() fails with empty needle ***\n");
+ }
+ else
+#endif
+ {
+ TEST_P(memmem(haystack, 12, "", 0), haystack);
+ TEST_P(memmem(haystack, 12, null, 0), haystack);
+ TEST_P(memmem(haystack, 0, "", 0), haystack);
+ TEST_P(memmem(haystack, 0, null, 0), haystack);
+ }
TEST_P(memmem(haystack + 2, 3, needle, 3), haystack + 2);
TEST_P(memmem(haystack + 2, 2, needle, 3), NULL);
TEST_P(memmem(a = "a\0bc", 4, "a\0bc", 4), a);
+ TEST_P(memmem(a, 4, "\0bc", 3), a + 1);
END();
}
Modified: freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/m4/sac-tport.m4
==============================================================================
--- freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/m4/sac-tport.m4 (original)
+++ freeswitch/branches/mikej/sofiasip-upgrade/libs/sofia-sip/m4/sac-tport.m4 Thu Mar 22 10:41:43 2007
@@ -27,7 +27,9 @@
AC_SYS_IP_RECVERR
AC_SYS_IPV6_RECVERR
-AC_CHECK_HEADERS(netinet/tcp.h netinet/sctp.h)
+AC_CHECK_HEADERS([netinet/tcp.h netinet/sctp.h],[],[],[
+#include <sys/socket.h>
+])
AC_ARG_ENABLE(sctp,
[ --enable-sctp use SCTP [[disabled]]],,
1
0