tmp
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@277 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
parent
d71231f075
commit
c406e3eadc
|
@ -131,13 +131,13 @@ struct zt_chanconfig {
|
||||||
char netdev_name[16]; /* name for the hdlc network device */
|
char netdev_name[16]; /* name for the hdlc network device */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct zt_bufferinfo {
|
struct zt_bufferinfo {
|
||||||
/* used in ZT_SET_BUFINFO and ZT_GET_BUFINFO */
|
/* used in ZT_SET_BUFINFO and ZT_GET_BUFINFO */
|
||||||
int txbufpolicy; /* Policy for handling receive buffers */
|
int txbufpolicy; /* Policy for handling receive buffers */
|
||||||
int rxbufpolicy; /* Policy for handling receive buffers */
|
int rxbufpolicy; /* Policy for handling receive buffers */
|
||||||
int numbufs; /* How many buffers to use */
|
int numbufs; /* How many buffers to use */
|
||||||
int bufsize; /* How big each buffer is */
|
int bufsize; /* How big each buffer is */
|
||||||
int readbufs; /* How many read buffers are full (read-only) */
|
int readbufs; /* How many read buffers are full (read-only) */
|
||||||
int writebufs; /* How many write buffers are full (read-only) */
|
int writebufs; /* How many write buffers are full (read-only) */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -250,8 +250,8 @@ ZT_SIG_EM = (1 << 6) /* E&M */
|
||||||
#define ZT_SETGAINS _IOWR (ZT_CODE, 17, struct zt_gains) /* Set Channel audio gains */
|
#define ZT_SETGAINS _IOWR (ZT_CODE, 17, struct zt_gains) /* Set Channel audio gains */
|
||||||
#define ZT_SPANCONFIG _IOW (ZT_CODE, 18, struct zt_lineconfig)/* Set Line (T1) Configurations and start system */
|
#define ZT_SPANCONFIG _IOW (ZT_CODE, 18, struct zt_lineconfig)/* Set Line (T1) Configurations and start system */
|
||||||
#define ZT_CHANCONFIG _IOW (ZT_CODE, 19, struct zt_chanconfig)/* Set Channel Configuration */
|
#define ZT_CHANCONFIG _IOW (ZT_CODE, 19, struct zt_chanconfig)/* Set Channel Configuration */
|
||||||
#define ZT_SET_BUFINFO _IOW (ZT_CODE, 27, struct zt_bufferinfo)/* Set buffer policy */
|
#define ZT_SET_BUFINFO _IOW (ZT_CODE, 27, struct zt_bufferinfo)/* Set buffer policy */
|
||||||
#define ZT_GET_BUFINFO _IOR (ZT_CODE, 28, struct zt_bufferinfo)/* Get current buffer info */
|
#define ZT_GET_BUFINFO _IOR (ZT_CODE, 28, struct zt_bufferinfo)/* Get current buffer info */
|
||||||
#define ZT_AUDIOMODE _IOW (ZT_CODE, 32, int) /* Set a clear channel into audio mode */
|
#define ZT_AUDIOMODE _IOW (ZT_CODE, 32, int) /* Set a clear channel into audio mode */
|
||||||
#define ZT_ECHOCANCEL _IOW (ZT_CODE, 33, int) /* Control Echo Canceller */
|
#define ZT_ECHOCANCEL _IOW (ZT_CODE, 33, int) /* Control Echo Canceller */
|
||||||
#define ZT_HDLCRAWMODE _IOW (ZT_CODE, 36, int) /* Set a clear channel into HDLC w/out FCS checking/calculation mode */
|
#define ZT_HDLCRAWMODE _IOW (ZT_CODE, 36, int) /* Set a clear channel into HDLC w/out FCS checking/calculation mode */
|
||||||
|
|
|
@ -1695,6 +1695,7 @@ static zap_status_t load_config(void)
|
||||||
|
|
||||||
if (zap_span_create(zio, &span) == ZAP_SUCCESS) {
|
if (zap_span_create(zio, &span) == ZAP_SUCCESS) {
|
||||||
zap_log(ZAP_LOG_DEBUG, "created span %d of type %s\n", span->span_id, type);
|
zap_log(ZAP_LOG_DEBUG, "created span %d of type %s\n", span->span_id, type);
|
||||||
|
d = 0;
|
||||||
} else {
|
} else {
|
||||||
zap_log(ZAP_LOG_CRIT, "failure creating span of type %s\n", type);
|
zap_log(ZAP_LOG_CRIT, "failure creating span of type %s\n", type);
|
||||||
span = NULL;
|
span = NULL;
|
||||||
|
|
|
@ -441,13 +441,13 @@ static void *zap_isdn_run(zap_thread_t *me, void *obj)
|
||||||
if (flags & ZAP_READ) {
|
if (flags & ZAP_READ) {
|
||||||
len = sizeof(buf);
|
len = sizeof(buf);
|
||||||
if (zap_channel_read(data->dchan, buf, &len) == ZAP_SUCCESS) {
|
if (zap_channel_read(data->dchan, buf, &len) == ZAP_SUCCESS) {
|
||||||
#ifdef IODEBUG
|
//#ifdef IODEBUG
|
||||||
//char bb[4096] = "";
|
char bb[4096] = "";
|
||||||
//print_hex_bytes(buf, len, bb, sizeof(bb));
|
print_hex_bytes(buf, len, bb, sizeof(bb));
|
||||||
|
|
||||||
//print_bits(buf, (int)len, bb, sizeof(bb), ZAP_ENDIAN_LITTLE, 0);
|
print_bits(buf, (int)len, bb, sizeof(bb), ZAP_ENDIAN_LITTLE, 0);
|
||||||
//zap_log(ZAP_LOG_DEBUG, "READ %d\n%s\n%s\n\n", (int)len, LINE, bb);
|
zap_log(ZAP_LOG_DEBUG, "READ %d\n%s\n%s\n\n", (int)len, LINE, bb);
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
Q921QueueHDLCFrame(&data->q921, buf, (int)len);
|
Q921QueueHDLCFrame(&data->q921, buf, (int)len);
|
||||||
Q921Rx12(&data->q921);
|
Q921Rx12(&data->q921);
|
||||||
|
|
|
@ -49,7 +49,7 @@ static unsigned zt_open_range(zap_span_t *span, unsigned start, unsigned end, za
|
||||||
{
|
{
|
||||||
unsigned configured = 0, x;
|
unsigned configured = 0, x;
|
||||||
const char ctlpath[] = "/dev/zap/ctl";
|
const char ctlpath[] = "/dev/zap/ctl";
|
||||||
char path[128] = "";
|
char path[] = "/dev/zap/channel";
|
||||||
zt_params_t ztp;
|
zt_params_t ztp;
|
||||||
zap_socket_t ctlfd = ZT_INVALID_SOCKET;
|
zap_socket_t ctlfd = ZT_INVALID_SOCKET;
|
||||||
|
|
||||||
|
@ -66,10 +66,12 @@ static unsigned zt_open_range(zap_span_t *span, unsigned start, unsigned end, za
|
||||||
zap_socket_t sockfd = ZT_INVALID_SOCKET;
|
zap_socket_t sockfd = ZT_INVALID_SOCKET;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "/dev/zap/%d", x);
|
//snprintf(path, sizeof(path), "/dev/zap/%d", x);
|
||||||
sockfd = open(path, O_RDWR);
|
sockfd = open(path, O_RDWR);
|
||||||
|
|
||||||
if (sockfd != ZT_INVALID_SOCKET && zap_span_add_channel(span, sockfd, type, &chan) == ZAP_SUCCESS) {
|
if (sockfd != ZT_INVALID_SOCKET && zap_span_add_channel(span, sockfd, type, &chan) == ZAP_SUCCESS) {
|
||||||
|
ioctl(sockfd, ZT_SPECIFY, &x);
|
||||||
|
|
||||||
if (type == ZAP_CHAN_TYPE_FXS || type == ZAP_CHAN_TYPE_FXO) {
|
if (type == ZAP_CHAN_TYPE_FXS || type == ZAP_CHAN_TYPE_FXO) {
|
||||||
struct zt_chanconfig cc;
|
struct zt_chanconfig cc;
|
||||||
memset(&cc, 0, sizeof(cc));
|
memset(&cc, 0, sizeof(cc));
|
||||||
|
@ -118,29 +120,31 @@ static unsigned zt_open_range(zap_span_t *span, unsigned start, unsigned end, za
|
||||||
close(sockfd);
|
close(sockfd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
len = zt_globals.eclevel;
|
||||||
|
if (ioctl(chan->sockfd, ZT_ECHOCANCEL, &len)) {
|
||||||
|
zap_log(ZAP_LOG_INFO, "failure configuring device %s as OpenZAP device %d:%d fd:%d err:%s\n",
|
||||||
|
path, chan->span_id, chan->chan_id, sockfd, strerror(errno));
|
||||||
|
close(sockfd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
len = zt_globals.eclevel;
|
if (chan->type != ZAP_CHAN_TYPE_DQ921 && chan->type != ZAP_CHAN_TYPE_DQ931) {
|
||||||
if (ioctl(chan->sockfd, ZT_ECHOCANCEL, &len)) {
|
len = zt_globals.codec_ms * 8;
|
||||||
zap_log(ZAP_LOG_INFO, "failure configuring device %s as OpenZAP device %d:%d fd:%d err:%s\n",
|
if (ioctl(chan->sockfd, ZT_SET_BLOCKSIZE, &len)) {
|
||||||
path, chan->span_id, chan->chan_id, sockfd, strerror(errno));
|
zap_log(ZAP_LOG_INFO, "failure configuring device %s as OpenZAP device %d:%d fd:%d err:%s\n",
|
||||||
close(sockfd);
|
path, chan->span_id, chan->chan_id, sockfd, strerror(errno));
|
||||||
continue;
|
close(sockfd);
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
len = zt_globals.codec_ms * 8;
|
|
||||||
if (ioctl(chan->sockfd, ZT_SET_BLOCKSIZE, &len)) {
|
|
||||||
zap_log(ZAP_LOG_INFO, "failure configuring device %s as OpenZAP device %d:%d fd:%d err:%s\n",
|
|
||||||
path, chan->span_id, chan->chan_id, sockfd, strerror(errno));
|
|
||||||
close(sockfd);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
chan->packet_len = len;
|
chan->packet_len = len;
|
||||||
chan->effective_interval = chan->native_interval = chan->packet_len / 8;
|
chan->effective_interval = chan->native_interval = chan->packet_len / 8;
|
||||||
|
|
||||||
if (chan->effective_codec == ZAP_CODEC_SLIN) {
|
if (chan->effective_codec == ZAP_CODEC_SLIN) {
|
||||||
chan->packet_len *= 2;
|
chan->packet_len *= 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(sockfd, ZT_GET_PARAMS, &ztp) < 0) {
|
if (ioctl(sockfd, ZT_GET_PARAMS, &ztp) < 0) {
|
||||||
|
@ -164,6 +168,20 @@ static unsigned zt_open_range(zap_span_t *span, unsigned start, unsigned end, za
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chan->type == ZAP_CHAN_TYPE_DQ921) {
|
||||||
|
struct zt_bufferinfo binfo;
|
||||||
|
memset(&binfo, 0, sizeof(binfo));
|
||||||
|
binfo.txbufpolicy = 0;
|
||||||
|
binfo.rxbufpolicy = 0;
|
||||||
|
binfo.numbufs = 32;
|
||||||
|
binfo.bufsize = 1024;
|
||||||
|
if (ioctl(sockfd, ZT_SET_BUFINFO, &binfo)) {
|
||||||
|
zap_log(ZAP_LOG_INFO, "failure configuring device %s as OpenZAP device %d:%d fd:%d\n", path, chan->span_id, chan->chan_id, sockfd);
|
||||||
|
close(sockfd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ztp.wink_time = zt_globals.wink_ms;
|
ztp.wink_time = zt_globals.wink_ms;
|
||||||
ztp.flash_time = zt_globals.flash_ms;
|
ztp.flash_time = zt_globals.flash_ms;
|
||||||
|
|
||||||
|
@ -290,6 +308,22 @@ static ZIO_CONFIGURE_FUNCTION(zt_configure)
|
||||||
|
|
||||||
static ZIO_OPEN_FUNCTION(zt_open)
|
static ZIO_OPEN_FUNCTION(zt_open)
|
||||||
{
|
{
|
||||||
|
if (zchan->type == ZAP_CHAN_TYPE_DQ921 || zchan->type == ZAP_CHAN_TYPE_DQ931) {
|
||||||
|
zchan->native_codec = zchan->effective_codec = ZAP_CODEC_NONE;
|
||||||
|
} else {
|
||||||
|
int ms = zt_globals.codec_ms;
|
||||||
|
int err;
|
||||||
|
if ((err = ioctl(zchan->sockfd, ZT_SET_BLOCKSIZE, &ms))) {
|
||||||
|
snprintf(zchan->last_error, sizeof(zchan->last_error), "%s", strerror(errno));
|
||||||
|
return ZAP_FAIL;
|
||||||
|
} else {
|
||||||
|
zap_channel_set_feature(zchan, ZAP_CHANNEL_FEATURE_INTERVAL);
|
||||||
|
zchan->effective_interval = zchan->native_interval = ms;
|
||||||
|
zchan->packet_len = zchan->native_interval * 8;
|
||||||
|
zchan->native_codec = zchan->effective_codec;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return ZAP_SUCCESS;
|
return ZAP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue