libsangoma.h

Go to the documentation of this file.
00001 /*******************************************************************************/
00036 #ifndef _LIBSNAGOMA_H
00037 #define _LIBSNAGOMA_H
00038 
00039 #ifdef __cplusplus
00040 extern "C" {    /* for C++ users */
00041 #endif
00042 
00043 #include <stdio.h>
00044 
00049 #define WANPIPE_TDM_API 1
00050 
00051 #ifdef WIN32
00052 #ifndef __WINDOWS__
00053 #define __WINDOWS__
00054 #endif
00055 #include <windows.h>
00056 #include <winioctl.h>
00057 #include <conio.h>
00058 #include <stddef.h> 
00059 #include <stdlib.h> 
00060 #include <wanpipe_api.h>
00061 
00062 #define _MYDEBUG
00063 #define PROGRAM_NAME "LIBSANGOMA: "
00064 #include <DebugOut.h>
00065 
00070 #define _SAPI_CALL  __cdecl
00071 #define SANGOMA_INFINITE_API_POLL_WAIT INFINITE
00072 
00077 #define sangoma_msleep(x)   Sleep(x)
00078 
00079 #else
00080 /* L I N U X */
00081 #include <stdlib.h>
00082 #include <stdarg.h>
00083 #include <ctype.h>
00084 #include <unistd.h>
00085 #include <sys/time.h>
00086 #include <sys/socket.h>
00087 #include <sys/ioctl.h>
00088 #include <sys/types.h>
00089 #include <sys/signal.h>
00090 #include <sys/select.h>
00091 #include <sys/wait.h>
00092 #include <sys/resource.h>
00093 #include <netinet/in.h>
00094 #include <string.h>
00095 #include <errno.h>
00096 #include <fcntl.h>
00097 #include <net/if.h>
00098 #include <poll.h>
00099 #include <signal.h>
00100 
00101 #include "wanpipe_api.h"
00102 
00107 #define _SAPI_CALL
00108 
00113 #define INVALID_HANDLE_VALUE -1
00114 
00119 #define SANGOMA_INFINITE_API_POLL_WAIT 0
00120 
00159 #define __cdecl
00160 #define BOOL        int
00161 #define DWORD       int
00162 #define FALSE       0
00163 #define TRUE        1
00164 #define sangoma_msleep(x) usleep(x*1000)
00165 #define _getch      getchar
00166 #define Sleep       sangoma_msleep
00167 #define HANDLE      int
00168 #define TCHAR       char
00169 #define ULONG       unsigned long
00170 #define UCHAR       unsigned char
00171 #define USHORT      unsigned short
00172 #define LPSTR       unsigned char *
00173 #define PUCHAR      unsigned char *
00174 #define LPTHREAD_START_ROUTINE void *
00175 #define _stricmp    strcmp
00176 #define _snprintf   snprintf
00177 #define _vsnprintf      vsnprintf
00178 
00179 
00180                
00181 #endif/* WIN32 */
00182 
00191 #define FNAME_LEN       100
00192 #define FUNC_DBG(x)     if(0)printf("%s():%d\n", x, __LINE__)
00193 #define DBG_PRINT       if(1)printf
00194 
00199 typedef wp_api_hdr_t sangoma_api_hdr_t;
00200 
00211 typedef struct sangoma_wait_obj
00212 {
00213 
00214    /***************************************/
00219     sng_fd_t        fd;
00221     uint32_t        flags_in;
00223     uint32_t        timeout;
00224 
00225 #if defined(WIN32)
00226 
00227     OVERLAPPED      OverlappedApiPoll;
00229     API_POLL_STRUCT api_poll;
00230 #endif
00231 
00233     uint32_t        object_type;
00234 
00235    /***************************************/
00240     uint32_t        flags_out;
00242     uint32_t        span;
00244     uint32_t        chan;
00245 
00246 }sangoma_wait_obj_t;
00247 
00254 typedef enum _sangoma_object_type
00255 {
00256     UNKNOWN_WAIT_OBJ,
00257     SANGOMA_WAIT_OBJ    
00258 }sangoma_object_type_t;
00259 
00260 /************************************************************/
00273 sng_fd_t _SAPI_CALL sangoma_open_api_span_chan(int span, int chan);
00274 
00275 
00285 sng_fd_t _SAPI_CALL __sangoma_open_api_span_chan(int span, int chan);
00286 #define __sangoma_open_tdmapi_span_chan __sangoma_open_api_span_chan
00287 
00296 sng_fd_t _SAPI_CALL sangoma_open_api_span(int span);
00297 
00298 
00310 #ifndef LIBSANGOMA_TDMAPI_CTRL
00311 #define LIBSANGOMA_TDMAPI_CTRL 1
00312 #endif
00313 
00322 sng_fd_t sangoma_open_api_ctrl(void);
00323 
00324 
00332 void _SAPI_CALL sangoma_close(sng_fd_t *fd);
00333 
00334 
00335 /************************************************************/
00354 int _SAPI_CALL sangoma_writemsg(sng_fd_t fd, void *hdrbuf, int hdrlen,
00355                          void *databuf, unsigned short datalen, int flag);
00356 
00357 
00372 int _SAPI_CALL sangoma_readmsg(sng_fd_t fd, void *hdrbuf, int hdrlen,
00373                         void *databuf, int datalen, int flag);
00374 
00375 
00376 
00377 
00378 /************************************************************/
00391 int _SAPI_CALL sangoma_socket_waitfor(sng_fd_t fd, int timeout, int flags_in, unsigned int *flags_out);
00392 
00401 int _SAPI_CALL sangoma_socket_waitfor_many(sangoma_wait_obj_t sangoma_wait_objects[],
00402                                            int number_of_sangoma_wait_objects,
00403                                            uint32_t system_wait_timeout);
00404 
00417 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);
00418 
00419 
00426 void _SAPI_CALL sangoma_release_wait_obj(sangoma_wait_obj_t *sng_wait_obj);
00427 
00434 void _SAPI_CALL sangoma_signal_wait_obj(sangoma_wait_obj_t *sng_wait_obj);
00435 
00436 
00437 /************************************************************/
00452 int _SAPI_CALL sangoma_read_event(sng_fd_t fd, wanpipe_api_t *tdm_api);
00453 
00454 
00462 int _SAPI_CALL sangoma_mgmt_cmd(sng_fd_t fd, wan_udp_hdr_t* wan_udp);
00463 
00471 int _SAPI_CALL sangoma_cmd_exec(sng_fd_t fd, wanpipe_api_t *tdm_api);
00472 
00473 
00481 int _SAPI_CALL sangoma_get_full_cfg(sng_fd_t fd, wanpipe_api_t *tdm_api);
00482 
00493 int _SAPI_CALL sangoma_tdm_set_usr_period(sng_fd_t fd, wanpipe_api_t *tdm_api, int period);
00494 
00502 int _SAPI_CALL sangoma_tdm_get_usr_period(sng_fd_t fd, wanpipe_api_t *tdm_api);
00503 
00511 int _SAPI_CALL sangoma_tdm_get_usr_mtu_mru(sng_fd_t fd, wanpipe_api_t *tdm_api);
00512 
00513 
00522 int _SAPI_CALL sangoma_flush_bufs(sng_fd_t fd, wanpipe_api_t *tdm_api);
00523 
00524 
00533 int _SAPI_CALL sangoma_tdm_enable_rbs_events(sng_fd_t fd, wanpipe_api_t *tdm_api, int poll_in_sec);
00534 
00542 int _SAPI_CALL sangoma_tdm_disable_rbs_events(sng_fd_t fd, wanpipe_api_t *tdm_api);
00543 
00552 int _SAPI_CALL sangoma_tdm_write_rbs(sng_fd_t fd, wanpipe_api_t *tdm_api, unsigned char rbs);
00553 
00554 
00564 int _SAPI_CALL sangoma_tdm_enable_dtmf_events(sng_fd_t fd, wanpipe_api_t *tdm_api);
00565 
00575 int _SAPI_CALL sangoma_tdm_disable_dtmf_events(sng_fd_t fd, wanpipe_api_t *tdm_api);
00576 
00577 
00587 int _SAPI_CALL sangoma_tdm_enable_rm_dtmf_events(sng_fd_t fd, wanpipe_api_t *tdm_api);
00588 
00598 int _SAPI_CALL sangoma_tdm_disable_rm_dtmf_events(sng_fd_t fd, wanpipe_api_t *tdm_api);
00599 
00609 int _SAPI_CALL sangoma_tdm_enable_rxhook_events(sng_fd_t fd, wanpipe_api_t *tdm_api);
00610 
00620 int _SAPI_CALL sangoma_tdm_disable_rxhook_events(sng_fd_t fd, wanpipe_api_t *tdm_api);
00621 
00631 int _SAPI_CALL sangoma_tdm_enable_ring_events(sng_fd_t fd, wanpipe_api_t *tdm_api);
00632 
00642 int _SAPI_CALL sangoma_tdm_disable_ring_events(sng_fd_t fd, wanpipe_api_t *tdm_api);
00643 
00644 
00654 int _SAPI_CALL sangoma_tdm_enable_ring_detect_events(sng_fd_t fd, wanpipe_api_t *tdm_api);
00655 
00665 int _SAPI_CALL sangoma_tdm_disable_ring_detect_events(sng_fd_t fd, wanpipe_api_t *tdm_api);
00666 
00676 int _SAPI_CALL sangoma_tdm_enable_ring_trip_detect_events(sng_fd_t fd, wanpipe_api_t *tdm_api);
00677 
00687 int _SAPI_CALL sangoma_tdm_disable_ring_trip_detect_events(sng_fd_t fd, wanpipe_api_t *tdm_api);
00688 
00699 int _SAPI_CALL sangoma_tdm_enable_tone_events(sng_fd_t fd, wanpipe_api_t *tdm_api, uint16_t tone_id);
00700 
00710 int _SAPI_CALL sangoma_tdm_disable_tone_events(sng_fd_t fd, wanpipe_api_t *tdm_api);
00711 
00721 int _SAPI_CALL sangoma_tdm_txsig_onhook(sng_fd_t fd, wanpipe_api_t *tdm_api);
00722 
00732 int _SAPI_CALL sangoma_tdm_txsig_offhook(sng_fd_t fd, wanpipe_api_t *tdm_api);
00733 
00743 int _SAPI_CALL sangoma_tdm_txsig_start(sng_fd_t fd, wanpipe_api_t *tdm_api);
00744 
00754 int _SAPI_CALL sangoma_tdm_txsig_kewl(sng_fd_t fd, wanpipe_api_t *tdm_api);
00755 
00765 int _SAPI_CALL sangoma_tdm_enable_hwec(sng_fd_t fd, wanpipe_api_t *tdm_api);
00766 
00776 int _SAPI_CALL sangoma_tdm_disable_hwec(sng_fd_t fd, wanpipe_api_t *tdm_api);
00777 
00787 int _SAPI_CALL sangoma_tdm_get_fe_alarms(sng_fd_t fd, wanpipe_api_t *tdm_api);
00788 
00789 
00790 
00791 #ifdef WP_API_FEATURE_LINK_STATUS
00792 # ifndef LIBSANGOMA_GET_LINKSTATUS
00793 
00797 # define LIBSANGOMA_GET_LINKSTATUS 1
00798 # endif
00799 
00809 int _SAPI_CALL sangoma_get_link_status(sng_fd_t fd, wanpipe_api_t *tdm_api, unsigned char *current_status);
00810 
00811 #endif
00812 
00813 /* set current Line Connection state - Connected/Disconnected */
00814 #ifndef LIBSANGOMA_GET_FESTATUS
00815 
00819 #define LIBSANGOMA_GET_FESTATUS 1
00820 #endif
00821 
00830 int _SAPI_CALL sangoma_set_fe_status(sng_fd_t fd, wanpipe_api_t *tdm_api, unsigned char new_status);
00831 
00832 
00833 #ifndef LIBSANGOMA_GET_HWCODING
00834 
00838 #define LIBSANGOMA_GET_HWCODING 1
00839 #endif
00840 
00851 int _SAPI_CALL sangoma_get_hw_coding(sng_fd_t fd, wanpipe_api_t *tdm_api);
00852 
00853 
00854 
00855 #ifndef LIBSANGOMA_GET_HWDTMF
00856 
00860 #define LIBSANGOMA_GET_HWDTMF 1
00861 #endif
00862 
00871 int _SAPI_CALL sangoma_tdm_get_hw_dtmf(sng_fd_t fd, wanpipe_api_t *tdm_api);
00872 
00881 int _SAPI_CALL sangoma_span_chan_toif(int span, int chan, char *interface_name);
00882 
00891 int _SAPI_CALL sangoma_span_chan_fromif(char *interface_name, int *span, int *chan);
00892 
00893 
00894 
00895 /*================================================================
00896  * DEPRECATED Function Calls - Not to be used any more
00897  * Here for backward compatibility 
00898  *================================================================*/
00899 
00900 
00901 #ifndef LIBSANGOMA_SET_FESTATUS
00902 
00906 #define LIBSANGOMA_SET_FESTATUS 1
00907 #endif
00908 
00919 int _SAPI_CALL sangoma_get_fe_status(sng_fd_t fd, wanpipe_api_t *tdm_api, unsigned char *current_status);
00920 
00921 
00922 
00934 int _SAPI_CALL sangoma_tdm_set_codec(sng_fd_t fd, wanpipe_api_t *tdm_api, int codec);
00935 
00946 int _SAPI_CALL sangoma_tdm_get_codec(sng_fd_t fd, wanpipe_api_t *tdm_api);
00947 
00948 
00958 sng_fd_t _SAPI_CALL sangoma_create_socket_by_name(char *device, char *card);
00959 
00969 int _SAPI_CALL sangoma_interface_toi(char *interface_name, int *span, int *chan);
00970 
00971 
00982 int _SAPI_CALL sangoma_tdm_set_power_level(sng_fd_t fd, wanpipe_api_t *tdm_api, int power);
00983 
00993 int _SAPI_CALL sangoma_tdm_get_power_level(sng_fd_t fd, wanpipe_api_t *tdm_api);
00994 
00995 #ifdef __cplusplus
00996 }
00997 #endif
00998 
01000 #if 1
01001 #define sangoma_open_tdmapi_span_chan sangoma_open_api_span_chan
01002 #define sangoma_open_tdmapi_span sangoma_open_api_span
01003 #define sangoma_open_tdmapi_ctrl sangoma_open_api_ctrl
01004 #define sangoma_tdm_get_fe_status sangoma_get_fe_status
01005 #define sangoma_socket_close sangoma_close
01006 #define sangoma_tdm_get_hw_coding sangoma_get_hw_coding
01007 #define sangoma_tdm_set_fe_status sangoma_set_fe_status
01008 #define sangoma_tdm_get_link_status sangoma_get_link_status
01009 #define sangoma_tdm_flush_bufs sangoma_flush_bufs
01010 #define sangoma_tdm_cmd_exec sangoma_cmd_exec
01011 #define sangoma_tdm_read_event sangoma_read_event
01012 #define sangoma_readmsg_tdm sangoma_readmsg
01013 #define sangoma_readmsg_socket sangoma_readmsg
01014 #define sangoma_sendmsg_socket sangoma_writemsg
01015 #define sangoma_writemsg_tdm sangoma_writemsg
01016 #define sangoma_create_socket_intr sangoma_open_api_span_chan
01017 #endif
01018 
01019 #endif  /* _LIBSNAGOMA_H */
01020 

Generated on Tue Jan 6 18:08:59 2009 for libsangoma by  doxygen 1.4.7