]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 18 May 2007 14:08:30 +0000 (14:08 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 18 May 2007 14:08:30 +0000 (14:08 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@28 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/freetdm/src/include/openzap.h
libs/freetdm/src/testapp.c
libs/freetdm/src/zap_wanpipe.c

index 4ee1e3a6fe2e6c2c014ac08d66a29fde41c509e1..077e4a098f013c6d3d06f8b0c4edfa7972320755 100644 (file)
@@ -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;
 };
index bb6b8d91cf1e672aefe63b9f7c5071f51d821bf2..0950c2acee3b027d11d50fb55db95eb03a59f81c 100644 (file)
@@ -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);
                        }
                }
        }
index 55c037d25a7c4b531c01eed90452c86da07407f7..7b5fabfd3d30f947099654cf2e463daf77b19578 100644 (file)
@@ -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