From 6014178b5b751c0d35a18f293fe1dec37fcf000d Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Thu, 16 Dec 2010 16:32:04 -0500 Subject: [PATCH 1/4] Removed unwanted lines in previous commit --- libs/freetdm/src/ftdm_io.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 8755d73875..1fdb867138 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -5117,9 +5117,16 @@ FT_DECLARE(ftdm_status_t) ftdm_configure_span_signaling(ftdm_span_t *span, const FT_DECLARE(ftdm_status_t) ftdm_span_start(ftdm_span_t *span) { if (span->start) { + /* check the alarms again before starting the signaling module + this works-around some I/O modules (netborder I/O module) that cannot + check the alarm status before during configuration because the spans are + not really started yet at the I/O level */ + if (ftdm_set_channels_alarms(span, 0) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_ERROR, "%d: Failed to set channel alarms\n", span->span_id); + return FTDM_FAIL; + } return span->start(span); } - return FTDM_FAIL; } From a134136ee715f6b392ec8bf3c5b3e31af7953c18 Mon Sep 17 00:00:00 2001 From: Arnaldo Pereira Date: Thu, 16 Dec 2010 19:44:32 -0200 Subject: [PATCH 2/4] freetdm: ftmod_r2 - notify the core when we change the signaling status of a channel or span through the api --- libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c index 9f35971abb..14eca429e8 100644 --- a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c +++ b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c @@ -468,6 +468,7 @@ static FIO_CHANNEL_SET_SIG_STATUS_FUNCTION(ftdm_r2_set_channel_sig_status) ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Cannot set signaling status to unknown value '%d'\n", status); return FTDM_FAIL; } + ftdm_r2_set_chan_sig_status(ftdmchan, status); return FTDM_SUCCESS; } @@ -528,6 +529,7 @@ static FIO_SPAN_SET_SIG_STATUS_FUNCTION(ftdm_r2_set_span_sig_status) openr2_chan_set_idle(r2chan); ftdm_log_chan_msg(fchan, FTDM_LOG_NOTICE, "Channel idle\n"); } + ftdm_r2_set_chan_sig_status(fchan, status); } ftdm_iterator_free(chaniter); return FTDM_SUCCESS; From 0f937ca13415ee60fb636cdbb6e6e5121d4fcb63 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Thu, 16 Dec 2010 18:29:45 -0500 Subject: [PATCH 3/4] freetdm: Add documentation on sig status --- libs/freetdm/docs/sigstatus.txt | 59 ++++++++++++++++++++++++++++++ libs/freetdm/src/include/freetdm.h | 1 + 2 files changed, 60 insertions(+) create mode 100644 libs/freetdm/docs/sigstatus.txt diff --git a/libs/freetdm/docs/sigstatus.txt b/libs/freetdm/docs/sigstatus.txt new file mode 100644 index 0000000000..10561bfb5b --- /dev/null +++ b/libs/freetdm/docs/sigstatus.txt @@ -0,0 +1,59 @@ +FreeTDM can both notify and set signaling status changes in the different protocols thru a unified interface. More +specific details on the C data types and function prototypes are found in freetdm.h + +The API provides the following functions and data types to do it: + +The signaling status in any channel/span is represented thru ftdm_signaling_status_t + + /* The signaling link is down (no d-chans up in the span/group, MFC-R2 bit pattern unidentified) */ + FTDM_SIG_STATE_DOWN, + /* The signaling link is suspended (MFC-R2 bit pattern blocked, PRI maintenance, ss7 blocked?) */ + FTDM_SIG_STATE_SUSPENDED, + /* The signaling link is ready and calls can be placed (ie: d-chan up, MFC-R2 both rx and tx in IDLE) */ + FTDM_SIG_STATE_UP, + /* Invalid status */ + FTDM_SIG_STATE_INVALID + +Changes in the signaling status are notified to the user using the standard callback notification function provided +during configuration using the sigevent type FTDM_SIGEVENT_SIGSTATUS_CHANGED which is sent when the line status changes. + +On startup the signalling status default is FTDM_SIG_STATE_DOWN, and no notification is provided until the state change, +so applications must assume the status is down unless told otherwise. + +When ftdm_span_start is called, the signaling stack takes care of attempting to bring the status to UP +but it will ultimately depend on the other side too. + +== Setting the signaling status == + +Users can set the signaling status on a given channel/span thru FreeTDM the following API functions: + +ftdm_channel_set_sig_status +ftdm_span_set_sig_status + +If the user calls ftdm_channel_set_sig_status(chan, FTDM_SIG_STATE_SUSPENDED), the signaling stack will try to set +the status of the line to the one requested, if successful, it will result in a SIGEVENT_SIGSTATUS_CHANGED notification +being sent with status FTDM_SIG_STATE_SUSPENDED. + +** MFC-R2 Signaling Notes ** +For MFC-R2, calling ftdm_span_start() results in setting the tx CAS bits to IDLE. However, if the rx bits are in BLOCKED state +the signaling status will be reported as SUSPENDED. + +If the user calls ftdm_channel_set_sig_status(chan, SUSPENDED), the tx CAS bits will be set to BLOCKED and, if, the current rx bits +are IDLE then a SIGEVENT_SIGSTATUS_CHANGED with state SUSPENDED will be sent. If the rx bits are already in blocked then no further +SIGEVENT_SIGSTATUS_CHANGED notification is needed (because it was already sent when the rx bits were initially detected as BLOCKED). + +If the user calls ftdm_channel_set_sig_status(chan, UP), the tx CAS bits will be set to IDLE and, if, the current rx bits +are IDLE, then SIGEVENT_SIGSTATUS_CHANGED with state UP will be sent. If the rx bits are BLOCKED, then no notification is +sent at all until the rx bits change. + +Bottom line is, for MFC-R2, SIGEVENT_SIGSTATUS_CHANGED UP is only sent to the user when both the rx and tx bits are in IDLE, and +SIGEVENT_SIGSTATUS_CHANGED SUSPENDED is only sent to the user when any of the rx or tx bits are in BLOCKED. + +== Getting the signaling status == +Users can get the signaling status on a given channel/span thru FreeTDM the following API functions: + +ftdm_channel_get_sig_status +ftdm_span_get_sig_status + +The line status returned should be the same as the last time a SIGEVENT_SIGSTATUS_CHANGED was reported. + diff --git a/libs/freetdm/src/include/freetdm.h b/libs/freetdm/src/include/freetdm.h index 41bf819a1c..56a9dc0577 100644 --- a/libs/freetdm/src/include/freetdm.h +++ b/libs/freetdm/src/include/freetdm.h @@ -367,6 +367,7 @@ typedef struct ftdm_channel_config { /*! \brief Signaling status on a given span or specific channel on protocols that support it + \note see docs/sigstatus.txt for more extensive documentation on signaling status */ typedef enum { /* The signaling link is down (no d-chans up in the span/group, MFC-R2 bit pattern unidentified) */ From 27ea959b4b3418cea08594ff2e31e9ae6ad10e09 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Fri, 17 Dec 2010 12:57:12 -0500 Subject: [PATCH 4/4] freetdm: add __USE_BSD to ftdm_os, needed by unistd.h for usleep() and string.h to define strcasecmp() add -Werror even when the compiler is unknown. This is just a work-around to gcc not being detected ad GNU by our current standalone build (not bootstrapped through FreeSWITCH) --- libs/freetdm/Makefile.am | 5 +++-- libs/freetdm/configure.ac | 2 +- libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c | 1 - libs/freetdm/src/include/ftdm_os.h | 5 ++++- libs/freetdm/src/testsangomaboost.c | 6 ------ 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/libs/freetdm/Makefile.am b/libs/freetdm/Makefile.am index af26f7f2af..5e804b7505 100644 --- a/libs/freetdm/Makefile.am +++ b/libs/freetdm/Makefile.am @@ -49,6 +49,7 @@ if HAVE_SNG_ISDN INCS += -I/usr/include/sng_isdn endif +# we needed to separate CFLAGS in FTDM_COMPAT_CFLAGS and FTDM_CFLAGS due to -c99 which causes problems with wanpipe headers FTDM_COMPAT_CFLAGS = $(INCS) -DFTDM_CONFIG_DIR=\"@confdir@\" -DFTDM_MOD_DIR=\"$(moddir)\" @COMP_VENDOR_COMPAT_CFLAGS@ @DEFS@ FTDM_CFLAGS = $(INCS) -DFTDM_CONFIG_DIR=\"@confdir@\" -DFTDM_MOD_DIR=\"$(moddir)\" @COMP_VENDOR_CFLAGS@ @DEFS@ COMPILE = $(CC) $(FTDM_CFLAGS) @@ -183,8 +184,8 @@ ftmod_analog_em_la_LIBADD = libfreetdm.la if HAVE_LIBSANGOMA mod_LTLIBRARIES += ftmod_wanpipe.la ftmod_wanpipe_la_SOURCES = $(SRC)/ftmod/ftmod_wanpipe/ftmod_wanpipe.c -#some structures within Wanpipe drivers are not c99 compatible, so we need to compile ftmod_wanpipe -#without c99 flags +# some structures within Wanpipe drivers are not c99 compatible, so we need to compile ftmod_wanpipe +# without c99 flags, use FTDM_COMPAT_CFLAGS instead ftmod_wanpipe_la_CFLAGS = $(AM_CFLAGS) $(FTDM_COMPAT_CFLAGS) -D__LINUX__ -I/usr/include/wanpipe ftmod_wanpipe_la_LDFLAGS = -shared -module -avoid-version -lsangoma ftmod_wanpipe_la_LIBADD = libfreetdm.la diff --git a/libs/freetdm/configure.ac b/libs/freetdm/configure.ac index 592dfd82a3..e26f10b0b2 100644 --- a/libs/freetdm/configure.ac +++ b/libs/freetdm/configure.ac @@ -82,7 +82,7 @@ sun) fi ;; *) - COMP_VENDOR_COMPAT_CFLAGS="-Wall -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes" + COMP_VENDOR_COMPAT_CFLAGS="-Wall -Werror -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes" COMP_VENDOR_CFLAGS="-std=c99 $COMP_VENDOR_COMPAT_CFLAGS" ;; esac diff --git a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c b/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c index 7320934a49..211bf713b7 100644 --- a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c +++ b/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c @@ -31,7 +31,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #include "private/ftdm_core.h" #include "ftmod_zt.h" diff --git a/libs/freetdm/src/include/ftdm_os.h b/libs/freetdm/src/include/ftdm_os.h index 5026bb7236..f3ebee9ea2 100644 --- a/libs/freetdm/src/include/ftdm_os.h +++ b/libs/freetdm/src/include/ftdm_os.h @@ -39,9 +39,12 @@ extern "C" { #endif +#if defined(__linux__) && !defined(__USE_BSD) +#define __USE_BSD +#endif + #include "ftdm_declare.h" #include "ftdm_threadmutex.h" - #include #ifndef __WINDOWS__ diff --git a/libs/freetdm/src/testsangomaboost.c b/libs/freetdm/src/testsangomaboost.c index 529dbbe5e2..b007fc186b 100644 --- a/libs/freetdm/src/testsangomaboost.c +++ b/libs/freetdm/src/testsangomaboost.c @@ -49,12 +49,6 @@ #include #include -#if defined(__linux__) && !defined(__USE_BSD) -#define __USE_BSD -#endif -#ifndef WIN32 -#include -#endif #include "freetdm.h"