update
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@28 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
parent
2511f8ff0e
commit
09e864a8ba
|
@ -200,6 +200,7 @@ struct zap_channel {
|
|||
zap_chan_type_t type;
|
||||
zap_socket_t sockfd;
|
||||
zap_channel_flag_t flags;
|
||||
char last_error[256];
|
||||
void *mod_data;
|
||||
struct zap_software_interface *zint;
|
||||
};
|
||||
|
|
|
@ -18,27 +18,30 @@ int main(int argc, char *argv[])
|
|||
int x = 0;
|
||||
|
||||
if (zap_channel_command(chan, ZAP_COMMAND_SET_INTERVAL, &ms) == ZAP_SUCCESS) {
|
||||
zap_channel_command(chan, ZAP_COMMAND_SET_INTERVAL, &ms);
|
||||
ms = 0;
|
||||
zap_channel_command(chan, ZAP_COMMAND_GET_INTERVAL, &ms);
|
||||
printf("interval set to %u\n", ms);
|
||||
} else {
|
||||
printf("set interval failed\n");
|
||||
printf("set interval failed [%s]\n", chan->last_error);
|
||||
}
|
||||
|
||||
for(x = 0; x < 25; x++) {
|
||||
unsigned char buf[80];
|
||||
unsigned char buf[2048];
|
||||
zap_size_t len = sizeof(buf);
|
||||
zap_wait_flag_t flags = ZAP_READ;
|
||||
|
||||
zap_channel_wait(chan, &flags, 0);
|
||||
|
||||
if (zap_channel_wait(chan, &flags, 0) == ZAP_FAIL) {
|
||||
printf("wait FAIL! %d [%s]\n", len, chan->last_error);
|
||||
}
|
||||
if (flags & ZAP_READ) {
|
||||
if (zap_channel_read(chan, buf, &len) == ZAP_SUCCESS) {
|
||||
printf("READ: %d\n", len);
|
||||
} else {
|
||||
printf("READ FAIL! %d\n", len);
|
||||
printf("READ FAIL! %d [%s]\n", len, chan->last_error);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
printf("wait fail\n");
|
||||
printf("wait fail [%s]\n", chan->last_error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,16 +188,22 @@ static unsigned wp_configure_channel(zap_config_t *cfg, const char *str, zap_spa
|
|||
return configured;
|
||||
}
|
||||
|
||||
static zap_status_t wp_tdm_cmd_exec(zap_socket_t fd, wanpipe_tdm_api_t *tdm_api)
|
||||
static zap_status_t wp_tdm_cmd_exec(zap_channel_t *zchan, wanpipe_tdm_api_t *tdm_api)
|
||||
{
|
||||
int err;
|
||||
|
||||
#if defined(WIN32)
|
||||
err = tdmv_api_ioctl(fd, &tdm_api->wp_tdm_cmd);
|
||||
err = tdmv_api_ioctl(zchan->sockfd, &tdm_api->wp_tdm_cmd);
|
||||
#else
|
||||
err = ioctl(fd,SIOC_WANPIPE_TDM_API,&tdm_api->wp_tdm_cmd);
|
||||
err = ioctl(zchan->sockfd, SIOC_WANPIPE_TDM_API, &tdm_api->wp_tdm_cmd);
|
||||
#endif
|
||||
return err ? ZAP_FAIL : ZAP_SUCCESS;
|
||||
|
||||
if (err) {
|
||||
snprintf(zchan->last_error, sizeof(zchan->last_error), "%s", strerror(errno));
|
||||
return ZAP_FAIL;
|
||||
}
|
||||
|
||||
return ZAP_SUCCESS;
|
||||
}
|
||||
|
||||
static ZINT_CONFIGURE_FUNCTION(wanpipe_configure)
|
||||
|
@ -300,7 +306,7 @@ static ZINT_COMMAND_FUNCTION(wanpipe_command)
|
|||
{
|
||||
tdm_api.wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_USR_PERIOD;
|
||||
|
||||
if (!(err = wp_tdm_cmd_exec(zchan->sockfd, &tdm_api))) {
|
||||
if (!(err = wp_tdm_cmd_exec(zchan, &tdm_api))) {
|
||||
*((int *)obj) = tdm_api.wp_tdm_cmd.usr_period;
|
||||
}
|
||||
|
||||
|
@ -310,12 +316,18 @@ static ZINT_COMMAND_FUNCTION(wanpipe_command)
|
|||
{
|
||||
tdm_api.wp_tdm_cmd.cmd = SIOC_WP_TDM_SET_USR_PERIOD;
|
||||
tdm_api.wp_tdm_cmd.usr_period = *((int *)obj);
|
||||
err = wp_tdm_cmd_exec(zchan->sockfd, &tdm_api);
|
||||
err = wp_tdm_cmd_exec(zchan, &tdm_api);
|
||||
}
|
||||
break;
|
||||
};
|
||||
|
||||
return err ? ZAP_FAIL : ZAP_SUCCESS;
|
||||
if (err) {
|
||||
snprintf(zchan->last_error, sizeof(zchan->last_error), "%s", strerror(errno));
|
||||
return ZAP_FAIL;
|
||||
}
|
||||
|
||||
|
||||
return ZAP_SUCCESS;
|
||||
}
|
||||
|
||||
static ZINT_WAIT_FUNCTION(wanpipe_wait)
|
||||
|
@ -356,6 +368,7 @@ static ZINT_WAIT_FUNCTION(wanpipe_wait)
|
|||
s = select(zchan->sockfd + 1, r, w, e, tvp);
|
||||
|
||||
if (s < 0) {
|
||||
snprintf(zchan->last_error, sizeof(zchan->last_error), "%s", strerror(errno));
|
||||
return ZAP_FAIL;
|
||||
}
|
||||
|
||||
|
@ -410,7 +423,7 @@ static ZINT_READ_FUNCTION(wanpipe_read_unix)
|
|||
*datalen = rx_len;
|
||||
|
||||
if (rx_len <= 0) {
|
||||
perror("wtf");
|
||||
snprintf(zchan->last_error, sizeof(zchan->last_error), "%s", strerror(errno));
|
||||
return ZAP_FAIL;
|
||||
}
|
||||
|
||||
|
@ -443,6 +456,7 @@ static ZINT_WRITE_FUNCTION(wanpipe_write_unix)
|
|||
bsent -= sizeof(wp_tdm_api_tx_hdr_t);
|
||||
}
|
||||
|
||||
*datalen = bsent;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue