diff --git a/ChangeLog.beta b/ChangeLog.beta index 533e407..efb2b9d 100644 --- a/ChangeLog.beta +++ b/ChangeLog.beta @@ -8,6 +8,12 @@ Copyright (c) 1995-2009 Sangoma Technologies Inc. For more info visit: http://wiki.sangoma.com ------------------------------------------------------------------------------ +* Fri May 08 2009 Nenad Corbic - Beta - 3.5.2 +=================================================================== + +- B700 PCIe cards were being desplayed as PCI cards in hwprobe +- Bug fix in wancfg_zaptel + * Thu May 07 2009 Nenad Corbic - Beta - 3.5.1 =================================================================== diff --git a/Setup b/Setup index ca482ea..f8e0039 100755 --- a/Setup +++ b/Setup @@ -7178,7 +7178,7 @@ KERNEL_UNAME=`uname -r` PKG_NAME=wanpipe DISTR_NAME="WANPIPE" PROD=wanrouter -PROD_VER=3.5.1 +PROD_VER=3.5.2 PROD_HOME=`pwd` META_CONF=$PROD_HOME/$PROD.rc WAN_INTR_DIR=$PROD_HOME/interfaces diff --git a/api/libsangoma/.svn/all-wcprops b/api/libsangoma/.svn/all-wcprops index fbf36d9..57f1b90 100644 --- a/api/libsangoma/.svn/all-wcprops +++ b/api/libsangoma/.svn/all-wcprops @@ -75,18 +75,6 @@ svn:wc:ra_dav:version-url V 60 /svn/libsangoma/!svn/ver/135/trunk/libsangoma-doxygen.config END -config.sub -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/libsangoma/!svn/ver/1/trunk/config.sub -END -libsangoma.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/libsangoma/!svn/ver/148/trunk/libsangoma.c -END compile.bat K 25 svn:wc:ra_dav:version-url @@ -99,6 +87,18 @@ svn:wc:ra_dav:version-url V 42 /svn/libsangoma/!svn/ver/1/trunk/ltmain.sh END +config.sub +K 25 +svn:wc:ra_dav:version-url +V 43 +/svn/libsangoma/!svn/ver/1/trunk/config.sub +END +libsangoma.c +K 25 +svn:wc:ra_dav:version-url +V 47 +/svn/libsangoma/!svn/ver/157/trunk/libsangoma.c +END cleanup.sh K 25 svn:wc:ra_dav:version-url @@ -186,8 +186,8 @@ END configure.in K 25 svn:wc:ra_dav:version-url -V 45 -/svn/libsangoma/!svn/ver/1/trunk/configure.in +V 47 +/svn/libsangoma/!svn/ver/157/trunk/configure.in END ChangeLog K 25 diff --git a/api/libsangoma/.svn/entries b/api/libsangoma/.svn/entries index 382944c..9e85d8b 100644 --- a/api/libsangoma/.svn/entries +++ b/api/libsangoma/.svn/entries @@ -45,7 +45,7 @@ file -2009-03-31T16:11:47.000000Z +2009-05-08T16:30:09.000000Z f84c30e2597ef02a8b7ae6e7abc79cba 2009-02-13T23:05:55.921736Z 91 @@ -58,7 +58,7 @@ file -2009-03-31T16:11:47.000000Z +2009-05-05T14:59:21.000000Z b64570263ebee3d9e6ba2d2337fd986f 2009-02-13T23:05:55.921736Z 91 @@ -195,14 +195,14 @@ davidr libsangoma.c file +157 - -2009-05-01T15:10:42.000000Z -44ce83abbd73b123a56d25e5ff50278a -2009-04-29T19:20:14.452199Z -148 +2009-05-08T16:29:30.000000Z +4cd810f2bcbadf8088a1ef20c41dabe1 +2009-05-08T18:19:43.882390Z +157 ncorbic ltmain.sh @@ -405,15 +405,15 @@ ncorbic configure.in file +157 - -2009-02-04T23:12:17.000000Z -5b9888fc365c4ebffdbb55656c091a2f -2008-02-28T18:51:53.196120Z -1 -root +2009-05-01T20:59:30.000000Z +d1b810723de5af3fa5ef31ebabfca2a7 +2009-05-08T18:19:43.882390Z +157 +ncorbic ChangeLog file diff --git a/api/libsangoma/.svn/text-base/configure.in.svn-base b/api/libsangoma/.svn/text-base/configure.in.svn-base index fff63ce..d28d8cc 100644 --- a/api/libsangoma/.svn/text-base/configure.in.svn-base +++ b/api/libsangoma/.svn/text-base/configure.in.svn-base @@ -2,12 +2,13 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT(libsangoma, 1.0.0, anthmct@yahoo.com) -AM_INIT_AUTOMAKE(libsangoma,1.0.0) +AC_INIT([libsangoma],[2.0.1],[ncorbic@sangoma.com]) +AM_INIT_AUTOMAKE(libsangoma,2.0.1) # Checks for programs. AC_PROG_CC AC_PROG_LIBTOOL AC_PROG_RANLIB +AC_CHECK_PROG(AR, ar, ar, no) # Checks for libraries. AC_CHECK_HEADERS(fcntl.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h unistd.h math.h) @@ -26,3 +27,4 @@ AC_FUNC_SELECT_ARGTYPES AC_CHECK_FUNCS([gettimeofday memset select socket]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT + diff --git a/api/libsangoma/.svn/text-base/libsangoma.c.svn-base b/api/libsangoma/.svn/text-base/libsangoma.c.svn-base index fbb65fa..30e807d 100644 --- a/api/libsangoma/.svn/text-base/libsangoma.c.svn-base +++ b/api/libsangoma/.svn/text-base/libsangoma.c.svn-base @@ -1058,7 +1058,7 @@ int _SAPI_CALL sangoma_get_full_cfg(sng_fd_t fd, wanpipe_api_t *tdm_api) return err; } -#if 1 +#if 0 printf("TDM API CFG:\n"); printf("\thw_tdm_coding:\t%d\n",tdm_api->wp_cmd.hw_tdm_coding); printf("\thw_mtu_mru:\t%d\n",tdm_api->wp_cmd.hw_mtu_mru); diff --git a/api/libsangoma/configure b/api/libsangoma/configure index 5cb6fb6..a773968 100755 --- a/api/libsangoma/configure +++ b/api/libsangoma/configure @@ -1,8 +1,8 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for libsangoma 2.0.1. +# Generated by GNU Autoconf 2.59 for libsangoma 1.0.0. # -# Report bugs to . +# Report bugs to . # # Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation @@ -423,9 +423,9 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='libsangoma' PACKAGE_TARNAME='libsangoma' -PACKAGE_VERSION='2.0.1' -PACKAGE_STRING='libsangoma 2.0.1' -PACKAGE_BUGREPORT='ncorbic@sangoma.com' +PACKAGE_VERSION='1.0.0' +PACKAGE_STRING='libsangoma 1.0.0' +PACKAGE_BUGREPORT='anthmct@yahoo.com' # Factoring default headers for most tests. ac_includes_default="\ @@ -953,7 +953,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libsangoma 2.0.1 to adapt to many kinds of systems. +\`configure' configures libsangoma 1.0.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1019,7 +1019,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libsangoma 2.0.1:";; + short | recursive ) echo "Configuration of libsangoma 1.0.0:";; esac cat <<\_ACEOF @@ -1063,7 +1063,7 @@ Some influential environment variables: Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. -Report bugs to . +Report bugs to . _ACEOF fi @@ -1159,7 +1159,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -libsangoma configure 2.0.1 +libsangoma configure 1.0.0 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -1173,7 +1173,7 @@ cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libsangoma $as_me 2.0.1, which was +It was created by libsangoma $as_me 1.0.0, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -1816,7 +1816,7 @@ fi # Define the identity of the package. PACKAGE=libsangoma - VERSION=2.0.1 + VERSION=1.0.0 cat >>confdefs.h <<_ACEOF @@ -4450,9 +4450,9 @@ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >& echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## ---------------------------------- ## -## Report this to ncorbic@sangoma.com ## -## ---------------------------------- ## +## -------------------------------- ## +## Report this to anthmct@yahoo.com ## +## -------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -18691,42 +18691,6 @@ else RANLIB="$ac_cv_prog_RANLIB" fi -# Extract the first word of "ar", so it can be a program name with args. -set dummy ar; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_AR+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$AR"; then - ac_cv_prog_AR="$AR" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AR="ar" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - - test -z "$ac_cv_prog_AR" && ac_cv_prog_AR="no" -fi -fi -AR=$ac_cv_prog_AR -if test -n "$AR"; then - echo "$as_me:$LINENO: result: $AR" >&5 -echo "${ECHO_T}$AR" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - # Checks for libraries. @@ -18859,9 +18823,9 @@ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >& echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## ---------------------------------- ## -## Report this to ncorbic@sangoma.com ## -## ---------------------------------- ## +## -------------------------------- ## +## Report this to anthmct@yahoo.com ## +## -------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -19098,9 +19062,9 @@ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >& echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## ---------------------------------- ## -## Report this to ncorbic@sangoma.com ## -## ---------------------------------- ## +## -------------------------------- ## +## Report this to anthmct@yahoo.com ## +## -------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -19745,7 +19709,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by libsangoma $as_me 2.0.1, which was +This file was extended by libsangoma $as_me 1.0.0, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -19803,7 +19767,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -libsangoma config.status 2.0.1 +libsangoma config.status 1.0.0 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" @@ -20540,4 +20504,3 @@ if test "$no_create" != yes; then $ac_cs_success || { (exit 1); exit 1; } fi - diff --git a/api/libsangoma/libsangoma.c b/api/libsangoma/libsangoma.c index fbb65fa..30e807d 100644 --- a/api/libsangoma/libsangoma.c +++ b/api/libsangoma/libsangoma.c @@ -1058,7 +1058,7 @@ int _SAPI_CALL sangoma_get_full_cfg(sng_fd_t fd, wanpipe_api_t *tdm_api) return err; } -#if 1 +#if 0 printf("TDM API CFG:\n"); printf("\thw_tdm_coding:\t%d\n",tdm_api->wp_cmd.hw_tdm_coding); printf("\thw_mtu_mru:\t%d\n",tdm_api->wp_cmd.hw_mtu_mru); diff --git a/api/libsangoma/sample_c/regression/latency/.svn/all-wcprops b/api/libsangoma/sample_c/regression/latency/.svn/all-wcprops index 09c83fc..e0534bd 100644 --- a/api/libsangoma/sample_c/regression/latency/.svn/all-wcprops +++ b/api/libsangoma/sample_c/regression/latency/.svn/all-wcprops @@ -3,3 +3,15 @@ svn:wc:ra_dav:version-url V 62 /svn/libsangoma/!svn/ver/155/trunk/sample_c/regression/latency END +sample.c +K 25 +svn:wc:ra_dav:version-url +V 71 +/svn/libsangoma/!svn/ver/157/trunk/sample_c/regression/latency/sample.c +END +Makefile.Linux +K 25 +svn:wc:ra_dav:version-url +V 77 +/svn/libsangoma/!svn/ver/157/trunk/sample_c/regression/latency/Makefile.Linux +END diff --git a/api/libsangoma/sample_c/regression/latency/.svn/entries b/api/libsangoma/sample_c/regression/latency/.svn/entries index 12e8be8..e39f6ee 100644 --- a/api/libsangoma/sample_c/regression/latency/.svn/entries +++ b/api/libsangoma/sample_c/regression/latency/.svn/entries @@ -28,26 +28,15 @@ ncorbic sample.c file -155 - - -add - -9c3d43435534fe23358b483fd9b63b3f +157 - - - - - - - - -copied -https://www.sangomapbx.com/svn/libsangoma/trunk/sample_c/regression/latency/sample_dtmf.c -155 +2009-05-05T20:53:34.000000Z +2a12b767a760ddfb4355e9e744deedec +2009-05-08T18:19:43.882390Z +157 +ncorbic short-dtmf.wav file @@ -76,25 +65,37 @@ ncorbic Makefile.Linux file +157 - -2009-05-04T12:34:59.000000Z -5f0316a21bfb3b31d2603de44b150173 -2009-05-04T14:23:31.206565Z -155 +2009-05-04T12:39:55.000000Z +5d1313f1e45ef0989f70fc11f808605b +2009-05-08T18:19:43.882390Z +157 ncorbic sample_dtmf.c file +157 -delete -2009-05-04T12:34:59.000000Z -9c3d43435534fe23358b483fd9b63b3f -2009-05-04T14:23:31.206565Z -155 -ncorbic + + + + + + + + + + + + + + + + +deleted diff --git a/api/libsangoma/sample_c/regression/latency/.svn/text-base/Makefile.Linux.svn-base b/api/libsangoma/sample_c/regression/latency/.svn/text-base/Makefile.Linux.svn-base index a9837cd..b03efa9 100644 --- a/api/libsangoma/sample_c/regression/latency/.svn/text-base/Makefile.Linux.svn-base +++ b/api/libsangoma/sample_c/regression/latency/.svn/text-base/Makefile.Linux.svn-base @@ -5,19 +5,19 @@ INCLUDES=-I../ -I/usr/include -I/usr/src/libpri -I$(WANINC) -I. -I/usr/local/in CFLAGS=-D__LINUX__ -D_REENTRANT -D_GNU_SOURCE -O2 -DWANPIPE_TDM_API CCFLAGS=-Wall -Wstrict-prototypes -Wmissing-prototypes -g -all: sample_dtmf +all: sample -everything: sample_dtmf +everything: sample lib_api.o: lib_api.c $(CC) $(CCFLAGS) $(INCLUDES) $(CFLAGS) -c -o lib_api.o lib_api.c -sample_dtmf.o: sample_dtmf.c - $(CC) $(CCFLAGS) $(INCLUDES) $(CFLAGS) -c -o sample_dtmf.o sample_dtmf.c +sample.o: sample.c + $(CC) $(CCFLAGS) $(INCLUDES) $(CFLAGS) -c -o sample.o sample.c -sample_dtmf: sample_dtmf.o lib_api.o - $(CC) $(CCFLAGS) $(INCLUDES) $(CFLAGS) -o sample_dtmf sample_dtmf.o lib_api.o -L. -lsangoma -lm -lpthread +sample: sample.o lib_api.o + $(CC) $(CCFLAGS) $(INCLUDES) $(CFLAGS) -o sample sample.o lib_api.o -L. -lsangoma -lm -lpthread clean: diff --git a/api/libsangoma/sample_c/regression/latency/.svn/text-base/sample.c.svn-base b/api/libsangoma/sample_c/regression/latency/.svn/text-base/sample.c.svn-base index 20bf461..0c6606b 100644 --- a/api/libsangoma/sample_c/regression/latency/.svn/text-base/sample.c.svn-base +++ b/api/libsangoma/sample_c/regression/latency/.svn/text-base/sample.c.svn-base @@ -89,6 +89,10 @@ typedef struct { int elapsed_max; int elapsed_min; + unsigned char rx_sync; + unsigned char tx_sync; + struct timeval tv_sync_start; + wanpipe_chan_stats_t stats; }sangoma_channel_t; @@ -244,12 +248,30 @@ int read_data(sangoma_channel_t *schan) sangoma_tdm_write_rbs(dev_fd, &tdm_api, schan->chan, schan->rx_rbs_bits); } + if (schan->tx_sync && !schan->rx_sync) { + int i; + for (i=0;idata[i]==tx_data) { + struct timeval last; + int elapsed; + gettimeofday(&last, NULL); + elapsed = abs((((last.tv_sec * 1000) + last.tv_usec / 1000) - ((schan->tv_sync_start.tv_sec * 1000) + schan->tv_sync_start.tv_usec / 1000))); + + + printf("wanpipe%d: Rx Sync Time %i ms Data=0x%X\n", + schan->span, elapsed, tx_data); + schan->rx_sync=1; + break; + } + } + } + /* if user needs Rx data to be written into a file: */ if(files_used & RX_FILE_USED){ write_data_to_file(schan, rx_el->data, Rx_lgth); } - return 0; + return Rx_lgth; } /*! @@ -329,12 +351,22 @@ int handle_data(sangoma_channel_t *schan) #endif if(api_poll_status & POLLIN){ - - if(read_data(schan) == 0){ - + int err; + + err = read_data(schan); + if(err > 0) { if(rx2tx){ /* Send back received data (create a "software loopback"), just a test. */ - int err=write_data(schan, &rx_el->hdr, rx_el->data); + if (tx_data) { + memset(rx_el->data, tx_data, err); + } + if (!schan->tx_sync) { + schan->tx_sync=1; + sangoma_flush_bufs(schan->sangoma_wait_object.fd,&tdm_api); + sangoma_flush_stats(schan->sangoma_wait_object.fd,&tdm_api); + gettimeofday(&schan->tv_sync_start, NULL); + } + err=write_data(schan, &rx_el->hdr, rx_el->data); if (err) { return err; } @@ -342,6 +374,7 @@ int handle_data(sangoma_channel_t *schan) } } +#if 0 if((api_poll_status & POLLOUT) && write_enable){ int err; @@ -363,12 +396,20 @@ int handle_data(sangoma_channel_t *schan) } } + if (!schan->tx_sync) { + schan->tx_sync=1; + sangoma_flush_bufs(schan->sangoma_wait_object.fd,&tdm_api); + sangoma_flush_stats(schan->sangoma_wait_object.fd,&tdm_api); + gettimeofday(&schan->tv_sync_start, NULL); + } + err=write_data(schan, api_tx_hdr, tx_el->data); if (err != 0) { return err; } }/* if() */ +#endif return 0; } @@ -691,8 +732,12 @@ static void *handle_span_chan(void *obj) if (flush_period && schan->loop_cnt % flush_period == 0) { printf("%s: Flushing Buffers\n",schan->name); - sangoma_flush_bufs(schan->sangoma_wait_object.fd,&tdm_api); - sangoma_get_print_stats(schan); + //sangoma_flush_bufs(schan->sangoma_wait_object.fd,&tdm_api); + tdm_api.wp_cmd.cmd = WP_API_CMD_GEN_FIFO_ERR; + sangoma_cmd_exec(schan->sangoma_wait_object.fd,&tdm_api); + schan->tx_sync=0; + schan->rx_sync=0; + //sangoma_get_print_stats(schan); } }/* for() */ diff --git a/api/libsangoma/sample_c/regression/latency/.svn/text-base/sample_dtmf.c.svn-base b/api/libsangoma/sample_c/regression/latency/.svn/text-base/sample_dtmf.c.svn-base deleted file mode 100644 index 20bf461..0000000 --- a/api/libsangoma/sample_c/regression/latency/.svn/text-base/sample_dtmf.c.svn-base +++ /dev/null @@ -1,1137 +0,0 @@ -/******************************************************************************//** - * \file sample.c - * \brief WANPIPE(tm) API C Sample Code - * - * Authors: David Rokhvarg - * Nenad Corbic - * - * Copyright (c) 2007 - 08, Sangoma Technologies - * All rights reserved. - * - * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the Sangoma Technologies nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Sangoma Technologies ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL Sangoma Technologies BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * =============================================================================== - * - */ - -#include "libsangoma.h" -#include "lib_api.h" - - -#define MAX_STACK_SIZE 1024 * 240 -#define MAX_SPANS 32 -#define MAX_CHANS 32 - -#define _printf(a,...) - -static int max_spans = MAX_SPANS; -static int max_chans = MAX_CHANS; -static int server_running=0; -static int threads_running=0; -pthread_mutex_t threads_running_lock; - -typedef struct { - - int init; - int span; - int chan; - - int poll_events_bitmap; - sangoma_wait_obj_t sangoma_wait_object; - pthread_t threadid; - - wp_api_element_t Rx_data; - wp_api_element_t Tx_data; - wanpipe_api_t tdm_api; - wan_udp_hdr_t wan_udp; - unsigned char rx_rbs_bits; - FILE *pRxFile; - FILE *pTxFile; - - char name[100]; - - unsigned int errors; - unsigned int rx_errors; - unsigned int rx_bytes; - unsigned int rx_packets; - - unsigned int tx_bytes; - unsigned int tx_errors; - unsigned int tx_packets; - unsigned int rx_events; - unsigned int rx_events_tone; - - unsigned int loop_cnt; - unsigned int tx_file_cnt; - - unsigned char prev_dtmf[MAX_CHANS]; - unsigned int test_failed; - - struct timeval tv_start; - int elapsed_max; - int elapsed_min; - - wanpipe_chan_stats_t stats; -}sangoma_channel_t; - -sangoma_channel_t sangoma_channel_idx[MAX_SPANS+1][MAX_CHANS+1]; - -/***************************************************************** - * Prototypes - *****************************************************************/ - -int __cdecl main(int argc, char* argv[]); -int open_sangoma_device(sangoma_channel_t *schan); -static void *handle_span_chan(void *obj); -int handle_tdm_event(sangoma_channel_t *schan); -int handle_data(sangoma_channel_t *schan); -int read_data(sangoma_channel_t *schan); -int write_data(sangoma_channel_t *schan, wp_api_hdr_t *tx_hdr, void *tx_data); -int dtmf_event(sng_fd_t fd,unsigned char digit,unsigned char type,unsigned char port); -int rbs_event(sng_fd_t fd,unsigned char rbs_bits); -int rxhook_event(sng_fd_t fd,unsigned char hook_state); -int rxring_event(sng_fd_t fd,unsigned char ring_state); -int ringtrip_event (sng_fd_t fd, unsigned char ring_state); -void print_rx_data(unsigned char *data, int datalen); -int write_data_to_file(sangoma_channel_t *schan, unsigned char *data, unsigned int data_length); -void close_sangoma_devices(sangoma_channel_t *schan); -static void sangoma_get_print_stats(sangoma_channel_t *schan); - -#ifdef WIN32 -BOOL TerminateHandler(DWORD dwCtrlType); -#else -void TerminateHandler(int); -#endif - -/***************************************************************** - * General Functions - *****************************************************************/ - -/*! - \fn void print_rx_data(unsigned char *data, int datalen) - \brief Prints the contents of data packet - \param data pointer to data buffer - \param datalen size of data buffer - \return void -*/ -void print_rx_data(unsigned char *data, int datalen) -{ - int i; - - printf("Data: (Len=%i)\n",datalen); - for(i = 0; i < datalen; i++) { - if((i % 20 == 0)){ - if(i){ - printf("\n"); - } - } - printf("%02X ", data[i]); -#if 0 - /* don't print too much!! */ - if(i > 100){ - printf("...\n"); - break; - } -#endif - } - printf("\n"); -} - -#if 1 -#ifdef __LINUX__ -static int sample_time_test(sangoma_channel_t *schan){ - - struct timeval last; - int elapsed; - int err; - - last=schan->tv_start; - gettimeofday(&schan->tv_start, NULL); - elapsed = abs((((last.tv_sec * 1000) + last.tv_usec / 1000) - ((schan->tv_start.tv_sec * 1000) + schan->tv_start.tv_usec / 1000))); - err = abs(20-elapsed); - if (err > 1 && err < 1000) { - if (elapsed > schan->elapsed_max) { - schan->elapsed_max = elapsed; - } - if (schan->elapsed_min > elapsed) { - schan->elapsed_min = elapsed; - } - printf("wanpipe%d: Elapsed %i diff=%i max=%i min=%i\n", - schan->span, elapsed,abs(20-elapsed),schan->elapsed_max,schan->elapsed_min); - } - - return 0; -} -#endif -#endif - -/*! - \fn int read_data(sangoma_channel_t *schan) - \brief Read data buffer from a device - \param dev_index device index number associated with device file descriptor - \return 0 - Ok otherwise Error - -*/ -int read_data(sangoma_channel_t *schan) -{ - wp_api_element_t *rx_el = (wp_api_element_t*)&schan->Rx_data; - wp_api_hdr_t *rx_hdr = &rx_el->hdr; - sng_fd_t dev_fd = schan->sangoma_wait_object.fd; - int Rx_lgth = 0; - static int Rx_count= 0; - wanpipe_api_t tdm_api; - - memset(&tdm_api,0,sizeof(tdm_api)); - memset(rx_hdr, 0, sizeof(wp_api_hdr_t)); - - - /* read the message */ - Rx_lgth = sangoma_readmsg( - dev_fd, - rx_hdr, /* header buffer */ - sizeof(wp_api_hdr_t), /* header size */ - rx_el->data, /* data buffer */ - MAX_NO_DATA_BYTES_IN_FRAME, /* data BUFFER size */ - 0); - if(Rx_lgth <= 0) { - printf("Span: %d, Chan: %d: Error receiving data!\n", - schan->span, schan->chan); - return 1; - } - -#ifdef __LINUX__ - sample_time_test(schan); -#endif - - schan->rx_packets++; - schan->rx_bytes+=Rx_lgth; - - if (verbose){ - print_rx_data(rx_el->data, Rx_lgth); - } - - /* use Rx_counter as "write" events trigger: */ - if(rbs_events == 1 && (Rx_count % 400) == 0){ - /* bitmap - set as needed: WAN_RBS_SIG_A | WAN_RBS_SIG_B | WAN_RBS_SIG_C | WAN_RBS_SIG_D; - - In this example make bits A and B to change each time, - so it's easy to see the change on the receiving side. - */ - if(schan->rx_rbs_bits == WAN_RBS_SIG_A){ - schan->rx_rbs_bits = WAN_RBS_SIG_B; - }else{ - schan->rx_rbs_bits = WAN_RBS_SIG_A; - } - printf("Writing RBS bits (0x%X)...\n", schan->rx_rbs_bits); - sangoma_tdm_write_rbs(dev_fd, &tdm_api, schan->chan, schan->rx_rbs_bits); - } - - /* if user needs Rx data to be written into a file: */ - if(files_used & RX_FILE_USED){ - write_data_to_file(schan, rx_el->data, Rx_lgth); - } - - return 0; -} - -/*! - \fn int write_data(sangoma_channel_t *schan, wp_api_hdr_t *tx_hdr, void *tx_data) - \brief Transmit a data buffer to a device. - \param dev_index device index number associated with device file descriptor - \param tx_hdr pointer to a wp_api_hdr_t - \param tx_data pointer to a data buffer - \return 0 - Ok otherwise Error -*/ -int write_data(sangoma_channel_t *schan, wp_api_hdr_t *tx_hdr, void *tx_data) -{ - sng_fd_t dev_fd = schan->sangoma_wait_object.fd; - int err; - int tx_len = tx_hdr->data_length; - - /* write a message */ - err = sangoma_writemsg( - dev_fd, - tx_hdr, /* header buffer */ - sizeof(wp_api_hdr_t), /* header size */ - tx_data, /* data buffer */ - tx_len, /* DATA size */ - 0); - - if (err <= 0){ - printf("Span: %d, Chan: %d: Failed to send! (%s) len=%i\n", - schan->span, schan->chan, strerror(errno), tx_len); - schan->tx_errors++; - return -1; - } - - schan->tx_packets++; - schan->tx_bytes+=err; - - if (verbose){ - printf("Packet sent: counter: %i, len: %i\n", schan->tx_packets, err); - } - - -#if 0 - if(Tx_count >= tx_cnt){ - write_enable=0; - printf("Disabling POLLOUT...\n"); - /* No need for POLLOUT, turn it off!! If not turned off, and we - * have nothing for transmission, sangoma_socket_waitfor() will return - * immediately, creating a busy loop. */ - sangoma_wait_objects[dev_index].flags_in &= (~POLLOUT); - } -#endif - return 0; -} - -/*! - \fn int handle_data(sangoma_channel_t *schan) - \brief Read data buffer from the device and transmit it back down. - \param dev_index device index number associated with device file descriptor - \return 0 - Ok otherwise Error - - Read data buffer from a device. After a successful read, transmit - the same data down the device. This function will have an ECHO effect. - Everything received will be transmitted down. -*/ -int handle_data(sangoma_channel_t *schan) -{ - wp_api_element_t *rx_el = &schan->Rx_data; - wp_api_element_t *tx_el = &schan->Tx_data; - uint32_t api_poll_status = schan->sangoma_wait_object.flags_out; - wanpipe_api_t tdm_api; - - memset(&tdm_api,0,sizeof(tdm_api)); - memset(rx_el, 0, sizeof(wp_api_element_t)); - -#if 0 - printf("%s(): span: %d, chan: %d\n", __FUNCTION__, - sangoma_wait_objects[dev_index].span, sangoma_wait_objects[dev_index].chan); -#endif - - if(api_poll_status & POLLIN){ - - if(read_data(schan) == 0){ - - if(rx2tx){ - /* Send back received data (create a "software loopback"), just a test. */ - int err=write_data(schan, &rx_el->hdr, rx_el->data); - if (err) { - return err; - } - } - } - } - - if((api_poll_status & POLLOUT) && write_enable){ - - int err; - wp_api_hdr_t *api_tx_hdr = &tx_el->hdr; - uint16_t Tx_length = sangoma_tdm_get_usr_mtu_mru(schan->sangoma_wait_object.fd,&tdm_api); - unsigned char tx_test_byte = tx_data; - - api_tx_hdr->data_length = Tx_length; - - if (schan->pTxFile == NULL) { - memset(tx_el->data, tx_test_byte, Tx_length); - } else { - memset(tx_el->data, 0xFF, Tx_length); - err=fread(tx_el->data, Tx_length, 1, schan->pTxFile); - if (err == 0) { - _printf("%s: Tx Whole File\n",schan->name); - schan->tx_file_cnt++; - rewind(schan->pTxFile); - } - } - - err=write_data(schan, api_tx_hdr, tx_el->data); - if (err != 0) { - return err; - } - - }/* if() */ - return 0; -} - -static unsigned char get_next_expected_digit(unsigned char current_digit) -{ - switch(current_digit) - { - case '0': - return '1'; - case '1': - return '2'; - case '2': - return '3'; - case '3': - return '4'; - case '4': - return '5'; - case '5': - return '6'; - case '6': - return '7'; - case '7': - return '8'; - case '8': - return '9'; - case '9': - return 'A'; - case 'A': - return 'B'; - case 'B': - return 'C'; - case 'C': - return 'D'; - case 'D': - return '#'; - case '#': - return '*'; - case '*': - return '0'; - default: - return '?'; - } -} - - - -/*! - \fn int decode_api_event(sangoma_channel_t *schan, wanpipe_api_t *tdm_api) - \brief Handle API Event - \param wp_tdm_api_event - \param sangoma_wait_obj -*/ -static int decode_api_event(sangoma_channel_t *schan, wanpipe_api_t *tdm_api) -{ - wp_api_event_t *wp_tdm_api_event = &tdm_api->wp_cmd.event; - - schan->rx_events++; - - //printf("decode_api_event(): span: %d, chan: %d\n", wp_tdm_api_event->span, wp_tdm_api_event->channel); - - switch(wp_tdm_api_event->wp_api_event_type) - { - case WP_API_EVENT_DTMF:/* DTMF detected by Hardware */ - - schan->rx_events_tone++; - - if (dtmf_seq_check) { - unsigned char digit = get_next_expected_digit(schan->prev_dtmf[wp_tdm_api_event->channel]); - - if (wp_tdm_api_event->wp_api_event_dtmf_type == WAN_EC_TONE_PRESENT) { - digit = get_next_expected_digit(schan->prev_dtmf[wp_tdm_api_event->channel]); - } else { - digit = schan->prev_dtmf[wp_tdm_api_event->channel]; - } - - if (digit != '?') { - if (digit != wp_tdm_api_event->wp_api_event_dtmf_digit) { - printf("%s: Error: DTMF Sequence Failed Expecting %c Got %c Events=%i Tone=%i\n", - schan->name,digit,wp_tdm_api_event->wp_api_event_dtmf_digit,schan->rx_events, schan->rx_events_tone); - - return -1; - } - } - - if (wp_tdm_api_event->wp_api_event_dtmf_type == WAN_EC_TONE_PRESENT) { - schan->prev_dtmf[wp_tdm_api_event->channel]=wp_tdm_api_event->wp_api_event_dtmf_digit; - } - } - - _printf("%s: DTMF Event: Span: %d Channel: %d, Digit: %c (Port: %s, Type:%s)!\n", - schan->name, - wp_tdm_api_event->span, - wp_tdm_api_event->channel, - wp_tdm_api_event->wp_api_event_dtmf_digit, - (wp_tdm_api_event->wp_api_event_dtmf_port == WAN_EC_CHANNEL_PORT_ROUT)?"ROUT":"SOUT", - (wp_tdm_api_event->wp_api_event_dtmf_type == WAN_EC_TONE_PRESENT)?"PRESENT":"STOP"); - break; - - case WP_API_EVENT_RXHOOK: - printf("%s: RXHOOK Event: Channel: %d, %s! (0x%X)\n", - schan->name, - wp_tdm_api_event->channel, - WAN_EVENT_RXHOOK_DECODE(wp_tdm_api_event->wp_api_event_hook_state), - wp_tdm_api_event->wp_api_event_hook_state); - break; - - case WP_API_EVENT_RING_DETECT: - printf("RING Event: %s! (0x%X)\n", - WAN_EVENT_RING_DECODE(wp_tdm_api_event->wp_api_event_ring_state), - wp_tdm_api_event->wp_api_event_ring_state); - break; - - case WP_API_EVENT_RING_TRIP_DETECT: - printf("RING TRIP Event: %s! (0x%X)\n", - WAN_EVENT_RING_TRIP_DECODE(wp_tdm_api_event->wp_api_event_ring_state), - wp_tdm_api_event->wp_api_event_ring_state); - break; - - case WP_API_EVENT_RBS: - printf("RBS Event: Channel: %d, 0x%X!\n", - wp_tdm_api_event->channel, - wp_tdm_api_event->wp_api_event_rbs_bits); - printf( "RX RBS: A:%1d B:%1d C:%1d D:%1d\n", - (wp_tdm_api_event->wp_api_event_rbs_bits & WAN_RBS_SIG_A) ? 1 : 0, - (wp_tdm_api_event->wp_api_event_rbs_bits & WAN_RBS_SIG_B) ? 1 : 0, - (wp_tdm_api_event->wp_api_event_rbs_bits & WAN_RBS_SIG_C) ? 1 : 0, - (wp_tdm_api_event->wp_api_event_rbs_bits & WAN_RBS_SIG_D) ? 1 : 0); - break; - - case WP_API_EVENT_LINK_STATUS: - printf("Link Status Event: %s! (0x%X)\n", - WAN_EVENT_LINK_STATUS_DECODE(wp_tdm_api_event->wp_api_event_link_status), - wp_tdm_api_event->wp_api_event_link_status); - break; - - case WP_API_EVENT_ALARM: - printf("New Alarm State: %s! (0x%X)\n", (wp_tdm_api_event->wp_api_event_alarm == 0?"Off":"On"), - wp_tdm_api_event->wp_api_event_alarm); - break; - - case WP_API_EVENT_POLARITY_REVERSE: - printf("Polarity Reversal Event : %s! (0x%X)\n", - WP_API_EVENT_POLARITY_REVERSE_DECODE(wp_tdm_api_event->wp_api_event_polarity_reverse), - wp_tdm_api_event->wp_api_event_polarity_reverse); - break; - - default: - printf("Unknown TDM API Event: %d\n", wp_tdm_api_event->wp_api_event_type); - break; - } - - return 0; -} - -/*! - \fn int handle_tdm_event(sangoma_channel_t *schan) - \brief Read Event buffer from the device - \param dev_index device index number associated with device file descriptor - \return 0 - Ok otherwise Error - - An EVENT has occoured. Execute a system call to read the EVENT - on a device. -*/ -int handle_tdm_event(sangoma_channel_t *schan) -{ - sng_fd_t dev_fd = schan->sangoma_wait_object.fd; - wanpipe_api_t tdm_api; - - memset(&tdm_api,0,sizeof(tdm_api)); - -#if 0 - printf("sangoma_wait_objects[%d].flags_out:", dev_index); - print_poll_event_bitmap(sangoma_wait_objects[dev_index].flags_out); - printf("\n"); -#endif - - if(sangoma_read_event(dev_fd, &tdm_api)){ - printf("%s: Error: Failed to read event %s\n",schan->name,strerror(errno)); - return 1; - } - - return decode_api_event(schan, &tdm_api); - -} - - -static void sangoma_get_print_stats(sangoma_channel_t *schan) -{ - wanpipe_api_t tdm_api; - wanpipe_chan_stats_t *stats = &schan->stats; - - memset(&tdm_api,0,sizeof(tdm_api)); - - sangoma_get_stats(schan->sangoma_wait_object.fd,&tdm_api,&schan->stats); - - printf(" Device %s Statistics\n",schan->name); - - printf("rx_packets =%i\n", stats->rx_packets); - printf("tx_packets =%i\n", stats->tx_packets); - printf("rx_bytes =%i\n", stats->rx_bytes); - printf("tx_bytes =%i\n", stats->tx_bytes); - - printf("rx_errors =%i\n", stats->rx_errors); - printf("tx_errors =%i\n", stats->tx_errors); - - printf("rx_dropped =%i\n", stats->rx_dropped); - printf("tx_dropped =%i\n", stats->tx_dropped); - printf("multicast =%i\n", stats->multicast); - printf("collisions =%i\n", stats->collisions); - - printf("rx_length_errors =%i\n", stats->rx_length_errors); - printf("rx_over_errors =%i\n", stats->rx_over_errors); - printf("rx_crc_errors =%i\n", stats->rx_crc_errors); - printf("rx_frame_errors =%i\n", stats->rx_frame_errors); - printf("rx_fifo_errors =%i\n", stats->rx_fifo_errors); - printf("rx_missed_errors =%i\n", stats->rx_missed_errors); - - printf("tx_aborted_errors =%i\n", stats->tx_aborted_errors); - printf("tx_carrier_errors =%i\n", stats->tx_carrier_errors); - printf("tx_fifo_errors =%i\n", stats->tx_fifo_errors); - printf("tx_heartbeat_errors =%i\n", stats->tx_heartbeat_errors); - printf("tx_window_errors =%i\n", stats->tx_window_errors); - printf("tx_idle_packets =%i\n", stats->tx_idle_packets); - - printf("errors =%i\n", stats->errors); - - printf("frames_in_tx_queue =%i\n", stats->current_number_of_frames_in_tx_queue); - printf("max_tx_queue_length =%i\n", stats->max_tx_queue_length); - printf("frames_in_rx_queue =%i\n", stats->current_number_of_frames_in_rx_queue); - printf("max_rx_queue_length =%i\n", stats->max_rx_queue_length); - - printf("events_in_event_queue =%i\n", stats->current_number_of_events_in_event_queue); - printf("max_event_queue_length =%i\n", stats->max_event_queue_length); - - printf("rx_events =%i\n", stats->rx_events); - printf("rx_events_dropped =%i\n", stats->rx_events_dropped); - printf("rx_events_tone =%i\n", stats->rx_events_tone); - -} - - -/*! - \fn static void *handle_span_chan(void *obj) - \brief Write data buffer into a file - \param obj schan pointer - \return void - - This function will wait on all opened devices. - This example will wait for RX and EVENT signals. - In case of POLLIN - rx data available - In case of POLLPRI - event is available -*/ -static void *handle_span_chan(void *obj) -{ - int iResult=0; - sangoma_channel_t *schan = (sangoma_channel_t*)obj; - wanpipe_api_t tdm_api; - - memset(&tdm_api,0,sizeof(tdm_api)); - - printf("\n\n%s: Span/Chan Handler: RxEnable=%s, TxEnable=%s, TxCnt=%i, TxLen=%i, Verbose=%i Stats=%i Flush=%i\n", - schan->name,(read_enable? "Yes":"No"), (write_enable?"Yes":"No"),tx_cnt,tx_size, verbose,stats_period,flush_period); - - - sangoma_flush_bufs(schan->sangoma_wait_object.fd,&tdm_api); - sangoma_flush_stats(schan->sangoma_wait_object.fd,&tdm_api); - - /* init to some hight value */ - schan->elapsed_min=100000; - - /* Main Rx/Tx/Event loop */ - while(server_running) - { - iResult = sangoma_socket_waitfor_many(&schan->sangoma_wait_object, - 1 /* number of wait objects */, - 1000/* 2 sec wait */); - - if(iResult < 0){ - /* error */ - printf("Error: iResult: %d\n", iResult); - schan->test_failed++; - break; - } - - if (iResult == 0){ - /* timeout */ - printf("%s: Timeout fd=%i Events=0x%X\n", - schan->name,schan->sangoma_wait_object.fd,schan->sangoma_wait_object.flags_in); - sangoma_get_full_cfg(schan->sangoma_wait_object.fd, &tdm_api); - sangoma_get_print_stats(schan); - schan->test_failed++; - break; - } - - schan->loop_cnt++; - - if (schan->sangoma_wait_object.flags_out & POLLPRI){ - /* got tdm api event */ - if(handle_tdm_event(schan)){ - sangoma_get_print_stats(schan); - schan->test_failed++; - break; - } - } - - if (schan->sangoma_wait_object.flags_out & (POLLIN | POLLOUT)){ - /* got data */ - if(handle_data(schan)){ - sangoma_get_print_stats(schan); - schan->test_failed++; - break; - } - } - - if (stats_period && - schan->loop_cnt % stats_period == 0) { - sangoma_get_print_stats(schan); - } - - if (flush_period && - schan->loop_cnt % flush_period == 0) { - printf("%s: Flushing Buffers\n",schan->name); - sangoma_flush_bufs(schan->sangoma_wait_object.fd,&tdm_api); - sangoma_get_print_stats(schan); - } - - }/* for() */ - - sangoma_get_stats(schan->sangoma_wait_object.fd,&tdm_api,&schan->stats); - - /* FIXME LOCK */ - pthread_mutex_lock(&threads_running_lock); - threads_running--; - pthread_mutex_unlock(&threads_running_lock); - - return NULL; -} - -/*! - \fn int write_data_to_file(sangoma_channel_t *schan, unsigned char *data, unsigned int data_length) - \brief Write data buffer into a file - \param data data buffer - \param data_length length of a data buffer - \return data_length = ok otherwise error - -*/ -int write_data_to_file(sangoma_channel_t *schan, unsigned char *data, unsigned int data_length) -{ - if(schan->pRxFile == NULL){ - return 1; - } - - return fwrite(data, 1, data_length, schan->pRxFile); -} - -#ifdef WIN32 -/* - * TerminateHandler() - this handler is called by the system whenever user tries to terminate - * the process with Ctrl+C, Ctrl+Break or closes the console window. - * Perform a clean-up here. - */ -BOOL TerminateHandler(DWORD dwCtrlType) -{ - int i; - - printf("\nProcess terminated by user request. Threads=%i\n",threads_running); - - server_running=0; - - /* return FALSE so the system will call the dafult handler which will terminate the process. */ - return FALSE; -} -#else -/*! - \fn void TerminateHandler (int sig) - \brief Signal handler for graceful shutdown - \param sig signal -*/ -void TerminateHandler (int sig) -{ - - printf("\nProcess terminated by user request Threads=%i.\n",threads_running); - - server_running=0; - - - return; -} - -#endif - -/*! - \fn int open_sangoma_device(sangoma_channel_t *schan) - \brief Open a single span chan device and return number of devices opened - \param open_device_counter returns the number of devices opened - \return 0 ok otherise error. - - This function will open a single span chan. - - However it can be rewritten to iterate for all spans and chans and try to - open all existing wanpipe devices. - - For each opened device, a wait object will be initialized. - For each device, configure the chunk size for tx/rx - enable events such as DTMF/RBS ...etc -*/ - -int open_sangoma_device(sangoma_channel_t *schan) -{ - int err = -1; - sng_fd_t dev_fd = INVALID_HANDLE_VALUE; - wanpipe_api_t tdm_api; - - memset(&tdm_api,0,sizeof(tdm_api)); - - /* span and chan are 1-based */ - dev_fd = sangoma_open_api_span_chan(schan->span, schan->chan); - if( dev_fd == INVALID_HANDLE_VALUE){ - printf("%s: Warning: Failed to open span %d, chan %d\n", schan->name, schan->span , schan->chan); - return 1; - }else{ - printf("%s: Successfuly opened span %d, chan %d fd=%i\n", schan->name, schan->span , schan->chan, dev_fd); - } - - - do{ - - printf("%s: Setup Span=%i Chan=%i Handler\n", - schan->name, schan->span, schan->chan); - - /* Front End connect/disconnect, and other events, such as DTMF... */ - schan->poll_events_bitmap |= (POLLHUP | POLLPRI); - - if(read_enable == 1){ - schan->poll_events_bitmap |= POLLIN; - } - - if(write_enable == 1){ - schan->poll_events_bitmap |= POLLOUT; - } - - if((err=sangoma_get_full_cfg(dev_fd, &tdm_api))){ - break; - } - - if(usr_period){ - printf("%s: Setting user period: %d\n", schan->name,usr_period); - if((err=sangoma_tdm_set_usr_period(dev_fd, &tdm_api, usr_period))){ - break; - } - } - - if(set_codec_slinear || usr_period || set_codec_none){ - /* display new configuration AFTER it was changed */ - if((err=sangoma_get_full_cfg(dev_fd, &tdm_api))){ - break; - } - } - - if(dtmf_enable_octasic == 1){ - schan->poll_events_bitmap |= POLLPRI; - /* enable dtmf detection on Octasic chip */ - if((err=sangoma_tdm_enable_dtmf_events(dev_fd, &tdm_api))){ - break; - } - } - - if(dtmf_enable_remora == 1){ - schan->poll_events_bitmap |= POLLPRI; - /* enable dtmf detection on Sangoma's Remora SLIC chip (A200 ONLY) */ - if((err=sangoma_tdm_enable_rm_dtmf_events(dev_fd, &tdm_api))){ - break; - } - } - - if(remora_hook == 1){ - schan->poll_events_bitmap |= POLLPRI; - if((err=sangoma_tdm_enable_rxhook_events(dev_fd, &tdm_api))){ - break; - } - } - - if(rbs_events == 1){ - schan->poll_events_bitmap |= POLLPRI; - if((err=sangoma_tdm_enable_rbs_events(dev_fd, &tdm_api, 20))){ - break; - } - } - - printf("%s: Device Config RxQ=%i TxQ=%i \n", - schan->name, - sangoma_get_rx_queue_sz(dev_fd,&tdm_api), - sangoma_get_rx_queue_sz(dev_fd,&tdm_api)); - - err=0; - - }while(0); - - if(sangoma_init_wait_obj(&schan->sangoma_wait_object, dev_fd, schan->span, schan->chan, schan->poll_events_bitmap, SANGOMA_WAIT_OBJ)){ - printf("%s: Error: Failed to initialize 'sangoma_wait_object'\n", schan->name); - return 1; - } - - if (tx_data) { - printf("%s: Setting Tx Data to 0x%X MaxSize=%i\n",schan->name, tx_data, sizeof(schan->Tx_data.data)); - memset(schan->Tx_data.data,tx_data,sizeof(schan->Tx_data.data)); - } - - printf("%s: Enabling Poll Events: RX=%d TX=%d EVENT=%d\n", schan->name, - schan->poll_events_bitmap&POLLIN, - schan->poll_events_bitmap&POLLOUT, - schan->poll_events_bitmap&POLLPRI); - - - printf("********************************\n"); - printf("files_used: 0x%x\n", files_used); - printf("********************************\n"); - if(files_used & RX_FILE_USED){ - char file_name[100]; - sprintf(file_name, "sangoma_s%dc%d.bin",schan->span,schan->chan); - schan->pRxFile = fopen( (const char*)file_name, "wb" ); - if(schan->pRxFile == NULL){ - printf("%s: Can't open Rx file: [%s]!!\n", schan->name, file_name); - return 1; - }else{ - printf("%s: Open Rx file: %s. OK.\n", schan->name , file_name); - } - } - - if(files_used & TX_FILE_USED){ - schan->pTxFile = fopen( (const char*)&tx_file[0], "rb" ); - if(schan->pTxFile == NULL){ - printf("%s: Can't open Tx file: [%s]!!\n", schan->name, tx_file); - return 1; - }else{ - printf("%s: Open Tx file: %s. OK.\n",schan->name, tx_file); - } - } - - return err; -} - -/*! - \fn void close_sangoma_devices(void) - \brief Close all opened devices -*/ -void close_sangoma_devices(sangoma_channel_t *schan) -{ - wanpipe_api_t tdm_api; - wanpipe_chan_stats_t *stats = &schan->stats; - int test_failed; - memset(&tdm_api,0,sizeof(tdm_api)); - - test_failed = schan->test_failed; - if (schan->rx_events_tone == 0) { - test_failed++; - } - - printf("%-10s: Errors: All=%03i Rx=%03i Tx=%03i Event=%03i | RX: Event=%03i Tone=%03i | App: R_Ev=%03i R_Tone=%03i T_Ev=%03i | Diff: %i %i | Test: %s\n",schan->name, - stats->errors, - stats->rx_errors, - stats->tx_errors, - stats->rx_events_dropped, - stats->rx_events, - stats->rx_events_tone, - schan->rx_events, - schan->rx_events_tone, - schan->tx_file_cnt, - abs(stats->rx_events-schan->rx_events), - abs(stats->rx_events_tone-schan->rx_events_tone), - test_failed?"FAILED":"Passed" - ); - - if(dtmf_enable_octasic == 1){ - /* Disable dtmf detection on Octasic chip */ - sangoma_tdm_disable_dtmf_events(schan->sangoma_wait_object.fd, &tdm_api); - } - - if(dtmf_enable_remora == 1){ - /* Disable dtmf detection on Sangoma's Remora SLIC chip */ - sangoma_tdm_disable_rm_dtmf_events(schan->sangoma_wait_object.fd, &tdm_api); - } - - if(remora_hook == 1){ - sangoma_tdm_disable_rxhook_events(schan->sangoma_wait_object.fd, &tdm_api); - } - - if(rbs_events == 1){ - sangoma_tdm_disable_rbs_events(schan->sangoma_wait_object.fd, &tdm_api); - } - - /* call sangoma_close() for EACH open Device Handle */ - sangoma_close(&schan->sangoma_wait_object.fd); - - return; -} - -#ifdef __LINUX__ -static int launch_handler_thread(sangoma_channel_t *schan) -{ - pthread_attr_t attr; - int result = -1; - - result = pthread_attr_init(&attr); - //pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); - //pthread_attr_setschedpolicy(&attr, SCHED_RR); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - pthread_attr_setstacksize(&attr, MAX_STACK_SIZE); - - result = pthread_create(&schan->threadid, &attr, handle_span_chan, schan); - if (result) { - printf("%s: %s(): Error: Creating Thread! %s\n", - schan->name,__FUNCTION__,strerror(errno)); - } else { - //FIXME LOCK - pthread_mutex_lock(&threads_running_lock); - threads_running++; - pthread_mutex_unlock(&threads_running_lock); - } - pthread_attr_destroy(&attr); - - return result; -} -#endif - - - - -static char api_usage[]="\n" -"\n" -":\n" -" -p Default: 1\n" -" -pm Default: 1\n" -" -i Default: 1\n" -" -r #read enable\n" -" -w #write eable\n" -" -dtmf_seq_check #check dtmf seq\n" -"\n" -" example 1: sangoma_c -p 1 -i 1 -r\n" -" in this example Wanpipe 1, Interface 1 will be used for reading data\n" -" example 1: sangoma_c -p 5 -i 32 -r\n" -" in this example Wanpipes 1-5, Interfaces 1-32 will be used for reading data\n" -"\n" -"\n" -" -txcnt #number of tx packets (Dflt: 1)\n" -" -txsize #tx packet size (Dflt: 10)\n" -" -txdelay #delay in sec after each tx packet (Dflt: 0)\n" -" -txdata #data to tx <1-255>\n" -" -rx2tx #transmit all received data\n" -"\n" -" -dtmf_octasic #Enable DTMF detection on Octasic chip\n" -" -dtmf_remora #Enable DTMF detection on A200 (SLIC) chip\n" -" -remora_hook #Enable On/Off hook events on A200\n" -" -set_codec_slinear #Enable SLINEAR codec\n" -" -set_codec_none #Disable codec\n" -" -rbs_events #Enable RBS change detection\n" -"\n" -" -rxcnt #number of rx packets before exit\n" -" #this number overwrites the txcnt\n" -" #Thus, app will only exit after it\n" -" #receives the rxcnt number of packets.\n" -" \n" -" -verbose #Enable verbose mode\n" -"\n"; - - - - -/*! - \fn int __cdecl main(int argc, char* argv[]) - \brief Main function that starts the sample code - \param argc number of arguments - \param argv argument list -*/ -int __cdecl main(int argc, char* argv[]) -{ - int proceed; - int span,chan,err; - int min_span; - - proceed=init_args(argc,argv); - if (proceed != WAN_TRUE){ - printf("%s",api_usage); - return -1; - } - - min_span=wanpipe_min_port_no; - if (min_span==0){ - min_span=1; - } - max_spans = wanpipe_port_no; - max_chans = wanpipe_if_no; - -#if defined(__LINUX__) - nice(-10); -#endif - - /* register Ctrl+C handler - we want a clean termination */ -#if defined(__WINDOWS__) - if (!SetConsoleCtrlHandler(TerminateHandler, TRUE)) { - printf("ERROR : Unable to register terminate handler ( %d ).\nProcess terminated.\n", - GetLastError()); - return -1; - } -#else - signal(SIGHUP,TerminateHandler); - signal(SIGTERM,TerminateHandler); - signal(SIGINT,TerminateHandler); -#endif - - server_running = 1; - pthread_mutex_init(&threads_running_lock,NULL); - - - printf("Connecting to Port/Span: %d, Interface/Chan: %d\n", - wanpipe_port_no, wanpipe_if_no); - - for (span=min_span;span<=max_spans;span++) { - for (chan=1;chan<=max_chans;chan++) { - sangoma_channel_t *schan = &sangoma_channel_idx[span][chan]; - schan->span=span; - schan->chan=chan; - sprintf(schan->name, "s%dc%d",span,chan); - err=open_sangoma_device(schan); - if (err == 0) { - schan->init=1; - err=launch_handler_thread(schan); - if (err) { - printf("Critical Error Failed to Launch Thread!\n"); - server_running=0; - goto server_shutdown; - } - } else { - close_sangoma_devices(schan); - } - } - } - - while (server_running) { - usleep(5000); - } - - - -server_shutdown: - - printf("Waiting for theads to stop !\n"); - while (threads_running) { - usleep(5000); - } - - printf("All threads stopped, shutting down !\n"); - - for (span=1;span<=max_spans;span++) { - for (chan=1;chan<=max_chans;chan++) { - sangoma_channel_t *schan = &sangoma_channel_idx[span][chan]; - if (schan->init) { - close_sangoma_devices(schan); - } - } - } - - pthread_mutex_destroy(&threads_running_lock); - - return 0; -} diff --git a/deb_control/wanpipe.deb b/deb_control/wanpipe.deb index db4ec47..c4ae8f3 100644 --- a/deb_control/wanpipe.deb +++ b/deb_control/wanpipe.deb @@ -1,5 +1,5 @@ Package: wanpipe -Version: 3.5.1-0 +Version: 3.5.2-0 Section: networking Priority: optional Architecture: all diff --git a/patches/kdrivers/include/wanpipe_version.h b/patches/kdrivers/include/wanpipe_version.h index 033a146..cd66ebd 100644 --- a/patches/kdrivers/include/wanpipe_version.h +++ b/patches/kdrivers/include/wanpipe_version.h @@ -10,7 +10,7 @@ #define WANPIPE_COMPANY "Sangoma Technologies Inc" /********** LINUX **********/ -#define WANPIPE_VERSION "3.5.1" +#define WANPIPE_VERSION "3.5.2" #define WANPIPE_SUB_VERSION "0" #define WANPIPE_VERSION_BETA 1 #define WANPIPE_LITE_VERSION "1.1.1" @@ -18,8 +18,8 @@ #if defined(__LINUX__) #define WANPIPE_VERSION_MAJOR 3 #define WANPIPE_VERSION_MINOR 5 -#define WANPIPE_VERSION_MINOR1 0 -#define WANPIPE_VERSION_MINOR2 49 +#define WANPIPE_VERSION_MINOR1 2 +#define WANPIPE_VERSION_MINOR2 0 #endif /********** FreeBSD **********/ diff --git a/patches/kdrivers/src/net/sdladrv.c b/patches/kdrivers/src/net/sdladrv.c index 7505e3d..4f26e5a 100644 --- a/patches/kdrivers/src/net/sdladrv.c +++ b/patches/kdrivers/src/net/sdladrv.c @@ -2968,6 +2968,7 @@ sdla_pci_probe_aft(sdlahw_t *hw, int bus_no, int slot_no, int irq) case AFT_2SERIAL_RS232_SUBSYS_VENDOR: case AFT_4SERIAL_RS232_SUBSYS_VENDOR: case AFT_A600_SUBSYS_VENDOR: + case A700_SHARK_SUBSYS_VENDOR: sdla_pcibridge_detect(hwcard); break; } diff --git a/rpmspec/wanpipe-mod.spec b/rpmspec/wanpipe-mod.spec index 4c98f21..c0a33a5 100644 --- a/rpmspec/wanpipe-mod.spec +++ b/rpmspec/wanpipe-mod.spec @@ -1,6 +1,6 @@ %define WANPIPE_VER wanpipe-modules %define name %{WANPIPE_VER} -%define version 3.5.1 +%define version 3.5.2 %define release 0 %define serial 1 %define MODULES_DIR /lib/modules @@ -51,6 +51,12 @@ echo "Wanpipe Modules located in %{MODULES_DIR}/%{KVERSION}" %changelog +* Fri May 08 2009 Nenad Corbic - Beta - 3.5.2 +=================================================================== + +- B700 PCIe cards were being desplayed as PCI cards in hwprobe +- Bug fix in wancfg_zaptel + * Thu May 07 2009 Nenad Corbic - Beta - 3.5.1 =================================================================== diff --git a/rpmspec/wanpipe-util.spec b/rpmspec/wanpipe-util.spec index 6175ba0..037118c 100644 --- a/rpmspec/wanpipe-util.spec +++ b/rpmspec/wanpipe-util.spec @@ -1,7 +1,7 @@ %define KERNEL_VERSION %{?kern_ver} %define WANPIPE_VER wanpipe-util %define name %{WANPIPE_VER} -%define version 3.5.1 +%define version 3.5.2 %define release 0 %define serial 1 %define ETC_DIR /etc @@ -328,6 +328,12 @@ enable_smg_log; %changelog +* Fri May 08 2009 Nenad Corbic - Beta - 3.5.2 +=================================================================== + +- B700 PCIe cards were being desplayed as PCI cards in hwprobe +- Bug fix in wancfg_zaptel + * Thu May 07 2009 Nenad Corbic - Beta - 3.5.1 =================================================================== diff --git a/rpmspec/wanpipe.spec b/rpmspec/wanpipe.spec index 009adcf..befd82b 100644 --- a/rpmspec/wanpipe.spec +++ b/rpmspec/wanpipe.spec @@ -1,7 +1,7 @@ %define KERNEL_VERSION %{?kern_ver} %define WANPIPE_VER wanpipe %define name %{WANPIPE_VER} -%define version 3.5.1 +%define version 3.5.2 %define release 0 %define serial 1 %define UTILS_DIR /usr/sbin @@ -255,6 +255,12 @@ install_init; %changelog +* Fri May 08 2009 Nenad Corbic - Beta - 3.5.2 +=================================================================== + +- B700 PCIe cards were being desplayed as PCI cards in hwprobe +- Bug fix in wancfg_zaptel + * Thu May 07 2009 Nenad Corbic - Beta - 3.5.1 =================================================================== diff --git a/samples/wanrouter b/samples/wanrouter index 6063cf4..133b3fc 100644 --- a/samples/wanrouter +++ b/samples/wanrouter @@ -2205,7 +2205,7 @@ init_global_params() { if [ $OSYSTEM = "Linux" ]; then - ROUTER_VERSION=3.5.1 + ROUTER_VERSION=3.5.2 IFCONFIG_LIST=ifconfig MODULE_STAT=lsmod WAN_DRIVERS="wanpipe" diff --git a/util/wancfg_zaptel/.svn/all-wcprops b/util/wancfg_zaptel/.svn/all-wcprops index 367b4a0..cd2157b 100644 --- a/util/wancfg_zaptel/.svn/all-wcprops +++ b/util/wancfg_zaptel/.svn/all-wcprops @@ -21,23 +21,23 @@ svn:wc:ra_dav:version-url V 97 /svn/wanpipe/!svn/ver/7323/wanpipe_common/branches/jpatel_new/wantools/wancfg_zaptel/uninstall.sh END -boostspan.pm -K 25 -svn:wc:ra_dav:version-url -V 97 -/svn/wanpipe/!svn/ver/7535/wanpipe_common/branches/jpatel_new/wantools/wancfg_zaptel/boostspan.pm -END setup-sangoma K 25 svn:wc:ra_dav:version-url V 98 /svn/wanpipe/!svn/ver/7323/wanpipe_common/branches/jpatel_new/wantools/wancfg_zaptel/setup-sangoma END -wancfg_zaptel +boostspan.pm K 25 svn:wc:ra_dav:version-url -V 98 -/svn/wanpipe/!svn/ver/7323/wanpipe_common/branches/jpatel_new/wantools/wancfg_zaptel/wancfg_zaptel +V 97 +/svn/wanpipe/!svn/ver/7535/wanpipe_common/branches/jpatel_new/wantools/wancfg_zaptel/boostspan.pm +END +A10x.pm +K 25 +svn:wc:ra_dav:version-url +V 92 +/svn/wanpipe/!svn/ver/7635/wanpipe_common/branches/jpatel_new/wantools/wancfg_zaptel/A10x.pm END Card.pm K 25 @@ -45,11 +45,11 @@ svn:wc:ra_dav:version-url V 92 /svn/wanpipe/!svn/ver/7608/wanpipe_common/branches/jpatel_new/wantools/wancfg_zaptel/Card.pm END -A10x.pm +wancfg_zaptel K 25 svn:wc:ra_dav:version-url -V 92 -/svn/wanpipe/!svn/ver/7635/wanpipe_common/branches/jpatel_new/wantools/wancfg_zaptel/A10x.pm +V 98 +/svn/wanpipe/!svn/ver/7323/wanpipe_common/branches/jpatel_new/wantools/wancfg_zaptel/wancfg_zaptel END A20x.pm K 25 @@ -81,18 +81,18 @@ svn:wc:ra_dav:version-url V 94 /svn/wanpipe/!svn/ver/7535/wanpipe_common/branches/jpatel_new/wantools/wancfg_zaptel/wancfg_fs END +wancfg_zaptel.pl +K 25 +svn:wc:ra_dav:version-url +V 101 +/svn/wanpipe/!svn/ver/7682/wanpipe_common/branches/jpatel_new/wantools/wancfg_zaptel/wancfg_zaptel.pl +END wancfg_dahdi K 25 svn:wc:ra_dav:version-url V 97 /svn/wanpipe/!svn/ver/7323/wanpipe_common/branches/jpatel_new/wantools/wancfg_zaptel/wancfg_dahdi END -wancfg_zaptel.pl -K 25 -svn:wc:ra_dav:version-url -V 101 -/svn/wanpipe/!svn/ver/7669/wanpipe_common/branches/jpatel_new/wantools/wancfg_zaptel/wancfg_zaptel.pl -END analogspan.pm K 25 svn:wc:ra_dav:version-url diff --git a/util/wancfg_zaptel/.svn/entries b/util/wancfg_zaptel/.svn/entries index 6625e18..902c8eb 100644 --- a/util/wancfg_zaptel/.svn/entries +++ b/util/wancfg_zaptel/.svn/entries @@ -64,6 +64,18 @@ file sangoma has-props +boostspan.pm +file + + + + +2009-04-07T21:16:44.000000Z +8948e0709dd4dd21a73477daed531949 +2009-04-08T15:24:10.094544Z +7535 +jpatel + setup-sangoma file @@ -77,29 +89,18 @@ c631bf29819aed1b49bcd46369e06b59 sangoma has-props -boostspan.pm +wancfg_zaptel file -2009-04-07T21:16:44.000000Z -8948e0709dd4dd21a73477daed531949 -2009-04-08T15:24:10.094544Z -7535 -jpatel - -A10x.pm -file - - - - -2009-04-29T18:33:09.000000Z -30e5452dacdc312595c854c1b7ca3fb8 -2009-04-27T23:10:02.151043Z -7635 -jpatel +2009-04-01T18:10:26.000000Z +0c2f52a3b64e425d9b18b3d1a29586e8 +2008-01-08T21:32:19.000000Z +5238 +sangoma +has-props Card.pm file @@ -113,18 +114,17 @@ dc1c67323bcd74e1c0a64c7b33af5c5f 7608 jpatel -wancfg_zaptel +A10x.pm file -2009-04-01T18:10:26.000000Z -0c2f52a3b64e425d9b18b3d1a29586e8 -2008-01-08T21:32:19.000000Z -5238 -sangoma -has-props +2009-04-29T18:33:09.000000Z +30e5452dacdc312595c854c1b7ca3fb8 +2009-04-27T23:10:02.151043Z +7635 +jpatel A20x.pm file @@ -189,6 +189,9 @@ b0dd0ff9bb1ecad55b1306f13bd2580f jpatel has-props +templates +dir + wancfg_dahdi file @@ -202,19 +205,16 @@ file jpatel has-props -templates -dir - wancfg_zaptel.pl file +7682 - -2009-05-05T18:45:53.000000Z -630ed59c6badbae7aa4d9b5d7e6c9d7e -2009-05-06T17:18:16.245239Z -7669 +2009-05-08T16:08:01.000000Z +741d97bced1a1b7305edbaa51903bee9 +2009-05-08T17:56:28.376256Z +7682 jpatel has-props diff --git a/util/wancfg_zaptel/.svn/text-base/wancfg_zaptel.pl.svn-base b/util/wancfg_zaptel/.svn/text-base/wancfg_zaptel.pl.svn-base index ee36496..b0f996a 100644 --- a/util/wancfg_zaptel/.svn/text-base/wancfg_zaptel.pl.svn-base +++ b/util/wancfg_zaptel/.svn/text-base/wancfg_zaptel.pl.svn-base @@ -355,7 +355,7 @@ if ($os_type_list =~ m/FreeBSD/ && $zaptel_dahdi_installed==$TRUE) { update_zaptel_cfg_script(); } -if( $zaptel_installed==$TRUE && $os_type_list =~ m/Linux/ ) { +if( $zaptel_installed==$TRUE && $os_type_list =~ m/Linux/ && $is_fs == $FALSE) { set_zaptel_hwhdlc(); } @@ -376,11 +376,13 @@ if ($os_type_list =~ m/FreeBSD/){ config_boot_freebsd(); } else { config_boot_linux(); - config_smg_ctrl_boot(); } config_ztcfg_start(); config_smg_ctrl_start(); +if($os_type_list =~ m/Linux/){ +config_smg_ctrl_boot(); +} clean_files(); print "Sangoma cards configuration complete, exiting...\n\n"; @@ -3411,7 +3413,7 @@ sub config_smg_ctrl_boot { if($silent==$FALSE){ print ("Would you like $script_name to start on system boot?\n"); $res= &prompt_user_list("YES","NO",""); - if($res=='NO'){ + if($res eq "NO"){ return; } } diff --git a/util/wancfg_zaptel/wancfg_zaptel.pl b/util/wancfg_zaptel/wancfg_zaptel.pl index ee36496..b0f996a 100755 --- a/util/wancfg_zaptel/wancfg_zaptel.pl +++ b/util/wancfg_zaptel/wancfg_zaptel.pl @@ -355,7 +355,7 @@ if ($os_type_list =~ m/FreeBSD/ && $zaptel_dahdi_installed==$TRUE) { update_zaptel_cfg_script(); } -if( $zaptel_installed==$TRUE && $os_type_list =~ m/Linux/ ) { +if( $zaptel_installed==$TRUE && $os_type_list =~ m/Linux/ && $is_fs == $FALSE) { set_zaptel_hwhdlc(); } @@ -376,11 +376,13 @@ if ($os_type_list =~ m/FreeBSD/){ config_boot_freebsd(); } else { config_boot_linux(); - config_smg_ctrl_boot(); } config_ztcfg_start(); config_smg_ctrl_start(); +if($os_type_list =~ m/Linux/){ +config_smg_ctrl_boot(); +} clean_files(); print "Sangoma cards configuration complete, exiting...\n\n"; @@ -3411,7 +3413,7 @@ sub config_smg_ctrl_boot { if($silent==$FALSE){ print ("Would you like $script_name to start on system boot?\n"); $res= &prompt_user_list("YES","NO",""); - if($res=='NO'){ + if($res eq "NO"){ return; } }