]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update wanpipe
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 19 Apr 2007 15:34:30 +0000 (15:34 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 19 Apr 2007 15:34:30 +0000 (15:34 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4971 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_wanpipe/Makefile
src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.c
src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.h
src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.c
src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.h
src/mod/endpoints/mod_wanpipe/mod_wanpipe.c

index 15c3dc8f05c1d30f6f5e1fb03c9191d5ae6831e1..d394407511c45afdf0ae1ddc0e5b725aafb253da 100644 (file)
@@ -3,7 +3,7 @@ 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.p15
+WANPIPE=wanpipe-3.1.0.p18
 WANPIPE_HOST=ftp://ftp.sangoma.com/linux/custom/3.1
 WANPIPE_FILE=$(WANPIPE).tgz
 WANPIPE_DIR=$(BASE)/libs/$(WANPIPE)
index 4e5c09e8c5878f34e72bec19b6aea12659a1b56a..282bd3c2a3eca8b40e2231372b7044a95c178dec 100644 (file)
@@ -1,25 +1,6 @@
-/*****************************************************************************
- * libsangoma.c        AFT T1/E1: HDLC API Code Library
- *
- * Author(s):  Anthony Minessale II <anthmct@yahoo.com>
- *              Nenad Corbic <ncorbic@sangoma.com>
- *              David Rokhvarg <davidr@sangoma.com>
- *              Michael Jerris <mike@jerris.com>
- *
- * Copyright:  (c) 2005 Anthony Minessale II
- *
- *             This program is free software; you can redistribute it and/or
- *             modify it under the terms of the GNU General Public License
- *             as published by the Free Software Foundation; either version
- *             2 of the License, or (at your option) any later version.
- * ============================================================================
- *
- * Aug 15, 2006  David Rokhvarg <davidr@sangoma.com>   Ported to MS Windows 2000/XP
- * Sep 24, 2006  Michael Jerris <mike@jerris.com>              Windows port, standardize api, cleanup
- * 
- */
-
 #include "libsangoma.h"
+#include <stdarg.h>
+
 #define DFT_CARD "wanpipe1"
 
 #if defined(WIN32)
@@ -265,6 +246,48 @@ sng_fd_t sangoma_open_tdmapi_span(int span)
     return fd;  
 }      
 
+static char *cut_path(char *in)
+{
+       char *p, *ret = in;
+       char delims[] = "/\\";
+       char *i;
+
+       for (i = delims; *i; i++) {
+               p = in;
+               while ((p = strchr(p, *i)) != 0) {
+                       ret = ++p;
+               }
+       }
+       return ret;
+}
+
+
+static void default_logger(char *file, const char *func, int line, int level, char *fmt, ...)
+{
+       char *fp;
+       char data[1024];
+
+       va_list ap;
+       
+       fp = cut_path(file);
+
+       va_start(ap, fmt);
+
+       vsnprintf(data, sizeof(data), fmt, ap);
+
+       fprintf(stderr, "%s:%d %s() %s", file, line, func, data);
+
+       va_end(ap);
+
+}
+
+sangoma_logger_t global_logger = default_logger;
+
+void sangoma_set_logger(sangoma_logger_t logger)
+{
+       global_logger = logger;
+}
+
 int sangoma_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag)
 {
        int rx_len=0;
index 0577165de055586c476a77e8d0fc4123a8eb4e79..14a5d99785dffefbff7f1634ff43485710178393 100644 (file)
@@ -1,18 +1,3 @@
-/*****************************************************************************
- * libsangoma.c        AFT T1/E1: HDLC API Code Library
- *
- * Author(s):  Anthony Minessale II <anthmct@yahoo.com>
- *              Nenad Corbic <ncorbic@sangoma.com>
- *
- * Copyright:  (c) 2005 Anthony Minessale II
- *
- *             This program is free software; you can redistribute it and/or
- *             modify it under the terms of the GNU General Public License
- *             as published by the Free Software Foundation; either version
- *             2 of the License, or (at your option) any later version.
- * ============================================================================
- */
-
 #ifndef _LIBSNAGOMA_H
 #define _LIBSNAGOMA_H
 #include <stdio.h>
@@ -161,6 +146,21 @@ int sangoma_tdm_disable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
 int sangoma_tdm_get_fe_alarms(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
 int sangoma_tdm_cmd_exec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
 
+#define WP_PRE __FILE__, __FUNCTION__, __LINE__
+#define WP_LOG_DEBUG WP_PRE, 7
+#define WP_LOG_INFO WP_PRE, 6
+#define WP_LOG_NOTICE WP_PRE, 5
+#define WP_LOG_WARNING WP_PRE, 4
+#define WP_LOG_ERROR WP_PRE, 3
+#define WP_LOG_CRIT WP_PRE, 2
+#define WP_LOG_ALERT WP_PRE, 1
+#define WP_LOG_EMERG WP_PRE, 0
+
+typedef void (*sangoma_logger_t)(char *file, const char *func, int line, int level, char *fmt, ...);
+void sangoma_set_logger(sangoma_logger_t logger);
+
+extern sangoma_logger_t global_logger;
+
 #ifndef LIBSANGOMA_GET_HWCODING
 #define LIBSANGOMA_GET_HWCODING 1
 #endif
index b459edd65ad458f552993dbd10d878ab1281585b..c5dcb2cd6306e11fe127cef01c91c5dd6909145b 100644 (file)
@@ -1,18 +1,3 @@
-/*****************************************************************************
- * sangoma_pri.c libpri Sangoma integration
- *
- * Author(s):  Anthony Minessale II <anthmct@yahoo.com>
- *              Nenad Corbic <ncorbic@sangoma.com>
- *
- * Copyright:  (c) 2005 Anthony Minessale II
- *
- *             This program is free software; you can redistribute it and/or
- *             modify it under the terms of the GNU General Public License
- *             as published by the Free Software Foundation; either version
- *             2 of the License, or (at your option) any later version.
- * ============================================================================
- */
-
 #include <libsangoma.h>
 #include <sangoma_pri.h>
 #ifndef HAVE_GETTIMEOFDAY
@@ -158,6 +143,10 @@ int sangoma_init_pri(struct sangoma_pri *spri, int span, int dchan, int swtype,
        } else {
                if ((spri->pri = pri_new_cb((int) dfd, node, swtype, __pri_sangoma_read, __pri_sangoma_write, NULL))) {
                        spri->span = span;
+                       spri->dchan = dchan;
+                       spri->swtype = swtype;
+                       spri->node = node;
+                       spri->debug = debug;
                        pri_set_debug(spri->pri, debug);
                        ret = 0;
                } else {
@@ -183,7 +172,7 @@ int sangoma_one_loop(struct sangoma_pri *spri)
        FD_ZERO(&efds);
 
 #ifdef _MSC_VER
-//Windows macro for FD_SET includes a warning C4127: conditional expression is constant
+//Windows macro  for FD_SET includes a warning C4127: conditional expression is constant
 #pragma warning(push)
 #pragma warning(disable:4127)
 #endif
@@ -211,6 +200,13 @@ int sangoma_one_loop(struct sangoma_pri *spri)
 
        sel = select(spri->pri->fd + 1, &rfds, NULL, &efds, next ? &now : NULL);
        event = NULL;
+       
+       if (FD_ISSET(spri->pri->fd, &efds)) {
+               wanpipe_tdm_api_t tdm_api = {0};
+
+               sangoma_tdm_read_event(spri->pri->fd, &tdm_api);
+               global_logger(WP_LOG_ERROR, "DCHANNEL ERROR! [span %d]\n", spri->span);
+       }
 
        if (!sel) {
                event = pri_schedule_run(spri->pri);
index 7aed00b07e9d3b53f7264659424c2302552ae7a9..5c3512aa122283dca0f9df7d10016095d0dcef7d 100644 (file)
@@ -79,6 +79,10 @@ struct sangoma_pri {
        void *private_info;
        event_handler eventmap[MAX_EVENT + 1];
        loop_handler on_loop;
+       int dfd;
+       int swtype;
+       int node; 
+       int debug;
 };
 
 struct sangoma_pri_event_list {
index 3d51d7b815583ec3cbf1bc1912e4c8a9a2694d75..fe19e89301ea0f17914e92878ef12eb1942dd769 100644 (file)
@@ -211,6 +211,19 @@ typedef struct private_object private_object_t;
 
 
 
+static void wp_logger(char *file, const char *func, int line, int level, char *fmt, ...)
+{
+       va_list ap;
+       char *data = NULL;
+       int ret;
+
+       va_start(ap, fmt);
+       if ((ret = switch_vasprintf(&data, fmt, ap)) != -1) {
+               switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, level, "%s", data);
+       }
+       va_end(ap);
+}
+
 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];
@@ -1299,6 +1312,8 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
 {
        switch_status_t status = SWITCH_STATUS_SUCCESS;
 
+       sangoma_set_logger(wp_logger);
+
        memset(SPANS, 0, sizeof(SPANS));
 
        pri_set_error(s_pri_error);