update wanpipe
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4971 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
1ab860da40
commit
e6f778ebff
|
@ -3,7 +3,7 @@ LIBPRI_HOST=http://ftp.digium.com/pub/libpri
|
||||||
LIBPRI=libpri-1.2.4
|
LIBPRI=libpri-1.2.4
|
||||||
LIBPRI_FILE=$(LIBPRI).tar.gz
|
LIBPRI_FILE=$(LIBPRI).tar.gz
|
||||||
LIBPRI_DIR=$(BASE)/libs/$(LIBPRI)
|
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_HOST=ftp://ftp.sangoma.com/linux/custom/3.1
|
||||||
WANPIPE_FILE=$(WANPIPE).tgz
|
WANPIPE_FILE=$(WANPIPE).tgz
|
||||||
WANPIPE_DIR=$(BASE)/libs/$(WANPIPE)
|
WANPIPE_DIR=$(BASE)/libs/$(WANPIPE)
|
||||||
|
|
|
@ -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 "libsangoma.h"
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#define DFT_CARD "wanpipe1"
|
#define DFT_CARD "wanpipe1"
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
|
@ -265,6 +246,48 @@ sng_fd_t sangoma_open_tdmapi_span(int span)
|
||||||
return fd;
|
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 sangoma_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag)
|
||||||
{
|
{
|
||||||
int rx_len=0;
|
int rx_len=0;
|
||||||
|
|
|
@ -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
|
#ifndef _LIBSNAGOMA_H
|
||||||
#define _LIBSNAGOMA_H
|
#define _LIBSNAGOMA_H
|
||||||
#include <stdio.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_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);
|
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
|
#ifndef LIBSANGOMA_GET_HWCODING
|
||||||
#define LIBSANGOMA_GET_HWCODING 1
|
#define LIBSANGOMA_GET_HWCODING 1
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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 <libsangoma.h>
|
||||||
#include <sangoma_pri.h>
|
#include <sangoma_pri.h>
|
||||||
#ifndef HAVE_GETTIMEOFDAY
|
#ifndef HAVE_GETTIMEOFDAY
|
||||||
|
@ -158,6 +143,10 @@ int sangoma_init_pri(struct sangoma_pri *spri, int span, int dchan, int swtype,
|
||||||
} else {
|
} else {
|
||||||
if ((spri->pri = pri_new_cb((int) dfd, node, swtype, __pri_sangoma_read, __pri_sangoma_write, NULL))) {
|
if ((spri->pri = pri_new_cb((int) dfd, node, swtype, __pri_sangoma_read, __pri_sangoma_write, NULL))) {
|
||||||
spri->span = span;
|
spri->span = span;
|
||||||
|
spri->dchan = dchan;
|
||||||
|
spri->swtype = swtype;
|
||||||
|
spri->node = node;
|
||||||
|
spri->debug = debug;
|
||||||
pri_set_debug(spri->pri, debug);
|
pri_set_debug(spri->pri, debug);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -183,7 +172,7 @@ int sangoma_one_loop(struct sangoma_pri *spri)
|
||||||
FD_ZERO(&efds);
|
FD_ZERO(&efds);
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#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(push)
|
||||||
#pragma warning(disable:4127)
|
#pragma warning(disable:4127)
|
||||||
#endif
|
#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);
|
sel = select(spri->pri->fd + 1, &rfds, NULL, &efds, next ? &now : NULL);
|
||||||
event = 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) {
|
if (!sel) {
|
||||||
event = pri_schedule_run(spri->pri);
|
event = pri_schedule_run(spri->pri);
|
||||||
|
|
|
@ -79,6 +79,10 @@ struct sangoma_pri {
|
||||||
void *private_info;
|
void *private_info;
|
||||||
event_handler eventmap[MAX_EVENT + 1];
|
event_handler eventmap[MAX_EVENT + 1];
|
||||||
loop_handler on_loop;
|
loop_handler on_loop;
|
||||||
|
int dfd;
|
||||||
|
int swtype;
|
||||||
|
int node;
|
||||||
|
int debug;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sangoma_pri_event_list {
|
struct sangoma_pri_event_list {
|
||||||
|
|
|
@ -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)
|
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];
|
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;
|
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
|
sangoma_set_logger(wp_logger);
|
||||||
|
|
||||||
memset(SPANS, 0, sizeof(SPANS));
|
memset(SPANS, 0, sizeof(SPANS));
|
||||||
|
|
||||||
pri_set_error(s_pri_error);
|
pri_set_error(s_pri_error);
|
||||||
|
|
Loading…
Reference in New Issue