char netdev_name[16]; /* name for the hdlc network device */
};
-struct zt_bufferinfo {\r
-/* used in ZT_SET_BUFINFO and ZT_GET_BUFINFO */\r
- int txbufpolicy; /* Policy for handling receive buffers */\r
- int rxbufpolicy; /* Policy for handling receive buffers */\r
- int numbufs; /* How many buffers to use */\r
- int bufsize; /* How big each buffer is */\r
- int readbufs; /* How many read buffers are full (read-only) */\r
+struct zt_bufferinfo {
+/* used in ZT_SET_BUFINFO and ZT_GET_BUFINFO */
+ int txbufpolicy; /* Policy for handling receive buffers */
+ int rxbufpolicy; /* Policy for handling receive buffers */
+ int numbufs; /* How many buffers to use */
+ int bufsize; /* How big each buffer is */
+ int readbufs; /* How many read buffers are full (read-only) */
int writebufs; /* How many write buffers are full (read-only) */
};
#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_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 */\r
-#define ZT_GET_BUFINFO _IOR (ZT_CODE, 28, struct zt_bufferinfo)/* Get current buffer info */\r
+#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_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_HDLCRAWMODE _IOW (ZT_CODE, 36, int) /* Set a clear channel into HDLC w/out FCS checking/calculation mode */
if (flags & ZAP_READ) {
len = sizeof(buf);
if (zap_channel_read(data->dchan, buf, &len) == ZAP_SUCCESS) {
-#ifdef IODEBUG
- //char bb[4096] = "";
- //print_hex_bytes(buf, len, bb, sizeof(bb));
+ //#ifdef IODEBUG
+ char bb[4096] = "";
+ print_hex_bytes(buf, len, bb, sizeof(bb));
- //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);
-#endif
+ 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);
+ //#endif
Q921QueueHDLCFrame(&data->q921, buf, (int)len);
Q921Rx12(&data->q921);
{
unsigned configured = 0, x;
const char ctlpath[] = "/dev/zap/ctl";
- char path[128] = "";
+ char path[] = "/dev/zap/channel";
zt_params_t ztp;
zap_socket_t ctlfd = ZT_INVALID_SOCKET;
zap_socket_t sockfd = ZT_INVALID_SOCKET;
int len;
- snprintf(path, sizeof(path), "/dev/zap/%d", x);
+ //snprintf(path, sizeof(path), "/dev/zap/%d", x);
sockfd = open(path, O_RDWR);
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) {
struct zt_chanconfig cc;
memset(&cc, 0, sizeof(cc));
close(sockfd);
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.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;
+ 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;
+ }
}
- chan->packet_len = len;
- chan->effective_interval = chan->native_interval = chan->packet_len / 8;
+ if (chan->type != ZAP_CHAN_TYPE_DQ921 && chan->type != ZAP_CHAN_TYPE_DQ931) {
+ 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->effective_interval = chan->native_interval = chan->packet_len / 8;
- if (chan->effective_codec == ZAP_CODEC_SLIN) {
- chan->packet_len *= 2;
+ if (chan->effective_codec == ZAP_CODEC_SLIN) {
+ chan->packet_len *= 2;
+ }
}
if (ioctl(sockfd, ZT_GET_PARAMS, &ztp) < 0) {
}
}
+ 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.flash_time = zt_globals.flash_ms;
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;
}