no message
git-svn-id: http://voip.null.ro/svn/yate@363 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
5e54e6b0b3
commit
f998e5deeb
|
@ -24,20 +24,12 @@
|
|||
|
||||
#include <modules/libypri.h>
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#error This module is not for Windows
|
||||
#else
|
||||
|
||||
extern "C" {
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#define MSG_NOSIGNAL 0
|
||||
#define MSG_DONTWAIT 0
|
||||
#include <winioctl.h>
|
||||
#define IOCTL_WRITE 1
|
||||
#define IOCTL_READ 2
|
||||
#define IOCTL_MGMT 3
|
||||
#define IoctlWriteCommand \
|
||||
CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_WRITE, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
|
||||
#define IoctlReadCommand \
|
||||
CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_READ, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
|
||||
#else
|
||||
typedef int HANDLE;
|
||||
#define INVALID_HANDLE_VALUE (-1)
|
||||
#define __LINUX__
|
||||
|
@ -45,7 +37,6 @@ typedef int HANDLE;
|
|||
#include <linux/if.h>
|
||||
#include <linux/wanpipe.h>
|
||||
#include <linux/sdla_bitstrm.h>
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
@ -54,10 +45,8 @@ typedef int HANDLE;
|
|||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifndef _WINDOWS
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
|
||||
using namespace TelEngine;
|
||||
|
@ -144,25 +133,13 @@ INIT_PLUGIN(WpDriver);
|
|||
|
||||
static int wp_recv(HANDLE fd, void *buf, int buflen, int flags = 0)
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
int r = 0;
|
||||
if (DeviceIoControl(fd,IoctlReadCommand,0,0,buf,buflen,(LPDWORD)&r,0))
|
||||
r = 0;
|
||||
#else
|
||||
int r = ::recv(fd,buf,buflen,flags);
|
||||
#endif
|
||||
return r;
|
||||
}
|
||||
|
||||
static int wp_send(HANDLE fd, void *buf, int buflen, int flags = 0)
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
int w = 0;
|
||||
if (DeviceIoControl(fd,IoctlWriteCommand,buf,buflen,buf,buflen,(LPDWORD)&w,0))
|
||||
w = 0;
|
||||
#else
|
||||
int w = ::send(fd,buf,buflen,flags);
|
||||
#endif
|
||||
return w;
|
||||
}
|
||||
|
||||
|
@ -204,9 +181,6 @@ static int wp_write(struct pri *pri, void *buf, int buflen)
|
|||
|
||||
static bool wp_select(HANDLE fd,int samp,bool* errp = 0)
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
return (::WaitForSingleObject(fd,samp/8) == WAIT_OBJECT_0);
|
||||
#else
|
||||
fd_set rdfds;
|
||||
fd_set errfds;
|
||||
FD_ZERO(&rdfds);
|
||||
|
@ -223,18 +197,13 @@ static bool wp_select(HANDLE fd,int samp,bool* errp = 0)
|
|||
if (errp)
|
||||
*errp = FD_ISSET(fd,&errfds);
|
||||
return FD_ISSET(fd,&rdfds);
|
||||
#endif
|
||||
}
|
||||
|
||||
void wp_close(HANDLE fd)
|
||||
{
|
||||
if (fd == INVALID_HANDLE_VALUE)
|
||||
return;
|
||||
#ifdef _WINDOWS
|
||||
::CloseHandle(fd);
|
||||
#else
|
||||
::close(fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
static HANDLE wp_open(const char* card, const char* device)
|
||||
|
@ -242,23 +211,6 @@ static HANDLE wp_open(const char* card, const char* device)
|
|||
DDebug(DebugAll,"wp_open('%s','%s')",card,device);
|
||||
if (null(card) || null(device))
|
||||
return INVALID_HANDLE_VALUE;
|
||||
#ifdef _WINDOWS
|
||||
String devname("\\\\.\\");
|
||||
devname << card << "_" << device;
|
||||
HANDLE fd = ::CreateFile(
|
||||
devname,
|
||||
GENERIC_READ|GENERIC_WRITE,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE,
|
||||
0,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_NO_BUFFERING|FILE_FLAG_WRITE_THROUGH,
|
||||
0);
|
||||
if (fd == INVALID_HANDLE_VALUE) {
|
||||
Debug(DebugGoOn,"Wanpipe failed to open device '%s': error %d: %s",
|
||||
devname.c_str(),errno,::strerror(errno));
|
||||
return fd;
|
||||
}
|
||||
#else
|
||||
HANDLE fd = ::socket(AF_WANPIPE, SOCK_RAW, 0);
|
||||
if (fd == INVALID_HANDLE_VALUE) {
|
||||
Debug(DebugGoOn,"Wanpipe failed to create socket: error %d: %s",
|
||||
|
@ -278,7 +230,6 @@ static HANDLE wp_open(const char* card, const char* device)
|
|||
wp_close(fd);
|
||||
fd = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
#endif
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
@ -485,22 +436,14 @@ PriSpan* WpDriver::createSpan(PriDriver* driver, int span, int first, int chans,
|
|||
card << "wanpipe" << span;
|
||||
card = cfg.getValue(sect,"card",card);
|
||||
String dev;
|
||||
#ifdef _WINDOWS
|
||||
dev = "if1";
|
||||
#else
|
||||
dev << "w" << span << "g2";
|
||||
#endif
|
||||
pri* p = wp_create(card,cfg.getValue(sect,"dgroup",dev),netType,swType);
|
||||
if (!p)
|
||||
return 0;
|
||||
WpSpan *ps = new WpSpan(p,driver,span,first,chans,dchan,cfg,sect,(HANDLE)::pri_fd(p));
|
||||
ps->startup();
|
||||
#ifdef _WINDOWS
|
||||
dev = "if0";
|
||||
#else
|
||||
dev.clear();
|
||||
dev << "w" << span << "g1";
|
||||
#endif
|
||||
WpData* dat = new WpData(ps,card,cfg.getValue(sect,"bgroup",dev));
|
||||
dat->startup();
|
||||
return ps;
|
||||
|
@ -529,4 +472,6 @@ void WpDriver::initialize()
|
|||
init("wpchan");
|
||||
}
|
||||
|
||||
#endif /* _WINDOWS */
|
||||
|
||||
/* vi: set ts=8 sw=4 sts=4 noet: */
|
||||
|
|
|
@ -0,0 +1,461 @@
|
|||
/**
|
||||
* wpchan.cpp
|
||||
* This file is part of the YATE Project http://YATE.null.ro
|
||||
*
|
||||
* Wanpipe PRI cards telephony driver
|
||||
*
|
||||
* Yet Another Telephony Engine - a fully featured software PBX and IVR
|
||||
* Copyright (C) 2004, 2005 Null Team
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <modules/libypri.h>
|
||||
|
||||
#ifndef _WINDOWS
|
||||
#error This module is only for Windows
|
||||
#else
|
||||
|
||||
extern "C" {
|
||||
|
||||
#define MSG_NOSIGNAL 0
|
||||
#define MSG_DONTWAIT 0
|
||||
#include <winioctl.h>
|
||||
#define IOCTL_WRITE 1
|
||||
#define IOCTL_READ 2
|
||||
#define IOCTL_MGMT 3
|
||||
#define IoctlWriteCommand \
|
||||
CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_WRITE, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
|
||||
#define IoctlReadCommand \
|
||||
CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_READ, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
|
||||
|
||||
};
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
||||
using namespace TelEngine;
|
||||
|
||||
class WpChan;
|
||||
|
||||
class WpSpan : public PriSpan, public Thread
|
||||
{
|
||||
friend class WpData;
|
||||
friend class WpDriver;
|
||||
public:
|
||||
virtual ~WpSpan();
|
||||
virtual void run();
|
||||
|
||||
private:
|
||||
WpSpan(struct pri *_pri, PriDriver* driver, int span, int first, int chans, int dchan, Configuration& cfg, const String& sect, HANDLE fd);
|
||||
HANDLE m_fd;
|
||||
WpData *m_data;
|
||||
};
|
||||
|
||||
class WpSource : public PriSource
|
||||
{
|
||||
public:
|
||||
WpSource(WpChan *owner, const char* format, unsigned int bufsize);
|
||||
~WpSource();
|
||||
void put(unsigned char val);
|
||||
|
||||
private:
|
||||
unsigned int m_bufpos;
|
||||
};
|
||||
|
||||
class WpConsumer : public PriConsumer, public Fifo
|
||||
{
|
||||
public:
|
||||
WpConsumer(WpChan *owner, const char* format, unsigned int bufsize);
|
||||
~WpConsumer();
|
||||
|
||||
virtual void Consume(const DataBlock &data, unsigned long timeDelta);
|
||||
};
|
||||
|
||||
class WpChan : public PriChan
|
||||
{
|
||||
friend class WpSource;
|
||||
friend class WpConsumer;
|
||||
friend class WpData;
|
||||
public:
|
||||
WpChan(const PriSpan *parent, int chan, unsigned int bufsize);
|
||||
virtual ~WpChan();
|
||||
virtual bool openData(const char* format, int echoTaps);
|
||||
|
||||
private:
|
||||
WpSource* m_wp_s;
|
||||
WpConsumer* m_wp_c;
|
||||
};
|
||||
|
||||
class WpData : public Thread
|
||||
{
|
||||
public:
|
||||
WpData(WpSpan* span, const char* card, const char* device);
|
||||
~WpData();
|
||||
virtual void run();
|
||||
private:
|
||||
WpSpan* m_span;
|
||||
HANDLE m_fd;
|
||||
unsigned char* m_buffer;
|
||||
WpChan **m_chans;
|
||||
};
|
||||
|
||||
class WpDriver : public PriDriver
|
||||
{
|
||||
friend class PriSpan;
|
||||
friend class WpHandler;
|
||||
public:
|
||||
WpDriver();
|
||||
virtual ~WpDriver();
|
||||
virtual void initialize();
|
||||
virtual PriSpan* createSpan(PriDriver* driver, int span, int first, int chans, Configuration& cfg, const String& sect);
|
||||
virtual PriChan* createChan(const PriSpan* span, int chan, unsigned int bufsize);
|
||||
};
|
||||
|
||||
INIT_PLUGIN(WpDriver);
|
||||
|
||||
#define WP_HEADER 16
|
||||
|
||||
static int wp_recv(HANDLE fd, void *buf, int buflen, int flags = 0)
|
||||
{
|
||||
int r = 0;
|
||||
if (DeviceIoControl(fd,IoctlReadCommand,0,0,buf,buflen,(LPDWORD)&r,0))
|
||||
r = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
static int wp_send(HANDLE fd, void *buf, int buflen, int flags = 0)
|
||||
{
|
||||
int w = 0;
|
||||
if (DeviceIoControl(fd,IoctlWriteCommand,buf,buflen,buf,buflen,(LPDWORD)&w,0))
|
||||
w = 0;
|
||||
return w;
|
||||
}
|
||||
|
||||
static int wp_read(struct pri *pri, void *buf, int buflen)
|
||||
{
|
||||
buflen -= 2;
|
||||
int sz = buflen+WP_HEADER;
|
||||
char *tmp = (char*)::calloc(sz,1);
|
||||
XDebug("wp_read",DebugAll,"pre buf=%p len=%d tmp=%p sz=%d",buf,buflen,tmp,sz);
|
||||
int r = wp_recv((HANDLE)::pri_fd(pri),tmp,sz,MSG_NOSIGNAL);
|
||||
XDebug("wp_read",DebugAll,"post r=%d",r);
|
||||
if (r > 0) {
|
||||
r -= WP_HEADER;
|
||||
if ((r > 0) && (r <= buflen)) {
|
||||
::memcpy(buf,tmp+WP_HEADER,r);
|
||||
r += 2;
|
||||
}
|
||||
}
|
||||
::free(tmp);
|
||||
return r;
|
||||
}
|
||||
|
||||
static int wp_write(struct pri *pri, void *buf, int buflen)
|
||||
{
|
||||
buflen -= 2;
|
||||
int sz = buflen+WP_HEADER;
|
||||
char *tmp = (char*)::calloc(sz,1);
|
||||
::memcpy(tmp+WP_HEADER,buf,buflen);
|
||||
XDebug("wp_write",DebugAll,"pre buf=%p len=%d tmp=%p sz=%d",buf,buflen,tmp,sz);
|
||||
int w = wp_send((HANDLE)::pri_fd(pri),tmp,sz,0);
|
||||
XDebug("wp_write",DebugAll,"post w=%d",w);
|
||||
if (w > 0) {
|
||||
w -= WP_HEADER;
|
||||
w += 2;
|
||||
}
|
||||
::free(tmp);
|
||||
return w;
|
||||
}
|
||||
|
||||
static bool wp_select(HANDLE fd,int samp,bool* errp = 0)
|
||||
{
|
||||
return (::WaitForSingleObject(fd,samp/8) == WAIT_OBJECT_0);
|
||||
}
|
||||
|
||||
void wp_close(HANDLE fd)
|
||||
{
|
||||
if (fd == INVALID_HANDLE_VALUE)
|
||||
return;
|
||||
::CloseHandle(fd);
|
||||
}
|
||||
|
||||
static HANDLE wp_open(const char* card, const char* device)
|
||||
{
|
||||
DDebug(DebugAll,"wp_open('%s','%s')",card,device);
|
||||
if (null(card) || null(device))
|
||||
return INVALID_HANDLE_VALUE;
|
||||
String devname("\\\\.\\");
|
||||
devname << card << "_" << device;
|
||||
HANDLE fd = ::CreateFile(
|
||||
devname,
|
||||
GENERIC_READ|GENERIC_WRITE,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE,
|
||||
0,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_NO_BUFFERING|FILE_FLAG_WRITE_THROUGH,
|
||||
0);
|
||||
if (fd == INVALID_HANDLE_VALUE) {
|
||||
Debug(DebugGoOn,"Wanpipe failed to open device '%s': error %d: %s",
|
||||
devname.c_str(),errno,::strerror(errno));
|
||||
return fd;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
static struct pri* wp_create(const char* card, const char* device, int nettype, int swtype)
|
||||
{
|
||||
DDebug(DebugAll,"wp_create('%s','%s',%d,%d)",card,device,nettype,swtype);
|
||||
HANDLE fd = wp_open(card,device);
|
||||
if (fd == INVALID_HANDLE_VALUE)
|
||||
return 0;
|
||||
struct pri* p = ::pri_new_cb((int)fd, nettype, swtype, wp_read, wp_write, 0);
|
||||
if (!p)
|
||||
wp_close(fd);
|
||||
return p;
|
||||
}
|
||||
|
||||
WpSpan::WpSpan(struct pri *_pri, PriDriver* driver, int span, int first, int chans, int dchan, Configuration& cfg, const String& sect, HANDLE fd)
|
||||
: PriSpan(_pri,driver,span,first,chans,dchan,cfg,sect), Thread("WpSpan"),
|
||||
m_fd(fd), m_data(0)
|
||||
{
|
||||
Debug(&__plugin,DebugAll,"WpSpan::WpSpan() [%p]",this);
|
||||
}
|
||||
|
||||
WpSpan::~WpSpan()
|
||||
{
|
||||
Debug(&__plugin,DebugAll,"WpSpan::~WpSpan() [%p]",this);
|
||||
m_ok = false;
|
||||
delete m_data;
|
||||
wp_close(m_fd);
|
||||
m_fd = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
void WpSpan::run()
|
||||
{
|
||||
Debug(&__plugin,DebugAll,"WpSpan::run() [%p]",this);
|
||||
for (;;) {
|
||||
bool rd = wp_select(m_fd,5); // 5 bytes per smallest q921 frame
|
||||
Thread::check();
|
||||
runEvent(!rd);
|
||||
}
|
||||
}
|
||||
|
||||
WpSource::WpSource(WpChan *owner, const char* format, unsigned int bufsize)
|
||||
: PriSource(owner,format,bufsize),
|
||||
m_bufpos(0)
|
||||
{
|
||||
Debug(m_owner,DebugAll,"WpSource::WpSource(%p) [%p]",owner,this);
|
||||
static_cast<WpChan*>(m_owner)->m_wp_s = this;
|
||||
}
|
||||
|
||||
WpSource::~WpSource()
|
||||
{
|
||||
Debug(m_owner,DebugAll,"WpSource::~WpSource() [%p]",this);
|
||||
static_cast<WpChan*>(m_owner)->m_wp_s = 0;
|
||||
}
|
||||
|
||||
void WpSource::put(unsigned char val)
|
||||
{
|
||||
((char*)m_buffer.data())[m_bufpos] = val;
|
||||
if (++m_bufpos >= m_buffer.length()) {
|
||||
m_bufpos = 0;
|
||||
Forward(m_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
WpConsumer::WpConsumer(WpChan *owner, const char* format, unsigned int bufsize)
|
||||
: PriConsumer(owner,format,bufsize), Fifo(2*bufsize)
|
||||
{
|
||||
Debug(m_owner,DebugAll,"WpConsumer::WpConsumer(%p) [%p]",owner,this);
|
||||
static_cast<WpChan*>(m_owner)->m_wp_c = this;
|
||||
}
|
||||
|
||||
WpConsumer::~WpConsumer()
|
||||
{
|
||||
Debug(m_owner,DebugAll,"WpConsumer::~WpConsumer() [%p]",this);
|
||||
static_cast<WpChan*>(m_owner)->m_wp_c = 0;
|
||||
}
|
||||
|
||||
void WpConsumer::Consume(const DataBlock &data, unsigned long timeDelta)
|
||||
{
|
||||
const unsigned char* buf = (const unsigned char*)data.data();
|
||||
for (unsigned int i = 0; i < data.length(); i++)
|
||||
put(buf[i]);
|
||||
}
|
||||
|
||||
WpData::WpData(WpSpan* span, const char* card, const char* device)
|
||||
: Thread("WpData"), m_span(span), m_fd(INVALID_HANDLE_VALUE), m_buffer(0), m_chans(0)
|
||||
{
|
||||
Debug(&__plugin,DebugAll,"WpData::WpData(%p) [%p]",span,this);
|
||||
HANDLE fd = wp_open(card,device);
|
||||
if (fd != INVALID_HANDLE_VALUE) {
|
||||
m_fd = fd;
|
||||
m_span->m_data = this;
|
||||
}
|
||||
}
|
||||
|
||||
WpData::~WpData()
|
||||
{
|
||||
Debug(&__plugin,DebugAll,"WpData::~WpData() [%p]",this);
|
||||
m_span->m_data = 0;
|
||||
wp_close(m_fd);
|
||||
m_fd = INVALID_HANDLE_VALUE;
|
||||
if (m_buffer)
|
||||
::free(m_buffer);
|
||||
if (m_chans)
|
||||
delete[] m_chans;
|
||||
}
|
||||
|
||||
void WpData::run()
|
||||
{
|
||||
Debug(&__plugin,DebugAll,"WpData::run() [%p]",this);
|
||||
int samp = 50;
|
||||
int bchans = m_span->bchans();
|
||||
int buflen = samp*bchans;
|
||||
int sz = buflen+WP_HEADER;
|
||||
m_buffer = (unsigned char*)::malloc(sz);
|
||||
// Build a compacted list of allocated B channels
|
||||
m_chans = new WpChan* [bchans];
|
||||
int b = 0;
|
||||
for (int n = 0; n < bchans; n++) {
|
||||
while (!m_span->m_chans[b])
|
||||
b++;
|
||||
m_chans[n] = static_cast<WpChan*>(m_span->m_chans[b++]);
|
||||
DDebug(&__plugin,DebugInfo,"wpdata ch[%d]=%d (%p)",n,m_chans[n]->chan(),m_chans[n]);
|
||||
}
|
||||
while (m_span && (m_fd >= 0)) {
|
||||
Thread::check();
|
||||
bool oob = false;
|
||||
bool rd = wp_select(m_fd,samp,&oob);
|
||||
if (oob) {
|
||||
DDebug("wpdata_recv_oob",DebugAll,"pre buf=%p len=%d sz=%d",m_buffer,buflen,sz);
|
||||
int r = wp_recv(m_fd,m_buffer,sz,MSG_OOB);
|
||||
DDebug("wpdata_recv_oob",DebugAll,"post r=%d",r);
|
||||
}
|
||||
|
||||
if (rd) {
|
||||
XDebug("wpdata_recv",DebugAll,"pre buf=%p len=%d sz=%d",m_buffer,buflen,sz);
|
||||
int r = wp_recv(m_fd,m_buffer,sz,0/*MSG_NOSIGNAL*/);
|
||||
XDebug("wpdata_recv",DebugAll,"post r=%d",r);
|
||||
r -= WP_HEADER;
|
||||
// We should have read N bytes for each B channel
|
||||
if ((r > 0) && ((r % bchans) == 0)) {
|
||||
r /= bchans;
|
||||
const unsigned char* dat = m_buffer + WP_HEADER;
|
||||
m_span->lock();
|
||||
for (int n = r; n > 0; n--)
|
||||
for (b = 0; b < bchans; b++) {
|
||||
WpSource *s = m_chans[b]->m_wp_s;
|
||||
if (s)
|
||||
s->put(PriDriver::bitswap(*dat));
|
||||
dat++;
|
||||
}
|
||||
m_span->unlock();
|
||||
}
|
||||
int w = samp;
|
||||
::memset(m_buffer,0,WP_HEADER);
|
||||
unsigned char* dat = m_buffer + WP_HEADER;
|
||||
m_span->lock();
|
||||
for (int n = w; n > 0; n--) {
|
||||
for (b = 0; b < bchans; b++) {
|
||||
WpConsumer *c = m_chans[b]->m_wp_c;
|
||||
*dat++ = PriDriver::bitswap(c ? c->get() : 0xff);
|
||||
}
|
||||
}
|
||||
m_span->unlock();
|
||||
w = (w * bchans) + WP_HEADER;
|
||||
XDebug("wpdata_send",DebugAll,"pre buf=%p len=%d sz=%d",m_buffer,w,sz);
|
||||
w = wp_send(m_fd,m_buffer,w,MSG_DONTWAIT);
|
||||
XDebug("wpdata_send",DebugAll,"post w=%d",w);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WpChan::WpChan(const PriSpan *parent, int chan, unsigned int bufsize)
|
||||
: PriChan(parent,chan,bufsize), m_wp_s(0), m_wp_c(0)
|
||||
{
|
||||
}
|
||||
|
||||
WpChan::~WpChan()
|
||||
{
|
||||
closeData();
|
||||
}
|
||||
|
||||
bool WpChan::openData(const char* format, int echoTaps)
|
||||
{
|
||||
if (echoTaps)
|
||||
Debug(DebugWarn,"Echo cancellation requested but not available in wanpipe");
|
||||
m_span->lock();
|
||||
setSource(new WpSource(this,format,m_bufsize));
|
||||
getSource()->deref();
|
||||
setConsumer(new WpConsumer(this,format,m_bufsize));
|
||||
getConsumer()->deref();
|
||||
m_span->unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
PriSpan* WpDriver::createSpan(PriDriver* driver, int span, int first, int chans, Configuration& cfg, const String& sect)
|
||||
{
|
||||
Debug(this,DebugAll,"WpDriver::createSpan(%p,%d,%d,%d) [%p]",driver,span,first,chans,this);
|
||||
int netType = -1;
|
||||
int swType = -1;
|
||||
int dchan = -1;
|
||||
netParams(cfg,sect,chans,&netType,&swType,&dchan);
|
||||
String card;
|
||||
card << "wanpipe" << span;
|
||||
card = cfg.getValue(sect,"card",card);
|
||||
String dev;
|
||||
dev = "if1";
|
||||
pri* p = wp_create(card,cfg.getValue(sect,"dgroup",dev),netType,swType);
|
||||
if (!p)
|
||||
return 0;
|
||||
WpSpan *ps = new WpSpan(p,driver,span,first,chans,dchan,cfg,sect,(HANDLE)::pri_fd(p));
|
||||
ps->startup();
|
||||
dev = "if0";
|
||||
WpData* dat = new WpData(ps,card,cfg.getValue(sect,"bgroup",dev));
|
||||
dat->startup();
|
||||
return ps;
|
||||
}
|
||||
|
||||
PriChan* WpDriver::createChan(const PriSpan* span, int chan, unsigned int bufsize)
|
||||
{
|
||||
Debug(this,DebugAll,"WpDriver::createChan(%p,%d,%u) [%p]",span,chan,bufsize,this);
|
||||
return new WpChan(span,chan,bufsize);
|
||||
}
|
||||
|
||||
WpDriver::WpDriver()
|
||||
: PriDriver("wp")
|
||||
{
|
||||
Output("Loaded module Wanpipe");
|
||||
}
|
||||
|
||||
WpDriver::~WpDriver()
|
||||
{
|
||||
Output("Unloading module Wanpipe");
|
||||
}
|
||||
|
||||
void WpDriver::initialize()
|
||||
{
|
||||
Output("Initializing module Wanpipe");
|
||||
init("wpchan");
|
||||
}
|
||||
|
||||
#endif /* _WINDOWS */
|
||||
|
||||
/* vi: set ts=8 sw=4 sts=4 noet: */
|
|
@ -0,0 +1,109 @@
|
|||
# Microsoft Developer Studio Project File - Name="Console" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=Console - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Console.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Console.mak" CFG="Console - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Console - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "Console - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Console - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I ".." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib /nologo /subsystem:console /machine:I386 /out:"Release/yate-console.exe"
|
||||
# SUBTRACT LINK32 /incremental:yes
|
||||
|
||||
!ELSEIF "$(CFG)" == "Console - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "." /I ".." /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"Debug/yate-console.exe" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Console - Win32 Release"
|
||||
# Name "Console - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\main.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\version.rc
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
|
@ -18,6 +18,21 @@ Package=<4>
|
|||
|
||||
###############################################################################
|
||||
|
||||
Project: "Console"=.\Console.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name Libyate
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Contrib"=.\Contrib.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
|
@ -146,6 +161,9 @@ Package=<4>
|
|||
Begin Project Dependency
|
||||
Project_Dep_Name Service
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name Console
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
|
|
@ -95,7 +95,7 @@ LINK32=link.exe
|
|||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\modules\wpchan.cpp
|
||||
SOURCE=..\modules\wpchanw.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
|
Loading…
Reference in New Issue