35 #include "libsangoma-pvt.h"
37 #if defined(__WINDOWS__)
38 # include <setupapi.h>
39 # include <initguid.h>
43 # define MAX_COMP_INSTID 2096
44 # define MAX_COMP_DESC 2096
45 # define MAX_FRIENDLY 2096
46 # define TMP_BUFFER_LEN 256
49 # define INVALID_INDEX (uint32_t) -1
50 # define WP_ALL_BITS_SET ((uint32_t)-1)
53 int libsng_dbg_level = 0;
59 #if defined(__WINDOWS__)
60 #define DBG_REGISTRY if(libsng_dbg_level)libsng_dbg
69 static void LibSangomaDecodeLastError(LPSTR lpszFunction)
72 DWORD dwLastErr = GetLastError();
74 FORMAT_MESSAGE_ALLOCATE_BUFFER |
75 FORMAT_MESSAGE_FROM_SYSTEM |
76 FORMAT_MESSAGE_IGNORE_INSERTS,
79 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
85 DBG_POLL(
"Last Error in %s(): %s (%d)\n", lpszFunction, (
char*)lpMsgBuf, dwLastErr);
87 LocalFree( lpMsgBuf );
97 static u16 handle_device_ioctl_result(
int bResult,
char *caller_name)
101 LibSangomaDecodeLastError(caller_name);
119 unsigned char id = 0;
121 wan_udp->wan_udphdr_request_reply = 0x01;
122 wan_udp->wan_udphdr_id = id;
123 wan_udp->wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
125 bIoResult = DeviceIoControl(
127 IoctlManagementCommand,
136 return handle_device_ioctl_result(bIoResult, __FUNCTION__);
147 static int tdmv_api_ioctl(
sng_fd_t fd, wanpipe_tdm_api_cmd_t *api_cmd)
151 bIoResult = DeviceIoControl(
155 sizeof(wanpipe_tdm_api_cmd_t),
157 sizeof(wanpipe_tdm_api_cmd_t),
162 return handle_device_ioctl_result(bIoResult, __FUNCTION__);
178 bIoResult = DeviceIoControl(
180 IoctlReadCommandNonBlocking,
183 (LPVOID)p_iovec_list,
188 return handle_device_ioctl_result(bIoResult, __FUNCTION__);
202 DWORD BytesReturned, bIoResult;
204 bIoResult = DeviceIoControl(
206 IoctlWriteCommandNonBlocking,
207 (LPVOID)p_iovec_list,
208 sizeof(*p_iovec_list),
209 (LPVOID)p_iovec_list,
210 sizeof(*p_iovec_list),
211 (LPDWORD)(&BytesReturned),
214 return (UCHAR)handle_device_ioctl_result(bIoResult, __FUNCTION__);
231 bIoResult = DeviceIoControl(
236 (LPVOID)api_poll_ptr,
241 return handle_device_ioctl_result(bIoResult, __FUNCTION__);
256 bIoResult = DeviceIoControl(
258 IoctlLoggerApiCommand,
260 sizeof(wp_logger_cmd_t),
262 sizeof(wp_logger_cmd_t),
264 (LPOVERLAPPED)NULL );
266 return handle_device_ioctl_result(bIoResult, __FUNCTION__);
274 bIoResult = DeviceIoControl(
276 IoctlCdevControlCommand,
278 sizeof(wanpipe_tdm_api_cmd_t),
280 sizeof(wanpipe_tdm_api_cmd_t),
285 return handle_device_ioctl_result(bIoResult, __FUNCTION__);
290 wanpipe_tdm_api_cmd_t tdm_api_cmd;
292 char event_name[200];
294 memset(&tdm_api_cmd, 0x00,
sizeof(tdm_api_cmd));
296 tdm_api_cmd.cmd = WP_CDEV_CMD_GET_INTERFACE_NAME;
297 sng_status = sangoma_cdev_ctrl_cmd(fd, &tdm_api_cmd);
298 if(SANG_ERROR(sng_status)){
299 DBG_ERR(
"sangoma_cdev_ctrl_cmd() failed!\n");
303 DBG_EVNT(
"%s(): interface name: %s\n", __FUNCTION__, tdm_api_cmd.data);
313 _snprintf(event_name,
sizeof(event_name),
"Global\\%s_signal", tdm_api_cmd.data);
315 sng_wait_obj->signal_object = OpenEvent(EVENT_ALL_ACCESS,
TRUE, event_name);
316 if(NULL == sng_wait_obj->signal_object){
318 LibSangomaDecodeLastError(__FUNCTION__);
325 static sangoma_status_t sangoma_wait_obj_poll(sangoma_wait_obj_t *sangoma_wait_object,
int flags_in, uint32_t *flags_out)
328 sangoma_wait_obj_t *sng_wait_obj = sangoma_wait_object;
334 memset(&api_poll, 0x00,
sizeof(api_poll));
338 if(sangoma_poll_fd(sng_wait_obj->fd, &api_poll)){
357 static int sangoma_check_number_of_wait_objects(uint32_t number_of_objects)
359 if(number_of_objects > MAXIMUM_WAIT_OBJECTS){
360 DBG_ERR(
"'number_of_objects': %d is greater than the Maximum of: %d\n",
361 number_of_objects, MAXIMUM_WAIT_OBJECTS);
365 if(number_of_objects < 1){
366 DBG_ERR(
"'number_of_objects': %d is less than the Minimum of: 1\n",
374 static sangoma_status_t get_out_flags(IN sangoma_wait_obj_t *sng_wait_objects[],
375 IN uint32_t first_signaled_obj_index,
376 IN uint32_t in_flags[], OUT uint32_t out_flags[],
377 IN uint32_t number_of_sangoma_wait_objects,
378 OUT BOOL *at_least_one_poll_set_flags_out)
382 if(at_least_one_poll_set_flags_out){
383 *at_least_one_poll_set_flags_out =
FALSE;
386 for(i = 0; i < number_of_sangoma_wait_objects; i++) {
388 sangoma_wait_obj_t *sangoma_wait_object = sng_wait_objects[i];
390 if (!sangoma_wait_object->signal_object) {
394 if (!SANGOMA_OBJ_HAS_DEVICE(sangoma_wait_object)) {
399 if((i == first_signaled_obj_index) ||
404 (WaitForSingleObject(sangoma_wait_object->signal_object, 0) == WAIT_OBJECT_0)) {
405 out_flags[i] |= SANG_WAIT_OBJ_IS_SIGNALED;
410 if(sangoma_wait_obj_poll(sangoma_wait_object, in_flags[i], &out_flags[i])){
414 if (out_flags[i] & in_flags[i]) {
415 if (at_least_one_poll_set_flags_out) {
416 *at_least_one_poll_set_flags_out =
TRUE;
428 static LONG registry_get_string_value(HKEY hkey, LPTSTR szKeyname, OUT LPSTR szValue, OUT
DWORD *pdwSize)
433 RegQueryValueEx(hkey, szKeyname, NULL, NULL, (
unsigned char *)szValue, pdwSize);
435 iReturnCode = RegQueryValueEx(hkey, szKeyname, NULL, NULL, (
unsigned char *)szValue, pdwSize);
436 if(ERROR_SUCCESS == iReturnCode){
439 DBG_REGISTRY(
"%s(): %s: %s: iReturnCode: %d\n", __FUNCTION__, szKeyname, szValue, iReturnCode);
446 LONG registry_set_string_value(HKEY hkey, LPTSTR szKeyname, IN LPSTR szValue)
451 dwSize = (
DWORD)strlen(szValue) + 1;
453 iReturnCode = RegSetValueEx(hkey, szKeyname, 0, REG_SZ, (
unsigned char *)szValue, dwSize);
454 DBG_REGISTRY(
"%s(): %s: %s\n", __FUNCTION__, szKeyname, szValue);
456 if(ERROR_SUCCESS == iReturnCode){
465 LONG registry_set_integer_value(HKEY hkey, LPTSTR szKeyname, IN
int iValue)
468 char szTemp[TMP_BUFFER_LEN];
471 sprintf(szTemp,
"%u", iValue);
473 dwSize = (
DWORD)strlen(szTemp) + 1;
474 iReturnCode = RegSetValueEx(hkey, szKeyname, 0, REG_SZ, (
unsigned char *)szTemp, dwSize);
476 if(ERROR_SUCCESS == iReturnCode){
480 DBG_REGISTRY(
"%s(): %s: %d: iReturnCode: %d\n", __FUNCTION__, szKeyname, iValue, iReturnCode);
488 HKEY registry_open_port_key(hardware_info_t *hardware_info)
490 int i, iRegistryReturnCode;
491 SP_DEVINFO_DATA deid={
sizeof(SP_DEVINFO_DATA)};
492 HDEVINFO hdi = SetupDiGetClassDevs((
struct _GUID *)&GUID_DEVCLASS_SANGOMA_ADAPTER, NULL,NULL, DIGCF_PRESENT);
493 char DeviceName[TMP_BUFFER_LEN], PCI_Bus[TMP_BUFFER_LEN], PCI_Slot[TMP_BUFFER_LEN], Port_Number[TMP_BUFFER_LEN];
498 char szCompInstanceId[MAX_COMP_INSTID];
499 TCHAR szCompDescription[MAX_COMP_DESC];
512 const TCHAR *search_SubStr =
"Sangoma Hardware Abstraction Driver";
515 for (i = 0; SetupDiEnumDeviceInfo(hdi, i, &deid); i++){
517 BOOL fSuccess = SetupDiGetDeviceInstanceId(hdi, &deid, (PSTR)szCompInstanceId, MAX_COMP_INSTID, NULL);
522 fSuccess = SetupDiGetDeviceRegistryProperty(hdi, &deid, SPDRP_DEVICEDESC, &dwRegType, (BYTE*)szCompDescription, MAX_COMP_DESC, NULL);
527 if (!strstr(szCompDescription, search_SubStr)) {
532 DBG_REGISTRY(
"* %s\n", szCompDescription);
534 hKeyTmp = SetupDiOpenDevRegKey(hdi, &deid, DICS_FLAG_GLOBAL, 0, DIREG_DRV, KEY_READ | KEY_SET_VALUE );
536 DBG_REGISTRY(
"Error: Failed to open Registry key!!\n");
541 iRegistryReturnCode = registry_get_string_value(hKeyTmp,
"PCI_Bus", PCI_Bus, &dwTemp);
542 if(iRegistryReturnCode){
547 iRegistryReturnCode = registry_get_string_value(hKeyTmp,
"PCI_Slot", PCI_Slot, &dwTemp);
548 if(iRegistryReturnCode){
552 Port_Number[0] =
'\0';
553 iRegistryReturnCode = registry_get_string_value(hKeyTmp,
"Port_Number", Port_Number, &dwTemp);
554 if(iRegistryReturnCode){
558 if( atoi(PCI_Bus) == hardware_info->pci_bus_number &&
559 atoi(PCI_Slot) == hardware_info->pci_slot_number &&
560 atoi(Port_Number) == hardware_info->port_number ){
562 hPortRegistryKey = hKeyTmp;
565 DeviceName[0] =
'\0';
566 registry_get_string_value(hPortRegistryKey,
"DeviceName", DeviceName, &dwTemp);
568 DBG_REGISTRY(
"Found Port's Registry key: DeviceName: %s, PCI_Bus: %s, PCI_Slot: %s, Port_Number: %s\n",
569 DeviceName, PCI_Bus, PCI_Slot, Port_Number);
574 SetupDiDestroyDeviceInfoList(hdi);
576 DBG_REGISTRY(
"hPortRegistryKey: 0x%X\n", hPortRegistryKey);
578 return hPortRegistryKey;
581 static char* timeslot_bitmap_to_string(
int bitmap)
583 int i = 0, range_counter = 0;
584 int start_channel = -1, stop_channel = -1;
585 static char tmp_string[256];
587 if( WP_ALL_BITS_SET == bitmap ){
591 tmp_string[0] =
'\0';
594 for(i = 0; i <
sizeof(bitmap) * 8; i++){
596 if(start_channel < 0){
598 if(bitmap & (1 << i)){
599 start_channel = i + 1;
603 if(start_channel >= 0){
604 if((bitmap & (1 << i)) == 0){
609 }
else if(i == (
sizeof(bitmap) * 8 - 1)){
614 stop_channel = (
sizeof(bitmap) * 8);
618 if(start_channel >= 0 && stop_channel >= 0){
622 _snprintf(&tmp_string[strlen(tmp_string)],
sizeof(tmp_string) - strlen(tmp_string),
".");
625 if(start_channel == stop_channel){
627 _snprintf(&tmp_string[strlen(tmp_string)],
sizeof(tmp_string) - strlen(tmp_string),
628 "%d", start_channel);
631 _snprintf(&tmp_string[strlen(tmp_string)],
sizeof(tmp_string) - strlen(tmp_string),
632 "%d-%d", start_channel, stop_channel);
635 start_channel = stop_channel = -1;
643 int registry_write_front_end_cfg(HKEY hPortRegistryKey, port_cfg_t *port_cfg)
645 wandev_conf_t *wandev_conf = &port_cfg->wandev_conf;
646 sdla_fe_cfg_t *sdla_fe_cfg = &wandev_conf->fe_cfg;
647 sdla_te_cfg_t *te_cfg = &sdla_fe_cfg->cfg.te_cfg;
648 sdla_remora_cfg_t *analog_cfg = &sdla_fe_cfg->cfg.remora;
649 sdla_bri_cfg_t *bri_cfg = &sdla_fe_cfg->cfg.bri;
655 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"tdmv_law", FE_TDMV_LAW(sdla_fe_cfg) );
660 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"ExternalSynchronization", FE_NETWORK_SYNC(sdla_fe_cfg) );
665 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"FE_TXTRISTATE", FE_TXTRISTATE(sdla_fe_cfg) );
670 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"HWEC_CLKSRC", wandev_conf->hwec_conf.clk_src );
677 switch(sdla_fe_cfg->media)
683 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"Media", sdla_fe_cfg->media );
688 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"LDecoding", sdla_fe_cfg->lcode );
693 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"Framing", sdla_fe_cfg->frame );
698 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"ClkRefPort", te_cfg->te_ref_clock);
703 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"TE_IGNORE_YEL", te_cfg->ignore_yel_alarm);
708 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"ACTIVE_CH", ENABLE_ALL_CHANNELS );
713 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"TE_RBS_CH", te_cfg->te_rbs_ch);
718 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"LBO", te_cfg->lbo );
723 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"ClkMode", te_cfg->te_clock );
728 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"HighImpedanceMode",te_cfg->high_impedance_mode );
733 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"TE_RX_SLEVEL", te_cfg->rx_slevel );
739 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"E1Signalling", te_cfg->sig_mode );
750 case WAN_MEDIA_FXOFXS:
752 iReturnCode = registry_set_string_value(hPortRegistryKey,
"remora_fxo_operation_mode_name", analog_cfg->opermode_name);
757 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"RM_BATTTHRESH", analog_cfg->battthresh);
762 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"RM_BATTDEBOUNCE", analog_cfg->battdebounce);
767 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"RM_FXO_TAPPING", analog_cfg->rm_mode);
772 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"RM_FXO_TAPPING_OFF_HOOK_THRESHOLD",analog_cfg->ohthresh);
777 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"RM_LCM", analog_cfg->rm_lcm);
782 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"RM_FXSTXGAIN", analog_cfg->fxs_txgain);
787 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"RM_FXSRXGAIN", analog_cfg->fxs_rxgain);
792 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"RM_FXOTXGAIN", analog_cfg->fxo_txgain);
797 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"RM_FXORXGAIN", analog_cfg->fxo_rxgain);
804 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"aft_bri_clock_mode", bri_cfg->clock_mode);
810 case WAN_MEDIA_SERIAL:
811 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"clock_source", wandev_conf->clocking);
816 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"BaudRate", wandev_conf->bps);
821 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"serial_connection_type", wandev_conf->connection);
826 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"serial_line_coding", wandev_conf->line_coding);
831 iReturnCode = registry_set_integer_value(hPortRegistryKey,
"serial_line_idle", wandev_conf->line_idle);
838 DBG_ERR(
"Invalid Media Type %d!\n", sdla_fe_cfg->media);
845 int registry_write_wan_tdmv_conf(HKEY hPortRegistryKey, port_cfg_t *port_cfg)
847 wandev_conf_t *wandev_conf = &port_cfg->wandev_conf;
848 sdla_fe_cfg_t *sdla_fe_cfg = &wandev_conf->fe_cfg;
849 wan_tdmv_conf_t *tdmv_conf = &wandev_conf->tdmv_conf;
853 switch(sdla_fe_cfg->media)
859 iReturnCode = registry_set_string_value(hPortRegistryKey,
"TDMV_DCHAN", timeslot_bitmap_to_string(tdmv_conf->dchan));
863 case WAN_MEDIA_FXOFXS:
865 case WAN_MEDIA_SERIAL:
871 DBG_ERR(
"Invalid Media Type %d!\n", sdla_fe_cfg->media);
879 int registry_write_channel_group_cfg(HKEY hPortRegistryKey, port_cfg_t *port_cfg,
int interface_index, wanif_conf_t wanif_conf)
881 char szTemp[TMP_BUFFER_LEN];
886 _snprintf(szTemp, TMP_BUFFER_LEN,
"aft_logic_channel_%d_line_mode", interface_index);
887 iReturnCode = registry_set_string_value(hPortRegistryKey, szTemp,
888 (wanif_conf.hdlc_streaming == WANOPT_YES ? MODE_OPTION_HDLC : MODE_OPTION_BITSTRM));
894 _snprintf(szTemp, TMP_BUFFER_LEN,
"aft_logic_channel_%d_mtu", interface_index);
895 iReturnCode = registry_set_integer_value(hPortRegistryKey, szTemp, wanif_conf.mtu);
901 _snprintf(szTemp, TMP_BUFFER_LEN,
"aft_logic_channel_%d_operational_mode", interface_index);
902 iReturnCode = registry_set_string_value(hPortRegistryKey, szTemp, wanif_conf.usedby);
908 _snprintf(szTemp, TMP_BUFFER_LEN,
"aft_logic_channel_%d_active_ch", interface_index);
909 iReturnCode = registry_set_string_value(hPortRegistryKey, szTemp, timeslot_bitmap_to_string(wanif_conf.active_ch));
915 _snprintf(szTemp, TMP_BUFFER_LEN,
"aft_logic_channel_%d_idle_char", interface_index);
916 iReturnCode = registry_set_integer_value(hPortRegistryKey, szTemp, wanif_conf.u.aft.idle_flag);
934 SP_DEVINFO_DATA deid = {
sizeof(SP_DEVINFO_DATA)};
936 TCHAR szInstanceId[MAX_COMP_INSTID];
938 const TCHAR *szAftSearchSubStr =
"PCI\\VEN_1923";
941 SP_PROPCHANGE_PARAMS pcp;
943 hdi = SetupDiGetClassDevs((
struct _GUID *)&GUID_DEVCLASS_SANGOMA_ADAPTER, NULL, NULL, DIGCF_PRESENT);
950 for (i = 0; SetupDiEnumDeviceInfo(hdi, i, &deid); i++){
952 BOOL fSuccess = SetupDiGetDeviceInstanceId(hdi, &deid, (PSTR)szInstanceId,
sizeof(szInstanceId), NULL);
957 if(!strstr(szInstanceId, szAftSearchSubStr)){
962 memset(&pcp, 0x00,
sizeof(pcp));
964 pcp.ClassInstallHeader.cbSize =
sizeof(SP_CLASSINSTALL_HEADER);
965 pcp.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
966 pcp.Scope = DICS_FLAG_GLOBAL;
970 pcp.StateChange = StateChange;
972 if(!SetupDiSetClassInstallParams(hdi, &deid, (SP_CLASSINSTALL_HEADER *)&pcp,
sizeof(pcp))){
977 if(!SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, hdi, &deid)){
984 SetupDiDestroyDeviceInfoList(hdi);
991 return sangoma_control_cards(DICS_DISABLE);
996 return sangoma_control_cards(DICS_ENABLE);
1006 int i, iRegistryReturnCode, iPortCounter = 0;
1007 SP_DEVINFO_DATA deid={
sizeof(SP_DEVINFO_DATA)};
1008 HDEVINFO hdi = SetupDiGetClassDevs((
struct _GUID *)&GUID_DEVCLASS_SANGOMA_ADAPTER, NULL,NULL, DIGCF_PRESENT);
1011 char szCompInstanceId[MAX_COMP_INSTID];
1012 TCHAR szCompDescription[MAX_COMP_DESC];
1025 const TCHAR *search_SubStr =
"Sangoma Hardware Abstraction Driver";
1028 for (i = 0; SetupDiEnumDeviceInfo(hdi, i, &deid); i++){
1030 BOOL fSuccess = SetupDiGetDeviceInstanceId(hdi, &deid, (PSTR)szCompInstanceId, MAX_COMP_INSTID, NULL);
1035 fSuccess = SetupDiGetDeviceRegistryProperty(hdi, &deid, SPDRP_DEVICEDESC, &dwRegType, (BYTE*)szCompDescription, MAX_COMP_DESC, NULL);
1040 if (!strstr(szCompDescription, search_SubStr)) {
1045 hKeyTmp = SetupDiOpenDevRegKey(hdi, &deid, DICS_FLAG_GLOBAL, 0, DIREG_DRV, KEY_READ | KEY_SET_VALUE );
1047 DBG_REGISTRY(
"Error: Failed to open Registry key!!\n");
1053 printf(
"* %s -> Setting Span/Port number: %d\n", szCompDescription, iPortCounter);
1062 iRegistryReturnCode = registry_set_integer_value(hKeyTmp, WP_REGSTR_USER_SPECIFIED_WANPIPE_NUMBER, iPortCounter);
1063 if(iRegistryReturnCode){
1067 RegCloseKey(hKeyTmp);
1071 SetupDiDestroyDeviceInfoList(hdi);
1084 int i, iRegistryReturnCode;
1085 SP_DEVINFO_DATA deid = {
sizeof(SP_DEVINFO_DATA)};
1086 HDEVINFO hdi = SetupDiGetClassDevs((
struct _GUID *)&GUID_DEVCLASS_SANGOMA_ADAPTER, NULL, NULL, DIGCF_PRESENT);
1090 TCHAR szTmp[MAX_COMP_DESC];
1091 BOOL fSuccess =
FALSE;
1094 for (i = 0; SetupDiEnumDeviceInfo(hdi, i, &deid); i++){
1096 fSuccess = SetupDiGetDeviceInstanceId(hdi, &deid, (PSTR)szTmp,
sizeof(szTmp), NULL);
1100 DBG_REGISTRY(
"%s(): Device Instance Id: %s\n", __FUNCTION__, szTmp);
1104 hKeyTmp = SetupDiOpenDevRegKey( hdi, &deid, DICS_FLAG_GLOBAL, 0, DIREG_DRV, KEY_READ | KEY_SET_VALUE );
1106 DBG_REGISTRY(
"Error: Failed to open Registry key!!\n");
1111 iRegistryReturnCode = registry_get_string_value(hKeyTmp,
"DriverVersion", szTmp, &dwTemp);
1112 if(iRegistryReturnCode){
1117 wp_snprintf(out_buffer, out_buffer_length, szTmp);
1119 RegCloseKey(hKeyTmp);
1125 SetupDiDestroyDeviceInfoList(hdi);
1142 int i, iRegistryReturnCode;
1143 SP_DEVINFO_DATA deid = {
sizeof(SP_DEVINFO_DATA)};
1145 TCHAR szInstanceId[MAX_COMP_INSTID];
1148 const TCHAR *szAftSearchSubStr =
"PCI\\VEN_1923";
1150 hdi = SetupDiGetClassDevs((
struct _GUID *)&GUID_DEVCLASS_SANGOMA_ADAPTER, NULL, NULL, DIGCF_PRESENT);
1157 for (i = 0; SetupDiEnumDeviceInfo(hdi, i, &deid); i++){
1159 BOOL fSuccess = SetupDiGetDeviceInstanceId(hdi, &deid, (PSTR)szInstanceId,
sizeof(szInstanceId), NULL);
1164 if(!strstr(szInstanceId, szAftSearchSubStr)){
1169 hKeyTmp = SetupDiOpenDevRegKey(hdi, &deid, DICS_FLAG_GLOBAL, 0, DIREG_DRV, KEY_READ | KEY_SET_VALUE );
1175 iRegistryReturnCode = registry_set_integer_value(hKeyTmp,
"driver_mode", driver_mode);
1176 if(iRegistryReturnCode){
1181 RegCloseKey(hKeyTmp);
1185 SetupDiDestroyDeviceInfoList(hdi);
1202 static unsigned char* sangoma_get_wan_udphdr_data_ptr(
wan_udp_hdr_t *wan_udp_ptr,
unsigned char off)
1204 unsigned char *p_data = &wan_udp_ptr->wan_udphdr_data[0];
1210 static unsigned char sangoma_set_wan_udphdr_data_byte(
wan_udp_hdr_t *wan_udp_ptr,
unsigned char off,
unsigned char data)
1212 unsigned char *p_data = &wan_udp_ptr->wan_udphdr_data[0];
1218 static unsigned char sangoma_get_wan_udphdr_data_byte(
wan_udp_hdr_t *wan_udp_ptr,
unsigned char off)
1220 unsigned char *p_data = &wan_udp_ptr->wan_udphdr_data[0];
1242 sangoma_wait_obj_t *sng_wait_obj = NULL;
1244 if (!sangoma_wait_object) {
1247 *sangoma_wait_object = NULL;
1248 sng_wait_obj = malloc(
sizeof(**sangoma_wait_object));
1249 if (!sng_wait_obj) {
1253 memset(sng_wait_obj, 0x00,
sizeof(*sng_wait_obj));
1255 sng_wait_obj->init_flag = LIBSNG_MAGIC_NO;
1257 sng_wait_obj->fd = fd;
1258 sng_wait_obj->object_type = object_type;
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){
1269 err = init_sangoma_event_object(sng_wait_obj, fd);
1277 if (SANGOMA_OBJ_IS_SIGNALABLE(sng_wait_obj)) {
1281 if (pipe(filedes)) {
1285 sng_wait_obj->signal_read_fd = filedes[0];
1286 sng_wait_obj->signal_write_fd = filedes[1];
1290 flags = fcntl(sng_wait_obj->signal_read_fd, F_GETFL, 0);
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)) {
1304 *sangoma_wait_object = sng_wait_obj;
1322 sangoma_wait_obj_t *sng_wait_obj = *sangoma_wait_object;
1324 if(sng_wait_obj->init_flag != LIBSNG_MAGIC_NO){
1329 #if defined(__WINDOWS__)
1330 if (sng_wait_obj->signal_object &&
1335 if (SANGOMA_OBJ_IS_SIGNALABLE(sng_wait_obj)) {
1340 sng_wait_obj->init_flag = 0;
1343 *sangoma_wait_object = NULL;
1355 if (!SANGOMA_OBJ_IS_SIGNALABLE(sng_wait_obj)) {
1361 #if defined(__WINDOWS__)
1362 if(sng_wait_obj->signal_object){
1363 if (!SetEvent(sng_wait_obj->signal_object)) {
1369 if (write(sng_wait_obj->signal_write_fd,
"s", 1) < 1) {
1384 return sng_wait_obj->fd;
1395 void _LIBSNG_CALL sangoma_wait_obj_set_context(sangoma_wait_obj_t *sng_wait_obj,
void *context)
1397 sng_wait_obj->context = context;
1408 return sng_wait_obj->context;
1422 uint32_t number_of_sangoma_wait_objects, int32_t system_wait_timeout)
1424 #if defined(__WINDOWS__)
1425 HANDLE hEvents[MAXIMUM_WAIT_OBJECTS];
1427 int at_least_one_poll_set_flags_out, err;
1428 sangoma_wait_obj_t *sangoma_wait_object;
1434 memset(out_flags, 0x00, number_of_sangoma_wait_objects *
sizeof(out_flags[0]));
1435 #if defined(__WINDOWS__)
1437 if(sangoma_check_number_of_wait_objects(number_of_sangoma_wait_objects)){
1442 for(i = 0; i < MAXIMUM_WAIT_OBJECTS; i++){
1448 for(i = 0; i < number_of_sangoma_wait_objects; i++){
1450 sangoma_wait_object = sng_wait_objects[i];
1452 if(LIBSNG_MAGIC_NO != sangoma_wait_object->init_flag){
1456 if(sangoma_wait_object->signal_object){
1457 hEvents[i] = sangoma_wait_object->signal_object;
1462 at_least_one_poll_set_flags_out =
FALSE;
1466 err = get_out_flags(sng_wait_objects, INVALID_INDEX, in_flags, out_flags, number_of_sangoma_wait_objects, &at_least_one_poll_set_flags_out);
1467 if(SANG_ERROR(err)){
1471 if(
TRUE == at_least_one_poll_set_flags_out){
1476 dwResult = WaitForMultipleObjects(number_of_sangoma_wait_objects, &hEvents[0],
FALSE, system_wait_timeout);
1477 if (WAIT_TIMEOUT == dwResult){
1481 if( dwResult >= (
DWORD)number_of_sangoma_wait_objects ) {
1486 err = get_out_flags(sng_wait_objects,
1489 in_flags, out_flags, number_of_sangoma_wait_objects, NULL);
1490 if(SANG_ERROR(err)){
1496 struct pollfd pfds[number_of_sangoma_wait_objects*2];
1501 memset(pfds, 0,
sizeof(pfds));
1503 for(i = 0; i < number_of_sangoma_wait_objects; i++){
1505 if (SANGOMA_OBJ_HAS_DEVICE(sng_wait_objects[i])) {
1506 pfds[i].fd = sng_wait_objects[i]->fd;
1507 pfds[i].events = in_flags[i];
1510 if (SANGOMA_OBJ_IS_SIGNALABLE(sng_wait_objects[i])) {
1511 pfds[number_of_sangoma_wait_objects+j].fd = sng_wait_objects[i]->signal_read_fd;
1512 pfds[number_of_sangoma_wait_objects+j].events = POLLIN;
1519 res = poll(pfds, (number_of_sangoma_wait_objects + j), system_wait_timeout);
1521 for(i = 0; i < number_of_sangoma_wait_objects; i++){
1522 out_flags[i] = pfds[i].revents;
1525 for(i = 0; i < j; i++){
1526 if (pfds[number_of_sangoma_wait_objects+i].revents & POLLIN) {
1528 read(pfds[number_of_sangoma_wait_objects+i].fd, &dummy_buf, 1);
1530 out_flags[i] |= SANG_WAIT_OBJ_IS_SIGNALED;
1533 }
else if (res < 0 && errno == EINTR) {
1535 goto poll_try_again;
1555 sangoma_status_t _LIBSNG_CALL sangoma_waitfor(sangoma_wait_obj_t *sangoma_wait_obj, uint32_t inflags, uint32_t *outflags, int32_t timeout)
1557 return sangoma_waitfor_many(&sangoma_wait_obj, &inflags, outflags, 1, timeout);
1568 #if defined(__WINDOWS__)
1572 sprintf(interface_name,
"s%ic%i",span,chan);
1579 char *p=NULL, *sp = NULL, *ch = NULL;
1583 strncpy(data, interface_name,
FNAME_LEN);
1585 for (p = data; *p; p++) {
1586 if (sp && *p ==
'g') {
1590 }
else if (*p ==
'w') {
1610 #if defined(__WINDOWS__)
1615 struct stat statbuf;
1616 struct timeval endtime = {0,0};
1617 struct timeval curtime = {0,0};
1620 if (sectimeout >= 0 && gettimeofday(&endtime, NULL)) {
1624 endtime.tv_sec += sectimeout;
1627 while ((rc = stat(interface_name, &statbuf)) && errno == ENOENT && counter != 10) {
1631 if (!rc || errno != ENOENT)
break;
1632 if (gettimeofday(&curtime, NULL)) {
1635 }
while (sectimeout < 0 || timercmp(&endtime, &curtime,>));
1642 char *p = NULL, *sp = NULL, *ch = NULL;
1649 strncpy(data, interface_name,
FNAME_LEN);
1651 for (p = data; *p; p++) {
1652 #if defined(__WINDOWS__)
1653 if (sp && (*p ==
'F'||*p ==
'f')) {
1655 if (sp && *p ==
'c') {
1660 #if defined(__WINDOWS__)
1661 }
else if (*p ==
'E'||*p ==
'e') {
1663 }
else if (*p ==
's') {
1690 #if defined(__WINDOWS__)
1700 memset(&tdm_api,0,
sizeof(tdm_api));
1721 #if defined(__WINDOWS__)
1724 return CreateFile( fname,
1725 GENERIC_READ | GENERIC_WRITE,
1726 FILE_SHARE_READ | FILE_SHARE_WRITE,
1727 (LPSECURITY_ATTRIBUTES)NULL,
1729 FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH,
1733 sprintf(fname,
"/dev/%s", dev_name);
1735 return open(fname, O_RDWR);
1755 #ifdef WP_API_FEATURE_LOGGER
1766 WANPIPE_API_INIT_CHAN(tdm_api, 0);
1792 for(i = 1; i < 32; i++){
1796 #if defined(__WINDOWS__)
1823 #if defined(__WINDOWS__)
1846 #if defined(__WINDOWS__)
1852 DBG_ERR(
"hdrlen (%i) != sizeof(wp_api_hdr_t) (%i)\n", hdrlen,
sizeof(
wp_api_hdr_t));
1856 memset(&iovec_list, 0x00,
sizeof(iovec_list));
1864 if (DoReadCommand(fd, &iovec_list)) {
1866 DBG_ERR(
"DoReadCommand() failed! Check messages log.\n");
1880 if(libsng_dbg_level)DBG_ERR(
"Operation Status: %s(%d)\n",
1890 memset(&msg,0,
sizeof(msg));
1891 memset(&iov[0],0,
sizeof(iov[0])*2);
1893 iov[0].iov_len=hdrlen;
1894 iov[0].iov_base=hdrbuf;
1896 iov[1].iov_len=datalen;
1897 iov[1].iov_base=databuf;
1902 rx_len = read(fd,&msg,
sizeof(msg));
1917 #if defined(__WINDOWS__)
1923 DBG_ERR(
"hdrlen (%i) != sizeof(wp_api_hdr_t) (%i)\n", hdrlen,
sizeof(
wp_api_hdr_t));
1927 #if defined(__WINDOWS__)
1931 memset(&iovec_list, 0x00,
sizeof(iovec_list));
1940 if (DoWriteCommand(fd, &iovec_list)) {
1942 DBG_ERR(
"DoWriteCommand() failed!! Check messages log.\n");
1954 DBG_ERR(
"Operation Status: %s(%d)\n",
1962 memset(&msg,0,
sizeof(msg));
1963 memset(&iov[0],0,
sizeof(iov[0])*2);
1965 iov[0].iov_len=hdrlen;
1966 iov[0].iov_base=hdrbuf;
1968 iov[1].iov_len=datalen;
1969 iov[1].iov_base=databuf;
1974 bsent = write(fd,&msg,
sizeof(msg));
1976 if (bsent == (datalen+hdrlen)){
1979 }
else if (errno == EBUSY){
1984 wp_api_hdr->wp_api_hdr_data_length=bsent;
1991 #ifdef WANPIPE_TDM_API
2008 #if defined(__WINDOWS__)
2009 err = tdmv_api_ioctl(fd, &tdm_api->
wp_cmd);
2014 sprintf(tmp,
"TDM API: CMD: %i\n",tdm_api->
wp_cmd.
cmd);
2030 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2040 printf(
"TDM API CFG:\n");
2051 #ifdef WP_API_FEATURE_FE_ALARM
2055 printf(
"\trx pkt\t%d\ttx pkt\t%d\n",tdm_api->
wp_cmd.
stats.rx_packets,
2057 printf(
"\trx err\t%d\ttx err\t%d\n",
2061 printf(
"\trx ovr\t%d\ttx idl\t%d\n",
2084 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2107 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2128 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2146 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2168 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2178 #ifdef WP_API_FEATURE_DTMF_EVENTS
2189 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2209 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2216 return tdm_api->
wp_cmd.hw_ec;
2221 #ifdef WP_API_FEATURE_EC_CHAN_STAT
2232 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2239 return tdm_api->
wp_cmd.hw_ec;
2244 #ifdef WP_API_FEATURE_HWEC_PERSIST
2258 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2265 return tdm_api->
wp_cmd.hw_ec;
2280 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2300 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2317 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2331 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2339 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2347 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2355 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2363 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2372 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2380 WANPIPE_API_INIT_CHAN(tdm_api, channel);
2390 WANPIPE_API_INIT_CHAN(tdm_api, channel);
2404 #ifdef WP_API_FEATURE_BUFFER_MULT
2410 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2413 *((
unsigned int*)&tdm_api->
wp_cmd.data[0]) = multiplier;
2429 #ifdef WP_API_FEATURE_EVENTS
2433 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2435 tdm_api->
wp_cmd.
cmd = WP_API_CMD_READ_EVENT;
2444 #ifdef WP_API_DEPRECATED_FEATURE_READ_CALLBACK_FUNCTIONS
2452 switch (rx_event->wp_api_event_type){
2456 tdm_api->
wp_callback.wp_rbs_event(fd,rx_event->wp_api_event_rbs_bits);
2460 #ifdef WP_API_FEATURE_DTMF_EVENTS
2464 rx_event->wp_api_event_dtmf_digit,
2465 rx_event->wp_api_event_dtmf_type,
2466 rx_event->wp_api_event_dtmf_port);
2471 case WP_API_EVENT_RXHOOK:
2474 rx_event->wp_api_event_hook_state);
2478 case WP_API_EVENT_RING_DETECT:
2481 rx_event->wp_api_event_ring_state);
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);
2492 #ifdef WP_API_FEATURE_FE_ALARM
2493 case WP_API_EVENT_ALARM:
2496 rx_event->wp_api_event_alarm);
2501 #ifdef WP_API_FEATURE_LINK_STATUS
2503 case WP_API_EVENT_LINK_STATUS:
2506 rx_event->wp_api_event_link_status);
2512 #ifdef WP_API_FEATURE_POL_REV
2513 case WP_API_EVENT_POLARITY_REVERSE:
2518 if(0)printf(
"Warning: libsangoma: %s fd=0x%p: Unknown TDM event!", __FUNCTION__,fd);
2520 if(0)printf(
"Warning: libsangoma: %s fd=%d: Unknown TDM event!", __FUNCTION__, fd);
2530 printf(
"Error: Read Event not supported!\n");
2536 #ifdef WP_API_FEATURE_LOGGER
2542 #if defined(__WINDOWS__)
2543 return logger_api_ioctl(fd, logger_cmd);
2548 sprintf(tmp,
"Logger CMD: %i\n",logger_cmd->cmd);
2558 logger_cmd->cmd = WP_API_LOGGER_CMD_READ_EVENT;
2559 return sangoma_logger_cmd_exec(fd, logger_cmd);
2564 logger_cmd->cmd = WP_API_LOGGER_CMD_FLUSH_BUFFERS;
2565 return sangoma_logger_cmd_exec(fd, logger_cmd);
2570 logger_cmd->cmd = WP_API_LOGGER_CMD_GET_STATS;
2571 return sangoma_logger_cmd_exec(fd, logger_cmd);
2576 logger_cmd->cmd = WP_API_LOGGER_CMD_RESET_STATS;
2577 return sangoma_logger_cmd_exec(fd, logger_cmd);
2582 logger_cmd->cmd = WP_API_LOGGER_CMD_OPEN_CNT;
2583 return sangoma_logger_cmd_exec(fd, logger_cmd);
2588 logger_cmd->cmd = WP_API_LOGGER_CMD_GET_LOGGER_LEVEL;
2589 return sangoma_logger_cmd_exec(fd, logger_cmd);
2594 logger_cmd->cmd = WP_API_LOGGER_CMD_SET_LOGGER_LEVEL;
2595 return sangoma_logger_cmd_exec(fd, logger_cmd);
2600 #ifdef WP_API_FEATURE_FAX_EVENTS
2603 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2605 tdm_api->
wp_cmd.
cmd = WP_API_CMD_SET_EVENT;
2613 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2615 tdm_api->
wp_cmd.
cmd = WP_API_CMD_SET_EVENT;
2624 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2631 return tdm_api->
wp_cmd.hw_fax;
2635 #ifdef WP_API_FEATURE_DTMF_EVENTS
2638 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2640 tdm_api->
wp_cmd.
cmd = WP_API_CMD_SET_EVENT;
2648 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2650 tdm_api->
wp_cmd.
cmd = WP_API_CMD_SET_EVENT;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
2803 tdm_api->
wp_cmd.
event.wp_api_event_tone_type = tone_id;
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;
2814 tdm_api->
wp_cmd.
event.wp_api_event_tone_type = 0x00;
2823 tdm_api->
wp_cmd.
cmd = WP_API_CMD_ENABLE_HWEC;
2831 tdm_api->
wp_cmd.
cmd = WP_API_CMD_DISABLE_HWEC;
2840 #ifdef WP_API_FEATURE_FE_ALARM
2845 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2847 tdm_api->
wp_cmd.
cmd = WP_API_CMD_GET_FE_ALARMS;
2864 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2866 tdm_api->
wp_cmd.
cmd = WP_API_CMD_GET_FE_STATUS;
2875 #ifdef WP_API_FEATURE_LINK_STATUS
2880 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2882 tdm_api->
wp_cmd.
cmd = WP_API_CMD_GET_FE_STATUS;
2892 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2894 tdm_api->
wp_cmd.
cmd = WP_API_CMD_SET_FE_STATUS;
2902 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2904 tdm_api->
wp_cmd.
cmd = WP_API_CMD_SET_EVENT;
2906 tdm_api->
wp_cmd.
event.wp_api_event_type = WP_API_EVENT_BRI_CHAN_LOOPBACK;
2913 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2915 tdm_api->
wp_cmd.
cmd = WP_API_CMD_SET_EVENT;
2917 tdm_api->
wp_cmd.
event.wp_api_event_type = WP_API_EVENT_BRI_CHAN_LOOPBACK;
2926 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2944 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2955 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2975 WANPIPE_API_INIT_CHAN(tdm_api, 0);
2986 WANPIPE_API_INIT_CHAN(tdm_api, 0);
3008 WANPIPE_API_INIT_CHAN(tdm_api, 0);
3014 if (tdm_api->
wp_cmd.data_len ==
sizeof(
unsigned char)) {
3015 *ver = tdm_api->
wp_cmd.data[0];
3028 WANPIPE_API_INIT_CHAN(tdm_api, 0);
3034 if (tdm_api->
wp_cmd.data_len ==
sizeof(
unsigned char)) {
3035 *ver = tdm_api->
wp_cmd.data[0];
3048 memset(&wan_udp, 0x00,
sizeof(wan_udp));
3052 wan_udp.wan_udphdr_data_len = 0;
3058 if (wan_udp.wan_udphdr_return_code) {
3062 *out_customer_id = sangoma_get_wan_udphdr_data_byte(&wan_udp, 0);
3067 #ifdef WP_API_FEATURE_LED_CTRL
3072 memset(&wan_udp, 0x00,
sizeof(wan_udp));
3076 wan_udp.wan_udphdr_data_len = 1;
3077 wan_udp.wan_udphdr_data[0] = led_ctrl;
3083 if (wan_udp.wan_udphdr_return_code) {
3091 #ifdef WP_API_FEATURE_FE_RW
3096 sdla_fe_debug_t *fe_debug;
3097 memset(&wan_udp, 0x00,
sizeof(wan_udp));
3102 memset(&tdm_api,0,
sizeof(tdm_api));
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;
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;
3127 if (wan_udp.wan_udphdr_return_code) {
3138 sdla_fe_debug_t *fe_debug;
3139 memset(&wan_udp, 0x00,
sizeof(wan_udp));
3144 memset(&tdm_api,0,
sizeof(tdm_api));
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;
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;
3168 if (wan_udp.wan_udphdr_return_code) {
3172 *data = fe_debug->fe_debug_reg.value;
3181 wan_remora_udp_t *rm_udp;
3184 memset(&wan_udp, 0x00,
sizeof(wan_udp));
3189 memset(&tdm_api,0,
sizeof(tdm_api));
3199 rm_udp = (wan_remora_udp_t *)wan_udp.wan_udphdr_data;
3200 rm_udp->mod_no = chan;
3201 wan_udp.wan_udphdr_command = WAN_FE_STATS;
3202 wan_udp.wan_udphdr_return_code = 0xaa;
3203 wan_udp.wan_udphdr_data_len =
sizeof(wan_remora_udp_t);
3209 if (wan_udp.wan_udphdr_return_code) {
3214 rm_udp = (wan_remora_udp_t *)wan_udp.wan_udphdr_data;
3215 if (rm_udp->type == MOD_TYPE_FXO){
3216 unsigned char volt = rm_udp->u.stats.volt;
3231 wan_remora_udp_t *rm_udp;
3234 memset(&wan_udp, 0x00,
sizeof(wan_udp));
3238 memset(&tdm_api,0,
sizeof(tdm_api));
3248 rm_udp = (wan_remora_udp_t *)wan_udp.wan_udphdr_data;
3249 rm_udp->mod_no = chan;
3250 wan_udp.wan_udphdr_command = WAN_FE_STATS;
3251 wan_udp.wan_udphdr_return_code = 0xaa;
3252 wan_udp.wan_udphdr_data_len =
sizeof(wan_remora_udp_t);
3258 if (wan_udp.wan_udphdr_return_code) {
3263 rm_udp = (wan_remora_udp_t *)wan_udp.wan_udphdr_data;
3264 if (rm_udp->type == MOD_TYPE_FXS){
3265 *tip=(float)(rm_udp->u.stats.tip_volt*376)/1000;
3266 *ring=(float)(rm_udp->u.stats.ring_volt*376)/1000;
3267 *bat=(float)(rm_udp->u.stats.bat_volt*376)/1000;
3269 printf(
"TIP\t: -%7.4f Volts\n", (
float)(rm_udp->u.stats.tip_volt*376)/1000);
3270 printf(
"RING\t: -%7.4f Volts\n", (
float)(rm_udp->u.stats.ring_volt*376)/1000);
3271 printf(
"VBAT\t: -%7.4f Volts\n", (
float)(rm_udp->u.stats.bat_volt*376)/1000);
3285 WANPIPE_API_INIT_CHAN(tdm_api, 0);
3301 WANPIPE_API_INIT_CHAN(tdm_api, 0);
3309 WANPIPE_API_INIT_CHAN(tdm_api, 0);
3316 #ifdef WP_API_FEATURE_RM_GAIN
3319 WANPIPE_API_INIT_CHAN(tdm_api, 0);
3321 tdm_api->
wp_cmd.
cmd = WP_API_CMD_SET_EVENT;
3324 tdm_api->
wp_cmd.
event.wp_api_event_gain_value = value;
3330 WANPIPE_API_INIT_CHAN(tdm_api, 0);
3332 tdm_api->
wp_cmd.
cmd = WP_API_CMD_SET_EVENT;
3335 tdm_api->
wp_cmd.
event.wp_api_event_gain_value = value;
3344 WANPIPE_API_INIT_CHAN(tdm_api, 0);
3346 tdm_api->
wp_cmd.
cmd = WP_API_CMD_SET_EVENT;
3347 tdm_api->
wp_cmd.
event.wp_api_event_type = WP_API_EVENT_SETPOLARITY;
3348 tdm_api->
wp_cmd.
event.wp_api_event_polarity = polarity;
3357 WANPIPE_API_INIT_CHAN(tdm_api, 0);
3359 tdm_api->
wp_cmd.
cmd = WP_API_CMD_SET_EVENT;
3360 tdm_api->
wp_cmd.
event.wp_api_event_type = WP_API_EVENT_ONHOOKTRANSFER;
3365 #ifdef WP_API_FEATURE_LOOP
3371 WANPIPE_API_INIT_CHAN(tdm_api, 0);
3382 WANPIPE_API_INIT_CHAN(tdm_api, 0);
3391 #ifdef WP_API_FEATURE_HWEC_PERSIST
3399 #ifdef WP_API_FEATURE_SS7_FORCE_RX
3402 WANPIPE_API_INIT_CHAN(tdm_api, 0);
3409 #ifdef WP_API_FEATURE_SS7_CFG_STATUS
3414 WANPIPE_API_INIT_CHAN(tdm_api, 0);
3420 if (ss7_cfg_status) {
sng_fd_t _LIBSNG_CALL __sangoma_open_api_span_chan(int span, int chan)
Open a Device based on Span/Chan values.
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.
int _LIBSNG_CALL sangoma_wait_obj_signal(sangoma_wait_obj_t *sng_wait_obj)
Set wait object to a signaled state.
int _LIBSNG_CALL sangoma_tdm_disable_rxhook_events(sng_fd_t fd, wanpipe_api_t *tdm_api)
Disable RX HOOK Events (Analog Only)
int _LIBSNG_CALL sangoma_tdm_enable_ring_events(sng_fd_t fd, wanpipe_api_t *tdm_api)
Enable RING Events (Analog Only)
#define INVALID_HANDLE_VALUE
Invalid file handle value -1, Ported from Windows.
int _LIBSNG_CALL sangoma_flush_stats(sng_fd_t fd, wanpipe_api_t *tdm_api)
Flush/Reset device statistics.
int _LIBSNG_CALL sangoma_get_full_cfg(sng_fd_t fd, wanpipe_api_t *tdm_api)
Read tdm api device configuration.
#define FALSE
FALSE value is 0, Ported from Windows.
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.
#define _snprintf
_snprintf type mapped to snprintf, Ported from Windows
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.
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.
int _LIBSNG_CALL sangoma_read_event(sng_fd_t fd, wanpipe_api_t *tdm_api)
Read API Events.
enum _sangoma_wait_obj_type sangoma_wait_obj_type_t
Wait object type definition.
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)...
sangoma_status_t _LIBSNG_CALL sangoma_logger_reset_statistics(sng_fd_t fd, wp_logger_cmd_t *logger_cmd)
Reset Wanpipe Logger statistics.
int _LIBSNG_CALL sangoma_mgmt_cmd(sng_fd_t fd, wan_udp_hdr_t *wan_udp)
Execute Sangoma Management Command.
int _LIBSNG_CALL sangoma_tdm_enable_rxhook_events(sng_fd_t fd, wanpipe_api_t *tdm_api)
Enable RX HOOK Events (Analog Only)
u_int8_t operation_status
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
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.
Memory Descriptor of a single buffer. This structure used internally by libsangoma.
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 ar...
int _LIBSNG_CALL sangoma_tdm_get_usr_period(sng_fd_t fd, wanpipe_api_t *tdm_api)
Get Tx/Rx Period in Milliseconds.
u_int32_t poll_events_bitmap
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.
int _LIBSNG_CALL sangoma_tdm_get_power_level(sng_fd_t fd, wanpipe_api_t *tdm_api)
Get Configured Power Level.
int _LIBSNG_CALL sangoma_tdm_disable_loop(sng_fd_t fd, wanpipe_api_t *tdm_api)
Disable channel loop.
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)
int _LIBSNG_CALL sangoma_writemsg(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, unsigned short datalen, int flag)
Write Data to device.
sng_fd_t _LIBSNG_CALL sangoma_open_api_ctrl(void)
Open a Global Control Device.
int _LIBSNG_CALL sangoma_get_firmware_version(sng_fd_t fd, wanpipe_api_t *tdm_api, unsigned char *ver)
Get Hardware/Firmware Version.
int _LIBSNG_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Execute Sangoma API Command.
int _LIBSNG_CALL sangoma_tdm_txsig_onhook(sng_fd_t fd, wanpipe_api_t *tdm_api)
Tranmsmit TX SIG ON HOOK (Analog Only)
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.
int _LIBSNG_CALL sangoma_interface_toi(char *interface_name, int *span, int *chan)
Convert Span & Chan to interface name.
unsigned int hw_tdm_coding
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)
int _LIBSNG_CALL sangoma_flush_event_bufs(sng_fd_t fd, wanpipe_api_t *tdm_api)
Flush only event buffers from current channel.
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.
int sng_fd_t
Windows/Unix file handle abstraction.
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.
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)
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.
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.
int _LIBSNG_CALL sangoma_flush_tx_bufs(sng_fd_t fd, wanpipe_api_t *tdm_api)
Flush only tx buffers from current channel.
#define SANGOMA_INIT_TDM_API_CMD_RESULT(_name_)
Initialize the 'result' in wanpipe_api_t to SANG_STATUS_GENERAL_ERROR.
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)
int HANDLE
file handle type int, Ported from Windows
int _LIBSNG_CALL sangoma_span_chan_fromif(char *interface_name, int *span, int *chan)
Convert Interace Name to Span & Chan.
sangoma_status_t _LIBSNG_CALL sangoma_logger_flush_buffers(sng_fd_t fd, wp_logger_cmd_t *logger_cmd)
Flush Wanpipe Logger internal buffers.
sng_fd_t _LIBSNG_CALL sangoma_open_api_span_chan(int span, int chan)
Open a Device based on Span/Chan values.
Wanpipe UDP Structure used for Maintenance and Debugging.
int _LIBSNG_CALL sangoma_get_rx_queue_sz(sng_fd_t fd, wanpipe_api_t *tdm_api)
Get Rx Queue Size for this channel.
TDM API channel statistics.
int _LIBSNG_CALL sangoma_tdm_enable_ring_detect_events(sng_fd_t fd, wanpipe_api_t *tdm_api)
Enable RING DETECT Events (Analog Only)
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)
int32_t sangoma_status_t
return status from sangoma APIs
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)
#define SDLA_DECODE_SANG_STATUS(status)
Print decode of Sangoma Return Codes.
int _LIBSNG_CALL sangoma_tdm_disable_rbs_events(sng_fd_t fd, wanpipe_api_t *tdm_api)
Disable RBS Events for a device.
wanpipe_api_callbacks_t wp_callback
int _LIBSNG_CALL sangoma_readmsg(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag)
Read Data from device.
#define FNAME_LEN
string length of a file name
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.
int _LIBSNG_CALL sangoma_fe_reg_write(sng_fd_t fd, uint32_t offset, uint8_t data)
Write to a front end register.
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.
u_int32_t user_flags_bitmap
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.
Wanpipe API Event Structure.
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.
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.
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.
#define _LIBSNG_CALL
Not used in Linux.
sangoma_status_t _LIBSNG_CALL sangoma_logger_get_statistics(sng_fd_t fd, wp_logger_cmd_t *logger_cmd)
Get Wanpipe Logger statistics.
int _LIBSNG_CALL sangoma_tdm_enable_hwec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Enable HWEC on this channel.
int _LIBSNG_CALL sangoma_tdm_disable_tone_events(sng_fd_t fd, wanpipe_api_t *tdm_api)
Enable TONE Events (Analog Only)
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) ...
int _LIBSNG_CALL sangoma_tdm_get_codec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Get Configured TDM Codec per chan.
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)
int _LIBSNG_CALL sangoma_tdm_get_hw_dtmf(sng_fd_t fd, wanpipe_api_t *tdm_api)
Check if hwdtmf support is available.
Fixed-length List of Memory Descriptors.
int _LIBSNG_CALL sangoma_get_hw_coding(sng_fd_t fd, wanpipe_api_t *tdm_api)
Get HW Voice Coding (ulaw/alaw)
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.
Variable-length List of Memory Descriptors.
int _LIBSNG_CALL sangoma_tdm_txsig_offhook(sng_fd_t fd, wanpipe_api_t *tdm_api)
Tranmsmit TX SIG OFF HOOK (Analog Only)
wan_iovec_t *WP_POINTER_64 msg_iov
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)
int _LIBSNG_CALL sangoma_tdm_disable_ring_events(sng_fd_t fd, wanpipe_api_t *tdm_api)
Disable RING Events (Analog Only)
int _LIBSNG_CALL sangoma_get_open_cnt(sng_fd_t fd, wanpipe_api_t *tdm_api)
Get device open count.
char TCHAR
TCHAN type mapped to char, Ported from Windows.
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.
deprecated, use SANGOMA_GENERIC_WAIT_OBJ
int _LIBSNG_CALL sangoma_tdm_disable_ring_detect_events(sng_fd_t fd, wanpipe_api_t *tdm_api)
Disable RING DETECT Events (Analog Only)
int DWORD
DWORD type is int, Ported from Windows.
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.
int _LIBSNG_CALL sangoma_tdm_set_codec(sng_fd_t fd, wanpipe_api_t *tdm_api, int codec)
Set TDM Codec per chan.
Wanpipe API Command Structure.
Windows poll structure used to implement blocking poll for read/write/event.
int _LIBSNG_CALL sangoma_span_chan_toif(int span, int chan, char *interface_name)
Convert Span & Chan to interface name.
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.
int _LIBSNG_CALL sangoma_tdm_txsig_kewl(sng_fd_t fd, wanpipe_api_t *tdm_api)
Tranmsmit TX SIG KEWL START (Analog Only)
sangoma_status_t _LIBSNG_CALL sangoma_wait_obj_delete(sangoma_wait_obj_t **sangoma_wait_object)
De-allocate all resources in a wait object.
void _LIBSNG_CALL sangoma_close(sng_fd_t *fd)
Close device file descriptor.
int _LIBSNG_CALL sangoma_get_tx_queue_sz(sng_fd_t fd, wanpipe_api_t *tdm_api)
Get Tx Queue Size for this channel.
#define WP_API_EVENT_ENABLE
Option to enable command.
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.
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)
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.
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. ...
sng_fd_t _LIBSNG_CALL sangoma_logger_open(void)
Open a Global Logger Device.
#define WP_INTERFACE_NAME_FORM
String define of a wanpipe interface name.
wanpipe_chan_stats_t stats
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)
sng_fd_t _LIBSNG_CALL sangoma_create_socket_by_name(char *device, char *card)
Open a device based on a interface and card name.
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.
int _LIBSNG_CALL sangoma_tdm_txsig_start(sng_fd_t fd, wanpipe_api_t *tdm_api)
Tranmsmit TX SIG START (Analog Only)
#define TRUE
TRUE value is 1, Ported from Windows.
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.
Wanpipe API Header Structure.
sangoma_status_t _LIBSNG_CALL sangoma_logger_read_event(sng_fd_t fd, wp_logger_cmd_t *logger_cmd)
Read Wanpipe Logger Events.
#define WP_API_EVENT_DISABLE
Option to disable command.
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.
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) ...
unsigned char operation_status
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.
int _LIBSNG_CALL sangoma_fe_reg_read(sng_fd_t fd, uint32_t offset, uint8_t *data)
Read front end register.
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.
wan_iovec_t iovec_list[WAN_IOVEC_LIST_LEN]
int _LIBSNG_CALL sangoma_get_cpld_version(sng_fd_t fd, wanpipe_api_t *tdm_api, unsigned char *ver)
Get AFT CPLD Version.
int _LIBSNG_CALL sangoma_flush_bufs(sng_fd_t fd, wanpipe_api_t *tdm_api)
Flush all (tx/rx/event) buffers from current channel.
int _LIBSNG_CALL sangoma_tdm_disable_hwec(sng_fd_t fd, wanpipe_api_t *tdm_api)
Disable HWEC on this channel.
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)
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
int _LIBSNG_CALL sangoma_flush_rx_bufs(sng_fd_t fd, wanpipe_api_t *tdm_api)
Flush only rx buffers from current channel.
struct wp_api_hdr wp_api_hdr_t
Wanpipe API Header Structure.