提交 62eea6fd authored 作者: Anthony Minessale's avatar Anthony Minessale

update

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@90 a93c3328-9c30-0410-af19-c9cd2b2d52af
上级 b8635f17
...@@ -32,7 +32,9 @@ ...@@ -32,7 +32,9 @@
OBJS=hashtable.o \ OBJS=hashtable.o \
hashtable_itr.o \ hashtable_itr.o \
openzap.o \ zap_io.o \
zap_isdn.o \
zap_analog.o \
zap_config.o \ zap_config.o \
g711.o \ g711.o \
libteletone_detect.o \ libteletone_detect.o \
...@@ -77,7 +79,7 @@ sangoma_pri.o: sangoma_pri.c ...@@ -77,7 +79,7 @@ sangoma_pri.o: sangoma_pri.c
priserver: $(MYLIB) priserver.o sangoma_pri.o priserver: $(MYLIB) priserver.o sangoma_pri.o
$(CC) sangoma_pri.o priserver.o -L. -o priserver -lopenzap -lm -lpthread ../../libpri-1.2.4/libpri.a $(CC) sangoma_pri.o priserver.o -L. -o priserver -lopenzap -lm -lpthread ../../libpri-1.2.4/libpri.a
openzap.o: openzap.c zap_io.o: zap_io.c
$(CC) $(MOD_CFLAGS) $(CC_CFLAGS) $(CFLAGS) -c $< -o $@ $(CC) $(MOD_CFLAGS) $(CC_CFLAGS) $(CFLAGS) -c $< -o $@
zap_wanpipe.o: zap_wanpipe.c zap_wanpipe.o: zap_wanpipe.c
......
...@@ -173,7 +173,7 @@ struct zap_channel { ...@@ -173,7 +173,7 @@ struct zap_channel {
teletone_dtmf_detect_state_t dtmf_detect; teletone_dtmf_detect_state_t dtmf_detect;
zap_event_t event_header; zap_event_t event_header;
char last_error[256]; char last_error[256];
zint_event_cb_t event_callback; zio_event_cb_t event_callback;
void *mod_data; void *mod_data;
uint32_t skip_read_frames; uint32_t skip_read_frames;
zap_buffer_t *dtmf_buffer; zap_buffer_t *dtmf_buffer;
...@@ -181,7 +181,7 @@ struct zap_channel { ...@@ -181,7 +181,7 @@ struct zap_channel {
uint32_t dtmf_off; uint32_t dtmf_off;
teletone_generation_session_t tone_session; teletone_generation_session_t tone_session;
struct zap_span *span; struct zap_span *span;
struct zap_software_interface *zint; struct zap_io_interface *zio;
}; };
...@@ -189,34 +189,35 @@ struct zap_span { ...@@ -189,34 +189,35 @@ struct zap_span {
uint32_t span_id; uint32_t span_id;
uint32_t chan_count; uint32_t chan_count;
zap_span_flag_t flags; zap_span_flag_t flags;
struct zap_software_interface *zint; struct zap_io_interface *zio;
zint_event_cb_t event_callback; zio_event_cb_t event_callback;
zap_mutex_t *mutex; zap_mutex_t *mutex;
zap_signal_type_t signal_type;
zap_channel_t channels[ZAP_MAX_CHANNELS_SPAN]; zap_channel_t channels[ZAP_MAX_CHANNELS_SPAN];
}; };
extern zap_logger_t zap_log; extern zap_logger_t zap_log;
struct zap_software_interface { struct zap_io_interface {
const char *name; const char *name;
zint_configure_t configure; zio_configure_t configure;
zint_open_t open; zio_open_t open;
zint_close_t close; zio_close_t close;
zint_command_t command; zio_command_t command;
zint_wait_t wait; zio_wait_t wait;
zint_read_t read; zio_read_t read;
zint_write_t write; zio_write_t write;
uint32_t span_index; uint32_t span_index;
struct zap_span spans[ZAP_MAX_SPANS_INTERFACE]; struct zap_span spans[ZAP_MAX_SPANS_INTERFACE];
}; };
zap_status_t zap_span_find(const char *name, uint32_t id, zap_span_t **span); zap_status_t zap_span_find(const char *name, uint32_t id, zap_span_t **span);
zap_status_t zap_span_create(zap_software_interface_t *zint, 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_software_interface_t *zint); zap_status_t zap_span_close_all(zap_io_interface_t *zio);
zap_status_t zap_span_add_channel(zap_span_t *span, zap_socket_t sockfd, zap_chan_type_t type, zap_channel_t **chan); zap_status_t zap_span_add_channel(zap_span_t *span, zap_socket_t sockfd, zap_chan_type_t type, zap_channel_t **chan);
zap_status_t zap_span_set_event_callback(zap_span_t *span, zint_event_cb_t event_callback); zap_status_t zap_span_set_event_callback(zap_span_t *span, zio_event_cb_t event_callback);
zap_status_t zap_channel_set_event_callback(zap_channel_t *zchan, zint_event_cb_t event_callback); zap_status_t zap_channel_set_event_callback(zap_channel_t *zchan, zio_event_cb_t event_callback);
zap_status_t zap_channel_open(const char *name, uint32_t span_id, uint32_t chan_id, zap_channel_t **zchan); zap_status_t zap_channel_open(const char *name, uint32_t span_id, uint32_t chan_id, zap_channel_t **zchan);
zap_status_t zap_channel_open_any(const char *name, uint32_t span_id, zap_direction_t direction, zap_channel_t **zchan); zap_status_t zap_channel_open_any(const char *name, uint32_t span_id, zap_direction_t direction, zap_channel_t **zchan);
zap_status_t zap_channel_close(zap_channel_t **zchan); zap_status_t zap_channel_close(zap_channel_t **zchan);
......
...@@ -45,11 +45,36 @@ typedef int zap_socket_t; ...@@ -45,11 +45,36 @@ typedef int zap_socket_t;
#endif #endif
typedef size_t zap_size_t; typedef size_t zap_size_t;
struct zap_software_interface; struct zap_io_interface;
#define ZAP_COMMAND_OBJ_INT *((int *)obj) #define ZAP_COMMAND_OBJ_INT *((int *)obj)
#define ZAP_COMMAND_OBJ_CHAR_P (char *)obj #define ZAP_COMMAND_OBJ_CHAR_P (char *)obj
typedef enum {
ZAP_SIGTYPE_NONE,
ZAP_SIGTYPE_ISDN,
ZAP_SIGTYPE_RBS,
ZAP_SIGTYPE_ANALOG
} zap_signal_type_t;
typedef enum {
ZAP_SIGEVENT_CALL_START,
ZAP_SIGEVENT_CALL_STOP,
ZAP_SIGEVENT_CALL_TRANSFER,
ZAP_SIGEVENT_ANSWER,
ZAP_SIGEVENT_PROGRESS,
ZAP_SIGEVENT_PROGRESS_MEDIA,
ZAP_SIGEVENT_NOTIFY,
ZAP_SIGEVENT_MISC
} zap_signal_event_t;
typedef enum {
ZAP_EVENT_NONE,
ZAP_EVENT_DTMF,
ZAP_EVENT_COUNT
} zap_event_type_t;
typedef enum { typedef enum {
ZAP_TOP_DOWN, ZAP_TOP_DOWN,
ZAP_BOTTOM_UP ZAP_BOTTOM_UP
...@@ -134,43 +159,43 @@ typedef enum { ...@@ -134,43 +159,43 @@ typedef enum {
typedef struct zap_channel zap_channel_t; typedef struct zap_channel zap_channel_t;
typedef struct zap_event zap_event_t; typedef struct zap_event zap_event_t;
#define ZINT_EVENT_CB_ARGS (zap_channel_t *zchan, zap_event_t *event) #define ZIO_EVENT_CB_ARGS (zap_channel_t *zchan, zap_event_t *event)
#define ZINT_CODEC_ARGS (void *data, zap_size_t max, zap_size_t *datalen) #define ZIO_CODEC_ARGS (void *data, zap_size_t max, zap_size_t *datalen)
#define ZINT_CONFIGURE_ARGS (struct zap_software_interface *zint) #define ZIO_CONFIGURE_ARGS (struct zap_io_interface *zio)
#define ZINT_OPEN_ARGS (zap_channel_t *zchan) #define ZIO_OPEN_ARGS (zap_channel_t *zchan)
#define ZINT_CLOSE_ARGS (zap_channel_t *zchan) #define ZIO_CLOSE_ARGS (zap_channel_t *zchan)
#define ZINT_COMMAND_ARGS (zap_channel_t *zchan, zap_command_t command, void *obj) #define ZIO_COMMAND_ARGS (zap_channel_t *zchan, zap_command_t command, void *obj)
#define ZINT_WAIT_ARGS (zap_channel_t *zchan, zap_wait_flag_t *flags, int32_t to) #define ZIO_WAIT_ARGS (zap_channel_t *zchan, zap_wait_flag_t *flags, int32_t to)
#define ZINT_READ_ARGS (zap_channel_t *zchan, void *data, zap_size_t *datalen) #define ZIO_READ_ARGS (zap_channel_t *zchan, void *data, zap_size_t *datalen)
#define ZINT_WRITE_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 (*zint_event_cb_t) ZINT_EVENT_CB_ARGS ; typedef zap_status_t (*zio_event_cb_t) ZIO_EVENT_CB_ARGS ;
typedef zap_status_t (*zint_codec_t) ZINT_CODEC_ARGS ; typedef zap_status_t (*zio_codec_t) ZIO_CODEC_ARGS ;
typedef zap_status_t (*zint_configure_t) ZINT_CONFIGURE_ARGS ; typedef zap_status_t (*zio_configure_t) ZIO_CONFIGURE_ARGS ;
typedef zap_status_t (*zint_open_t) ZINT_OPEN_ARGS ; typedef zap_status_t (*zio_open_t) ZIO_OPEN_ARGS ;
typedef zap_status_t (*zint_close_t) ZINT_CLOSE_ARGS ; typedef zap_status_t (*zio_close_t) ZIO_CLOSE_ARGS ;
typedef zap_status_t (*zint_command_t) ZINT_COMMAND_ARGS ; typedef zap_status_t (*zio_command_t) ZIO_COMMAND_ARGS ;
typedef zap_status_t (*zint_wait_t) ZINT_WAIT_ARGS ; typedef zap_status_t (*zio_wait_t) ZIO_WAIT_ARGS ;
typedef zap_status_t (*zint_read_t) ZINT_READ_ARGS ; typedef zap_status_t (*zio_read_t) ZIO_READ_ARGS ;
typedef zap_status_t (*zint_write_t) ZINT_WRITE_ARGS ; typedef zap_status_t (*zio_write_t) ZIO_WRITE_ARGS ;
#define ZINT_EVENT_CB_FUNCTION(name) zap_status_t name ZINT_EVENT_CB_ARGS #define ZIO_EVENT_CB_FUNCTION(name) zap_status_t name ZIO_EVENT_CB_ARGS
#define ZINT_CODEC_FUNCTION(name) zap_status_t name ZINT_CODEC_ARGS #define ZIO_CODEC_FUNCTION(name) zap_status_t name ZIO_CODEC_ARGS
#define ZINT_CONFIGURE_FUNCTION(name) zap_status_t name ZINT_CONFIGURE_ARGS #define ZIO_CONFIGURE_FUNCTION(name) zap_status_t name ZIO_CONFIGURE_ARGS
#define ZINT_OPEN_FUNCTION(name) zap_status_t name ZINT_OPEN_ARGS #define ZIO_OPEN_FUNCTION(name) zap_status_t name ZIO_OPEN_ARGS
#define ZINT_CLOSE_FUNCTION(name) zap_status_t name ZINT_CLOSE_ARGS #define ZIO_CLOSE_FUNCTION(name) zap_status_t name ZIO_CLOSE_ARGS
#define ZINT_COMMAND_FUNCTION(name) zap_status_t name ZINT_COMMAND_ARGS #define ZIO_COMMAND_FUNCTION(name) zap_status_t name ZIO_COMMAND_ARGS
#define ZINT_WAIT_FUNCTION(name) zap_status_t name ZINT_WAIT_ARGS #define ZIO_WAIT_FUNCTION(name) zap_status_t name ZIO_WAIT_ARGS
#define ZINT_READ_FUNCTION(name) zap_status_t name ZINT_READ_ARGS #define ZIO_READ_FUNCTION(name) zap_status_t name ZIO_READ_ARGS
#define ZINT_WRITE_FUNCTION(name) zap_status_t name ZINT_WRITE_ARGS #define ZIO_WRITE_FUNCTION(name) zap_status_t name ZIO_WRITE_ARGS
#define ZINT_CONFIGURE_MUZZLE assert(zint != NULL) #define ZIO_CONFIGURE_MUZZLE assert(zio != NULL)
#define ZINT_OPEN_MUZZLE assert(zchan != NULL) #define ZIO_OPEN_MUZZLE assert(zchan != NULL)
#define ZINT_CLOSE_MUZZLE assert(zchan != NULL) #define ZIO_CLOSE_MUZZLE assert(zchan != NULL)
#define ZINT_COMMAND_MUZZLE assert(zchan != NULL); assert(command != 0); assert(obj != NULL) #define ZIO_COMMAND_MUZZLE assert(zchan != NULL); assert(command != 0); assert(obj != NULL)
#define ZINT_WAIT_MUZZLE assert(zchan != NULL); assert(flags != 0); assert(to != 0) #define ZIO_WAIT_MUZZLE assert(zchan != NULL); assert(flags != 0); assert(to != 0)
#define ZINT_READ_MUZZLE assert(zchan != NULL); assert(data != NULL); assert(datalen != NULL) #define ZIO_READ_MUZZLE assert(zchan != NULL); assert(data != NULL); assert(datalen != NULL)
#define ZINT_WRITE_MUZZLE assert(zchan != NULL); assert(data != NULL); assert(datalen != NULL) #define ZIO_WRITE_MUZZLE assert(zchan != NULL); assert(data != NULL); assert(datalen != NULL)
#define ZAP_PRE __FILE__, __FUNCTION__, __LINE__ #define ZAP_PRE __FILE__, __FUNCTION__, __LINE__
...@@ -192,16 +217,9 @@ typedef zap_status_t (*zint_write_t) ZINT_WRITE_ARGS ; ...@@ -192,16 +217,9 @@ typedef zap_status_t (*zint_write_t) ZINT_WRITE_ARGS ;
#define ZAP_LOG_ALERT ZAP_PRE, ZAP_LOG_LEVEL_ALERT #define ZAP_LOG_ALERT ZAP_PRE, ZAP_LOG_LEVEL_ALERT
#define ZAP_LOG_EMERG ZAP_PRE, ZAP_LOG_LEVEL_EMERG #define ZAP_LOG_EMERG ZAP_PRE, ZAP_LOG_LEVEL_EMERG
typedef enum {
ZAP_EVENT_NONE,
ZAP_EVENT_DTMF,
ZAP_EVENT_COUNT
} zap_event_type_t;
typedef struct zap_span zap_span_t; typedef struct zap_span zap_span_t;
typedef void (*zap_logger_t)(char *file, const char *func, int line, int level, char *fmt, ...); typedef void (*zap_logger_t)(char *file, const char *func, int line, int level, char *fmt, ...);
typedef struct zap_software_interface zap_software_interface_t; typedef struct zap_io_interface zap_io_interface_t;
typedef struct hashtable zap_hash_t; typedef struct hashtable zap_hash_t;
typedef struct hashtable_itr zap_hash_itr_t; typedef struct hashtable_itr zap_hash_itr_t;
typedef struct key zap_hash_key_t; typedef struct key zap_hash_key_t;
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#define ZAP_WANPIPE_H #define ZAP_WANPIPE_H
#include "openzap.h" #include "openzap.h"
zap_status_t wanpipe_init(zap_software_interface_t **zint); zap_status_t wanpipe_init(zap_io_interface_t **zint);
zap_status_t wanpipe_destroy(void); zap_status_t wanpipe_destroy(void);
#endif #endif
...@@ -42,7 +42,7 @@ static struct { ...@@ -42,7 +42,7 @@ static struct {
unsigned codec_ms; unsigned codec_ms;
} wp_globals; } wp_globals;
static zap_software_interface_t wanpipe_interface; static zap_io_interface_t wanpipe_interface;
static zap_status_t wp_tdm_cmd_exec(zap_channel_t *zchan, wanpipe_tdm_api_t *tdm_api) static zap_status_t wp_tdm_cmd_exec(zap_channel_t *zchan, wanpipe_tdm_api_t *tdm_api)
{ {
...@@ -146,7 +146,7 @@ static unsigned wp_configure_channel(zap_config_t *cfg, const char *str, zap_spa ...@@ -146,7 +146,7 @@ static unsigned wp_configure_channel(zap_config_t *cfg, const char *str, zap_spa
return configured; return configured;
} }
static ZINT_CONFIGURE_FUNCTION(wanpipe_configure) static ZIO_CONFIGURE_FUNCTION(wanpipe_configure)
{ {
zap_config_t cfg; zap_config_t cfg;
char *var, *val; char *var, *val;
...@@ -155,7 +155,7 @@ static ZINT_CONFIGURE_FUNCTION(wanpipe_configure) ...@@ -155,7 +155,7 @@ static ZINT_CONFIGURE_FUNCTION(wanpipe_configure)
int new_span = 0; int new_span = 0;
unsigned configured = 0, d = 0; unsigned configured = 0, d = 0;
ZINT_CONFIGURE_MUZZLE; ZIO_CONFIGURE_MUZZLE;
zap_log(ZAP_LOG_DEBUG, "configuring wanpipe\n"); zap_log(ZAP_LOG_DEBUG, "configuring wanpipe\n");
if (!zap_config_open_file(&cfg, "wanpipe.conf")) { if (!zap_config_open_file(&cfg, "wanpipe.conf")) {
...@@ -229,7 +229,7 @@ static ZINT_CONFIGURE_FUNCTION(wanpipe_configure) ...@@ -229,7 +229,7 @@ static ZINT_CONFIGURE_FUNCTION(wanpipe_configure)
return configured ? ZAP_SUCCESS : ZAP_FAIL; return configured ? ZAP_SUCCESS : ZAP_FAIL;
} }
static ZINT_OPEN_FUNCTION(wanpipe_open) static ZIO_OPEN_FUNCTION(wanpipe_open)
{ {
wanpipe_tdm_api_t tdm_api; wanpipe_tdm_api_t tdm_api;
...@@ -259,18 +259,18 @@ static ZINT_OPEN_FUNCTION(wanpipe_open) ...@@ -259,18 +259,18 @@ static ZINT_OPEN_FUNCTION(wanpipe_open)
return ZAP_SUCCESS; return ZAP_SUCCESS;
} }
static ZINT_CLOSE_FUNCTION(wanpipe_close) static ZIO_CLOSE_FUNCTION(wanpipe_close)
{ {
ZINT_CLOSE_MUZZLE; ZIO_CLOSE_MUZZLE;
return ZAP_SUCCESS; return ZAP_SUCCESS;
} }
static ZINT_COMMAND_FUNCTION(wanpipe_command) static ZIO_COMMAND_FUNCTION(wanpipe_command)
{ {
wanpipe_tdm_api_t tdm_api; wanpipe_tdm_api_t tdm_api;
int err = 0; int err = 0;
ZINT_COMMAND_MUZZLE; ZIO_COMMAND_MUZZLE;
memset(&tdm_api, 0, sizeof(tdm_api)); memset(&tdm_api, 0, sizeof(tdm_api));
...@@ -306,7 +306,7 @@ static ZINT_COMMAND_FUNCTION(wanpipe_command) ...@@ -306,7 +306,7 @@ static ZINT_COMMAND_FUNCTION(wanpipe_command)
return ZAP_SUCCESS; return ZAP_SUCCESS;
} }
static ZINT_READ_FUNCTION(wanpipe_read) static ZIO_READ_FUNCTION(wanpipe_read)
{ {
int rx_len = 0; int rx_len = 0;
wp_tdm_api_rx_hdr_t hdrframe; wp_tdm_api_rx_hdr_t hdrframe;
...@@ -325,7 +325,7 @@ static ZINT_READ_FUNCTION(wanpipe_read) ...@@ -325,7 +325,7 @@ static ZINT_READ_FUNCTION(wanpipe_read)
return ZAP_SUCCESS; return ZAP_SUCCESS;
} }
static ZINT_WRITE_FUNCTION(wanpipe_write) static ZIO_WRITE_FUNCTION(wanpipe_write)
{ {
int bsent; int bsent;
wp_tdm_api_tx_hdr_t hdrframe; wp_tdm_api_tx_hdr_t hdrframe;
...@@ -344,7 +344,7 @@ static ZINT_WRITE_FUNCTION(wanpipe_write) ...@@ -344,7 +344,7 @@ static ZINT_WRITE_FUNCTION(wanpipe_write)
} }
static ZINT_WAIT_FUNCTION(wanpipe_wait) static ZIO_WAIT_FUNCTION(wanpipe_wait)
{ {
int32_t inflags = 0; int32_t inflags = 0;
int result; int result;
...@@ -389,9 +389,9 @@ static ZINT_WAIT_FUNCTION(wanpipe_wait) ...@@ -389,9 +389,9 @@ static ZINT_WAIT_FUNCTION(wanpipe_wait)
return ZAP_SUCCESS; return ZAP_SUCCESS;
} }
zap_status_t wanpipe_init(zap_software_interface_t **zint) zap_status_t wanpipe_init(zap_io_interface_t **zio)
{ {
assert(zint != NULL); assert(zio != NULL);
memset(&wanpipe_interface, 0, sizeof(wanpipe_interface)); memset(&wanpipe_interface, 0, sizeof(wanpipe_interface));
wp_globals.codec_ms = 20; wp_globals.codec_ms = 20;
...@@ -403,7 +403,7 @@ zap_status_t wanpipe_init(zap_software_interface_t **zint) ...@@ -403,7 +403,7 @@ zap_status_t wanpipe_init(zap_software_interface_t **zint)
wanpipe_interface.wait = wanpipe_wait; wanpipe_interface.wait = wanpipe_wait;
wanpipe_interface.read = wanpipe_read; wanpipe_interface.read = wanpipe_read;
wanpipe_interface.write = wanpipe_write; wanpipe_interface.write = wanpipe_write;
*zint = &wanpipe_interface; *zio = &wanpipe_interface;
return ZAP_SUCCESS; return ZAP_SUCCESS;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论