git-svn-id: http://svn.openzap.org/svn/openzap/trunk@102 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Anthony Minessale
2007-05-22 22:07:05 +00:00
parent 2e097a54ef
commit b67a52b142
21 changed files with 1458 additions and 1014 deletions

View File

@@ -88,6 +88,8 @@
#include "libteletone.h"
#include "zap_buffer.h"
#include "zap_threadmutex.h"
#include "Q931.h"
#include "Q921.h"
#ifdef NDEBUG
#undef assert
@@ -185,6 +187,26 @@ struct zap_channel {
};
struct zap_sigmsg {
zap_signal_event_t event_id;
uint32_t chan_id;
char cid_name[80];
char ani[25];
char aniII[25];
char dnis[25];
};
struct zap_isdn_data {
Q921Data_t q921;
Q931_TrunkInfo_t q931;
zap_channel_t *dchan;
zap_channel_t *dchans[2];
struct zap_sigmsg sigmsg;
zio_signal_cb_t sig_cb;
uint32_t flags;
};
struct zap_span {
uint32_t span_id;
uint32_t chan_count;
@@ -192,7 +214,10 @@ struct zap_span {
struct zap_io_interface *zio;
zio_event_cb_t event_callback;
zap_mutex_t *mutex;
zap_trunk_type_t trunk_type;
zap_signal_type_t signal_type;
struct zap_isdn_data *isdn_data;
char last_error[256];
zap_channel_t channels[ZAP_MAX_CHANNELS_SPAN];
};
@@ -212,6 +237,8 @@ struct zap_io_interface {
struct zap_span spans[ZAP_MAX_SPANS_INTERFACE];
};
zap_trunk_type_t str2zap_trunk_type(char *name);
char *zap_trunk_type2str(zap_trunk_type_t type);
zap_status_t zap_span_find(const char *name, uint32_t id, zap_span_t **span);
zap_status_t zap_span_create(zap_io_interface_t *zio, zap_span_t **span);
zap_status_t zap_span_close_all(zap_io_interface_t *zio);
@@ -230,5 +257,7 @@ zap_status_t zap_global_destroy(void);
void zap_global_set_logger(zap_logger_t logger);
void zap_global_set_default_logger(int level);
uint32_t zap_separate_string(char *buf, char delim, char **array, int arraylen);
void print_bits(uint8_t *b, int bl, char *buf, int blen, int e);
#endif

View File

@@ -0,0 +1,49 @@
/*
* 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_ISDN_H
#define ZAP_ISDN_H
#include "openzap.h"
typedef enum {
ZAP_ISDN_RUNNING = (1 << 0)
} zap_isdn_flag_t;
typedef struct zap_isdn_data zap_isdn_data_t;
zap_status_t zap_isdn_start(zap_span_t *span);
zap_status_t zap_isdn_init(void);
zap_status_t zap_isdn_configure_span(zap_span_t *span, Q921NetUser_t mode, Q931Dialect_t dialect, zio_signal_cb_t sig_cb);
#endif

View File

@@ -50,6 +50,14 @@ struct zap_io_interface;
#define ZAP_COMMAND_OBJ_INT *((int *)obj)
#define ZAP_COMMAND_OBJ_CHAR_P (char *)obj
typedef enum {
ZAP_TRUNK_E1,
ZAP_TRUNK_T1,
ZAP_TRUNK_J1,
ZAP_TRUNK_BRI,
ZAP_TRUNK_NONE
} zap_trunk_type_t;
typedef enum {
ZAP_SIGTYPE_NONE,
ZAP_SIGTYPE_ISDN,
@@ -71,7 +79,6 @@ typedef enum {
typedef enum {
ZAP_EVENT_NONE,
ZAP_EVENT_DTMF,
ZAP_EVENT_COUNT
} zap_event_type_t;
@@ -158,7 +165,10 @@ typedef enum {
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;
#define ZIO_SIGNAL_CB_ARGS (zap_span_t *span, zap_sigmsg_t *sigmsg, void *raw_data, uint32_t raw_data_len)
#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_ARGS (struct zap_io_interface *zio)
@@ -169,6 +179,7 @@ typedef struct zap_event zap_event_t;
#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)
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_t) ZIO_CONFIGURE_ARGS ;
@@ -179,6 +190,7 @@ 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 ;
#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) zap_status_t name ZIO_CODEC_ARGS
#define ZIO_CONFIGURE_FUNCTION(name) zap_status_t name ZIO_CONFIGURE_ARGS
@@ -217,7 +229,7 @@ typedef zap_status_t (*zio_write_t) ZIO_WRITE_ARGS ;
#define ZAP_LOG_ALERT ZAP_PRE, ZAP_LOG_LEVEL_ALERT
#define ZAP_LOG_EMERG ZAP_PRE, ZAP_LOG_LEVEL_EMERG
typedef struct zap_span zap_span_t;
typedef void (*zap_logger_t)(char *file, const char *func, int line, int level, char *fmt, ...);
typedef struct zap_io_interface zap_io_interface_t;
typedef struct hashtable zap_hash_t;