From 526cb45c93d76101df5e5dda5c54f4a152a49eb8 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Fri, 15 Jan 2010 19:38:56 +0000 Subject: [PATCH] more freetdm headers missing git-svn-id: http://svn.openzap.org/svn/openzap/branches/sangoma_boost@970 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/freetdm/src/include/ftdm_buffer.h | 154 +++++ libs/freetdm/src/include/ftdm_config.h | 145 ++++ libs/freetdm/src/include/ftdm_dso.h | 51 ++ libs/freetdm/src/include/ftdm_m3ua.h | 134 ++++ libs/freetdm/src/include/ftdm_threadmutex.h | 67 ++ libs/freetdm/src/include/ftdm_types.h | 703 ++++++++++++++++++++ 6 files changed, 1254 insertions(+) create mode 100644 libs/freetdm/src/include/ftdm_buffer.h create mode 100644 libs/freetdm/src/include/ftdm_config.h create mode 100644 libs/freetdm/src/include/ftdm_dso.h create mode 100644 libs/freetdm/src/include/ftdm_m3ua.h create mode 100644 libs/freetdm/src/include/ftdm_threadmutex.h create mode 100644 libs/freetdm/src/include/ftdm_types.h diff --git a/libs/freetdm/src/include/ftdm_buffer.h b/libs/freetdm/src/include/ftdm_buffer.h new file mode 100644 index 0000000000..e069e2d44b --- /dev/null +++ b/libs/freetdm/src/include/ftdm_buffer.h @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2007, Anthony Minessale II + * All rights reserved. + * + * 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 original author; nor the names of any contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT OWNER + * OR CONTRIBUTORS 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 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FTDM_BUFFER_H +#define FTDM_BUFFER_H + +#include "freetdm.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ftdm_buffer Buffer Routines + * @ingroup buffer + * The purpose of this module is to make a plain buffering interface that can be used for read/write buffers + * throughout the application. + * @{ + */ +struct ftdm_buffer; +typedef struct ftdm_buffer ftdm_buffer_t; + +/*! \brief Allocate a new dynamic ftdm_buffer + * \param buffer returned pointer to the new buffer + * \param blocksize length to realloc by as data is added + * \param start_len ammount of memory to reserve initially + * \param max_len length the buffer is allowed to grow to + * \return status + */ +FT_DECLARE(ftdm_status_t) ftdm_buffer_create(ftdm_buffer_t **buffer, ftdm_size_t blocksize, ftdm_size_t start_len, ftdm_size_t max_len); + +/*! \brief Get the length of a ftdm_buffer_t + * \param buffer any buffer of type ftdm_buffer_t + * \return int size of the buffer. + */ +FT_DECLARE(ftdm_size_t) ftdm_buffer_len(ftdm_buffer_t *buffer); + +/*! \brief Get the freespace of a ftdm_buffer_t + * \param buffer any buffer of type ftdm_buffer_t + * \return int freespace in the buffer. + */ +FT_DECLARE(ftdm_size_t) ftdm_buffer_freespace(ftdm_buffer_t *buffer); + +/*! \brief Get the in use amount of a ftdm_buffer_t + * \param buffer any buffer of type ftdm_buffer_t + * \return int ammount of buffer curently in use + */ +FT_DECLARE(ftdm_size_t) ftdm_buffer_inuse(ftdm_buffer_t *buffer); + +/*! \brief Read data from a ftdm_buffer_t up to the ammount of datalen if it is available. Remove read data from buffer. + * \param buffer any buffer of type ftdm_buffer_t + * \param data pointer to the read data to be returned + * \param datalen amount of data to be returned + * \return int ammount of data actually read + */ +FT_DECLARE(ftdm_size_t) ftdm_buffer_read(ftdm_buffer_t *buffer, void *data, ftdm_size_t datalen); + +/*! \brief Read data endlessly from a ftdm_buffer_t + * \param buffer any buffer of type ftdm_buffer_t + * \param data pointer to the read data to be returned + * \param datalen amount of data to be returned + * \return int ammount of data actually read + * \note Once you have read all the data from the buffer it will loop around. + */ +FT_DECLARE(ftdm_size_t) ftdm_buffer_read_loop(ftdm_buffer_t *buffer, void *data, ftdm_size_t datalen); + +/*! \brief Assign a number of loops to read + * \param buffer any buffer of type ftdm_buffer_t + * \param loops the number of loops (-1 for infinite) + */ +FT_DECLARE(void) ftdm_buffer_set_loops(ftdm_buffer_t *buffer, int32_t loops); + +/*! \brief Write data into a ftdm_buffer_t up to the length of datalen + * \param buffer any buffer of type ftdm_buffer_t + * \param data pointer to the data to be written + * \param datalen amount of data to be written + * \return int amount of buffer used after the write, or 0 if no space available + */ +FT_DECLARE(ftdm_size_t) ftdm_buffer_write(ftdm_buffer_t *buffer, const void *data, ftdm_size_t datalen); + +/*! \brief Remove data from the buffer + * \param buffer any buffer of type ftdm_buffer_t + * \param datalen amount of data to be removed + * \return int size of buffer, or 0 if unable to toss that much data + */ +FT_DECLARE(ftdm_size_t) ftdm_buffer_toss(ftdm_buffer_t *buffer, ftdm_size_t datalen); + +/*! \brief Remove all data from the buffer + * \param buffer any buffer of type ftdm_buffer_t + */ +FT_DECLARE(void) ftdm_buffer_zero(ftdm_buffer_t *buffer); + +/*! \brief Destroy the buffer + * \param buffer buffer to destroy + * \note only neccessary on dynamic buffers (noop on pooled ones) + */ +FT_DECLARE(void) ftdm_buffer_destroy(ftdm_buffer_t **buffer); + +/*! \brief Seek to offset from the beginning of the buffer + * \param buffer buffer to seek + * \param datalen offset in bytes + * \return new position + */ +FT_DECLARE(ftdm_size_t) ftdm_buffer_seek(ftdm_buffer_t *buffer, ftdm_size_t datalen); + +/** @} */ + +FT_DECLARE(ftdm_size_t) ftdm_buffer_zwrite(ftdm_buffer_t *buffer, const void *data, ftdm_size_t datalen); + +#ifdef __cplusplus +} +#endif + +#endif +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4: + */ diff --git a/libs/freetdm/src/include/ftdm_config.h b/libs/freetdm/src/include/ftdm_config.h new file mode 100644 index 0000000000..0f96a8f872 --- /dev/null +++ b/libs/freetdm/src/include/ftdm_config.h @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2007, Anthony Minessale II + * All rights reserved. + * + * 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 original author; nor the names of any contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT OWNER + * OR CONTRIBUTORS 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 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @defgroup config Config File Parser + * @ingroup config + * This module implements a basic interface and file format parser + * + *
+ *
+ * EXAMPLE 
+ * 
+ * [category1]
+ * var1 => val1
+ * var2 => val2
+ * \# lines that begin with \# are comments
+ * \#var3 => val3
+ * 
+ * @{ + */ + +#ifndef FTDM_CONFIG_H +#define FTDM_CONFIG_H + +#include "freetdm.h" +#define FTDM_URL_SEPARATOR "://" + + +#ifdef WIN32 +#define FTDM_PATH_SEPARATOR "\\" +#ifndef FTDM_CONFIG_DIR +#define FTDM_CONFIG_DIR "c:\\freetdm" +#endif +#define ftdm_is_file_path(file) (*(file +1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR)) +#else +#define FTDM_PATH_SEPARATOR "/" +#ifndef FTDM_CONFIG_DIR +#define FTDM_CONFIG_DIR "/etc/freetdm" +#endif +#define ftdm_is_file_path(file) ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR)) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ftdm_config ftdm_config_t; + +/*! \brief A simple file handle representing an open configuration file **/ +struct ftdm_config { + /*! FILE stream buffer to the opened file */ + FILE *file; + /*! path to the file */ + char path[512]; + /*! current category */ + char category[256]; + /*! current section */ + char section[256]; + /*! buffer of current line being read */ + char buf[1024]; + /*! current line number in file */ + int lineno; + /*! current category number in file */ + int catno; + /*! current section number in file */ + int sectno; + + int lockto; +}; + +/*! + \brief Open a configuration file + \param cfg (ftdm_config_t *) config handle to use + \param file_path path to the file + \return 1 (true) on success 0 (false) on failure +*/ +int ftdm_config_open_file(ftdm_config_t * cfg, const char *file_path); + +/*! + \brief Close a previously opened configuration file + \param cfg (ftdm_config_t *) config handle to use +*/ +void ftdm_config_close_file(ftdm_config_t * cfg); + +/*! + \brief Retrieve next name/value pair from configuration file + \param cfg (ftdm_config_t *) config handle to use + \param var pointer to aim at the new variable name + \param val pointer to aim at the new value +*/ +int ftdm_config_next_pair(ftdm_config_t * cfg, char **var, char **val); + +/*! + \brief Retrieve the CAS bits from a configuration string value + \param strvalue pointer to the configuration string value (expected to be in format whatever:xxxx) + \param outbits pointer to aim at the CAS bits +*/ +FT_DECLARE (int) ftdm_config_get_cas_bits(char *strvalue, unsigned char *outbits); + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4: + */ diff --git a/libs/freetdm/src/include/ftdm_dso.h b/libs/freetdm/src/include/ftdm_dso.h new file mode 100644 index 0000000000..c4c4b705d1 --- /dev/null +++ b/libs/freetdm/src/include/ftdm_dso.h @@ -0,0 +1,51 @@ +/* + * Cross Platform dso/dll load abstraction + * Copyright(C) 2008 Michael Jerris + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so. + * + * This work is provided under this license on an "as is" basis, without warranty of any kind, + * either expressed or implied, including, without limitation, warranties that the covered code + * is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire + * risk as to the quality and performance of the covered code is with you. Should any covered + * code prove defective in any respect, you (not the initial developer or any other contributor) + * assume the cost of any necessary servicing, repair or correction. This disclaimer of warranty + * constitutes an essential part of this license. No use of any covered code is authorized hereunder + * except under this disclaimer. + * + */ + + +#ifndef _FTDM_DSO_H +#define _FTDM_DSO_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (*ftdm_func_ptr_t) (void); +typedef void * ftdm_dso_lib_t; + +FT_DECLARE(void) ftdm_dso_destroy(ftdm_dso_lib_t *lib); +FT_DECLARE(ftdm_dso_lib_t) ftdm_dso_open(const char *path, char **err); +FT_DECLARE(void *) ftdm_dso_func_sym(ftdm_dso_lib_t lib, const char *sym, char **err); + +#ifdef __cplusplus +} +#endif + +#endif + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 + */ + diff --git a/libs/freetdm/src/include/ftdm_m3ua.h b/libs/freetdm/src/include/ftdm_m3ua.h new file mode 100644 index 0000000000..ae2abb5022 --- /dev/null +++ b/libs/freetdm/src/include/ftdm_m3ua.h @@ -0,0 +1,134 @@ +/* + * ftdm_m3ua.h + * freetdm + * + * Created by Shane Burrell on 4/3/08. + * Copyright 2008 Shane Burrell. All rights reserved. + * + * Copyright (c) 2007, Anthony Minessale II, Nenad Corbic + * + * 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 original author; nor the names of any contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT OWNER + * OR CONTRIBUTORS 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 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +//#include "m3ua_client.h" +#include "freetdm.h" + +#ifdef __cplusplus +extern "C" { +#endif +enum e_sigboost_event_id_values +{ + SIGBOOST_EVENT_CALL_START = 0x80, /*128*/ + SIGBOOST_EVENT_CALL_START_ACK = 0x81, /*129*/ + SIGBOOST_EVENT_CALL_START_NACK = 0x82, /*130*/ + SIGBOOST_EVENT_CALL_START_NACK_ACK = 0x83, /*131*/ + SIGBOOST_EVENT_CALL_ANSWERED = 0x84, /*132*/ + SIGBOOST_EVENT_CALL_STOPPED = 0x85, /*133*/ + SIGBOOST_EVENT_CALL_STOPPED_ACK = 0x86, /*134*/ + SIGBOOST_EVENT_SYSTEM_RESTART = 0x87, /*135*/ + SIGBOOST_EVENT_SYSTEM_RESTART_ACK = 0x88, /*136*/ + /* Following IDs are ss7boost to sangoma_mgd only. */ + SIGBOOST_EVENT_HEARTBEAT = 0x89, /*137*/ + SIGBOOST_EVENT_INSERT_CHECK_LOOP = 0x8a, /*138*/ + SIGBOOST_EVENT_REMOVE_CHECK_LOOP = 0x8b, /*139*/ + SIGBOOST_EVENT_AUTO_CALL_GAP_ABATE = 0x8c, /*140*/ +}; +enum e_sigboost_release_cause_values +{ + SIGBOOST_RELEASE_CAUSE_UNDEFINED = 0, + SIGBOOST_RELEASE_CAUSE_NORMAL = 16, + SIGBOOST_RELEASE_CAUSE_BUSY = 17, + /* probable elimination */ + //SIGBOOST_RELEASE_CAUSE_BUSY = 0x91, /* 145 */ + //SIGBOOST_RELEASE_CAUSE_CALLED_NOT_EXIST = 0x92, /* 146 */ + //SIGBOOST_RELEASE_CAUSE_CIRCUIT_RESET = 0x93, /* 147 */ + //SIGBOOST_RELEASE_CAUSE_NOANSWER = 0x94, /* 148 */ +}; + +enum e_sigboost_call_setup_ack_nack_cause_values +{ + SIGBOOST_CALL_SETUP_NACK_ALL_CKTS_BUSY = 117, /* unused Q.850 value */ + SIGBOOST_CALL_SETUP_NACK_TEST_CKT_BUSY = 118, /* unused Q.850 value */ + SIGBOOST_CALL_SETUP_NACK_INVALID_NUMBER = 28, + /* probable elimination */ + //SIGBOOST_CALL_SETUP_RESERVED = 0x00, + //SIGBOOST_CALL_SETUP_CIRCUIT_RESET = 0x10, + //SIGBOOST_CALL_SETUP_NACK_CKT_START_TIMEOUT = 0x11, + //SIGBOOST_CALL_SETUP_NACK_AUTO_CALL_GAP = 0x17, +}; +typedef enum { + M3UA_SPAN_SIGNALING_M3UA, + M3UA_SPAN_SIGNALING_SS7BOX, + +} M3UA_TSpanSignaling; +#define M3UA_SPAN_STRINGS "M3UA", "SS7BOX" +FTDM_STR2ENUM_P(m3ua_str2span, m3ua_span2str, M3UA_TSpanSignaling) + + + +typedef enum { + FTDM_M3UA_RUNNING = (1 << 0) +} ftdm_m3uat_flag_t; + +/*typedef struct m3ua_data { + m3uac_connection_t mcon; + m3uac_connection_t pcon; + zio_signal_cb_t signal_cb; + uint32_t flags; +} m3ua_data_t; + +*/ +/*typedef struct mu3a_link { + ss7bc_connection_t mcon; + ss7bc_connection_t pcon; + zio_signal_cb_t signal_cb; + uint32_t flags; +} ftdm_m3ua_data_t; +*/ + +ftdm_status_t m3ua_init(ftdm_io_interface_t **zint); +ftdm_status_t m3ua_destroy(void); +ftdm_status_t m3ua_start(ftdm_span_t *span); + +#ifdef __cplusplus +} +#endif + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4: + */ + diff --git a/libs/freetdm/src/include/ftdm_threadmutex.h b/libs/freetdm/src/include/ftdm_threadmutex.h new file mode 100644 index 0000000000..a970eda522 --- /dev/null +++ b/libs/freetdm/src/include/ftdm_threadmutex.h @@ -0,0 +1,67 @@ +/* + * Cross Platform Thread/Mutex abstraction + * Copyright(C) 2007 Michael Jerris + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so. + * + * This work is provided under this license on an "as is" basis, without warranty of any kind, + * either expressed or implied, including, without limitation, warranties that the covered code + * is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire + * risk as to the quality and performance of the covered code is with you. Should any covered + * code prove defective in any respect, you (not the initial developer or any other contributor) + * assume the cost of any necessary servicing, repair or correction. This disclaimer of warranty + * constitutes an essential part of this license. No use of any covered code is authorized hereunder + * except under this disclaimer. + * + * Contributors: + * + * Moises Silva + * + */ + + +#ifndef _FTDM_THREADMUTEX_H +#define _FTDM_THREADMUTEX_H + +#include "freetdm.h" + +#ifdef __cplusplus +extern "C" { +#endif +typedef struct ftdm_mutex ftdm_mutex_t; +typedef struct ftdm_thread ftdm_thread_t; +typedef struct ftdm_condition ftdm_condition_t; +typedef void *(*ftdm_thread_function_t) (ftdm_thread_t *, void *); + +FT_DECLARE(ftdm_status_t) ftdm_thread_create_detached(ftdm_thread_function_t func, void *data); +FT_DECLARE(ftdm_status_t) ftdm_thread_create_detached_ex(ftdm_thread_function_t func, void *data, ftdm_size_t stack_size); +FT_DECLARE(void) ftdm_thread_override_default_stacksize(ftdm_size_t size); +FT_DECLARE(ftdm_status_t) ftdm_mutex_create(ftdm_mutex_t **mutex); +FT_DECLARE(ftdm_status_t) ftdm_mutex_destroy(ftdm_mutex_t **mutex); +FT_DECLARE(ftdm_status_t) _ftdm_mutex_lock(ftdm_mutex_t *mutex); +FT_DECLARE(ftdm_status_t) _ftdm_mutex_trylock(ftdm_mutex_t *mutex); +FT_DECLARE(ftdm_status_t) _ftdm_mutex_unlock(ftdm_mutex_t *mutex); +FT_DECLARE(ftdm_status_t) ftdm_condition_create(ftdm_condition_t **cond, ftdm_mutex_t *mutex); +FT_DECLARE(ftdm_status_t) ftdm_condition_destroy(ftdm_condition_t **cond); +FT_DECLARE(ftdm_status_t) ftdm_condition_signal(ftdm_condition_t *cond); +FT_DECLARE(ftdm_status_t) ftdm_condition_wait(ftdm_condition_t *cond, int ms); + +#ifdef __cplusplus +} +#endif + +#endif + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4: + */ + diff --git a/libs/freetdm/src/include/ftdm_types.h b/libs/freetdm/src/include/ftdm_types.h new file mode 100644 index 0000000000..680ba0feb4 --- /dev/null +++ b/libs/freetdm/src/include/ftdm_types.h @@ -0,0 +1,703 @@ +/* + * Copyright (c) 2007, Anthony Minessale II + * All rights reserved. + * + * 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 original author; nor the names of any contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT OWNER + * OR CONTRIBUTORS 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 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Contributors: + * + * Moises Silva + * + */ + +#ifndef FTDM_TYPES_H +#define FTDM_TYPES_H +#include "fsk.h" + +#ifdef WIN32 +#include +typedef HANDLE ftdm_socket_t; +typedef unsigned __int64 uint64_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int8 uint8_t; +typedef __int64 int64_t; +typedef __int32 int32_t; +typedef __int16 int16_t; +typedef __int8 int8_t; +typedef intptr_t ftdm_ssize_t; +typedef int ftdm_filehandle_t; +#else +#include +#include +#include +#include +typedef int ftdm_socket_t; +typedef ssize_t ftdm_ssize_t; +typedef int ftdm_filehandle_t; +#endif + +#ifdef __cplusplus +extern "C" { +#endif +#define TAG_END NULL + +typedef size_t ftdm_size_t; +struct ftdm_io_interface; + +#define FTDM_COMMAND_OBJ_INT *((int *)obj) +#define FTDM_COMMAND_OBJ_CHAR_P (char *)obj +#define FTDM_COMMAND_OBJ_FLOAT *(float *)obj +#define FTDM_FSK_MOD_FACTOR 0x10000 +#define FTDM_DEFAULT_DTMF_ON 250 +#define FTDM_DEFAULT_DTMF_OFF 50 + +#define FTDM_END -1 +#define FTDM_ANY_STATE -1 + +typedef uint64_t ftdm_time_t; + +typedef enum { + FTDM_ENDIAN_BIG = 1, + FTDM_ENDIAN_LITTLE = -1 +} ftdm_endian_t; + +typedef enum { + FTDM_CID_TYPE_SDMF = 0x04, + FTDM_CID_TYPE_MDMF = 0x80 +} ftdm_cid_type_t; + +typedef enum { + MDMF_DATETIME = 1, + MDMF_PHONE_NUM = 2, + MDMF_DDN = 3, + MDMF_NO_NUM = 4, + MDMF_PHONE_NAME = 7, + MDMF_NO_NAME = 8, + MDMF_ALT_ROUTE = 9, + MDMF_INVALID = 10 +} ftdm_mdmf_type_t; +#define MDMF_STRINGS "X", "DATETIME", "PHONE_NUM", "DDN", "NO_NUM", "X", "X", "PHONE_NAME", "NO_NAME", "ALT_ROUTE", "INVALID" +FTDM_STR2ENUM_P(ftdm_str2ftdm_mdmf_type, ftdm_mdmf_type2str, ftdm_mdmf_type_t) + +#define FTDM_TONEMAP_LEN 128 +typedef enum { + FTDM_TONEMAP_NONE, + FTDM_TONEMAP_DIAL, + FTDM_TONEMAP_RING, + FTDM_TONEMAP_BUSY, + FTDM_TONEMAP_FAIL1, + FTDM_TONEMAP_FAIL2, + FTDM_TONEMAP_FAIL3, + FTDM_TONEMAP_ATTN, + FTDM_TONEMAP_CALLWAITING_CAS, + FTDM_TONEMAP_CALLWAITING_SAS, + FTDM_TONEMAP_CALLWAITING_ACK, + FTDM_TONEMAP_INVALID +} ftdm_tonemap_t; +#define TONEMAP_STRINGS "NONE", "DIAL", "RING", "BUSY", "FAIL1", "FAIL2", "FAIL3", "ATTN", "CALLWAITING-CAS", "CALLWAITING-SAS", "CALLWAITING-ACK", "INVALID" +FTDM_STR2ENUM_P(ftdm_str2ftdm_tonemap, ftdm_tonemap2str, ftdm_tonemap_t) + +typedef enum { + FTDM_TRUNK_E1, + FTDM_TRUNK_T1, + FTDM_TRUNK_J1, + FTDM_TRUNK_BRI, + FTDM_TRUNK_BRI_PTMP, + FTDM_TRUNK_FXO, + FTDM_TRUNK_FXS, + FTDM_TRUNK_EM, + FTDM_TRUNK_NONE +} ftdm_trunk_type_t; +#define TRUNK_STRINGS "E1", "T1", "J1", "BRI", "BRI_PTMP", "FXO", "FXS", "EM", "NONE" +FTDM_STR2ENUM_P(ftdm_str2ftdm_trunk_type, ftdm_trunk_type2str, ftdm_trunk_type_t) + +typedef enum { + FTDM_ANALOG_START_KEWL, + FTDM_ANALOG_START_LOOP, + FTDM_ANALOG_START_GROUND, + FTDM_ANALOG_START_WINK, + FTDM_ANALOG_START_NA +} ftdm_analog_start_type_t; +#define START_TYPE_STRINGS "KEWL", "LOOP", "GROUND", "WINK", "NA" +FTDM_STR2ENUM_P(ftdm_str2ftdm_analog_start_type, ftdm_analog_start_type2str, ftdm_analog_start_type_t) + +typedef enum { + FTDM_OOB_ONHOOK, + FTDM_OOB_OFFHOOK, + FTDM_OOB_WINK, + FTDM_OOB_FLASH, + FTDM_OOB_RING_START, + FTDM_OOB_RING_STOP, + FTDM_OOB_ALARM_TRAP, + FTDM_OOB_ALARM_CLEAR, + FTDM_OOB_NOOP, + FTDM_OOB_CAS_BITS_CHANGE, + FTDM_OOB_INVALID +} ftdm_oob_event_t; +#define OOB_STRINGS "DTMF", "ONHOOK", "OFFHOOK", "WINK", "FLASH", "RING_START", "RING_STOP", "ALARM_TRAP", "ALARM_CLEAR", "NOOP", "CAS_BITS_CHANGE", "INVALID" +FTDM_STR2ENUM_P(ftdm_str2ftdm_oob_event, ftdm_oob_event2str, ftdm_oob_event_t) + +typedef enum { + FTDM_ALARM_NONE = 0, + FTDM_ALARM_RECOVER = (1 << 0), + FTDM_ALARM_LOOPBACK = (1 << 2), + FTDM_ALARM_YELLOW = (1 << 3), + FTDM_ALARM_RED = (1 << 4), + FTDM_ALARM_BLUE = (1 << 5), + FTDM_ALARM_NOTOPEN = ( 1 << 6), + FTDM_ALARM_AIS = ( 1 << 7), + FTDM_ALARM_RAI = ( 1 << 8), + FTDM_ALARM_GENERAL = ( 1 << 30) +} ftdm_alarm_flag_t; + +typedef enum { + FTDM_SIGTYPE_NONE, + FTDM_SIGTYPE_ISDN, + FTDM_SIGTYPE_RBS, + FTDM_SIGTYPE_ANALOG, + FTDM_SIGTYPE_SANGOMABOOST, + FTDM_SIGTYPE_M3UA, + FTDM_SIGTYPE_R2 +} ftdm_signal_type_t; + +/*! + \brief Signaling status on a given span or specific channel on protocols that support it + */ +typedef enum { + /* The signaling link is down (no d-chans up in the span/group, MFC-R2 bit pattern unidentified) */ + FTDM_SIG_STATE_DOWN, + /* The signaling link is suspended (MFC-R2 bit pattern blocked, ss7 blocked?) */ + FTDM_SIG_STATE_SUSPENDED, + /* The signaling link is ready and calls can be placed */ + FTDM_SIG_STATE_UP, + /* Invalid status */ + FTDM_SIG_STATE_INVALID +} ftdm_signaling_status_t; +#define SIGSTATUS_STRINGS "DOWN", "SUSPENDED", "UP", "INVALID" +FTDM_STR2ENUM_P(ftdm_str2ftdm_signaling_status, ftdm_signaling_status2str, ftdm_signaling_status_t) + +typedef enum { + FTDM_SIGEVENT_START, + FTDM_SIGEVENT_STOP, + FTDM_SIGEVENT_TRANSFER, + FTDM_SIGEVENT_ANSWER, + FTDM_SIGEVENT_UP, + FTDM_SIGEVENT_FLASH, + FTDM_SIGEVENT_PROGRESS, + FTDM_SIGEVENT_PROGRESS_MEDIA, + FTDM_SIGEVENT_NOTIFY, + FTDM_SIGEVENT_TONE_DETECTED, + FTDM_SIGEVENT_ALARM_TRAP, + FTDM_SIGEVENT_ALARM_CLEAR, + FTDM_SIGEVENT_MISC, + FTDM_SIGEVENT_COLLECTED_DIGIT, + FTDM_SIGEVENT_ADD_CALL, + FTDM_SIGEVENT_RESTART, + /* Signaling link status changed (D-chan up, down, R2 blocked etc) */ + FTDM_SIGEVENT_SIGSTATUS_CHANGED, + /* Hardware link status changed (Line connected, disconnected) */ + FTDM_SIGEVENT_HWSTATUS_CHANGED, + FTDM_SIGEVENT_INVALID +} ftdm_signal_event_t; +#define SIGNAL_STRINGS "START", "STOP", "TRANSFER", "ANSWER", "UP", "FLASH", "PROGRESS", \ + "PROGRESS_MEDIA", "NOTIFY", "TONE_DETECTED", "ALARM_TRAP", "ALARM_CLEAR", "MISC", \ + "COLLECTED_DIGIT", "ADD_CALL", "RESTART", "SIGLINK_CHANGED", "HWSTATUS_CHANGED", "INVALID" +FTDM_STR2ENUM_P(ftdm_str2ftdm_signal_event, ftdm_signal_event2str, ftdm_signal_event_t) + +typedef enum { + FTDM_EVENT_NONE, + FTDM_EVENT_DTMF, + FTDM_EVENT_OOB, + FTDM_EVENT_COUNT +} ftdm_event_type_t; + +typedef enum { + FTDM_TOP_DOWN, + FTDM_BOTTOM_UP +} ftdm_direction_t; + +typedef enum { + FTDM_SUCCESS, + FTDM_FAIL, + FTDM_MEMERR, + FTDM_TIMEOUT, + FTDM_NOTIMPL, + FTDM_CHECKSUM_ERROR, + FTDM_STATUS_COUNT, + FTDM_BREAK +} ftdm_status_t; + +typedef enum { + FTDM_NO_FLAGS = 0, + FTDM_READ = (1 << 0), + FTDM_WRITE = (1 << 1), + FTDM_EVENTS = (1 << 2) +} ftdm_wait_flag_t; + +typedef enum { + FTDM_CODEC_ULAW = 0, + FTDM_CODEC_ALAW = 8, + FTDM_CODEC_SLIN = 10, + FTDM_CODEC_NONE = (1 << 30) +} ftdm_codec_t; + +typedef enum { + FTDM_TONE_DTMF = (1 << 0) +} ftdm_tone_type_t; + +typedef enum { + FTDM_COMMAND_NOOP, + FTDM_COMMAND_SET_INTERVAL, + FTDM_COMMAND_GET_INTERVAL, + FTDM_COMMAND_SET_CODEC, + FTDM_COMMAND_GET_CODEC, + FTDM_COMMAND_SET_NATIVE_CODEC, + FTDM_COMMAND_GET_NATIVE_CODEC, + FTDM_COMMAND_ENABLE_DTMF_DETECT, + FTDM_COMMAND_DISABLE_DTMF_DETECT, + FTDM_COMMAND_SEND_DTMF, + FTDM_COMMAND_SET_DTMF_ON_PERIOD, + FTDM_COMMAND_GET_DTMF_ON_PERIOD, + FTDM_COMMAND_SET_DTMF_OFF_PERIOD, + FTDM_COMMAND_GET_DTMF_OFF_PERIOD, + FTDM_COMMAND_GENERATE_RING_ON, + FTDM_COMMAND_GENERATE_RING_OFF, + FTDM_COMMAND_OFFHOOK, + FTDM_COMMAND_ONHOOK, + FTDM_COMMAND_FLASH, + FTDM_COMMAND_WINK, + FTDM_COMMAND_ENABLE_PROGRESS_DETECT, + FTDM_COMMAND_DISABLE_PROGRESS_DETECT, + FTDM_COMMAND_TRACE_INPUT, + FTDM_COMMAND_TRACE_OUTPUT, + FTDM_COMMAND_ENABLE_CALLERID_DETECT, + FTDM_COMMAND_DISABLE_CALLERID_DETECT, + FTDM_COMMAND_ENABLE_ECHOCANCEL, + FTDM_COMMAND_DISABLE_ECHOCANCEL, + FTDM_COMMAND_ENABLE_ECHOTRAIN, + FTDM_COMMAND_DISABLE_ECHOTRAIN, + FTDM_COMMAND_SET_CAS_BITS, + FTDM_COMMAND_GET_CAS_BITS, + FTDM_COMMAND_SET_RX_GAIN, + FTDM_COMMAND_GET_RX_GAIN, + FTDM_COMMAND_SET_TX_GAIN, + FTDM_COMMAND_GET_TX_GAIN, + FTDM_COMMAND_FLUSH_TX_BUFFERS, + FTDM_COMMAND_FLUSH_RX_BUFFERS, + FTDM_COMMAND_FLUSH_BUFFERS, + FTDM_COMMAND_SET_PRE_BUFFER_SIZE, + FTDM_COMMAND_SET_LINK_STATUS, + FTDM_COMMAND_GET_LINK_STATUS, + FTDM_COMMAND_COUNT +} ftdm_command_t; + +typedef enum { + FTDM_SPAN_CONFIGURED = (1 << 0), + FTDM_SPAN_READY = (1 << 1), + FTDM_SPAN_STATE_CHANGE = (1 << 2), + FTDM_SPAN_SUSPENDED = (1 << 3), + FTDM_SPAN_IN_THREAD = (1 << 4), + FTDM_SPAN_STOP_THREAD = (1 << 5) +} ftdm_span_flag_t; + +typedef enum { + FTDM_CHAN_TYPE_B, + FTDM_CHAN_TYPE_DQ921, + FTDM_CHAN_TYPE_DQ931, + FTDM_CHAN_TYPE_FXS, + FTDM_CHAN_TYPE_FXO, + FTDM_CHAN_TYPE_EM, + FTDM_CHAN_TYPE_CAS, + FTDM_CHAN_TYPE_COUNT +} ftdm_chan_type_t; + +#define CHAN_TYPE_STRINGS "B", "DQ921", "DQ931", "FXS", "FXO", "EM", "CAS", "INVALID" +FTDM_STR2ENUM_P(ftdm_str2ftdm_chan_type, ftdm_chan_type2str, ftdm_chan_type_t) + +typedef enum { + FTDM_CHANNEL_FEATURE_DTMF_DETECT = (1 << 0), + FTDM_CHANNEL_FEATURE_DTMF_GENERATE = (1 << 1), + FTDM_CHANNEL_FEATURE_CODECS = (1 << 2), + FTDM_CHANNEL_FEATURE_INTERVAL = (1 << 3), + FTDM_CHANNEL_FEATURE_CALLERID = (1 << 4), + FTDM_CHANNEL_FEATURE_PROGRESS = (1 << 5) +} ftdm_channel_feature_t; + +typedef enum { + FTDM_CHANNEL_STATE_DOWN, + FTDM_CHANNEL_STATE_HOLD, + FTDM_CHANNEL_STATE_SUSPENDED, + FTDM_CHANNEL_STATE_DIALTONE, + FTDM_CHANNEL_STATE_COLLECT, + FTDM_CHANNEL_STATE_RING, + FTDM_CHANNEL_STATE_BUSY, + FTDM_CHANNEL_STATE_ATTN, + FTDM_CHANNEL_STATE_GENRING, + FTDM_CHANNEL_STATE_DIALING, + FTDM_CHANNEL_STATE_GET_CALLERID, + FTDM_CHANNEL_STATE_CALLWAITING, + FTDM_CHANNEL_STATE_RESTART, + FTDM_CHANNEL_STATE_PROGRESS, + FTDM_CHANNEL_STATE_PROGRESS_MEDIA, + FTDM_CHANNEL_STATE_UP, + FTDM_CHANNEL_STATE_IDLE, + FTDM_CHANNEL_STATE_TERMINATING, + FTDM_CHANNEL_STATE_CANCEL, + FTDM_CHANNEL_STATE_HANGUP, + FTDM_CHANNEL_STATE_HANGUP_COMPLETE, + FTDM_CHANNEL_STATE_INVALID +} ftdm_channel_state_t; +#define CHANNEL_STATE_STRINGS "DOWN", "HOLD", "SUSPENDED", "DIALTONE", "COLLECT", \ + "RING", "BUSY", "ATTN", "GENRING", "DIALING", "GET_CALLERID", "CALLWAITING", \ + "RESTART", "PROGRESS", "PROGRESS_MEDIA", "UP", "IDLE", "TERMINATING", "CANCEL", "HANGUP", "HANGUP_COMPLETE", "INVALID" +FTDM_STR2ENUM_P(ftdm_str2ftdm_channel_state, ftdm_channel_state2str, ftdm_channel_state_t) + +typedef enum { + FTDM_CHANNEL_CONFIGURED = (1 << 0), + FTDM_CHANNEL_READY = (1 << 1), + FTDM_CHANNEL_OPEN = (1 << 2), + FTDM_CHANNEL_DTMF_DETECT = (1 << 3), + FTDM_CHANNEL_SUPRESS_DTMF = (1 << 4), + FTDM_CHANNEL_TRANSCODE = (1 << 5), + FTDM_CHANNEL_BUFFER = (1 << 6), + FTDM_CHANNEL_EVENT = (1 << 7), + FTDM_CHANNEL_INTHREAD = (1 << 8), + FTDM_CHANNEL_WINK = (1 << 9), + FTDM_CHANNEL_FLASH = (1 << 10), + FTDM_CHANNEL_STATE_CHANGE = (1 << 11), + FTDM_CHANNEL_HOLD = (1 << 12), + FTDM_CHANNEL_INUSE = (1 << 13), + FTDM_CHANNEL_OFFHOOK = (1 << 14), + FTDM_CHANNEL_RINGING = (1 << 15), + FTDM_CHANNEL_PROGRESS_DETECT = (1 << 16), + FTDM_CHANNEL_CALLERID_DETECT = (1 << 17), + FTDM_CHANNEL_OUTBOUND = (1 << 18), + FTDM_CHANNEL_SUSPENDED = (1 << 19), + FTDM_CHANNEL_3WAY = (1 << 20), + FTDM_CHANNEL_PROGRESS = (1 << 21), + FTDM_CHANNEL_MEDIA = (1 << 22), + FTDM_CHANNEL_ANSWERED = (1 << 23), + FTDM_CHANNEL_MUTE = (1 << 24), + FTDM_CHANNEL_USE_RX_GAIN = (1 << 25), + FTDM_CHANNEL_USE_TX_GAIN = (1 << 26), +} ftdm_channel_flag_t; +#if defined(__cplusplus) && defined(WIN32) + // fix C2676 +__inline__ ftdm_channel_flag_t operator|=(ftdm_channel_flag_t a, int32_t b) { + a = (ftdm_channel_flag_t)(a | b); + return a; +} +__inline__ ftdm_channel_flag_t operator&=(ftdm_channel_flag_t a, int32_t b) { + a = (ftdm_channel_flag_t)(a & b); + return a; +} +#endif + +typedef enum { + ZSM_NONE, + ZSM_UNACCEPTABLE, + ZSM_ACCEPTABLE +} ftdm_state_map_type_t; + +typedef enum { + ZSD_INBOUND, + ZSD_OUTBOUND, +} ftdm_state_direction_t; + +#define FTDM_MAP_NODE_SIZE 512 +#define FTDM_MAP_MAX FTDM_CHANNEL_STATE_INVALID+2 + +struct ftdm_state_map_node { + ftdm_state_direction_t direction; + ftdm_state_map_type_t type; + ftdm_channel_state_t check_states[FTDM_MAP_MAX]; + ftdm_channel_state_t states[FTDM_MAP_MAX]; +}; +typedef struct ftdm_state_map_node ftdm_state_map_node_t; + +struct ftdm_state_map { + ftdm_state_map_node_t nodes[FTDM_MAP_NODE_SIZE]; +}; +typedef struct ftdm_state_map ftdm_state_map_t; + +typedef enum ftdm_channel_hw_link_status { + FTDM_HW_LINK_DISCONNECTED = 0, + FTDM_HW_LINK_CONNECTED +} ftdm_channel_hw_link_status_t; + +typedef struct ftdm_conf_parameter_s { + const char *var; + const char *val; +} ftdm_conf_parameter_t; + +typedef struct ftdm_channel ftdm_channel_t; +typedef struct ftdm_event ftdm_event_t; +typedef struct ftdm_sigmsg ftdm_sigmsg_t; +typedef struct ftdm_span ftdm_span_t; +typedef struct ftdm_group ftdm_group_t; +typedef struct ftdm_caller_data ftdm_caller_data_t; +typedef struct ftdm_io_interface ftdm_io_interface_t; + +struct ftdm_stream_handle; +typedef struct ftdm_stream_handle ftdm_stream_handle_t; + +typedef ftdm_status_t (*ftdm_stream_handle_raw_write_function_t) (ftdm_stream_handle_t *handle, uint8_t *data, ftdm_size_t datalen); +typedef ftdm_status_t (*ftdm_stream_handle_write_function_t) (ftdm_stream_handle_t *handle, const char *fmt, ...); + +#define ZIO_CHANNEL_REQUEST_ARGS (ftdm_span_t *span, uint32_t chan_id, ftdm_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan) +#define ZIO_CHANNEL_OUTGOING_CALL_ARGS (ftdm_channel_t *ftdmchan) +#define ZIO_CHANNEL_SET_SIG_STATUS_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status) +#define ZIO_CHANNEL_GET_SIG_STATUS_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t *status) +#define ZIO_SPAN_SET_SIG_STATUS_ARGS (ftdm_span_t *span, ftdm_signaling_status_t status) +#define ZIO_SPAN_GET_SIG_STATUS_ARGS (ftdm_span_t *span, ftdm_signaling_status_t *status) +#define ZIO_SPAN_POLL_EVENT_ARGS (ftdm_span_t *span, uint32_t ms) +#define ZIO_SPAN_NEXT_EVENT_ARGS (ftdm_span_t *span, ftdm_event_t **event) +#define ZIO_SIGNAL_CB_ARGS (ftdm_sigmsg_t *sigmsg) +#define ZIO_EVENT_CB_ARGS (ftdm_channel_t *ftdmchan, ftdm_event_t *event) +#define ZIO_CODEC_ARGS (void *data, ftdm_size_t max, ftdm_size_t *datalen) +#define ZIO_CONFIGURE_SPAN_ARGS (ftdm_span_t *span, const char *str, ftdm_chan_type_t type, char *name, char *number) +#define ZIO_CONFIGURE_ARGS (const char *category, const char *var, const char *val, int lineno) +#define ZIO_OPEN_ARGS (ftdm_channel_t *ftdmchan) +#define ZIO_CLOSE_ARGS (ftdm_channel_t *ftdmchan) +#define ZIO_CHANNEL_DESTROY_ARGS (ftdm_channel_t *ftdmchan) +#define ZIO_SPAN_DESTROY_ARGS (ftdm_span_t *span) +#define ZIO_COMMAND_ARGS (ftdm_channel_t *ftdmchan, ftdm_command_t command, void *obj) +#define ZIO_WAIT_ARGS (ftdm_channel_t *ftdmchan, ftdm_wait_flag_t *flags, int32_t to) +#define ZIO_GET_ALARMS_ARGS (ftdm_channel_t *ftdmchan) +#define ZIO_READ_ARGS (ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen) +#define ZIO_WRITE_ARGS (ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen) +#define ZIO_IO_LOAD_ARGS (ftdm_io_interface_t **zio) +#define ZIO_IO_UNLOAD_ARGS (void) +#define ZIO_SIG_LOAD_ARGS (void) +#define ZIO_SIG_CONFIGURE_ARGS (ftdm_span_t *span, zio_signal_cb_t sig_cb, va_list ap) +#define ZIO_CONFIGURE_SPAN_SIGNALING_ARGS (ftdm_span_t *span, zio_signal_cb_t sig_cb, ftdm_conf_parameter_t *ftdm_parameters) +#define ZIO_SIG_UNLOAD_ARGS (void) +#define ZIO_API_ARGS (ftdm_stream_handle_t *stream, const char *data) + +typedef ftdm_status_t (*zio_channel_request_t) ZIO_CHANNEL_REQUEST_ARGS ; +typedef ftdm_status_t (*zio_channel_outgoing_call_t) ZIO_CHANNEL_OUTGOING_CALL_ARGS ; +typedef ftdm_status_t (*zio_channel_set_sig_status_t) ZIO_CHANNEL_SET_SIG_STATUS_ARGS; +typedef ftdm_status_t (*zio_channel_get_sig_status_t) ZIO_CHANNEL_GET_SIG_STATUS_ARGS; +typedef ftdm_status_t (*zio_span_set_sig_status_t) ZIO_SPAN_SET_SIG_STATUS_ARGS; +typedef ftdm_status_t (*zio_span_get_sig_status_t) ZIO_SPAN_GET_SIG_STATUS_ARGS; +typedef ftdm_status_t (*zio_span_poll_event_t) ZIO_SPAN_POLL_EVENT_ARGS ; +typedef ftdm_status_t (*zio_span_next_event_t) ZIO_SPAN_NEXT_EVENT_ARGS ; +typedef ftdm_status_t (*zio_signal_cb_t) ZIO_SIGNAL_CB_ARGS ; +typedef ftdm_status_t (*zio_event_cb_t) ZIO_EVENT_CB_ARGS ; +typedef ftdm_status_t (*zio_codec_t) ZIO_CODEC_ARGS ; +typedef ftdm_status_t (*zio_configure_span_t) ZIO_CONFIGURE_SPAN_ARGS ; +typedef ftdm_status_t (*zio_configure_t) ZIO_CONFIGURE_ARGS ; +typedef ftdm_status_t (*zio_open_t) ZIO_OPEN_ARGS ; +typedef ftdm_status_t (*zio_close_t) ZIO_CLOSE_ARGS ; +typedef ftdm_status_t (*zio_channel_destroy_t) ZIO_CHANNEL_DESTROY_ARGS ; +typedef ftdm_status_t (*zio_span_destroy_t) ZIO_SPAN_DESTROY_ARGS ; +typedef ftdm_status_t (*zio_get_alarms_t) ZIO_GET_ALARMS_ARGS ; +typedef ftdm_status_t (*zio_command_t) ZIO_COMMAND_ARGS ; +typedef ftdm_status_t (*zio_wait_t) ZIO_WAIT_ARGS ; +typedef ftdm_status_t (*zio_read_t) ZIO_READ_ARGS ; +typedef ftdm_status_t (*zio_write_t) ZIO_WRITE_ARGS ; +typedef ftdm_status_t (*zio_io_load_t) ZIO_IO_LOAD_ARGS ; +typedef ftdm_status_t (*zio_sig_load_t) ZIO_SIG_LOAD_ARGS ; +typedef ftdm_status_t (*zio_sig_configure_t) ZIO_SIG_CONFIGURE_ARGS ; +typedef ftdm_status_t (*zio_configure_span_signaling_t) ZIO_CONFIGURE_SPAN_SIGNALING_ARGS ; +typedef ftdm_status_t (*zio_io_unload_t) ZIO_IO_UNLOAD_ARGS ; +typedef ftdm_status_t (*zio_sig_unload_t) ZIO_SIG_UNLOAD_ARGS ; +typedef ftdm_status_t (*zio_api_t) ZIO_API_ARGS ; + + +#define ZIO_CHANNEL_REQUEST_FUNCTION(name) ftdm_status_t name ZIO_CHANNEL_REQUEST_ARGS +#define ZIO_CHANNEL_OUTGOING_CALL_FUNCTION(name) ftdm_status_t name ZIO_CHANNEL_OUTGOING_CALL_ARGS +#define ZIO_CHANNEL_SET_SIG_STATUS_FUNCTION(name) ftdm_status_t name ZIO_CHANNEL_SET_SIG_STATUS_ARGS +#define ZIO_CHANNEL_GET_SIG_STATUS_FUNCTION(name) ftdm_status_t name ZIO_CHANNEL_GET_SIG_STATUS_ARGS +#define ZIO_SPAN_SET_SIG_STATUS_FUNCTION(name) ftdm_status_t name ZIO_SPAN_SET_SIG_STATUS_ARGS +#define ZIO_SPAN_GET_SIG_STATUS_FUNCTION(name) ftdm_status_t name ZIO_SPAN_GET_SIG_STATUS_ARGS +#define ZIO_SPAN_POLL_EVENT_FUNCTION(name) ftdm_status_t name ZIO_SPAN_POLL_EVENT_ARGS +#define ZIO_SPAN_NEXT_EVENT_FUNCTION(name) ftdm_status_t name ZIO_SPAN_NEXT_EVENT_ARGS +#define ZIO_SIGNAL_CB_FUNCTION(name) ftdm_status_t name ZIO_SIGNAL_CB_ARGS +#define ZIO_EVENT_CB_FUNCTION(name) ftdm_status_t name ZIO_EVENT_CB_ARGS +#define ZIO_CODEC_FUNCTION(name) FT_DECLARE_NONSTD(ftdm_status_t) name ZIO_CODEC_ARGS +#define ZIO_CONFIGURE_SPAN_FUNCTION(name) ftdm_status_t name ZIO_CONFIGURE_SPAN_ARGS +#define ZIO_CONFIGURE_FUNCTION(name) ftdm_status_t name ZIO_CONFIGURE_ARGS +#define ZIO_OPEN_FUNCTION(name) ftdm_status_t name ZIO_OPEN_ARGS +#define ZIO_CLOSE_FUNCTION(name) ftdm_status_t name ZIO_CLOSE_ARGS +#define ZIO_CHANNEL_DESTROY_FUNCTION(name) ftdm_status_t name ZIO_CHANNEL_DESTROY_ARGS +#define ZIO_SPAN_DESTROY_FUNCTION(name) ftdm_status_t name ZIO_SPAN_DESTROY_ARGS +#define ZIO_GET_ALARMS_FUNCTION(name) ftdm_status_t name ZIO_GET_ALARMS_ARGS +#define ZIO_COMMAND_FUNCTION(name) ftdm_status_t name ZIO_COMMAND_ARGS +#define ZIO_WAIT_FUNCTION(name) ftdm_status_t name ZIO_WAIT_ARGS +#define ZIO_READ_FUNCTION(name) ftdm_status_t name ZIO_READ_ARGS +#define ZIO_WRITE_FUNCTION(name) ftdm_status_t name ZIO_WRITE_ARGS +#define ZIO_IO_LOAD_FUNCTION(name) ftdm_status_t name ZIO_IO_LOAD_ARGS +#define ZIO_SIG_LOAD_FUNCTION(name) ftdm_status_t name ZIO_SIG_LOAD_ARGS +#define ZIO_SIG_CONFIGURE_FUNCTION(name) ftdm_status_t name ZIO_SIG_CONFIGURE_ARGS +#define ZIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(name) ftdm_status_t name ZIO_CONFIGURE_SPAN_SIGNALING_ARGS +#define ZIO_IO_UNLOAD_FUNCTION(name) ftdm_status_t name ZIO_IO_UNLOAD_ARGS +#define ZIO_SIG_UNLOAD_FUNCTION(name) ftdm_status_t name ZIO_SIG_UNLOAD_ARGS +#define ZIO_API_FUNCTION(name) ftdm_status_t name ZIO_API_ARGS + +#include "ftdm_dso.h" + +typedef struct { + char name[256]; + zio_io_load_t io_load; + zio_io_unload_t io_unload; + zio_sig_load_t sig_load; + zio_sig_configure_t sig_configure; + zio_sig_unload_t sig_unload; + /*! + \brief configure a given span signaling + \see sig_configure + This is just like sig_configure but receives + an array of paramters instead of va_list + I'd like to deprecate sig_configure and move + all modules to use sigparam_configure + */ + zio_configure_span_signaling_t configure_span_signaling; + ftdm_dso_lib_t lib; + char path[256]; +} ftdm_module_t; + +#ifndef __FUNCTION__ +#define __FUNCTION__ (const char *)__func__ +#endif + +#define FTDM_PRE __FILE__, __FUNCTION__, __LINE__ +#define FTDM_LOG_LEVEL_DEBUG 7 +#define FTDM_LOG_LEVEL_INFO 6 +#define FTDM_LOG_LEVEL_NOTICE 5 +#define FTDM_LOG_LEVEL_WARNING 4 +#define FTDM_LOG_LEVEL_ERROR 3 +#define FTDM_LOG_LEVEL_CRIT 2 +#define FTDM_LOG_LEVEL_ALERT 1 +#define FTDM_LOG_LEVEL_EMERG 0 + +#define FTDM_LOG_DEBUG FTDM_PRE, FTDM_LOG_LEVEL_DEBUG +#define FTDM_LOG_INFO FTDM_PRE, FTDM_LOG_LEVEL_INFO +#define FTDM_LOG_NOTICE FTDM_PRE, FTDM_LOG_LEVEL_NOTICE +#define FTDM_LOG_WARNING FTDM_PRE, FTDM_LOG_LEVEL_WARNING +#define FTDM_LOG_ERROR FTDM_PRE, FTDM_LOG_LEVEL_ERROR +#define FTDM_LOG_CRIT FTDM_PRE, FTDM_LOG_LEVEL_CRIT +#define FTDM_LOG_ALERT FTDM_PRE, FTDM_LOG_LEVEL_ALERT +#define FTDM_LOG_EMERG FTDM_PRE, FTDM_LOG_LEVEL_EMERG + +typedef struct ftdm_fsk_data_state ftdm_fsk_data_state_t; +typedef int (*ftdm_fsk_data_decoder_t)(ftdm_fsk_data_state_t *state); +typedef ftdm_status_t (*ftdm_fsk_write_sample_t)(int16_t *buf, ftdm_size_t buflen, void *user_data); +typedef void (*ftdm_logger_t)(const char *file, const char *func, int line, int level, const char *fmt, ...); +typedef struct hashtable ftdm_hash_t; +typedef struct hashtable_iterator ftdm_hash_iterator_t; +typedef struct key ftdm_hash_key_t; +typedef struct value ftdm_hash_val_t; +typedef struct ftdm_bitstream ftdm_bitstream_t; +typedef struct ftdm_fsk_modulator ftdm_fsk_modulator_t; +typedef ftdm_status_t (*ftdm_span_start_t)(ftdm_span_t *span); +typedef ftdm_status_t (*ftdm_span_stop_t)(ftdm_span_t *span); + +typedef enum { + FTDM_CAUSE_NONE = 0, + FTDM_CAUSE_UNALLOCATED = 1, + FTDM_CAUSE_NO_ROUTE_TRANSIT_NET = 2, + FTDM_CAUSE_NO_ROUTE_DESTINATION = 3, + FTDM_CAUSE_CHANNEL_UNACCEPTABLE = 6, + FTDM_CAUSE_CALL_AWARDED_DELIVERED = 7, + FTDM_CAUSE_NORMAL_CLEARING = 16, + FTDM_CAUSE_USER_BUSY = 17, + FTDM_CAUSE_NO_USER_RESPONSE = 18, + FTDM_CAUSE_NO_ANSWER = 19, + FTDM_CAUSE_SUBSCRIBER_ABSENT = 20, + FTDM_CAUSE_CALL_REJECTED = 21, + FTDM_CAUSE_NUMBER_CHANGED = 22, + FTDM_CAUSE_REDIRECTION_TO_NEW_DESTINATION = 23, + FTDM_CAUSE_EXCHANGE_ROUTING_ERROR = 25, + FTDM_CAUSE_DESTINATION_OUT_OF_ORDER = 27, + FTDM_CAUSE_INVALID_NUMBER_FORMAT = 28, + FTDM_CAUSE_FACILITY_REJECTED = 29, + FTDM_CAUSE_RESPONSE_TO_STATUS_ENQUIRY = 30, + FTDM_CAUSE_NORMAL_UNSPECIFIED = 31, + FTDM_CAUSE_NORMAL_CIRCUIT_CONGESTION = 34, + FTDM_CAUSE_NETWORK_OUT_OF_ORDER = 38, + FTDM_CAUSE_NORMAL_TEMPORARY_FAILURE = 41, + FTDM_CAUSE_SWITCH_CONGESTION = 42, + FTDM_CAUSE_ACCESS_INFO_DISCARDED = 43, + FTDM_CAUSE_REQUESTED_CHAN_UNAVAIL = 44, + FTDM_CAUSE_PRE_EMPTED = 45, + FTDM_CAUSE_FACILITY_NOT_SUBSCRIBED = 50, + FTDM_CAUSE_OUTGOING_CALL_BARRED = 52, + FTDM_CAUSE_INCOMING_CALL_BARRED = 54, + FTDM_CAUSE_BEARERCAPABILITY_NOTAUTH = 57, + FTDM_CAUSE_BEARERCAPABILITY_NOTAVAIL = 58, + FTDM_CAUSE_SERVICE_UNAVAILABLE = 63, + FTDM_CAUSE_BEARERCAPABILITY_NOTIMPL = 65, + FTDM_CAUSE_CHAN_NOT_IMPLEMENTED = 66, + FTDM_CAUSE_FACILITY_NOT_IMPLEMENTED = 69, + FTDM_CAUSE_SERVICE_NOT_IMPLEMENTED = 79, + FTDM_CAUSE_INVALID_CALL_REFERENCE = 81, + FTDM_CAUSE_INCOMPATIBLE_DESTINATION = 88, + FTDM_CAUSE_INVALID_MSG_UNSPECIFIED = 95, + FTDM_CAUSE_MANDATORY_IE_MISSING = 96, + FTDM_CAUSE_MESSAGE_TYPE_NONEXIST = 97, + FTDM_CAUSE_WRONG_MESSAGE = 98, + FTDM_CAUSE_IE_NONEXIST = 99, + FTDM_CAUSE_INVALID_IE_CONTENTS = 100, + FTDM_CAUSE_WRONG_CALL_STATE = 101, + FTDM_CAUSE_RECOVERY_ON_TIMER_EXPIRE = 102, + FTDM_CAUSE_MANDATORY_IE_LENGTH_ERROR = 103, + FTDM_CAUSE_PROTOCOL_ERROR = 111, + FTDM_CAUSE_INTERWORKING = 127, + FTDM_CAUSE_SUCCESS = 142, + FTDM_CAUSE_ORIGINATOR_CANCEL = 487, + FTDM_CAUSE_CRASH = 500, + FTDM_CAUSE_SYSTEM_SHUTDOWN = 501, + FTDM_CAUSE_LOSE_RACE = 502, + FTDM_CAUSE_MANAGER_REQUEST = 503, + FTDM_CAUSE_BLIND_TRANSFER = 600, + FTDM_CAUSE_ATTENDED_TRANSFER = 601, + FTDM_CAUSE_ALLOTTED_TIMEOUT = 602, + FTDM_CAUSE_USER_CHALLENGE = 603, + FTDM_CAUSE_MEDIA_TIMEOUT = 604 +} ftdm_call_cause_t; + +#ifdef __cplusplus +} +#endif + +#endif + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4: + */ +