#include "libsangoma.h"
Include dependency graph for libsangoma.c:
Go to the source code of this file.
Defines | |
#define | DFT_CARD "wanpipe1" |
Default card name. Deprecated not used. | |
#define | DEV_NAME_LEN 100 |
String length of device name. | |
#define | DBG_POLL if(0)libsng_dbg |
#define | DBG_EVNT if(0)libsng_dbg |
#define | DBG_ERR if(1)libsng_dbg |
Functions | |
void _SAPI_CALL | sangoma_close (sng_fd_t *fd) |
Close device file descriptor. | |
void _SAPI_CALL | sangoma_init_wait_obj (sangoma_wait_obj_t *sng_wait_obj, sng_fd_t fd, int span, int chan, int timeout, int flags_in, int object_type) |
Initialize a wait object that will be used in sangoma_socket_waitfor_many() function. | |
void _SAPI_CALL | sangoma_release_wait_obj (sangoma_wait_obj_t *sng_wait_obj) |
De-allocate all resources in a wait object. | |
void _SAPI_CALL | sangoma_signal_wait_obj (sangoma_wait_obj_t *sng_wait_obj) |
Set wait object to a signalled state. | |
int _SAPI_CALL | sangoma_socket_waitfor_many (sangoma_wait_obj_t sangoma_wait_objects[], int number_of_sangoma_wait_objects, uint32_t system_wait_timeout) |
Wait for multiple file descriptors - poll(). | |
int _SAPI_CALL | sangoma_socket_waitfor (sng_fd_t fd, int timeout, int flags_in, unsigned int *flags_out) |
Wait for a single file descriptor - poll(). | |
int _SAPI_CALL | sangoma_mgmt_cmd (sng_fd_t fd, wan_udp_hdr_t *wan_udp) |
Execute Sangoma Management Command. | |
int _SAPI_CALL | sangoma_span_chan_toif (int span, int chan, char *interface_name) |
Convert Span & Chan to interface name. | |
int _SAPI_CALL | sangoma_interface_toi (char *interface_name, int *span, int *chan) |
Convert Span & Chan to interface name. | |
int _SAPI_CALL | sangoma_span_chan_fromif (char *interface_name, int *span, int *chan) |
Convert Interace Name to Span & Chan. | |
sng_fd_t _SAPI_CALL | sangoma_open_api_span_chan (int span, int chan) |
Open a Device based on Span/Chan values. | |
sng_fd_t _SAPI_CALL | __sangoma_open_api_span_chan (int span, int chan) |
Open a Device based on Span/Chan values. | |
sng_fd_t | sangoma_open_api_ctrl (void) |
Open a Global Control Device. | |
sng_fd_t _SAPI_CALL | sangoma_create_socket_by_name (char *device, char *card) |
Open a device based on a interface and card name. | |
sng_fd_t _SAPI_CALL | sangoma_open_api_span (int span) |
int _SAPI_CALL | sangoma_readmsg (sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag) |
Read Data from device. | |
int _SAPI_CALL | sangoma_writemsg (sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, unsigned short datalen, int flag) |
Write Data to device. | |
int _SAPI_CALL | sangoma_cmd_exec (sng_fd_t fd, wanpipe_api_t *tdm_api) |
Execute Sangoma API Command. | |
int _SAPI_CALL | sangoma_get_full_cfg (sng_fd_t fd, wanpipe_api_t *tdm_api) |
Read tdm api device configuration. | |
int _SAPI_CALL | sangoma_tdm_set_codec (sng_fd_t fd, wanpipe_api_t *tdm_api, int codec) |
Set TDM Codec per chan. | |
int _SAPI_CALL | sangoma_tdm_get_codec (sng_fd_t fd, wanpipe_api_t *tdm_api) |
Get Configured TDM Codec per chan. | |
int _SAPI_CALL | sangoma_tdm_set_usr_period (sng_fd_t fd, wanpipe_api_t *tdm_api, int period) |
Set Tx/Rx Period in Milliseconds. | |
int _SAPI_CALL | sangoma_tdm_get_usr_period (sng_fd_t fd, wanpipe_api_t *tdm_api) |
Get Tx/Rx Period in Milliseconds. | |
int _SAPI_CALL | sangoma_get_hw_coding (sng_fd_t fd, wanpipe_api_t *tdm_api) |
Get HW Voice Coding (ulaw/alaw). | |
int _SAPI_CALL | sangoma_tdm_get_usr_mtu_mru (sng_fd_t fd, wanpipe_api_t *tdm_api) |
Get Tx/Rx MTU/MRU in bytes. | |
int _SAPI_CALL | sangoma_tdm_set_power_level (sng_fd_t fd, wanpipe_api_t *tdm_api, int power) |
Set Power Level - so only data matching the power level would be passed up. | |
int _SAPI_CALL | sangoma_tdm_get_power_level (sng_fd_t fd, wanpipe_api_t *tdm_api) |
Get Configured Power Level. | |
int _SAPI_CALL | sangoma_flush_bufs (sng_fd_t fd, wanpipe_api_t *tdm_api) |
Flush buffers from current channel. | |
int _SAPI_CALL | sangoma_tdm_enable_rbs_events (sng_fd_t fd, wanpipe_api_t *tdm_api, int poll_in_sec) |
Enable RBS Events on a device. | |
int _SAPI_CALL | sangoma_tdm_disable_rbs_events (sng_fd_t fd, wanpipe_api_t *tdm_api) |
Disable RBS Events for a device. | |
int _SAPI_CALL | sangoma_tdm_write_rbs (sng_fd_t fd, wanpipe_api_t *tdm_api, unsigned char rbs) |
Write RBS Bits on a device. | |
int _SAPI_CALL | sangoma_read_event (sng_fd_t fd, wanpipe_api_t *tdm_api) |
Read API Events. | |
int _SAPI_CALL | sangoma_tdm_enable_hwec (sng_fd_t fd, wanpipe_api_t *tdm_api) |
Enable HWEC on this channel. | |
int _SAPI_CALL | sangoma_tdm_disable_hwec (sng_fd_t fd, wanpipe_api_t *tdm_api) |
Disable HWEC on this channel. |
Author(s): Nenad Corbic <ncorbic@sangoma.com> David Rokhvarg <davidr@sangoma.com> Michael Jerris <mike@jerris.com> Anthony Minessale II <anthmct@yahoo.com>
Copyright: (c) 2005-2008 Nenad Corbic <ncorbic@sangoma.com>
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Sangoma Technologies nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY Sangoma Technologies ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Sangoma Technologies BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Definition in file libsangoma.c.
#define DBG_POLL if(0)libsng_dbg |
WINDOWS Only Section
Definition at line 86 of file libsangoma.c.
void sangoma_close | ( | sng_fd_t * | fd | ) |
Close device file descriptor.
fd | device file descriptor |
Definition at line 390 of file libsangoma.c.
References INVALID_HANDLE_VALUE.
Referenced by cleanup(), sangoma_open_api_span_chan(), and sangoma_release_wait_obj().
00391 { 00392 #if defined(WIN32) 00393 if( *fd != INVALID_HANDLE_VALUE){ 00394 CloseHandle(*fd); 00395 *fd = INVALID_HANDLE_VALUE; 00396 } 00397 #else 00398 if (*fd >= 0) { 00399 close(*fd); 00400 *fd = -1; 00401 } 00402 #endif 00403 }
Here is the caller graph for this function:
void sangoma_init_wait_obj | ( | sangoma_wait_obj_t * | sng_wait_obj, | |
sng_fd_t | fd, | |||
int | span, | |||
int | chan, | |||
int | timeout, | |||
int | flags_in, | |||
int | object_type | |||
) |
Initialize a wait object that will be used in sangoma_socket_waitfor_many() function.
sng_wait_obj | pointer a single device object | |
fd | device file descriptor | |
span | span number starting from 1 to 255 | |
chan | chan number starting from 1 to 32 | |
timeout | timeout in miliseconds in case of no event | |
flags_in | events to wait for (read/write/event) | |
object_type | defines whether file descriptor is a sangoma device or other sytem file descriptor. |
Definition at line 417 of file libsangoma.c.
References sangoma_wait_obj::chan, FALSE, sangoma_wait_obj::fd, sangoma_wait_obj::flags_in, sangoma_wait_obj::object_type, sangoma_wait_obj::span, and sangoma_wait_obj::timeout.
Referenced by open_sangoma_devices().
00418 { 00419 sng_wait_obj->fd = fd; 00420 sng_wait_obj->timeout = timeout; 00421 sng_wait_obj->flags_in = flags_in; 00422 sng_wait_obj->span = span; 00423 sng_wait_obj->chan = chan; 00424 sng_wait_obj->object_type = object_type; 00425 #if defined(WIN32) 00426 sng_wait_obj->OverlappedApiPoll.hEvent = CreateEvent( NULL, FALSE, FALSE, NULL); 00427 #endif 00428 }
Here is the caller graph for this function:
void sangoma_release_wait_obj | ( | sangoma_wait_obj_t * | sng_wait_obj | ) |
De-allocate all resources in a wait object.
sng_wait_obj | pointer a single device object |
Definition at line 436 of file libsangoma.c.
References sangoma_wait_obj::fd, INVALID_HANDLE_VALUE, sangoma_wait_obj::object_type, and sangoma_close().
00437 { 00438 if(sng_wait_obj->fd != INVALID_HANDLE_VALUE){ 00439 sangoma_close(&sng_wait_obj->fd); 00440 sng_wait_obj->fd = INVALID_HANDLE_VALUE; 00441 } 00442 00443 sng_wait_obj->object_type = UNKNOWN_WAIT_OBJ; 00444 00445 #if defined(WIN32) 00446 if(sng_wait_obj->OverlappedApiPoll.hEvent){ 00447 CloseHandle(sng_wait_obj->OverlappedApiPoll.hEvent); 00448 sng_wait_obj->OverlappedApiPoll.hEvent = 0; 00449 } 00450 #endif 00451 }
Here is the call graph for this function:
void sangoma_signal_wait_obj | ( | sangoma_wait_obj_t * | sng_wait_obj | ) |
Set wait object to a signalled state.
sng_wait_obj | pointer a single device object |
Definition at line 459 of file libsangoma.c.
00460 { 00461 #if defined(WIN32) 00462 if(sng_wait_obj->OverlappedApiPoll.hEvent){ 00463 SetEvent(sng_wait_obj->OverlappedApiPoll.hEvent); 00464 } 00465 #else 00466 //FIXME: implement signalling of the sng_wait_obj->fd ?? 00467 #endif 00468 }
int sangoma_socket_waitfor_many | ( | sangoma_wait_obj_t | sangoma_wait_objects[], | |
int | number_of_sangoma_wait_objects, | |||
uint32_t | system_wait_timeout | |||
) |
Wait for multiple file descriptors - poll().
sangoma_wait_objects | pointer to array of file descriptors to wait for | |
number_of_sangoma_wait_objects | size of the array of file descriptors | |
system_wait_timeout | timeout in miliseconds in case of no event |
Definition at line 478 of file libsangoma.c.
References DBG_EVNT, HANDLE, sangoma_wait_obj::object_type, and sangoma_wait_objects.
Referenced by handle_span_chan().
00479 { 00480 int i; 00481 #if defined(WIN32) 00482 HANDLE hEvents[MAXIMUM_WAIT_OBJECTS]; 00483 00484 if(number_of_sangoma_wait_objects > MAXIMUM_WAIT_OBJECTS){ 00485 DBG_EVNT("Error: %s(): 'number_of_sangoma_wait_objects': %d is greater than the Maximum of: %d\n", __FUNCTION__, 00486 number_of_sangoma_wait_objects, MAXIMUM_WAIT_OBJECTS); 00487 return -1; 00488 } 00489 00490 if(number_of_sangoma_wait_objects < 1){ 00491 DBG_EVNT("Error: %s(): 'number_of_sangoma_wait_objects': %d is less than the Minimum of: 1!\n", __FUNCTION__, 00492 number_of_sangoma_wait_objects); 00493 return -2; 00494 } 00495 00496 for(i = 0; i < number_of_sangoma_wait_objects; i++){ 00497 hEvents[i] = sangoma_wait_objects[i].OverlappedApiPoll.hEvent; 00498 if(sangoma_wait_objects[i].object_type == SANGOMA_WAIT_OBJ){ 00499 sangoma_socket_poll(&sangoma_wait_objects[i]); 00500 } 00501 } 00502 00503 /* wait untill at least one of the events is signalled OR a timeout */ 00504 if(WAIT_TIMEOUT == WaitForMultipleObjects(number_of_sangoma_wait_objects, &hEvents[0], FALSE, system_wait_timeout)){ 00505 return 0; 00506 } 00507 00508 /* find which overlapped IO was completed */ 00509 for(i = 0; i < number_of_sangoma_wait_objects; i++){ 00510 00511 if(sangoma_wait_objects[i].object_type != SANGOMA_WAIT_OBJ){ 00512 DBG_POLL("%s(): at index %d is not a SANGOMA_WAIT_OBJ\n", __FUNCTION__, i); 00513 continue; 00514 } 00515 00516 if(sangoma_socket_get_state(&sangoma_wait_objects[i]) > 0){ 00517 00518 if(sangoma_wait_objects[i].api_poll.operation_status == SANG_STATUS_SUCCESS){ 00519 00520 sangoma_wait_objects[i].flags_out = sangoma_wait_objects[i].api_poll.poll_events_bitmap; 00521 00522 }else{ 00523 DBG_EVNT("Error: %s(): Invalid Operation Status: %s(%d)\n", __FUNCTION__, 00524 SDLA_DECODE_SANG_STATUS(sangoma_wait_objects[i].api_poll.operation_status), 00525 sangoma_wait_objects[i].api_poll.operation_status); 00526 return -2; 00527 } 00528 } 00529 } 00530 00531 return 1; 00532 #else 00533 struct pollfd pfds[number_of_sangoma_wait_objects]; 00534 int res; 00535 00536 memset(pfds, 0, sizeof(pfds)); 00537 00538 for(i = 0; i < number_of_sangoma_wait_objects; i++){ 00539 pfds[i].fd = sangoma_wait_objects[i].fd; 00540 pfds[i].events = sangoma_wait_objects[i].flags_in; 00541 } 00542 00543 res = poll(pfds, number_of_sangoma_wait_objects, sangoma_wait_objects[0].timeout); 00544 if (res > 0) { 00545 for(i = 0; i < number_of_sangoma_wait_objects; i++){ 00546 sangoma_wait_objects[i].flags_out = pfds[i].revents; 00547 } 00548 } 00549 00550 return res; 00551 #endif 00552 }
Here is the caller graph for this function:
int sangoma_socket_waitfor | ( | sng_fd_t | fd, | |
int | timeout, | |||
int | flags_in, | |||
unsigned int * | flags_out | |||
) |
Wait for a single file descriptor - poll().
fd | device file descriptor | |
timeout | timeout in miliseconds in case of no event | |
flags_in | events to wait for (read/write/event) | |
flags_out | events that occured (read/write/event) |
Definition at line 564 of file libsangoma.c.
References BOOL, DBG_EVNT, DWORD, FALSE, _API_POLL_STRUCT::operation_status, _API_POLL_STRUCT::poll_events_bitmap, SANG_STATUS_SUCCESS, SDLA_DECODE_SANG_STATUS, TRUE, and _API_POLL_STRUCT::user_flags_bitmap.
00565 { 00566 #if defined(WIN32) 00567 API_POLL_STRUCT api_poll; 00568 DWORD NumberOfBytesTransferred; 00569 BOOL bOverlappedResult; 00570 OVERLAPPED OverlappedApiPoll; 00571 00572 memset(&api_poll, 0x00, sizeof(API_POLL_STRUCT)); 00573 00574 api_poll.user_flags_bitmap = flags_in; 00575 00576 /* This call will return immediatly because it is "overlapped"! 00577 * Caller of this function must implement the actual wait. */ 00578 if(DoApiPollCommand(fd, &api_poll, &OverlappedApiPoll)){ 00579 //failed 00580 return -1; 00581 } 00582 00583 bOverlappedResult = GetOverlappedResult(fd, &OverlappedApiPoll, &NumberOfBytesTransferred, 00584 TRUE /* wait (indefinitely) for IO to complete */); 00585 if(bOverlappedResult == FALSE){ 00586 if(GetLastError() == ERROR_IO_INCOMPLETE){ 00587 /* IO still in process */ 00588 return 0; 00589 }else{ 00590 /* Function call failed. Error. */ 00591 return -1; 00592 } 00593 }else{ 00594 if(GetLastError() == ERROR_SUCCESS){ 00595 /* IO is complete. Sangoma "socket" is signaled. */ 00596 if(api_poll.operation_status == SANG_STATUS_SUCCESS){ 00597 00598 *flags_out = api_poll.poll_events_bitmap; 00599 return 1; 00600 }else{ 00601 DBG_EVNT("Error: %s(): Invalid Operation Status: %s(%d)\n", __FUNCTION__, 00602 SDLA_DECODE_SANG_STATUS(api_poll.operation_status), api_poll.operation_status); 00603 return -3; 00604 } 00605 } 00606 if(GetLastError() == ERROR_INVALID_PARAMETER){ 00607 /* IO is complete, but with an error. */ 00608 return -2; 00609 } 00610 } 00611 return -1; 00612 #else 00613 struct pollfd pfds[1]; 00614 int res; 00615 00616 memset(&pfds[0], 0, sizeof(pfds[0])); 00617 pfds[0].fd = fd; 00618 pfds[0].events = flags_in; 00619 *flags_out=0; 00620 00621 res = poll(pfds, 1, timeout); 00622 if (res > 0) { 00623 *flags_out = pfds[0].revents; 00624 } 00625 00626 return res; 00627 #endif 00628 }
int sangoma_mgmt_cmd | ( | sng_fd_t | fd, | |
wan_udp_hdr_t * | wan_udp | |||
) |
Execute Sangoma Management Command.
fd | device file descriptor | |
wan_udp | management command structure |
Definition at line 630 of file libsangoma.c.
References wan_udp, and WANPIPE_IOCTL_PIPEMON.
00631 { 00632 #if defined(__WINDOWS__) 00633 if(DoManagementCommand(fd, wan_udp)){ 00634 return 1; 00635 } 00636 #else 00637 unsigned char id = 0; 00638 int err=0; 00639 wan_udp->wan_udphdr_request_reply = 0x01; 00640 wan_udp->wan_udphdr_id = id; 00641 wan_udp->wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD; 00642 00643 err=ioctl(fd,WANPIPE_IOCTL_PIPEMON,wan_udp); 00644 if (err < 0) { 00645 return 1; 00646 } 00647 #endif 00648 00649 if(wan_udp->wan_udphdr_return_code != WAN_CMD_OK){ 00650 return 2; 00651 } 00652 return 0; 00653 }
int sangoma_span_chan_toif | ( | int | span, | |
int | chan, | |||
char * | interface_name | |||
) |
Convert Span & Chan to interface name.
span | span number starting from 1 to 255 | |
chan | chan number starting from 1 to 32 | |
interface_name | pointer to string where interface name will be written |
Definition at line 655 of file libsangoma.c.
00656 { 00657 #if defined(WIN32) 00658 /* FIXME: Not implemented */ 00659 return -1; 00660 #else 00661 sprintf(interface_name,"s%ic%i",span,chan); 00662 #endif 00663 return 0; 00664 }
int sangoma_interface_toi | ( | char * | interface_name, | |
int * | span, | |||
int * | chan | |||
) |
Convert Span & Chan to interface name.
interface_name | pointer to string where interface name will be written | |
span | span number starting from 1 to 255 | |
chan | chan number starting from 1 to 32 |
Definition at line 666 of file libsangoma.c.
References FNAME_LEN.
Referenced by sangoma_create_socket_by_name().
00667 { 00668 char *p=NULL, *sp = NULL, *ch = NULL; 00669 int ret = 0; 00670 char data[FNAME_LEN]; 00671 00672 strncpy(data, interface_name, FNAME_LEN); 00673 if ((data[0])) { 00674 for (p = data; *p; p++) { 00675 if (sp && *p == 'g') { 00676 *p = '\0'; 00677 ch = (p + 1); 00678 break; 00679 } else if (*p == 'w') { 00680 sp = (p + 1); 00681 } 00682 } 00683 00684 if(ch && sp) { 00685 *span = atoi(sp); 00686 *chan = atoi(ch); 00687 ret = 1; 00688 } else { 00689 *span = -1; 00690 *chan = -1; 00691 } 00692 } 00693 00694 return ret; 00695 }
Here is the caller graph for this function:
int sangoma_span_chan_fromif | ( | char * | interface_name, | |
int * | span, | |||
int * | chan | |||
) |
Convert Interace Name to Span & Chan.
interface_name | pointer to string containing interface name | |
span | integer pointer where to write span value | |
chan | integer pointer where to write chan value |
Definition at line 697 of file libsangoma.c.
References FNAME_LEN.
00698 { 00699 char *p = NULL, *sp = NULL, *ch = NULL; 00700 int ret = 0; 00701 char data[FNAME_LEN]; 00702 00703 strncpy(data, interface_name, FNAME_LEN); 00704 if ((data[0])) { 00705 for (p = data; *p; p++) { 00706 if (sp && *p == 'c') { 00707 *p = '\0'; 00708 ch = (p + 1); 00709 break; 00710 } else if (*p == 's') { 00711 sp = (p + 1); 00712 } 00713 } 00714 00715 if(ch && sp) { 00716 *span = atoi(sp); 00717 *chan = atoi(ch); 00718 ret = 1; 00719 } else { 00720 *span = -1; 00721 *chan = -1; 00722 } 00723 } 00724 00725 return ret; 00726 }
sng_fd_t sangoma_open_api_span_chan | ( | int | span, | |
int | chan | |||
) |
Open a Device based on Span/Chan values.
span | span number starting from 1 to 255 | |
chan | chan number starting from 1 to 32 |
Definition at line 728 of file libsangoma.c.
References __sangoma_open_api_span_chan(), INVALID_HANDLE_VALUE, sangoma_close(), sangoma_cmd_exec(), tdm_api, and WP_API_CMD_OPEN_CNT.
Referenced by open_sangoma_devices(), sangoma_create_socket_by_name(), and sangoma_open_api_span().
00729 { 00730 sng_fd_t fd = INVALID_HANDLE_VALUE; 00731 wanpipe_api_t tdm_api; 00732 int err; 00733 00734 fd = __sangoma_open_api_span_chan(span, chan); 00735 00736 #if defined(__WINDOWS__) 00737 if(fd == INVALID_HANDLE_VALUE){ 00738 //DBG_EVNT("Span: %d, chan: %d: is not running, consider 'busy'\n", span, chan); 00739 return fd; 00740 } 00741 #else 00742 if (fd < 0) { 00743 return fd; 00744 } 00745 #endif 00746 00747 memset(&tdm_api,0,sizeof(tdm_api)); 00748 tdm_api.wp_cmd.cmd = WP_API_CMD_OPEN_CNT; 00749 err=sangoma_cmd_exec(fd,&tdm_api); 00750 if (err){ 00751 sangoma_close(&fd); 00752 return err; 00753 } 00754 00755 if (tdm_api.wp_cmd.open_cnt > 1) { 00756 sangoma_close(&fd); 00757 } 00758 00759 return fd; 00760 }
Here is the call graph for this function:
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.
span | span number starting from 1 to 255 | |
chan | chan number starting from 1 to 32 |
Definition at line 763 of file libsangoma.c.
References _snprintf, DEV_NAME_LEN, FNAME_LEN, HANDLE, and WP_INTERFACE_NAME_FORM.
Referenced by sangoma_open_api_span_chan().
00764 { 00765 char fname[FNAME_LEN], tmp_fname[FNAME_LEN]; 00766 00767 /* Form the Interface Name from span and chan number (i.e. wanpipe1_if1). */ 00768 _snprintf(tmp_fname, DEV_NAME_LEN, WP_INTERFACE_NAME_FORM, span, chan); 00769 00770 #if defined(WIN32) 00771 _snprintf(fname , FNAME_LEN, "\\\\.\\%s", tmp_fname); 00772 return CreateFile( fname, 00773 GENERIC_READ | GENERIC_WRITE, 00774 FILE_SHARE_READ | FILE_SHARE_WRITE, 00775 (LPSECURITY_ATTRIBUTES)NULL, 00776 OPEN_EXISTING, 00777 FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH | FILE_FLAG_OVERLAPPED, 00778 (HANDLE)NULL 00779 ); 00780 #else 00781 //sprintf(fname,"/dev/wanpipe%d_if%d",span,chan); 00782 sprintf(fname,"/dev/%s", tmp_fname); 00783 00784 return open(fname, O_RDWR); 00785 #endif 00786 }
Here is the caller graph for this function:
sng_fd_t sangoma_open_api_ctrl | ( | void | ) |
Open a Global Control Device.
Definition at line 788 of file libsangoma.c.
References INVALID_HANDLE_VALUE.
00789 { 00790 #if defined(WIN32) 00791 sng_fd_t fd = INVALID_HANDLE_VALUE; 00792 00793 #pragma message("sangoma_open_api_ctrl: Not support on Windows") 00794 #else 00795 sng_fd_t fd=-1; 00796 00797 fd = open("/dev/wanpipe_ctrl", O_RDWR); 00798 #endif 00799 00800 return fd; 00801 }
sng_fd_t sangoma_create_socket_by_name | ( | char * | device, | |
char * | card | |||
) |
Open a device based on a interface and card name.
device | interface name | |
card | card name |
Definition at line 803 of file libsangoma.c.
References sangoma_interface_toi(), and sangoma_open_api_span_chan().
00804 { 00805 int span,chan; 00806 sangoma_interface_toi(device,&span,&chan); 00807 00808 return sangoma_open_api_span_chan(span,chan); 00809 }
Here is the call 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.
fd | device file descriptor | |
hdrbuf | pointer to header structure wp_api_hdr_t | |
hdrlen | size of wp_api_hdr_t | |
databuf | pointer to data buffer to be received | |
datalen | length of data buffer | |
flag | currently not used, set to 0 |
Definition at line 836 of file libsangoma.c.
References wp_api_element::data, DBG_EVNT, wp_api_element::hdr, SANG_STATUS_BUFFER_TOO_SMALL, SANG_STATUS_RX_DATA_AVAILABLE, and SDLA_DECODE_SANG_STATUS.
Referenced by read_data().
00837 { 00838 int rx_len=0; 00839 00840 #if defined(WIN32) 00841 wp_api_hdr_t *rx_hdr = (wp_api_hdr_t*)hdrbuf; 00842 wp_api_element_t wp_api_element; 00843 00844 if(hdrlen != sizeof(wp_api_hdr_t)){ 00845 //error 00846 DBG_EVNT("Error: %s(): invalid size of user's 'header buffer'. Should be 'sizeof(wp_api_hdr_t)'.\n", __FUNCTION__); 00847 return -1; 00848 } 00849 00850 if(DoReadCommand(fd, &wp_api_element)){ 00851 //error 00852 DBG_EVNT("Error: %s(): DoReadCommand() failed! Check messages log.\n", __FUNCTION__); 00853 return -4; 00854 } 00855 00856 memcpy(rx_hdr, &wp_api_element.hdr, sizeof(wp_api_hdr_t)); 00857 00858 switch(rx_hdr->operation_status) 00859 { 00860 case SANG_STATUS_RX_DATA_AVAILABLE: 00861 /* ok */ 00862 if(rx_hdr->data_length <= datalen){ 00863 memcpy(databuf, wp_api_element.data, rx_hdr->data_length); 00864 }else{ 00865 rx_hdr->operation_status = SANG_STATUS_BUFFER_TOO_SMALL; 00866 } 00867 break; 00868 default: 00869 /* note that SANG_STATUS_DEVICE_BUSY is NOT an error! */ 00870 if(0)DBG_EVNT("Error: %s(): Operation Status: %s(%d)\n", __FUNCTION__, 00871 SDLA_DECODE_SANG_STATUS(rx_hdr->operation_status), rx_hdr->operation_status); 00872 return -5; 00873 } 00874 00875 rx_len = rx_hdr->data_length; 00876 #else 00877 struct msghdr msg; 00878 struct iovec iov[2]; 00879 00880 memset(&msg,0,sizeof(struct msghdr)); 00881 00882 iov[0].iov_len=hdrlen; 00883 iov[0].iov_base=hdrbuf; 00884 00885 iov[1].iov_len=datalen; 00886 iov[1].iov_base=databuf; 00887 00888 msg.msg_iovlen=2; 00889 msg.msg_iov=iov; 00890 00891 rx_len = read(fd,&msg,datalen+hdrlen); 00892 00893 if (rx_len <= sizeof(wp_api_hdr_t)){ 00894 return -EINVAL; 00895 } 00896 00897 rx_len-=sizeof(wp_api_hdr_t); 00898 #endif 00899 return rx_len; 00900 }
Here is the caller graph for this function:
int sangoma_writemsg | ( | sng_fd_t | fd, | |
void * | hdrbuf, | |||
int | hdrlen, | |||
void * | databuf, | |||
unsigned short | datalen, | |||
int | flag | |||
) |
Write Data to device.
fd | device file descriptor | |
hdrbuf | pointer to header structure wp_api_hdr_t | |
hdrlen | size of wp_api_hdr_t | |
databuf | pointer to data buffer to be transmitted | |
datalen | length of data buffer | |
flag | currently not used, set to 0 |
Definition at line 902 of file libsangoma.c.
References DBG_ERR, DBG_EVNT, SANG_STATUS_DEVICE_BUSY, SANG_STATUS_IO_ERROR, SANG_STATUS_SUCCESS, SANG_STATUS_TX_HDR_TOO_SHORT, and SDLA_DECODE_SANG_STATUS.
Referenced by write_data().
00903 { 00904 int bsent=-1; 00905 wp_api_hdr_t *wp_api_hdr = hdrbuf; 00906 00907 if (hdrlen != sizeof(wp_api_hdr_t)) { 00908 DBG_ERR("Error: sangoma_writemsg() failed! hdrlen (%i) != sizeof(wp_api_hdr_t) (%i)\n", 00909 hdrlen,sizeof(wp_api_hdr_t)); 00910 wp_api_hdr->operation_status = SANG_STATUS_TX_HDR_TOO_SHORT; 00911 return -1; 00912 } 00913 00914 #if defined(WIN32) 00915 00916 00917 //queue data for transmission 00918 if(DoWriteCommand(fd, databuf, datalen, hdrbuf, hdrlen)){ 00919 //error 00920 DBG_EVNT("Error: DoWriteCommand() failed!! Check messages log.\n"); 00921 return -1; 00922 } 00923 00924 bsent=0; 00925 //check that frame was transmitted 00926 switch(wp_api_hdr->operation_status) 00927 { 00928 case SANG_STATUS_SUCCESS: 00929 bsent = datalen; 00930 break; 00931 default: 00932 DBG_EVNT("Error: %s(): Operation Status: %s(%d)\n", __FUNCTION__, 00933 SDLA_DECODE_SANG_STATUS(wp_api_hdr->operation_status), wp_api_hdr->operation_status); 00934 break; 00935 }//switch() 00936 #else 00937 struct msghdr msg; 00938 struct iovec iov[2]; 00939 wp_api_hdr_t *tx_el=hdrbuf; 00940 00941 memset(&msg,0,sizeof(struct msghdr)); 00942 00943 iov[0].iov_len=hdrlen; 00944 iov[0].iov_base=hdrbuf; 00945 00946 iov[1].iov_len=datalen; 00947 iov[1].iov_base=databuf; 00948 00949 msg.msg_iovlen=2; 00950 msg.msg_iov=iov; 00951 00952 bsent = write(fd,&msg,datalen+hdrlen); 00953 00954 if (bsent == (datalen+hdrlen)){ 00955 tx_el->wp_api_hdr_operation_status=SANG_STATUS_SUCCESS; 00956 bsent-=sizeof(wp_api_hdr_t); 00957 } else if (errno == EBUSY){ 00958 tx_el->wp_api_hdr_operation_status=SANG_STATUS_DEVICE_BUSY; 00959 } else { 00960 tx_el->wp_api_hdr_operation_status=SANG_STATUS_IO_ERROR; 00961 } 00962 tx_el->wp_api_hdr_data_length=bsent; 00963 #endif 00964 return bsent; 00965 }
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.
fd | device file descriptor | |
tdm_api | tdm api command structure |
Definition at line 974 of file libsangoma.c.
References wanpipe_api_cmd::cmd, tdm_api, and wanpipe_api::wp_cmd.
Referenced by sangoma_flush_bufs(), sangoma_get_full_cfg(), sangoma_get_hw_coding(), sangoma_open_api_span_chan(), sangoma_read_event(), sangoma_tdm_disable_hwec(), sangoma_tdm_disable_rbs_events(), sangoma_tdm_enable_hwec(), sangoma_tdm_enable_rbs_events(), sangoma_tdm_get_codec(), sangoma_tdm_get_power_level(), sangoma_tdm_get_usr_mtu_mru(), sangoma_tdm_get_usr_period(), sangoma_tdm_set_codec(), sangoma_tdm_set_power_level(), sangoma_tdm_set_usr_period(), and sangoma_tdm_write_rbs().
00975 { 00976 int err; 00977 00978 #if defined(WIN32) 00979 err = tdmv_api_ioctl(fd, &tdm_api->wp_cmd); 00980 #else 00981 err = ioctl(fd,SIOC_WANPIPE_TDM_API,&tdm_api->wp_cmd); 00982 if (err < 0){ 00983 char tmp[50]; 00984 sprintf(tmp,"TDM API: CMD: %i\n",tdm_api->wp_cmd.cmd); 00985 perror(tmp); 00986 return -1; 00987 } 00988 #endif 00989 return err; 00990 }
Here is the caller graph for this function:
int sangoma_get_full_cfg | ( | sng_fd_t | fd, | |
wanpipe_api_t * | tdm_api | |||
) |
Read tdm api device configuration.
fd | device file descriptor | |
tdm_api | tdm api command structure |
Definition at line 996 of file libsangoma.c.
References wanpipe_api_cmd::cmd, wanpipe_api_cmd::fe_alarms, wanpipe_api_cmd::hw_mtu_mru, wanpipe_api_cmd::hw_tdm_coding, wanpipe_api_cmd::idle_flag, wanpipe_api_cmd::power_level, wanpipe_api_cmd::rx_disable, wanpipe_chan_stats::rx_errors, wanpipe_chan_stats::rx_fifo_errors, wanpipe_chan_stats::rx_packets, sangoma_cmd_exec(), wanpipe_api_cmd::stats, tdm_api, wanpipe_api_cmd::tdm_codec, wanpipe_chan_stats::tx_carrier_errors, wanpipe_api_cmd::tx_disable, wanpipe_chan_stats::tx_errors, wanpipe_chan_stats::tx_packets, wanpipe_api_cmd::usr_mtu_mru, wanpipe_api_cmd::usr_period, WP_API_CMD_GET_FULL_CFG, and wanpipe_api::wp_cmd.
Referenced by open_sangoma_devices().
00997 { 00998 int err; 00999 01000 tdm_api->wp_cmd.cmd = WP_API_CMD_GET_FULL_CFG; 01001 01002 err=sangoma_cmd_exec(fd,tdm_api); 01003 if (err){ 01004 return err; 01005 } 01006 01007 #if 1 01008 printf("TDM API CFG:\n"); 01009 printf("\thw_tdm_coding:\t%d\n",tdm_api->wp_cmd.hw_tdm_coding); 01010 printf("\thw_mtu_mru:\t%d\n",tdm_api->wp_cmd.hw_mtu_mru); 01011 printf("\tusr_period:\t%d\n",tdm_api->wp_cmd.usr_period); 01012 printf("\ttdm_codec:\t%d\n",tdm_api->wp_cmd.tdm_codec); 01013 printf("\tpower_level:\t%d\n",tdm_api->wp_cmd.power_level); 01014 printf("\trx_disable:\t%d\n",tdm_api->wp_cmd.rx_disable); 01015 printf("\ttx_disable:\t%d\n",tdm_api->wp_cmd.tx_disable); 01016 printf("\tusr_mtu_mru:\t%d\n",tdm_api->wp_cmd.usr_mtu_mru); 01017 printf("\tidle flag:\t0x%02X\n",tdm_api->wp_cmd.idle_flag); 01018 01019 #ifdef WP_API_FEATURE_FE_ALARM 01020 printf("\tfe alarms:\t0x%02X\n",tdm_api->wp_cmd.fe_alarms); 01021 #endif 01022 01023 printf("\trx pkt\t%d\ttx pkt\t%d\n",tdm_api->wp_cmd.stats.rx_packets, 01024 tdm_api->wp_cmd.stats.tx_packets); 01025 printf("\trx err\t%d\ttx err\t%d\n", 01026 tdm_api->wp_cmd.stats.rx_errors, 01027 tdm_api->wp_cmd.stats.tx_errors); 01028 #ifndef __WINDOWS__ 01029 printf("\trx ovr\t%d\ttx idl\t%d\n", 01030 tdm_api->wp_cmd.stats.rx_fifo_errors, 01031 tdm_api->wp_cmd.stats.tx_carrier_errors); 01032 #endif 01033 #endif 01034 01035 return 0; 01036 }
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.
fd | device file descriptor | |
tdm_api | tdm api command structure | |
codec | codec to set (ulaw/alaw/slinear) |
Definition at line 1050 of file libsangoma.c.
References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), tdm_api, wanpipe_api_cmd::tdm_codec, WP_API_CMD_SET_CODEC, and wanpipe_api::wp_cmd.
Referenced by open_sangoma_devices().
01051 { 01052 int err; 01053 01054 tdm_api->wp_cmd.cmd = WP_API_CMD_SET_CODEC; 01055 tdm_api->wp_cmd.tdm_codec = codec; 01056 01057 err=sangoma_cmd_exec(fd,tdm_api); 01058 01059 return err; 01060 }
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.
fd | device file descriptor | |
tdm_api | tdm api command structure |
Definition at line 1074 of file libsangoma.c.
References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), tdm_api, wanpipe_api_cmd::tdm_codec, WP_API_CMD_GET_CODEC, and wanpipe_api::wp_cmd.
01075 { 01076 int err; 01077 01078 tdm_api->wp_cmd.cmd = WP_API_CMD_GET_CODEC; 01079 01080 err=sangoma_cmd_exec(fd,tdm_api); 01081 if (err){ 01082 return err; 01083 } 01084 01085 return tdm_api->wp_cmd.tdm_codec; 01086 }
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.
fd | device file descriptor | |
tdm_api | tdm api command structure | |
period | value in miliseconds (1,2,5,10) |
Definition at line 1095 of file libsangoma.c.
References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), tdm_api, wanpipe_api_cmd::usr_period, WP_API_CMD_SET_USR_PERIOD, and wanpipe_api::wp_cmd.
Referenced by open_sangoma_devices().
01096 { 01097 int err; 01098 01099 tdm_api->wp_cmd.cmd = WP_API_CMD_SET_USR_PERIOD; 01100 tdm_api->wp_cmd.usr_period = period; 01101 01102 err=sangoma_cmd_exec(fd,tdm_api); 01103 01104 return err; 01105 }
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.
fd | device file descriptor | |
tdm_api | tdm api command structure |
Definition at line 1114 of file libsangoma.c.
References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), tdm_api, wanpipe_api_cmd::usr_period, WP_API_CMD_GET_USR_PERIOD, and wanpipe_api::wp_cmd.
01115 { 01116 int err; 01117 01118 tdm_api->wp_cmd.cmd = WP_API_CMD_GET_USR_PERIOD; 01119 01120 err=sangoma_cmd_exec(fd,tdm_api); 01121 if (err){ 01122 return err; 01123 } 01124 01125 return tdm_api->wp_cmd.usr_period; 01126 }
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).
fd | device file descriptor | |
tdm_api | tdm api command structure |
Definition at line 1134 of file libsangoma.c.
References wanpipe_api_cmd::cmd, wanpipe_api_cmd::hw_tdm_coding, sangoma_cmd_exec(), tdm_api, WP_API_CMD_GET_HW_CODING, and wanpipe_api::wp_cmd.
01135 { 01136 int err; 01137 tdm_api->wp_cmd.cmd = WP_API_CMD_GET_HW_CODING; 01138 err=sangoma_cmd_exec(fd,tdm_api); 01139 if (err){ 01140 return err; 01141 } 01142 return tdm_api->wp_cmd.hw_tdm_coding; 01143 }
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.
fd | device file descriptor | |
tdm_api | tdm api command structure |
Definition at line 1170 of file libsangoma.c.
References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), tdm_api, wanpipe_api_cmd::usr_mtu_mru, WP_API_CMD_GET_USR_MTU_MRU, and wanpipe_api::wp_cmd.
01171 { 01172 int err; 01173 01174 tdm_api->wp_cmd.cmd = WP_API_CMD_GET_USR_MTU_MRU; 01175 01176 err=sangoma_cmd_exec(fd,tdm_api); 01177 if (err){ 01178 return err; 01179 } 01180 01181 return tdm_api->wp_cmd.usr_mtu_mru; 01182 }
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.
fd | device file descriptor | |
tdm_api | tdm api command structure | |
power | value of power |
Definition at line 1190 of file libsangoma.c.
References wanpipe_api_cmd::cmd, wanpipe_api_cmd::power_level, sangoma_cmd_exec(), tdm_api, WP_API_CMD_SET_POWER_LEVEL, and wanpipe_api::wp_cmd.
01191 { 01192 int err; 01193 01194 tdm_api->wp_cmd.cmd = WP_API_CMD_SET_POWER_LEVEL; 01195 tdm_api->wp_cmd.power_level = power; 01196 01197 err=sangoma_cmd_exec(fd,tdm_api); 01198 01199 return err; 01200 }
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.
fd | device file descriptor | |
tdm_api | tdm api command structure |
Definition at line 1208 of file libsangoma.c.
References wanpipe_api_cmd::cmd, wanpipe_api_cmd::power_level, sangoma_cmd_exec(), tdm_api, WP_API_CMD_GET_POWER_LEVEL, and wanpipe_api::wp_cmd.
01209 { 01210 int err; 01211 01212 tdm_api->wp_cmd.cmd = WP_API_CMD_GET_POWER_LEVEL; 01213 01214 err=sangoma_cmd_exec(fd,tdm_api); 01215 if (err){ 01216 return err; 01217 } 01218 01219 return tdm_api->wp_cmd.power_level; 01220 }
Here is the call graph for this function:
int sangoma_flush_bufs | ( | sng_fd_t | fd, | |
wanpipe_api_t * | tdm_api | |||
) |
Flush buffers from current channel.
fd | device file descriptor | |
tdm_api | tdm api command structure |
Definition at line 1222 of file libsangoma.c.
References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), tdm_api, WP_API_CMD_FLUSH_BUFFERS, and wanpipe_api::wp_cmd.
01223 { 01224 int err; 01225 tdm_api->wp_cmd.cmd = WP_API_CMD_FLUSH_BUFFERS; 01226 01227 err=sangoma_cmd_exec(fd,tdm_api); 01228 if (err){ 01229 return err; 01230 } 01231 01232 return 0; 01233 }
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.
fd | device file descriptor | |
tdm_api | tdm api command structure | |
poll_in_sec | driver poll period for rbs events |
Definition at line 1235 of file libsangoma.c.
References wanpipe_api_cmd::cmd, wanpipe_api_cmd::rbs_poll, sangoma_cmd_exec(), tdm_api, WP_API_CMD_ENABLE_RBS_EVENTS, and wanpipe_api::wp_cmd.
Referenced by open_sangoma_devices().
01235 { 01236 01237 int err; 01238 01239 tdm_api->wp_cmd.cmd = WP_API_CMD_ENABLE_RBS_EVENTS; 01240 tdm_api->wp_cmd.rbs_poll=poll_in_sec; 01241 01242 err=sangoma_cmd_exec(fd,tdm_api); 01243 if (err){ 01244 return err; 01245 } 01246 01247 return tdm_api->wp_cmd.rbs_poll; 01248 }
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.
fd | device file descriptor | |
tdm_api | tdm api command structure |
Definition at line 1251 of file libsangoma.c.
References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), tdm_api, WP_API_CMD_DISABLE_RBS_EVENTS, and wanpipe_api::wp_cmd.
Referenced by cleanup().
01251 { 01252 01253 int err; 01254 tdm_api->wp_cmd.cmd = WP_API_CMD_DISABLE_RBS_EVENTS; 01255 01256 err=sangoma_cmd_exec(fd,tdm_api); 01257 if (err){ 01258 return err; 01259 } 01260 01261 return 0; 01262 }
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, | |||
unsigned char | rbs | |||
) |
Write RBS Bits on a device.
fd | device file descriptor | |
tdm_api | tdm api command structure | |
rbs | rbs bits (ABCD) |
Definition at line 1264 of file libsangoma.c.
References wanpipe_api_cmd::cmd, wanpipe_api_cmd::rbs_tx_bits, sangoma_cmd_exec(), tdm_api, WP_API_CMD_WRITE_RBS_BITS, and wanpipe_api::wp_cmd.
Referenced by read_data().
01265 { 01266 01267 int err; 01268 tdm_api->wp_cmd.cmd = WP_API_CMD_WRITE_RBS_BITS; 01269 tdm_api->wp_cmd.rbs_tx_bits=rbs; 01270 01271 err=sangoma_cmd_exec(fd,tdm_api); 01272 if (err){ 01273 return err; 01274 } 01275 01276 return 0; 01277 }
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.
fd | device file descriptor | |
tdm_api | tdm api command structure |
Definition at line 1279 of file libsangoma.c.
References wanpipe_api_cmd::cmd, wanpipe_api_cmd::event, sangoma_cmd_exec(), tdm_api, wanpipe_api::wp_callback, wanpipe_api::wp_cmd, wanpipe_api_callbacks::wp_dtmf_event, wanpipe_api_callbacks::wp_fe_alarm_event, wanpipe_api_callbacks::wp_link_status_event, wanpipe_api_callbacks::wp_rbs_event, wanpipe_api_callbacks::wp_ring_detect_event, wanpipe_api_callbacks::wp_ring_trip_detect_event, and wanpipe_api_callbacks::wp_rxhook_event.
Referenced by handle_tdm_event().
01280 { 01281 01282 #ifdef WP_API_FEATURE_EVENTS 01283 wp_api_event_t *rx_event; 01284 int err; 01285 01286 tdm_api->wp_cmd.cmd = WP_API_CMD_READ_EVENT; 01287 01288 err=sangoma_cmd_exec(fd,tdm_api); 01289 if (err){ 01290 return err; 01291 } 01292 01293 rx_event = &tdm_api->wp_cmd.event; 01294 01295 01296 /* 01297 The use of callbacks here is purely optional and is left 01298 here for backward compatibility purposes. By default user 01299 should handle events outside this funciton. This function 01300 should only be used to read the event 01301 */ 01302 01303 switch (rx_event->wp_api_event_type){ 01304 01305 case WP_API_EVENT_RBS: 01306 if (tdm_api->wp_callback.wp_rbs_event) { 01307 tdm_api->wp_callback.wp_rbs_event(fd,rx_event->wp_api_event_rbs_bits); 01308 } 01309 01310 break; 01311 01312 #ifdef WP_API_FEATURE_DTMF_EVENTS 01313 case WP_API_EVENT_DTMF: 01314 if (tdm_api->wp_callback.wp_dtmf_event) { 01315 tdm_api->wp_callback.wp_dtmf_event(fd, 01316 rx_event->wp_api_event_dtmf_digit, 01317 rx_event->wp_api_event_dtmf_type, 01318 rx_event->wp_api_event_dtmf_port); 01319 } 01320 break; 01321 #endif 01322 01323 case WP_API_EVENT_RXHOOK: 01324 if (tdm_api->wp_callback.wp_rxhook_event) { 01325 tdm_api->wp_callback.wp_rxhook_event(fd, 01326 rx_event->wp_api_event_hook_state); 01327 } 01328 break; 01329 01330 case WP_API_EVENT_RING_DETECT: 01331 if (tdm_api->wp_callback.wp_ring_detect_event) { 01332 tdm_api->wp_callback.wp_ring_detect_event(fd, 01333 rx_event->wp_api_event_ring_state); 01334 } 01335 break; 01336 01337 case WP_API_EVENT_RING_TRIP_DETECT: 01338 if (tdm_api->wp_callback.wp_ring_trip_detect_event) { 01339 tdm_api->wp_callback.wp_ring_trip_detect_event(fd, 01340 rx_event->wp_api_event_ring_state); 01341 } 01342 break; 01343 01344 #ifdef WP_API_FEATURE_FE_ALARM 01345 case WP_API_EVENT_ALARM: 01346 if (tdm_api->wp_callback.wp_fe_alarm_event) { 01347 tdm_api->wp_callback.wp_fe_alarm_event(fd, 01348 rx_event->wp_api_event_alarm); 01349 } 01350 break; 01351 #endif 01352 01353 #ifdef WP_API_FEATURE_LINK_STATUS 01354 /* Link Status */ 01355 case WP_API_EVENT_LINK_STATUS: 01356 if(tdm_api->wp_callback.wp_link_status_event){ 01357 tdm_api->wp_callback.wp_link_status_event(fd, 01358 rx_event->wp_api_event_link_status); 01359 } 01360 01361 break; 01362 #endif 01363 default: 01364 printf("%d: Unknown TDM event!", (int)fd); 01365 break; 01366 } 01367 01368 return 0; 01369 #else 01370 printf("Error: Read Event not supported!\n"); 01371 return -1; 01372 #endif 01373 }
Here is the call graph for this function:
Here is the caller graph for this function:
int sangoma_tdm_enable_hwec | ( | sng_fd_t | fd, | |
wanpipe_api_t * | tdm_api | |||
) |
Enable HWEC on this channel.
fd | device file descriptor | |
tdm_api | tdm api command structure |
Definition at line 1656 of file libsangoma.c.
References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), tdm_api, and wanpipe_api::wp_cmd.
01657 { 01658 int err; 01659 01660 tdm_api->wp_cmd.cmd = WP_API_CMD_ENABLE_HWEC; 01661 err=sangoma_cmd_exec(fd,tdm_api); 01662 if (err){ 01663 return err; 01664 } 01665 01666 return 0; 01667 }
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.
fd | device file descriptor | |
tdm_api | tdm api command structure |
Definition at line 1669 of file libsangoma.c.
References wanpipe_api_cmd::cmd, sangoma_cmd_exec(), tdm_api, and wanpipe_api::wp_cmd.
01670 { 01671 int err; 01672 01673 tdm_api->wp_cmd.cmd = WP_API_CMD_DISABLE_HWEC; 01674 err=sangoma_cmd_exec(fd,tdm_api); 01675 if (err){ 01676 return err; 01677 } 01678 01679 return 0; 01680 }
Here is the call graph for this function: