git-svn-id: http://svn.openzap.org/svn/openzap/trunk@277 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Anthony Minessale 2007-06-20 17:53:09 +00:00
parent d71231f075
commit c406e3eadc
4 changed files with 71 additions and 36 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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,7 +120,6 @@ static unsigned zt_open_range(zap_span_t *span, unsigned start, unsigned end, za
close(sockfd); close(sockfd);
break; break;
} }
}
len = zt_globals.eclevel; len = zt_globals.eclevel;
if (ioctl(chan->sockfd, ZT_ECHOCANCEL, &len)) { if (ioctl(chan->sockfd, ZT_ECHOCANCEL, &len)) {
@ -127,7 +128,9 @@ static unsigned zt_open_range(zap_span_t *span, unsigned start, unsigned end, za
close(sockfd); close(sockfd);
continue; continue;
} }
}
if (chan->type != ZAP_CHAN_TYPE_DQ921 && chan->type != ZAP_CHAN_TYPE_DQ931) {
len = zt_globals.codec_ms * 8; len = zt_globals.codec_ms * 8;
if (ioctl(chan->sockfd, ZT_SET_BLOCKSIZE, &len)) { 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", zap_log(ZAP_LOG_INFO, "failure configuring device %s as OpenZAP device %d:%d fd:%d err:%s\n",
@ -142,6 +145,7 @@ static unsigned zt_open_range(zap_span_t *span, unsigned start, unsigned end, za
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) {
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); 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);
@ -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;
} }