wanpipe_api_iface.h

Go to the documentation of this file.
00001 /******************************************************************************/
00035 #ifndef __WANPIPE_API_IFACE_H_
00036 #define __WANPIPE_API_IFACE_H_
00037 
00038 #include "wanpipe_api_hdr.h"
00039 
00044 #if defined(__WINDOWS__)
00045 typedef HANDLE sng_fd_t;
00046 #else
00047 typedef int sng_fd_t;
00048 #endif
00049 
00050 /* Indicate to library that new features exist */
00061 #define WP_API_FEATURE_DTMF_EVENTS  1
00062 #define WP_API_FEATURE_FE_ALARM     1
00063 #define WP_API_FEATURE_EVENTS       1
00064 #define WP_API_FEATURE_LINK_STATUS  1
00065 
00066 
00074 enum WANPIPE_IOCTL_CODE {
00075     WANPIPE_IOCTL_WRITE=1,              
00076     WANPIPE_IOCTL_READ,                 
00077     WANPIPE_IOCTL_MGMT,                 
00078     WANPIPE_IOCTL_SET_IDLE_TX_BUFFER,   
00079     WANPIPE_IOCTL_API_POLL,             
00080     WANPIPE_IOCTL_SET_SHARED_EVENT,     
00081     WANPIPE_IOCTL_PORT_MGMT,            
00082     WANPIPE_IOCTL_PORT_CONFIG,          
00083     WANPIPE_IOCTL_API_CMD,              
00084     WANPIPE_IOCTL_PIPEMON,              
00085     WANPIPE_IOCTL_SNMP,                 
00086     WANPIPE_IOCTL_SNMP_IFSPEED,         
00087     WANPIPE_IOCTL_DEVEL                 
00088 };
00089 
00090 
00095 enum WANPIPE_IOCTL_PIPEMON_CMDS {
00096     WANPIPEMON_ROUTER_UP_TIME = 0x50,       
00097     WANPIPEMON_ENABLE_TRACING,              
00098     WANPIPEMON_DISABLE_TRACING,             
00099     WANPIPEMON_GET_TRACE_INFO,              
00100     WANPIPEMON_READ_CODE_VERSION,           
00101     WANPIPEMON_FLUSH_OPERATIONAL_STATS,     
00102     WANPIPEMON_OPERATIONAL_STATS,           
00103     WANPIPEMON_READ_OPERATIONAL_STATS,      
00104     WANPIPEMON_READ_CONFIGURATION,          
00105     WANPIPEMON_READ_COMMS_ERROR_STATS,      
00106     WANPIPEMON_FLUSH_COMMS_ERROR_STATS,     
00107     WANPIPEMON_AFT_LINK_STATUS,             
00108     WANPIPEMON_AFT_MODEM_STATUS,            
00109     WANPIPEMON_AFT_HWEC_STATUS,             
00110     WANPIPEMON_DIGITAL_LOOPTEST,            
00111     WANPIPEMON_SET_FT1_MODE,                
00113     WANPIPEMON_GET_OPEN_HANDLES_COUNTER,    
00114     WANPIPEMON_GET_CARD_TYPE,               
00115     WANPIPEMON_API_NOT_USED,                
00116     WANPIPEMON_GET_HW_MAC_ADDR,             
00117     WANPIPEMON_FLUSH_TX_BUFFERS,            
00118     WANPIPEMON_WAN_EC_IOCTL,                
00119     WANPIPEMON_WAN_SET_RBS_BITS,            
00120     WANPIPEMON_WAN_GET_RBS_BITS,            
00121     WANPIPEMON_AFT_CUSTOMER_ID,             
00122     WANPIPEMON_FT1_READ_STATUS,             
00124     WANPIPEMON_DRIVER_STAT_IFSEND,          
00125     WANPIPEMON_DRIVER_STAT_INTR,            
00126     WANPIPEMON_DRIVER_STAT_GEN,             
00127     WANPIPEMON_FLUSH_DRIVER_STATS,          
00128     WANPIPEMON_GET_IBA_DATA,                
00129     WANPIPEMON_TDM_API,                     
00131     WANPIPEMON_PROTOCOL_PRIVATE             
00132 };
00133 
00134 
00139 enum wanpipe_api_cmds
00140 {
00141 
00142     WP_API_CMD_GET_USR_MTU_MRU,         
00143     WP_API_CMD_SET_USR_PERIOD,      
00144     WP_API_CMD_GET_USR_PERIOD,      
00145     WP_API_CMD_SET_HW_MTU_MRU,      
00146     WP_API_CMD_GET_HW_MTU_MRU,      
00147     WP_API_CMD_SET_CODEC,           
00148     WP_API_CMD_GET_CODEC,           
00149     WP_API_CMD_SET_POWER_LEVEL,     
00150     WP_API_CMD_GET_POWER_LEVEL,         
00151     WP_API_CMD_TOGGLE_RX,           
00152     WP_API_CMD_TOGGLE_TX,           
00153     WP_API_CMD_GET_HW_CODING,       
00154     WP_API_CMD_SET_HW_CODING,       
00155     WP_API_CMD_GET_FULL_CFG,            
00156     WP_API_CMD_SET_EC_TAP,              
00157     WP_API_CMD_GET_EC_TAP,              
00158     WP_API_CMD_ENABLE_RBS_EVENTS,   
00159     WP_API_CMD_DISABLE_RBS_EVENTS,  
00160     WP_API_CMD_WRITE_RBS_BITS,      
00161     WP_API_CMD_READ_RBS_BITS,       
00162     WP_API_CMD_GET_STATS,           
00163     WP_API_CMD_FLUSH_BUFFERS,       
00164     WP_API_CMD_FLUSH_TX_BUFFERS,    
00165     WP_API_CMD_FLUSH_RX_BUFFERS,    
00166     WP_API_CMD_FLUSH_EVENT_BUFFERS, 
00167     WP_API_CMD_READ_EVENT,          
00168     WP_API_CMD_SET_EVENT,           
00169     WP_API_CMD_SET_RX_GAINS,            
00170     WP_API_CMD_SET_TX_GAINS,            
00171     WP_API_CMD_CLEAR_RX_GAINS,      
00172     WP_API_CMD_CLEAR_TX_GAINS,      
00173     WP_API_CMD_GET_FE_ALARMS,       
00174     WP_API_CMD_ENABLE_HWEC,         
00175     WP_API_CMD_DISABLE_HWEC,            
00176     WP_API_CMD_SET_FE_STATUS,       
00177     WP_API_CMD_GET_FE_STATUS,       
00178     WP_API_CMD_GET_HW_DTMF,         
00179     WP_API_CMD_DRV_MGMNT,           
00180     WP_API_CMD_RESET_STATS,         
00181     WP_API_CMD_DRIVER_VERSION,      
00182     WP_API_CMD_FIRMWARE_VERSION,    
00183     WP_API_CMD_CPLD_VERSION,        
00184     WP_API_CMD_OPEN_CNT,            
00186     WP_API_CMD_NOTSUPP              
00187 };
00188 
00189 
00190 
00203 enum wanpipe_api_events
00204 {
00205     WP_API_EVENT_NONE,              
00206     WP_API_EVENT_RBS,               
00207     WP_API_EVENT_ALARM,             
00208     WP_API_EVENT_DTMF,              
00209     WP_API_EVENT_RM_DTMF,           
00210     WP_API_EVENT_RXHOOK,                
00211     WP_API_EVENT_RING,              
00212     WP_API_EVENT_RING_DETECT,       
00213     WP_API_EVENT_RING_TRIP_DETECT,  
00214     WP_API_EVENT_TONE,              
00215     WP_API_EVENT_TXSIG_KEWL,            
00216     WP_API_EVENT_TXSIG_START,       
00217     WP_API_EVENT_TXSIG_OFFHOOK,     
00218     WP_API_EVENT_TXSIG_ONHOOK,      
00219     WP_API_EVENT_ONHOOKTRANSFER,        
00220     WP_API_EVENT_SETPOLARITY,       
00221     WP_API_EVENT_BRI_CHAN_LOOPBACK, 
00222     WP_API_EVENT_LINK_STATUS,       
00223     WP_API_EVENT_MODEM_STATUS       
00224 };
00225 
00226 
00227 
00236 #define WP_API_EVENT_ENABLE     0x01
00237 #define WP_API_EVENT_DISABLE        0x02
00238 #define WP_API_EVENT_MODE_DECODE(mode)              \
00239         ((mode) == WP_API_EVENT_ENABLE) ? "Enable" :    \
00240         ((mode) == WP_API_EVENT_DISABLE) ? "Disable" :  \
00241                         "(Unknown mode)"
00242 
00253 #define WPTDM_A_BIT             WAN_RBS_SIG_A
00254 #define WPTDM_B_BIT             WAN_RBS_SIG_B
00255 #define WPTDM_C_BIT             WAN_RBS_SIG_C
00256 #define WPTDM_D_BIT             WAN_RBS_SIG_D
00257 
00258 
00267 #define WP_API_EVENT_RXHOOK_OFF 0x01
00268 #define WP_API_EVENT_RXHOOK_ON  0x02
00269 #define WP_API_EVENT_RXHOOK_DECODE(state)               \
00270         ((state) == WP_API_EVENT_RXHOOK_OFF) ? "Off-hook" : \
00271         ((state) == WP_API_EVENT_RXHOOK_ON) ? "On-hook" :   \
00272                         "(Unknown state)"
00273 
00281 #define WP_API_EVENT_RING_PRESENT   0x01
00282 #define WP_API_EVENT_RING_STOP  0x02
00283 #define WP_API_EVENT_RING_DECODE(state)             \
00284         ((state) == WP_API_EVENT_RING_PRESENT) ? "Ring Present" :   \
00285         ((state) == WP_API_EVENT_RING_STOP) ? "Ring Stop" : \
00286                         "(Unknown state)"
00287 
00296 #define WP_API_EVENT_RING_TRIP_PRESENT  0x01
00297 #define WP_API_EVENT_RING_TRIP_STOP 0x02
00298 #define WP_API_EVENT_RING_TRIP_DECODE(state)                \
00299         ((state) == WP_API_EVENT_RING_TRIP_PRESENT) ? "Ring Present" :  \
00300         ((state) == WP_API_EVENT_RING_TRIP_STOP) ? "Ring Stop" :    \
00301                         "(Unknown state)"
00302 /*Link Status */
00311 #define WP_API_EVENT_LINK_STATUS_CONNECTED      0x01
00312 #define WP_API_EVENT_LINK_STATUS_DISCONNECTED   0x02
00313 #define WP_API_EVENT_LINK_STATUS_DECODE(status)                 \
00314         ((status) == WP_API_EVENT_LINK_STATUS_CONNECTED) ? "Connected" :        \
00315         ((status) == WP_API_EVENT_LINK_STATUS_DISCONNECTED)  ? "Disconnected" :     \
00316                             "Unknown"
00317 
00328 #define WP_API_EVENT_TONE_DIAL  0x01
00329 #define WP_API_EVENT_TONE_BUSY  0x02
00330 #define WP_API_EVENT_TONE_RING  0x03
00331 #define WP_API_EVENT_TONE_CONGESTION    0x04
00332 
00333 /* BRI channels list */
00342 #define WAN_BRI_BCHAN1      0x01
00343 #define WAN_BRI_BCHAN2      0x02
00344 #define WAN_BRI_DCHAN       0x03
00345 
00346 #pragma pack(1)
00347 
00348 
00355 typedef struct wanpipe_chan_stats
00356 {
00357     unsigned int    rx_packets;     /* total packets received   */
00358     unsigned int    tx_packets;     /* total packets transmitted    */
00359     unsigned int    rx_bytes;       /* total bytes received     */
00360     unsigned int    tx_bytes;       /* total bytes transmitted  */
00361     unsigned int    rx_errors;      /* bad packets received     */
00362     unsigned int    tx_errors;      /* packet transmit problems */
00363     unsigned int    rx_dropped;     /* no space in linux buffers    */
00364     unsigned int    tx_dropped;     /* no space available in linux  */
00365     unsigned int    multicast;      /* multicast packets received   */
00366     unsigned int    collisions;
00367 
00368     /* detailed rx_errors: */
00369     unsigned int    rx_length_errors;
00370     unsigned int    rx_over_errors;     /* receiver ring buff overflow  */
00371     unsigned int    rx_crc_errors;      /* recved pkt with crc error    */
00372     unsigned int    rx_frame_errors;    /* recv'd frame alignment error */
00373     unsigned int    rx_fifo_errors;     /* recv'r fifo overrun      */
00374     unsigned int    rx_missed_errors;   /* receiver missed packet   */
00375 
00376     /* detailed tx_errors */
00377     unsigned int    tx_aborted_errors;
00378     unsigned int    tx_carrier_errors;  /* trunsmitter underrun error counter */
00379 
00380     unsigned int    tx_fifo_errors;
00381     unsigned int    tx_heartbeat_errors;
00382     unsigned int    tx_window_errors;
00383 
00384     unsigned int    tx_idle_packets;
00385 
00386     unsigned int    errors;
00387 
00388     unsigned int    current_number_of_frames_in_tx_queue;
00389     unsigned int    max_tx_queue_length;
00390 
00391     unsigned int    current_number_of_frames_in_rx_queue;
00392     unsigned int    max_rx_queue_length;
00393     
00394 }wanpipe_chan_stats_t;
00395 
00396 
00397 #define WP_AFT_CHAN_ERROR_STATS(chan,var) chan->chan_stats.var++;chan->chan_stats.errors++
00398 
00408 typedef struct wanpipe_api_dev_cfg
00409 {
00410         unsigned int hw_tdm_coding; /* Set/Get HW TDM coding: uLaw muLaw */
00411         unsigned int hw_mtu_mru;    /* Set/Get HW TDM MTU/MRU */
00412         unsigned int usr_period;    /* Set/Get User Period in ms */
00413         unsigned int tdm_codec;     /* Set/Get TDM Codec: SLinear */
00414         unsigned int power_level;   /* Set/Get Power level treshold */
00415         unsigned int rx_disable;    /* Enable/Disable Rx */
00416         unsigned int tx_disable;    /* Enable/Disable Tx */
00417         unsigned int usr_mtu_mru;   /* Set/Get User TDM MTU/MRU */
00418         unsigned int ec_tap;        /* Echo Cancellation Tap */
00419         unsigned int rbs_poll;      /* Enable/Disable RBS Polling */
00420         unsigned int rbs_rx_bits;   /* Rx RBS Bits */
00421         unsigned int rbs_tx_bits;   /* Tx RBS Bits */
00422         unsigned int hdlc;          /* HDLC based device */
00423         unsigned int idle_flag;     /* IDLE flag to Tx */
00424         unsigned int fe_alarms;     /* FE Alarms detected */
00425         unsigned char fe_status;    /* FE status - Connected or Disconnected */
00426         unsigned int hw_dtmf;       /* HW DTMF enabled */
00427         unsigned char open_cnt;     /* Open cnt */
00428         /* Duplicate the structure below */
00429         wanpipe_chan_stats_t stats; /* TDM Statistics */
00430 }wanpipe_api_dev_cfg_t;
00431 
00432 
00433 #define WANPIPE_API_CMD_SZ 512
00434 /* The the union size is max-cmd-result-span-chan-data_len */
00435 #define WANPIPE_API_CMD_SZ_UNION  WANPIPE_API_CMD_SZ - (sizeof(unsigned int)*3) - (sizeof(unsigned char)*2)
00436 
00448 typedef struct wanpipe_api_cmd
00449 {
00450     unsigned int cmd;       
00451     unsigned int result;    
00452     unsigned char span;     
00453     unsigned char chan;     
00455     union {
00456         struct {
00457             unsigned int hw_tdm_coding; 
00458             unsigned int hw_mtu_mru;    
00459             unsigned int usr_period;    
00460             unsigned int tdm_codec;     
00461             unsigned int power_level;   
00462             unsigned int rx_disable;    
00463             unsigned int tx_disable;    
00464             unsigned int usr_mtu_mru;   
00465             unsigned int ec_tap;        
00466             unsigned int rbs_poll;      
00467             unsigned int rbs_rx_bits;   
00468             unsigned int rbs_tx_bits;   
00469             unsigned int hdlc;          
00470             unsigned int idle_flag;     
00471             unsigned int fe_alarms;     
00472             unsigned char fe_status;    
00473             unsigned int  hw_dtmf;      
00474             unsigned char open_cnt;     
00475             wanpipe_chan_stats_t stats; 
00476         };
00477         wp_api_event_t event;   
00479         struct {
00480             unsigned char data[WANPIPE_API_CMD_SZ_UNION];
00481             unsigned int data_len;
00482         };
00483     };
00484 }wanpipe_api_cmd_t;
00485 
00492 typedef struct wanpipe_api_callbacks
00493 {
00494     int (*wp_rbs_event)(sng_fd_t fd, unsigned char rbs_bits);
00495     int (*wp_dtmf_event)(sng_fd_t fd, unsigned char dtmf, unsigned char type, unsigned char port);
00496     int (*wp_rxhook_event)(sng_fd_t fd, unsigned char hook_state);
00497     int (*wp_ring_detect_event)(sng_fd_t fd, unsigned char ring_state);
00498     int (*wp_ring_trip_detect_event)(sng_fd_t fd, unsigned char ring_state);
00499     int (*wp_fe_alarm_event)(sng_fd_t fd, unsigned int fe_alarm_event);
00500     int (*wp_link_status_event)(sng_fd_t fd, unsigned int link_status_event);
00501 }wanpipe_api_callbacks_t;
00502 
00513 typedef struct wanpipe_api
00514 {
00515     wanpipe_api_cmd_t   wp_cmd;         
00516     wanpipe_api_callbacks_t wp_callback;    
00517 }wanpipe_api_t;
00518 
00519 #pragma pack()
00520 
00521 
00522 /***************************************************/
00525 #endif

Generated on Tue Jan 6 18:07:39 2009 for sample_c by  doxygen 1.4.7