[Freeswitch-svn] [commit] r4971 - in freeswitch/trunk/src/mod/endpoints/mod_wanpipe: . libsangoma

Freeswitch SVN anthm at freeswitch.org
Thu Apr 19 11:34:30 EDT 2007


Author: anthm
Date: Thu Apr 19 11:34:30 2007
New Revision: 4971

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_wanpipe/Makefile
   freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.c
   freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.h
   freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.c
   freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.h
   freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c

Log:
update wanpipe

Modified: freeswitch/trunk/src/mod/endpoints/mod_wanpipe/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_wanpipe/Makefile	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_wanpipe/Makefile	Thu Apr 19 11:34:30 2007
@@ -3,7 +3,7 @@
 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)

Modified: freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.c	Thu Apr 19 11:34:30 2007
@@ -1,25 +1,6 @@
-/*****************************************************************************
- * libsangoma.c	AFT T1/E1: HDLC API Code Library
- *
- * Author(s):	Anthony Minessale II <anthmct at yahoo.com>
- *              Nenad Corbic <ncorbic at sangoma.com>
- *              David Rokhvarg <davidr at sangoma.com>
- *              Michael Jerris <mike at 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 at sangoma.com>	Ported to MS Windows 2000/XP
- * Sep 24, 2006  Michael Jerris <mike at jerris.com>		Windows port, standardize api, cleanup
- * 
- */
-
 #include "libsangoma.h"
+#include <stdarg.h>
+
 #define DFT_CARD "wanpipe1"
 
 #if defined(WIN32)
@@ -265,6 +246,48 @@
     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;

Modified: freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.h	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/libsangoma.h	Thu Apr 19 11:34:30 2007
@@ -1,18 +1,3 @@
-/*****************************************************************************
- * libsangoma.c	AFT T1/E1: HDLC API Code Library
- *
- * Author(s):	Anthony Minessale II <anthmct at yahoo.com>
- *              Nenad Corbic <ncorbic at 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_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

Modified: freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.c	Thu Apr 19 11:34:30 2007
@@ -1,18 +1,3 @@
-/*****************************************************************************
- * sangoma_pri.c libpri Sangoma integration
- *
- * Author(s):	Anthony Minessale II <anthmct at yahoo.com>
- *              Nenad Corbic <ncorbic at 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 @@
 	} 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 @@
 	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 @@
 
 	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);

Modified: freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.h	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_wanpipe/libsangoma/sangoma_pri.h	Thu Apr 19 11:34:30 2007
@@ -79,6 +79,10 @@
 	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 {

Modified: freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c	Thu Apr 19 11:34:30 2007
@@ -211,6 +211,19 @@
 
 
 
+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_status_t status = SWITCH_STATUS_SUCCESS;
 
+	sangoma_set_logger(wp_logger);
+
 	memset(SPANS, 0, sizeof(SPANS));
 
 	pri_set_error(s_pri_error);



More information about the Freeswitch-svn mailing list