libsangoma.h File Reference

Wanpipe API Library header for Sangoma AFT T1/E1/Analog/BRI/Serial Hardware - Provides User a Unified/OS Agnostic API to Wanpipe/Sangoma Drivers and Hardware. More...

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/signal.h>
#include <sys/select.h>
#include <sys/wait.h>
#include <sys/resource.h>
#include <netinet/in.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <net/if.h>
#include <poll.h>
#include <signal.h>
#include <pthread.h>
#include <stdint.h>
#include "wanpipe_api.h"

Include dependency graph for libsangoma.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define WANPIPE_TDM_API   1
 Used by compiler and driver to enable TDM API.
#define LIBSANGOMA_VERSION(a, b, c)   (((a) << 16) + ((b) << 8) + (c))
 LibSangoma Macro to check the Version Number.
#define LIBSANGOMA_VERSION_CODE   LIBSANGOMA_VERSION(3,0,0)
 LibSangoma Current Version Number to be checked against the LIBSANGOMA_VERSION Macro.
#define LIBSANGOMA_VERSION_STR   "3.0.0"
 LibSangoma Version in string format.
#define _SAPI_CALL
 Not used in Linux.
#define INVALID_HANDLE_VALUE   -1
 Invalid file handle value -1, Ported from Windows.
#define SANGOMA_INFINITE_API_POLL_WAIT   -1
 Infinite poll timeout value -1, Ported from Windows.
#define SANGOMA_WAIT_INFINITE   -1
#define __cdecl
 Ported from Windows.
#define FALSE   0
#define TRUE   1
 TRUE value is 1, Ported from Windows.
#define sangoma_msleep(x)   usleep(x*1000)
 milisecond sleep function
#define _getch   getchar
 get character, Ported from Windows
#define Sleep   sangoma_msleep
 milisecond sleep function
#define _stricmp   strcmp
#define _snprintf   snprintf
 _snprintf type mapped to snprintf, Ported from Windows
#define _vsnprintf   vsnprintf
#define EnterCriticalSection(arg)   pthread_mutex_lock(arg)
#define LeaveCriticalSection(arg)   pthread_mutex_unlock(arg)
#define InitializeCriticalSection(arg)   pthread_mutex_init(arg, NULL);
#define FNAME_LEN   100
 string length of a file name
#define FUNC_DBG(x)   if(0)printf("%s():%d\n", x, __LINE__)
 function debug print function
#define DBG_PRINT   if(1)printf
 debug print function
#define DECODE_SANGOMA_WAIT_OBJECT_TYPE(type)
#define __sangoma_open_tdmapi_span_chan   __sangoma_open_api_span_chan
#define LIBSANGOMA_TDMAPI_CTRL   1
 Global control device feature.
#define LIBSANGOMA_GET_FESTATUS   1
 Get Front End Status feature.
#define LIBSANGOMA_GET_HWCODING   1
 Get HW Coding Feature.
#define LIBSANGOMA_GET_HWDTMF   1
 HW DTMF Feature.
#define LIBSANGOMA_SET_FESTATUS   1
 Set Front End Status Feature.
#define sangoma_open_tdmapi_span_chan   sangoma_open_api_span_chan
#define sangoma_open_tdmapi_span   sangoma_open_api_span
#define sangoma_open_tdmapi_ctrl   sangoma_open_api_ctrl
#define sangoma_tdm_get_fe_status   sangoma_get_fe_status
#define sangoma_socket_close   sangoma_close
#define sangoma_tdm_get_hw_coding   sangoma_get_hw_coding
#define sangoma_tdm_set_fe_status   sangoma_set_fe_status
#define sangoma_tdm_get_link_status   sangoma_get_link_status
#define sangoma_tdm_flush_bufs   sangoma_flush_bufs
#define sangoma_tdm_cmd_exec   sangoma_cmd_exec
#define sangoma_tdm_read_event   sangoma_read_event
#define sangoma_readmsg_tdm   sangoma_readmsg
#define sangoma_readmsg_socket   sangoma_readmsg
#define sangoma_sendmsg_socket   sangoma_writemsg
#define sangoma_writemsg_tdm   sangoma_writemsg
#define sangoma_create_socket_intr   sangoma_open_api_span_chan
 Backward compatible open span chan call.

Typedefs

typedef void sangoma_wait_obj_t
typedef int HANDLE
typedef int BOOL
typedef int DWORD
typedef char TCHAR
typedef unsigned char UCHAR
typedef unsigned long ULONG
typedef unsigned short USHORT
typedef unsigned char * LPSTR
typedef unsigned char * PUCHAR
typedef void * LPTHREAD_START_ROUTINE
typedef pthread_mutex_t CRITICAL_SECTION
typedef tm SYSTEMTIME
typedef char * LPCTSTR
typedef int32_t sangoma_status_t
 return status from sangoma APIs
typedef wp_api_hdr_t sangoma_api_hdr_t
 Backward comaptible define of wp_api_hdr_t.
typedef enum _sangoma_wait_obj_type sangoma_wait_obj_type_t
 Wait object type definition.

Enumerations

enum  _sangoma_wait_obj_type { UNKNOWN_WAIT_OBJ = 0, SANGOMA_GENERIC_WAIT_OBJ = 0, SANGOMA_DEVICE_WAIT_OBJ, SANGOMA_DEVICE_WAIT_OBJ_SIG }

Functions

sng_fd_t _SAPI_CALL sangoma_open_api_span_chan (int span, int chan)
 Open a Device based on Span/Chan values.
sng_fd_t _SAPI_CALL __sangoma_open_api_span_chan (int span, int chan)
 Open a Device based on Span/Chan values.
sng_fd_t _SAPI_CALL sangoma_open_api_span (int span)
sng_fd_t _SAPI_CALL sangoma_open_api_ctrl (void)
 Open a Global Control Device.
sng_fd_t _SAPI_CALL sangoma_open_driver_ctrl (int port_no)
 Open a Global Driver Control Device.
void _SAPI_CALL sangoma_close (sng_fd_t *fd)
 Close device file descriptor.
int _SAPI_CALL sangoma_get_open_cnt (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Get device open count.
int _SAPI_CALL sangoma_writemsg (sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, unsigned short datalen, int flag)
 Write Data to device.
int _SAPI_CALL sangoma_readmsg (sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag)
 Read Data from device.
sangoma_status_t _SAPI_CALL sangoma_waitfor (sangoma_wait_obj_t *sangoma_wait_obj, uint32_t inflags, uint32_t *outflags, int32_t timeout)
sangoma_status_t _SAPI_CALL sangoma_waitfor_many (sangoma_wait_obj_t *sangoma_wait_objects[], uint32_t in_flags[], uint32_t out_flags[], uint32_t number_of_sangoma_wait_objects, int32_t system_wait_timeout)
sangoma_status_t _SAPI_CALL sangoma_wait_obj_create (sangoma_wait_obj_t **sangoma_wait_object, sng_fd_t fd, sangoma_wait_obj_type_t object_type)
 Create a wait object that will be used with sangoma_waitfor_many() API.
sangoma_status_t _SAPI_CALL sangoma_wait_obj_delete (sangoma_wait_obj_t **sangoma_wait_object)
 De-allocate all resources in a wait object.
sangoma_status_t _SAPI_CALL sangoma_wait_obj_signal (sangoma_wait_obj_t *sangoma_wait_object)
 Set wait object to a signaled state.
sng_fd_t _SAPI_CALL sangoma_wait_obj_get_fd (sangoma_wait_obj_t *sangoma_wait_object)
 Retrieve fd device file descriptor which was the 'fd' parameter for sangoma_wait_obj_init().
void _SAPI_CALL sangoma_wait_obj_set_context (sangoma_wait_obj_t *sangoma_wait_object, void *context)
void *_SAPI_CALL sangoma_wait_obj_get_context (sangoma_wait_obj_t *sangoma_wait_object)
 Retrieve the user context (if any) that was set via sangoma_wait_obj_set_context.
int _SAPI_CALL sangoma_cmd_exec (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Execute Sangoma API Command.
int _SAPI_CALL sangoma_get_full_cfg (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Read tdm api device configuration.
int _SAPI_CALL sangoma_tdm_set_usr_period (sng_fd_t fd, wanpipe_api_t *tdm_api, int period)
 Set Tx/Rx Period in Milliseconds.
int _SAPI_CALL sangoma_tdm_get_usr_period (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Get Tx/Rx Period in Milliseconds.
int _SAPI_CALL sangoma_tdm_get_usr_mtu_mru (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Get Tx/Rx MTU/MRU in bytes.
int _SAPI_CALL sangoma_flush_bufs (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Flush buffers from current channel.
int _SAPI_CALL sangoma_tdm_enable_rbs_events (sng_fd_t fd, wanpipe_api_t *tdm_api, int poll_in_sec)
 Enable RBS Events on a device.
int _SAPI_CALL sangoma_tdm_disable_rbs_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Disable RBS Events for a device.
int _SAPI_CALL sangoma_tdm_write_rbs (sng_fd_t fd, wanpipe_api_t *tdm_api, int channel, unsigned char rbs)
 Write RBS Bits on a device.
int _SAPI_CALL sangoma_tdm_read_rbs (sng_fd_t fd, wanpipe_api_t *tdm_api, int channel, unsigned char *rbs)
 Read RBS Bits on a device.
int _SAPI_CALL sangoma_tdm_enable_dtmf_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Enable DTMF Detection on Octasic chip (if hw supports it).
int _SAPI_CALL sangoma_tdm_disable_dtmf_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Disable DTMF Detection on Octasic chip (if hw supports it).
int _SAPI_CALL sangoma_tdm_enable_rm_dtmf_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Enable DTMF Detection on Analog/Remora SLIC Chip.
int _SAPI_CALL sangoma_tdm_disable_rm_dtmf_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Disable DTMF Detection on Analog/Remora SLIC Chip.
int _SAPI_CALL sangoma_tdm_enable_rxhook_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Enable RX HOOK Events (Analog Only).
int _SAPI_CALL sangoma_tdm_disable_rxhook_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Disable RX HOOK Events (Analog Only).
int _SAPI_CALL sangoma_tdm_enable_ring_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Enable RING Events (Analog Only).
int _SAPI_CALL sangoma_tdm_disable_ring_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Disable RING Events (Analog Only).
int _SAPI_CALL sangoma_tdm_enable_ring_detect_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Enable RING DETECT Events (Analog Only).
int _SAPI_CALL sangoma_tdm_disable_ring_detect_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Disable RING DETECT Events (Analog Only).
int _SAPI_CALL sangoma_tdm_enable_ring_trip_detect_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Enable RING TRIP Events (Analog Only).
int _SAPI_CALL sangoma_tdm_disable_ring_trip_detect_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Disable RING TRIP Events (Analog Only).
int _SAPI_CALL sangoma_tdm_enable_tone_events (sng_fd_t fd, wanpipe_api_t *tdm_api, uint16_t tone_id)
 Transmit a TONE on this device (Analog Only).
int _SAPI_CALL sangoma_tdm_disable_tone_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Enable TONE Events (Analog Only).
int _SAPI_CALL sangoma_tdm_txsig_onhook (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Tranmsmit TX SIG ON HOOK (Analog Only).
int _SAPI_CALL sangoma_tdm_txsig_offhook (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Tranmsmit TX SIG OFF HOOK (Analog Only).
int _SAPI_CALL sangoma_tdm_txsig_start (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Tranmsmit TX SIG START (Analog Only).
int _SAPI_CALL sangoma_tdm_txsig_kewl (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Tranmsmit TX SIG KEWL START (Analog Only).
int _SAPI_CALL sangoma_tdm_enable_hwec (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Enable HWEC on this channel.
int _SAPI_CALL sangoma_tdm_disable_hwec (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Disable HWEC on this channel.
int _SAPI_CALL sangoma_tdm_get_fe_alarms (sng_fd_t fd, wanpipe_api_t *tdm_api, unsigned int *alarms)
 Get Front End Alarms (T1/E1 Only).
int _SAPI_CALL sangoma_set_fe_status (sng_fd_t fd, wanpipe_api_t *tdm_api, unsigned char new_status)
 Set Device Link Status (Connected/Disconnected).
int _SAPI_CALL sangoma_enable_bri_bchan_loopback (sng_fd_t fd, wanpipe_api_t *tdm_api, int channel)
 Enable BRI Bchannel loopback - used when debugging bri device.
int _SAPI_CALL sangoma_disable_bri_bchan_loopback (sng_fd_t fd, wanpipe_api_t *tdm_api, int channel)
 Disable BRI Bchannel loopback - used when debugging bri device.
int _SAPI_CALL sangoma_get_tx_queue_sz (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Get Tx Queue Size for this channel.
int _SAPI_CALL sangoma_set_tx_queue_sz (sng_fd_t fd, wanpipe_api_t *tdm_api, int size)
 Get Tx Queue Size for this channel.
int _SAPI_CALL sangoma_get_rx_queue_sz (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Get Rx Queue Size for this channel.
int _SAPI_CALL sangoma_set_rx_queue_sz (sng_fd_t fd, wanpipe_api_t *tdm_api, int size)
 Get Tx Queue Size for this channel.
int _SAPI_CALL sangoma_get_hw_coding (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Get HW Voice Coding (ulaw/alaw).
int _SAPI_CALL sangoma_tdm_get_hw_dtmf (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Check if hwdtmf support is available.
int _SAPI_CALL sangoma_span_chan_toif (int span, int chan, char *interface_name)
 Convert Span & Chan to interface name.
int _SAPI_CALL sangoma_span_chan_fromif (char *interface_name, int *span, int *chan)
 Convert Interace Name to Span & Chan.
int _SAPI_CALL sangoma_interface_wait_up (int span, int chan, int sectimeout)
 Wait for a sangoma device to come up (ie: Linux wait for /dev/wanpipex_1 to come up).
int _SAPI_CALL sangoma_get_driver_version (sng_fd_t fd, wanpipe_api_t *tdm_api, wan_driver_version_t *drv_ver)
 Get Device Driver Version Number.
int _SAPI_CALL sangoma_get_firmware_version (sng_fd_t fd, wanpipe_api_t *tdm_api, unsigned char *ver)
 Get Hardware/Firmware Version.
int _SAPI_CALL sangoma_get_cpld_version (sng_fd_t fd, wanpipe_api_t *tdm_api, unsigned char *ver)
 Get Hardare/CPLD Version.
int _SAPI_CALL sangoma_get_stats (sng_fd_t fd, wanpipe_api_t *tdm_api, wanpipe_chan_stats_t *stats)
 Get Device Statistics. Statistics will be available in tdm_api->wp_cmd.stats structure.
int _SAPI_CALL sangoma_flush_stats (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Flush/Reset device statistics.
int _SAPI_CALL sangoma_set_rm_rxflashtime (sng_fd_t fd, wanpipe_api_t *tdm_api, int rxflashtime)
 Set rxflashtime for FXS module Wink-Flash Event.
int _SAPI_CALL sangoma_read_event (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Read API Events.
int _SAPI_CALL sangoma_driver_port_start (sng_fd_t fd, port_management_struct_t *port_mgmnt, unsigned short port_no)
int _SAPI_CALL sangoma_driver_port_stop (sng_fd_t fd, port_management_struct_t *port_mgmnt, unsigned short port_no)
int _SAPI_CALL sangoma_driver_port_set_config (sng_fd_t fd, port_cfg_t *port_cfg, unsigned short port_no)
int _SAPI_CALL sangoma_driver_port_get_config (sng_fd_t fd, port_cfg_t *port_cfg, unsigned short port_no)
int _SAPI_CALL sangoma_driver_get_hw_info (sng_fd_t fd, port_management_struct_t *port_mgmnt, unsigned short port_no)
int _SAPI_CALL sangoma_mgmt_cmd (sng_fd_t fd, wan_udp_hdr_t *wan_udp)
 Execute Sangoma Management Command.
int _SAPI_CALL sangoma_get_fe_status (sng_fd_t fd, wanpipe_api_t *tdm_api, unsigned char *current_status)
 Get Device Link Status (Connected/Disconnected).
int _SAPI_CALL sangoma_tdm_set_codec (sng_fd_t fd, wanpipe_api_t *tdm_api, int codec)
 Set TDM Codec per chan.
int _SAPI_CALL sangoma_tdm_get_codec (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Get Configured TDM Codec per chan.
sng_fd_t _SAPI_CALL sangoma_create_socket_by_name (char *device, char *card)
 Open a device based on a interface and card name.
int _SAPI_CALL sangoma_interface_toi (char *interface_name, int *span, int *chan)
 Convert Span & Chan to interface name.
int _SAPI_CALL sangoma_tdm_set_power_level (sng_fd_t fd, wanpipe_api_t *tdm_api, int power)
 Set Power Level - so only data matching the power level would be passed up.
int _SAPI_CALL sangoma_tdm_get_power_level (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Get Configured Power Level.


Detailed Description

Wanpipe API Library header for Sangoma AFT T1/E1/Analog/BRI/Serial Hardware - Provides User a Unified/OS Agnostic API to Wanpipe/Sangoma Drivers and Hardware.

Author(s): Nenad Corbic <ncorbic@sangoma.com> David Rokhvarg <davidr@sangoma.com> Michael Jerris <mike@jerris.com> Anthony Minessale II <anthmct@yahoo.com>

Copyright: (c) 2005-2008 Nenad Corbic <ncorbic@sangoma.com>

* 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 =============================================================================== v.2.0.0 Nenad Corbic Jan 30 2009 Added sangoma_get_driver_version, sangoma_get_firmware_version, sangoma_get_cpld_version functions,sangoma_get_stats,sangoma_flush_stats

Definition in file libsangoma.h.


Define Documentation

#define DECODE_SANGOMA_WAIT_OBJECT_TYPE ( type   ) 

Value:

type == SANGOMA_GENERIC_WAIT_OBJ    ? "SANGOMA_GENERIC_WAIT_OBJ"    :\
    type == SANGOMA_DEVICE_WAIT_OBJ     ? "SANGOMA_DEVICE_WAIT_OBJ"     :\
    type == SANGOMA_DEVICE_WAIT_OBJ_SIG ? "SANGOMA_DEVICE_WAIT_OBJ_SIG" :\
    "Invalid Wait Object type!"

Definition at line 303 of file libsangoma.h.

Referenced by sangoma_wait_obj_create().

#define sangoma_open_tdmapi_span_chan   sangoma_open_api_span_chan

Backward compabile defines

Definition at line 1275 of file libsangoma.h.


Typedef Documentation

typedef int32_t sangoma_status_t

return status from sangoma APIs

As of now this typedef maps exactly to SANG_STATUS_T, however that is a kernel type, ugly, ugly, uglyyyyy, we should have strictly minimum set of shared data structures between kernel and user many return codes specified in SANG_STATUS_T are kernel specific like FAILED_TO_LOCK_USER_MEMORY or INVALID_IRQL, the libsangoma user does not need that much information, and even if ever needs it we should provide simpler defaults

Definition at line 265 of file libsangoma.h.


Enumeration Type Documentation

enum _sangoma_wait_obj_type

Enumerator:
UNKNOWN_WAIT_OBJ  deprecated, use SANGOMA_GENERIC_WAIT_OBJ
SANGOMA_GENERIC_WAIT_OBJ  Generic object that can be signaled but is not associated to any sangoma device.
SANGOMA_DEVICE_WAIT_OBJ  Sangoma object associated to some device which cannot be signaled (cannot call sangoma_wait_obj_signal on it).
SANGOMA_DEVICE_WAIT_OBJ_SIG  Sangoma object that is associated to a device AND can be signaled.

Definition at line 291 of file libsangoma.h.


Function Documentation

sng_fd_t _SAPI_CALL sangoma_open_api_span_chan ( int  span,
int  chan 
)

Open a Device based on Span/Chan values.

Parameters:
span span number starting from 1 to 255
chan chan number starting from 1 to 32
Returns:
File Descriptor: -1 error, 0 or positive integer: valid file descriptor
Restriced open, device will allowed to be open only once.

Definition at line 886 of file libsangoma.c.

References __sangoma_open_api_span_chan(), INVALID_HANDLE_VALUE, sangoma_close(), sangoma_cmd_exec(), and WP_API_CMD_OPEN_CNT.

Referenced by open_sangoma_device(), sangoma_create_socket_by_name(), and sangoma_open_api_span().

00887 {
00888     sng_fd_t fd = INVALID_HANDLE_VALUE;
00889     wanpipe_api_t tdm_api;
00890     int err;
00891 
00892     fd = __sangoma_open_api_span_chan(span, chan);
00893 
00894 #if defined(__WINDOWS__)
00895     if(fd == INVALID_HANDLE_VALUE){
00896         return fd;
00897     }
00898 #else
00899     if (fd < 0) {
00900         return fd;
00901     }
00902 #endif
00903 
00904     memset(&tdm_api,0,sizeof(tdm_api));
00905     tdm_api.wp_cmd.cmd = WP_API_CMD_OPEN_CNT;
00906     err=sangoma_cmd_exec(fd,&tdm_api);
00907     if (err){
00908         sangoma_close(&fd);
00909         return fd;
00910     }
00911 
00912     if (tdm_api.wp_cmd.open_cnt > 1) {
00913         /* this is NOT the first open request for this span/chan */
00914         sangoma_close(&fd);
00915         fd = INVALID_HANDLE_VALUE;/* fd is NOT valid anymore */
00916     }
00917 
00918     return fd;
00919 }            

Here is the call graph for this function:

Here is the caller graph for this function:

sng_fd_t _SAPI_CALL __sangoma_open_api_span_chan ( int  span,
int  chan 
)

Open a Device based on Span/Chan values.

Parameters:
span span number starting from 1 to 255
chan chan number starting from 1 to 32
Returns:
File Descriptor: -1 error, 0 or positive integer: valid file descriptor
Unrestriced open, allows mutiple open calls on a single device

Definition at line 922 of file libsangoma.c.

References _snprintf, FNAME_LEN, and WP_INTERFACE_NAME_FORM.

Referenced by sangoma_open_api_span_chan().

00923 {
00924     char fname[FNAME_LEN], tmp_fname[FNAME_LEN];
00925 
00926     /* Form the Interface Name from span and chan number (i.e. wanpipe1_if1). */
00927     _snprintf(tmp_fname, DEV_NAME_LEN, WP_INTERFACE_NAME_FORM, span, chan);
00928 
00929 #if defined(__WINDOWS__)
00930     _snprintf(fname , FNAME_LEN, "\\\\.\\%s", tmp_fname);
00931     return CreateFile(  fname, 
00932                         GENERIC_READ | GENERIC_WRITE, 
00933                         FILE_SHARE_READ | FILE_SHARE_WRITE,
00934                         (LPSECURITY_ATTRIBUTES)NULL, 
00935                         OPEN_EXISTING,
00936                         FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH,
00937                         (HANDLE)NULL
00938                         );
00939 #else
00940     sprintf(fname,"/dev/%s", tmp_fname);
00941 
00942     return open(fname, O_RDWR);
00943 #endif
00944 }            

Here is the caller graph for this function:

sng_fd_t _SAPI_CALL sangoma_open_api_ctrl ( void   ) 

Open a Global Control Device.

Returns:
File Descriptor - negative=error 0 or greater = fd
The global control device receives events for all devices configured.

Definition at line 946 of file libsangoma.c.

References _snprintf, FNAME_LEN, and WP_CTRL_DEV_NAME.

00947 {
00948     char fname[FNAME_LEN], tmp_fname[FNAME_LEN];
00949 
00950     /* Form the Ctrl Device Name. */
00951     _snprintf(tmp_fname, DEV_NAME_LEN, WP_CTRL_DEV_NAME);
00952 
00953 #if defined(__WINDOWS__)
00954     _snprintf(fname , FNAME_LEN, "\\\\.\\%s", tmp_fname);
00955 
00956     return CreateFile(  fname, 
00957                         GENERIC_READ | GENERIC_WRITE, 
00958                         FILE_SHARE_READ | FILE_SHARE_WRITE,
00959                         (LPSECURITY_ATTRIBUTES)NULL, 
00960                         OPEN_EXISTING,
00961                         FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH,
00962                         (HANDLE)NULL
00963                         );
00964 #else
00965     sprintf(fname,"/dev/%s", tmp_fname);
00966 
00967     return open(fname, O_RDWR);
00968 #endif
00969 }

sng_fd_t _SAPI_CALL sangoma_open_driver_ctrl ( int  port_no  ) 

Open a Global Driver Control Device.

Returns:
File Descriptor - negative=error 0 or greater = fd
The global control device receives events for all devices configured.

Definition at line 2224 of file libsangoma.c.

References _snprintf, FNAME_LEN, WP_CONFIG_DEV_NAME, and WP_PORT_NAME_FORM.

02225 {
02226     char fname[FNAME_LEN], tmp_fname[FNAME_LEN];
02227 
02228 #if defined(__WINDOWS__)
02229     /* Form the Config Device Name (i.e. wanpipe1, wanpipe2,...). */
02230     _snprintf(tmp_fname, DEV_NAME_LEN, WP_PORT_NAME_FORM, port_no);
02231     _snprintf(fname, FNAME_LEN, "\\\\.\\%s", tmp_fname);
02232 
02233     return CreateFile(  fname, 
02234                         GENERIC_READ | GENERIC_WRITE, 
02235                         FILE_SHARE_READ | FILE_SHARE_WRITE,
02236                         (LPSECURITY_ATTRIBUTES)NULL, 
02237                         OPEN_EXISTING,
02238                         FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH,
02239                         (HANDLE)NULL
02240                         );
02241 #else
02242     /* Form the Config Device Name. ("/dev/wanpipe") */
02243     _snprintf(tmp_fname, DEV_NAME_LEN, WP_CONFIG_DEV_NAME);
02244 
02245     sprintf(fname,"/dev/%s", tmp_fname);
02246 
02247     return open(fname, O_RDWR);
02248 #endif
02249 }

void _SAPI_CALL sangoma_close ( sng_fd_t fd  ) 

Close device file descriptor.

Parameters:
fd device file descriptor
Returns:
void

Definition at line 1025 of file libsangoma.c.

References INVALID_HANDLE_VALUE.

Referenced by cleanup(), sangoma_open_api_span_chan(), and sangoma_wait_obj_delete().

01026 {
01027 #if defined(__WINDOWS__)
01028     if( *fd != INVALID_HANDLE_VALUE){
01029         CloseHandle(*fd);
01030         *fd = INVALID_HANDLE_VALUE;
01031     }
01032 #else
01033     if (*fd >= 0) {
01034         close(*fd);
01035         *fd = -1;
01036     }
01037 #endif
01038 }

Here is the caller graph for this function:

int _SAPI_CALL sangoma_get_open_cnt ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Get device open count.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
negative or 0: error, greater than 1 : open count

Definition at line 972 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::open_cnt, sangoma_cmd_exec(), WP_API_CMD_OPEN_CNT, and wanpipe_api::wp_cmd.

00973 {
00974     int err;
00975     tdm_api->wp_cmd.cmd = WP_API_CMD_OPEN_CNT;
00976 
00977     err=sangoma_cmd_exec(fd,tdm_api);
00978     if (err){
00979         return -1;
00980     }
00981 
00982     return tdm_api->wp_cmd.open_cnt;
00983 }

Here is the call graph for this function:

int _SAPI_CALL sangoma_writemsg ( sng_fd_t  fd,
void *  hdrbuf,
int  hdrlen,
void *  databuf,
unsigned short  datalen,
int  flag 
)

Write Data to device.

Parameters:
fd device file descriptor
hdrbuf pointer to header structure wp_api_hdr_t
hdrlen size of wp_api_hdr_t
databuf pointer to data buffer to be transmitted
datalen length of data buffer
flag currently not used, set to 0
Returns:
transmit size, must be equal to datalen, anything else is error
In case of error return code, one must check the header operation_status variable to identify the reason of an error. Please refer to the error codes.

Definition at line 1112 of file libsangoma.c.

References DBG_ERR, SANG_STATUS_DEVICE_BUSY, SANG_STATUS_IO_ERROR, SANG_STATUS_SUCCESS, and SDLA_DECODE_SANG_STATUS.

Referenced by write_data().

01113 {
01114     int bsent=-1;
01115     wp_api_hdr_t *wp_api_hdr = hdrbuf;
01116 
01117     if (hdrlen != sizeof(wp_api_hdr_t)) {
01118         /* error. Possible cause is a mismatch between versions of API header files. */
01119         DBG_ERR("hdrlen (%i) != sizeof(wp_api_hdr_t) (%i)\n", hdrlen, sizeof(wp_api_hdr_t));
01120         return -1;
01121     }
01122 
01123 #if defined(__WINDOWS__)
01124     //queue data for transmission
01125     if(DoWriteCommand(fd, databuf, datalen, hdrbuf, hdrlen)){
01126         //error
01127         DBG_ERR("DoWriteCommand() failed!! Check messages log.\n");
01128         return -1;
01129     }
01130 
01131     bsent=0;
01132     //check that frame was transmitted
01133     switch(wp_api_hdr->operation_status)
01134     {
01135     case SANG_STATUS_SUCCESS:
01136         bsent = datalen;
01137         break;
01138     default:
01139         DBG_ERR("Operation Status: %s(%d)\n",
01140             SDLA_DECODE_SANG_STATUS(wp_api_hdr->operation_status), wp_api_hdr->operation_status);
01141         break;
01142     }//switch()
01143 #else
01144     struct msghdr msg;
01145     struct iovec iov[2];
01146 
01147     memset(&msg,0,sizeof(struct msghdr));
01148 
01149     iov[0].iov_len=hdrlen;
01150     iov[0].iov_base=hdrbuf;
01151 
01152     iov[1].iov_len=datalen;
01153     iov[1].iov_base=databuf;
01154 
01155     msg.msg_iovlen=2;
01156     msg.msg_iov=iov;
01157 
01158     bsent = write(fd,&msg,datalen+hdrlen);
01159 
01160     if (bsent == (datalen+hdrlen)){
01161         wp_api_hdr->wp_api_hdr_operation_status=SANG_STATUS_SUCCESS;
01162         bsent-=sizeof(wp_api_hdr_t);
01163     } else if (errno == EBUSY){
01164         wp_api_hdr->wp_api_hdr_operation_status=SANG_STATUS_DEVICE_BUSY;
01165     } else {
01166         wp_api_hdr->wp_api_hdr_operation_status=SANG_STATUS_IO_ERROR;
01167     }
01168     wp_api_hdr->wp_api_hdr_data_length=bsent;
01169 
01170     //FIXME - THIS SHOULD BE DONE IN KERNEL
01171         wp_api_hdr->wp_api_tx_hdr_max_queue_length=16;
01172         wp_api_hdr->wp_api_tx_hdr_number_of_frames_in_queue=0;
01173 
01174 #endif
01175     return bsent;
01176 }

Here is the caller graph for this function:

int _SAPI_CALL sangoma_readmsg ( sng_fd_t  fd,
void *  hdrbuf,
int  hdrlen,
void *  databuf,
int  datalen,
int  flag 
)

Read Data from device.

Device READ / WRITE Functions

Definition at line 1046 of file libsangoma.c.

References wp_api_element::data, DBG_ERR, wp_api_element::hdr, SANG_STATUS_BUFFER_TOO_SMALL, SANG_STATUS_RX_DATA_AVAILABLE, and SDLA_DECODE_SANG_STATUS.

Referenced by read_data().

01047 {
01048     int rx_len=0;
01049 
01050 #if defined(__WINDOWS__)
01051     wp_api_hdr_t    *rx_hdr = (wp_api_hdr_t*)hdrbuf;
01052     wp_api_element_t wp_api_element;
01053 
01054     if(hdrlen != sizeof(wp_api_hdr_t)){
01055         //error
01056         DBG_ERR("hdrlen (%i) != sizeof(wp_api_hdr_t) (%i)\n", hdrlen, sizeof(wp_api_hdr_t));
01057         return -1;
01058     }
01059 
01060     if(DoReadCommand(fd, &wp_api_element)){
01061         //error
01062         DBG_ERR("DoReadCommand() failed! Check messages log.\n");
01063         return -4;
01064     }
01065 
01066     memcpy(rx_hdr, &wp_api_element.hdr, sizeof(wp_api_hdr_t));
01067 
01068     switch(rx_hdr->operation_status)
01069     {
01070     case SANG_STATUS_RX_DATA_AVAILABLE:
01071         /* ok */
01072         if(rx_hdr->data_length <= datalen){
01073             memcpy(databuf, wp_api_element.data, rx_hdr->data_length);
01074         }else{
01075             rx_hdr->operation_status = SANG_STATUS_BUFFER_TOO_SMALL;
01076         }
01077         break;
01078     default:
01079         /* note that SANG_STATUS_NO_DATA_AVAILABLE is NOT an error! */
01080         if(0)DBG_ERR("Operation Status: %s(%d)\n",
01081             SDLA_DECODE_SANG_STATUS(rx_hdr->operation_status), rx_hdr->operation_status);
01082         return -5;
01083     }
01084 
01085     rx_len = rx_hdr->data_length;
01086 #else
01087     struct msghdr msg;
01088     struct iovec iov[2];
01089 
01090     memset(&msg,0,sizeof(struct msghdr));
01091 
01092     iov[0].iov_len=hdrlen;
01093     iov[0].iov_base=hdrbuf;
01094 
01095     iov[1].iov_len=datalen;
01096     iov[1].iov_base=databuf;
01097 
01098     msg.msg_iovlen=2;
01099     msg.msg_iov=iov;
01100 
01101     rx_len = read(fd,&msg,sizeof(msg));
01102 
01103     if (rx_len <= sizeof(wp_api_hdr_t)){
01104         return -EINVAL;
01105     }
01106 
01107     rx_len-=sizeof(wp_api_hdr_t);
01108 #endif
01109     return rx_len;
01110 }                    

Here is the caller graph for this function:

sangoma_status_t _SAPI_CALL sangoma_wait_obj_create ( sangoma_wait_obj_t **  sangoma_wait_object,
sng_fd_t  fd,
sangoma_wait_obj_type_t  object_type 
)

Create a wait object that will be used with sangoma_waitfor_many() API.

Parameters:
sangoma_wait_object pointer a single device object
fd device file descriptor
object_type type of the wait object. see sangoma_wait_obj_type_t for types
See also:
sangoma_wait_obj_type_t
Returns:
SANG_STATUS_SUCCESS: success, or error status

Definition at line 446 of file libsangoma.c.

References DBG_INIT, DECODE_SANGOMA_WAIT_OBJECT_TYPE, FALSE, INVALID_HANDLE_VALUE, SANG_STATUS_FAILED_ALLOCATE_MEMORY, SANG_STATUS_GENERAL_ERROR, SANG_STATUS_INVALID_DEVICE, SANG_STATUS_SUCCESS, and SANGOMA_GENERIC_WAIT_OBJ.

Referenced by open_sangoma_device().

00447 {
00448     int err = 0;
00449     sangoma_wait_obj_t *sng_wait_obj;
00450 
00451     if (!sangoma_wait_object) { 
00452         return SANG_STATUS_INVALID_DEVICE;
00453     }
00454     *sangoma_wait_object = NULL;
00455     sng_wait_obj = malloc(sizeof(**sangoma_wait_object));
00456     if (!sng_wait_obj) {
00457         return SANG_STATUS_FAILED_ALLOCATE_MEMORY;
00458     }
00459 
00460     memset(sng_wait_obj, 0x00, sizeof(*sng_wait_obj));
00461     /* it is a first initialization of the object */
00462     sng_wait_obj->init_flag = LIBSNG_MAGIC_NO;
00463 
00464     sng_wait_obj->fd            = fd;
00465     sng_wait_obj->object_type   = object_type;
00466 
00467 #if defined(__WINDOWS__)
00468     DBG_INIT("%s(): sng_wait_obj ptr: 0x%p\n", __FUNCTION__, sng_wait_obj);
00469     DBG_INIT("%s(): fd: 0x%X, object_type: %s\n", __FUNCTION__, fd, DECODE_SANGOMA_WAIT_OBJECT_TYPE(object_type));
00470     DBG_INIT("%s(): sizeof(**sangoma_wait_object): %d\n", __FUNCTION__, sizeof(**sangoma_wait_object));
00471 
00472     if (SANGOMA_OBJ_IS_SIGNALABLE(sng_wait_obj)) {
00473         sng_wait_obj->generic_event_object.hEvent = CreateEvent( NULL, FALSE, FALSE, NULL);
00474         if(!sng_wait_obj->generic_event_object.hEvent){
00475             return SANG_STATUS_GENERAL_ERROR;
00476         }
00477     }
00478 
00479     if(SANGOMA_GENERIC_WAIT_OBJ == object_type){
00480         /* everything is done for the generic wait object */
00481         *sangoma_wait_object = sng_wait_obj;
00482         return SANG_STATUS_SUCCESS;
00483     }
00484 
00485     err = init_sangoma_event_object(sng_wait_obj, POLLIN /* must be a SINGLE bit because there is a signaling object for each bit */);
00486     if(SANG_STATUS_SUCCESS != err){
00487         return err;
00488     }
00489 
00490     err = init_sangoma_event_object(sng_wait_obj, POLLOUT /* must be a SINGLE bit because there is a signaling object for each bit */);
00491     if(SANG_STATUS_SUCCESS != err){
00492         return err;
00493     }
00494 
00495     err = init_sangoma_event_object(sng_wait_obj, POLLPRI /* must be a SINGLE bit because there is a signaling object for each bit */);
00496     if(SANG_STATUS_SUCCESS != err) {
00497         return err;
00498     }
00499         
00500     DBG_INIT("%s(): returning: %d", __FUNCTION__, err);
00501 #else
00502     int filedes[2];
00503     if (SANGOMA_OBJ_IS_SIGNALABLE(sng_wait_obj)) {
00504         sng_wait_obj->signal_read_fd = INVALID_HANDLE_VALUE;
00505         sng_wait_obj->signal_write_fd = INVALID_HANDLE_VALUE;
00506         /* if we want cross-process event notification we can use a named pipe with mkfifo() */
00507         if (pipe(filedes)) {
00508             return -1;
00509         }
00510         sng_wait_obj->signal_read_fd = filedes[0];
00511         sng_wait_obj->signal_write_fd = filedes[1];
00512     }
00513 #endif
00514     *sangoma_wait_object = sng_wait_obj;
00515     return err;
00516 }

Here is the caller graph for this function:

sangoma_status_t _SAPI_CALL sangoma_wait_obj_delete ( sangoma_wait_obj_t **  sangoma_wait_object  ) 

De-allocate all resources in a wait object.

Parameters:
sangoma_wait_object pointer to a pointer to a single device object
Returns:
SANG_STATUS_SUCCESS on success or some sangoma status error

Definition at line 524 of file libsangoma.c.

References SANG_STATUS_INVALID_DEVICE, SANG_STATUS_SUCCESS, sangoma_close(), and UNKNOWN_WAIT_OBJ.

Referenced by cleanup().

00525 {
00526     sangoma_wait_obj_t *sng_wait_obj = *sangoma_wait_object;
00527 #if defined(__WINDOWS__)
00528     int index = 0;
00529 #endif
00530 
00531     if(sng_wait_obj->init_flag != LIBSNG_MAGIC_NO){
00532         /* error. object was not initialized by sangoma_wait_obj_init() */
00533         return SANG_STATUS_INVALID_DEVICE;
00534     }
00535 
00536 #if defined(__WINDOWS__)
00537     if (SANGOMA_OBJ_IS_SIGNALABLE(sng_wait_obj)) {
00538         sangoma_close(&sng_wait_obj->generic_event_object.hEvent);
00539     }
00540     if (SANGOMA_OBJ_HAS_DEVICE(sng_wait_obj)) {
00541         for(index = 0; index < LIBSNG_NUMBER_OF_EVENT_OBJECTS; index++){
00542             sangoma_close(&sng_wait_obj->sng_event_objects[index].hEvent);
00543         }
00544     }
00545 #else
00546     if (SANGOMA_OBJ_IS_SIGNALABLE(sng_wait_obj)) {
00547         sangoma_close(&sng_wait_obj->signal_read_fd);
00548         sangoma_close(&sng_wait_obj->signal_write_fd);
00549     }
00550 #endif
00551     sng_wait_obj->init_flag = 0;
00552     sng_wait_obj->object_type = UNKNOWN_WAIT_OBJ;
00553     *sangoma_wait_object = NULL;
00554     return SANG_STATUS_SUCCESS;
00555 }

Here is the call graph for this function:

Here is the caller graph for this function:

sangoma_status_t _SAPI_CALL sangoma_wait_obj_signal ( sangoma_wait_obj_t sng_wait_obj  ) 

Set wait object to a signaled state.

Parameters:
sangoma_wait_object pointer a single device object
Returns:
0 on success, non-zero on error

Definition at line 563 of file libsangoma.c.

References SANG_STATUS_GENERAL_ERROR, SANG_STATUS_INVALID_DEVICE, and SANG_STATUS_SUCCESS.

00564 {
00565     if (!SANGOMA_OBJ_IS_SIGNALABLE(sng_wait_obj)) {
00566         /* even when Windows objects are always signalable for the sake of providing
00567          * a consistent interface to the user we downgrade the capabilities of Windows
00568          * objects unless the sangoma wait object is explicitly initialized as signalable
00569          * */
00570         return SANG_STATUS_INVALID_DEVICE;
00571     }
00572 #if defined(__WINDOWS__)
00573     if(sng_wait_obj->generic_event_object.hEvent){
00574         if (!SetEvent(sng_wait_obj->generic_event_object.hEvent)) {
00575             return SANG_STATUS_GENERAL_ERROR;
00576         }
00577     }
00578 #else
00579     /* at this point we know is a signalable object and has a signal_write_fd */
00580     if (write(sng_wait_obj->signal_write_fd, "s", 1) < 1) {
00581         return SANG_STATUS_GENERAL_ERROR;
00582     }
00583 #endif
00584     return SANG_STATUS_SUCCESS;
00585 }

sng_fd_t _SAPI_CALL sangoma_wait_obj_get_fd ( sangoma_wait_obj_t sng_wait_obj  ) 

Retrieve fd device file descriptor which was the 'fd' parameter for sangoma_wait_obj_init().

Parameters:
sangoma_wait_object pointer a single device object
Returns:
fd - device file descriptor

Definition at line 593 of file libsangoma.c.

Referenced by cleanup(), handle_tdm_event(), read_data(), and write_data().

00594 {
00595     return sng_wait_obj->fd;
00596 }

Here is the caller graph for this function:

void* _SAPI_CALL sangoma_wait_obj_get_context ( sangoma_wait_obj_t sng_wait_obj  ) 

Retrieve the user context (if any) that was set via sangoma_wait_obj_set_context.

Parameters:
sangoma_wait_object pointer a single device object
Returns:
void*

Definition at line 617 of file libsangoma.c.

Referenced by cleanup(), read_data(), and write_data().

00618 {
00619     return sng_wait_obj->context;
00620 }

Here is the caller graph for this function:

int _SAPI_CALL sangoma_cmd_exec ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Execute Sangoma API Command.

Device API COMMAND Functions

Definition at line 1192 of file libsangoma.c.

References wanpipe_api_cmd::cmd, WANPIPE_IOCTL_API_CMD, and wanpipe_api::wp_cmd.

Referenced by sangoma_disable_bri_bchan_loopback(), sangoma_enable_bri_bchan_loopback(), sangoma_flush_bufs(), sangoma_flush_stats(), sangoma_get_cpld_version(), sangoma_get_driver_version(), sangoma_get_firmware_version(), sangoma_get_full_cfg(), sangoma_get_hw_coding(), sangoma_get_open_cnt(), sangoma_get_rx_queue_sz(), sangoma_get_stats(), sangoma_get_tx_queue_sz(), sangoma_open_api_span_chan(), sangoma_read_event(), sangoma_set_rm_rxflashtime(), sangoma_set_rx_queue_sz(), sangoma_set_tx_queue_sz(), sangoma_tdm_disable_hwec(), sangoma_tdm_disable_rbs_events(), sangoma_tdm_enable_hwec(), sangoma_tdm_enable_rbs_events(), sangoma_tdm_get_codec(), sangoma_tdm_get_power_level(), sangoma_tdm_get_usr_mtu_mru(), sangoma_tdm_get_usr_period(), sangoma_tdm_read_rbs(), sangoma_tdm_set_codec(), sangoma_tdm_set_power_level(), sangoma_tdm_set_usr_period(), and sangoma_tdm_write_rbs().

01193 {
01194     int err;
01195 
01196 #if defined(__WINDOWS__)
01197     err = tdmv_api_ioctl(fd, &tdm_api->wp_cmd);
01198 #else
01199     err = ioctl(fd,WANPIPE_IOCTL_API_CMD,&tdm_api->wp_cmd);
01200     if (err < 0){
01201         char tmp[50];
01202         sprintf(tmp,"TDM API: CMD: %i\n",tdm_api->wp_cmd.cmd);
01203         perror(tmp);
01204         return -1;
01205     }
01206 #endif
01207     return err;
01208 }

Here is the caller graph for this function:

int _SAPI_CALL sangoma_get_full_cfg ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Read tdm api device configuration.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok

Definition at line 1214 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::fe_alarms, wanpipe_api_cmd::hw_mtu_mru, wanpipe_api_cmd::hw_tdm_coding, wanpipe_api_cmd::idle_flag, wanpipe_api_cmd::power_level, wanpipe_api_cmd::rx_disable, wanpipe_chan_stats::rx_errors, wanpipe_chan_stats::rx_fifo_errors, wanpipe_chan_stats::rx_packets, sangoma_cmd_exec(), wanpipe_api_cmd::stats, wanpipe_api_cmd::tdm_codec, wanpipe_chan_stats::tx_carrier_errors, wanpipe_api_cmd::tx_disable, wanpipe_chan_stats::tx_errors, wanpipe_chan_stats::tx_packets, wanpipe_api_cmd::usr_mtu_mru, wanpipe_api_cmd::usr_period, WP_API_CMD_GET_FULL_CFG, and wanpipe_api::wp_cmd.

Referenced by open_sangoma_device().

01215 {
01216     int err;
01217 
01218     tdm_api->wp_cmd.cmd = WP_API_CMD_GET_FULL_CFG;
01219 
01220     err=sangoma_cmd_exec(fd,tdm_api);
01221     if (err){
01222         return err;
01223     }
01224 
01225 #if 0
01226     printf("TDM API CFG:\n");
01227     printf("\thw_tdm_coding:\t%d\n",tdm_api->wp_cmd.hw_tdm_coding);
01228     printf("\thw_mtu_mru:\t%d\n",tdm_api->wp_cmd.hw_mtu_mru);
01229     printf("\tusr_period:\t%d\n",tdm_api->wp_cmd.usr_period);
01230     printf("\ttdm_codec:\t%d\n",tdm_api->wp_cmd.tdm_codec);
01231     printf("\tpower_level:\t%d\n",tdm_api->wp_cmd.power_level);
01232     printf("\trx_disable:\t%d\n",tdm_api->wp_cmd.rx_disable);
01233     printf("\ttx_disable:\t%d\n",tdm_api->wp_cmd.tx_disable);
01234     printf("\tusr_mtu_mru:\t%d\n",tdm_api->wp_cmd.usr_mtu_mru);
01235     printf("\tidle flag:\t0x%02X\n",tdm_api->wp_cmd.idle_flag);
01236 
01237 #ifdef WP_API_FEATURE_FE_ALARM
01238     printf("\tfe alarms:\t0x%02X\n",tdm_api->wp_cmd.fe_alarms);
01239 #endif
01240     
01241     printf("\trx pkt\t%d\ttx pkt\t%d\n",tdm_api->wp_cmd.stats.rx_packets,
01242                 tdm_api->wp_cmd.stats.tx_packets);
01243     printf("\trx err\t%d\ttx err\t%d\n",
01244                 tdm_api->wp_cmd.stats.rx_errors,
01245                 tdm_api->wp_cmd.stats.tx_errors);
01246 #ifndef __WINDOWS__
01247     printf("\trx ovr\t%d\ttx idl\t%d\n",
01248                 tdm_api->wp_cmd.stats.rx_fifo_errors,
01249                 tdm_api->wp_cmd.stats.tx_carrier_errors);
01250 #endif      
01251 #endif      
01252     
01253     return 0;
01254 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _SAPI_CALL sangoma_tdm_set_usr_period ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
int  period 
)

Set Tx/Rx Period in Milliseconds.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
period value in miliseconds (1,2,5,10)
Returns:
non-zero: error, 0: ok
Only valid in CHAN Operation Mode

Definition at line 1313 of file libsangoma.c.

References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), wanpipe_api_cmd::usr_period, WP_API_CMD_SET_USR_PERIOD, and wanpipe_api::wp_cmd.

Referenced by open_sangoma_device().

01314 {
01315     int err;
01316 
01317     tdm_api->wp_cmd.cmd = WP_API_CMD_SET_USR_PERIOD;
01318     tdm_api->wp_cmd.usr_period = period;
01319 
01320     err=sangoma_cmd_exec(fd,tdm_api);
01321 
01322     return err;
01323 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _SAPI_CALL sangoma_tdm_get_usr_period ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Get Tx/Rx Period in Milliseconds.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
negative: error or configured period value

Definition at line 1332 of file libsangoma.c.

References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), wanpipe_api_cmd::usr_period, WP_API_CMD_GET_USR_PERIOD, and wanpipe_api::wp_cmd.

01333 {
01334     int err;
01335 
01336     tdm_api->wp_cmd.cmd = WP_API_CMD_GET_USR_PERIOD;
01337 
01338     err=sangoma_cmd_exec(fd,tdm_api);
01339     if (err){
01340         return err;
01341     }
01342 
01343     return tdm_api->wp_cmd.usr_period;
01344 }

Here is the call graph for this function:

int _SAPI_CALL sangoma_tdm_get_usr_mtu_mru ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Get Tx/Rx MTU/MRU in bytes.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
negative: error or configured mtu/mru in bytes

Definition at line 1388 of file libsangoma.c.

References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), wanpipe_api_cmd::usr_mtu_mru, WP_API_CMD_GET_USR_MTU_MRU, and wanpipe_api::wp_cmd.

01389 {
01390     int err;
01391 
01392     tdm_api->wp_cmd.cmd = WP_API_CMD_GET_USR_MTU_MRU;
01393 
01394     err=sangoma_cmd_exec(fd,tdm_api);
01395     if (err){
01396         return err;
01397     }
01398 
01399     return tdm_api->wp_cmd.usr_mtu_mru;
01400 }

Here is the call graph for this function:

int _SAPI_CALL sangoma_flush_bufs ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Flush buffers from current channel.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok

Definition at line 1440 of file libsangoma.c.

References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), WP_API_CMD_FLUSH_BUFFERS, and wanpipe_api::wp_cmd.

01441 {
01442     int err;
01443     tdm_api->wp_cmd.cmd = WP_API_CMD_FLUSH_BUFFERS;
01444 
01445     err=sangoma_cmd_exec(fd,tdm_api);
01446     if (err){
01447         return err;
01448     }
01449 
01450     return 0;
01451 }

Here is the call graph for this function:

int _SAPI_CALL sangoma_tdm_enable_rbs_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
int  poll_in_sec 
)

Enable RBS Events on a device.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
poll_in_sec driver poll period for rbs events
Returns:
non-zero: error, 0: ok

Definition at line 1453 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::rbs_poll, sangoma_cmd_exec(), WP_API_CMD_ENABLE_RBS_EVENTS, and wanpipe_api::wp_cmd.

Referenced by open_sangoma_device().

01453                                                                                                    {
01454     
01455     int err;
01456     
01457     tdm_api->wp_cmd.cmd = WP_API_CMD_ENABLE_RBS_EVENTS;
01458     tdm_api->wp_cmd.rbs_poll=poll_in_sec;
01459     
01460     err=sangoma_cmd_exec(fd,tdm_api);
01461     if (err){
01462         return err;
01463     }
01464 
01465     return 0;
01466 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _SAPI_CALL sangoma_tdm_disable_rbs_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Disable RBS Events for a device.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok

Definition at line 1469 of file libsangoma.c.

References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), WP_API_CMD_DISABLE_RBS_EVENTS, and wanpipe_api::wp_cmd.

Referenced by cleanup().

01469                                                                                    {
01470 
01471     int err;
01472     tdm_api->wp_cmd.cmd = WP_API_CMD_DISABLE_RBS_EVENTS;
01473     
01474     err=sangoma_cmd_exec(fd,tdm_api);
01475     if (err){
01476         return err;
01477     }
01478 
01479     return 0;
01480 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _SAPI_CALL sangoma_tdm_write_rbs ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
int  channel,
unsigned char  rbs 
)

Write RBS Bits on a device.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
channel t1/e1 timeslot
rbs rbs bits (ABCD)
Returns:
non-zero: error, 0: ok

Definition at line 1482 of file libsangoma.c.

References wanpipe_api_cmd::chan, wanpipe_api_cmd::cmd, wanpipe_api_cmd::rbs_tx_bits, sangoma_cmd_exec(), WP_API_CMD_WRITE_RBS_BITS, and wanpipe_api::wp_cmd.

Referenced by read_data().

01483 {
01484     
01485     int err;
01486     tdm_api->wp_cmd.cmd = WP_API_CMD_WRITE_RBS_BITS;
01487     tdm_api->wp_cmd.chan = (unsigned char)channel;
01488     tdm_api->wp_cmd.rbs_tx_bits=rbs;
01489     
01490     err=sangoma_cmd_exec(fd,tdm_api);
01491     if (err){
01492         return err;
01493     }
01494 
01495     return 0;
01496 }        

Here is the call graph for this function:

Here is the caller graph for this function:

int _SAPI_CALL sangoma_tdm_read_rbs ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
int  channel,
unsigned char *  rbs 
)

Read RBS Bits on a device.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
channel t1/e1 timeslot
rbs pointer to rbs bits (ABCD)
Returns:
non-zero: error, 0: ok

Definition at line 1499 of file libsangoma.c.

References wanpipe_api_cmd::chan, wanpipe_api_cmd::cmd, wanpipe_api_cmd::rbs_rx_bits, wanpipe_api_cmd::rbs_tx_bits, sangoma_cmd_exec(), WP_API_CMD_READ_RBS_BITS, and wanpipe_api::wp_cmd.

01500 {
01501     
01502     int err;
01503     tdm_api->wp_cmd.cmd = WP_API_CMD_READ_RBS_BITS;
01504     tdm_api->wp_cmd.chan = (unsigned char)channel;
01505     tdm_api->wp_cmd.rbs_tx_bits=0;
01506     
01507     err=sangoma_cmd_exec(fd,tdm_api);
01508     if (err){
01509         return err;
01510     }
01511 
01512     *rbs=(unsigned char)tdm_api->wp_cmd.rbs_rx_bits;
01513 
01514     return 0;
01515 }        

Here is the call graph for this function:

int sangoma_tdm_enable_dtmf_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Enable DTMF Detection on Octasic chip (if hw supports it).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on cards that have HWEC

Referenced by open_sangoma_device().

Here is the caller graph for this function:

int sangoma_tdm_disable_dtmf_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Disable DTMF Detection on Octasic chip (if hw supports it).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on cards that have HWEC

Referenced by cleanup().

Here is the caller graph for this function:

int sangoma_tdm_enable_rm_dtmf_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Enable DTMF Detection on Analog/Remora SLIC Chip.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on Analog Cards

Referenced by open_sangoma_device().

Here is the caller graph for this function:

int sangoma_tdm_disable_rm_dtmf_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Disable DTMF Detection on Analog/Remora SLIC Chip.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on Analog Cards

Referenced by cleanup().

Here is the caller graph for this function:

int sangoma_tdm_enable_rxhook_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Enable RX HOOK Events (Analog Only).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on Analog Cards

Referenced by open_sangoma_device().

Here is the caller graph for this function:

int sangoma_tdm_disable_rxhook_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Disable RX HOOK Events (Analog Only).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on Analog Cards

Referenced by cleanup().

Here is the caller graph for this function:

int sangoma_tdm_enable_ring_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Enable RING Events (Analog Only).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on Analog Cards

int sangoma_tdm_disable_ring_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Disable RING Events (Analog Only).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on Analog Cards

int sangoma_tdm_enable_ring_detect_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Enable RING DETECT Events (Analog Only).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on Analog Cards

int sangoma_tdm_disable_ring_detect_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Disable RING DETECT Events (Analog Only).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on Analog Cards

int sangoma_tdm_enable_ring_trip_detect_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Enable RING TRIP Events (Analog Only).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on Analog Cards

int sangoma_tdm_disable_ring_trip_detect_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Disable RING TRIP Events (Analog Only).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on Analog Cards

int sangoma_tdm_enable_tone_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
uint16_t  tone_id 
)

Transmit a TONE on this device (Analog Only).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
tone_id tone type to transmit
Returns:
non-zero: error, 0: ok
Supported only on Analog Cards

int sangoma_tdm_disable_tone_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Enable TONE Events (Analog Only).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on Analog Cards

int sangoma_tdm_txsig_onhook ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Tranmsmit TX SIG ON HOOK (Analog Only).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on Analog Cards

int sangoma_tdm_txsig_offhook ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Tranmsmit TX SIG OFF HOOK (Analog Only).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on Analog Cards

int sangoma_tdm_txsig_start ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Tranmsmit TX SIG START (Analog Only).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on Analog Cards

int sangoma_tdm_txsig_kewl ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Tranmsmit TX SIG KEWL START (Analog Only).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on Analog Cards

int _SAPI_CALL sangoma_tdm_enable_hwec ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Enable HWEC on this channel.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on cards that have HWEC

Definition at line 1903 of file libsangoma.c.

References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), and wanpipe_api::wp_cmd.

01904 {
01905         int err;
01906 
01907         tdm_api->wp_cmd.cmd = WP_API_CMD_ENABLE_HWEC;
01908         err=sangoma_cmd_exec(fd,tdm_api);
01909         if (err){
01910                 return err;
01911         }
01912 
01913         return 0;
01914 }

Here is the call graph for this function:

int _SAPI_CALL sangoma_tdm_disable_hwec ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Disable HWEC on this channel.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
Supported only on cards that have HWEC

Definition at line 1916 of file libsangoma.c.

References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), and wanpipe_api::wp_cmd.

01917 {
01918         int err;
01919 
01920         tdm_api->wp_cmd.cmd = WP_API_CMD_DISABLE_HWEC;
01921         err=sangoma_cmd_exec(fd,tdm_api);
01922         if (err){
01923                 return err;
01924         }
01925 
01926         return 0;
01927 }

Here is the call graph for this function:

int _SAPI_CALL sangoma_tdm_get_fe_alarms ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
unsigned int *  alarms 
)

Get Front End Alarms (T1/E1 Only).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
alarms bit map status of T1/E1 alarms
Returns:
non-zero: error, 0: ok
Supported only on T1/E1 Cards

int sangoma_set_fe_status ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
unsigned char  new_status 
)

Set Device Link Status (Connected/Disconnected).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
new_status new status 0=Link UP 1=Link Down
Returns:
non-zero: error, 0: ok

int _SAPI_CALL sangoma_enable_bri_bchan_loopback ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
int  channel 
)

Enable BRI Bchannel loopback - used when debugging bri device.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
channel bri bchannel 1 or 2
Returns:
non-zero: error, 0: ok

Definition at line 1996 of file libsangoma.c.

References wp_api_event::channel, wanpipe_api_cmd::cmd, wanpipe_api_cmd::event, sangoma_cmd_exec(), WP_API_EVENT_ENABLE, and wanpipe_api::wp_cmd.

01997 {
01998     tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
01999     tdm_api->wp_cmd.event.channel   = (unsigned char)channel;
02000     tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_BRI_CHAN_LOOPBACK;
02001     tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_ENABLE;
02002     return sangoma_cmd_exec(fd, tdm_api);
02003 }

Here is the call graph for this function:

int _SAPI_CALL sangoma_disable_bri_bchan_loopback ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
int  channel 
)

Disable BRI Bchannel loopback - used when debugging bri device.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
channel bri bchannel 1 or 2
Returns:
non-zero: error, 0: ok

Definition at line 1987 of file libsangoma.c.

References wp_api_event::channel, wanpipe_api_cmd::cmd, wanpipe_api_cmd::event, sangoma_cmd_exec(), WP_API_EVENT_DISABLE, and wanpipe_api::wp_cmd.

01988 {
01989     tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
01990     tdm_api->wp_cmd.event.channel   = (unsigned char)channel;
01991     tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_BRI_CHAN_LOOPBACK;
01992     tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_DISABLE;
01993     return sangoma_cmd_exec(fd, tdm_api);
01994 }

Here is the call graph for this function:

int _SAPI_CALL sangoma_get_tx_queue_sz ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Get Tx Queue Size for this channel.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok

Definition at line 2006 of file libsangoma.c.

References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), wanpipe_api_cmd::tx_queue_sz, WP_API_CMD_GET_TX_Q_SIZE, and wanpipe_api::wp_cmd.

Referenced by open_sangoma_device().

02007 {
02008     int err;
02009 
02010     tdm_api->wp_cmd.cmd = WP_API_CMD_GET_TX_Q_SIZE;
02011     tdm_api->wp_cmd.tx_queue_sz = 0;
02012     
02013     err=sangoma_cmd_exec(fd, tdm_api);
02014     if (err < 0) {
02015         return err;
02016     }
02017 
02018     return tdm_api->wp_cmd.tx_queue_sz;
02019 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _SAPI_CALL sangoma_set_tx_queue_sz ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
int  size 
)

Get Tx Queue Size for this channel.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
size tx queue size (minimum value of 1)
Returns:
non-zero: error, 0: ok

Definition at line 2021 of file libsangoma.c.

References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), wanpipe_api_cmd::tx_queue_sz, WP_API_CMD_SET_TX_Q_SIZE, and wanpipe_api::wp_cmd.

Referenced by open_sangoma_device().

02022 {
02023     if (size < 0) {
02024         return -1;
02025     }
02026 
02027     tdm_api->wp_cmd.cmd = WP_API_CMD_SET_TX_Q_SIZE;
02028     tdm_api->wp_cmd.tx_queue_sz = size;
02029     
02030     return sangoma_cmd_exec(fd, tdm_api);
02031 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _SAPI_CALL sangoma_get_rx_queue_sz ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Get Rx Queue Size for this channel.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok

Definition at line 2033 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::rx_queue_sz, sangoma_cmd_exec(), WP_API_CMD_GET_RX_Q_SIZE, and wanpipe_api::wp_cmd.

Referenced by open_sangoma_device().

02034 {
02035     int err;
02036 
02037     tdm_api->wp_cmd.cmd = WP_API_CMD_GET_RX_Q_SIZE;
02038     tdm_api->wp_cmd.rx_queue_sz = 0;
02039     
02040     err=sangoma_cmd_exec(fd, tdm_api);
02041     if (err < 0) {
02042         return err;
02043     }
02044 
02045     return tdm_api->wp_cmd.rx_queue_sz;
02046 
02047 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _SAPI_CALL sangoma_set_rx_queue_sz ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
int  size 
)

Get Tx Queue Size for this channel.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
size rx queue size (minimum value of 1)
Returns:
non-zero: error, 0: ok

Definition at line 2049 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::rx_queue_sz, sangoma_cmd_exec(), WP_API_CMD_SET_RX_Q_SIZE, and wanpipe_api::wp_cmd.

Referenced by open_sangoma_device().

02050 {
02051     if (size < 0) {
02052         return -1;
02053     }
02054 
02055     tdm_api->wp_cmd.cmd = WP_API_CMD_SET_RX_Q_SIZE;
02056     tdm_api->wp_cmd.rx_queue_sz = size;
02057     
02058     return sangoma_cmd_exec(fd, tdm_api);
02059 
02060 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _SAPI_CALL sangoma_get_hw_coding ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Get HW Voice Coding (ulaw/alaw).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
This function will return the low level voice coding depending on configuration. (ulaw or alaw)

Definition at line 1352 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::hw_tdm_coding, sangoma_cmd_exec(), WP_API_CMD_GET_HW_CODING, and wanpipe_api::wp_cmd.

01353 {
01354         int err;
01355         tdm_api->wp_cmd.cmd = WP_API_CMD_GET_HW_CODING;
01356         err=sangoma_cmd_exec(fd,tdm_api);
01357         if (err){
01358                 return err;
01359         }
01360         return tdm_api->wp_cmd.hw_tdm_coding;
01361 }

Here is the call graph for this function:

int sangoma_tdm_get_hw_dtmf ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Check if hwdtmf support is available.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
This function will check if hw supports HW DTMF.

int _SAPI_CALL sangoma_span_chan_toif ( int  span,
int  chan,
char *  interface_name 
)

Convert Span & Chan to interface name.

Device OPEN / CLOSE Functions

Definition at line 781 of file libsangoma.c.

00782 {
00783 #if defined(__WINDOWS__)
00784 /* FIXME: Not implemented */
00785     return -1;
00786 #else
00787     sprintf(interface_name,"s%ic%i",span,chan);
00788 #endif
00789     return 0;
00790 }

int _SAPI_CALL sangoma_span_chan_fromif ( char *  interface_name,
int *  span,
int *  chan 
)

Convert Interace Name to Span & Chan.

Parameters:
interface_name pointer to string containing interface name
span integer pointer where to write span value
chan integer pointer where to write chan value
Returns:
non-zero = error, 0 = ok

Definition at line 855 of file libsangoma.c.

References FNAME_LEN.

00856 {
00857     char *p = NULL, *sp = NULL, *ch = NULL;
00858     int ret = 0;
00859     char data[FNAME_LEN];
00860 
00861     strncpy(data, interface_name, FNAME_LEN);
00862     if ((data[0])) {
00863         for (p = data; *p; p++) {
00864             if (sp && *p == 'c') {
00865                 *p = '\0';
00866                 ch = (p + 1);
00867                 break;
00868             } else if (*p == 's') {
00869                 sp = (p + 1);
00870             }
00871         }
00872 
00873         if(ch && sp) {
00874             *span = atoi(sp);
00875             *chan = atoi(ch);
00876             ret = 1;
00877         } else {
00878             *span = -1;
00879             *chan = -1;
00880         }
00881     }
00882 
00883     return ret;
00884 }

int _SAPI_CALL sangoma_interface_wait_up ( int  span,
int  chan,
int  sectimeout 
)

Wait for a sangoma device to come up (ie: Linux wait for /dev/wanpipex_1 to come up).

Parameters:
span span number of the device to wait
chan chan number of the device to wait
sectimeout how many seconds to wait for the device to come up, -1 to wait forever
Returns:
non-zero = error, 0 = ok

Definition at line 823 of file libsangoma.c.

References FNAME_LEN, and WP_INTERFACE_NAME_FORM.

00824 {
00825 #if defined(__WINDOWS__)
00826   /* Windows does not need to wait for interfaces to come up */
00827   return 0;
00828 #else
00829     char interface_name[FNAME_LEN];
00830   struct stat statbuf;
00831   struct timeval endtime = {0,0};
00832   struct timeval curtime = {0,0};
00833   int counter;
00834   int rc;
00835   if (sectimeout >= 0 && gettimeofday(&endtime, NULL)) {
00836     return -1;
00837   }
00838   snprintf(interface_name, sizeof(interface_name), "/dev/" WP_INTERFACE_NAME_FORM, span, chan);
00839   endtime.tv_sec += sectimeout;
00840   do {
00841     counter = 0;
00842     while ((rc = stat(interface_name, &statbuf)) && errno == ENOENT && counter != 10) {
00843       poll(0, 0, 100); // test in 100ms increments
00844       counter++;
00845     }
00846     if (!rc || errno != ENOENT) break;
00847     if (gettimeofday(&curtime, NULL)) {
00848       return -1;
00849     }
00850   } while (sectimeout < 0 || timercmp(&endtime, &curtime,>));
00851   return rc;
00852 #endif
00853 }

int _SAPI_CALL sangoma_get_driver_version ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
wan_driver_version_t drv_ver 
)

Get Device Driver Version Number.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
drv_ver driver version structure that will contain the driver version
Returns:
non-zero = error, 0 = ok

Definition at line 2062 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::data_len, sangoma_cmd_exec(), wanpipe_api_cmd::version, WP_API_CMD_DRIVER_VERSION, and wanpipe_api::wp_cmd.

02063 {
02064     int err;
02065 
02066     tdm_api->wp_cmd.cmd = WP_API_CMD_DRIVER_VERSION;
02067 
02068     err = sangoma_cmd_exec(fd, tdm_api);
02069     if (err == 0) {
02070         if (tdm_api->wp_cmd.data_len == sizeof(wan_driver_version_t)) {
02071             if (drv_ver) {
02072                 memcpy(drv_ver,&tdm_api->wp_cmd.version,sizeof(wan_driver_version_t));
02073             }
02074         } else {
02075             return -1;
02076         }
02077     }
02078 
02079     return err;
02080 }

Here is the call graph for this function:

int _SAPI_CALL sangoma_get_firmware_version ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
unsigned char *  ver 
)

Get Hardware/Firmware Version.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
ver hardware/firmware version number
Returns:
non-zero = error, 0 = ok

Definition at line 2082 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::data, wanpipe_api_cmd::data_len, sangoma_cmd_exec(), WP_API_CMD_FIRMWARE_VERSION, and wanpipe_api::wp_cmd.

02083 {
02084     int err;
02085 
02086     tdm_api->wp_cmd.cmd = WP_API_CMD_FIRMWARE_VERSION;
02087 
02088     err = sangoma_cmd_exec(fd, tdm_api);
02089     if (err == 0) {
02090         if (tdm_api->wp_cmd.data_len == sizeof(unsigned char)) {
02091             *ver = tdm_api->wp_cmd.data[0];
02092         } else {
02093             return -1;
02094         }
02095     }
02096 
02097     return err;
02098 }

Here is the call graph for this function:

int _SAPI_CALL sangoma_get_cpld_version ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
unsigned char *  ver 
)

Get Hardare/CPLD Version.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
ver hardware/cpld version number
Returns:
non-zero = error, 0 = ok

Definition at line 2101 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::data, wanpipe_api_cmd::data_len, sangoma_cmd_exec(), WP_API_CMD_CPLD_VERSION, and wanpipe_api::wp_cmd.

02102 {
02103     int err;
02104 
02105     tdm_api->wp_cmd.cmd = WP_API_CMD_CPLD_VERSION;
02106 
02107     err = sangoma_cmd_exec(fd, tdm_api);
02108     if (err == 0) {
02109         if (tdm_api->wp_cmd.data_len == sizeof(unsigned char)) {
02110             *ver = tdm_api->wp_cmd.data[0];
02111         } else {
02112             return -1;
02113         }
02114     }
02115 
02116     return err;
02117 }

Here is the call graph for this function:

int _SAPI_CALL sangoma_get_stats ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
wanpipe_chan_stats_t stats 
)

Get Device Statistics. Statistics will be available in tdm_api->wp_cmd.stats structure.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
stats stats structure will be filled with device stats. (Optional, can be left NULL)
Returns:
non-zero = error, 0 = ok

Definition at line 2119 of file libsangoma.c.

References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), wanpipe_api_cmd::stats, WP_API_CMD_GET_STATS, and wanpipe_api::wp_cmd.

02120 {
02121     int err;
02122 
02123     tdm_api->wp_cmd.cmd = WP_API_CMD_GET_STATS;
02124 
02125     err = sangoma_cmd_exec(fd, tdm_api);
02126     if (err == 0) {
02127         if (stats) {
02128             memcpy(stats,&tdm_api->wp_cmd.stats,sizeof(wanpipe_chan_stats_t));
02129         }
02130     }
02131 
02132     return err;
02133 }

Here is the call graph for this function:

int _SAPI_CALL sangoma_flush_stats ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Flush/Reset device statistics.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero = error, 0 = ok

Definition at line 2135 of file libsangoma.c.

References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), WP_API_CMD_RESET_STATS, and wanpipe_api::wp_cmd.

02136 {
02137     tdm_api->wp_cmd.cmd = WP_API_CMD_RESET_STATS;
02138     return sangoma_cmd_exec(fd, tdm_api);
02139 }

Here is the call graph for this function:

int _SAPI_CALL sangoma_set_rm_rxflashtime ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
int  rxflashtime 
)

Set rxflashtime for FXS module Wink-Flash Event.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
rxflashtime time value
Returns:
non-zero = error, 0 = ok

Definition at line 2141 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::rxflashtime, sangoma_cmd_exec(), WP_API_CMD_SET_RM_RXFLASHTIME, and wanpipe_api::wp_cmd.

02142 {
02143     int err;
02144 
02145     tdm_api->wp_cmd.cmd = WP_API_CMD_SET_RM_RXFLASHTIME;
02146     tdm_api->wp_cmd.rxflashtime=rxflashtime;
02147     err = sangoma_cmd_exec(fd, tdm_api);
02148     return err;
02149 }

Here is the call graph for this function:

int _SAPI_CALL sangoma_read_event ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Read API Events.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
non-zero: error, 0: ok
The TDM API structure will be populated with a TDM API or WAN Event. This function usually used after wait() function indicated that event has occured.

Definition at line 1517 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::event, sangoma_cmd_exec(), WP_API_EVENT_POLARITY_REVERSE, wanpipe_api::wp_callback, wanpipe_api::wp_cmd, wanpipe_api_callbacks::wp_dtmf_event, wanpipe_api_callbacks::wp_fe_alarm_event, wanpipe_api_callbacks::wp_link_status_event, wanpipe_api_callbacks::wp_rbs_event, wanpipe_api_callbacks::wp_ring_detect_event, wanpipe_api_callbacks::wp_ring_trip_detect_event, and wanpipe_api_callbacks::wp_rxhook_event.

Referenced by handle_tdm_event().

01518 {
01519 
01520 #ifdef WP_API_FEATURE_EVENTS
01521     wp_api_event_t *rx_event;
01522     int err;
01523 
01524     tdm_api->wp_cmd.cmd = WP_API_CMD_READ_EVENT;
01525     
01526     err=sangoma_cmd_exec(fd,tdm_api);
01527     if (err){
01528         return err;
01529     }
01530 
01531     rx_event = &tdm_api->wp_cmd.event;
01532 
01533 
01534     /*
01535      The use of callbacks here is purely optional and is left
01536      here for backward compatibility purposes.  By default user
01537      should handle events outside this funciton. This function
01538      should only be used to read the event
01539     */
01540 
01541     switch (rx_event->wp_api_event_type){
01542     
01543     case WP_API_EVENT_RBS:
01544         if (tdm_api->wp_callback.wp_rbs_event) {
01545             tdm_api->wp_callback.wp_rbs_event(fd,rx_event->wp_api_event_rbs_bits);
01546         }
01547         
01548         break;
01549     
01550 #ifdef WP_API_FEATURE_DTMF_EVENTS
01551     case WP_API_EVENT_DTMF:
01552         if (tdm_api->wp_callback.wp_dtmf_event) {
01553             tdm_api->wp_callback.wp_dtmf_event(fd,
01554                         rx_event->wp_api_event_dtmf_digit,
01555                         rx_event->wp_api_event_dtmf_type,
01556                         rx_event->wp_api_event_dtmf_port);
01557         }
01558         break;
01559 #endif
01560         
01561     case WP_API_EVENT_RXHOOK:
01562         if (tdm_api->wp_callback.wp_rxhook_event) {
01563             tdm_api->wp_callback.wp_rxhook_event(fd,
01564                         rx_event->wp_api_event_hook_state);
01565         }
01566         break;
01567 
01568     case WP_API_EVENT_RING_DETECT:
01569         if (tdm_api->wp_callback.wp_ring_detect_event) {
01570             tdm_api->wp_callback.wp_ring_detect_event(fd,
01571                         rx_event->wp_api_event_ring_state);
01572         }
01573         break;
01574 
01575     case WP_API_EVENT_RING_TRIP_DETECT:
01576         if (tdm_api->wp_callback.wp_ring_trip_detect_event) {
01577             tdm_api->wp_callback.wp_ring_trip_detect_event(fd,
01578                         rx_event->wp_api_event_ring_state);
01579         }
01580         break;
01581 
01582 #ifdef WP_API_FEATURE_FE_ALARM
01583     case WP_API_EVENT_ALARM:
01584         if (tdm_api->wp_callback.wp_fe_alarm_event) {
01585             tdm_api->wp_callback.wp_fe_alarm_event(fd,
01586                         rx_event->wp_api_event_alarm);
01587         }   
01588         break; 
01589 #endif
01590 
01591 #ifdef WP_API_FEATURE_LINK_STATUS
01592     /* Link Status */   
01593     case WP_API_EVENT_LINK_STATUS:
01594         if(tdm_api->wp_callback.wp_link_status_event){
01595             tdm_api->wp_callback.wp_link_status_event(fd,
01596                         rx_event->wp_api_event_link_status);
01597         }
01598         
01599         break;
01600 #endif
01601 
01602 #ifdef WP_API_FEATURE_POL_REV
01603     case WP_API_EVENT_POLARITY_REVERSE:
01604         break;
01605 #endif  
01606     default:
01607 #ifdef __WINDOWS__
01608         printf("libsangoma: %s fd=0x%p: Unknown TDM event!", __FUNCTION__,fd);
01609 #else
01610         printf("libsangoma: %s fd=%d: Unknown TDM event!", __FUNCTION__, fd);
01611 #endif
01612         break;
01613     }
01614     
01615     return 0;
01616 #else
01617     printf("Error: Read Event not supported!\n");
01618     return -1;
01619 #endif
01620 }        

Here is the call graph for this function:

Here is the caller graph for this function:

int _SAPI_CALL sangoma_driver_port_start ( sng_fd_t  fd,
port_management_struct_t *  port_mgmnt,
unsigned short  port_no 
)

Device PORT Control Functions

Definition at line 2277 of file libsangoma.c.

References SANG_STATUS_SUCCESS.

02278 {
02279     int err;
02280     port_mgmnt->command_code = START_PORT_VOLATILE_CONFIG;
02281     port_mgmnt->port_no = port_no;
02282 
02283     err = sangoma_port_mgmnt_ioctl(fd, port_mgmnt);
02284     if (err) {
02285         return err;
02286     }
02287 
02288     if (port_mgmnt->operation_status != SANG_STATUS_SUCCESS ) {
02289         err=port_mgmnt->operation_status;
02290     }
02291 
02292     return err;
02293 }

int _SAPI_CALL sangoma_mgmt_cmd ( sng_fd_t  fd,
wan_udp_hdr_t wan_udp 
)

Execute Sangoma Management Command.

Parameters:
fd device file descriptor
wan_udp management command structure
Returns:
non-zero: error, 0: ok

Definition at line 2252 of file libsangoma.c.

References WANPIPE_IOCTL_PIPEMON.

02253 {
02254 #if defined(__WINDOWS__)
02255     if(DoManagementCommand(fd, wan_udp)){
02256         return 1;
02257     }
02258 #else
02259     unsigned char id = 0;
02260     int err=0;
02261     wan_udp->wan_udphdr_request_reply = 0x01;
02262     wan_udp->wan_udphdr_id = id;
02263     wan_udp->wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
02264 
02265     err=ioctl(fd,WANPIPE_IOCTL_PIPEMON,wan_udp);
02266     if (err < 0) {
02267         return 1;
02268     }
02269 #endif
02270 
02271     if(wan_udp->wan_udphdr_return_code != WAN_CMD_OK){
02272         return 2;
02273     }
02274     return 0;
02275 }

int sangoma_get_fe_status ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
unsigned char *  current_status 
)

Get Device Link Status (Connected/Disconnected).

Parameters:
fd device file descriptor
tdm_api tdm api command structure
current_status pointer where result will be filled: 0=Link UP 1=Link Down
Returns:
non-zero: error, 0: ok -> check current_status
Deprecated - replaced by sangoma_tdm_get_link_status function

int _SAPI_CALL sangoma_tdm_set_codec ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
int  codec 
)

Set TDM Codec per chan.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
codec codec to set (ulaw/alaw/slinear)
Returns:
non-zero: error, 0: ok
Deprecated Function - Here for backward compatibility Only valid in CHAN Operation Mode

Definition at line 1268 of file libsangoma.c.

References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), wanpipe_api_cmd::tdm_codec, WP_API_CMD_SET_CODEC, and wanpipe_api::wp_cmd.

Referenced by open_sangoma_device().

01269 {
01270     int err;
01271 
01272     tdm_api->wp_cmd.cmd = WP_API_CMD_SET_CODEC;
01273     tdm_api->wp_cmd.tdm_codec = codec;
01274 
01275     err=sangoma_cmd_exec(fd,tdm_api);
01276 
01277     return err;
01278 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _SAPI_CALL sangoma_tdm_get_codec ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Get Configured TDM Codec per chan.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
negative: error or configured codec value
Deprecated Function - Here for backward compatibility Only valid in CHAN Operation Mode

Definition at line 1292 of file libsangoma.c.

References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), wanpipe_api_cmd::tdm_codec, WP_API_CMD_GET_CODEC, and wanpipe_api::wp_cmd.

01293 {
01294     int err;
01295 
01296     tdm_api->wp_cmd.cmd = WP_API_CMD_GET_CODEC;
01297 
01298     err=sangoma_cmd_exec(fd,tdm_api);
01299     if (err){
01300         return err;
01301     }
01302 
01303     return tdm_api->wp_cmd.tdm_codec;   
01304 }

Here is the call graph for this function:

sng_fd_t _SAPI_CALL sangoma_create_socket_by_name ( char *  device,
char *  card 
)

Open a device based on a interface and card name.

Parameters:
device interface name
card card name
Returns:
File Descriptor: -1 error, 0 or positive integer: valid file descriptor
Deprecated - here for backward compatibility

Definition at line 985 of file libsangoma.c.

References sangoma_interface_toi(), and sangoma_open_api_span_chan().

00986 {
00987     int span,chan;
00988     sangoma_interface_toi(device,&span,&chan);
00989     
00990     return sangoma_open_api_span_chan(span,chan);
00991 }

Here is the call graph for this function:

int _SAPI_CALL sangoma_interface_toi ( char *  interface_name,
int *  span,
int *  chan 
)

Convert Span & Chan to interface name.

Parameters:
interface_name pointer to string where interface name will be written
span span number starting from 1 to 255
chan chan number starting from 1 to 32
Returns:
non-zero = error, 0 = ok Deprecated - here for backward compatibility

Definition at line 792 of file libsangoma.c.

References FNAME_LEN.

Referenced by sangoma_create_socket_by_name().

00793 {
00794     char *p=NULL, *sp = NULL, *ch = NULL;
00795     int ret = 0;
00796     char data[FNAME_LEN];
00797 
00798     strncpy(data, interface_name, FNAME_LEN);
00799     if ((data[0])) {
00800         for (p = data; *p; p++) {
00801             if (sp && *p == 'g') {
00802                 *p = '\0';
00803                 ch = (p + 1);
00804                 break;
00805             } else if (*p == 'w') {
00806                 sp = (p + 1);
00807             }
00808         }
00809 
00810         if(ch && sp) {
00811             *span = atoi(sp);
00812             *chan = atoi(ch);
00813             ret = 1;
00814         } else {
00815             *span = -1;
00816             *chan = -1;
00817         }
00818     }
00819 
00820     return ret;
00821 }

Here is the caller graph for this function:

int _SAPI_CALL sangoma_tdm_set_power_level ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
int  power 
)

Set Power Level - so only data matching the power level would be passed up.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
power value of power
Returns:
non-zero: error, 0: ok
Deprecated - not used/implemented

Definition at line 1408 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::power_level, sangoma_cmd_exec(), WP_API_CMD_SET_POWER_LEVEL, and wanpipe_api::wp_cmd.

01409 {
01410     int err;
01411 
01412     tdm_api->wp_cmd.cmd = WP_API_CMD_SET_POWER_LEVEL;
01413     tdm_api->wp_cmd.power_level = power;
01414 
01415     err=sangoma_cmd_exec(fd,tdm_api);
01416 
01417     return err;
01418 }

Here is the call graph for this function:

int _SAPI_CALL sangoma_tdm_get_power_level ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Get Configured Power Level.

Parameters:
fd device file descriptor
tdm_api tdm api command structure
Returns:
negative: error or configured power level
Deprecated - not used/implemented

Definition at line 1426 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::power_level, sangoma_cmd_exec(), WP_API_CMD_GET_POWER_LEVEL, and wanpipe_api::wp_cmd.

01427 {
01428     int err;
01429 
01430     tdm_api->wp_cmd.cmd = WP_API_CMD_GET_POWER_LEVEL;
01431 
01432     err=sangoma_cmd_exec(fd,tdm_api);
01433     if (err){
01434         return err;
01435     }
01436 
01437     return tdm_api->wp_cmd.power_level;
01438 }

Here is the call graph for this function:


Generated on Fri Jun 26 12:46:20 2009 for libsangoma by  doxygen 1.4.7