Linux renaming from openzap to freetdm

git-svn-id: http://svn.openzap.org/svn/openzap/branches/sangoma_boost@967 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Moises Silva
2010-01-15 19:22:49 +00:00
parent 0346bc76cc
commit 900f1ed2ef
90 changed files with 10653 additions and 12819 deletions

View File

@@ -7,7 +7,7 @@
#define __inline__ __inline
#endif
#endif
#include "openzap.h"
#include "freetdm.h"
#ifdef __cplusplus
extern "C" {
@@ -81,7 +81,7 @@ struct hashtable_iterator;
* @return newly created hashtable or NULL on failure
*/
OZ_DECLARE(struct hashtable *)
FT_DECLARE(struct hashtable *)
create_hashtable(unsigned int minsize,
unsigned int (*hashfunction) (void*),
int (*key_eq_fn) (void*,void*));
@@ -112,7 +112,7 @@ typedef enum {
HASHTABLE_FLAG_FREE_VALUE = (1 << 1)
} hashtable_flag_t;
OZ_DECLARE(int)
FT_DECLARE(int)
hashtable_insert(struct hashtable *h, void *k, void *v, hashtable_flag_t flags);
#define DEFINE_HASHTABLE_INSERT(fnname, keytype, valuetype) \
@@ -130,7 +130,7 @@ hashtable_insert(struct hashtable *h, void *k, void *v, hashtable_flag_t flags);
* @return the value associated with the key, or NULL if none found
*/
OZ_DECLARE(void *)
FT_DECLARE(void *)
hashtable_search(struct hashtable *h, void *k);
#define DEFINE_HASHTABLE_SEARCH(fnname, keytype, valuetype) \
@@ -148,7 +148,7 @@ hashtable_search(struct hashtable *h, void *k);
* @return the value associated with the key, or NULL if none found
*/
OZ_DECLARE(void *) /* returns value */
FT_DECLARE(void *) /* returns value */
hashtable_remove(struct hashtable *h, void *k);
#define DEFINE_HASHTABLE_REMOVE(fnname, keytype, valuetype) \
@@ -165,7 +165,7 @@ hashtable_remove(struct hashtable *h, void *k);
* @param h the hashtable
* @return the number of items stored in the hashtable
*/
OZ_DECLARE(unsigned int)
FT_DECLARE(unsigned int)
hashtable_count(struct hashtable *h);
@@ -177,12 +177,12 @@ hashtable_count(struct hashtable *h);
* @param free_values whether to call 'free' on the remaining values
*/
OZ_DECLARE(void)
FT_DECLARE(void)
hashtable_destroy(struct hashtable *h);
OZ_DECLARE(struct hashtable_iterator*) hashtable_first(struct hashtable *h);
OZ_DECLARE(struct hashtable_iterator*) hashtable_next(struct hashtable_iterator *i);
OZ_DECLARE(void) hashtable_this(struct hashtable_iterator *i, const void **key, int *klen, void **val);
FT_DECLARE(struct hashtable_iterator*) hashtable_first(struct hashtable *h);
FT_DECLARE(struct hashtable_iterator*) hashtable_next(struct hashtable_iterator *i);
FT_DECLARE(void) hashtable_this(struct hashtable_iterator *i, const void **key, int *klen, void **val);
#ifdef __cplusplus
} /* extern C */

View File

@@ -4,10 +4,10 @@
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* The contents of this file are subject to the Mftilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
* http://www.mftilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
@@ -33,8 +33,8 @@
* Exception:
* The author hereby grants the use of this source code under the
* following license if and only if the source code is distributed
* as part of the openzap library. Any use or distribution of this
* source code outside the scope of the openzap library will nullify the
* as part of the freetdm library. Any use or distribution of this
* source code outside the scope of the freetdm library will nullify the
* following license and reinact the MPL 1.1 as stated above.
*
* Copyright (c) 2007, Anthony Minessale II

View File

@@ -7,8 +7,8 @@
* Exception:
* The author hereby grants the use of this source code under the
* following license if and only if the source code is distributed
* as part of the openzap library. Any use or distribution of this
* source code outside the scope of the openzap library will nullify the
* as part of the freetdm library. Any use or distribution of this
* source code outside the scope of the freetdm library will nullify the
* following license and reinact the MPL 1.1 as stated above.
*
* Copyright (c) 2007, Anthony Minessale II

View File

@@ -1,932 +0,0 @@
/*
* 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 <moy@sangoma.com>
*
*/
#ifndef OPENZAP_H
#define OPENZAP_H
#if !defined(_XOPEN_SOURCE) && !defined(__FreeBSD__)
#define _XOPEN_SOURCE 600
#endif
#ifndef HAVE_STRINGS_H
#define HAVE_STRINGS_H 1
#endif
#ifndef HAVE_SYS_SOCKET_H
#define HAVE_SYS_SOCKET_H 1
#endif
#ifndef __WINDOWS__
#if defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32) || defined(_WIN64)
#define __WINDOWS__
#endif
#endif
#ifdef _MSC_VER
#if defined(OZ_DECLARE_STATIC)
#define OZ_DECLARE(type) type __stdcall
#define OZ_DECLARE_NONSTD(type) type __cdecl
#define OZ_DECLARE_DATA
#elif defined(OPENZAP_EXPORTS)
#define OZ_DECLARE(type) __declspec(dllexport) type __stdcall
#define OZ_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl
#define OZ_DECLARE_DATA __declspec(dllexport)
#else
#define OZ_DECLARE(type) __declspec(dllimport) type __stdcall
#define OZ_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl
#define OZ_DECLARE_DATA __declspec(dllimport)
#endif
#define EX_DECLARE_DATA __declspec(dllexport)
#else
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(HAVE_VISIBILITY)
#define OZ_DECLARE(type) __attribute__((visibility("default"))) type
#define OZ_DECLARE_NONSTD(type) __attribute__((visibility("default"))) type
#define OZ_DECLARE_DATA __attribute__((visibility("default")))
#else
#define OZ_DECLARE(type) type
#define OZ_DECLARE_NONSTD(type) type
#define OZ_DECLARE_DATA
#endif
#define EX_DECLARE_DATA
#endif
#ifdef _MSC_VER
#ifndef __inline__
#define __inline__ __inline
#endif
#if (_MSC_VER >= 1400) /* VC8+ */
#ifndef _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
#endif
#ifndef _CRT_NONSTDC_NO_DEPRECATE
#define _CRT_NONSTDC_NO_DEPRECATE
#endif
#endif
#ifndef strcasecmp
#define strcasecmp(s1, s2) _stricmp(s1, s2)
#endif
#ifndef strncasecmp
#define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n)
#endif
#ifndef snprintf
#define snprintf _snprintf
#endif
#ifndef S_IRUSR
#define S_IRUSR _S_IREAD
#endif
#ifndef S_IWUSR
#define S_IWUSR _S_IWRITE
#endif
#undef HAVE_STRINGS_H
#undef HAVE_SYS_SOCKET_H
/* disable warning for zero length array in a struct */
/* this will cause errors on c99 and ansi compliant compilers and will need to be fixed in the wanpipe header files */
#pragma warning(disable:4706)
#pragma comment(lib, "Winmm")
#endif
#define ZAP_THREAD_STACKSIZE 240 * 1024
#define ZAP_ENUM_NAMES(_NAME, _STRINGS) static const char * _NAME [] = { _STRINGS , NULL };
#define ZAP_STR2ENUM_P(_FUNC1, _FUNC2, _TYPE) OZ_DECLARE(_TYPE) _FUNC1 (const char *name); OZ_DECLARE(const char *) _FUNC2 (_TYPE type);
#define ZAP_STR2ENUM(_FUNC1, _FUNC2, _TYPE, _STRINGS, _MAX) \
OZ_DECLARE(_TYPE) _FUNC1 (const char *name) \
{ \
int i; \
_TYPE t = _MAX ; \
\
for (i = 0; i < _MAX ; i++) { \
if (!strcasecmp(name, _STRINGS[i])) { \
t = (_TYPE) i; \
break; \
} \
} \
\
return t; \
} \
OZ_DECLARE(const char *) _FUNC2 (_TYPE type) \
{ \
if (type > _MAX) { \
type = _MAX; \
} \
return _STRINGS[(int)type]; \
} \
#define zap_true(expr) \
(expr && ( !strcasecmp(expr, "yes") || \
!strcasecmp(expr, "on") || \
!strcasecmp(expr, "true") || \
!strcasecmp(expr, "enabled") || \
!strcasecmp(expr, "active") || \
atoi(expr))) ? 1 : 0
#include <time.h>
#ifndef __WINDOWS__
#include <sys/time.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include <assert.h>
#include "zap_types.h"
#include "hashtable.h"
#include "zap_config.h"
#include "g711.h"
#include "libteletone.h"
#include "zap_buffer.h"
#include "zap_threadmutex.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __WINDOWS__
#define zap_sleep(x) Sleep(x)
#else
#define zap_sleep(x) usleep(x * 1000)
#endif
#ifdef NDEBUG
#undef assert
#define assert(_Expression) ((void)(_Expression))
#endif
#define ZAP_MAX_CHANNELS_PHYSICAL_SPAN 32
#define ZAP_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN 32
#define ZAP_MAX_CHANNELS_SPAN ZAP_MAX_CHANNELS_PHYSICAL_SPAN * ZAP_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN
#define ZAP_MAX_SPANS_INTERFACE 128
#define ZAP_MAX_CHANNELS_GROUP 1024
#define ZAP_MAX_GROUPS_INTERFACE ZAP_MAX_SPANS_INTERFACE
#define GOTO_STATUS(label,st) status = st; goto label ;
#define zap_copy_string(x,y,z) strncpy(x, y, z - 1)
#define zap_set_string(x,y) strncpy(x, y, sizeof(x)-1)
#define zap_strlen_zero(s) (!s || *s == '\0')
#define zap_strlen_zero_buf(s) (*s == '\0')
#define zap_channel_test_feature(obj, flag) ((obj)->features & flag)
#define zap_channel_set_feature(obj, flag) (obj)->features |= (flag)
#define zap_channel_clear_feature(obj, flag) (obj)->features &= ~(flag)
#define zap_channel_set_member_locked(obj, _m, _v) zap_mutex_lock(obj->mutex); obj->_m = _v; zap_mutex_unlock(obj->mutex)
/*!
\brief Test for the existance of a flag on an arbitary object
\command obj the object to test
\command flag the or'd list of flags to test
\return true value if the object has the flags defined
*/
#define zap_test_flag(obj, flag) ((obj)->flags & flag)
#define zap_test_pflag(obj, flag) ((obj)->pflags & flag)
#define zap_test_sflag(obj, flag) ((obj)->sflags & flag)
#define zap_set_alarm_flag(obj, flag) (obj)->alarm_flags |= (flag)
#define zap_clear_alarm_flag(obj, flag) (obj)->alarm_flags &= ~(flag)
#define zap_test_alarm_flag(obj, flag) ((obj)->alarm_flags & flag)
/*!
\brief Set a flag on an arbitrary object
\command obj the object to set the flags on
\command flag the or'd list of flags to set
*/
#define zap_set_flag(obj, flag) (obj)->flags |= (flag)
#define zap_set_flag_locked(obj, flag) assert(obj->mutex != NULL); \
zap_mutex_lock(obj->mutex); \
(obj)->flags |= (flag); \
zap_mutex_unlock(obj->mutex);
#define zap_set_pflag(obj, flag) (obj)->pflags |= (flag)
#define zap_set_pflag_locked(obj, flag) assert(obj->mutex != NULL); \
zap_mutex_lock(obj->mutex); \
(obj)->pflags |= (flag); \
zap_mutex_unlock(obj->mutex);
#define zap_set_sflag(obj, flag) (obj)->sflags |= (flag)
#define zap_set_sflag_locked(obj, flag) assert(obj->mutex != NULL); \
zap_mutex_lock(obj->mutex); \
(obj)->sflags |= (flag); \
zap_mutex_unlock(obj->mutex);
/*!
\brief Clear a flag on an arbitrary object while locked
\command obj the object to test
\command flag the or'd list of flags to clear
*/
#define zap_clear_flag(obj, flag) (obj)->flags &= ~(flag)
#define zap_clear_flag_locked(obj, flag) assert(obj->mutex != NULL); zap_mutex_lock(obj->mutex); (obj)->flags &= ~(flag); zap_mutex_unlock(obj->mutex);
#define zap_clear_pflag(obj, flag) (obj)->pflags &= ~(flag)
#define zap_clear_pflag_locked(obj, flag) assert(obj->mutex != NULL); zap_mutex_lock(obj->mutex); (obj)->pflags &= ~(flag); zap_mutex_unlock(obj->mutex);
#define zap_clear_sflag(obj, flag) (obj)->sflags &= ~(flag)
#define zap_clear_sflag_locked(obj, flag) assert(obj->mutex != NULL); zap_mutex_lock(obj->mutex); (obj)->sflags &= ~(flag); zap_mutex_unlock(obj->mutex);
#define zap_set_state_locked(obj, s) if ( obj->state == s ) { \
zap_log(ZAP_LOG_WARNING, "Why bother changing state on %d:%d from %s to %s\n", obj->span_id, obj->chan_id, zap_channel_state2str(obj->state), zap_channel_state2str(s)); \
} else if (zap_test_flag(obj, ZAP_CHANNEL_READY)) { \
zap_channel_state_t st = obj->state; \
zap_channel_set_state(obj, s, 1); \
if (obj->state == s) zap_log(ZAP_LOG_DEBUG, "Changing state on %d:%d from %s to %s\n", obj->span_id, obj->chan_id, zap_channel_state2str(st), zap_channel_state2str(s)); \
else zap_log(ZAP_LOG_WARNING, "VETO Changing state on %d:%d from %s to %s\n", obj->span_id, obj->chan_id, zap_channel_state2str(st), zap_channel_state2str(s)); \
}
#ifdef _MSC_VER
/* The while(0) below throws a conditional expression is constant warning */
#pragma warning(disable:4127)
#endif
#define zap_set_state_locked_wait(obj, s) \
do { \
int __safety = 100; \
zap_set_state_locked(obj, s); \
while(__safety-- && zap_test_flag(obj, ZAP_CHANNEL_STATE_CHANGE)) { \
zap_sleep(10); \
} \
if(!__safety) { \
zap_log(ZAP_LOG_CRIT, "State change not completed\n"); \
} \
} while(0);
#define zap_wait_for_flag_cleared(obj, flag, time) \
do { \
int __safety = time; \
while(__safety-- && zap_test_flag(obj, flag)) { \
zap_mutex_unlock(obj->mutex); \
zap_sleep(10); \
zap_mutex_lock(obj->mutex); \
} \
if(!__safety) { \
zap_log(ZAP_LOG_CRIT, "flag %d was never cleared\n", flag); \
} \
} while(0);
#define zap_set_state_wait(obj, s) \
do { \
zap_channel_set_state(obj, s, 0); \
zap_wait_for_flag_cleared(obj, ZAP_CHANNEL_STATE_CHANGE, 100); \
} while(0);
typedef enum {
ZAP_STATE_CHANGE_FAIL,
ZAP_STATE_CHANGE_SUCCESS,
ZAP_STATE_CHANGE_SAME,
} zap_state_change_result_t;
#define zap_set_state_r(obj, s, l, r) if ( obj->state == s ) { \
zap_log(ZAP_LOG_WARNING, "Why bother changing state on %d:%d from %s to %s\n", obj->span_id, obj->chan_id, zap_channel_state2str(obj->state), zap_channel_state2str(s)); r = ZAP_STATE_CHANGE_SAME; \
} else if (zap_test_flag(obj, ZAP_CHANNEL_READY)) { \
int st = obj->state; \
r = (zap_channel_set_state(obj, s, l) == ZAP_SUCCESS) ? ZAP_STATE_CHANGE_SUCCESS : ZAP_STATE_CHANGE_FAIL; \
if (obj->state == s) {zap_log(ZAP_LOG_DEBUG, "Changing state on %d:%d from %s to %s\n", obj->span_id, obj->chan_id, zap_channel_state2str(st), zap_channel_state2str(s));} \
else {zap_log(ZAP_LOG_WARNING, "VETO Changing state on %d:%d from %s to %s\n", obj->span_id, obj->chan_id, zap_channel_state2str(st), zap_channel_state2str(s)); } \
}
#define zap_is_dtmf(key) ((key > 47 && key < 58) || (key > 64 && key < 69) || (key > 96 && key < 101) || key == 35 || key == 42 || key == 87 || key == 119)
/*!
\brief Copy flags from one arbitrary object to another
\command dest the object to copy the flags to
\command src the object to copy the flags from
\command flags the flags to copy
*/
#define zap_copy_flags(dest, src, flags) (dest)->flags &= ~(flags); (dest)->flags |= ((src)->flags & (flags))
struct zap_stream_handle {
zap_stream_handle_write_function_t write_function;
zap_stream_handle_raw_write_function_t raw_write_function;
void *data;
void *end;
zap_size_t data_size;
zap_size_t data_len;
zap_size_t alloc_len;
zap_size_t alloc_chunk;
};
OZ_DECLARE_NONSTD(zap_status_t) zap_console_stream_raw_write(zap_stream_handle_t *handle, uint8_t *data, zap_size_t datalen);
OZ_DECLARE_NONSTD(zap_status_t) zap_console_stream_write(zap_stream_handle_t *handle, const char *fmt, ...);
#define ZAP_CMD_CHUNK_LEN 1024
#define ZAP_STANDARD_STREAM(s) memset(&s, 0, sizeof(s)); s.data = malloc(ZAP_CMD_CHUNK_LEN); \
assert(s.data); \
memset(s.data, 0, ZAP_CMD_CHUNK_LEN); \
s.end = s.data; \
s.data_size = ZAP_CMD_CHUNK_LEN; \
s.write_function = zap_console_stream_write; \
s.raw_write_function = zap_console_stream_raw_write; \
s.alloc_len = ZAP_CMD_CHUNK_LEN; \
s.alloc_chunk = ZAP_CMD_CHUNK_LEN
struct zap_event {
zap_event_type_t e_type;
uint32_t enum_id;
zap_channel_t *channel;
void *data;
};
#define ZAP_TOKEN_STRLEN 128
#define ZAP_MAX_TOKENS 10
static __inline__ char *zap_clean_string(char *s)
{
char *p;
for (p = s; p && *p; p++) {
uint8_t x = (uint8_t) *p;
if (x < 32 || x > 127) {
*p = ' ';
}
}
return s;
}
struct zap_bitstream {
uint8_t *data;
uint32_t datalen;
uint32_t byte_index;
uint8_t bit_index;
int8_t endian;
uint8_t top;
uint8_t bot;
uint8_t ss;
uint8_t ssv;
};
struct zap_fsk_data_state {
dsp_fsk_handle_t *fsk1200_handle;
uint8_t init;
uint8_t *buf;
size_t bufsize;
zap_size_t blen;
zap_size_t bpos;
zap_size_t dlen;
zap_size_t ppos;
int checksum;
};
struct zap_fsk_modulator {
teletone_dds_state_t dds;
zap_bitstream_t bs;
uint32_t carrier_bits_start;
uint32_t carrier_bits_stop;
uint32_t chan_sieze_bits;
uint32_t bit_factor;
uint32_t bit_accum;
uint32_t sample_counter;
int32_t samples_per_bit;
int32_t est_bytes;
fsk_modem_types_t modem_type;
zap_fsk_data_state_t *fsk_data;
zap_fsk_write_sample_t write_sample_callback;
void *user_data;
int16_t sample_buffer[64];
};
/**
* Type Of Number (TON)
*/
typedef enum {
ZAP_TON_UNKNOWN = 0,
ZAP_TON_INTERNATIONAL,
ZAP_TON_NATIONAL,
ZAP_TON_NETWORK_SPECIFIC,
ZAP_TON_SUBSCRIBER_NUMBER,
ZAP_TON_ABBREVIATED_NUMBER,
ZAP_TON_RESERVED
} zap_ton_t;
typedef struct {
char digits[25];
uint8_t type;
uint8_t plan;
} zap_number_t;
typedef enum {
ZAP_CALLER_STATE_DIALING,
ZAP_CALLER_STATE_SUCCESS,
ZAP_CALLER_STATE_FAIL
} zap_caller_state_t;
struct zap_caller_data {
char cid_date[8];
char cid_name[80];
zap_number_t cid_num;
zap_number_t ani;
zap_number_t dnis;
zap_number_t rdnis;
char aniII[25];
uint8_t screen;
uint8_t pres;
char collected[25];
int CRV;
int hangup_cause;
uint8_t raw_data[1024];
uint32_t raw_data_len;
uint32_t flags;
zap_caller_state_t call_state;
uint32_t chan_id;
};
typedef enum {
ZAP_TYPE_NONE,
ZAP_TYPE_SPAN = 0xFF,
ZAP_TYPE_CHANNEL
} zap_data_type_t;
/* 2^8 table size, one for each byte value */
#define ZAP_GAINS_TABLE_SIZE 256
struct zap_channel {
zap_data_type_t data_type;
uint32_t span_id;
uint32_t chan_id;
uint32_t physical_span_id;
uint32_t physical_chan_id;
uint32_t rate;
uint32_t extra_id;
zap_chan_type_t type;
zap_socket_t sockfd;
zap_channel_flag_t flags;
uint32_t pflags;
uint32_t sflags;
zap_alarm_flag_t alarm_flags;
zap_channel_feature_t features;
zap_codec_t effective_codec;
zap_codec_t native_codec;
uint32_t effective_interval;
uint32_t native_interval;
uint32_t packet_len;
zap_channel_state_t state;
zap_channel_state_t last_state;
zap_channel_state_t init_state;
zap_mutex_t *mutex;
teletone_dtmf_detect_state_t dtmf_detect;
uint32_t buffer_delay;
zap_event_t event_header;
char last_error[256];
zio_event_cb_t event_callback;
uint32_t skip_read_frames;
zap_buffer_t *dtmf_buffer;
zap_buffer_t *gen_dtmf_buffer;
zap_buffer_t *pre_buffer;
zap_buffer_t *digit_buffer;
zap_buffer_t *fsk_buffer;
zap_mutex_t *pre_buffer_mutex;
uint32_t dtmf_on;
uint32_t dtmf_off;
char *dtmf_hangup_buf;
teletone_generation_session_t tone_session;
zap_time_t last_event_time;
zap_time_t ring_time;
char tokens[ZAP_MAX_TOKENS+1][ZAP_TOKEN_STRLEN];
uint8_t needed_tones[ZAP_TONEMAP_INVALID];
uint8_t detected_tones[ZAP_TONEMAP_INVALID];
zap_tonemap_t last_detected_tone;
uint32_t token_count;
char chan_name[128];
char chan_number[32];
zap_filehandle_t fds[2];
zap_fsk_data_state_t fsk;
uint8_t fsk_buf[80];
uint32_t ring_count;
void *mod_data;
void *call_data;
struct zap_caller_data caller_data;
struct zap_span *span;
struct zap_io_interface *zio;
zap_hash_t *variable_hash;
unsigned char rx_cas_bits;
uint32_t pre_buffer_size;
unsigned char rxgain_table[ZAP_GAINS_TABLE_SIZE];
unsigned char txgain_table[ZAP_GAINS_TABLE_SIZE];
float rxgain;
float txgain;
};
struct zap_sigmsg {
zap_signal_event_t event_id;
uint32_t chan_id;
uint32_t span_id;
zap_channel_t *channel;
void *raw_data;
uint32_t raw_data_len;
};
struct zap_span {
zap_data_type_t data_type;
char *name;
uint32_t span_id;
uint32_t chan_count;
zap_span_flag_t flags;
struct zap_io_interface *zio;
zio_event_cb_t event_callback;
zap_mutex_t *mutex;
zap_trunk_type_t trunk_type;
zap_analog_start_type_t start_type;
zap_signal_type_t signal_type;
void *signal_data;
zap_event_t event_header;
char last_error[256];
char tone_map[ZAP_TONEMAP_INVALID+1][ZAP_TONEMAP_LEN];
teletone_tone_map_t tone_detect_map[ZAP_TONEMAP_INVALID+1];
teletone_multi_tone_t tone_finder[ZAP_TONEMAP_INVALID+1];
zap_channel_t *channels[ZAP_MAX_CHANNELS_SPAN+1];
zio_channel_outgoing_call_t outgoing_call;
zio_channel_set_sig_status_t set_channel_sig_status;
zio_channel_get_sig_status_t get_channel_sig_status;
zio_span_set_sig_status_t set_span_sig_status;
zio_span_get_sig_status_t get_span_sig_status;
zio_channel_request_t channel_request;
zap_span_start_t start;
zap_span_stop_t stop;
void *mod_data;
char *type;
char *dtmf_hangup;
size_t dtmf_hangup_len;
int suggest_chan_id;
zap_state_map_t *state_map;
struct zap_span *next;
};
struct zap_group {
char *name;
uint32_t group_id;
uint32_t chan_count;
zap_channel_t *channels[ZAP_MAX_CHANNELS_GROUP];
uint32_t last_used_index;
zap_mutex_t *mutex;
struct zap_group *next;
};
OZ_DECLARE_DATA extern zap_logger_t zap_log;
typedef enum {
ZAP_CRASH_NEVER = 0,
ZAP_CRASH_ON_ASSERT
} zap_crash_policy_t;
OZ_DECLARE_DATA extern zap_crash_policy_t g_zap_crash_policy;
typedef void *(*zap_malloc_func_t)(void *pool, zap_size_t len);
typedef void *(*zap_calloc_func_t)(void *pool, zap_size_t elements, zap_size_t len);
typedef void (*zap_free_func_t)(void *pool, void *ptr);
typedef struct zap_memory_handler {
void *pool;
zap_malloc_func_t malloc;
zap_calloc_func_t calloc;
zap_free_func_t free;
} zap_memory_handler_t;
OZ_DECLARE_DATA extern zap_memory_handler_t g_zap_mem_handler;
struct zap_io_interface {
const char *name;
zio_configure_span_t configure_span;
zio_configure_t configure;
zio_open_t open;
zio_close_t close;
zio_channel_destroy_t channel_destroy;
zio_span_destroy_t span_destroy;
zio_get_alarms_t get_alarms;
zio_command_t command;
zio_wait_t wait;
zio_read_t read;
zio_write_t write;
zio_span_poll_event_t poll_event;
zio_span_next_event_t next_event;
zio_api_t api;
};
typedef struct zap_queue zap_queue_t;
typedef zap_status_t (*zap_queue_create_func_t)(zap_queue_t **queue, zap_size_t capacity);
typedef zap_status_t (*zap_queue_enqueue_func_t)(zap_queue_t *queue, void *obj);
typedef void *(*zap_queue_dequeue_func_t)(zap_queue_t *queue);
typedef zap_status_t (*zap_queue_wait_func_t)(zap_queue_t *queue, int ms);
typedef zap_status_t (*zap_queue_destroy_func_t)(zap_queue_t **queue);
typedef struct zap_queue_handler {
zap_queue_create_func_t create;
zap_queue_enqueue_func_t enqueue;
zap_queue_dequeue_func_t dequeue;
zap_queue_wait_func_t wait;
zap_queue_destroy_func_t destroy;
} zap_queue_handler_t;
OZ_DECLARE_DATA extern zap_queue_handler_t g_zap_queue_handler;
/*! brief create a new queue */
#define zap_queue_create(queue, capacity) g_zap_queue_handler.create(queue, capacity)
/*! Enqueue an object */
#define zap_queue_enqueue(queue, obj) g_zap_queue_handler.enqueue(queue, obj)
/*! dequeue an object from the queue */
#define zap_queue_dequeue(queue) g_zap_queue_handler.dequeue(queue)
/*! wait ms milliseconds for a queue to have available objects, -1 to wait forever */
#define zap_queue_wait(queue, ms) g_zap_queue_handler.wait(queue, ms)
/*! destroy the queue */
#define zap_queue_destroy(queue) g_zap_queue_handler.destroy(queue)
/*! \brief Override the default queue handler */
OZ_DECLARE(zap_status_t) zap_global_set_queue_handler(zap_queue_handler_t *handler);
/*! \brief Duplicate string */
OZ_DECLARE(char *) zap_strdup(const char *str);
OZ_DECLARE(char *) zap_strndup(const char *str, zap_size_t inlen);
OZ_DECLARE(zap_size_t) zap_fsk_modulator_generate_bit(zap_fsk_modulator_t *fsk_trans, int8_t bit, int16_t *buf, zap_size_t buflen);
OZ_DECLARE(int32_t) zap_fsk_modulator_generate_carrier_bits(zap_fsk_modulator_t *fsk_trans, uint32_t bits);
OZ_DECLARE(void) zap_fsk_modulator_generate_chan_sieze(zap_fsk_modulator_t *fsk_trans);
OZ_DECLARE(void) zap_fsk_modulator_send_data(zap_fsk_modulator_t *fsk_trans);
#define zap_fsk_modulator_send_all(_it) zap_fsk_modulator_generate_chan_sieze(_it); \
zap_fsk_modulator_generate_carrier_bits(_it, _it->carrier_bits_start); \
zap_fsk_modulator_send_data(_it); \
zap_fsk_modulator_generate_carrier_bits(_it, _it->carrier_bits_stop)
OZ_DECLARE(zap_status_t) zap_fsk_modulator_init(zap_fsk_modulator_t *fsk_trans,
fsk_modem_types_t modem_type,
uint32_t sample_rate,
zap_fsk_data_state_t *fsk_data,
float db_level,
uint32_t carrier_bits_start,
uint32_t carrier_bits_stop,
uint32_t chan_sieze_bits,
zap_fsk_write_sample_t write_sample_callback,
void *user_data);
OZ_DECLARE(int8_t) zap_bitstream_get_bit(zap_bitstream_t *bsp);
OZ_DECLARE(void) zap_bitstream_init(zap_bitstream_t *bsp, uint8_t *data, uint32_t datalen, zap_endian_t endian, uint8_t ss);
OZ_DECLARE(zap_status_t) zap_fsk_data_parse(zap_fsk_data_state_t *state, zap_size_t *type, char **data, zap_size_t *len);
OZ_DECLARE(zap_status_t) zap_fsk_demod_feed(zap_fsk_data_state_t *state, int16_t *data, size_t samples);
OZ_DECLARE(zap_status_t) zap_fsk_demod_destroy(zap_fsk_data_state_t *state);
OZ_DECLARE(int) zap_fsk_demod_init(zap_fsk_data_state_t *state, int rate, uint8_t *buf, size_t bufsize);
OZ_DECLARE(zap_status_t) zap_fsk_data_init(zap_fsk_data_state_t *state, uint8_t *data, uint32_t datalen);
OZ_DECLARE(zap_status_t) zap_fsk_data_add_mdmf(zap_fsk_data_state_t *state, zap_mdmf_type_t type, const uint8_t *data, uint32_t datalen);
OZ_DECLARE(zap_status_t) zap_fsk_data_add_checksum(zap_fsk_data_state_t *state);
OZ_DECLARE(zap_status_t) zap_fsk_data_add_sdmf(zap_fsk_data_state_t *state, const char *date, char *number);
OZ_DECLARE(zap_status_t) zap_channel_outgoing_call(zap_channel_t *zchan);
OZ_DECLARE(zap_status_t) zap_channel_set_sig_status(zap_channel_t *zchan, zap_signaling_status_t status);
OZ_DECLARE(zap_status_t) zap_channel_get_sig_status(zap_channel_t *zchan, zap_signaling_status_t *status);
OZ_DECLARE(zap_status_t) zap_span_set_sig_status(zap_span_t *span, zap_signaling_status_t status);
OZ_DECLARE(zap_status_t) zap_span_get_sig_status(zap_span_t *span, zap_signaling_status_t *status);
OZ_DECLARE(void) zap_channel_rotate_tokens(zap_channel_t *zchan);
OZ_DECLARE(void) zap_channel_clear_detected_tones(zap_channel_t *zchan);
OZ_DECLARE(void) zap_channel_clear_needed_tones(zap_channel_t *zchan);
OZ_DECLARE(zap_status_t) zap_channel_get_alarms(zap_channel_t *zchan);
OZ_DECLARE(zap_status_t) zap_channel_send_fsk_data(zap_channel_t *zchan, zap_fsk_data_state_t *fsk_data, float db_level);
OZ_DECLARE(zap_status_t) zap_channel_clear_token(zap_channel_t *zchan, const char *token);
OZ_DECLARE(void) zap_channel_replace_token(zap_channel_t *zchan, const char *old_token, const char *new_token);
OZ_DECLARE(zap_status_t) zap_channel_add_token(zap_channel_t *zchan, char *token, int end);
OZ_DECLARE(zap_status_t) zap_channel_set_state(zap_channel_t *zchan, zap_channel_state_t state, int lock);
OZ_DECLARE(zap_status_t) zap_span_load_tones(zap_span_t *span, const char *mapname);
OZ_DECLARE(zap_size_t) zap_channel_dequeue_dtmf(zap_channel_t *zchan, char *dtmf, zap_size_t len);
OZ_DECLARE(zap_status_t) zap_channel_queue_dtmf(zap_channel_t *zchan, const char *dtmf);
OZ_DECLARE(void) zap_channel_flush_dtmf(zap_channel_t *zchan);
OZ_DECLARE(zap_time_t) zap_current_time_in_ms(void);
OZ_DECLARE(zap_status_t) zap_span_poll_event(zap_span_t *span, uint32_t ms);
OZ_DECLARE(zap_status_t) zap_span_next_event(zap_span_t *span, zap_event_t **event);
OZ_DECLARE(zap_status_t) zap_span_find(uint32_t id, zap_span_t **span);
OZ_DECLARE(zap_status_t) zap_span_create(zap_io_interface_t *zio, zap_span_t **span, const char *name);
OZ_DECLARE(zap_status_t) zap_span_close_all(void);
OZ_DECLARE(zap_status_t) zap_span_add_channel(zap_span_t *span, zap_socket_t sockfd, zap_chan_type_t type, zap_channel_t **chan);
OZ_DECLARE(zap_status_t) zap_span_set_event_callback(zap_span_t *span, zio_event_cb_t event_callback);
OZ_DECLARE(zap_status_t) zap_channel_add_to_group(const char* name, zap_channel_t* zchan);
OZ_DECLARE(zap_status_t) zap_group_add_channels(const char* name, zap_span_t* span, const char* val);
OZ_DECLARE(zap_status_t) zap_channel_remove_from_group(zap_group_t* group, zap_channel_t* zchan);
OZ_DECLARE(zap_status_t) zap_group_find(uint32_t id, zap_group_t **group);
OZ_DECLARE(zap_status_t) zap_group_find_by_name(const char *name, zap_group_t **group);
OZ_DECLARE(zap_status_t) zap_group_create(zap_group_t **group, const char *name);
OZ_DECLARE(zap_status_t) zap_channel_set_event_callback(zap_channel_t *zchan, zio_event_cb_t event_callback);
OZ_DECLARE(zap_status_t) zap_channel_open(uint32_t span_id, uint32_t chan_id, zap_channel_t **zchan);
OZ_DECLARE(zap_status_t) zap_channel_open_chan(zap_channel_t *zchan);
OZ_DECLARE(zap_status_t) zap_span_channel_use_count(zap_span_t *span, uint32_t *count);
OZ_DECLARE(zap_status_t) zap_group_channel_use_count(zap_group_t *group, uint32_t *count);
OZ_DECLARE(zap_status_t) zap_channel_open_by_span(uint32_t span_id, zap_direction_t direction, zap_caller_data_t *caller_data, zap_channel_t **zchan);
OZ_DECLARE(zap_status_t) zap_channel_open_by_group(uint32_t group_id, zap_direction_t direction, zap_caller_data_t *caller_data, zap_channel_t **zchan);
OZ_DECLARE(zap_status_t) zap_channel_close(zap_channel_t **zchan);
OZ_DECLARE(zap_status_t) zap_channel_done(zap_channel_t *zchan);
OZ_DECLARE(zap_status_t) zap_channel_use(zap_channel_t *zchan);
OZ_DECLARE(zap_status_t) zap_channel_command(zap_channel_t *zchan, zap_command_t command, void *obj);
OZ_DECLARE(zap_status_t) zap_channel_wait(zap_channel_t *zchan, zap_wait_flag_t *flags, int32_t to);
OZ_DECLARE(zap_status_t) zap_channel_read(zap_channel_t *zchan, void *data, zap_size_t *datalen);
OZ_DECLARE(void) zap_generate_sln_silence(int16_t *data, uint32_t samples, uint32_t divisor);
OZ_DECLARE(zap_status_t) zap_channel_write(zap_channel_t *zchan, void *data, zap_size_t datasize, zap_size_t *datalen);
OZ_DECLARE(zap_status_t) zap_channel_add_var(zap_channel_t *zchan, const char *var_name, const char *value);
OZ_DECLARE(const char *) zap_channel_get_var(zap_channel_t *zchan, const char *var_name);
OZ_DECLARE(zap_status_t) zap_channel_clear_vars(zap_channel_t *zchan);
OZ_DECLARE(zap_status_t) zap_global_init(void);
OZ_DECLARE(zap_status_t) zap_global_configuration(void);
OZ_DECLARE(zap_status_t) zap_global_destroy(void);
OZ_DECLARE(zap_status_t) zap_global_set_memory_handler(zap_memory_handler_t *handler);
OZ_DECLARE(void) zap_global_set_crash_policy(zap_crash_policy_t policy);
OZ_DECLARE(void) zap_global_set_logger(zap_logger_t logger);
OZ_DECLARE(void) zap_global_set_default_logger(int level);
OZ_DECLARE(uint32_t) zap_separate_string(char *buf, char delim, char **array, int arraylen);
OZ_DECLARE(void) print_bits(uint8_t *b, int bl, char *buf, int blen, int e, uint8_t ss);
OZ_DECLARE(void) print_hex_bytes(uint8_t *data, zap_size_t dlen, char *buf, zap_size_t blen);
OZ_DECLARE_NONSTD(int) zap_hash_equalkeys(void *k1, void *k2);
OZ_DECLARE_NONSTD(uint32_t) zap_hash_hashfromstring(void *ky);
OZ_DECLARE(uint32_t) zap_running(void);
OZ_DECLARE(zap_status_t) zap_channel_complete_state(zap_channel_t *zchan);
OZ_DECLARE(zap_status_t) zap_channel_init(zap_channel_t *zchan);
OZ_DECLARE(int) zap_load_modules(void);
OZ_DECLARE(zap_status_t) zap_unload_modules(void);
OZ_DECLARE(zap_status_t) zap_configure_span(const char *type, zap_span_t *span, zio_signal_cb_t sig_cb, ...);
OZ_DECLARE(zap_status_t) zap_configure_span_signaling(const char *type, zap_span_t *span, zio_signal_cb_t sig_cb, zap_conf_parameter_t *parameters);
OZ_DECLARE(zap_status_t) zap_span_start(zap_span_t *span);
OZ_DECLARE(zap_status_t) zap_span_stop(zap_span_t *span);
OZ_DECLARE(char *) zap_build_dso_path(const char *name, char *path, zap_size_t len);
OZ_DECLARE(zap_status_t) zap_global_add_io_interface(zap_io_interface_t *io_interface);
OZ_DECLARE(int) zap_load_module(const char *name);
OZ_DECLARE(int) zap_load_module_assume(const char *name);
OZ_DECLARE(zap_status_t) zap_span_find_by_name(const char *name, zap_span_t **span);
OZ_DECLARE(char *) zap_api_execute(const char *type, const char *cmd);
OZ_DECLARE(int) zap_vasprintf(char **ret, const char *fmt, va_list ap);
ZIO_CODEC_FUNCTION(zio_slin2ulaw);
ZIO_CODEC_FUNCTION(zio_ulaw2slin);
ZIO_CODEC_FUNCTION(zio_slin2alaw);
ZIO_CODEC_FUNCTION(zio_alaw2slin);
ZIO_CODEC_FUNCTION(zio_ulaw2alaw);
ZIO_CODEC_FUNCTION(zio_alaw2ulaw);
#ifdef DEBUG_LOCKS
#define zap_mutex_lock(_x) printf("++++++lock %s:%d\n", __FILE__, __LINE__) && _zap_mutex_lock(_x)
#define zap_mutex_trylock(_x) printf("++++++try %s:%d\n", __FILE__, __LINE__) && _zap_mutex_trylock(_x)
#define zap_mutex_unlock(_x) printf("------unlock %s:%d\n", __FILE__, __LINE__) && _zap_mutex_unlock(_x)
#else
#define zap_mutex_lock(_x) _zap_mutex_lock(_x)
#define zap_mutex_trylock(_x) _zap_mutex_trylock(_x)
#define zap_mutex_unlock(_x) _zap_mutex_unlock(_x)
#endif
/*!
\brief Assert condition
*/
#define zap_assert(assertion, msg) \
if (!(assertion)) { \
zap_log(ZAP_LOG_CRIT, msg); \
if (g_zap_crash_policy & ZAP_CRASH_ON_ASSERT) { \
zap_abort(); \
} \
}
/*!
\brief Assert condition and return
*/
#define zap_assert_return(assertion, retval, msg) \
if (!(assertion)) { \
zap_log(ZAP_LOG_CRIT, msg); \
if (g_zap_crash_policy & ZAP_CRASH_ON_ASSERT) { \
zap_abort(); \
} else { \
return retval; \
} \
}
/*!
\brief Allocate uninitialized memory
\command chunksize the chunk size
*/
#define zap_malloc(chunksize) g_zap_mem_handler.malloc(g_zap_mem_handler.pool, chunksize)
/*!
\brief Allocate initialized memory
\command chunksize the chunk size
*/
#define zap_calloc(elements, chunksize) g_zap_mem_handler.calloc(g_zap_mem_handler.pool, elements, chunksize)
/*!
\brief Free chunk of memory
\command chunksize the chunk size
*/
#define zap_free(chunk) g_zap_mem_handler.free(g_zap_mem_handler.pool, chunk)
/*!
\brief Free a pointer and set it to NULL unless it already is NULL
\command it the pointer
*/
#define zap_safe_free(it) if (it) { zap_free(it); it = NULL; }
/*!
\brief Socket the given socket
\command it the socket
*/
#define zap_socket_close(it) if (it > -1) { close(it); it = -1;}
static __inline__ void zap_abort(void)
{
#ifdef __cplusplus
::abort();
#else
abort();
#endif
}
static __inline__ void zap_set_state_all(zap_span_t *span, zap_channel_state_t state)
{
uint32_t j;
zap_mutex_lock(span->mutex);
for(j = 1; j <= span->chan_count; j++) {
zap_set_state_locked((span->channels[j]), state);
}
zap_mutex_unlock(span->mutex);
}
static __inline__ int zap_check_state_all(zap_span_t *span, zap_channel_state_t state)
{
uint32_t j;
for(j = 1; j <= span->chan_count; j++) {
if (span->channels[j]->state != state || zap_test_flag(span->channels[j], ZAP_CHANNEL_STATE_CHANGE)) {
return 0;
}
}
return 1;
}
static __inline__ void zap_set_flag_all(zap_span_t *span, uint32_t flag)
{
uint32_t j;
zap_mutex_lock(span->mutex);
for(j = 1; j <= span->chan_count; j++) {
zap_set_flag_locked((span->channels[j]), flag);
}
zap_mutex_unlock(span->mutex);
}
static __inline__ void zap_clear_flag_all(zap_span_t *span, uint32_t flag)
{
uint32_t j;
zap_mutex_lock(span->mutex);
for(j = 1; j <= span->chan_count; j++) {
zap_clear_flag_locked((span->channels[j]), flag);
}
zap_mutex_unlock(span->mutex);
}
#ifdef __cplusplus
} /* extern C */
#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:
*/

View File

@@ -1,154 +0,0 @@
/*
* 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 ZAP_BUFFER_H
#define ZAP_BUFFER_H
#include "openzap.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup zap_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 zap_buffer;
typedef struct zap_buffer zap_buffer_t;
/*! \brief Allocate a new dynamic zap_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
*/
OZ_DECLARE(zap_status_t) zap_buffer_create(zap_buffer_t **buffer, zap_size_t blocksize, zap_size_t start_len, zap_size_t max_len);
/*! \brief Get the length of a zap_buffer_t
* \param buffer any buffer of type zap_buffer_t
* \return int size of the buffer.
*/
OZ_DECLARE(zap_size_t) zap_buffer_len(zap_buffer_t *buffer);
/*! \brief Get the freespace of a zap_buffer_t
* \param buffer any buffer of type zap_buffer_t
* \return int freespace in the buffer.
*/
OZ_DECLARE(zap_size_t) zap_buffer_freespace(zap_buffer_t *buffer);
/*! \brief Get the in use amount of a zap_buffer_t
* \param buffer any buffer of type zap_buffer_t
* \return int ammount of buffer curently in use
*/
OZ_DECLARE(zap_size_t) zap_buffer_inuse(zap_buffer_t *buffer);
/*! \brief Read data from a zap_buffer_t up to the ammount of datalen if it is available. Remove read data from buffer.
* \param buffer any buffer of type zap_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
*/
OZ_DECLARE(zap_size_t) zap_buffer_read(zap_buffer_t *buffer, void *data, zap_size_t datalen);
/*! \brief Read data endlessly from a zap_buffer_t
* \param buffer any buffer of type zap_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.
*/
OZ_DECLARE(zap_size_t) zap_buffer_read_loop(zap_buffer_t *buffer, void *data, zap_size_t datalen);
/*! \brief Assign a number of loops to read
* \param buffer any buffer of type zap_buffer_t
* \param loops the number of loops (-1 for infinite)
*/
OZ_DECLARE(void) zap_buffer_set_loops(zap_buffer_t *buffer, int32_t loops);
/*! \brief Write data into a zap_buffer_t up to the length of datalen
* \param buffer any buffer of type zap_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
*/
OZ_DECLARE(zap_size_t) zap_buffer_write(zap_buffer_t *buffer, const void *data, zap_size_t datalen);
/*! \brief Remove data from the buffer
* \param buffer any buffer of type zap_buffer_t
* \param datalen amount of data to be removed
* \return int size of buffer, or 0 if unable to toss that much data
*/
OZ_DECLARE(zap_size_t) zap_buffer_toss(zap_buffer_t *buffer, zap_size_t datalen);
/*! \brief Remove all data from the buffer
* \param buffer any buffer of type zap_buffer_t
*/
OZ_DECLARE(void) zap_buffer_zero(zap_buffer_t *buffer);
/*! \brief Destroy the buffer
* \param buffer buffer to destroy
* \note only neccessary on dynamic buffers (noop on pooled ones)
*/
OZ_DECLARE(void) zap_buffer_destroy(zap_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
*/
OZ_DECLARE(zap_size_t) zap_buffer_seek(zap_buffer_t *buffer, zap_size_t datalen);
/** @} */
OZ_DECLARE(zap_size_t) zap_buffer_zwrite(zap_buffer_t *buffer, const void *data, zap_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:
*/

View File

@@ -1,145 +0,0 @@
/*
* 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
*
* <pre>
*
* EXAMPLE
*
* [category1]
* var1 => val1
* var2 => val2
* \# lines that begin with \# are comments
* \#var3 => val3
* </pre>
* @{
*/
#ifndef ZAP_CONFIG_H
#define ZAP_CONFIG_H
#include "openzap.h"
#define ZAP_URL_SEPARATOR "://"
#ifdef WIN32
#define ZAP_PATH_SEPARATOR "\\"
#ifndef ZAP_CONFIG_DIR
#define ZAP_CONFIG_DIR "c:\\openzap"
#endif
#define zap_is_file_path(file) (*(file +1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR))
#else
#define ZAP_PATH_SEPARATOR "/"
#ifndef ZAP_CONFIG_DIR
#define ZAP_CONFIG_DIR "/etc/openzap"
#endif
#define zap_is_file_path(file) ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR))
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct zap_config zap_config_t;
/*! \brief A simple file handle representing an open configuration file **/
struct zap_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 (zap_config_t *) config handle to use
\param file_path path to the file
\return 1 (true) on success 0 (false) on failure
*/
int zap_config_open_file(zap_config_t * cfg, const char *file_path);
/*!
\brief Close a previously opened configuration file
\param cfg (zap_config_t *) config handle to use
*/
void zap_config_close_file(zap_config_t * cfg);
/*!
\brief Retrieve next name/value pair from configuration file
\param cfg (zap_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 zap_config_next_pair(zap_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
*/
OZ_DECLARE (int) zap_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:
*/

View File

@@ -1,51 +0,0 @@
/*
* 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 _ZAP_DSO_H
#define _ZAP_DSO_H
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*zap_func_ptr_t) (void);
typedef void * zap_dso_lib_t;
OZ_DECLARE(void) zap_dso_destroy(zap_dso_lib_t *lib);
OZ_DECLARE(zap_dso_lib_t) zap_dso_open(const char *path, char **err);
OZ_DECLARE(void *) zap_dso_func_sym(zap_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
*/

View File

@@ -1,134 +0,0 @@
/*
* zap_m3ua.h
* openzap
*
* 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 "openzap.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"
ZAP_STR2ENUM_P(m3ua_str2span, m3ua_span2str, M3UA_TSpanSignaling)
typedef enum {
ZAP_M3UA_RUNNING = (1 << 0)
} zap_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;
} zap_m3ua_data_t;
*/
zap_status_t m3ua_init(zap_io_interface_t **zint);
zap_status_t m3ua_destroy(void);
zap_status_t m3ua_start(zap_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:
*/

View File

@@ -1,67 +0,0 @@
/*
* 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 <moy@sangoma.com>
*
*/
#ifndef _ZAP_THREADMUTEX_H
#define _ZAP_THREADMUTEX_H
#include "openzap.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct zap_mutex zap_mutex_t;
typedef struct zap_thread zap_thread_t;
typedef struct zap_condition zap_condition_t;
typedef void *(*zap_thread_function_t) (zap_thread_t *, void *);
OZ_DECLARE(zap_status_t) zap_thread_create_detached(zap_thread_function_t func, void *data);
OZ_DECLARE(zap_status_t) zap_thread_create_detached_ex(zap_thread_function_t func, void *data, zap_size_t stack_size);
OZ_DECLARE(void) zap_thread_override_default_stacksize(zap_size_t size);
OZ_DECLARE(zap_status_t) zap_mutex_create(zap_mutex_t **mutex);
OZ_DECLARE(zap_status_t) zap_mutex_destroy(zap_mutex_t **mutex);
OZ_DECLARE(zap_status_t) _zap_mutex_lock(zap_mutex_t *mutex);
OZ_DECLARE(zap_status_t) _zap_mutex_trylock(zap_mutex_t *mutex);
OZ_DECLARE(zap_status_t) _zap_mutex_unlock(zap_mutex_t *mutex);
OZ_DECLARE(zap_status_t) zap_condition_create(zap_condition_t **cond, zap_mutex_t *mutex);
OZ_DECLARE(zap_status_t) zap_condition_destroy(zap_condition_t **cond);
OZ_DECLARE(zap_status_t) zap_condition_signal(zap_condition_t *cond);
OZ_DECLARE(zap_status_t) zap_condition_wait(zap_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:
*/

View File

@@ -1,703 +0,0 @@
/*
* 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 <moy@sangoma.com>
*
*/
#ifndef ZAP_TYPES_H
#define ZAP_TYPES_H
#include "fsk.h"
#ifdef WIN32
#include <windows.h>
typedef HANDLE zap_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 zap_ssize_t;
typedef int zap_filehandle_t;
#else
#include <stdint.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <stdarg.h>
typedef int zap_socket_t;
typedef ssize_t zap_ssize_t;
typedef int zap_filehandle_t;
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define TAG_END NULL
typedef size_t zap_size_t;
struct zap_io_interface;
#define ZAP_COMMAND_OBJ_INT *((int *)obj)
#define ZAP_COMMAND_OBJ_CHAR_P (char *)obj
#define ZAP_COMMAND_OBJ_FLOAT *(float *)obj
#define ZAP_FSK_MOD_FACTOR 0x10000
#define ZAP_DEFAULT_DTMF_ON 250
#define ZAP_DEFAULT_DTMF_OFF 50
#define ZAP_END -1
#define ZAP_ANY_STATE -1
typedef uint64_t zap_time_t;
typedef enum {
ZAP_ENDIAN_BIG = 1,
ZAP_ENDIAN_LITTLE = -1
} zap_endian_t;
typedef enum {
ZAP_CID_TYPE_SDMF = 0x04,
ZAP_CID_TYPE_MDMF = 0x80
} zap_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
} zap_mdmf_type_t;
#define MDMF_STRINGS "X", "DATETIME", "PHONE_NUM", "DDN", "NO_NUM", "X", "X", "PHONE_NAME", "NO_NAME", "ALT_ROUTE", "INVALID"
ZAP_STR2ENUM_P(zap_str2zap_mdmf_type, zap_mdmf_type2str, zap_mdmf_type_t)
#define ZAP_TONEMAP_LEN 128
typedef enum {
ZAP_TONEMAP_NONE,
ZAP_TONEMAP_DIAL,
ZAP_TONEMAP_RING,
ZAP_TONEMAP_BUSY,
ZAP_TONEMAP_FAIL1,
ZAP_TONEMAP_FAIL2,
ZAP_TONEMAP_FAIL3,
ZAP_TONEMAP_ATTN,
ZAP_TONEMAP_CALLWAITING_CAS,
ZAP_TONEMAP_CALLWAITING_SAS,
ZAP_TONEMAP_CALLWAITING_ACK,
ZAP_TONEMAP_INVALID
} zap_tonemap_t;
#define TONEMAP_STRINGS "NONE", "DIAL", "RING", "BUSY", "FAIL1", "FAIL2", "FAIL3", "ATTN", "CALLWAITING-CAS", "CALLWAITING-SAS", "CALLWAITING-ACK", "INVALID"
ZAP_STR2ENUM_P(zap_str2zap_tonemap, zap_tonemap2str, zap_tonemap_t)
typedef enum {
ZAP_TRUNK_E1,
ZAP_TRUNK_T1,
ZAP_TRUNK_J1,
ZAP_TRUNK_BRI,
ZAP_TRUNK_BRI_PTMP,
ZAP_TRUNK_FXO,
ZAP_TRUNK_FXS,
ZAP_TRUNK_EM,
ZAP_TRUNK_NONE
} zap_trunk_type_t;
#define TRUNK_STRINGS "E1", "T1", "J1", "BRI", "BRI_PTMP", "FXO", "FXS", "EM", "NONE"
ZAP_STR2ENUM_P(zap_str2zap_trunk_type, zap_trunk_type2str, zap_trunk_type_t)
typedef enum {
ZAP_ANALOG_START_KEWL,
ZAP_ANALOG_START_LOOP,
ZAP_ANALOG_START_GROUND,
ZAP_ANALOG_START_WINK,
ZAP_ANALOG_START_NA
} zap_analog_start_type_t;
#define START_TYPE_STRINGS "KEWL", "LOOP", "GROUND", "WINK", "NA"
ZAP_STR2ENUM_P(zap_str2zap_analog_start_type, zap_analog_start_type2str, zap_analog_start_type_t)
typedef enum {
ZAP_OOB_ONHOOK,
ZAP_OOB_OFFHOOK,
ZAP_OOB_WINK,
ZAP_OOB_FLASH,
ZAP_OOB_RING_START,
ZAP_OOB_RING_STOP,
ZAP_OOB_ALARM_TRAP,
ZAP_OOB_ALARM_CLEAR,
ZAP_OOB_NOOP,
ZAP_OOB_CAS_BITS_CHANGE,
ZAP_OOB_INVALID
} zap_oob_event_t;
#define OOB_STRINGS "DTMF", "ONHOOK", "OFFHOOK", "WINK", "FLASH", "RING_START", "RING_STOP", "ALARM_TRAP", "ALARM_CLEAR", "NOOP", "CAS_BITS_CHANGE", "INVALID"
ZAP_STR2ENUM_P(zap_str2zap_oob_event, zap_oob_event2str, zap_oob_event_t)
typedef enum {
ZAP_ALARM_NONE = 0,
ZAP_ALARM_RECOVER = (1 << 0),
ZAP_ALARM_LOOPBACK = (1 << 2),
ZAP_ALARM_YELLOW = (1 << 3),
ZAP_ALARM_RED = (1 << 4),
ZAP_ALARM_BLUE = (1 << 5),
ZAP_ALARM_NOTOPEN = ( 1 << 6),
ZAP_ALARM_AIS = ( 1 << 7),
ZAP_ALARM_RAI = ( 1 << 8),
ZAP_ALARM_GENERAL = ( 1 << 30)
} zap_alarm_flag_t;
typedef enum {
ZAP_SIGTYPE_NONE,
ZAP_SIGTYPE_ISDN,
ZAP_SIGTYPE_RBS,
ZAP_SIGTYPE_ANALOG,
ZAP_SIGTYPE_SANGOMABOOST,
ZAP_SIGTYPE_M3UA,
ZAP_SIGTYPE_R2
} zap_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) */
ZAP_SIG_STATE_DOWN,
/* The signaling link is suspended (MFC-R2 bit pattern blocked, ss7 blocked?) */
ZAP_SIG_STATE_SUSPENDED,
/* The signaling link is ready and calls can be placed */
ZAP_SIG_STATE_UP,
/* Invalid status */
ZAP_SIG_STATE_INVALID
} zap_signaling_status_t;
#define SIGSTATUS_STRINGS "DOWN", "SUSPENDED", "UP", "INVALID"
ZAP_STR2ENUM_P(zap_str2zap_signaling_status, zap_signaling_status2str, zap_signaling_status_t)
typedef enum {
ZAP_SIGEVENT_START,
ZAP_SIGEVENT_STOP,
ZAP_SIGEVENT_TRANSFER,
ZAP_SIGEVENT_ANSWER,
ZAP_SIGEVENT_UP,
ZAP_SIGEVENT_FLASH,
ZAP_SIGEVENT_PROGRESS,
ZAP_SIGEVENT_PROGRESS_MEDIA,
ZAP_SIGEVENT_NOTIFY,
ZAP_SIGEVENT_TONE_DETECTED,
ZAP_SIGEVENT_ALARM_TRAP,
ZAP_SIGEVENT_ALARM_CLEAR,
ZAP_SIGEVENT_MISC,
ZAP_SIGEVENT_COLLECTED_DIGIT,
ZAP_SIGEVENT_ADD_CALL,
ZAP_SIGEVENT_RESTART,
/* Signaling link status changed (D-chan up, down, R2 blocked etc) */
ZAP_SIGEVENT_SIGSTATUS_CHANGED,
/* Hardware link status changed (Line connected, disconnected) */
ZAP_SIGEVENT_HWSTATUS_CHANGED,
ZAP_SIGEVENT_INVALID
} zap_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"
ZAP_STR2ENUM_P(zap_str2zap_signal_event, zap_signal_event2str, zap_signal_event_t)
typedef enum {
ZAP_EVENT_NONE,
ZAP_EVENT_DTMF,
ZAP_EVENT_OOB,
ZAP_EVENT_COUNT
} zap_event_type_t;
typedef enum {
ZAP_TOP_DOWN,
ZAP_BOTTOM_UP
} zap_direction_t;
typedef enum {
ZAP_SUCCESS,
ZAP_FAIL,
ZAP_MEMERR,
ZAP_TIMEOUT,
ZAP_NOTIMPL,
ZAP_CHECKSUM_ERROR,
ZAP_STATUS_COUNT,
ZAP_BREAK
} zap_status_t;
typedef enum {
ZAP_NO_FLAGS = 0,
ZAP_READ = (1 << 0),
ZAP_WRITE = (1 << 1),
ZAP_EVENTS = (1 << 2)
} zap_wait_flag_t;
typedef enum {
ZAP_CODEC_ULAW = 0,
ZAP_CODEC_ALAW = 8,
ZAP_CODEC_SLIN = 10,
ZAP_CODEC_NONE = (1 << 30)
} zap_codec_t;
typedef enum {
ZAP_TONE_DTMF = (1 << 0)
} zap_tone_type_t;
typedef enum {
ZAP_COMMAND_NOOP,
ZAP_COMMAND_SET_INTERVAL,
ZAP_COMMAND_GET_INTERVAL,
ZAP_COMMAND_SET_CODEC,
ZAP_COMMAND_GET_CODEC,
ZAP_COMMAND_SET_NATIVE_CODEC,
ZAP_COMMAND_GET_NATIVE_CODEC,
ZAP_COMMAND_ENABLE_DTMF_DETECT,
ZAP_COMMAND_DISABLE_DTMF_DETECT,
ZAP_COMMAND_SEND_DTMF,
ZAP_COMMAND_SET_DTMF_ON_PERIOD,
ZAP_COMMAND_GET_DTMF_ON_PERIOD,
ZAP_COMMAND_SET_DTMF_OFF_PERIOD,
ZAP_COMMAND_GET_DTMF_OFF_PERIOD,
ZAP_COMMAND_GENERATE_RING_ON,
ZAP_COMMAND_GENERATE_RING_OFF,
ZAP_COMMAND_OFFHOOK,
ZAP_COMMAND_ONHOOK,
ZAP_COMMAND_FLASH,
ZAP_COMMAND_WINK,
ZAP_COMMAND_ENABLE_PROGRESS_DETECT,
ZAP_COMMAND_DISABLE_PROGRESS_DETECT,
ZAP_COMMAND_TRACE_INPUT,
ZAP_COMMAND_TRACE_OUTPUT,
ZAP_COMMAND_ENABLE_CALLERID_DETECT,
ZAP_COMMAND_DISABLE_CALLERID_DETECT,
ZAP_COMMAND_ENABLE_ECHOCANCEL,
ZAP_COMMAND_DISABLE_ECHOCANCEL,
ZAP_COMMAND_ENABLE_ECHOTRAIN,
ZAP_COMMAND_DISABLE_ECHOTRAIN,
ZAP_COMMAND_SET_CAS_BITS,
ZAP_COMMAND_GET_CAS_BITS,
ZAP_COMMAND_SET_RX_GAIN,
ZAP_COMMAND_GET_RX_GAIN,
ZAP_COMMAND_SET_TX_GAIN,
ZAP_COMMAND_GET_TX_GAIN,
ZAP_COMMAND_FLUSH_TX_BUFFERS,
ZAP_COMMAND_FLUSH_RX_BUFFERS,
ZAP_COMMAND_FLUSH_BUFFERS,
ZAP_COMMAND_SET_PRE_BUFFER_SIZE,
ZAP_COMMAND_SET_LINK_STATUS,
ZAP_COMMAND_GET_LINK_STATUS,
ZAP_COMMAND_COUNT
} zap_command_t;
typedef enum {
ZAP_SPAN_CONFIGURED = (1 << 0),
ZAP_SPAN_READY = (1 << 1),
ZAP_SPAN_STATE_CHANGE = (1 << 2),
ZAP_SPAN_SUSPENDED = (1 << 3),
ZAP_SPAN_IN_THREAD = (1 << 4),
ZAP_SPAN_STOP_THREAD = (1 << 5)
} zap_span_flag_t;
typedef enum {
ZAP_CHAN_TYPE_B,
ZAP_CHAN_TYPE_DQ921,
ZAP_CHAN_TYPE_DQ931,
ZAP_CHAN_TYPE_FXS,
ZAP_CHAN_TYPE_FXO,
ZAP_CHAN_TYPE_EM,
ZAP_CHAN_TYPE_CAS,
ZAP_CHAN_TYPE_COUNT
} zap_chan_type_t;
#define CHAN_TYPE_STRINGS "B", "DQ921", "DQ931", "FXS", "FXO", "EM", "CAS", "INVALID"
ZAP_STR2ENUM_P(zap_str2zap_chan_type, zap_chan_type2str, zap_chan_type_t)
typedef enum {
ZAP_CHANNEL_FEATURE_DTMF_DETECT = (1 << 0),
ZAP_CHANNEL_FEATURE_DTMF_GENERATE = (1 << 1),
ZAP_CHANNEL_FEATURE_CODECS = (1 << 2),
ZAP_CHANNEL_FEATURE_INTERVAL = (1 << 3),
ZAP_CHANNEL_FEATURE_CALLERID = (1 << 4),
ZAP_CHANNEL_FEATURE_PROGRESS = (1 << 5)
} zap_channel_feature_t;
typedef enum {
ZAP_CHANNEL_STATE_DOWN,
ZAP_CHANNEL_STATE_HOLD,
ZAP_CHANNEL_STATE_SUSPENDED,
ZAP_CHANNEL_STATE_DIALTONE,
ZAP_CHANNEL_STATE_COLLECT,
ZAP_CHANNEL_STATE_RING,
ZAP_CHANNEL_STATE_BUSY,
ZAP_CHANNEL_STATE_ATTN,
ZAP_CHANNEL_STATE_GENRING,
ZAP_CHANNEL_STATE_DIALING,
ZAP_CHANNEL_STATE_GET_CALLERID,
ZAP_CHANNEL_STATE_CALLWAITING,
ZAP_CHANNEL_STATE_RESTART,
ZAP_CHANNEL_STATE_PROGRESS,
ZAP_CHANNEL_STATE_PROGRESS_MEDIA,
ZAP_CHANNEL_STATE_UP,
ZAP_CHANNEL_STATE_IDLE,
ZAP_CHANNEL_STATE_TERMINATING,
ZAP_CHANNEL_STATE_CANCEL,
ZAP_CHANNEL_STATE_HANGUP,
ZAP_CHANNEL_STATE_HANGUP_COMPLETE,
ZAP_CHANNEL_STATE_INVALID
} zap_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"
ZAP_STR2ENUM_P(zap_str2zap_channel_state, zap_channel_state2str, zap_channel_state_t)
typedef enum {
ZAP_CHANNEL_CONFIGURED = (1 << 0),
ZAP_CHANNEL_READY = (1 << 1),
ZAP_CHANNEL_OPEN = (1 << 2),
ZAP_CHANNEL_DTMF_DETECT = (1 << 3),
ZAP_CHANNEL_SUPRESS_DTMF = (1 << 4),
ZAP_CHANNEL_TRANSCODE = (1 << 5),
ZAP_CHANNEL_BUFFER = (1 << 6),
ZAP_CHANNEL_EVENT = (1 << 7),
ZAP_CHANNEL_INTHREAD = (1 << 8),
ZAP_CHANNEL_WINK = (1 << 9),
ZAP_CHANNEL_FLASH = (1 << 10),
ZAP_CHANNEL_STATE_CHANGE = (1 << 11),
ZAP_CHANNEL_HOLD = (1 << 12),
ZAP_CHANNEL_INUSE = (1 << 13),
ZAP_CHANNEL_OFFHOOK = (1 << 14),
ZAP_CHANNEL_RINGING = (1 << 15),
ZAP_CHANNEL_PROGRESS_DETECT = (1 << 16),
ZAP_CHANNEL_CALLERID_DETECT = (1 << 17),
ZAP_CHANNEL_OUTBOUND = (1 << 18),
ZAP_CHANNEL_SUSPENDED = (1 << 19),
ZAP_CHANNEL_3WAY = (1 << 20),
ZAP_CHANNEL_PROGRESS = (1 << 21),
ZAP_CHANNEL_MEDIA = (1 << 22),
ZAP_CHANNEL_ANSWERED = (1 << 23),
ZAP_CHANNEL_MUTE = (1 << 24),
ZAP_CHANNEL_USE_RX_GAIN = (1 << 25),
ZAP_CHANNEL_USE_TX_GAIN = (1 << 26),
} zap_channel_flag_t;
#if defined(__cplusplus) && defined(WIN32)
// fix C2676
__inline__ zap_channel_flag_t operator|=(zap_channel_flag_t a, int32_t b) {
a = (zap_channel_flag_t)(a | b);
return a;
}
__inline__ zap_channel_flag_t operator&=(zap_channel_flag_t a, int32_t b) {
a = (zap_channel_flag_t)(a & b);
return a;
}
#endif
typedef enum {
ZSM_NONE,
ZSM_UNACCEPTABLE,
ZSM_ACCEPTABLE
} zap_state_map_type_t;
typedef enum {
ZSD_INBOUND,
ZSD_OUTBOUND,
} zap_state_direction_t;
#define ZAP_MAP_NODE_SIZE 512
#define ZAP_MAP_MAX ZAP_CHANNEL_STATE_INVALID+2
struct zap_state_map_node {
zap_state_direction_t direction;
zap_state_map_type_t type;
zap_channel_state_t check_states[ZAP_MAP_MAX];
zap_channel_state_t states[ZAP_MAP_MAX];
};
typedef struct zap_state_map_node zap_state_map_node_t;
struct zap_state_map {
zap_state_map_node_t nodes[ZAP_MAP_NODE_SIZE];
};
typedef struct zap_state_map zap_state_map_t;
typedef enum zap_channel_hw_link_status {
ZAP_HW_LINK_DISCONNECTED = 0,
ZAP_HW_LINK_CONNECTED
} zap_channel_hw_link_status_t;
typedef struct zap_conf_parameter_s {
const char *var;
const char *val;
} zap_conf_parameter_t;
typedef struct zap_channel zap_channel_t;
typedef struct zap_event zap_event_t;
typedef struct zap_sigmsg zap_sigmsg_t;
typedef struct zap_span zap_span_t;
typedef struct zap_group zap_group_t;
typedef struct zap_caller_data zap_caller_data_t;
typedef struct zap_io_interface zap_io_interface_t;
struct zap_stream_handle;
typedef struct zap_stream_handle zap_stream_handle_t;
typedef zap_status_t (*zap_stream_handle_raw_write_function_t) (zap_stream_handle_t *handle, uint8_t *data, zap_size_t datalen);
typedef zap_status_t (*zap_stream_handle_write_function_t) (zap_stream_handle_t *handle, const char *fmt, ...);
#define ZIO_CHANNEL_REQUEST_ARGS (zap_span_t *span, uint32_t chan_id, zap_direction_t direction, zap_caller_data_t *caller_data, zap_channel_t **zchan)
#define ZIO_CHANNEL_OUTGOING_CALL_ARGS (zap_channel_t *zchan)
#define ZIO_CHANNEL_SET_SIG_STATUS_ARGS (zap_channel_t *zchan, zap_signaling_status_t status)
#define ZIO_CHANNEL_GET_SIG_STATUS_ARGS (zap_channel_t *zchan, zap_signaling_status_t *status)
#define ZIO_SPAN_SET_SIG_STATUS_ARGS (zap_span_t *span, zap_signaling_status_t status)
#define ZIO_SPAN_GET_SIG_STATUS_ARGS (zap_span_t *span, zap_signaling_status_t *status)
#define ZIO_SPAN_POLL_EVENT_ARGS (zap_span_t *span, uint32_t ms)
#define ZIO_SPAN_NEXT_EVENT_ARGS (zap_span_t *span, zap_event_t **event)
#define ZIO_SIGNAL_CB_ARGS (zap_sigmsg_t *sigmsg)
#define ZIO_EVENT_CB_ARGS (zap_channel_t *zchan, zap_event_t *event)
#define ZIO_CODEC_ARGS (void *data, zap_size_t max, zap_size_t *datalen)
#define ZIO_CONFIGURE_SPAN_ARGS (zap_span_t *span, const char *str, zap_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 (zap_channel_t *zchan)
#define ZIO_CLOSE_ARGS (zap_channel_t *zchan)
#define ZIO_CHANNEL_DESTROY_ARGS (zap_channel_t *zchan)
#define ZIO_SPAN_DESTROY_ARGS (zap_span_t *span)
#define ZIO_COMMAND_ARGS (zap_channel_t *zchan, zap_command_t command, void *obj)
#define ZIO_WAIT_ARGS (zap_channel_t *zchan, zap_wait_flag_t *flags, int32_t to)
#define ZIO_GET_ALARMS_ARGS (zap_channel_t *zchan)
#define ZIO_READ_ARGS (zap_channel_t *zchan, void *data, zap_size_t *datalen)
#define ZIO_WRITE_ARGS (zap_channel_t *zchan, void *data, zap_size_t *datalen)
#define ZIO_IO_LOAD_ARGS (zap_io_interface_t **zio)
#define ZIO_IO_UNLOAD_ARGS (void)
#define ZIO_SIG_LOAD_ARGS (void)
#define ZIO_SIG_CONFIGURE_ARGS (zap_span_t *span, zio_signal_cb_t sig_cb, va_list ap)
#define ZIO_CONFIGURE_SPAN_SIGNALING_ARGS (zap_span_t *span, zio_signal_cb_t sig_cb, zap_conf_parameter_t *zap_parameters)
#define ZIO_SIG_UNLOAD_ARGS (void)
#define ZIO_API_ARGS (zap_stream_handle_t *stream, const char *data)
typedef zap_status_t (*zio_channel_request_t) ZIO_CHANNEL_REQUEST_ARGS ;
typedef zap_status_t (*zio_channel_outgoing_call_t) ZIO_CHANNEL_OUTGOING_CALL_ARGS ;
typedef zap_status_t (*zio_channel_set_sig_status_t) ZIO_CHANNEL_SET_SIG_STATUS_ARGS;
typedef zap_status_t (*zio_channel_get_sig_status_t) ZIO_CHANNEL_GET_SIG_STATUS_ARGS;
typedef zap_status_t (*zio_span_set_sig_status_t) ZIO_SPAN_SET_SIG_STATUS_ARGS;
typedef zap_status_t (*zio_span_get_sig_status_t) ZIO_SPAN_GET_SIG_STATUS_ARGS;
typedef zap_status_t (*zio_span_poll_event_t) ZIO_SPAN_POLL_EVENT_ARGS ;
typedef zap_status_t (*zio_span_next_event_t) ZIO_SPAN_NEXT_EVENT_ARGS ;
typedef zap_status_t (*zio_signal_cb_t) ZIO_SIGNAL_CB_ARGS ;
typedef zap_status_t (*zio_event_cb_t) ZIO_EVENT_CB_ARGS ;
typedef zap_status_t (*zio_codec_t) ZIO_CODEC_ARGS ;
typedef zap_status_t (*zio_configure_span_t) ZIO_CONFIGURE_SPAN_ARGS ;
typedef zap_status_t (*zio_configure_t) ZIO_CONFIGURE_ARGS ;
typedef zap_status_t (*zio_open_t) ZIO_OPEN_ARGS ;
typedef zap_status_t (*zio_close_t) ZIO_CLOSE_ARGS ;
typedef zap_status_t (*zio_channel_destroy_t) ZIO_CHANNEL_DESTROY_ARGS ;
typedef zap_status_t (*zio_span_destroy_t) ZIO_SPAN_DESTROY_ARGS ;
typedef zap_status_t (*zio_get_alarms_t) ZIO_GET_ALARMS_ARGS ;
typedef zap_status_t (*zio_command_t) ZIO_COMMAND_ARGS ;
typedef zap_status_t (*zio_wait_t) ZIO_WAIT_ARGS ;
typedef zap_status_t (*zio_read_t) ZIO_READ_ARGS ;
typedef zap_status_t (*zio_write_t) ZIO_WRITE_ARGS ;
typedef zap_status_t (*zio_io_load_t) ZIO_IO_LOAD_ARGS ;
typedef zap_status_t (*zio_sig_load_t) ZIO_SIG_LOAD_ARGS ;
typedef zap_status_t (*zio_sig_configure_t) ZIO_SIG_CONFIGURE_ARGS ;
typedef zap_status_t (*zio_configure_span_signaling_t) ZIO_CONFIGURE_SPAN_SIGNALING_ARGS ;
typedef zap_status_t (*zio_io_unload_t) ZIO_IO_UNLOAD_ARGS ;
typedef zap_status_t (*zio_sig_unload_t) ZIO_SIG_UNLOAD_ARGS ;
typedef zap_status_t (*zio_api_t) ZIO_API_ARGS ;
#define ZIO_CHANNEL_REQUEST_FUNCTION(name) zap_status_t name ZIO_CHANNEL_REQUEST_ARGS
#define ZIO_CHANNEL_OUTGOING_CALL_FUNCTION(name) zap_status_t name ZIO_CHANNEL_OUTGOING_CALL_ARGS
#define ZIO_CHANNEL_SET_SIG_STATUS_FUNCTION(name) zap_status_t name ZIO_CHANNEL_SET_SIG_STATUS_ARGS
#define ZIO_CHANNEL_GET_SIG_STATUS_FUNCTION(name) zap_status_t name ZIO_CHANNEL_GET_SIG_STATUS_ARGS
#define ZIO_SPAN_SET_SIG_STATUS_FUNCTION(name) zap_status_t name ZIO_SPAN_SET_SIG_STATUS_ARGS
#define ZIO_SPAN_GET_SIG_STATUS_FUNCTION(name) zap_status_t name ZIO_SPAN_GET_SIG_STATUS_ARGS
#define ZIO_SPAN_POLL_EVENT_FUNCTION(name) zap_status_t name ZIO_SPAN_POLL_EVENT_ARGS
#define ZIO_SPAN_NEXT_EVENT_FUNCTION(name) zap_status_t name ZIO_SPAN_NEXT_EVENT_ARGS
#define ZIO_SIGNAL_CB_FUNCTION(name) zap_status_t name ZIO_SIGNAL_CB_ARGS
#define ZIO_EVENT_CB_FUNCTION(name) zap_status_t name ZIO_EVENT_CB_ARGS
#define ZIO_CODEC_FUNCTION(name) OZ_DECLARE_NONSTD(zap_status_t) name ZIO_CODEC_ARGS
#define ZIO_CONFIGURE_SPAN_FUNCTION(name) zap_status_t name ZIO_CONFIGURE_SPAN_ARGS
#define ZIO_CONFIGURE_FUNCTION(name) zap_status_t name ZIO_CONFIGURE_ARGS
#define ZIO_OPEN_FUNCTION(name) zap_status_t name ZIO_OPEN_ARGS
#define ZIO_CLOSE_FUNCTION(name) zap_status_t name ZIO_CLOSE_ARGS
#define ZIO_CHANNEL_DESTROY_FUNCTION(name) zap_status_t name ZIO_CHANNEL_DESTROY_ARGS
#define ZIO_SPAN_DESTROY_FUNCTION(name) zap_status_t name ZIO_SPAN_DESTROY_ARGS
#define ZIO_GET_ALARMS_FUNCTION(name) zap_status_t name ZIO_GET_ALARMS_ARGS
#define ZIO_COMMAND_FUNCTION(name) zap_status_t name ZIO_COMMAND_ARGS
#define ZIO_WAIT_FUNCTION(name) zap_status_t name ZIO_WAIT_ARGS
#define ZIO_READ_FUNCTION(name) zap_status_t name ZIO_READ_ARGS
#define ZIO_WRITE_FUNCTION(name) zap_status_t name ZIO_WRITE_ARGS
#define ZIO_IO_LOAD_FUNCTION(name) zap_status_t name ZIO_IO_LOAD_ARGS
#define ZIO_SIG_LOAD_FUNCTION(name) zap_status_t name ZIO_SIG_LOAD_ARGS
#define ZIO_SIG_CONFIGURE_FUNCTION(name) zap_status_t name ZIO_SIG_CONFIGURE_ARGS
#define ZIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(name) zap_status_t name ZIO_CONFIGURE_SPAN_SIGNALING_ARGS
#define ZIO_IO_UNLOAD_FUNCTION(name) zap_status_t name ZIO_IO_UNLOAD_ARGS
#define ZIO_SIG_UNLOAD_FUNCTION(name) zap_status_t name ZIO_SIG_UNLOAD_ARGS
#define ZIO_API_FUNCTION(name) zap_status_t name ZIO_API_ARGS
#include "zap_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;
zap_dso_lib_t lib;
char path[256];
} zap_module_t;
#ifndef __FUNCTION__
#define __FUNCTION__ (const char *)__func__
#endif
#define ZAP_PRE __FILE__, __FUNCTION__, __LINE__
#define ZAP_LOG_LEVEL_DEBUG 7
#define ZAP_LOG_LEVEL_INFO 6
#define ZAP_LOG_LEVEL_NOTICE 5
#define ZAP_LOG_LEVEL_WARNING 4
#define ZAP_LOG_LEVEL_ERROR 3
#define ZAP_LOG_LEVEL_CRIT 2
#define ZAP_LOG_LEVEL_ALERT 1
#define ZAP_LOG_LEVEL_EMERG 0
#define ZAP_LOG_DEBUG ZAP_PRE, ZAP_LOG_LEVEL_DEBUG
#define ZAP_LOG_INFO ZAP_PRE, ZAP_LOG_LEVEL_INFO
#define ZAP_LOG_NOTICE ZAP_PRE, ZAP_LOG_LEVEL_NOTICE
#define ZAP_LOG_WARNING ZAP_PRE, ZAP_LOG_LEVEL_WARNING
#define ZAP_LOG_ERROR ZAP_PRE, ZAP_LOG_LEVEL_ERROR
#define ZAP_LOG_CRIT ZAP_PRE, ZAP_LOG_LEVEL_CRIT
#define ZAP_LOG_ALERT ZAP_PRE, ZAP_LOG_LEVEL_ALERT
#define ZAP_LOG_EMERG ZAP_PRE, ZAP_LOG_LEVEL_EMERG
typedef struct zap_fsk_data_state zap_fsk_data_state_t;
typedef int (*zap_fsk_data_decoder_t)(zap_fsk_data_state_t *state);
typedef zap_status_t (*zap_fsk_write_sample_t)(int16_t *buf, zap_size_t buflen, void *user_data);
typedef void (*zap_logger_t)(const char *file, const char *func, int line, int level, const char *fmt, ...);
typedef struct hashtable zap_hash_t;
typedef struct hashtable_iterator zap_hash_iterator_t;
typedef struct key zap_hash_key_t;
typedef struct value zap_hash_val_t;
typedef struct zap_bitstream zap_bitstream_t;
typedef struct zap_fsk_modulator zap_fsk_modulator_t;
typedef zap_status_t (*zap_span_start_t)(zap_span_t *span);
typedef zap_status_t (*zap_span_stop_t)(zap_span_t *span);
typedef enum {
ZAP_CAUSE_NONE = 0,
ZAP_CAUSE_UNALLOCATED = 1,
ZAP_CAUSE_NO_ROUTE_TRANSIT_NET = 2,
ZAP_CAUSE_NO_ROUTE_DESTINATION = 3,
ZAP_CAUSE_CHANNEL_UNACCEPTABLE = 6,
ZAP_CAUSE_CALL_AWARDED_DELIVERED = 7,
ZAP_CAUSE_NORMAL_CLEARING = 16,
ZAP_CAUSE_USER_BUSY = 17,
ZAP_CAUSE_NO_USER_RESPONSE = 18,
ZAP_CAUSE_NO_ANSWER = 19,
ZAP_CAUSE_SUBSCRIBER_ABSENT = 20,
ZAP_CAUSE_CALL_REJECTED = 21,
ZAP_CAUSE_NUMBER_CHANGED = 22,
ZAP_CAUSE_REDIRECTION_TO_NEW_DESTINATION = 23,
ZAP_CAUSE_EXCHANGE_ROUTING_ERROR = 25,
ZAP_CAUSE_DESTINATION_OUT_OF_ORDER = 27,
ZAP_CAUSE_INVALID_NUMBER_FORMAT = 28,
ZAP_CAUSE_FACILITY_REJECTED = 29,
ZAP_CAUSE_RESPONSE_TO_STATUS_ENQUIRY = 30,
ZAP_CAUSE_NORMAL_UNSPECIFIED = 31,
ZAP_CAUSE_NORMAL_CIRCUIT_CONGESTION = 34,
ZAP_CAUSE_NETWORK_OUT_OF_ORDER = 38,
ZAP_CAUSE_NORMAL_TEMPORARY_FAILURE = 41,
ZAP_CAUSE_SWITCH_CONGESTION = 42,
ZAP_CAUSE_ACCESS_INFO_DISCARDED = 43,
ZAP_CAUSE_REQUESTED_CHAN_UNAVAIL = 44,
ZAP_CAUSE_PRE_EMPTED = 45,
ZAP_CAUSE_FACILITY_NOT_SUBSCRIBED = 50,
ZAP_CAUSE_OUTGOING_CALL_BARRED = 52,
ZAP_CAUSE_INCOMING_CALL_BARRED = 54,
ZAP_CAUSE_BEARERCAPABILITY_NOTAUTH = 57,
ZAP_CAUSE_BEARERCAPABILITY_NOTAVAIL = 58,
ZAP_CAUSE_SERVICE_UNAVAILABLE = 63,
ZAP_CAUSE_BEARERCAPABILITY_NOTIMPL = 65,
ZAP_CAUSE_CHAN_NOT_IMPLEMENTED = 66,
ZAP_CAUSE_FACILITY_NOT_IMPLEMENTED = 69,
ZAP_CAUSE_SERVICE_NOT_IMPLEMENTED = 79,
ZAP_CAUSE_INVALID_CALL_REFERENCE = 81,
ZAP_CAUSE_INCOMPATIBLE_DESTINATION = 88,
ZAP_CAUSE_INVALID_MSG_UNSPECIFIED = 95,
ZAP_CAUSE_MANDATORY_IE_MISSING = 96,
ZAP_CAUSE_MESSAGE_TYPE_NONEXIST = 97,
ZAP_CAUSE_WRONG_MESSAGE = 98,
ZAP_CAUSE_IE_NONEXIST = 99,
ZAP_CAUSE_INVALID_IE_CONTENTS = 100,
ZAP_CAUSE_WRONG_CALL_STATE = 101,
ZAP_CAUSE_RECOVERY_ON_TIMER_EXPIRE = 102,
ZAP_CAUSE_MANDATORY_IE_LENGTH_ERROR = 103,
ZAP_CAUSE_PROTOCOL_ERROR = 111,
ZAP_CAUSE_INTERWORKING = 127,
ZAP_CAUSE_SUCCESS = 142,
ZAP_CAUSE_ORIGINATOR_CANCEL = 487,
ZAP_CAUSE_CRASH = 500,
ZAP_CAUSE_SYSTEM_SHUTDOWN = 501,
ZAP_CAUSE_LOSE_RACE = 502,
ZAP_CAUSE_MANAGER_REQUEST = 503,
ZAP_CAUSE_BLIND_TRANSFER = 600,
ZAP_CAUSE_ATTENDED_TRANSFER = 601,
ZAP_CAUSE_ALLOTTED_TIMEOUT = 602,
ZAP_CAUSE_USER_CHALLENGE = 603,
ZAP_CAUSE_MEDIA_TIMEOUT = 604
} zap_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:
*/