sample.c File Reference

WANPIPE(tm) API C Sample Code. More...

#include "libsangoma.h"
#include "lib_api.h"

Include dependency graph for sample.c:

Go to the source code of this file.

Classes

struct  sangoma_chan

Defines

#define TEST_NUMBER_OF_OBJECTS   1
 Number of wait objects to define in object array.

Typedefs

typedef struct sangoma_chan sangoma_chan_t

Functions

int __cdecl main (int argc, char *argv[])
 Main function that starts the sample code.
int open_sangoma_device (void)
 Open a single span chan device.
void handle_span_chan (int open_device_counter)
 Write data buffer into a file.
int handle_tdm_event (uint32_t dev_index)
 Read Event buffer from the device.
int handle_data (uint32_t dev_index, int flags_out)
 Read data buffer from the device and transmit it back down.
int read_data (uint32_t dev_index, wp_api_hdr_t *rx_hdr, void *rx_buffer, int rx_buffer_length)
int write_data (uint32_t dev_index, wp_api_hdr_t *tx_hdr, void *tx_buffer, int tx_len)
 Transmit a data buffer to a device.
int dtmf_event (sng_fd_t fd, unsigned char digit, unsigned char type, unsigned char port)
int rbs_event (sng_fd_t fd, unsigned char rbs_bits)
int rxhook_event (sng_fd_t fd, unsigned char hook_state)
int rxring_event (sng_fd_t fd, unsigned char ring_state)
int ringtrip_event (sng_fd_t fd, unsigned char ring_state)
int write_data_to_file (unsigned char *data, unsigned int data_length)
 Write data buffer into a file.
int sangoma_print_stats (sng_fd_t sangoma_dev)
void cleanup (void)
 Protperly shutdown single device.
int handle_fe_rw (void)
void TerminateHandler (int)
 Signal handler for graceful shutdown.
void print_rxdata (unsigned char *data, int datalen, wp_api_hdr_t *hdr)

Variables

sangoma_chan_t sangoma_channels [TEST_NUMBER_OF_OBJECTS]
unsigned char rx_rbs_bits = WAN_RBS_SIG_A
FILE * pRxFile
int application_termination_flag = 0


Detailed Description

WANPIPE(tm) API C Sample Code.

Authors: David Rokhvarg <davidr@sangoma.com> Nenad Corbic <ncorbic@sangoma.com>

Copyright (c) 2007 - 08, Sangoma Technologies All rights reserved.

* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Sangoma Technologies nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY Sangoma Technologies ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Sangoma Technologies BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ===============================================================================

Definition in file sample.c.


Define Documentation

#define TEST_NUMBER_OF_OBJECTS   1

Number of wait objects to define in object array.

Objects are used to wait on file descripotrs. Usually there is one wait object per file descriptor.

In this example there is a single file descriptor and a single wait object.

Definition at line 50 of file sample.c.

Referenced by cleanup(), handle_span_chan(), and main().


Function Documentation

int main ( int  argc,
char *  argv[] 
)

Main function that starts the sample code.

Main function start of the applicatoin.

Parameters:
argc number of arguments
argv argument list
argc number of arguments
argv argument list
Returns:
0 - ok non-zero - Error
Get user Input Set program settings based on user input Create SangomaInterface Class based on user span/chan input. Bind callback functions read/event to SangomaInteface class. Execute the SangomaInterface handling function -> start() The start function will read/write/event data. In Main thread prompt the user for commands.

Definition at line 933 of file sample.c.

References _getch, cleanup(), handle_span_chan(), MAX_NO_DATA_BYTES_IN_FRAME, open_sangoma_device(), TerminateHandler(), TEST_NUMBER_OF_OBJECTS, and TRUE.

00934 {
00935     int proceed, i;
00936 
00937 #if 0
00938     /* Function used to rescan pci/usb bus.
00939        added here as use example. Uncomment to use.
00940        This function should only be used when all ports
00941        are down. */
00942     sangoma_hardware_rescan();
00943 #endif
00944 
00945     proceed=init_args(argc,argv);
00946     if (proceed != WAN_TRUE){
00947         usage(argv[0]);
00948         return -1;
00949     }
00950 
00951     /* register Ctrl+C handler - we want a clean termination */
00952 #if defined(__WINDOWS__)
00953     if (!SetConsoleCtrlHandler(TerminateHandler, TRUE)) {
00954         printf("ERROR : Unable to register terminate handler ( %d ).\nProcess terminated.\n", 
00955             GetLastError());
00956         return -1;
00957     }
00958 #else
00959     signal(SIGHUP,TerminateHandler);
00960     signal(SIGTERM,TerminateHandler);
00961 #endif
00962     
00963     for(i = 0; i < TEST_NUMBER_OF_OBJECTS; i++){
00964         sangoma_wait_objects[i] = NULL;
00965     }
00966 
00967     poll_events_bitmap = 0;
00968     if(read_enable  == 1){
00969         poll_events_bitmap |= POLLIN;
00970     }
00971 
00972     if(write_enable == 1 && rx2tx == 1){
00973         /* These two options are mutually exclusive because 'rx2tx' option
00974          * indicates "use Reciever as the timing source for Transmitter". */
00975         write_enable = 0;
00976     }
00977     
00978     if(write_enable == 1){
00979         poll_events_bitmap |= POLLOUT;
00980     }
00981 
00982     /* Front End connect/disconnect, and other events, such as DTMF... */
00983     poll_events_bitmap |= (POLLHUP | POLLPRI);
00984 #if defined(__WINDOWS__)
00985     printf("Enabling Poll Events:\n");
00986     print_poll_event_bitmap(poll_events_bitmap);
00987 #endif
00988     printf("Connecting to Port/Span: %d, Interface/Chan: %d\n",
00989         wanpipe_port_no, wanpipe_if_no);
00990 
00991 
00992     if(open_sangoma_device()){
00993         return -1;
00994     }
00995 
00996     printf("********************************\n");
00997     printf("files_used: 0x%x\n", files_used);
00998     printf("********************************\n");
00999     if(files_used & RX_FILE_USED){
01000         pRxFile = fopen( (const char*)&rx_file[0], "wb" );
01001         if(pRxFile == NULL){
01002             printf("Can't open Rx file: [%s]!!\n", rx_file);
01003         }else{
01004             printf("Open Rx file: %s. OK.\n", rx_file);
01005         }
01006     }
01007 
01008     if (fe_read_cmd || fe_write_cmd) {
01009         handle_fe_rw();
01010         goto done;
01011     }
01012     
01013     handle_span_chan(1 /* handle a single device */);
01014 
01015 done:
01016     /* returned from main loop, do the cleanup before exiting: */
01017     cleanup();
01018 
01019     printf("\nSample application exiting.(press any key)\n");
01020     _getch();
01021     return 0;
01022 }

Here is the call graph for this function:

int open_sangoma_device ( void   ) 

Open a single span chan device.

Returns:
0 ok otherise error.
This function will open a single span chan.

However it can be rewritten to iterate for all spans and chans and try to open all existing wanpipe devices.

For each opened device, a wait object will be initialized. For each device, configure the chunk size for tx/rx enable events such as DTMF/RBS ...etc

Definition at line 760 of file sample.c.

References INVALID_HANDLE_VALUE, SANG_STATUS_SUCCESS, SANGOMA_DEVICE_WAIT_OBJ, sangoma_flush_bufs(), sangoma_get_full_cfg(), sangoma_get_rx_queue_sz(), sangoma_get_tx_queue_sz(), sangoma_open_api_span_chan(), sangoma_set_rx_queue_sz(), sangoma_set_tx_queue_sz(), sangoma_tdm_enable_dtmf_events(), sangoma_tdm_enable_rbs_events(), sangoma_tdm_enable_rm_dtmf_events(), sangoma_tdm_enable_rxhook_events(), sangoma_tdm_set_buffer_multiplier(), sangoma_tdm_set_codec(), sangoma_tdm_set_usr_period(), and sangoma_wait_obj_create().

Referenced by main().

00761 {
00762     int span, chan, err = 0, open_dev_cnt = 0;
00763     sangoma_status_t status;
00764     sng_fd_t    dev_fd = INVALID_HANDLE_VALUE;
00765     wanpipe_api_t tdm_api;
00766 
00767     span = wanpipe_port_no;
00768     chan = wanpipe_if_no;
00769 
00770     /* span and chan are 1-based */
00771     dev_fd = sangoma_open_api_span_chan(span, chan);
00772     if( dev_fd == INVALID_HANDLE_VALUE){
00773         printf("Warning: Failed to open span %d, chan %d\n", span , chan);
00774         return 1;
00775     }else{
00776         printf("Successfuly opened span %d, chan %d\n", span , chan);
00777     }
00778 
00779     memset(&tdm_api, 0x00, sizeof(tdm_api));
00780 
00781     status = sangoma_wait_obj_create(&sangoma_wait_objects[open_dev_cnt], dev_fd, SANGOMA_DEVICE_WAIT_OBJ);
00782     if(status != SANG_STATUS_SUCCESS){
00783         printf("Error: Failed to create 'sangoma_wait_object'!\n");
00784         return 1;
00785     }
00786     sangoma_channels[open_dev_cnt].channo = chan;
00787     sangoma_channels[open_dev_cnt].spanno = span;
00788     sangoma_wait_obj_set_context(sangoma_wait_objects[open_dev_cnt], &sangoma_channels[open_dev_cnt]);
00789     /* open_dev_cnt++; */
00790 
00791     if((err = sangoma_get_full_cfg(dev_fd, &tdm_api))){
00792         return 1;
00793     }
00794 
00795     if(set_codec_slinear){
00796         printf("Setting SLINEAR codec\n");
00797         if((err=sangoma_tdm_set_codec(dev_fd, &tdm_api, WP_SLINEAR))){
00798             return 1;
00799         }
00800     }
00801 
00802     if(set_codec_none){
00803         printf("Disabling codec\n");
00804         if((err=sangoma_tdm_set_codec(dev_fd, &tdm_api, WP_NONE))){
00805             return 1;
00806         }
00807     }
00808 
00809     if(usr_period){
00810         printf("Setting user period: %d\n", usr_period);
00811         if((err=sangoma_tdm_set_usr_period(dev_fd, &tdm_api, usr_period))){
00812             return 1;
00813         }
00814     }
00815 
00816     if (rx_gain_cmd) {
00817         printf("Setting rx gain : %f\n", rx_gain);
00818         if (sangoma_set_rx_gain(dev_fd,&tdm_api,rx_gain)) {
00819             return 1;
00820         }   
00821     }
00822 
00823     if (tx_gain_cmd) {
00824         printf("Setting tx gain : %f\n", rx_gain);
00825         if (sangoma_set_tx_gain(dev_fd,&tdm_api,tx_gain)) {
00826             return 1;
00827         }
00828     }
00829 
00830     if(set_codec_slinear || usr_period || set_codec_none){
00831         /* display new configuration AFTER it was changed */
00832         if((err=sangoma_get_full_cfg(dev_fd, &tdm_api))){
00833             return 1;
00834         }
00835     }
00836 
00837     if(dtmf_enable_octasic == 1){
00838         poll_events_bitmap |= POLLPRI;
00839         /* enable dtmf detection on Octasic chip */
00840         if((err=sangoma_tdm_enable_dtmf_events(dev_fd, &tdm_api))){
00841             return 1;
00842         }
00843     }
00844 
00845     if(dtmf_enable_remora == 1){
00846         poll_events_bitmap |= POLLPRI;
00847         /* enable dtmf detection on Sangoma's Remora SLIC chip (A200 ONLY) */
00848         if((err=sangoma_tdm_enable_rm_dtmf_events(dev_fd, &tdm_api))){
00849             return 1;
00850         }
00851     }
00852 
00853     if(remora_hook == 1){
00854         poll_events_bitmap |= POLLPRI;
00855         if((err=sangoma_tdm_enable_rxhook_events(dev_fd, &tdm_api))){
00856             return 1;
00857         }
00858     }
00859 
00860     if(rbs_events == 1){
00861         poll_events_bitmap |= POLLPRI;
00862         if((err=sangoma_tdm_enable_rbs_events(dev_fd, &tdm_api, 20))){
00863             return 1;
00864         }
00865     }
00866     if (buffer_multiplier) {
00867         printf("Setting buffer multiplier to %i\n",buffer_multiplier);
00868         err=sangoma_tdm_set_buffer_multiplier(dev_fd,&tdm_api,buffer_multiplier);
00869         if (err) {
00870             return 1;
00871         }
00872     }
00873 
00874     printf("Device Config RxQ=%i TxQ=%i \n",
00875         sangoma_get_rx_queue_sz(dev_fd,&tdm_api),
00876         sangoma_get_rx_queue_sz(dev_fd,&tdm_api));
00877 
00878 #if 0
00879     sangoma_set_rx_queue_sz(dev_fd,&tdm_api,20);
00880     sangoma_set_tx_queue_sz(dev_fd,&tdm_api,30);
00881 #endif
00882 
00883     printf("Device Config RxQ=%i TxQ=%i \n",
00884         sangoma_get_rx_queue_sz(dev_fd,&tdm_api),
00885         sangoma_get_tx_queue_sz(dev_fd,&tdm_api));
00886     
00887     sangoma_flush_bufs(dev_fd,&tdm_api);
00888 
00889     sangoma_print_stats(dev_fd);
00890 
00891 
00892     return err;
00893 }

Here is the call graph for this function:

Here is the caller graph for this function:

void handle_span_chan ( int  open_device_counter  ) 

Write data buffer into a file.

Parameters:
open_device_counter number of opened devices
Returns:
void
This function will wait on all opened devices. This example will wait for RX and EVENT signals. In case of POLLIN - rx data available In case of POLLPRI - event is available

Definition at line 576 of file sample.c.

References handle_data(), handle_tdm_event(), SANG_STATUS_APIPOLL_TIMEOUT, SANG_STATUS_SUCCESS, sangoma_wait_obj_get_fd(), SDLA_DECODE_SANG_STATUS, and TEST_NUMBER_OF_OBJECTS.

Referenced by main().

00577 {
00578     int iResult, i;
00579     u_int32_t input_flags[TEST_NUMBER_OF_OBJECTS];
00580     u_int32_t output_flags[TEST_NUMBER_OF_OBJECTS];
00581 
00582     printf("\n\nSpan/Chan Handler: RxEnable=%s, TxEnable=%s, TxCnt=%i, TxLen=%i, rx2tx=%s\n",
00583         (read_enable? "Yes":"No"), (write_enable?"Yes":"No"),tx_cnt,tx_size, (rx2tx?"Yes":"No"));   
00584 
00585     for (i = 0; i < open_device_counter; i++) {
00586         input_flags[i] = poll_events_bitmap;
00587     }
00588 
00589     /* Main Rx/Tx/Event loop */
00590     while(!application_termination_flag) 
00591     {   
00592         iResult = sangoma_waitfor_many(sangoma_wait_objects, 
00593                            input_flags,
00594                            output_flags,
00595                            open_device_counter /* number of wait objects */,
00596                            5000 /* wait timeout, in milliseconds */);
00597         switch(iResult)
00598         {
00599         case SANG_STATUS_APIPOLL_TIMEOUT:
00600             /* timeout (not an error) */
00601             {
00602             sng_fd_t dev_fd = sangoma_wait_obj_get_fd(sangoma_wait_objects[0]);
00603             sangoma_print_stats(dev_fd);
00604             }
00605             printf("Timeout\n");
00606             continue;
00607 
00608         case SANG_STATUS_SUCCESS:
00609             for(i = 0; i < open_device_counter; i++){
00610 
00611                 /* a wait object was signaled */
00612                 if(output_flags[i] & POLLPRI){
00613                     /* got tdm api event */
00614                     if(handle_tdm_event(i)){
00615                         printf("Error in handle_tdm_event()!\n");
00616                         application_termination_flag=1;
00617                         break;
00618                     }
00619                 }
00620                     
00621                 if(output_flags[i] & (POLLIN | POLLOUT)){
00622                     /* rx data OR a free tx buffer available */
00623                     if(handle_data(i, output_flags[i])){
00624                         printf("Error in handle_data()!\n");
00625                         //application_termination_flag=1;
00626                         break;
00627                     }
00628                 }
00629             }/* for() */
00630             break;
00631 
00632         default:
00633             /* error */
00634             printf("Error: iResult: %s (%d)\n", SDLA_DECODE_SANG_STATUS(iResult), iResult);
00635             return;
00636         }
00637 
00638     }/* while() */
00639 }

Here is the call graph for this function:

Here is the caller graph for this function:

int handle_tdm_event ( uint32_t  dev_index  ) 

Read Event buffer from the device.

Parameters:
dev_index device index number associated with device file descriptor
Returns:
0 - Ok otherwise Error
An EVENT has occoured. Execute a system call to read the EVENT on a device.

Definition at line 513 of file sample.c.

References wanpipe_api_cmd::event, sangoma_read_event(), sangoma_wait_obj_get_fd(), and wanpipe_api::wp_cmd.

Referenced by handle_span_chan().

00514 {
00515     wanpipe_api_t   tdm_api; 
00516     sng_fd_t        dev_fd = sangoma_wait_obj_get_fd(sangoma_wait_objects[dev_index]);
00517 
00518 #if 0
00519     printf("%s(): dev_index: %d, dev_fd: 0x%p\n", __FUNCTION__, dev_index, dev_fd);
00520 #endif
00521 
00522     memset(&tdm_api, 0x00, sizeof(tdm_api));
00523 
00524     if(sangoma_read_event(dev_fd, &tdm_api)){
00525         return 1;
00526     }
00527 
00528     decode_api_event(&tdm_api.wp_cmd.event);
00529     return 0;
00530 }

Here is the call graph for this function:

Here is the caller graph for this function:

int handle_data ( uint32_t  dev_index,
int  flags_out 
)

Read data buffer from the device and transmit it back down.

Parameters:
dev_index device index number associated with device file descriptor
Returns:
0 - Ok otherwise Error
Read data buffer from a device.

Definition at line 391 of file sample.c.

References wp_api_hdr::data_length, MAX_NO_DATA_BYTES_IN_FRAME, and write_data().

Referenced by handle_span_chan().

00392 {
00393     wp_api_hdr_t    rxhdr;
00394     int err=0;
00395 
00396     memset(&rxhdr, 0, sizeof(rxhdr));
00397 
00398 #if 0
00399     printf("%s(): span: %d, chan: %d\n", __FUNCTION__,
00400         sangoma_wait_objects[dev_index].span, sangoma_wait_objects[dev_index].chan);
00401 #endif
00402 
00403     if(flags_out & POLLIN){
00404         if(read_data(dev_index, &rxhdr, rxdata, MAX_NO_DATA_BYTES_IN_FRAME) == 0){
00405             if(rx2tx){
00406                 /* Send back received data (create a "software loopback"), just a test. */
00407                 return write_data(dev_index, &rxhdr, rxdata,rxhdr.data_length);
00408             }
00409         }
00410     }
00411 
00412     if( (flags_out & POLLOUT) && write_enable ){
00413     
00414         wp_api_hdr_t txhdr;
00415         static unsigned char tx_test_byte = 2;
00416 
00417         memset(&txhdr, 0, sizeof(txhdr));
00418         txhdr.data_length = (unsigned short)tx_size;/* use '-txsize' command line option to change 'tx_size' */
00419 
00420         /* set data which will be transmitted */
00421         memset(txdata, tx_test_byte, txhdr.data_length);
00422         
00423         err = write_data(dev_index, &txhdr, txdata, tx_size);
00424         if (err== 0) {
00425             //tx_test_byte++;
00426         }
00427     }
00428     return err;
00429 }

Here is the call graph for this function:

Here is the caller graph for this function:

int write_data ( uint32_t  dev_index,
wp_api_hdr_t tx_hdr,
void *  tx_data,
int  tx_len 
)

Transmit a data buffer to a device.

Parameters:
dev_index device index number associated with device file descriptor
tx_hdr pointer to a wp_api_hdr_t
tx_data pointer to a data buffer
tx_len tx data buffer len
Returns:
0 - Ok otherwise Error

Definition at line 325 of file sample.c.

References sangoma_msleep, sangoma_wait_obj_get_context(), sangoma_wait_obj_get_fd(), and sangoma_writemsg().

Referenced by handle_data().

00326 {
00327     sng_fd_t    dev_fd  = sangoma_wait_obj_get_fd(sangoma_wait_objects[dev_index]);
00328     sangoma_chan_t *chan = sangoma_wait_obj_get_context(sangoma_wait_objects[dev_index]);
00329     int         err;
00330     static int  Tx_count = 0;
00331 
00332     if (hdlc_repeat) {
00333         if (verbose){
00334             printf("Repeating Frame\n");
00335         }
00336         tx_hdr->wp_api_tx_hdr_hdlc_rpt_len=4;
00337         memset(tx_hdr->wp_api_tx_hdr_hdlc_rpt_data,Tx_count,4);
00338     }
00339 
00340     /* write a message */
00341     err = sangoma_writemsg(
00342                 dev_fd,
00343                 tx_hdr,                 /* header buffer */
00344                 sizeof(wp_api_hdr_t),   /* header size */
00345                 tx_buffer,              /* data buffer */
00346                 tx_len,                 /* DATA size */
00347                 0);
00348 
00349     if (err <= 0){
00350         printf("Span: %d, Chan: %d: Failed to send %s!\n", 
00351             chan->spanno, 
00352             chan->channo, strerror(errno));
00353         return -1;
00354     }
00355     
00356     Tx_count++;
00357     if (verbose){
00358         printf("Packet sent: counter: %i, len: %i, errors %i\n", Tx_count, err, tx_hdr->wp_api_tx_hdr_errors);
00359     }else{
00360         if(Tx_count && (!(Tx_count % 1000))){
00361             printf("Packet sent: counter: %i, len: %i\n", Tx_count, err);
00362         }
00363     }
00364 
00365     if (tx_delay) {
00366         sangoma_msleep(tx_delay);
00367     }
00368 
00369 #if 1
00370     if(tx_cnt && Tx_count >= tx_cnt){
00371         write_enable=0;
00372         printf("Disabling POLLOUT...\n");
00373         /* No need for POLLOUT, turn it off!! If not turned off, and we
00374          * have nothing for transmission, sangoma_socket_waitfor() will return
00375          * immediately, creating a busy loop. */
00376         //sangoma_wait_objects[dev_index].flags_in &= (~POLLOUT);
00377         return 0;
00378     }
00379 #endif
00380     return 0;
00381 }

Here is the call graph for this function:

Here is the caller graph for this function:

int write_data_to_file ( unsigned char *  data,
unsigned int  data_length 
)

Write data buffer into a file.

Parameters:
data data buffer
data_length length of a data buffer
Returns:
data_length = ok otherwise error

Definition at line 649 of file sample.c.

00650 {
00651     if(pRxFile == NULL){
00652         return 1;
00653     }
00654 
00655     return fwrite(data, 1, data_length, pRxFile);
00656 }

void cleanup ( void   ) 

Protperly shutdown single device.

Parameters:
dev_no device index number
Returns:
void

Definition at line 697 of file sample.c.

References sangoma_close(), sangoma_tdm_disable_dtmf_events(), sangoma_tdm_disable_rbs_events(), sangoma_tdm_disable_rm_dtmf_events(), sangoma_tdm_disable_rxhook_events(), sangoma_wait_obj_delete(), sangoma_wait_obj_get_context(), sangoma_wait_obj_get_fd(), and TEST_NUMBER_OF_OBJECTS.

Referenced by main(), and TerminateHandler().

00698 {
00699     int dev_no;
00700     sng_fd_t fd;
00701     sangoma_chan_t *chan;
00702     sangoma_wait_obj_t *sng_wait_object;
00703     wanpipe_api_t tdm_api; 
00704 
00705     /* do the cleanup before exiting: */
00706     for(dev_no = 0; dev_no < TEST_NUMBER_OF_OBJECTS; dev_no++){
00707 
00708         sng_wait_object = sangoma_wait_objects[dev_no];
00709         if(!sng_wait_object){
00710             continue;
00711         }
00712         chan = sangoma_wait_obj_get_context(sng_wait_object);
00713         printf("%s(): span: %d, chan: %d ...\n", __FUNCTION__, 
00714             chan->channo,
00715             chan->spanno);
00716 
00717         fd = sangoma_wait_obj_get_fd(sng_wait_object);
00718         memset(&tdm_api, 0x00, sizeof(tdm_api));
00719 
00720         if(dtmf_enable_octasic == 1){
00721             /* Disable dtmf detection on Octasic chip */
00722             sangoma_tdm_disable_dtmf_events(fd, &tdm_api);
00723         }
00724 
00725         if(dtmf_enable_remora == 1){
00726             /* Disable dtmf detection on Sangoma's Remora SLIC chip */
00727             sangoma_tdm_disable_rm_dtmf_events(fd, &tdm_api);
00728         }
00729 
00730         if(remora_hook == 1){
00731             sangoma_tdm_disable_rxhook_events(fd, &tdm_api);
00732         }
00733 
00734         if(rbs_events == 1){
00735             sangoma_tdm_disable_rbs_events(fd, &tdm_api);
00736         }
00737 
00738         sangoma_wait_obj_delete(&sng_wait_object);
00739 
00740         sangoma_close(&fd);
00741 
00742     }
00743 }

Here is the call graph for this function:

Here is the caller graph for this function:

void TerminateHandler ( int  sig  ) 

Signal handler for graceful shutdown.

Parameters:
sig signal

Definition at line 679 of file sample.c.

References cleanup().

Referenced by main().

00680 {
00681     printf("\nProcess terminated by user request.\n");
00682     application_termination_flag = 1;
00683     /* do the cleanup before exiting: */
00684     cleanup();
00685     return;
00686 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Wed Jun 1 17:30:45 2011 for libsangoma by  doxygen 1.5.6