update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4902 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
7e979e7649
commit
350ed66d5d
|
@ -3,20 +3,23 @@ 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.p13
|
||||
WANPIPE=wanpipe-3.1.0.p15
|
||||
WANPIPE_HOST=ftp://ftp.sangoma.com/linux/custom/3.1
|
||||
WANPIPE_FILE=$(WANPIPE).tgz
|
||||
WANPIPE_DIR=$(BASE)/libs/$(WANPIPE)
|
||||
WANPIPE_INCLUDE=$(WANPIPE_DIR)/patches/kdrivers/include
|
||||
WANPIPE_KO=$(WANPIPE_DIR)/patches/kdrivers/src/net/wanpipe.ko
|
||||
WANPIPE_INSTALLED_KO=$(shell echo "/lib/modules/`uname -r`/kernel/drivers/net/wan/wanpipe.ko")
|
||||
LIBSANGOMA_DIR=$(WANPIPE_DIR)/api/libsangoma
|
||||
LIBSANGOMA_DIR=./libsangoma
|
||||
LOCAL_CFLAGS =-w -I$(WANPIPE_INCLUDE) -I$(LIBSANGOMA_DIR) -I/usr/local/include -I$(LIBPRI_DIR) -I/usr/src/linux/include -I. -I/usr/include
|
||||
LOCAL_CFLAGS +=-D__LINUX__ -D_REENTRANT -D_GNU_SOURCE -DAFT_A104 -DWANPIPE_TDM_API -I$(switch_srcdir)/libs/libteletone/src -D_GNUC_ -DWANPIPE_TDM_API
|
||||
LOCAL_OBJS = ss7boost_client.o $(LIBPRI_DIR)/copy_string.o $(LIBPRI_DIR)/pri.o $(LIBPRI_DIR)/q921.o $(LIBPRI_DIR)/prisched.o $(LIBPRI_DIR)/q931.o $(LIBPRI_DIR)/pri_facility.o $(LIBSANGOMA_DIR)/libsangoma.o $(LIBSANGOMA_DIR)/sangoma_pri.o
|
||||
|
||||
include $(BASE)/build/modmake.rules
|
||||
|
||||
testapp: testapp.c $(LIBSANGOMA_DIR)/libsangoma.o
|
||||
$(CC) -I$(WANPIPE_DIR)/api/lib $(CFLAGS) $(LOCAL_CFLAGS) lib_api.c testapp.c $(LIBSANGOMA_DIR)/libsangoma.o -o testapp
|
||||
|
||||
$(LIBPRI_DIR):
|
||||
$(GETLIB) $(LIBPRI_HOST) $(LIBPRI_FILE)
|
||||
|
||||
|
|
|
@ -0,0 +1,537 @@
|
|||
/*****************************************************************************
|
||||
* lib_api.c Common API library
|
||||
*
|
||||
* Author(s): Nenad Corbic <ncorbic@sangoma.com>
|
||||
*
|
||||
* Copyright: (c) 2003 Sangoma Technologies Inc.
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <linux/if_wanpipe.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <linux/if.h>
|
||||
|
||||
#include <linux/wanpipe_defines.h>
|
||||
#include <linux/wanpipe_cfg.h>
|
||||
#include <linux/wanpipe.h>
|
||||
|
||||
#include "lib_api.h"
|
||||
|
||||
#define SINGLE_CHANNEL 0x2
|
||||
#define RANGE_CHANNEL 0x1
|
||||
|
||||
|
||||
char read_enable=0;
|
||||
char write_enable=0;
|
||||
char primary_enable=0;
|
||||
int tx_cnt=1;
|
||||
int rx_cnt=0;
|
||||
int tx_size=10;
|
||||
int tx_delay=0;
|
||||
int tx_data=-1;
|
||||
int tx_ss7_type=0;
|
||||
int rx_ss7_timer=0;
|
||||
|
||||
unsigned char card_name[WAN_IFNAME_SZ];
|
||||
unsigned char if_name[WAN_IFNAME_SZ];
|
||||
|
||||
unsigned char sw_if_name[WAN_IFNAME_SZ];
|
||||
unsigned char sw_card_name[WAN_IFNAME_SZ];
|
||||
|
||||
unsigned char tx_file[WAN_IFNAME_SZ];
|
||||
unsigned char rx_file[WAN_IFNAME_SZ];
|
||||
|
||||
unsigned char daddr[TX_ADDR_STR_SZ];
|
||||
unsigned char saddr[TX_ADDR_STR_SZ];
|
||||
unsigned char udata[TX_ADDR_STR_SZ];
|
||||
|
||||
int files_used=0;
|
||||
int verbose=0;
|
||||
|
||||
int tx_connections;
|
||||
|
||||
int ds_prot=0;
|
||||
int ds_prot_opt=0;
|
||||
int ds_max_mult_cnt=0;
|
||||
unsigned int ds_active_ch=0;
|
||||
int ds_7bit_hdlc=0;
|
||||
int direction=-1;
|
||||
|
||||
int tx_channels=1;
|
||||
int cause=0;
|
||||
int diagn=0;
|
||||
|
||||
int card_cnt=0;
|
||||
int i_cnt=0;
|
||||
|
||||
unsigned long parse_active_channel(char* val);
|
||||
|
||||
int init_args(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
int c_cnt=0;
|
||||
|
||||
sprintf(daddr,"111");
|
||||
sprintf(saddr,"222");
|
||||
sprintf(udata,"C9");
|
||||
|
||||
for (i = 0; i < argc; i++){
|
||||
|
||||
if (!strcmp(argv[i],"-i")){
|
||||
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid Interface Name!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
strncpy(if_name, argv[i+1],WAN_IFNAME_SZ);
|
||||
i_cnt=1;
|
||||
|
||||
}else if (!strcmp(argv[i],"-si")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid Switch Interface Name!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
strncpy(sw_if_name, argv[i+1], WAN_IFNAME_SZ);
|
||||
|
||||
}else if (!strcmp(argv[i],"-c")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid Card Name!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
strncpy(card_name, argv[i+1], WAN_IFNAME_SZ);
|
||||
card_cnt=1;
|
||||
|
||||
}else if (!strcmp(argv[i],"-sc")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid Switch Card Name!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
strncpy(sw_card_name, argv[i+1], WAN_IFNAME_SZ);
|
||||
|
||||
}else if (!strcmp(argv[i],"-r")){
|
||||
read_enable=1;
|
||||
c_cnt=1;
|
||||
|
||||
}else if (!strcmp(argv[i],"-w")){
|
||||
write_enable=1;
|
||||
c_cnt=1;
|
||||
|
||||
}else if (!strcmp(argv[i],"-pri")){
|
||||
primary_enable=1;
|
||||
|
||||
}else if (!strcmp(argv[i],"-txcnt")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid tx cnt!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
tx_cnt = atoi(argv[i+1]);
|
||||
}else{
|
||||
printf("ERROR: Invalid tx cnt!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
}else if (!strcmp(argv[i],"-rxcnt")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid rx cnt!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
rx_cnt = atoi(argv[i+1]);
|
||||
}else{
|
||||
printf("ERROR: Invalid rx cnt!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
}else if (!strcmp(argv[i],"-txsize")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid tx size!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
tx_size = atoi(argv[i+1]);
|
||||
}else{
|
||||
printf("ERROR: Invalid tx size, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}else if (!strcmp(argv[i],"-txdelay")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid tx delay!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
tx_delay = atoi(argv[i+1]);
|
||||
}else{
|
||||
printf("ERROR: Invalid tx delay, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}else if (!strcmp(argv[i],"-txdata")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid tx data!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
tx_data = atoi(argv[i+1]);
|
||||
}else{
|
||||
printf("ERROR: Invalid tx data, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}else if (!strcmp(argv[i],"-tx_ss7_type")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid tx ss7 type!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
tx_ss7_type = atoi(argv[i+1]);
|
||||
}else{
|
||||
printf("ERROR: Invalid tx ss7 type, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
}else if (!strcmp(argv[i],"-rx_ss7_timer")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid rx ss7 timer!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
rx_ss7_timer = atoi(argv[i+1]);
|
||||
}else{
|
||||
printf("ERROR: Invalid tx ss7 type, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
}else if (!strcmp(argv[i],"-txfile")){
|
||||
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid Tx File Name!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
strncpy(tx_file, argv[i+1],WAN_IFNAME_SZ);
|
||||
files_used |= TX_FILE_USED;
|
||||
|
||||
}else if (!strcmp(argv[i],"-rxfile")){
|
||||
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid Rx File Name!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
strncpy(rx_file, argv[i+1],WAN_IFNAME_SZ);
|
||||
files_used |= RX_FILE_USED;
|
||||
|
||||
}else if (!strcmp(argv[i],"-daddr")){
|
||||
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid daddr str!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
strncpy(daddr, argv[i+1],TX_ADDR_STR_SZ);
|
||||
|
||||
}else if (!strcmp(argv[i],"-saddr")){
|
||||
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid saddr str!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
strncpy(saddr, argv[i+1],TX_ADDR_STR_SZ);
|
||||
|
||||
}else if (!strcmp(argv[i],"-udata")){
|
||||
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid udata str!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
strncpy(udata, argv[i+1],TX_ADDR_STR_SZ);
|
||||
|
||||
}else if (!strcmp(argv[i],"-verbose")){
|
||||
verbose=1;
|
||||
|
||||
}else if (!strcmp(argv[i],"-prot")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid prot!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
ds_prot = atoi(argv[i+1]);
|
||||
}else{
|
||||
printf("ERROR: Invalid prot, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
}else if (!strcmp(argv[i],"-prot_opt")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid prot_opt!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
ds_prot_opt = atoi(argv[i+1]);
|
||||
}else{
|
||||
printf("ERROR: Invalid prot_opt, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}else if (!strcmp(argv[i],"-max_mult_cnt")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid max_mult_cnt!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
ds_max_mult_cnt = atoi(argv[i+1]);
|
||||
}else{
|
||||
printf("ERROR: Invalid max_mult_cnt, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}else if (!strcmp(argv[i],"-active_ch")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid active ch!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
ds_active_ch = parse_active_channel(argv[i+1]);
|
||||
}else if (!strcmp(argv[i],"-txchan")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid channels!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
tx_channels = atoi(argv[i+1]);
|
||||
}else{
|
||||
printf("ERROR: Invalid channels, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}else if (!strcmp(argv[i],"-diagn")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid diagn!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
diagn = atoi(argv[i+1]);
|
||||
}else{
|
||||
printf("ERROR: Invalid diagn, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
}else if (!strcmp(argv[i],"-cause")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid cause!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
cause = atoi(argv[i+1]);
|
||||
}else{
|
||||
printf("ERROR: Invalid cause, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
}else if (!strcmp(argv[i],"-7bit_hdlc")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid 7bit hdlc value!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
ds_7bit_hdlc = atoi(argv[i+1]);
|
||||
}else{
|
||||
printf("ERROR: Invalid 7bit hdlc, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
}else if (!strcmp(argv[i],"-dir")){
|
||||
if (i+1 > argc-1){
|
||||
printf("ERROR: Invalid direction value!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
if(isdigit(argv[i+1][0])){
|
||||
direction = atoi(argv[i+1]);
|
||||
}else{
|
||||
printf("ERROR: Invalid direction, must be a digit!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!i_cnt){
|
||||
printf("ERROR: No Interface Name!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
if (!card_cnt){
|
||||
printf("ERROR: No Card name!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
if (!c_cnt){
|
||||
printf("ERROR: No Read or Write Command!\n");
|
||||
return WAN_FALSE;
|
||||
}
|
||||
|
||||
return WAN_TRUE;
|
||||
}
|
||||
|
||||
static unsigned char api_usage[]="\n"
|
||||
"\n"
|
||||
"<options>:\n"
|
||||
" -i <ifname> #interface name\n"
|
||||
" -c <card name> #card name\n"
|
||||
" -r #read enable\n"
|
||||
" -w #write eable\n"
|
||||
"\n"
|
||||
"<extra options>\n"
|
||||
" -txcnt <digit> #number of tx packets (Dflt: 1)\n"
|
||||
" -txsize <digit> #tx packet size (Dflt: 10)\n"
|
||||
" -txdelay <digit> #delay in sec after each tx packet (Dflt: 0)\n"
|
||||
" -txdata <digit> #data to tx <1-255>\n"
|
||||
"\n"
|
||||
" -txfile <file> #Use file to tx instead\n"
|
||||
" -rxfile <file> #Save all rx data to a file\n"
|
||||
" \n"
|
||||
"\n"
|
||||
" -tx_ss7_type <digit> # 1=FISU 2=LSSU (repeating)\n"
|
||||
" -rx_ss7_timer <digit> #Force receive timeout value \n"
|
||||
"\n"
|
||||
" -rxcnt <digit> #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"
|
||||
"<datascope options>\n"
|
||||
"\n"
|
||||
" -prot <digit> #Protocol Bit map: \n"
|
||||
" #1=FISU, 2=LSSU, 4=MSU, 8=RAW HDLC\n"
|
||||
" \n"
|
||||
" -prot_opt <digit> #Protocol bit map\n"
|
||||
" #0=None, 1=Delta, 2=Max Multiple\n"
|
||||
"\n"
|
||||
" -active_ch <digit> #Active channel\n"
|
||||
" #ALL = all channels \n"
|
||||
" #1 24 = 1 to 24 \n"
|
||||
" #1.24 = 1 and 24 \n"
|
||||
" #1-4.7-15 = 1 to 4 and 7 to 15\n"
|
||||
" \n"
|
||||
" -max_mult_cnt <digit> #If Prot_opt == 2 \n"
|
||||
" #max_mult_cnt is the number of \n"
|
||||
" #consecutive duplicate frames \n"
|
||||
" #received before pass up the stack.\n"
|
||||
" \n"
|
||||
" -7bit_hdlc <digit> #Enable 7 Bit Hdlc Engine\n"
|
||||
" #1=Enable 0=Disable\n"
|
||||
" \n"
|
||||
" -dir <digit> #Direction 0: Rx 1: Tx none: All\n"
|
||||
"\n"
|
||||
"<x25 protocol options>\n"
|
||||
"\n"
|
||||
" -txchan <digit> #Number of channels (dflt=1)\n"
|
||||
" -cause <digit> #disconnect cause (dflt=0)\n"
|
||||
" -diagn <digit> #disconnect diagnostic (dflt=0)\n"
|
||||
"\n";
|
||||
|
||||
void usage(unsigned char *api_name)
|
||||
{
|
||||
printf ("\n\nAPI %s USAGE:\n\n%s <options> <extra options>\n\n%s\n",
|
||||
api_name,api_name,api_usage);
|
||||
}
|
||||
|
||||
|
||||
/*============================================================================
|
||||
* TE1
|
||||
*/
|
||||
unsigned long get_active_channels(int channel_flag, int start_channel, int stop_channel)
|
||||
{
|
||||
int i = 0;
|
||||
unsigned long tmp = 0, mask = 0;
|
||||
|
||||
if ((channel_flag & (SINGLE_CHANNEL | RANGE_CHANNEL)) == 0)
|
||||
return tmp;
|
||||
if (channel_flag & RANGE_CHANNEL) { /* Range of channels */
|
||||
for(i = start_channel; i <= stop_channel; i++) {
|
||||
mask = 1 << (i - 1);
|
||||
tmp |=mask;
|
||||
}
|
||||
} else { /* Single channel */
|
||||
mask = 1 << (stop_channel - 1);
|
||||
tmp |= mask;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
unsigned long parse_active_channel(char* val)
|
||||
{
|
||||
int channel_flag = 0;
|
||||
char* ptr = val;
|
||||
int channel = 0, start_channel = 0;
|
||||
unsigned long tmp = 0;
|
||||
|
||||
if (strcmp(val,"ALL") == 0)
|
||||
return ENABLE_ALL_CHANNELS;
|
||||
|
||||
while(*ptr != '\0') {
|
||||
if (isdigit(*ptr)) {
|
||||
channel = strtoul(ptr, &ptr, 10);
|
||||
channel_flag |= SINGLE_CHANNEL;
|
||||
} else {
|
||||
if (*ptr == '-') {
|
||||
channel_flag |= RANGE_CHANNEL;
|
||||
start_channel = channel;
|
||||
} else {
|
||||
tmp |= get_active_channels(channel_flag, start_channel, channel);
|
||||
channel_flag = 0;
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
if (channel_flag){
|
||||
tmp |= get_active_channels(channel_flag, start_channel, channel);
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void u_delay(int usec)
|
||||
{
|
||||
struct timeval tv;
|
||||
tv.tv_usec = usec;
|
||||
tv.tv_sec=0;
|
||||
|
||||
select(0,NULL,NULL, NULL, &tv);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -34,7 +34,7 @@ typedef unsigned __int32 u_int32_t;
|
|||
#ifdef WANPIPE_TDM_API
|
||||
#include <wanpipe_tdm_api.h> //for TDMV API
|
||||
#endif
|
||||
#include <sang_status_defines.h> //return codes
|
||||
#include <sang_status_defines.h>//return codes
|
||||
#include <sang_api.h> //for IOCTL codes
|
||||
#include <sdla_te1_pmc.h> //RBS definitions
|
||||
#include <sdla_te1.h> //TE1 macros
|
||||
|
@ -94,7 +94,7 @@ sng_fd_t sangoma_create_socket_by_name(char *device, char *card);
|
|||
/* Open Span/Chan devices
|
||||
* open_tdmapi_span_chan: open device based on span chan values
|
||||
* sangoma_open_tdmapi_span: open first available device on span
|
||||
*/
|
||||
*/
|
||||
|
||||
sng_fd_t sangoma_open_tdmapi_span_chan(int span, int chan);
|
||||
sng_fd_t sangoma_open_tdmapi_span(int span);
|
||||
|
@ -104,65 +104,67 @@ sng_fd_t sangoma_open_tdmapi_span(int span);
|
|||
/* Device Rx/Tx functions
|
||||
* writemsg_tdm: tx header + data from separate buffers
|
||||
* readmsg_tdm: rx header + data to separate buffers
|
||||
*/
|
||||
int sangoma_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, unsigned short datalen, int flag);
|
||||
int sangoma_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag);
|
||||
*/
|
||||
int sangoma_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen,
|
||||
void *databuf, unsigned short datalen, int flag);
|
||||
int sangoma_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen,
|
||||
void *databuf, int datalen, int flag);
|
||||
|
||||
#define sangoma_readmsg_socket sangoma_readmsg_tdm
|
||||
#define sangoma_sendmsg_socket sangoma_writemsg_tdm
|
||||
|
||||
#ifdef WANPIPE_TDM_API
|
||||
|
||||
void sangoma_socket_close(sng_fd_t * sp);
|
||||
void sangoma_socket_close(sng_fd_t *sp);
|
||||
int sangoma_socket_waitfor(sng_fd_t fd, int timeout, int flags);
|
||||
|
||||
/* Get Full TDM API configuration per chan */
|
||||
int sangoma_get_full_cfg(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_get_full_cfg(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
|
||||
/* Get/Set TDM Codec per chan */
|
||||
int sangoma_tdm_set_codec(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int codec);
|
||||
int sangoma_tdm_get_codec(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_set_codec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int codec);
|
||||
int sangoma_tdm_get_codec(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
|
||||
/* Get/Set USR Tx/Rx Period in milliseconds */
|
||||
int sangoma_tdm_set_usr_period(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int period);
|
||||
int sangoma_tdm_get_usr_period(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_set_usr_period(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int period);
|
||||
int sangoma_tdm_get_usr_period(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
|
||||
/* Get user MTU/MRU values in bytes */
|
||||
int sangoma_tdm_get_usr_mtu_mru(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_get_usr_mtu_mru(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
|
||||
/* Not supported yet */
|
||||
int sangoma_tdm_set_power_level(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int power);
|
||||
int sangoma_tdm_get_power_level(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_set_power_level(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int power);
|
||||
int sangoma_tdm_get_power_level(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
|
||||
/* Flush buffers from current channel */
|
||||
int sangoma_tdm_flush_bufs(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_flush_bufs(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
|
||||
int sangoma_tdm_enable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, int poll_in_sec);
|
||||
int sangoma_tdm_disable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_enable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, int poll_in_sec);
|
||||
int sangoma_tdm_disable_rbs_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
|
||||
int sangoma_tdm_write_rbs(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api, unsigned char rbs);
|
||||
int sangoma_tdm_write_rbs(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api, unsigned char rbs);
|
||||
|
||||
int sangoma_tdm_read_event(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_read_event(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
|
||||
/* DTMF Detection on Octasic chip */
|
||||
int sangoma_tdm_enable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_disable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_enable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_disable_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
|
||||
/* DTMF Detection on A200 (SLIC) chip */
|
||||
int sangoma_tdm_enable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_disable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_enable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
int sangoma_tdm_disable_rm_dtmf_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
|
||||
/* On/Off hook events on A200 (Analog) card */
|
||||
int sangoma_tdm_enable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_disable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_enable_rxhook_events(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api);
|
||||
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);
|
||||
|
||||
#ifndef LIBSANGOMA_GET_HWCODING
|
||||
#define LIBSANGOMA_GET_HWCODING 1
|
||||
#endif
|
||||
int sangoma_tdm_get_hw_coding(int fd, wanpipe_tdm_api_t * tdm_api);
|
||||
int sangoma_tdm_get_hw_coding(int fd, wanpipe_tdm_api_t *tdm_api);
|
||||
|
||||
#endif /* WANPIPE_TDM_API */
|
||||
#endif /* WANPIPE_TDM_API */
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,448 @@
|
|||
/*****************************************************************************
|
||||
* aft_api.c AFT T1/E1: HDLC API Sample Code
|
||||
*
|
||||
* Author(s): Nenad Corbic <ncorbic@sangoma.com>
|
||||
*
|
||||
* Copyright: (c) 2003-2004 Sangoma Technologies Inc.
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <linux/if_wanpipe.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <linux/if.h>
|
||||
#include <linux/wanpipe_defines.h>
|
||||
#include <linux/wanpipe_cfg.h>
|
||||
#include <linux/wanpipe.h>
|
||||
#include <libsangoma.h>
|
||||
#include "lib_api.h"
|
||||
|
||||
#define MAX_TX_DATA 5000 /* Size of tx data */
|
||||
#define MAX_FRAMES 5000 /* Number of frames to transmit */
|
||||
|
||||
#define MAX_RX_DATA 5000
|
||||
|
||||
unsigned short Rx_lgth;
|
||||
|
||||
unsigned char Rx_data[MAX_RX_DATA];
|
||||
unsigned char Tx_data[MAX_TX_DATA + sizeof(wp_tdm_api_rx_hdr_t)];
|
||||
|
||||
/* Prototypes */
|
||||
int MakeConnection(void);
|
||||
void handle_span_chan( void);
|
||||
void sig_end(int sigid);
|
||||
|
||||
int dev_fd;
|
||||
FILE *tx_fd=NULL,*rx_fd=NULL;
|
||||
wanpipe_tdm_api_t tdm_api;
|
||||
|
||||
|
||||
/***************************************************
|
||||
* HANDLE SOCKET
|
||||
*
|
||||
* o Read a socket
|
||||
* o Cast data received to api_rx_element_t data type
|
||||
* o The received packet contains 16 bytes header
|
||||
*
|
||||
* ------------------------------------------
|
||||
* | 16 bytes | X bytes ...
|
||||
* ------------------------------------------
|
||||
* Header Data
|
||||
*
|
||||
* o Data structures:
|
||||
* ------------------
|
||||
* typedef struct {
|
||||
* union {
|
||||
* struct {
|
||||
* unsigned char _event_type;
|
||||
* unsigned char _rbs_rx_bits;
|
||||
* unsigned int _time_stamp;
|
||||
* }wp_event;
|
||||
* struct {
|
||||
* unsigned char _rbs_rx_bits;
|
||||
* unsigned int _time_stamp;
|
||||
* }wp_rx;
|
||||
* unsigned char reserved[16];
|
||||
* }wp_rx_hdr_u;
|
||||
* #define wp_api_event_type wp_rx_hdr_u.wp_event._event_type
|
||||
* #define wp_api_event_rbs_rx_bits wp_rx_hdr_u.wp_event._rbs_rx_bits
|
||||
* #define wp_api_event_time_stamp wp_rx_hdr_u.wp_event._time_stamp
|
||||
* } wp_tdm_api_rx_hdr_t;
|
||||
*
|
||||
* typedef struct {
|
||||
* wp_tdm_api_rx_hdr_t hdr;
|
||||
* unsigned char data[1];
|
||||
* } wp_tdm_api_rx_element_t;
|
||||
*
|
||||
* typedef struct {
|
||||
* union {
|
||||
* struct {
|
||||
* unsigned char _rbs_rx_bits;
|
||||
* unsigned int _time_stamp;
|
||||
* }wp_tx;
|
||||
* unsigned char reserved[16];
|
||||
* }wp_tx_hdr_u;
|
||||
* #define wp_api_time_stamp wp_tx_hdr_u.wp_tx._time_stamp
|
||||
* } wp_tdm_api_tx_hdr_t;
|
||||
*
|
||||
* typedef struct {
|
||||
* wp_tdm_api_tx_hdr_t hdr;
|
||||
* unsigned char data[1];
|
||||
* } wp_tdm_api_tx_element_t;
|
||||
*
|
||||
* #define WPTDM_A_BIT 0x08
|
||||
* #define WPTDM_B_BIT 0x04
|
||||
* #define WPTDM_C_BIT 0x02
|
||||
* #define WPTDM_D_BIT 0x01
|
||||
*
|
||||
*/
|
||||
|
||||
void handle_span_chan(void)
|
||||
{
|
||||
unsigned int Rx_count,Tx_count,Tx_length;
|
||||
wp_tdm_api_rx_element_t* api_rx_el;
|
||||
wp_tdm_api_tx_element_t * api_tx_el;
|
||||
fd_set ready,write,oob;
|
||||
int err,i;
|
||||
|
||||
#if 0
|
||||
int rlen;
|
||||
int stream_sync=0;
|
||||
#endif
|
||||
|
||||
Rx_count = 0;
|
||||
Tx_count = 0;
|
||||
|
||||
if (tdm_api.wp_tdm_cmd.hdlc) {
|
||||
Tx_length = tx_size;
|
||||
} else {
|
||||
Tx_length = tdm_api.wp_tdm_cmd.usr_mtu_mru;
|
||||
}
|
||||
|
||||
printf("\n\nSocket Handler: Rx=%d Tx=%i TxCnt=%i TxLen=%i TxDelay=%i\n",
|
||||
read_enable,write_enable,tx_cnt,tx_size,tx_delay);
|
||||
|
||||
/* Initialize the Tx Data buffer */
|
||||
memset(&Tx_data[0],0,MAX_TX_DATA + sizeof(wp_tdm_api_rx_hdr_t));
|
||||
|
||||
/* Cast the Tx data packet with the tx element
|
||||
* structure. We must insert a 16 byte
|
||||
* driver header, which driver will remove
|
||||
* before passing packet out the physical port */
|
||||
api_tx_el = (wp_tdm_api_tx_element_t*)&Tx_data[0];
|
||||
|
||||
|
||||
/* Create a Tx packet based on user info, or
|
||||
* by deafult incrementing number starting from 0 */
|
||||
for (i=0;i<Tx_length;i++){
|
||||
if (tx_data == -1){
|
||||
api_tx_el->data[i] = (unsigned char)i;
|
||||
}else{
|
||||
#if 0
|
||||
api_tx_el->data[i] = (unsigned char)tx_data+(i%4);
|
||||
#else
|
||||
api_tx_el->data[i] = (unsigned char)tx_data;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
sangoma_tdm_enable_rxhook_events(dev_fd, &tdm_api);
|
||||
|
||||
/* Main Rx Tx OOB routine */
|
||||
for(;;) {
|
||||
|
||||
/* Initialize all select() descriptors */
|
||||
FD_ZERO(&ready);
|
||||
FD_ZERO(&write);
|
||||
FD_ZERO(&oob);
|
||||
FD_SET(dev_fd,&oob);
|
||||
FD_SET(dev_fd,&ready);
|
||||
|
||||
if (write_enable){
|
||||
FD_SET(dev_fd,&write);
|
||||
}
|
||||
|
||||
/* Select will block, until:
|
||||
* 1: OOB event, link level change
|
||||
* 2: Rx data available
|
||||
* 3: Interface able to Tx */
|
||||
|
||||
if(select(dev_fd + 1,&ready, &write, &oob, NULL)){
|
||||
|
||||
fflush(stdout);
|
||||
if (FD_ISSET(dev_fd,&oob)){
|
||||
|
||||
/* An OOB event is pending, usually indicating
|
||||
* a link level change */
|
||||
|
||||
err=sangoma_tdm_read_event(dev_fd,&tdm_api);
|
||||
|
||||
if(err < 0 ) {
|
||||
printf("Failed to receive OOB %i , %i\n", Rx_count, err);
|
||||
err = ioctl(dev_fd,SIOC_WANPIPE_SOCK_STATE,0);
|
||||
printf("Sock state is %s\n",
|
||||
(err == 0) ? "CONNECTED" :
|
||||
(err == 1) ? "DISCONNECTED" :
|
||||
"CONNECTING");
|
||||
break;
|
||||
}
|
||||
|
||||
printf("GOT OOB EXCEPTION CMD Exiting\n");
|
||||
}
|
||||
|
||||
|
||||
if (FD_ISSET(dev_fd,&ready)){
|
||||
|
||||
/* An Rx packet is pending
|
||||
* 1: Read the rx packet into the Rx_data
|
||||
* buffer. Confirm len > 0
|
||||
*
|
||||
* 2: Cast Rx_data to the api_rx_element.
|
||||
* Thus, removing a 16 byte header
|
||||
* attached by the driver.
|
||||
*
|
||||
* 3. Check error_flag:
|
||||
* CRC,Abort..etc
|
||||
*/
|
||||
|
||||
memset(Rx_data, 0, sizeof(Rx_data));
|
||||
|
||||
err = sangoma_readmsg_tdm(dev_fd,
|
||||
Rx_data,
|
||||
sizeof(wp_tdm_api_rx_hdr_t),
|
||||
&Rx_data[sizeof(wp_tdm_api_rx_hdr_t)],
|
||||
MAX_RX_DATA, 0);
|
||||
|
||||
|
||||
if (!read_enable){
|
||||
goto bitstrm_skip_read;
|
||||
}
|
||||
|
||||
/* err indicates bytes received */
|
||||
if(err <= 0) {
|
||||
printf("\nError receiving data\n");
|
||||
break;
|
||||
}
|
||||
|
||||
api_rx_el = (wp_tdm_api_rx_element_t*)&Rx_data[0];
|
||||
|
||||
/* Check the packet length */
|
||||
Rx_lgth = err;
|
||||
if(Rx_lgth<=0) {
|
||||
printf("\nShort frame received (%d)\n",
|
||||
Rx_lgth);
|
||||
return;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (api_rx_el->data[0] == tx_data && api_rx_el->data[1] == (tx_data+1)){
|
||||
if (!stream_sync){
|
||||
printf("GOT SYNC %x\n",api_rx_el->data[0]);
|
||||
}
|
||||
stream_sync=1;
|
||||
}else{
|
||||
if (stream_sync){
|
||||
printf("OUT OF SYNC: %x\n",api_rx_el->data[0]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
++Rx_count;
|
||||
|
||||
if (verbose){
|
||||
#if 0
|
||||
printf("Received %i Length = %i\n",
|
||||
Rx_count,Rx_lgth);
|
||||
|
||||
printf("Data: ");
|
||||
for(i=0;i<Rx_lgth; i ++) {
|
||||
printf("0x%02X ", api_rx_el->data[i]);
|
||||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
}else{
|
||||
//putchar('R');
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
switch(api_rx_el->hdr.wp_api_event_type){
|
||||
case WP_TDM_EVENT_DTMF:
|
||||
printf("DTMV Event: %c (%s:%s)!\n",
|
||||
api_rx_el->hdr.wp_api_event_dtmf_digit,
|
||||
(api_rx_el->hdr.wp_api_event_dtmf_type&WP_TDM_EVENT_DTMF_ROUT)?"ROUT":"SOUT",
|
||||
(api_rx_el->hdr.wp_api_event_dtmf_type&WP_TDM_EVENT_DTMF_PRESET)?"PRESET":"STOP");
|
||||
break;
|
||||
case WP_TDM_EVENT_RXHOOK:
|
||||
printf("RXHOOK Event: %s!\n",
|
||||
(api_rx_el->hdr.wp_api_event_rxhook_state&WP_TDM_EVENT_RXHOOK_OFF)?"OFF-HOOK":"ON-HOOK");
|
||||
break;
|
||||
case WP_TDM_EVENT_RING:
|
||||
printf("RING Event: %s!\n",
|
||||
(api_rx_el->hdr.wp_api_event_ring_state&WP_TDM_EVENT_RING_PRESENT)?"PRESENT":"STOP");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (rx_cnt > 0 && Rx_count >= rx_cnt){
|
||||
break;
|
||||
}
|
||||
bitstrm_skip_read:
|
||||
;
|
||||
}
|
||||
|
||||
if (FD_ISSET(dev_fd,&write)){
|
||||
|
||||
|
||||
err = sangoma_writemsg_tdm(dev_fd,
|
||||
Tx_data,16,
|
||||
&Tx_data[16], Tx_length,
|
||||
0);
|
||||
if (err <= 0){
|
||||
if (errno == EBUSY){
|
||||
if (verbose){
|
||||
printf("Sock busy try again!\n");
|
||||
}
|
||||
/* Socket busy try sending again !*/
|
||||
}else{
|
||||
printf("Faild to send %i \n",errno);
|
||||
perror("Send: ");
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
|
||||
++Tx_count;
|
||||
|
||||
if (verbose){
|
||||
//printf("Packet sent: Sent %i : %i\n",
|
||||
// err,Tx_count);
|
||||
}else{
|
||||
//putchar('T');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tx_delay){
|
||||
usleep(tx_delay);
|
||||
}
|
||||
|
||||
if (tx_cnt && tx_size && Tx_count >= tx_cnt && !(files_used & TX_FILE_USED)){
|
||||
|
||||
write_enable=0;
|
||||
if (rx_cnt > 0){
|
||||
/* Dont break let rx finish */
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sangoma_tdm_disable_rxhook_events(dev_fd, &tdm_api);
|
||||
if (tx_fd){
|
||||
fclose(tx_fd);
|
||||
}
|
||||
if (rx_fd){
|
||||
fclose(rx_fd);
|
||||
}
|
||||
close (dev_fd);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
int rxhook_event (int fd, unsigned char state)
|
||||
{
|
||||
printf("%d: RXHOOK Event: %s!\n",
|
||||
fd, (state & WAN_EVENT_RXHOOK_OFF)?"OFF-HOOK":"ON-HOOK");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* Main:
|
||||
*
|
||||
* o Make a socket connection to the driver.
|
||||
* o Call handle_span_chan() to read the socket
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int proceed;
|
||||
|
||||
proceed=init_args(argc,argv);
|
||||
if (proceed != WAN_TRUE){
|
||||
usage(argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT,&sig_end);
|
||||
memset(&tdm_api,0,sizeof(tdm_api));
|
||||
tdm_api.wp_tdm_event.wp_rxhook_event = &rxhook_event;
|
||||
|
||||
printf("TDM RXHOOK PTR = %p\n",tdm_api.wp_tdm_event.wp_rxhook_event);
|
||||
|
||||
dev_fd =-1;
|
||||
|
||||
dev_fd = sangoma_open_tdmapi_span_chan(atoi(card_name),atoi(if_name));
|
||||
if( dev_fd < 0){
|
||||
printf("Failed to open span chan (%s:%s:%d:%d)\n",
|
||||
card_name, if_name,
|
||||
atoi(card_name),atoi(if_name));
|
||||
exit (1);
|
||||
}
|
||||
printf("HANDLING SPAN %i CHAN %i FD=%i\n",
|
||||
atoi(card_name),atoi(if_name),dev_fd);
|
||||
|
||||
sangoma_tdm_set_codec(dev_fd,&tdm_api,WP_NONE);
|
||||
sangoma_get_full_cfg(dev_fd, &tdm_api);
|
||||
|
||||
handle_span_chan();
|
||||
close(dev_fd);
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
void sig_end(int sigid)
|
||||
{
|
||||
|
||||
printf("Got Signal %i\n",sigid);
|
||||
|
||||
sangoma_tdm_disable_rxhook_events(dev_fd, &tdm_api);
|
||||
|
||||
if (tx_fd){
|
||||
fclose(tx_fd);
|
||||
}
|
||||
if (rx_fd){
|
||||
fclose(rx_fd);
|
||||
}
|
||||
|
||||
if (dev_fd){
|
||||
close (dev_fd);
|
||||
}
|
||||
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue