libsangoma  1
Functions | Variables
libsangoma.c File Reference

Wanpipe API Code Library for Sangoma AFT T1/E1/Analog/BRI/Serial hardware. More...

#include "libsangoma-pvt.h"
Include dependency graph for libsangoma.c:

Go to the source code of this file.

Functions

sangoma_status_t _LIBSNG_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. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_wait_obj_delete (sangoma_wait_obj_t **sangoma_wait_object)
 De-allocate all resources in a wait object. More...
 
int _LIBSNG_CALL sangoma_wait_obj_signal (sangoma_wait_obj_t *sng_wait_obj)
 Set wait object to a signaled state. More...
 
sng_fd_t _LIBSNG_CALL sangoma_wait_obj_get_fd (sangoma_wait_obj_t *sng_wait_obj)
 Get fd device file descriptor which was the 'fd' parameter for sangoma_wait_obj_create(), not useful for generic objects. More...
 
void _LIBSNG_CALL sangoma_wait_obj_set_context (sangoma_wait_obj_t *sng_wait_obj, void *context)
 
PVOID _LIBSNG_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. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_waitfor_many (sangoma_wait_obj_t *sng_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 _LIBSNG_CALL sangoma_waitfor (sangoma_wait_obj_t *sangoma_wait_obj, uint32_t inflags, uint32_t *outflags, int32_t timeout)
 
int _LIBSNG_CALL sangoma_span_chan_toif (int span, int chan, char *interface_name)
 Convert Span & Chan to interface name. More...
 
int _LIBSNG_CALL sangoma_interface_toi (char *interface_name, int *span, int *chan)
 Convert Span & Chan to interface name. More...
 
int _LIBSNG_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) More...
 
int _LIBSNG_CALL sangoma_span_chan_fromif (char *interface_name, int *span, int *chan)
 Convert Interace Name to Span & Chan. More...
 
sng_fd_t _LIBSNG_CALL sangoma_open_api_span_chan (int span, int chan)
 Open a Device based on Span/Chan values. More...
 
sng_fd_t _LIBSNG_CALL sangoma_open_dev_by_name (const char *dev_name)
 Open API device using it's name. For example: Linux: w1g1, Windows wanpipe1_if1. More...
 
sng_fd_t _LIBSNG_CALL __sangoma_open_api_span_chan (int span, int chan)
 Open a Device based on Span/Chan values. More...
 
sng_fd_t _LIBSNG_CALL sangoma_open_api_ctrl (void)
 Open a Global Control Device. More...
 
sng_fd_t _LIBSNG_CALL sangoma_logger_open (void)
 Open a Global Logger Device. More...
 
int _LIBSNG_CALL sangoma_get_open_cnt (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Get device open count. More...
 
sng_fd_t _LIBSNG_CALL sangoma_create_socket_by_name (char *device, char *card)
 Open a device based on a interface and card name. More...
 
sng_fd_t _LIBSNG_CALL sangoma_open_api_span (int span)
 
void _LIBSNG_CALL sangoma_close (sng_fd_t *fd)
 Close device file descriptor. More...
 
int _LIBSNG_CALL sangoma_readmsg (sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag)
 Read Data from device. More...
 
int _LIBSNG_CALL sangoma_writemsg (sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, unsigned short datalen, int flag)
 Write Data to device. More...
 
int _LIBSNG_CALL sangoma_cmd_exec (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Execute Sangoma API Command. More...
 
int _LIBSNG_CALL sangoma_get_full_cfg (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Read tdm api device configuration. More...
 
int _LIBSNG_CALL sangoma_tdm_set_codec (sng_fd_t fd, wanpipe_api_t *tdm_api, int codec)
 Set TDM Codec per chan. More...
 
int _LIBSNG_CALL sangoma_tdm_get_codec (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Get Configured TDM Codec per chan. More...
 
int _LIBSNG_CALL sangoma_tdm_set_usr_period (sng_fd_t fd, wanpipe_api_t *tdm_api, int period)
 Set Tx/Rx Period in Milliseconds. More...
 
int _LIBSNG_CALL sangoma_tdm_get_usr_period (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Get Tx/Rx Period in Milliseconds. More...
 
int _LIBSNG_CALL sangoma_get_hw_coding (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Get HW Voice Coding (ulaw/alaw) More...
 
int _LIBSNG_CALL sangoma_tdm_get_hw_dtmf (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Check if hwdtmf support is available. More...
 
int _LIBSNG_CALL sangoma_tdm_get_hw_ec (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Check if hw echo cancelation support is available. More...
 
int _LIBSNG_CALL sangoma_tdm_get_hwec_chan_status (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Check if hw echo cancelation is enabled on current timeslot. More...
 
int _LIBSNG_CALL sangoma_tdm_get_hwec_persist_status (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Check if hwec persis mode is on: On persist mode hwec is always enabled. More...
 
int _LIBSNG_CALL sangoma_tdm_get_usr_mtu_mru (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Get Tx/Rx MTU/MRU in bytes. More...
 
int _LIBSNG_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. More...
 
int _LIBSNG_CALL sangoma_tdm_get_power_level (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Get Configured Power Level. More...
 
int _LIBSNG_CALL sangoma_flush_bufs (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Flush all (tx/rx/event) buffers from current channel. More...
 
int _LIBSNG_CALL sangoma_flush_rx_bufs (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Flush only rx buffers from current channel. More...
 
int _LIBSNG_CALL sangoma_flush_tx_bufs (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Flush only tx buffers from current channel. More...
 
int _LIBSNG_CALL sangoma_flush_event_bufs (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Flush only event buffers from current channel. More...
 
int _LIBSNG_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. More...
 
int _LIBSNG_CALL sangoma_tdm_disable_rbs_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Disable RBS Events for a device. More...
 
int _LIBSNG_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. More...
 
int _LIBSNG_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. More...
 
int _LIBSNG_CALL sangoma_tdm_set_buffer_multiplier (sng_fd_t fd, wanpipe_api_t *tdm_api, unsigned int multiplier)
 Set voice tx/rx buffer multiplier. More...
 
int _LIBSNG_CALL sangoma_read_event (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Read API Events. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_logger_cmd_exec (sng_fd_t fd, wp_logger_cmd_t *logger_cmd)
 
sangoma_status_t _LIBSNG_CALL sangoma_logger_read_event (sng_fd_t fd, wp_logger_cmd_t *logger_cmd)
 Read Wanpipe Logger Events. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_logger_flush_buffers (sng_fd_t fd, wp_logger_cmd_t *logger_cmd)
 Flush Wanpipe Logger internal buffers. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_logger_get_statistics (sng_fd_t fd, wp_logger_cmd_t *logger_cmd)
 Get Wanpipe Logger statistics. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_logger_reset_statistics (sng_fd_t fd, wp_logger_cmd_t *logger_cmd)
 Reset Wanpipe Logger statistics. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_logger_get_open_handle_counter (sng_fd_t fd, wp_logger_cmd_t *logger_cmd)
 Get Counter of open Handles/File Descriptors of Wanpipe Logger. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_logger_get_logger_level (sng_fd_t fd, wp_logger_cmd_t *logger_cmd)
 Get current level (types of events) of Wanpipe Logger. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_logger_set_logger_level (sng_fd_t fd, wp_logger_cmd_t *logger_cmd)
 Set current level (types of events) of Wanpipe Logger. More...
 
int _LIBSNG_CALL sangoma_tdm_enable_fax_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Enable FAX Detection on Octasic chip (if hw supports it) More...
 
int _LIBSNG_CALL sangoma_tdm_disable_fax_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Disable FAX Detection on Octasic chip (if hw supports it) More...
 
int _LIBSNG_CALL sangoma_tdm_get_hw_fax (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Get HW FAX Detection State (Enable or Disabled) on Octasic chip (if hw supports it) More...
 
int _LIBSNG_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) More...
 
int _LIBSNG_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) More...
 
int _LIBSNG_CALL sangoma_tdm_enable_rm_dtmf_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Enable DTMF Detection on Analog/Remora SLIC Chip. More...
 
int _LIBSNG_CALL sangoma_tdm_disable_rm_dtmf_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Disable DTMF Detection on Analog/Remora SLIC Chip. More...
 
int _LIBSNG_CALL sangoma_tdm_enable_rxhook_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Enable RX HOOK Events (Analog Only) More...
 
int _LIBSNG_CALL sangoma_tdm_disable_rxhook_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Disable RX HOOK Events (Analog Only) More...
 
int _LIBSNG_CALL sangoma_tdm_enable_ring_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Enable RING Events (Analog Only) More...
 
int _LIBSNG_CALL sangoma_tdm_disable_ring_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Disable RING Events (Analog Only) More...
 
int _LIBSNG_CALL sangoma_tdm_enable_ring_detect_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Enable RING DETECT Events (Analog Only) More...
 
int _LIBSNG_CALL sangoma_tdm_disable_ring_detect_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Disable RING DETECT Events (Analog Only) More...
 
int _LIBSNG_CALL sangoma_tdm_enable_ring_trip_detect_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Enable RING TRIP Events (Analog Only) More...
 
int _LIBSNG_CALL sangoma_tdm_disable_ring_trip_detect_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Disable RING TRIP Events (Analog Only) More...
 
int _LIBSNG_CALL sangoma_tdm_txsig_kewl (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Tranmsmit TX SIG KEWL START (Analog Only) More...
 
int _LIBSNG_CALL sangoma_tdm_txsig_start (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Tranmsmit TX SIG START (Analog Only) More...
 
int _LIBSNG_CALL sangoma_tdm_txsig_onhook (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Tranmsmit TX SIG ON HOOK (Analog Only) More...
 
int _LIBSNG_CALL sangoma_tdm_txsig_offhook (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Tranmsmit TX SIG OFF HOOK (Analog Only) More...
 
int _LIBSNG_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) More...
 
int _LIBSNG_CALL sangoma_tdm_disable_tone_events (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Enable TONE Events (Analog Only) More...
 
int _LIBSNG_CALL sangoma_tdm_enable_hwec (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Enable HWEC on this channel. More...
 
int _LIBSNG_CALL sangoma_tdm_disable_hwec (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Disable HWEC on this channel. More...
 
int _LIBSNG_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) More...
 
int _LIBSNG_CALL sangoma_get_fe_status (sng_fd_t fd, wanpipe_api_t *tdm_api, unsigned char *current_status)
 Get Device Link Status (Connected/Disconnected) More...
 
int _LIBSNG_CALL sangoma_get_link_status (sng_fd_t fd, wanpipe_api_t *tdm_api, unsigned char *current_status)
 Get Device Link Status (Connected/Disconnected) More...
 
int _LIBSNG_CALL sangoma_set_fe_status (sng_fd_t fd, wanpipe_api_t *tdm_api, unsigned char new_status)
 Set Device Link Status (Connected/Disconnected) More...
 
int _LIBSNG_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. More...
 
int _LIBSNG_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. More...
 
int _LIBSNG_CALL sangoma_get_tx_queue_sz (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Get Tx Queue Size for this channel. More...
 
int _LIBSNG_CALL sangoma_set_tx_queue_sz (sng_fd_t fd, wanpipe_api_t *tdm_api, int size)
 Get Tx Queue Size for this channel. More...
 
int _LIBSNG_CALL sangoma_get_rx_queue_sz (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Get Rx Queue Size for this channel. More...
 
int _LIBSNG_CALL sangoma_set_rx_queue_sz (sng_fd_t fd, wanpipe_api_t *tdm_api, int size)
 Get Tx Queue Size for this channel. More...
 
int _LIBSNG_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. More...
 
int _LIBSNG_CALL sangoma_get_firmware_version (sng_fd_t fd, wanpipe_api_t *tdm_api, unsigned char *ver)
 Get Hardware/Firmware Version. More...
 
int _LIBSNG_CALL sangoma_get_cpld_version (sng_fd_t fd, wanpipe_api_t *tdm_api, unsigned char *ver)
 Get AFT CPLD Version. More...
 
int _LIBSNG_CALL sangoma_get_aft_customer_id (sng_fd_t fd, unsigned char *out_customer_id)
 Get Customer-specific ID from AFT hardware, the default value is 0xFF, any change requires special arrangement with Sangoma Technologies. More...
 
int _LIBSNG_CALL sangoma_port_led_ctrl (sng_fd_t fd, unsigned char led_ctrl)
 Control the LED ligths of the TDM port. On (led set based on link status) Off (turn off all led). Used to visually identify a phisical port from software. More...
 
int _LIBSNG_CALL sangoma_fe_reg_write (sng_fd_t fd, uint32_t offset, uint8_t data)
 Write to a front end register. More...
 
int _LIBSNG_CALL sangoma_fe_reg_read (sng_fd_t fd, uint32_t offset, uint8_t *data)
 Read front end register. More...
 
int _LIBSNG_CALL sangoma_analog_fxo_stats (sng_fd_t fd, uint8_t *data)
 
int _LIBSNG_CALL sangoma_analog_fxs_stats (sng_fd_t fd, float *tip, float *ring, float *bat)
 
int _LIBSNG_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. More...
 
int _LIBSNG_CALL sangoma_flush_stats (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Flush/Reset device statistics. More...
 
int _LIBSNG_CALL sangoma_set_rm_rxflashtime (sng_fd_t fd, wanpipe_api_t *tdm_api, int rxflashtime)
 Set rxflashtime for FXS module Wink-Flash Event. More...
 
int _LIBSNG_CALL sangoma_set_rm_tx_gain (sng_fd_t fd, wanpipe_api_t *tdm_api, int value)
 set tx gain for FXO/FXS module More...
 
int _LIBSNG_CALL sangoma_set_rm_rx_gain (sng_fd_t fd, wanpipe_api_t *tdm_api, int value)
 set rx gain for FXO/FXS module More...
 
int _LIBSNG_CALL sangoma_tdm_set_polarity (sng_fd_t fd, wanpipe_api_t *tdm_api, int polarity)
 
int _LIBSNG_CALL sangoma_tdm_txsig_onhooktransfer (sng_fd_t fd, wanpipe_api_t *tdm_api)
 
int _LIBSNG_CALL sangoma_tdm_enable_loop (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Enable channel loop: All rx data will be transmitted back out. More...
 
int _LIBSNG_CALL sangoma_tdm_disable_loop (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Disable channel loop. More...
 
int _LIBSNG_CALL sangoma_ss7_force_rx (sng_fd_t fd, wanpipe_api_t *tdm_api)
 Force the firmware to pass up a repeating frame. More...
 
int _LIBSNG_CALL sangoma_ss7_get_cfg_status (sng_fd_t fd, wanpipe_api_t *tdm_api, wan_api_ss7_cfg_status_t *ss7_cfg_status)
 Get current ss7 hw configuration. More...
 

Variables

int libsng_dbg_level = 0
 

Detailed Description

Wanpipe API Code Library for Sangoma AFT T1/E1/Analog/BRI/Serial hardware.

Author(s): Nenad Corbic ncorb.nosp@m.ic@s.nosp@m.angom.nosp@m.a.co.nosp@m.m David Rokhvarg david.nosp@m.r@sa.nosp@m.ngoma.nosp@m..com Michael Jerris mike@.nosp@m.jerr.nosp@m.is.co.nosp@m.m Anthony Minessale II anthm.nosp@m.ct@y.nosp@m.ahoo..nosp@m.com

Copyright: (c) 2005-2008 Nenad Corbic ncorb.nosp@m.ic@s.nosp@m.angom.nosp@m.a.co.nosp@m.m

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 libsangoma.c.

Function Documentation

sangoma_status_t 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.

Device POLL Functions

Parameters
sangoma_wait_objectpointer a single device object
fddevice file descriptor
object_typetype 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
Parameters
sangoma_wait_objectpointer a single device object
fddevice file descriptor
object_typetype 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 1239 of file libsangoma.c.

References FALSE, INVALID_HANDLE_VALUE, SANG_STATUS_FAILED_ALLOCATE_MEMORY, SANG_STATUS_GENERAL_ERROR, SANG_STATUS_INVALID_PARAMETER, SANG_STATUS_SUCCESS, and sangoma_wait_obj_delete().

Referenced by open_sangoma_device().

1240 {
1241  int err = 0;
1242  sangoma_wait_obj_t *sng_wait_obj = NULL;
1243 
1244  if (!sangoma_wait_object) {
1246  }
1247  *sangoma_wait_object = NULL;
1248  sng_wait_obj = malloc(sizeof(**sangoma_wait_object));
1249  if (!sng_wait_obj) {
1251  }
1252 
1253  memset(sng_wait_obj, 0x00, sizeof(*sng_wait_obj));
1254  /* it is a first initialization of the object */
1255  sng_wait_obj->init_flag = LIBSNG_MAGIC_NO;
1256 
1257  sng_wait_obj->fd = fd;
1258  sng_wait_obj->object_type = object_type;
1259 
1260 #if defined(__WINDOWS__)
1261  if (!SANGOMA_OBJ_HAS_DEVICE(sng_wait_obj)) {
1262  sng_wait_obj->signal_object = CreateEvent(NULL, FALSE, FALSE, NULL);
1263  if(!sng_wait_obj->signal_object){
1265  goto failed;
1266  }
1267  err = SANG_STATUS_SUCCESS;
1268  } else {
1269  err = init_sangoma_event_object(sng_wait_obj, fd);
1270  if(SANG_STATUS_SUCCESS != err){
1271  goto failed;
1272  }
1273  }
1274 #else
1275  int flags;
1276  int filedes[2];
1277  if (SANGOMA_OBJ_IS_SIGNALABLE(sng_wait_obj)) {
1278  sng_wait_obj->signal_read_fd = INVALID_HANDLE_VALUE;
1279  sng_wait_obj->signal_write_fd = INVALID_HANDLE_VALUE;
1280  /* if we want cross-process event notification we can use a named pipe with mkfifo() */
1281  if (pipe(filedes)) {
1283  goto failed;
1284  }
1285  sng_wait_obj->signal_read_fd = filedes[0];
1286  sng_wait_obj->signal_write_fd = filedes[1];
1287  /* make the read fd non-blocking, multiple threads can wait for it but just one
1288  * wil read the dummy notify character, the others would block otherwise and that's
1289  * not what we want */
1290  flags = fcntl(sng_wait_obj->signal_read_fd, F_GETFL, 0);
1291  if (flags < 0) {
1293  goto failed;
1294  }
1295  flags |= O_NONBLOCK;
1296  fcntl(sng_wait_obj->signal_read_fd, F_SETFL, flags);
1297  flags = fcntl(sng_wait_obj->signal_read_fd, F_GETFL, 0);
1298  if (flags < 0 || !(flags & O_NONBLOCK)) {
1300  goto failed;
1301  }
1302  }
1303 #endif
1304  *sangoma_wait_object = sng_wait_obj;
1305  return err;
1306 
1307 failed:
1308  if (sng_wait_obj) {
1309  sangoma_wait_obj_delete(&sng_wait_obj);
1310  }
1311  return err;
1312 }
#define INVALID_HANDLE_VALUE
Invalid file handle value -1, Ported from Windows.
Definition: libsangoma.h:191
#define FALSE
FALSE value is 0, Ported from Windows.
Definition: libsangoma.h:244
sangoma_status_t _LIBSNG_CALL sangoma_wait_obj_delete(sangoma_wait_obj_t **sangoma_wait_object)
De-allocate all resources in a wait object.
Definition: libsangoma.c:1320

Here is the call graph for this function:

Here is the caller graph for this function:

sangoma_status_t sangoma_wait_obj_delete ( sangoma_wait_obj_t **  sangoma_wait_object)

De-allocate all resources in a wait object.

De-allocate all resources inside a wait object which were allocated by sangoma_wait_obj_init().

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

Definition at line 1320 of file libsangoma.c.

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

Referenced by cleanup(), and sangoma_wait_obj_create().

1321 {
1322  sangoma_wait_obj_t *sng_wait_obj = *sangoma_wait_object;
1323 
1324  if(sng_wait_obj->init_flag != LIBSNG_MAGIC_NO){
1325  /* error. object was not initialized by sangoma_wait_obj_init() */
1327  }
1328 
1329 #if defined(__WINDOWS__)
1330  if (sng_wait_obj->signal_object &&
1331  sng_wait_obj->signal_object != INVALID_HANDLE_VALUE) {
1332  sangoma_close(&sng_wait_obj->signal_object);
1333  }
1334 #else
1335  if (SANGOMA_OBJ_IS_SIGNALABLE(sng_wait_obj)) {
1336  sangoma_close(&sng_wait_obj->signal_read_fd);
1337  sangoma_close(&sng_wait_obj->signal_write_fd);
1338  }
1339 #endif
1340  sng_wait_obj->init_flag = 0;
1341  sng_wait_obj->object_type = UNKNOWN_WAIT_OBJ;
1342  free(sng_wait_obj);
1343  *sangoma_wait_object = NULL;
1344  return SANG_STATUS_SUCCESS;
1345 }
#define INVALID_HANDLE_VALUE
Invalid file handle value -1, Ported from Windows.
Definition: libsangoma.h:191
deprecated, use SANGOMA_GENERIC_WAIT_OBJ
Definition: libsangoma.h:367
void _LIBSNG_CALL sangoma_close(sng_fd_t *fd)
Close device file descriptor.
Definition: libsangoma.c:1818

Here is the call graph for this function:

Here is the caller graph for this function:

void sangoma_wait_obj_signal ( sangoma_wait_obj_t *  sangoma_wait_object)

Set wait object to a signaled state.

Parameters
sangoma_wait_objectpointer a single device object that can be signaled
Returns
sangoma_status_t

Definition at line 1353 of file libsangoma.c.

References SANG_STATUS_GENERAL_ERROR, SANG_STATUS_INVALID_DEVICE, and SANG_STATUS_SUCCESS.

1354 {
1355  if (!SANGOMA_OBJ_IS_SIGNALABLE(sng_wait_obj)) {
1356  /* even when Windows objects are always signalable for the sake of providing
1357  * a consistent interface to the user we downgrade the capabilities of Windows
1358  * objects unless the sangoma wait object is explicitly initialized as signalable */
1360  }
1361 #if defined(__WINDOWS__)
1362  if(sng_wait_obj->signal_object){
1363  if (!SetEvent(sng_wait_obj->signal_object)) {
1365  }
1366  }
1367 #else
1368  /* at this point we know is a signalable object and has a signal_write_fd */
1369  if (write(sng_wait_obj->signal_write_fd, "s", 1) < 1) {
1371  }
1372 #endif
1373  return SANG_STATUS_SUCCESS;
1374 }
sng_fd_t sangoma_wait_obj_get_fd ( sangoma_wait_obj_t *  sangoma_wait_object)

Get fd device file descriptor which was the 'fd' parameter for sangoma_wait_obj_create(), not useful for generic objects.

Parameters
sangoma_wait_objectpointer a single device object
Returns
sng_fd_t - device file descriptor

Definition at line 1382 of file libsangoma.c.

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

1383 {
1384  return sng_wait_obj->fd;
1385 }

Here is the caller graph for this function:

PVOID 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.

Parameters
sangoma_wait_objectpointer a single device object
Returns
void*

Windows note: must use return type PVOID instead of void* to satisfy WDK compiler.

Parameters
sangoma_wait_objectpointer a single device object
Returns
void*

Definition at line 1406 of file libsangoma.c.

Referenced by cleanup(), and write_data().

1407 {
1408  return sng_wait_obj->context;
1409 }

Here is the caller graph for this function:

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

Convert Span & Chan to interface name.

Device OPEN / CLOSE Functions

Parameters
spanspan number starting from 1 to 255
chanchan number starting from 1 to 32
interface_namepointer to string where interface name will be written
Returns
non-zero = error, 0 = ok

Definition at line 1566 of file libsangoma.c.

References WP_INTERFACE_NAME_FORM.

1567 {
1568 #if defined(__WINDOWS__)
1569  /* Form the Interface Name from span and chan number (i.e. wanpipe1_if1). */
1570  sprintf(interface_name, WP_INTERFACE_NAME_FORM, span, chan);
1571 #else
1572  sprintf(interface_name,"s%ic%i",span,chan);
1573 #endif
1574  return 0;
1575 }
#define WP_INTERFACE_NAME_FORM
String define of a wanpipe interface name.
int sangoma_interface_toi ( char *  interface_name,
int *  span,
int *  chan 
)

Convert Span & Chan to interface name.

Parameters
interface_namepointer to string where interface name will be written
spanspan number starting from 1 to 255
chanchan number starting from 1 to 32
Returns
non-zero = error, 0 = ok Deprecated - here for backward compatibility

Definition at line 1577 of file libsangoma.c.

References FNAME_LEN.

Referenced by sangoma_create_socket_by_name().

1578 {
1579  char *p=NULL, *sp = NULL, *ch = NULL;
1580  int ret = 0;
1581  char data[FNAME_LEN];
1582 
1583  strncpy(data, interface_name, FNAME_LEN);
1584  if ((data[0])) {
1585  for (p = data; *p; p++) {
1586  if (sp && *p == 'g') {
1587  *p = '\0';
1588  ch = (p + 1);
1589  break;
1590  } else if (*p == 'w') {
1591  sp = (p + 1);
1592  }
1593  }
1594 
1595  if(ch && sp) {
1596  *span = atoi(sp);
1597  *chan = atoi(ch);
1598  ret = 1;
1599  } else {
1600  *span = -1;
1601  *chan = -1;
1602  }
1603  }
1604 
1605  return ret;
1606 }
#define FNAME_LEN
string length of a file name
Definition: libsangoma.h:348

Here is the caller graph for this function:

int 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
spanspan number of the device to wait
chanchan number of the device to wait
sectimeouthow many seconds to wait for the device to come up, -1 to wait forever
Returns
non-zero = error, 0 = ok

Definition at line 1608 of file libsangoma.c.

References FNAME_LEN, and WP_INTERFACE_NAME_FORM.

1609 {
1610 #if defined(__WINDOWS__)
1611  /* Windows does not need to wait for interfaces to come up */
1612  return 0;
1613 #else
1614  char interface_name[FNAME_LEN];
1615  struct stat statbuf;
1616  struct timeval endtime = {0,0};
1617  struct timeval curtime = {0,0};
1618  int counter;
1619  int rc;
1620  if (sectimeout >= 0 && gettimeofday(&endtime, NULL)) {
1621  return -1;
1622  }
1623  snprintf(interface_name, sizeof(interface_name), "/dev/" WP_INTERFACE_NAME_FORM, span, chan);
1624  endtime.tv_sec += sectimeout;
1625  do {
1626  counter = 0;
1627  while ((rc = stat(interface_name, &statbuf)) && errno == ENOENT && counter != 10) {
1628  poll(0, 0, 100); // test in 100ms increments
1629  counter++;
1630  }
1631  if (!rc || errno != ENOENT) break;
1632  if (gettimeofday(&curtime, NULL)) {
1633  return -1;
1634  }
1635  } while (sectimeout < 0 || timercmp(&endtime, &curtime,>));
1636  return rc;
1637 #endif
1638 }
#define FNAME_LEN
string length of a file name
Definition: libsangoma.h:348
#define WP_INTERFACE_NAME_FORM
String define of a wanpipe interface name.
int sangoma_span_chan_fromif ( char *  interface_name,
int *  span,
int *  chan 
)

Convert Interace Name to Span & Chan.

Parameters
interface_namepointer to string containing interface name
spaninteger pointer where to write span value
chaninteger pointer where to write chan value
Returns
non-zero = error, 0 = ok

Definition at line 1640 of file libsangoma.c.

References FNAME_LEN.

1641 {
1642  char *p = NULL, *sp = NULL, *ch = NULL;
1643  int ret = 0;
1644  char data[FNAME_LEN];
1645 
1646  /* Windows: Accept WANPIPEx_IFy or wanpipex_ify
1647  * where x is the span and y is the chan. */
1648 
1649  strncpy(data, interface_name, FNAME_LEN);
1650  if ((data[0])) {
1651  for (p = data; *p; p++) {
1652 #if defined(__WINDOWS__)
1653  if (sp && (*p == 'F'||*p == 'f')) {
1654 #else
1655  if (sp && *p == 'c') {
1656 #endif
1657  *p = '\0';
1658  ch = (p + 1);
1659  break;
1660 #if defined(__WINDOWS__)
1661  } else if (*p == 'E'||*p == 'e') {
1662 #else
1663  } else if (*p == 's') {
1664 #endif
1665  sp = (p + 1);
1666  }
1667  }
1668 
1669  if(ch && sp) {
1670  *span = atoi(sp);
1671  *chan = atoi(ch);
1672  ret = 1;
1673  } else {
1674  *span = -1;
1675  *chan = -1;
1676  }
1677  }
1678 
1679  return ret;
1680 }
#define FNAME_LEN
string length of a file name
Definition: libsangoma.h:348
sng_fd_t sangoma_open_api_span_chan ( int  span,
int  chan 
)

Open a Device based on Span/Chan values.

Device OPEN / CLOSE Functions

Parameters
spanspan number starting from 1 to 255
chanchan 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 1682 of file libsangoma.c.

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

Referenced by open_sangoma_device(), and sangoma_create_socket_by_name().

1683 {
1685  wanpipe_api_t tdm_api;
1686  int err;
1687 
1688  fd = __sangoma_open_api_span_chan(span, chan);
1689 
1690 #if defined(__WINDOWS__)
1691  if(fd == INVALID_HANDLE_VALUE){
1692  return fd;
1693  }
1694 #else
1695  if (fd < 0) {
1696  return fd;
1697  }
1698 #endif
1699 
1700  memset(&tdm_api,0,sizeof(tdm_api));
1701  tdm_api.wp_cmd.cmd = WP_API_CMD_OPEN_CNT;
1702  err=sangoma_cmd_exec(fd,&tdm_api);
1703  if (err){
1704  sangoma_close(&fd);
1705  return fd;
1706  }
1707 
1708  if (tdm_api.wp_cmd.open_cnt > 1) {
1709  /* this is NOT the first open request for this span/chan */
1710  sangoma_close(&fd);
1711  fd = INVALID_HANDLE_VALUE;/* fd is NOT valid anymore */
1712  }
1713 
1714  return fd;
1715 }
sng_fd_t _LIBSNG_CALL __sangoma_open_api_span_chan(int span, int chan)
Open a Device based on Span/Chan values.
Definition: libsangoma.c:1740
#define INVALID_HANDLE_VALUE
Invalid file handle value -1, Ported from Windows.
Definition: libsangoma.h:191
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
int sng_fd_t
Windows/Unix file handle abstraction.
wanpipe_api_cmd_t wp_cmd
unsigned int open_cnt
Wanpipe API Command Structure.
void _LIBSNG_CALL sangoma_close(sng_fd_t *fd)
Close device file descriptor.
Definition: libsangoma.c:1818

Here is the call graph for this function:

Here is the caller graph for this function:

sng_fd_t sangoma_open_dev_by_name ( const char *  dev_name)

Open API device using it's name. For example: Linux: w1g1, Windows wanpipe1_if1.

Parameters
dev_nameAPI device name
Returns
File Descriptor: -1 error, 0 or positive integer: valid file descriptor

Definition at line 1717 of file libsangoma.c.

References _snprintf, and FNAME_LEN.

Referenced by __sangoma_open_api_span_chan(), sangoma_logger_open(), sangoma_open_api_ctrl(), and sangoma_open_driver_ctrl().

1718 {
1719  char fname[FNAME_LEN];
1720 
1721 #if defined(__WINDOWS__)
1722  _snprintf(fname , FNAME_LEN, "\\\\.\\%s", dev_name);
1723 
1724  return CreateFile( fname,
1725  GENERIC_READ | GENERIC_WRITE,
1726  FILE_SHARE_READ | FILE_SHARE_WRITE,
1727  (LPSECURITY_ATTRIBUTES)NULL,
1728  OPEN_EXISTING,
1729  FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH,
1730  (HANDLE)NULL
1731  );
1732 #else
1733  sprintf(fname,"/dev/%s", dev_name);
1734 
1735  return open(fname, O_RDWR);
1736 #endif
1737 }
#define _snprintf
_snprintf type mapped to snprintf, Ported from Windows
Definition: libsangoma.h:255
int HANDLE
file handle type int, Ported from Windows
Definition: libsangoma.h:258
#define FNAME_LEN
string length of a file name
Definition: libsangoma.h:348

Here is the caller graph for this function:

sng_fd_t __sangoma_open_api_span_chan ( int  span,
int  chan 
)

Open a Device based on Span/Chan values.

Parameters
spanspan number starting from 1 to 255
chanchan 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 1740 of file libsangoma.c.

References _snprintf, FNAME_LEN, sangoma_open_dev_by_name(), and WP_INTERFACE_NAME_FORM.

Referenced by open_sangoma_device(), and sangoma_open_api_span_chan().

1741 {
1742  char tmp_fname[FNAME_LEN];
1743 
1744  /* Form the Interface Name from span and chan number (i.e. wanpipe1_if1). */
1745  _snprintf(tmp_fname, DEV_NAME_LEN, WP_INTERFACE_NAME_FORM, span, chan);
1746 
1747  return sangoma_open_dev_by_name(tmp_fname);
1748 }
#define _snprintf
_snprintf type mapped to snprintf, Ported from Windows
Definition: libsangoma.h:255
#define FNAME_LEN
string length of a file name
Definition: libsangoma.h:348
sng_fd_t _LIBSNG_CALL sangoma_open_dev_by_name(const char *dev_name)
Open API device using it&#39;s name. For example: Linux: w1g1, Windows wanpipe1_if1.
Definition: libsangoma.c:1717
#define WP_INTERFACE_NAME_FORM
String define of a wanpipe interface name.

Here is the call graph for this function:

Here is the caller graph for this function:

sng_fd_t 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 1750 of file libsangoma.c.

References sangoma_open_dev_by_name().

1751 {
1752  return sangoma_open_dev_by_name(WP_CTRL_DEV_NAME);
1753 }
sng_fd_t _LIBSNG_CALL sangoma_open_dev_by_name(const char *dev_name)
Open API device using it&#39;s name. For example: Linux: w1g1, Windows wanpipe1_if1.
Definition: libsangoma.c:1717

Here is the call graph for this function:

sng_fd_t sangoma_logger_open ( void  )

Open a Global Logger Device.

Returns
File Descriptor - negative=error 0 or greater = fd

The global Logger device receives Logger Events for all devices configured.

Definition at line 1756 of file libsangoma.c.

References sangoma_open_dev_by_name().

1757 {
1758  return sangoma_open_dev_by_name(WP_LOGGER_DEV_NAME);
1759 }
sng_fd_t _LIBSNG_CALL sangoma_open_dev_by_name(const char *dev_name)
Open API device using it&#39;s name. For example: Linux: w1g1, Windows wanpipe1_if1.
Definition: libsangoma.c:1717

Here is the call graph for this function:

int sangoma_get_open_cnt ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Get device open count.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
negative or 0: error, greater than 1 : open count

Definition at line 1762 of file libsangoma.c.

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

1763 {
1764  int err;
1765 
1766  WANPIPE_API_INIT_CHAN(tdm_api, 0);
1768  tdm_api->wp_cmd.cmd = WP_API_CMD_OPEN_CNT;
1769 
1770  err=sangoma_cmd_exec(fd,tdm_api);
1771  if (err){
1772  return -1;
1773  }
1774 
1775  return tdm_api->wp_cmd.open_cnt;
1776 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
unsigned int open_cnt

Here is the call graph for this function:

sng_fd_t sangoma_create_socket_by_name ( char *  device,
char *  card 
)

Open a device based on a interface and card name.

Parameters
deviceinterface name
cardcard name
Returns
File Descriptor: -1 error, 0 or positive integer: valid file descriptor

Deprecated - here for backward compatibility

Definition at line 1778 of file libsangoma.c.

References sangoma_interface_toi(), and sangoma_open_api_span_chan().

1779 {
1780  int span,chan;
1781  sangoma_interface_toi(device,&span,&chan);
1782 
1783  return sangoma_open_api_span_chan(span,chan);
1784 }
int _LIBSNG_CALL sangoma_interface_toi(char *interface_name, int *span, int *chan)
Convert Span &amp; Chan to interface name.
Definition: libsangoma.c:1577
sng_fd_t _LIBSNG_CALL sangoma_open_api_span_chan(int span, int chan)
Open a Device based on Span/Chan values.
Definition: libsangoma.c:1682

Here is the call graph for this function:

void sangoma_close ( sng_fd_t fd)

Close device file descriptor.

Parameters
fddevice file descriptor
Returns
void

Definition at line 1818 of file libsangoma.c.

References INVALID_HANDLE_VALUE.

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

1819 {
1820  if (!fd) {
1821  return;
1822  }
1823 #if defined(__WINDOWS__)
1824  if (*fd != INVALID_HANDLE_VALUE){
1825  CloseHandle(*fd);
1826  *fd = INVALID_HANDLE_VALUE;
1827  }
1828 #else
1829  if (*fd >= 0) {
1830  close(*fd);
1831  *fd = -1;
1832  }
1833 #endif
1834 }
#define INVALID_HANDLE_VALUE
Invalid file handle value -1, Ported from Windows.
Definition: libsangoma.h:191

Here is the caller graph for this function:

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

Read Data from device.

Device READ / WRITE Functions

Parameters
fddevice file descriptor
hdrbufpointer to header structure wp_api_hdr_t
hdrlensize of wp_api_hdr_t
databufpointer to data buffer to be received
datalenlength of data buffer
flagcurrently not used, set to 0
Returns
received size, must be equal to datalen, anything else is error or busy

In case of error return code, one must check the header operation_status variable to identify the reason of error. Please refer to the error codes.

Definition at line 1842 of file libsangoma.c.

References wp_api_hdr::data_length, wan_iovec_list::iovec_list, wan_msghdr::msg_iov, wan_msghdr::msg_iovlen, wp_api_hdr::operation_status, SANG_STATUS_NO_DATA_AVAILABLE, SANG_STATUS_RX_DATA_AVAILABLE, and SDLA_DECODE_SANG_STATUS.

1843 {
1844  int rx_len=0;
1845 
1846 #if defined(__WINDOWS__)
1847  wp_api_hdr_t *rx_hdr = (wp_api_hdr_t*)hdrbuf;
1848  wan_iovec_list_t iovec_list;
1849 
1850  if (hdrlen != sizeof(wp_api_hdr_t)) {
1851  /*error*/
1852  DBG_ERR("hdrlen (%i) != sizeof(wp_api_hdr_t) (%i)\n", hdrlen, sizeof(wp_api_hdr_t));
1853  return -1;
1854  }
1855 
1856  memset(&iovec_list, 0x00, sizeof(iovec_list));
1857 
1858  iovec_list.iovec_list[0].iov_base = hdrbuf;
1859  iovec_list.iovec_list[0].iov_len = hdrlen;
1860 
1861  iovec_list.iovec_list[1].iov_base = databuf;
1862  iovec_list.iovec_list[1].iov_len = datalen;
1863 
1864  if (DoReadCommand(fd, &iovec_list)) {
1865  /*error*/
1866  DBG_ERR("DoReadCommand() failed! Check messages log.\n");
1867  return -4;
1868  }
1869 
1870  switch(rx_hdr->operation_status)
1871  {
1873  /* ok */
1874  break;
1876  /* Note that SANG_STATUS_NO_DATA_AVAILABLE is NOT an error becase
1877  * read() is non-blocking and can be called at any time (by some polling code)*/
1878  return 1; /* return positive value to indicate IOCTL success, user must check 'rx_hdr->operation_status' */
1879  default:
1880  if(libsng_dbg_level)DBG_ERR("Operation Status: %s(%d)\n",
1882  return -5;
1883  }
1884 
1885  rx_len = rx_hdr->data_length;
1886 #else
1887  wan_msghdr_t msg;
1888  wan_iovec_t iov[2];
1889 
1890  memset(&msg,0,sizeof(msg));
1891  memset(&iov[0],0,sizeof(iov[0])*2);
1892 
1893  iov[0].iov_len=hdrlen;
1894  iov[0].iov_base=hdrbuf;
1895 
1896  iov[1].iov_len=datalen;
1897  iov[1].iov_base=databuf;
1898 
1899  msg.msg_iovlen=2;
1900  msg.msg_iov=iov;
1901 
1902  rx_len = read(fd,&msg,sizeof(msg));
1903 
1904  if (rx_len <= sizeof(wp_api_hdr_t)){
1905  return -EINVAL;
1906  }
1907 
1908  rx_len -= sizeof(wp_api_hdr_t);
1909 #endif
1910  return rx_len;
1911 }
u_int8_t operation_status
Memory Descriptor of a single buffer. This structure used internally by libsangoma.
u_int32_t msg_iovlen
#define SDLA_DECODE_SANG_STATUS(status)
Print decode of Sangoma Return Codes.
Fixed-length List of Memory Descriptors.
Variable-length List of Memory Descriptors.
wan_iovec_t *WP_POINTER_64 msg_iov
Wanpipe API Header Structure.
u_int16_t data_length
wan_iovec_t iovec_list[WAN_IOVEC_LIST_LEN]
struct wp_api_hdr wp_api_hdr_t
Wanpipe API Header Structure.
int sangoma_writemsg ( sng_fd_t  fd,
void *  hdrbuf,
int  hdrlen,
void *  databuf,
unsigned short  datalen,
int  flag 
)

Write Data to device.

Device READ / WRITE Functions

Parameters
fddevice file descriptor
hdrbufpointer to header structure wp_api_hdr_t
hdrlensize of wp_api_hdr_t
databufpointer to data buffer to be transmitted
datalenlength of data buffer
flagcurrently 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 1913 of file libsangoma.c.

References wp_api_hdr::data_length, wan_iovec_list::iovec_list, wan_msghdr::msg_iov, wan_msghdr::msg_iovlen, wp_api_hdr::operation_status, SANG_STATUS_DEVICE_BUSY, SANG_STATUS_IO_ERROR, SANG_STATUS_SUCCESS, and SDLA_DECODE_SANG_STATUS.

Referenced by write_data().

1914 {
1915  int bsent=-1;
1916  wp_api_hdr_t *wp_api_hdr = hdrbuf;
1917 #if defined(__WINDOWS__)
1918  wan_iovec_list_t iovec_list;
1919 #endif
1920 
1921  if (hdrlen != sizeof(wp_api_hdr_t)) {
1922  /* error. Possible cause is a mismatch between versions of API header files. */
1923  DBG_ERR("hdrlen (%i) != sizeof(wp_api_hdr_t) (%i)\n", hdrlen, sizeof(wp_api_hdr_t));
1924  return -1;
1925  }
1926 
1927 #if defined(__WINDOWS__)
1928 
1929  wp_api_hdr->data_length = datalen;
1930 
1931  memset(&iovec_list, 0x00, sizeof(iovec_list));
1932 
1933  iovec_list.iovec_list[0].iov_base = hdrbuf;
1934  iovec_list.iovec_list[0].iov_len = hdrlen;
1935 
1936  iovec_list.iovec_list[1].iov_base = databuf;
1937  iovec_list.iovec_list[1].iov_len = datalen;
1938 
1939  /* queue data for transmission */
1940  if (DoWriteCommand(fd, &iovec_list)) {
1941  /*error*/
1942  DBG_ERR("DoWriteCommand() failed!! Check messages log.\n");
1943  return -1;
1944  }
1945 
1946  bsent=0;
1947  /*check that frame was transmitted*/
1948  switch(wp_api_hdr->operation_status)
1949  {
1950  case SANG_STATUS_SUCCESS:
1951  bsent = datalen;
1952  break;
1953  default:
1954  DBG_ERR("Operation Status: %s(%d)\n",
1955  SDLA_DECODE_SANG_STATUS(wp_api_hdr->operation_status), wp_api_hdr->operation_status);
1956  break;
1957  }/*switch()*/
1958 #else
1959  wan_msghdr_t msg;
1960  wan_iovec_t iov[2];
1961 
1962  memset(&msg,0,sizeof(msg));
1963  memset(&iov[0],0,sizeof(iov[0])*2);
1964 
1965  iov[0].iov_len=hdrlen;
1966  iov[0].iov_base=hdrbuf;
1967 
1968  iov[1].iov_len=datalen;
1969  iov[1].iov_base=databuf;
1970 
1971  msg.msg_iovlen=2;
1972  msg.msg_iov=iov;
1973 
1974  bsent = write(fd,&msg,sizeof(msg));
1975 
1976  if (bsent == (datalen+hdrlen)){
1977  wp_api_hdr->wp_api_hdr_operation_status=SANG_STATUS_SUCCESS;
1978  bsent-=sizeof(wp_api_hdr_t);
1979  } else if (errno == EBUSY){
1980  wp_api_hdr->wp_api_hdr_operation_status=SANG_STATUS_DEVICE_BUSY;
1981  } else {
1982  wp_api_hdr->wp_api_hdr_operation_status=SANG_STATUS_IO_ERROR;
1983  }
1984  wp_api_hdr->wp_api_hdr_data_length=bsent;
1985 
1986 #endif
1987  return bsent;
1988 }
u_int8_t operation_status
Memory Descriptor of a single buffer. This structure used internally by libsangoma.
u_int32_t msg_iovlen
#define SDLA_DECODE_SANG_STATUS(status)
Print decode of Sangoma Return Codes.
Fixed-length List of Memory Descriptors.
Variable-length List of Memory Descriptors.
wan_iovec_t *WP_POINTER_64 msg_iov
Wanpipe API Header Structure.
u_int16_t data_length
wan_iovec_t iovec_list[WAN_IOVEC_LIST_LEN]
struct wp_api_hdr wp_api_hdr_t
Wanpipe API Header Structure.

Here is the caller graph for this function:

int sangoma_cmd_exec ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Execute Sangoma API Command.

Device API COMMAND Functions

Device API COMMAND Functions

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Definition at line 2004 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_event_bufs(), sangoma_flush_rx_bufs(), sangoma_flush_stats(), sangoma_flush_tx_bufs(), sangoma_get_cpld_version(), sangoma_get_driver_version(), sangoma_get_fe_status(), sangoma_get_firmware_version(), sangoma_get_full_cfg(), sangoma_get_hw_coding(), sangoma_get_link_status(), 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_fe_status(), sangoma_set_rm_rx_gain(), sangoma_set_rm_rxflashtime(), sangoma_set_rm_tx_gain(), sangoma_set_rx_queue_sz(), sangoma_set_tx_queue_sz(), sangoma_ss7_force_rx(), sangoma_ss7_get_cfg_status(), sangoma_tdm_disable_dtmf_events(), sangoma_tdm_disable_fax_events(), sangoma_tdm_disable_hwec(), sangoma_tdm_disable_loop(), sangoma_tdm_disable_rbs_events(), sangoma_tdm_disable_ring_detect_events(), sangoma_tdm_disable_ring_events(), sangoma_tdm_disable_ring_trip_detect_events(), sangoma_tdm_disable_rm_dtmf_events(), sangoma_tdm_disable_rxhook_events(), sangoma_tdm_disable_tone_events(), sangoma_tdm_enable_dtmf_events(), sangoma_tdm_enable_fax_events(), sangoma_tdm_enable_hwec(), sangoma_tdm_enable_loop(), sangoma_tdm_enable_rbs_events(), sangoma_tdm_enable_ring_detect_events(), sangoma_tdm_enable_ring_events(), sangoma_tdm_enable_ring_trip_detect_events(), sangoma_tdm_enable_rm_dtmf_events(), sangoma_tdm_enable_rxhook_events(), sangoma_tdm_enable_tone_events(), sangoma_tdm_get_codec(), sangoma_tdm_get_fe_alarms(), sangoma_tdm_get_hw_dtmf(), sangoma_tdm_get_hw_ec(), sangoma_tdm_get_hw_fax(), sangoma_tdm_get_hwec_chan_status(), sangoma_tdm_get_hwec_persist_status(), sangoma_tdm_get_power_level(), sangoma_tdm_get_usr_mtu_mru(), sangoma_tdm_get_usr_period(), sangoma_tdm_read_rbs(), sangoma_tdm_set_buffer_multiplier(), sangoma_tdm_set_codec(), sangoma_tdm_set_power_level(), sangoma_tdm_set_usr_period(), sangoma_tdm_txsig_kewl(), sangoma_tdm_txsig_offhook(), sangoma_tdm_txsig_onhook(), sangoma_tdm_txsig_start(), and sangoma_tdm_write_rbs().

2005 {
2006  int err;
2007 
2008 #if defined(__WINDOWS__)
2009  err = tdmv_api_ioctl(fd, &tdm_api->wp_cmd);
2010 #else
2011  err = ioctl(fd,WANPIPE_IOCTL_API_CMD,&tdm_api->wp_cmd);
2012  if (err < 0){
2013  char tmp[50];
2014  sprintf(tmp,"TDM API: CMD: %i\n",tdm_api->wp_cmd.cmd);
2015  perror(tmp);
2016  return -1;
2017  }
2018 #endif
2019  return err;
2020 }
wanpipe_api_cmd_t wp_cmd
int sangoma_get_full_cfg ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Read tdm api device configuration.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Definition at line 2026 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, sangoma_cmd_exec(), SANGOMA_INIT_TDM_API_CMD_RESULT, wanpipe_api_cmd::stats, wanpipe_api_cmd::tdm_codec, wanpipe_api_cmd::tx_disable, 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(), sangoma_fe_reg_read(), and sangoma_fe_reg_write().

2027 {
2028  int err;
2029 
2030  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2032  tdm_api->wp_cmd.cmd = WP_API_CMD_GET_FULL_CFG;
2033 
2034  err=sangoma_cmd_exec(fd,tdm_api);
2035  if (err){
2036  return err;
2037  }
2038 
2039 #if 0
2040  printf("TDM API CFG:\n");
2041  printf("\thw_tdm_coding:\t%d\n",tdm_api->wp_cmd.hw_tdm_coding);
2042  printf("\thw_mtu_mru:\t%d\n",tdm_api->wp_cmd.hw_mtu_mru);
2043  printf("\tusr_period:\t%d\n",tdm_api->wp_cmd.usr_period);
2044  printf("\ttdm_codec:\t%d\n",tdm_api->wp_cmd.tdm_codec);
2045  printf("\tpower_level:\t%d\n",tdm_api->wp_cmd.power_level);
2046  printf("\trx_disable:\t%d\n",tdm_api->wp_cmd.rx_disable);
2047  printf("\ttx_disable:\t%d\n",tdm_api->wp_cmd.tx_disable);
2048  printf("\tusr_mtu_mru:\t%d\n",tdm_api->wp_cmd.usr_mtu_mru);
2049  printf("\tidle flag:\t0x%02X\n",tdm_api->wp_cmd.idle_flag);
2050 
2051 #ifdef WP_API_FEATURE_FE_ALARM
2052  printf("\tfe alarms:\t0x%02X\n",tdm_api->wp_cmd.fe_alarms);
2053 #endif
2054 
2055  printf("\trx pkt\t%d\ttx pkt\t%d\n",tdm_api->wp_cmd.stats.rx_packets,
2056  tdm_api->wp_cmd.stats.tx_packets);
2057  printf("\trx err\t%d\ttx err\t%d\n",
2058  tdm_api->wp_cmd.stats.rx_errors,
2059  tdm_api->wp_cmd.stats.tx_errors);
2060 #ifndef __WINDOWS__
2061  printf("\trx ovr\t%d\ttx idl\t%d\n",
2062  tdm_api->wp_cmd.stats.rx_fifo_errors,
2063  tdm_api->wp_cmd.stats.tx_carrier_errors);
2064 #endif
2065 #endif
2066 
2067  return 0;
2068 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
unsigned int usr_mtu_mru
unsigned int hw_tdm_coding
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
unsigned int rx_disable
unsigned int fe_alarms
unsigned int hw_mtu_mru
wanpipe_chan_stats_t stats
unsigned int tx_disable
unsigned int usr_period
unsigned int tdm_codec
unsigned int idle_flag
unsigned int power_level

Here is the call graph for this function:

Here is the caller graph for this function:

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

Set TDM Codec per chan.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
codeccodec 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 2082 of file libsangoma.c.

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

Referenced by open_sangoma_device().

2083 {
2084  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2086  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_CODEC;
2087  tdm_api->wp_cmd.tdm_codec = codec;
2088  return sangoma_cmd_exec(fd,tdm_api);
2089 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
unsigned int tdm_codec

Here is the call graph for this function:

Here is the caller graph for this function:

int sangoma_tdm_get_codec ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Get Configured TDM Codec per chan.

Parameters
fddevice file descriptor
tdm_apitdm 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 2103 of file libsangoma.c.

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

2104 {
2105  int err;
2106 
2107  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2109  tdm_api->wp_cmd.cmd = WP_API_CMD_GET_CODEC;
2110 
2111  err=sangoma_cmd_exec(fd,tdm_api);
2112  if (err){
2113  return err;
2114  }
2115 
2116  return tdm_api->wp_cmd.tdm_codec;
2117 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
unsigned int tdm_codec

Here is the call graph for this function:

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

Set Tx/Rx Period in Milliseconds.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
periodvalue in miliseconds (1,2,5,10)
Returns
non-zero: error, 0: ok

Only valid in CHAN Operation Mode

Definition at line 2126 of file libsangoma.c.

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

Referenced by open_sangoma_device().

2127 {
2128  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2131  tdm_api->wp_cmd.usr_period = period;
2132  return sangoma_cmd_exec(fd,tdm_api);
2133 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
unsigned int usr_period

Here is the call graph for this function:

Here is the caller graph for this function:

int sangoma_tdm_get_usr_period ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Get Tx/Rx Period in Milliseconds.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
negative: error or configured period value

Definition at line 2142 of file libsangoma.c.

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

2143 {
2144  int err;
2145 
2146  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2149 
2150  err=sangoma_cmd_exec(fd,tdm_api);
2151  if (err){
2152  return err;
2153  }
2154 
2155  return tdm_api->wp_cmd.usr_period;
2156 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
unsigned int usr_period

Here is the call graph for this function:

int sangoma_get_hw_coding ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Get HW Voice Coding (ulaw/alaw)

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
the low level voice coding, depending on configuration. (WP_MULAW or WP_ALAW)

Definition at line 2164 of file libsangoma.c.

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

2165 {
2166  int err;
2167 
2168  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2170  tdm_api->wp_cmd.cmd = WP_API_CMD_GET_HW_CODING;
2171  err=sangoma_cmd_exec(fd,tdm_api);
2172  if (err){
2173  return err;
2174  }
2175  return tdm_api->wp_cmd.hw_tdm_coding;
2176 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
unsigned int hw_tdm_coding
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

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
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

This function will check if hw supports HW DTMF.

Definition at line 2185 of file libsangoma.c.

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

2186 {
2187  int err;
2188 
2189  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2191  tdm_api->wp_cmd.cmd = WP_API_CMD_GET_HW_DTMF;
2192  err=sangoma_cmd_exec(fd,tdm_api);
2193  if (err){
2194  return err;
2195  }
2196  return tdm_api->wp_cmd.hw_dtmf;
2197 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
unsigned int hw_dtmf

Here is the call graph for this function:

int sangoma_tdm_get_hw_ec ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Check if hw echo cancelation support is available.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: disable, >0:enabled

This function will check if hw supports HW EC.

Definition at line 2205 of file libsangoma.c.

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

2206 {
2207  int err;
2208 
2209  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2211  tdm_api->wp_cmd.cmd = WP_API_CMD_GET_HW_EC;
2212  err=sangoma_cmd_exec(fd,tdm_api);
2213  if (err){
2214  return err;
2215  }
2216  return tdm_api->wp_cmd.hw_ec;
2217 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

int sangoma_tdm_get_hwec_chan_status ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Check if hw echo cancelation is enabled on current timeslot.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: disabled, >0: enabled

This function will check if hw echo cancelation is enable on current timeslot.

Definition at line 2228 of file libsangoma.c.

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

2229 {
2230  int err;
2231 
2232  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2235  err=sangoma_cmd_exec(fd,tdm_api);
2236  if (err){
2237  return err;
2238  }
2239  return tdm_api->wp_cmd.hw_ec;
2240 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

int sangoma_tdm_get_hwec_persist_status ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Check if hwec persis mode is on: On persist mode hwec is always enabled.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: disabled, >0: enabled

This function will check if hw persist mode is enabled.

Definition at line 2254 of file libsangoma.c.

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

2255 {
2256  int err;
2257 
2258  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2261  err=sangoma_cmd_exec(fd,tdm_api);
2262  if (err){
2263  return err;
2264  }
2265  return tdm_api->wp_cmd.hw_ec;
2266 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

int sangoma_tdm_get_usr_mtu_mru ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Get Tx/Rx MTU/MRU in bytes.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
negative: error or configured mtu/mru in bytes

Definition at line 2276 of file libsangoma.c.

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

2277 {
2278  int err;
2279 
2280  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2283 
2284  err=sangoma_cmd_exec(fd,tdm_api);
2285  if (err){
2286  return err;
2287  }
2288 
2289  return tdm_api->wp_cmd.usr_mtu_mru;
2290 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
unsigned int usr_mtu_mru
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

int 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
fddevice file descriptor
tdm_apitdm api command structure
powervalue of power
Returns
non-zero: error, 0: ok

Deprecated - not used/implemented

Definition at line 2298 of file libsangoma.c.

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

2299 {
2300  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2303  tdm_api->wp_cmd.power_level = power;
2304  return sangoma_cmd_exec(fd,tdm_api);
2305 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
unsigned int power_level

Here is the call graph for this function:

int sangoma_tdm_get_power_level ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Get Configured Power Level.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
negative: error or configured power level

Deprecated - not used/implemented

Definition at line 2313 of file libsangoma.c.

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

2314 {
2315  int err;
2316 
2317  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2320 
2321  err=sangoma_cmd_exec(fd,tdm_api);
2322  if (err){
2323  return err;
2324  }
2325 
2326  return tdm_api->wp_cmd.power_level;
2327 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
unsigned int power_level

Here is the call graph for this function:

int sangoma_flush_bufs ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Flush all (tx/rx/event) buffers from current channel.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Definition at line 2329 of file libsangoma.c.

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

Referenced by open_sangoma_device().

2330 {
2331  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2333  tdm_api->wp_cmd.cmd = WP_API_CMD_FLUSH_BUFFERS;
2334  return sangoma_cmd_exec(fd,tdm_api);
2335 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

Here is the caller graph for this function:

int sangoma_flush_rx_bufs ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Flush only rx buffers from current channel.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Definition at line 2337 of file libsangoma.c.

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

2338 {
2339  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2342  return sangoma_cmd_exec(fd,tdm_api);
2343 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

int sangoma_flush_tx_bufs ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Flush only tx buffers from current channel.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Definition at line 2345 of file libsangoma.c.

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

2346 {
2347  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2350  return sangoma_cmd_exec(fd,tdm_api);
2351 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

int sangoma_flush_event_bufs ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Flush only event buffers from current channel.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Definition at line 2353 of file libsangoma.c.

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

2354 {
2355  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2358  return sangoma_cmd_exec(fd,tdm_api);
2359 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

int 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
fddevice file descriptor
tdm_apitdm api command structure
poll_in_secdriver poll period for rbs events
Returns
non-zero: error, 0: ok

Definition at line 2361 of file libsangoma.c.

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

Referenced by open_sangoma_device().

2362 {
2363  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2366  tdm_api->wp_cmd.rbs_poll = poll_in_sec;
2367  return sangoma_cmd_exec(fd,tdm_api);
2368 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
unsigned int rbs_poll
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

Here is the caller graph for this function:

int sangoma_tdm_disable_rbs_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Disable RBS Events for a device.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Definition at line 2370 of file libsangoma.c.

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

Referenced by cleanup().

2370  {
2371 
2372  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2375  return sangoma_cmd_exec(fd,tdm_api);
2376 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

Here is the caller graph for this function:

int 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
fddevice file descriptor
tdm_apitdm api command structure
channelt1/e1 timeslot
rbsrbs bits (ABCD)
Returns
non-zero: error, 0: ok

Definition at line 2378 of file libsangoma.c.

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

2379 {
2380  WANPIPE_API_INIT_CHAN(tdm_api, channel);
2383  tdm_api->wp_cmd.rbs_tx_bits=rbs;
2384  return sangoma_cmd_exec(fd,tdm_api);
2385 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
unsigned int rbs_tx_bits

Here is the call graph for this function:

int 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
fddevice file descriptor
tdm_apitdm api command structure
channelt1/e1 timeslot
rbspointer to rbs bits (ABCD)
Returns
non-zero: error, 0: ok

Definition at line 2387 of file libsangoma.c.

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

2388 {
2389  int err;
2390  WANPIPE_API_INIT_CHAN(tdm_api, channel);
2392  tdm_api->wp_cmd.cmd = WP_API_CMD_READ_RBS_BITS;
2393  tdm_api->wp_cmd.rbs_tx_bits=0;
2394 
2395  err=sangoma_cmd_exec(fd,tdm_api);
2396  if (err){
2397  return err;
2398  }
2399 
2400  *rbs=(unsigned char)tdm_api->wp_cmd.rbs_rx_bits;
2401  return 0;
2402 }
unsigned int rbs_rx_bits
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
unsigned int rbs_tx_bits

Here is the call graph for this function:

int sangoma_tdm_set_buffer_multiplier ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
unsigned int  multiplier 
)

Set voice tx/rx buffer multiplier.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
multiplierbuffer multiplier value 0-disable or 1 to TDMAPI_MAX_BUFFER_MULTIPLIER
Returns
non-zero: error, 0: ok

Definition at line 2406 of file libsangoma.c.

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

Referenced by open_sangoma_device().

2407 {
2408 
2409  int err;
2410  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2413  *((unsigned int*)&tdm_api->wp_cmd.data[0]) = multiplier;
2414 
2415  err=sangoma_cmd_exec(fd,tdm_api);
2416  if (err){
2417  return err;
2418  }
2419 
2420  return 0;
2421 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

Here is the caller graph for this function:

int sangoma_read_event ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Read API Events.

Device EVENT Function

Parameters
fddevice file descriptor
tdm_apitdm 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 2426 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::event, sangoma_cmd_exec(), SANGOMA_INIT_TDM_API_CMD_RESULT, WP_API_EVENT_DTMF, WP_API_EVENT_RBS, wanpipe_api::wp_callback, and wanpipe_api::wp_cmd.

Referenced by handle_tdm_event().

2427 {
2428 
2429 #ifdef WP_API_FEATURE_EVENTS
2430  wp_api_event_t *rx_event;
2431  int err;
2432 
2433  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2435  tdm_api->wp_cmd.cmd = WP_API_CMD_READ_EVENT;
2436 
2437  err=sangoma_cmd_exec(fd,tdm_api);
2438  if (err){
2439  return err;
2440  }
2441 
2442  rx_event = &tdm_api->wp_cmd.event;
2443 
2444 #ifdef WP_API_DEPRECATED_FEATURE_READ_CALLBACK_FUNCTIONS
2445  /*
2446  The use of callbacks here is purely optional and is left
2447  here for backward compatibility purposes. By default user
2448  should handle events outside this funciton. This function
2449  should only be used to read the event
2450  */
2451 
2452  switch (rx_event->wp_api_event_type){
2453 
2454  case WP_API_EVENT_RBS:
2455  if (tdm_api->wp_callback.wp_rbs_event) {
2456  tdm_api->wp_callback.wp_rbs_event(fd,rx_event->wp_api_event_rbs_bits);
2457  }
2458  break;
2459 
2460 #ifdef WP_API_FEATURE_DTMF_EVENTS
2461  case WP_API_EVENT_DTMF:
2462  if (tdm_api->wp_callback.wp_dtmf_event) {
2463  tdm_api->wp_callback.wp_dtmf_event(fd,
2464  rx_event->wp_api_event_dtmf_digit,
2465  rx_event->wp_api_event_dtmf_type,
2466  rx_event->wp_api_event_dtmf_port);
2467  }
2468  break;
2469 #endif
2470 
2471  case WP_API_EVENT_RXHOOK:
2472  if (tdm_api->wp_callback.wp_rxhook_event) {
2473  tdm_api->wp_callback.wp_rxhook_event(fd,
2474  rx_event->wp_api_event_hook_state);
2475  }
2476  break;
2477 
2478  case WP_API_EVENT_RING_DETECT:
2479  if (tdm_api->wp_callback.wp_ring_detect_event) {
2480  tdm_api->wp_callback.wp_ring_detect_event(fd,
2481  rx_event->wp_api_event_ring_state);
2482  }
2483  break;
2484 
2485  case WP_API_EVENT_RING_TRIP_DETECT:
2486  if (tdm_api->wp_callback.wp_ring_trip_detect_event) {
2487  tdm_api->wp_callback.wp_ring_trip_detect_event(fd,
2488  rx_event->wp_api_event_ring_state);
2489  }
2490  break;
2491 
2492 #ifdef WP_API_FEATURE_FE_ALARM
2493  case WP_API_EVENT_ALARM:
2494  if (tdm_api->wp_callback.wp_fe_alarm_event) {
2495  tdm_api->wp_callback.wp_fe_alarm_event(fd,
2496  rx_event->wp_api_event_alarm);
2497  }
2498  break;
2499 #endif
2500 
2501 #ifdef WP_API_FEATURE_LINK_STATUS
2502  /* Link Status */
2503  case WP_API_EVENT_LINK_STATUS:
2504  if(tdm_api->wp_callback.wp_link_status_event){
2505  tdm_api->wp_callback.wp_link_status_event(fd,
2506  rx_event->wp_api_event_link_status);
2507  }
2508 
2509  break;
2510 #endif
2511 
2512 #ifdef WP_API_FEATURE_POL_REV
2513  case WP_API_EVENT_POLARITY_REVERSE:
2514  break;
2515 #endif
2516  default:
2517 #ifdef __WINDOWS__
2518  if(0)printf("Warning: libsangoma: %s fd=0x%p: Unknown TDM event!", __FUNCTION__,fd);
2519 #else
2520  if(0)printf("Warning: libsangoma: %s fd=%d: Unknown TDM event!", __FUNCTION__, fd);
2521 #endif
2522  break;
2523  }
2524 
2525 #endif
2526 
2527 
2528  return 0;
2529 #else
2530  printf("Error: Read Event not supported!\n");
2531  return -1;
2532 #endif
2533 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wanpipe_api_callbacks_t wp_callback
Wanpipe API Event Structure.
wp_api_event_t event

Here is the call graph for this function:

Here is the caller graph for this function:

sangoma_status_t sangoma_logger_read_event ( sng_fd_t  fd,
wp_logger_cmd_t *  logger_cmd 
)

Read Wanpipe Logger Events.

Parameters
fddevice file descriptor
logger_cmdLogger API command structure
Returns
SANG_STATUS_SUCCESS: ok, else: error

The Logger API structure will be populated with a Logger Event. This function usually used after wait() function indicated that an event has occured.

Definition at line 2556 of file libsangoma.c.

2557 {
2558  logger_cmd->cmd = WP_API_LOGGER_CMD_READ_EVENT;
2559  return sangoma_logger_cmd_exec(fd, logger_cmd);
2560 }
sangoma_status_t sangoma_logger_flush_buffers ( sng_fd_t  fd,
wp_logger_cmd_t *  logger_cmd 
)

Flush Wanpipe Logger internal buffers.

Parameters
fddevice file descriptor
logger_cmdLogger API command structure
Returns
SANG_STATUS_SUCCESS: ok, else: error

Definition at line 2562 of file libsangoma.c.

2563 {
2564  logger_cmd->cmd = WP_API_LOGGER_CMD_FLUSH_BUFFERS;
2565  return sangoma_logger_cmd_exec(fd, logger_cmd);
2566 }
sangoma_status_t sangoma_logger_get_statistics ( sng_fd_t  fd,
wp_logger_cmd_t *  logger_cmd 
)

Get Wanpipe Logger statistics.

Parameters
fddevice file descriptor
logger_cmdLogger API command structure
Returns
SANG_STATUS_SUCCESS: ok, else: error

Definition at line 2568 of file libsangoma.c.

2569 {
2570  logger_cmd->cmd = WP_API_LOGGER_CMD_GET_STATS;
2571  return sangoma_logger_cmd_exec(fd, logger_cmd);
2572 }
sangoma_status_t sangoma_logger_reset_statistics ( sng_fd_t  fd,
wp_logger_cmd_t *  logger_cmd 
)

Reset Wanpipe Logger statistics.

Parameters
fddevice file descriptor
logger_cmdLogger API command structure
Returns
SANG_STATUS_SUCCESS: ok, else: error

Definition at line 2574 of file libsangoma.c.

2575 {
2576  logger_cmd->cmd = WP_API_LOGGER_CMD_RESET_STATS;
2577  return sangoma_logger_cmd_exec(fd, logger_cmd);
2578 }
sangoma_status_t sangoma_logger_get_open_handle_counter ( sng_fd_t  fd,
wp_logger_cmd_t *  logger_cmd 
)

Get Counter of open Handles/File Descriptors of Wanpipe Logger.

Parameters
fddevice file descriptor
logger_cmdLogger API command structure
Returns
SANG_STATUS_SUCCESS: ok, else: error

Definition at line 2580 of file libsangoma.c.

2581 {
2582  logger_cmd->cmd = WP_API_LOGGER_CMD_OPEN_CNT;
2583  return sangoma_logger_cmd_exec(fd, logger_cmd);
2584 }
sangoma_status_t sangoma_logger_get_logger_level ( sng_fd_t  fd,
wp_logger_cmd_t *  logger_cmd 
)

Get current level (types of events) of Wanpipe Logger.

Parameters
fddevice file descriptor
logger_cmdLogger API command structure
Returns
SANG_STATUS_SUCCESS: ok, else: error

Definition at line 2586 of file libsangoma.c.

2587 {
2588  logger_cmd->cmd = WP_API_LOGGER_CMD_GET_LOGGER_LEVEL;
2589  return sangoma_logger_cmd_exec(fd, logger_cmd);
2590 }
sangoma_status_t sangoma_logger_set_logger_level ( sng_fd_t  fd,
wp_logger_cmd_t *  logger_cmd 
)

Set current level (types of events) of Wanpipe Logger.

Parameters
fddevice file descriptor
logger_cmdLogger API command structure
Returns
SANG_STATUS_SUCCESS: ok, else: error

Definition at line 2592 of file libsangoma.c.

2593 {
2594  logger_cmd->cmd = WP_API_LOGGER_CMD_SET_LOGGER_LEVEL;
2595  return sangoma_logger_cmd_exec(fd, logger_cmd);
2596 }
int sangoma_tdm_enable_fax_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Enable FAX Detection on Octasic chip (if hw supports it)

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on cards that have HWEC

Definition at line 2601 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::event, sangoma_cmd_exec(), SANGOMA_INIT_TDM_API_CMD_RESULT, WP_API_EVENT_ENABLE, WP_API_EVENT_FAX_DETECT, and wanpipe_api::wp_cmd.

2602 {
2603  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2605  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2606  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_FAX_DETECT;
2607  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_ENABLE;
2608  return sangoma_cmd_exec(fd,tdm_api);
2609 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_ENABLE
Option to enable command.

Here is the call graph for this function:

int sangoma_tdm_disable_fax_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Disable FAX Detection on Octasic chip (if hw supports it)

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on cards that have HWEC

Definition at line 2611 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::event, sangoma_cmd_exec(), SANGOMA_INIT_TDM_API_CMD_RESULT, WP_API_EVENT_DISABLE, WP_API_EVENT_FAX_DETECT, and wanpipe_api::wp_cmd.

2612 {
2613  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2615  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2616  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_FAX_DETECT;
2617  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_DISABLE;
2618  return sangoma_cmd_exec(fd,tdm_api);
2619 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_DISABLE
Option to disable command.

Here is the call graph for this function:

int sangoma_tdm_get_hw_fax ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Get HW FAX Detection State (Enable or Disabled) on Octasic chip (if hw supports it)

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: Disabled, 1: Enabled

Supported only on cards that have HWEC

Definition at line 2621 of file libsangoma.c.

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

2622 {
2623  int err;
2624  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2627  err=sangoma_cmd_exec(fd,tdm_api);
2628  if (err){
2629  return err;
2630  }
2631  return tdm_api->wp_cmd.hw_fax;
2632 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

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
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on cards that have HWEC

Definition at line 2636 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::event, sangoma_cmd_exec(), SANGOMA_INIT_TDM_API_CMD_RESULT, WP_API_EVENT_DTMF, WP_API_EVENT_ENABLE, and wanpipe_api::wp_cmd.

Referenced by open_sangoma_device().

2637 {
2638  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2640  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2641  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_DTMF;
2642  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_ENABLE;
2643  return sangoma_cmd_exec(fd,tdm_api);
2644 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_ENABLE
Option to enable command.

Here is the call graph for this function:

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
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on cards that have HWEC

Definition at line 2646 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::event, sangoma_cmd_exec(), SANGOMA_INIT_TDM_API_CMD_RESULT, WP_API_EVENT_DISABLE, WP_API_EVENT_DTMF, and wanpipe_api::wp_cmd.

Referenced by cleanup().

2647 {
2648  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2650  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2651  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_DTMF;
2652  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_DISABLE;
2653  return sangoma_cmd_exec(fd,tdm_api);
2654 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_DISABLE
Option to disable command.

Here is the call graph for this function:

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
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on Analog Cards

Definition at line 2656 of file libsangoma.c.

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

Referenced by open_sangoma_device().

2657 {
2658  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2660  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2661  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_RM_DTMF;
2662  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_ENABLE;
2663  return sangoma_cmd_exec(fd,tdm_api);
2664 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_ENABLE
Option to enable command.

Here is the call graph for this function:

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
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on Analog Cards

Definition at line 2666 of file libsangoma.c.

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

Referenced by cleanup().

2667 {
2668  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2670  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2671  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_RM_DTMF;
2672  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_DISABLE;
2673  return sangoma_cmd_exec(fd,tdm_api);
2674 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_DISABLE
Option to disable command.

Here is the call graph for this function:

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
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on Analog Cards

Definition at line 2676 of file libsangoma.c.

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

Referenced by open_sangoma_device().

2677 {
2678  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2680  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2681  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_RXHOOK;
2682  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_ENABLE;
2683  return sangoma_cmd_exec(fd,tdm_api);
2684 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_ENABLE
Option to enable command.

Here is the call graph for this function:

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
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on Analog Cards

Definition at line 2686 of file libsangoma.c.

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

Referenced by cleanup().

2687 {
2688  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2690  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2691  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_RXHOOK;
2692  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_DISABLE;
2693  return sangoma_cmd_exec(fd,tdm_api);
2694 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_DISABLE
Option to disable command.

Here is the call graph for this function:

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
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on Analog Cards

Definition at line 2696 of file libsangoma.c.

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

2697 {
2698  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2700  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2701  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_RING;
2702  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_ENABLE;
2703  return sangoma_cmd_exec(fd,tdm_api);
2704 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_ENABLE
Option to enable command.

Here is the call graph for this function:

int sangoma_tdm_disable_ring_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Disable RING Events (Analog Only)

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on Analog Cards

Definition at line 2706 of file libsangoma.c.

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

2707 {
2708  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2710  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2711  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_RING;
2712  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_DISABLE;
2713  return sangoma_cmd_exec(fd,tdm_api);
2714 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_DISABLE
Option to disable command.

Here is the call graph for this function:

int sangoma_tdm_enable_ring_detect_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Enable RING DETECT Events (Analog Only)

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on Analog Cards

Definition at line 2716 of file libsangoma.c.

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

2717 {
2718  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2720  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2721  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_RING_DETECT;
2722  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_ENABLE;
2723  return sangoma_cmd_exec(fd,tdm_api);
2724 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_ENABLE
Option to enable command.

Here is the call graph for this function:

int sangoma_tdm_disable_ring_detect_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Disable RING DETECT Events (Analog Only)

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on Analog Cards

Definition at line 2726 of file libsangoma.c.

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

2727 {
2728  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2730  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2731  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_RING_DETECT;
2732  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_DISABLE;
2733  return sangoma_cmd_exec(fd,tdm_api);
2734 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_DISABLE
Option to disable command.

Here is the call graph for this function:

int sangoma_tdm_enable_ring_trip_detect_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Enable RING TRIP Events (Analog Only)

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on Analog Cards

Definition at line 2736 of file libsangoma.c.

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

2737 {
2738  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2740  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2741  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_RING_TRIP_DETECT;
2742  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_ENABLE;
2743  return sangoma_cmd_exec(fd,tdm_api);
2744 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_ENABLE
Option to enable command.

Here is the call graph for this function:

int sangoma_tdm_disable_ring_trip_detect_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Disable RING TRIP Events (Analog Only)

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on Analog Cards

Definition at line 2746 of file libsangoma.c.

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

2747 {
2748  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2750  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2751  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_RING_TRIP_DETECT;
2752  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_DISABLE;
2753  return sangoma_cmd_exec(fd,tdm_api);
2754 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_DISABLE
Option to disable command.

Here is the call graph for this function:

int sangoma_tdm_txsig_kewl ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Tranmsmit TX SIG KEWL START (Analog Only)

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on Analog Cards

Definition at line 2756 of file libsangoma.c.

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

2757 {
2758  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2760  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2761  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_TXSIG_KEWL;
2762  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_ENABLE;
2763  return sangoma_cmd_exec(fd,tdm_api);
2764 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_ENABLE
Option to enable command.

Here is the call graph for this function:

int sangoma_tdm_txsig_start ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Tranmsmit TX SIG START (Analog Only)

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on Analog Cards

Definition at line 2766 of file libsangoma.c.

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

2767 {
2768  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2770  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2771  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_TXSIG_START;
2772  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_ENABLE;
2773  return sangoma_cmd_exec(fd,tdm_api);
2774 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_ENABLE
Option to enable command.

Here is the call graph for this function:

int sangoma_tdm_txsig_onhook ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Tranmsmit TX SIG ON HOOK (Analog Only)

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on Analog Cards

Definition at line 2776 of file libsangoma.c.

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

2777 {
2778  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2780  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2781  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_TXSIG_ONHOOK;
2782  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_ENABLE;
2783  return sangoma_cmd_exec(fd,tdm_api);
2784 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_ENABLE
Option to enable command.

Here is the call graph for this function:

int sangoma_tdm_txsig_offhook ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Tranmsmit TX SIG OFF HOOK (Analog Only)

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on Analog Cards

Definition at line 2786 of file libsangoma.c.

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

2787 {
2788  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2790  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2791  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_TXSIG_OFFHOOK;
2792  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_ENABLE;
2793  return sangoma_cmd_exec(fd,tdm_api);
2794 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_ENABLE
Option to enable command.

Here is the call graph for this function:

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
fddevice file descriptor
tdm_apitdm api command structure
tone_idtone type to transmit
Returns
non-zero: error, 0: ok

Supported only on Analog Cards

Definition at line 2796 of file libsangoma.c.

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

2797 {
2798  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2800  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2801  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_TONE;
2802  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_ENABLE;
2803  tdm_api->wp_cmd.event.wp_api_event_tone_type = tone_id;
2804  return sangoma_cmd_exec(fd,tdm_api);
2805 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_ENABLE
Option to enable command.

Here is the call graph for this function:

int sangoma_tdm_disable_tone_events ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Enable TONE Events (Analog Only)

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on Analog Cards

Definition at line 2807 of file libsangoma.c.

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

2808 {
2809  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2811  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2812  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_TONE;
2813  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_DISABLE;
2814  tdm_api->wp_cmd.event.wp_api_event_tone_type = 0x00;
2815  return sangoma_cmd_exec(fd,tdm_api);
2816 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_DISABLE
Option to disable command.

Here is the call graph for this function:

int sangoma_tdm_enable_hwec ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Enable HWEC on this channel.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on cards that have HWEC

Definition at line 2819 of file libsangoma.c.

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

2820 {
2821  /* intentionally NOT initializing chan - caller must do it */
2823  tdm_api->wp_cmd.cmd = WP_API_CMD_ENABLE_HWEC;
2824  return sangoma_cmd_exec(fd,tdm_api);
2825 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

int sangoma_tdm_disable_hwec ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Disable HWEC on this channel.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Supported only on cards that have HWEC

Definition at line 2827 of file libsangoma.c.

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

2828 {
2829  /* intentionally NOT initializing chan - caller must do it */
2831  tdm_api->wp_cmd.cmd = WP_API_CMD_DISABLE_HWEC;
2832  return sangoma_cmd_exec(fd,tdm_api);
2833 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

int _LIBSNG_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
fddevice file descriptor
tdm_apitdm api command structure
alarmsbit map status of T1/E1 alarms
Returns
non-zero: error, 0: ok

Supported only on T1/E1 Cards

Definition at line 2841 of file libsangoma.c.

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

2842 {
2843  int err;
2844 
2845  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2847  tdm_api->wp_cmd.cmd = WP_API_CMD_GET_FE_ALARMS;
2848 
2849  err=sangoma_cmd_exec(fd,tdm_api);
2850  if (err){
2851  return err;
2852  }
2853 
2854  *alarms=tdm_api->wp_cmd.fe_alarms;
2855 
2856  return 0;
2857 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
unsigned int fe_alarms

Here is the call graph for this function:

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
fddevice file descriptor
tdm_apitdm api command structure
current_statuspointer 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

Definition at line 2860 of file libsangoma.c.

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

2861 {
2862  int err;
2863 
2864  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2866  tdm_api->wp_cmd.cmd = WP_API_CMD_GET_FE_STATUS;
2867  err = sangoma_cmd_exec(fd, tdm_api);
2868  *current_status = tdm_api->wp_cmd.fe_status;
2869 
2870  return err;
2871 }
unsigned char fe_status
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

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

Get Device Link Status (Connected/Disconnected)

Parameters
fddevice file descriptor
tdm_apitdm api command structure
current_statuspointer where result will be filled: 0=Link UP 1=Link Down
Returns
non-zero: error, 0: ok -> check current_status

Definition at line 2876 of file libsangoma.c.

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

2877 {
2878  int err;
2879 
2880  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2882  tdm_api->wp_cmd.cmd = WP_API_CMD_GET_FE_STATUS;
2883  err = sangoma_cmd_exec(fd, tdm_api);
2884  *current_status = tdm_api->wp_cmd.fe_status;
2885 
2886  return err;
2887 }
unsigned char fe_status
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

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
fddevice file descriptor
tdm_apitdm api command structure
new_statusnew status 0=Link UP 1=Link Down
Returns
non-zero: error, 0: ok

Definition at line 2890 of file libsangoma.c.

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

2891 {
2892  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2894  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_FE_STATUS;
2895  tdm_api->wp_cmd.fe_status = new_status;
2896  return sangoma_cmd_exec(fd, tdm_api);
2897 }
unsigned char fe_status
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

int _LIBSNG_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
fddevice file descriptor
tdm_apitdm api command structure
channelbri bchannel 1 or 2
Returns
non-zero: error, 0: ok

Definition at line 2900 of file libsangoma.c.

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

2901 {
2902  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2904  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2905  tdm_api->wp_cmd.event.channel = (unsigned char)channel;
2906  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_BRI_CHAN_LOOPBACK;
2907  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_DISABLE;
2908  return sangoma_cmd_exec(fd, tdm_api);
2909 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
u_int8_t channel
wp_api_event_t event
#define WP_API_EVENT_DISABLE
Option to disable command.

Here is the call graph for this function:

int _LIBSNG_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
fddevice file descriptor
tdm_apitdm api command structure
channelbri bchannel 1 or 2
Returns
non-zero: error, 0: ok

Definition at line 2911 of file libsangoma.c.

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

2912 {
2913  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2915  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
2916  tdm_api->wp_cmd.event.channel = (unsigned char)channel;
2917  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_BRI_CHAN_LOOPBACK;
2918  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_ENABLE;
2919  return sangoma_cmd_exec(fd, tdm_api);
2920 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
u_int8_t channel
wp_api_event_t event
#define WP_API_EVENT_ENABLE
Option to enable command.

Here is the call graph for this function:

int sangoma_get_tx_queue_sz ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Get Tx Queue Size for this channel.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Definition at line 2922 of file libsangoma.c.

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

Referenced by open_sangoma_device().

2923 {
2924  int err;
2925 
2926  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2928  tdm_api->wp_cmd.cmd = WP_API_CMD_GET_TX_Q_SIZE;
2929  tdm_api->wp_cmd.tx_queue_sz = 0;
2930 
2931  err=sangoma_cmd_exec(fd, tdm_api);
2932  if (err < 0) {
2933  return err;
2934  }
2935 
2936  return tdm_api->wp_cmd.tx_queue_sz;
2937 }
unsigned int tx_queue_sz
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

Here is the caller graph for this function:

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

Get Tx Queue Size for this channel.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
sizetx queue size (minimum value of 1)
Returns
non-zero: error, 0: ok

Definition at line 2939 of file libsangoma.c.

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

Referenced by open_sangoma_device().

2940 {
2941  if (size < 0) {
2942  return -1;
2943  }
2944  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2946  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_TX_Q_SIZE;
2947  tdm_api->wp_cmd.tx_queue_sz = size;
2948  return sangoma_cmd_exec(fd, tdm_api);
2949 }
unsigned int tx_queue_sz
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

Here is the caller graph for this function:

int sangoma_get_rx_queue_sz ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Get Rx Queue Size for this channel.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero: error, 0: ok

Definition at line 2951 of file libsangoma.c.

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

Referenced by open_sangoma_device().

2952 {
2953  int err;
2954 
2955  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2957  tdm_api->wp_cmd.cmd = WP_API_CMD_GET_RX_Q_SIZE;
2958  tdm_api->wp_cmd.rx_queue_sz = 0;
2959 
2960  err=sangoma_cmd_exec(fd, tdm_api);
2961  if (err < 0) {
2962  return err;
2963  }
2964 
2965  return tdm_api->wp_cmd.rx_queue_sz;
2966 
2967 }
unsigned int rx_queue_sz
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

Here is the caller graph for this function:

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

Get Tx Queue Size for this channel.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
sizerx queue size (minimum value of 1)
Returns
non-zero: error, 0: ok

Definition at line 2969 of file libsangoma.c.

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

Referenced by open_sangoma_device().

2970 {
2971  if (size < 0) {
2972  return -1;
2973  }
2974 
2975  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2977  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_RX_Q_SIZE;
2978  tdm_api->wp_cmd.rx_queue_sz = size;
2979  return sangoma_cmd_exec(fd, tdm_api);
2980 }
unsigned int rx_queue_sz
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

Here is the caller graph for this function:

int 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
fddevice file descriptor
tdm_apitdm api command structure
drv_verdriver version structure that will contain the driver version
Returns
non-zero = error, 0 = ok

Definition at line 2982 of file libsangoma.c.

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

2983 {
2984  int err;
2985 
2986  WANPIPE_API_INIT_CHAN(tdm_api, 0);
2989 
2990  err = sangoma_cmd_exec(fd, tdm_api);
2991  if (err == 0) {
2992  if (tdm_api->wp_cmd.data_len == sizeof(wan_driver_version_t)) {
2993  if (drv_ver) {
2994  memcpy(drv_ver,&tdm_api->wp_cmd.version,sizeof(wan_driver_version_t));
2995  }
2996  } else {
2997  return -1;
2998  }
2999  }
3000 
3001  return err;
3002 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

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

Get Hardware/Firmware Version.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
verhardware/firmware version number
Returns
non-zero = error, 0 = ok

Definition at line 3004 of file libsangoma.c.

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

3005 {
3006  int err;
3007 
3008  WANPIPE_API_INIT_CHAN(tdm_api, 0);
3011 
3012  err = sangoma_cmd_exec(fd, tdm_api);
3013  if (err == 0) {
3014  if (tdm_api->wp_cmd.data_len == sizeof(unsigned char)) {
3015  *ver = tdm_api->wp_cmd.data[0];
3016  } else {
3017  return -1;
3018  }
3019  }
3020 
3021  return err;
3022 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

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

Get AFT CPLD Version.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
verAFT CPLD version number
Returns
non-zero = error, 0 = ok

Definition at line 3024 of file libsangoma.c.

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

3025 {
3026  int err;
3027 
3028  WANPIPE_API_INIT_CHAN(tdm_api, 0);
3030  tdm_api->wp_cmd.cmd = WP_API_CMD_CPLD_VERSION;
3031 
3032  err = sangoma_cmd_exec(fd, tdm_api);
3033  if (err == 0) {
3034  if (tdm_api->wp_cmd.data_len == sizeof(unsigned char)) {
3035  *ver = tdm_api->wp_cmd.data[0];
3036  } else {
3037  return -1;
3038  }
3039  }
3040 
3041  return err;
3042 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

int _LIBSNG_CALL sangoma_get_aft_customer_id ( sng_fd_t  fd,
unsigned char *  out_customer_id 
)

Get Customer-specific ID from AFT hardware, the default value is 0xFF, any change requires special arrangement with Sangoma Technologies.

Parameters
fddevice file descriptor
out_customer_idAFT Customer ID
Returns
non-zero = error, 0 = ok

Definition at line 3044 of file libsangoma.c.

References SANG_STATUS_IO_ERROR, SANG_STATUS_UNSUPPORTED_FUNCTION, sangoma_mgmt_cmd(), and WANPIPEMON_AFT_CUSTOMER_ID.

3045 {
3046  wan_udp_hdr_t wan_udp;
3047 
3048  memset(&wan_udp, 0x00, sizeof(wan_udp));
3049 
3050  wan_udp.wan_udphdr_command = WANPIPEMON_AFT_CUSTOMER_ID;
3051  wan_udp.wan_udphdr_return_code = SANG_STATUS_UNSUPPORTED_FUNCTION;
3052  wan_udp.wan_udphdr_data_len = 0;
3053 
3054  if (sangoma_mgmt_cmd(fd, &wan_udp)) {
3055  return SANG_STATUS_IO_ERROR;
3056  }
3057 
3058  if (wan_udp.wan_udphdr_return_code) {
3060  }
3061 
3062  *out_customer_id = sangoma_get_wan_udphdr_data_byte(&wan_udp, 0);
3063 
3064  return 0;
3065 }
int _LIBSNG_CALL sangoma_mgmt_cmd(sng_fd_t fd, wan_udp_hdr_t *wan_udp)
Execute Sangoma Management Command.
Wanpipe UDP Structure used for Maintenance and Debugging.
Definition: wanpipe_api.h:92

Here is the call graph for this function:

int _LIBSNG_CALL sangoma_port_led_ctrl ( sng_fd_t  fd,
unsigned char  led_state 
)

Control the LED ligths of the TDM port. On (led set based on link status) Off (turn off all led). Used to visually identify a phisical port from software.

Parameters
fddevice file descriptor
led_state0=off 1=on
Returns
non-zero = error, 0 = ok

Definition at line 3068 of file libsangoma.c.

References SANG_STATUS_IO_ERROR, SANG_STATUS_UNSUPPORTED_FUNCTION, sangoma_mgmt_cmd(), and WANPIPEMON_LED_CTRL.

3069 {
3070  wan_udp_hdr_t wan_udp;
3071 
3072  memset(&wan_udp, 0x00, sizeof(wan_udp));
3073 
3074  wan_udp.wan_udphdr_command = WANPIPEMON_LED_CTRL;
3075  wan_udp.wan_udphdr_return_code = SANG_STATUS_UNSUPPORTED_FUNCTION;
3076  wan_udp.wan_udphdr_data_len = 1;
3077  wan_udp.wan_udphdr_data[0] = led_ctrl;
3078 
3079  if (sangoma_mgmt_cmd(fd, &wan_udp)) {
3080  return SANG_STATUS_IO_ERROR;
3081  }
3082 
3083  if (wan_udp.wan_udphdr_return_code) {
3085  }
3086 
3087  return 0;
3088 }
int _LIBSNG_CALL sangoma_mgmt_cmd(sng_fd_t fd, wan_udp_hdr_t *wan_udp)
Execute Sangoma Management Command.
Wanpipe UDP Structure used for Maintenance and Debugging.
Definition: wanpipe_api.h:92

Here is the call graph for this function:

int sangoma_fe_reg_write ( sng_fd_t  fd,
uint32_t  offset,
uint8_t  data 
)

Write to a front end register.

Parameters
fddevice file descriptor
offsetoffset of front end register
datavalue to write
Returns
non-zero = error, 0 = ok

Definition at line 3092 of file libsangoma.c.

References wanpipe_api_cmd::chan, SANG_STATUS_IO_ERROR, SANG_STATUS_UNSUPPORTED_FUNCTION, sangoma_get_full_cfg(), sangoma_mgmt_cmd(), and wanpipe_api::wp_cmd.

3093 {
3094  int chan=0;
3095  wan_udp_hdr_t wan_udp;
3096  sdla_fe_debug_t *fe_debug;
3097  memset(&wan_udp, 0x00, sizeof(wan_udp));
3098 
3099  {
3100  int err;
3101  wanpipe_api_t tdm_api;
3102  memset(&tdm_api,0,sizeof(tdm_api));
3103  err=sangoma_get_full_cfg(fd, &tdm_api);
3104  if (err) {
3105  return err;
3106  }
3107  chan=tdm_api.wp_cmd.chan;
3108  if (chan)
3109  chan--;
3110  }
3111 
3112  wan_udp.wan_udphdr_command = WAN_FE_SET_DEBUG_MODE;
3113  wan_udp.wan_udphdr_data_len = sizeof(sdla_fe_debug_t);
3114  wan_udp.wan_udphdr_return_code = 0xaa;
3115  fe_debug = (sdla_fe_debug_t*)wan_udp.wan_udphdr_data;
3116 
3117  fe_debug->type = WAN_FE_DEBUG_REG;
3118  fe_debug->mod_no = chan;
3119  fe_debug->fe_debug_reg.reg = offset;
3120  fe_debug->fe_debug_reg.value = data;
3121  fe_debug->fe_debug_reg.read = 0;
3122 
3123  if (sangoma_mgmt_cmd(fd, &wan_udp)) {
3124  return SANG_STATUS_IO_ERROR;
3125  }
3126 
3127  if (wan_udp.wan_udphdr_return_code) {
3129  }
3130 
3131  return 0;
3132 }
int _LIBSNG_CALL sangoma_get_full_cfg(sng_fd_t fd, wanpipe_api_t *tdm_api)
Read tdm api device configuration.
Definition: libsangoma.c:2026
int _LIBSNG_CALL sangoma_mgmt_cmd(sng_fd_t fd, wan_udp_hdr_t *wan_udp)
Execute Sangoma Management Command.
wanpipe_api_cmd_t wp_cmd
Wanpipe UDP Structure used for Maintenance and Debugging.
Definition: wanpipe_api.h:92
unsigned char chan
Wanpipe API Command Structure.

Here is the call graph for this function:

int sangoma_fe_reg_read ( sng_fd_t  fd,
uint32_t  offset,
uint8_t *  data 
)

Read front end register.

Parameters
fddevice file descriptor
offsetoffset of front end register
datavalue of the read register
Returns
non-zero = error, 0 = ok

Definition at line 3134 of file libsangoma.c.

References wanpipe_api_cmd::chan, SANG_STATUS_IO_ERROR, SANG_STATUS_UNSUPPORTED_FUNCTION, sangoma_get_full_cfg(), sangoma_mgmt_cmd(), and wanpipe_api::wp_cmd.

Referenced by open_sangoma_device().

3135 {
3136  int chan=0;
3137  wan_udp_hdr_t wan_udp;
3138  sdla_fe_debug_t *fe_debug;
3139  memset(&wan_udp, 0x00, sizeof(wan_udp));
3140 
3141  {
3142  int err;
3143  wanpipe_api_t tdm_api;
3144  memset(&tdm_api,0,sizeof(tdm_api));
3145  err=sangoma_get_full_cfg(fd, &tdm_api);
3146  if (err) {
3147  return err;
3148  }
3149  chan=tdm_api.wp_cmd.chan;
3150  if (chan)
3151  chan--;
3152  }
3153 
3154  wan_udp.wan_udphdr_command = WAN_FE_SET_DEBUG_MODE;
3155  wan_udp.wan_udphdr_data_len = sizeof(sdla_fe_debug_t);
3156  wan_udp.wan_udphdr_return_code = 0xaa;
3157  fe_debug = (sdla_fe_debug_t*)wan_udp.wan_udphdr_data;
3158 
3159  fe_debug->type = WAN_FE_DEBUG_REG;
3160  fe_debug->mod_no = chan;
3161  fe_debug->fe_debug_reg.reg = offset;
3162  fe_debug->fe_debug_reg.read = 1;
3163 
3164  if (sangoma_mgmt_cmd(fd, &wan_udp)) {
3165  return SANG_STATUS_IO_ERROR;
3166  }
3167 
3168  if (wan_udp.wan_udphdr_return_code) {
3170  }
3171 
3172  *data = fe_debug->fe_debug_reg.value;
3173 
3174  return 0;
3175 }
int _LIBSNG_CALL sangoma_get_full_cfg(sng_fd_t fd, wanpipe_api_t *tdm_api)
Read tdm api device configuration.
Definition: libsangoma.c:2026
int _LIBSNG_CALL sangoma_mgmt_cmd(sng_fd_t fd, wan_udp_hdr_t *wan_udp)
Execute Sangoma Management Command.
wanpipe_api_cmd_t wp_cmd
Wanpipe UDP Structure used for Maintenance and Debugging.
Definition: wanpipe_api.h:92
unsigned char chan
Wanpipe API Command Structure.

Here is the call graph for this function:

Here is the caller graph for this function:

int 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
fddevice file descriptor
tdm_apitdm api command structure
statsstats structure will be filled with device stats. (Optional, can be left NULL)
Returns
non-zero = error, 0 = ok

Definition at line 3281 of file libsangoma.c.

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

3282 {
3283  int err;
3284 
3285  WANPIPE_API_INIT_CHAN(tdm_api, 0);
3287  tdm_api->wp_cmd.cmd = WP_API_CMD_GET_STATS;
3288 
3289  err = sangoma_cmd_exec(fd, tdm_api);
3290  if (err == 0) {
3291  if (stats) {
3292  memcpy(stats, &tdm_api->wp_cmd.stats, sizeof(wanpipe_chan_stats_t));
3293  }
3294  }
3295 
3296  return err;
3297 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
TDM API channel statistics.
wanpipe_chan_stats_t stats

Here is the call graph for this function:

int _LIBSNG_CALL sangoma_flush_stats ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Flush/Reset device statistics.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero = error, 0 = ok

Definition at line 3299 of file libsangoma.c.

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

Referenced by open_sangoma_device().

3300 {
3301  WANPIPE_API_INIT_CHAN(tdm_api, 0);
3303  tdm_api->wp_cmd.cmd = WP_API_CMD_RESET_STATS;
3304  return sangoma_cmd_exec(fd, tdm_api);
3305 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

Here is the caller graph for this function:

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

Set rxflashtime for FXS module Wink-Flash Event.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
rxflashtimetime value
Returns
non-zero = error, 0 = ok

Definition at line 3307 of file libsangoma.c.

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

3308 {
3309  WANPIPE_API_INIT_CHAN(tdm_api, 0);
3312  tdm_api->wp_cmd.rxflashtime=rxflashtime;
3313  return sangoma_cmd_exec(fd, tdm_api);
3314 }
unsigned int rxflashtime
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

int sangoma_set_rm_tx_gain ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
int  value 
)

set tx gain for FXO/FXS module

Parameters
fddevice file descriptor
tdm_apitdm api command structure
valuetxgain (FXO - txgain value ranges from -150 to 120 , FXS - txgain value 35,-35)
Returns
non-zero = error, 0 = ok

Definition at line 3317 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::event, sangoma_cmd_exec(), SANGOMA_INIT_TDM_API_CMD_RESULT, WP_API_EVENT_ENABLE, WP_API_EVENT_SET_RM_TX_GAIN, and wanpipe_api::wp_cmd.

3318 {
3319  WANPIPE_API_INIT_CHAN(tdm_api, 0);
3321  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
3322  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_SET_RM_TX_GAIN;
3323  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_ENABLE;
3324  tdm_api->wp_cmd.event.wp_api_event_gain_value = value;
3325  return sangoma_cmd_exec(fd, tdm_api);
3326 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_ENABLE
Option to enable command.

Here is the call graph for this function:

int sangoma_set_rm_rx_gain ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
int  value 
)

set rx gain for FXO/FXS module

Parameters
fddevice file descriptor
tdm_apitdm api command structure
valuerxgain (FXO - rxgain value ranges from -150 to 120 , FXS -rxgain value 35,-35)
Returns
non-zero = error, 0 = ok

Definition at line 3328 of file libsangoma.c.

References wanpipe_api_cmd::cmd, wanpipe_api_cmd::event, sangoma_cmd_exec(), SANGOMA_INIT_TDM_API_CMD_RESULT, WP_API_EVENT_ENABLE, WP_API_EVENT_SET_RM_RX_GAIN, and wanpipe_api::wp_cmd.

3329 {
3330  WANPIPE_API_INIT_CHAN(tdm_api, 0);
3332  tdm_api->wp_cmd.cmd = WP_API_CMD_SET_EVENT;
3333  tdm_api->wp_cmd.event.wp_api_event_type = WP_API_EVENT_SET_RM_RX_GAIN;
3334  tdm_api->wp_cmd.event.wp_api_event_mode = WP_API_EVENT_ENABLE;
3335  tdm_api->wp_cmd.event.wp_api_event_gain_value = value;
3336  return sangoma_cmd_exec(fd, tdm_api);
3337 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd
wp_api_event_t event
#define WP_API_EVENT_ENABLE
Option to enable command.

Here is the call graph for this function:

int sangoma_tdm_enable_loop ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Enable channel loop: All rx data will be transmitted back out.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero = error, 0 = ok

Definition at line 3367 of file libsangoma.c.

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

3368 {
3369  int err;
3370 
3371  WANPIPE_API_INIT_CHAN(tdm_api, 0);
3373  tdm_api->wp_cmd.cmd = WP_API_CMD_ENABLE_LOOP;
3374  err = sangoma_cmd_exec(fd, tdm_api);
3375  return err;
3376 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

int sangoma_tdm_disable_loop ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Disable channel loop.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
non-zero = error, 0 = ok

Definition at line 3378 of file libsangoma.c.

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

3379 {
3380  int err;
3381 
3382  WANPIPE_API_INIT_CHAN(tdm_api, 0);
3384  tdm_api->wp_cmd.cmd = WP_API_CMD_DISABLE_LOOP;
3385  err = sangoma_cmd_exec(fd, tdm_api);
3386  return err;
3387 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

int _LIBSNG_CALL sangoma_ss7_force_rx ( sng_fd_t  fd,
wanpipe_api_t tdm_api 
)

Force the firmware to pass up a repeating frame.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
Returns
SANG_STATUS_SUCCESS: success, or error status of IOCTL

Definition at line 3400 of file libsangoma.c.

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

3401 {
3402  WANPIPE_API_INIT_CHAN(tdm_api, 0);
3404  tdm_api->wp_cmd.cmd = WP_API_CMD_SS7_FORCE_RX;
3405  return sangoma_cmd_exec(fd, tdm_api);
3406 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

int _LIBSNG_CALL sangoma_ss7_get_cfg_status ( sng_fd_t  fd,
wanpipe_api_t tdm_api,
wan_api_ss7_cfg_status_t ss7_cfg_status 
)

Get current ss7 hw configuration.

Parameters
fddevice file descriptor
tdm_apitdm api command structure
ss7_cfg_statusss7 configuration status structure
Returns
SANG_STATUS_SUCCESS: success, or error status of IOCTL

Definition at line 3410 of file libsangoma.c.

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

Referenced by open_sangoma_device().

3411 {
3412  int err;
3413 
3414  WANPIPE_API_INIT_CHAN(tdm_api, 0);
3417 
3418  err = sangoma_cmd_exec(fd, tdm_api);
3419  if (err == 0) {
3420  if (ss7_cfg_status) {
3421  memcpy(ss7_cfg_status, &tdm_api->wp_cmd.ss7_cfg_status, sizeof(wan_api_ss7_cfg_status_t));
3422  }
3423  }
3424 
3425  return err;
3426 }
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
Definition: libsangoma.c:2004
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the &#39;result&#39; in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
Definition: libsangoma.h:104
wanpipe_api_cmd_t wp_cmd

Here is the call graph for this function:

Here is the caller graph for this function: