#include "libsangoma-pvt.h"
#include "libsangoma.h"

Go to the source code of this file.
Functions | |
| int | sangoma_port_mgmnt_ioctl (sng_fd_t fd, port_management_struct_t *port_management) |
| int | sangoma_port_cfg_ioctl (sng_fd_t fd, port_cfg_t *port_cfg) |
| sng_fd_t _LIBSNG_CALL | sangoma_open_driver_ctrl (int port_no) |
| Open a Global Driver Control Device. | |
| int _LIBSNG_CALL | sangoma_mgmt_cmd (sng_fd_t fd, wan_udp_hdr_t *wan_udp) |
| Execute Sangoma Management Command. | |
| int _LIBSNG_CALL | sangoma_driver_port_start (sng_fd_t fd, port_management_struct_t *port_mgmnt, unsigned short port_no) |
| Start a Port, create Sangoma Communication interfaces. | |
| int _LIBSNG_CALL | sangoma_driver_port_stop (sng_fd_t fd, port_management_struct_t *port_mgmnt, unsigned short port_no) |
| Start a Port, create Sangoma Communication interfaces. | |
| int _LIBSNG_CALL | sangoma_driver_get_hw_info (sng_fd_t fd, port_management_struct_t *port_mgmnt, unsigned short port_no) |
| Retrieve information about a single instance of Sangoma hardware. | |
| int _LIBSNG_CALL | sangoma_driver_get_version (sng_fd_t fd, port_management_struct_t *port_mgmnt, unsigned short port_no) |
| Retrieve Driver Version BEFORE any communication interface is configured and sangoma_get_driver_version() can not be called. | |
| int _LIBSNG_CALL | sangoma_driver_hw_rescan (sng_fd_t fd, port_management_struct_t *port_mgmnt, int *cnt) |
| Rescan the pci and usb bus for newly added hardware. | |
| int _LIBSNG_CALL | sangoma_driver_port_set_config (sng_fd_t fd, port_cfg_t *port_cfg, unsigned short port_no) |
| Set Port's "Volatile" configuration. The configuration will not persist between system restarts. Before calling this function please stop the port by calling sangoma_driver_port_stop(). After calling this function please start the port by calling sangoma_driver_port_start(). | |
| int _LIBSNG_CALL | sangoma_driver_port_get_config (sng_fd_t fd, port_cfg_t *port_cfg, unsigned short port_no) |
| Retrieve Port's "Volatile" configuration. | |
| int _LIBSNG_CALL | sangoma_write_port_config_on_persistent_storage (hardware_info_t *hardware_info, port_cfg_t *port_cfg, unsigned short port_no) |
Author(s): Nenad Corbic, David Rokhvarg <davidr@sangoma.com>
Copyright: (c) 2005-2011 Sangoma Technologies Corporation
* 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_config.c.
| int sangoma_port_mgmnt_ioctl | ( | sng_fd_t | fd, | |
| port_management_struct_t * | port_management | |||
| ) |
Device PORT Control Functions
Definition at line 42 of file libsangoma_config.c.
References SANG_STATUS_INVALID_DEVICE, and WANPIPE_IOCTL_PORT_MGMT.
Referenced by sangoma_driver_get_hw_info(), sangoma_driver_get_version(), sangoma_driver_hw_rescan(), sangoma_driver_port_start(), and sangoma_driver_port_stop().
00043 { 00044 int err = 0; 00045 #if defined(__WINDOWS__) 00046 DWORD ln; 00047 if(DeviceIoControl( 00048 fd, 00049 IoctlPortManagementCommand, 00050 (LPVOID)port_management, 00051 sizeof(port_management_struct_t), 00052 (LPVOID)port_management, 00053 sizeof(port_management_struct_t), 00054 (LPDWORD)(&ln), 00055 (LPOVERLAPPED)NULL 00056 ) == FALSE){ 00057 /* Call OS specific code to find cause of the error and check messages log. */ 00058 DBG_ERR("%s():Error: IoctlPortManagementCommand failed!!\n", __FUNCTION__); 00059 err = -1; 00060 } 00061 #else 00062 err=ioctl(fd,WANPIPE_IOCTL_PORT_MGMT,port_management); 00063 if (err) { 00064 err = -1; 00065 } 00066 #endif 00067 if(err){ 00068 port_management->operation_status = SANG_STATUS_INVALID_DEVICE; 00069 } 00070 00071 return err; 00072 }

| sng_fd_t sangoma_open_driver_ctrl | ( | int | port_no | ) |
Open a Global Driver Control Device.
Definition at line 107 of file libsangoma_config.c.
References _snprintf, FNAME_LEN, sangoma_open_dev_by_name(), and WP_PORT_NAME_FORM.
00108 { 00109 char tmp_fname[FNAME_LEN]; 00110 00111 #if defined(__WINDOWS__) 00112 /* Form the Config Device Name (i.e. wanpipe1, wanpipe2,...). */ 00113 _snprintf(tmp_fname, DEV_NAME_LEN, WP_PORT_NAME_FORM, port_no); 00114 #else 00115 /* Form the Config Device Name. ("/dev/wanpipe") */ 00116 _snprintf(tmp_fname, DEV_NAME_LEN, WP_CONFIG_DEV_NAME); 00117 #endif 00118 return sangoma_open_dev_by_name(tmp_fname); 00119 }

| int sangoma_mgmt_cmd | ( | sng_fd_t | fd, | |
| wan_udp_hdr_t * | wan_udp | |||
| ) |
Execute Sangoma Management Command.
Device MANAGEMENT Functions
| fd | device file descriptor | |
| wan_udp | management command structure |
Definition at line 122 of file libsangoma_config.c.
References WANPIPE_IOCTL_PIPEMON.
Referenced by sangoma_fe_reg_read(), sangoma_fe_reg_write(), sangoma_get_aft_customer_id(), and sangoma_port_led_ctrl().
00123 { 00124 int err=0; 00125 #if defined(__WINDOWS__) 00126 if(UdpManagementCommand(fd, wan_udp)){ 00127 err = 1; 00128 } 00129 #else 00130 unsigned char id = 0; 00131 00132 wan_udp->wan_udphdr_request_reply = 0x01; 00133 wan_udp->wan_udphdr_id = id; 00134 wan_udp->wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD; 00135 00136 err=ioctl(fd,WANPIPE_IOCTL_PIPEMON,wan_udp); 00137 if (err < 0) { 00138 err = 1; 00139 } 00140 #endif 00141 if(err){ 00142 /* The ioctl failed. */ 00143 return err; 00144 } 00145 00146 /* The ioctl was successfull. The caller must check 00147 * value of wan_udp->wan_udphdr_return_code. */ 00148 return 0; 00149 }

| int sangoma_driver_port_start | ( | sng_fd_t | fd, | |
| port_management_struct_t * | port_mgmnt, | |||
| unsigned short | port_no | |||
| ) |
Start a Port, create Sangoma Communication interfaces.
Device PORT Control Functions
| [in] | fd | Port Device file descriptor |
| [out] | port_mgmnt | pointer to a port_management_struct_t structure. On return, sangoma_driver_port_start() updates operation_status field of this structure. |
| [in] | port_no | 1-based Port Number. Port numbers correspond to Port Names. For example, a 2-Port card will have ports named WANPIPE1 and WANPIPE2. |
Definition at line 151 of file libsangoma_config.c.
References SANG_STATUS_GENERAL_ERROR, and sangoma_port_mgmnt_ioctl().
00152 { 00153 int err; 00154 port_mgmnt->operation_status = SANG_STATUS_GENERAL_ERROR; 00155 port_mgmnt->command_code = START_PORT_VOLATILE_CONFIG; 00156 port_mgmnt->port_no = port_no; 00157 00158 err = sangoma_port_mgmnt_ioctl(fd, port_mgmnt); 00159 if (err) { 00160 /* ioctl failed */ 00161 return err; 00162 } 00163 00164 return port_mgmnt->operation_status; 00165 }

| int sangoma_driver_port_stop | ( | sng_fd_t | fd, | |
| port_management_struct_t * | port_mgmnt, | |||
| unsigned short | port_no | |||
| ) |
Start a Port, create Sangoma Communication interfaces.
| [in] | fd | Port Device file descriptor |
| [out] | port_mgmnt | pointer to a port_management_struct_t structure. On return, sangoma_driver_port_stop() updates operation_status field of this structure. |
| [in] | port_no | 1-based Port Number. Port numbers correspond to Port Names. For example, a 2-Port card will have ports named WANPIPE1 and WANPIPE2. |
Definition at line 167 of file libsangoma_config.c.
References SANG_STATUS_CAN_NOT_STOP_DEVICE_WHEN_ALREADY_STOPPED, SANG_STATUS_GENERAL_ERROR, SANG_STATUS_SUCCESS, and sangoma_port_mgmnt_ioctl().
00168 { 00169 int err; 00170 port_mgmnt->operation_status = SANG_STATUS_GENERAL_ERROR; 00171 port_mgmnt->command_code = STOP_PORT; 00172 port_mgmnt->port_no = port_no; 00173 00174 err = sangoma_port_mgmnt_ioctl(fd, port_mgmnt); 00175 if (err) { 00176 /* ioctl failed */ 00177 return err; 00178 } 00179 00180 switch(port_mgmnt->operation_status) 00181 { 00182 case SANG_STATUS_CAN_NOT_STOP_DEVICE_WHEN_ALREADY_STOPPED: 00183 /* This is not an error, rather a state indication. 00184 * Return SANG_STATUS_SUCCESS, but real return code will be available 00185 * for the caller at port_mgmnt->operation_status. */ 00186 err = SANG_STATUS_SUCCESS; 00187 break; 00188 default: 00189 err = port_mgmnt->operation_status; 00190 break; 00191 } 00192 00193 return err; 00194 }

| int sangoma_driver_get_hw_info | ( | sng_fd_t | fd, | |
| port_management_struct_t * | port_mgmnt, | |||
| unsigned short | port_no | |||
| ) |
Retrieve information about a single instance of Sangoma hardware.
| [in] | fd | Port Device file descriptor |
| [out] | port_mgmnt | pointer to port_management_struct_t structure which will contain hardware_info_t at it's "data" field, when this function returns. |
| [in] | port_no | please see comment of sangoma_driver_port_set_config() |
Definition at line 196 of file libsangoma_config.c.
References SANG_STATUS_GENERAL_ERROR, and sangoma_port_mgmnt_ioctl().
00197 { 00198 int err; 00199 port_mgmnt->operation_status = SANG_STATUS_GENERAL_ERROR; 00200 port_mgmnt->command_code = GET_HARDWARE_INFO; 00201 port_mgmnt->port_no = port_no; 00202 00203 err = sangoma_port_mgmnt_ioctl(fd, port_mgmnt); 00204 if (err) { 00205 return err; 00206 } 00207 00208 return port_mgmnt->operation_status; 00209 }

| int sangoma_driver_get_version | ( | sng_fd_t | fd, | |
| port_management_struct_t * | port_mgmnt, | |||
| unsigned short | port_no | |||
| ) |
Retrieve Driver Version BEFORE any communication interface is configured and sangoma_get_driver_version() can not be called.
| [in] | fd | Port Device file descriptor |
| [out] | port_mgmnt | pointer to port_management_struct_t structure which will contain wan_driver_version_t at it's "data" field, when this function returns. |
| [in] | port_no | please see comment of sangoma_driver_port_set_config() |
Definition at line 211 of file libsangoma_config.c.
References sangoma_port_mgmnt_ioctl().
00212 { 00213 int err; 00214 port_mgmnt->command_code = GET_DRIVER_VERSION; 00215 port_mgmnt->port_no = port_no; 00216 00217 err = sangoma_port_mgmnt_ioctl(fd, port_mgmnt); 00218 if (err) { 00219 return err; 00220 } 00221 00222 return port_mgmnt->operation_status; 00223 }

| int sangoma_driver_hw_rescan | ( | sng_fd_t | fd, | |
| port_management_struct_t * | port_mgmnt, | |||
| int * | detected_port_cnt | |||
| ) |
Rescan the pci and usb bus for newly added hardware.
| [in] | fd | Port Device file descriptor |
| [out] | port_mgmnt | pointer to port_management_struct_t structure which will contain wan_driver_version_t at it's "data" field, when this function returns. |
| [out] | detected_port_cnt | newly detected ports. |
Definition at line 226 of file libsangoma_config.c.
References sangoma_port_mgmnt_ioctl().
00227 { 00228 int err; 00229 port_mgmnt->command_code = WANPIPE_HARDWARE_RESCAN; 00230 port_mgmnt->port_no = 1; 00231 00232 err = sangoma_port_mgmnt_ioctl(fd, port_mgmnt); 00233 if (err < 0) { 00234 return err; 00235 } 00236 00237 *cnt=port_mgmnt->port_no; 00238 00239 return port_mgmnt->operation_status; 00240 }

| int sangoma_driver_port_set_config | ( | sng_fd_t | fd, | |
| port_cfg_t * | port_cfg, | |||
| unsigned short | port_no | |||
| ) |
Set Port's "Volatile" configuration. The configuration will not persist between system restarts. Before calling this function please stop the port by calling sangoma_driver_port_stop(). After calling this function please start the port by calling sangoma_driver_port_start().
| [in] | fd | Port Device file descriptor |
| [in,out] | port_cfg | pointer to port_cfg_t structure that specifies complete Port configuration. On return, sangoma_driver_port_set_config() updates operation_status field of this structure. |
| [in] | port_no | 1-based Port Number. Port numbers correspond to Port Names. For example, a 2-Port card will have ports named WANPIPE1 and WANPIPE2. |
Definition at line 244 of file libsangoma_config.c.
References SANG_STATUS_GENERAL_ERROR.
00245 { 00246 port_cfg->operation_status = SANG_STATUS_GENERAL_ERROR; 00247 port_cfg->command_code = SET_PORT_VOLATILE_CONFIG; 00248 port_cfg->port_no = port_no; 00249 00250 return sangoma_port_cfg_ioctl(fd, port_cfg); 00251 }
| int sangoma_driver_port_get_config | ( | sng_fd_t | fd, | |
| port_cfg_t * | port_cfg, | |||
| unsigned short | port_no | |||
| ) |
Retrieve Port's "Volatile" configuration.
| [in] | fd | Port Device file descriptor |
| [out] | port_cfg | pointer to port_cfg_t structure. On return, sangoma_driver_port_get_config() will copy current Port configuration into this structure. |
| [in] | port_no | please see comment of sangoma_driver_port_set_config() |
Definition at line 253 of file libsangoma_config.c.
References SANG_STATUS_GENERAL_ERROR.
00254 { 00255 port_cfg->operation_status = SANG_STATUS_GENERAL_ERROR; 00256 port_cfg->command_code = GET_PORT_VOLATILE_CONFIG; 00257 port_cfg->port_no = port_no; 00258 return sangoma_port_cfg_ioctl(fd, port_cfg); 00259 }
1.5.6