]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
dyna won't you blow your horn
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 29 Aug 2008 15:58:59 +0000 (15:58 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 29 Aug 2008 15:58:59 +0000 (15:58 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@517 a93c3328-9c30-0410-af19-c9cd2b2d52af

34 files changed:
libs/openzap/Makefile.in
libs/openzap/conf/modules.conf [new file with mode: 0644]
libs/openzap/configure.ac
libs/openzap/mod_openzap/Makefile
libs/openzap/mod_openzap/mod_openzap.c
libs/openzap/src/hashtable.c
libs/openzap/src/include/hashtable.h
libs/openzap/src/include/hashtable_private.h
libs/openzap/src/include/openzap.h
libs/openzap/src/include/zap_dso.h
libs/openzap/src/include/zap_skel.h [deleted file]
libs/openzap/src/include/zap_types.h
libs/openzap/src/include/zap_wanpipe.h [deleted file]
libs/openzap/src/ozmod/ozmod_analog/ozmod_analog.c [moved from libs/openzap/src/zap_analog.c with 95% similarity]
libs/openzap/src/ozmod/ozmod_analog/zap_analog.h [moved from libs/openzap/src/include/zap_analog.h with 91% similarity]
libs/openzap/src/ozmod/ozmod_isdn/ozmod_isdn.c [moved from libs/openzap/src/zap_isdn.c with 97% similarity]
libs/openzap/src/ozmod/ozmod_isdn/zap_isdn.h [moved from libs/openzap/src/include/zap_isdn.h with 91% similarity]
libs/openzap/src/ozmod/ozmod_pika/ozmod_pika.c [moved from libs/openzap/src/zap_pika.c with 99% similarity]
libs/openzap/src/ozmod/ozmod_pika/zap_pika.h [moved from libs/openzap/src/include/zap_pika.h with 96% similarity]
libs/openzap/src/ozmod/ozmod_skel/ozmod_skel.c [moved from libs/openzap/src/zap_skel.c with 88% similarity]
libs/openzap/src/ozmod/ozmod_ss7_boost/ozmod_ss7_boost.c [moved from libs/openzap/src/zap_ss7_boost.c with 96% similarity]
libs/openzap/src/ozmod/ozmod_ss7_boost/sigboost.h [moved from libs/openzap/src/include/sigboost.h with 100% similarity]
libs/openzap/src/ozmod/ozmod_ss7_boost/ss7_boost_client.c [moved from libs/openzap/src/ss7_boost_client.c with 100% similarity]
libs/openzap/src/ozmod/ozmod_ss7_boost/ss7_boost_client.h [moved from libs/openzap/src/include/ss7_boost_client.h with 100% similarity]
libs/openzap/src/ozmod/ozmod_ss7_boost/zap_ss7_boost.h [moved from libs/openzap/src/include/zap_ss7_boost.h with 88% similarity]
libs/openzap/src/ozmod/ozmod_wanpipe/ozmod_wanpipe.c [moved from libs/openzap/src/zap_wanpipe.c with 99% similarity]
libs/openzap/src/ozmod/ozmod_wanpipe/wanpipe_tdm_api_iface.h [moved from libs/openzap/src/include/wanpipe_tdm_api_iface.h with 100% similarity]
libs/openzap/src/ozmod/ozmod_zt/ozmod_zt.c [moved from libs/openzap/src/zap_zt.c with 99% similarity]
libs/openzap/src/ozmod/ozmod_zt/ozmod_zt.h [moved from libs/openzap/src/include/zap_zt.h with 98% similarity]
libs/openzap/src/testanalog.c
libs/openzap/src/testboost.c
libs/openzap/src/testisdn.c
libs/openzap/src/zap_dso.c
libs/openzap/src/zap_io.c

index 6c3bb534e5ff9ccfaf29c1d8b22e2be4fb6f7254..2ad180b4308096e6bb47b9609b9e0f20f5399327 100644 (file)
@@ -35,8 +35,6 @@ SOURCES=\
 $(SRC)/hashtable.c \
 $(SRC)/hashtable_itr.c \
 $(SRC)/zap_io.c \
-$(SRC)/zap_isdn.c \
-$(SRC)/zap_analog.c \
 $(SRC)/zap_config.c \
 $(SRC)/zap_callerid.c \
 $(SRC)/fsk.c \
@@ -46,7 +44,14 @@ $(SRC)/libteletone_detect.c \
 $(SRC)/libteletone_generate.c \
 $(SRC)/zap_buffer.c \
 $(SRC)/zap_threadmutex.c \
-$(SRC)/zap_dso.c \
+$(SRC)/zap_dso.c
+
+BOOST_SOURCES=\
+$(SRC)/ozmod/ozmod_ss7_boost/ss7_boost_client.c \
+$(SRC)/ozmod/ozmod_ss7_boost/zap_ss7_boost.c
+
+
+ISDN_SOURCES=\
 $(SRC)/isdn/EuroISDNStateNT.c \
 $(SRC)/isdn/EuroISDNStateTE.c \
 $(SRC)/isdn/mfifo.c \
@@ -66,18 +71,13 @@ $(SRC)/isdn/DMSStateTE.c \
 $(SRC)/isdn/5ESSmes.c \
 $(SRC)/isdn/5ESSStateNT.c \
 $(SRC)/isdn/5ESSStateTE.c \
-$(SRC)/isdn/Q932mes.c \
-$(SRC)/zap_zt.c \
-$(SRC)/zap_wanpipe.c \
-$(SRC)/ss7_boost_client.c \
-$(SRC)/zap_ss7_boost.c
+$(SRC)/isdn/Q932mes.c
+
 
 OBJS=\
 $(SRC)/hashtable.o \
 $(SRC)/hashtable_itr.o \
 $(SRC)/zap_io.o \
-$(SRC)/zap_isdn.o \
-$(SRC)/zap_analog.o \
 $(SRC)/zap_config.o \
 $(SRC)/zap_callerid.o \
 $(SRC)/fsk.o \
@@ -87,7 +87,13 @@ $(SRC)/libteletone_detect.o \
 $(SRC)/libteletone_generate.o \
 $(SRC)/zap_buffer.o \
 $(SRC)/zap_threadmutex.o \
-$(SRC)/zap_dso.o \
+$(SRC)/zap_dso.o
+
+BOOST_OBJS=\
+$(SRC)/ozmod/ozmod_ss7_boost/ss7_boost_client.o
+
+
+ISDN_OBJS=\
 $(SRC)/isdn/EuroISDNStateNT.o \
 $(SRC)/isdn/EuroISDNStateTE.o \
 $(SRC)/isdn/mfifo.o \
@@ -107,11 +113,8 @@ $(SRC)/isdn/DMSStateTE.o \
 $(SRC)/isdn/5ESSmes.o \
 $(SRC)/isdn/5ESSStateNT.o \
 $(SRC)/isdn/5ESSStateTE.o \
-$(SRC)/isdn/Q932mes.o \
-$(SRC)/zap_zt.o \
-$(SRC)/zap_wanpipe.o \
-$(SRC)/ss7_boost_client.o \
-$(SRC)/zap_ss7_boost.o
+$(SRC)/isdn/Q932mes.o
+
 
 HEADERS= $(SRC)/include/fsk.h \
 $(SRC)/include/g711.h \
@@ -124,18 +127,14 @@ $(SRC)/include/libteletone.h \
 $(SRC)/include/openzap.h \
 $(SRC)/include/sangoma_tdm_api.h \
 $(SRC)/include/uart.h \
-$(SRC)/include/wanpipe_tdm_api_iface.h \
-$(SRC)/include/zap_analog.h \
 $(SRC)/include/zap_buffer.h \
 $(SRC)/include/zap_config.h \
-$(SRC)/include/zap_isdn.h \
-$(SRC)/include/zap_skel.h \
 $(SRC)/include/zap_threadmutex.h \
 $(SRC)/include/zap_dso.h \
-$(SRC)/include/zap_types.h \
-$(SRC)/include/zap_wanpipe.h \
-$(SRC)/include/zap_ss7_boost.h \
-$(SRC)/include/zap_zt.h \
+$(SRC)/include/zap_types.h 
+
+
+ISDN_HEADERS=\
 $(SRC)/isdn/include/mfifo.h \
 $(SRC)/isdn/include/national.h \
 $(SRC)/isdn/include/DMS.h \
@@ -145,30 +144,33 @@ $(SRC)/isdn/include/Q931.h \
 $(SRC)/isdn/include/Q931ie.h \
 $(SRC)/isdn/include/Q932.h 
 
+
 PWD=$(shell pwd)
-INCS=-I$(PWD)/$(SRC)/include -I$(PWD)/$(SRC)/isdn/include
-CFLAGS+= $(INCS) $(ZAP_CFLAGS)
-MYLIB=libopenzap.a
+INCS=-I$(PWD)/$(SRC)/include -I$(PWD)/$(SRC)/isdn/include -I$(PWD)/$(SRC)/ozmod/ozmod_ss7_boost
+CFLAGS+= $(INCS) $(ZAP_CFLAGS) -DZAP_CONFIG_DIR=\"@prefix@/conf\" -DZAP_MOD_DIR=\"@prefix@/mod\"
+MYLIB=libopenzap.so
 LIBPRIA=libpri.a
 LIBPRI=./libpri
 TMP=-I$(LIBPRI) -I$(SRC)/include -I./src -w
+PREFIX=@prefix@
 
 PIKA_DIR=$(shell ls -d /usr/include/pika 2>/dev/null)
 PIKA_LIB=$(shell ls /usr/lib/libpikahmpapi.so 2>/dev/null)
 
-ifneq ($(PIKA_DIR),)
-ifneq ($(PIKA_LIB),)
-OBJS += $(SRC)/zap_pika.o
-CFLAGS += -DZAP_PIKA_SUPPORT -I$(PIKA_DIR)
-ADD_OBJS = $(PIKA_LIB)
-endif
-endif
+#ifneq ($(PIKA_DIR),)
+#ifneq ($(PIKA_LIB),)
+#OBJS += $(SRC)/zap_pika.o
+#CFLAGS += -DZAP_PIKA_SUPPORT -I$(PIKA_DIR)
+#ADD_OBJS = $(PIKA_LIB)
+#endif
+#endif
 
-all: $(MYLIB)
+all: $(MYLIB) analogmod isdnmod boostmod ztmod wpmod
 
 $(MYLIB): $(OBJS) $(HEADERS) $(SOURCES)
-       ar rcs $(MYLIB) $(OBJS) $(ADD_OBJS)
-       ranlib $(MYLIB)
+       #ar rcs $(MYLIB) $(OBJS) $(ADD_OBJS)
+       #ranlib $(MYLIB)
+       $(CC) -shared -Wl,-x -o $(MYLIB) $(OBJS) $(ADD_OBJS) -ldl
 
 testapp: $(SRC)/testapp.c $(MYLIB)
        $(CC) $(INCS) -L. $(SRC)/testapp.c -o testapp -lopenzap -lm -lpthread
@@ -226,6 +228,54 @@ mod_openzap-install: mod_openzap
 mod_openzap-clean:
        @if [ -f mod_openzap/mod_openzap.so ] ; then cd mod_openzap && make clean ; fi
 
-clean: mod_openzap-clean
-       rm -f $(SRC)/*.o $(SRC)/isdn/*.o $(MYLIB) *~ \#* testapp testcid testtones detect_tones detect_dtmf priserver testisdn testboost testanalog
+clean: 
+       rm -f $(SRC)/*.o $(SRC)/isdn/*.o $(MYLIB) *~ \#* testapp testcid testtones detect_tones detect_dtmf priserver testisdn testboost testanalog src/ozmod/*/*.o src/ozmod/*/*.so src/ozmod/*/*.dylib src/ozmod/*/*.dll
        @if [ -f $(LIBPRI)/$(LIBPRIA) ] ; then cd $(LIBPRI) && make clean ; fi
+
+install: all
+       @mkdir -p $(DESTDIR)$(PREFIX)
+       @[ -d "$(DESTDIR)$(PREFIX)/conf" ] || ( mkdir -p $(DESTDIR)$(PREFIX)/conf)
+       @[ -f "$(DESTDIR)$(PREFIX)/conf/openzap.conf" ] || ( cp conf/*.conf $(DESTDIR)$(PREFIX)/conf)
+       @mkdir -p $(DESTDIR)$(PREFIX)/lib
+       @[ ! -f $(MYLIB) ] || cp -f $(MYLIB) $(DESTDIR)$(PREFIX)/lib
+       @mkdir -p $(DESTDIR)$(PREFIX)/mod
+       @[ ! -f ozmod_* ] || cp -f ozmod_* $(DESTDIR)$(PREFIX)/mod
+       @cp -f src/ozmod/*/*.so $(DESTDIR)$(PREFIX)/mod
+       @echo OpenZAP Installed
+
+uninstall:
+       @rm -fr $(DESTDIR)$(PREFIX)
+
+$(SRC)/ozmod/ozmod_skel/ozmod_skel.so:
+       $(CC) $(INCS) $(ZAP_CFLAGS) -L. $(SRC)/ozmod/ozmod_skel/ozmod_skel.c -o $(SRC)/ozmod/ozmod_skel/ozmod_skel.so -shared -Wl,-x -lm -lpthread -ldl -Wl,--rpath -Wl,$(PREFIX)/lib
+skelmod: $(SRC)/ozmod/ozmod_skel/ozmod_skel.so
+
+
+$(SRC)/ozmod/ozmod_zt/ozmod_zt.so:
+       $(CC) $(INCS) $(ZAP_CFLAGS) -L. $(SRC)/ozmod/ozmod_zt/ozmod_zt.c -o $(SRC)/ozmod/ozmod_zt/ozmod_zt.so -shared -Wl,-x -lm -lpthread -ldl $(MYLIB) -Wl,--rpath -Wl,$(PREFIX)/lib
+ztmod: $(SRC)/ozmod/ozmod_zt/ozmod_zt.so
+
+$(SRC)/ozmod/ozmod_wanpipe/ozmod_wanpipe.so:
+       $(CC) $(INCS) $(ZAP_CFLAGS) -L. $(SRC)/ozmod/ozmod_wanpipe/ozmod_wanpipe.c -o $(SRC)/ozmod/ozmod_wanpipe/ozmod_wanpipe.so -shared -Wl,-x -lm -lpthread -ldl $(MYLIB) -Wl,--rpath -Wl,$(PREFIX)/lib
+wpmod: $(SRC)/ozmod/ozmod_wanpipe/ozmod_wanpipe.so
+
+$(SRC)/ozmod/ozmod_pika/ozmod_pika.so:
+       $(CC) -I$(PIKA_DIR) $(INCS) $(ZAP_CFLAGS) -L. $(SRC)/ozmod/ozmod_pika/ozmod_pika.c -o $(SRC)/ozmod/ozmod_pika/ozmod_pika.so -shared -Wl,-x -lm -lpthread -ldl $(MYLIB) $(PIKA_LIB) -Wl,--rpath -Wl,$(PREFIX)/lib
+
+pikamod: $(SRC)/ozmod/ozmod_pika/ozmod_pika.so
+
+$(ISDN_OBJS): $(ISDN_HEADERS) $(ISDN_SOURCES) $(SRC)/ozmod/ozmod_isdn/ozmod_isdn.c
+
+$(SRC)/ozmod/ozmod_isdn/ozmod_isdn.so: $(MYLIB) $(ISDN_OBJS)
+       $(CC) -I$(SRC)/isdn/include/ $(INCS) $(ZAP_CFLAGS) -L. $(ISDN_OBJS) $(SRC)/ozmod/ozmod_isdn/ozmod_isdn.c -o $(SRC)/ozmod/ozmod_isdn/ozmod_isdn.so -shared -Wl,-x -lm -lpthread -ldl $(MYLIB) -Wl,--rpath -Wl,$(PREFIX)/lib
+isdnmod: $(SRC)/ozmod/ozmod_isdn/ozmod_isdn.so
+
+$(SRC)/ozmod/ozmod_analog/ozmod_analog.so: $(MYLIB) $(ANALOG_OBJS)
+       $(CC) -I$(SRC)/analog/include/ $(INCS) $(ZAP_CFLAGS) -L. $(SRC)/ozmod/ozmod_analog/ozmod_analog.c -o $(SRC)/ozmod/ozmod_analog/ozmod_analog.so -shared -Wl,-x -lm -lpthread -ldl $(MYLIB) -Wl,--rpath -Wl,$(PREFIX)/lib
+analogmod: $(SRC)/ozmod/ozmod_analog/ozmod_analog.so
+
+$(SRC)/ozmod/ozmod_ss7_boost/ozmod_ss7_boost.so: $(MYLIB) $(BOOST_OBJS)
+       $(CC) -I/ozmod/ozmod_ss7_boost $(INCS) $(ZAP_CFLAGS) -L. $(BOOST_OBJS) $(SRC)/ozmod/ozmod_ss7_boost/ozmod_ss7_boost.c -o $(SRC)/ozmod/ozmod_ss7_boost/ozmod_ss7_boost.so -shared -Wl,-x -lm -lpthread -ldl $(MYLIB) -Wl,--rpath -Wl,$(PREFIX)/lib
+boostmod: $(SRC)/ozmod/ozmod_ss7_boost/ozmod_ss7_boost.so
+
+
diff --git a/libs/openzap/conf/modules.conf b/libs/openzap/conf/modules.conf
new file mode 100644 (file)
index 0000000..28d8d0b
--- /dev/null
@@ -0,0 +1,11 @@
+[modules]
+;load => ozmod_skel
+load => ozmod_zt
+load => ozmod_wanpipe
+;load => ozmod_pika
+load => ozmod_isdn
+load => ozmod_analog
+;load => ozmod_ss7_boost
+
+
+
index 480527be18b815c7ce1f1819d60038256dd96b15..76ee2c8df03516b409e0567ebd439ce74e1d4be3 100644 (file)
@@ -10,6 +10,9 @@ AC_PROG_CC
 AC_PROG_MAKE_SET
 AC_PROG_RANLIB
 
+
+AC_PREFIX_DEFAULT(/usr/local/openzap)
+
 # Check for com;iler type
 AC_DEFUN([AX_COMPILER_VENDOR],
 [
index 1552a37c45b1734c63b89e0547fd6bdc2b676714..b380a8103a0e83d5c7da9dfa8315ea2933a07ff9 100644 (file)
@@ -1,14 +1,21 @@
 BASE=../../..
 OZ_DIR=..
 VERBOSE=1
-OZA=$(OZ_DIR)/libopenzap.a
+OZSO=$(OZ_DIR)/libopenzap.so
 LOCAL_CFLAGS=-I$(OZ_DIR)/src/include -I$(OZ_DIR)/src/isdn/include
-LOCAL_LIBADD=$(OZA)
+LOCAL_LDFLAGS=-L$(OZ_DIR) -lopenzap 
 include $(BASE)/build/modmake.rules
 
-local_depend: $(OZA)
+local_depend: $(OZSO)
 
-$(OZA): $(OZ_DIR)/.update
-       cd $(OZ_DIR) && $(MAKE) ZAP_MODS="wanpipe zt" ZAP_CFLAGS="$(ALL_CXXFLAGS)"
+$(OZSO): $(OZ_DIR)/.update
+       cd $(OZ_DIR) && $(MAKE) ZAP_CFLAGS="$(ALL_CXXFLAGS)"
+
+local_install:
+       cd $(OZ_DIR) && $(MAKE) install ZAP_CFLAGS="$(ALL_CXXFLAGS)"
+       [ ! -f $(DESTDIR)$(PREFIX)/conf/autoload_configs/openzap.conf.xml ] || cp -f $(OZ_DIR)/conf/openzap.conf.xml  $(DESTDIR)$(PREFIX)/conf/autoload_configs
+
+local_clean:
+       cd $(OZ_DIR) && $(MAKE) clean
 
 
index 9c0af7659fca81095a93f816a981edd87cc42833..ae9133bf1d9134b3ebeebda5ca4e832c27f2ecf4 100644 (file)
@@ -31,9 +31,6 @@
  */
 #include <switch.h>
 #include "openzap.h"
-#include "zap_analog.h"
-#include "zap_isdn.h"
-#include "zap_ss7_boost.h"
 
 #ifndef __FUNCTION__
 #define __FUNCTION__ __SWITCH_FUNC__
@@ -1562,7 +1559,11 @@ static switch_status_t load_config(void)
                                continue;
                        }
 
-                       if (zap_analog_configure_span(span, tonegroup, to, max, on_analog_signal) != ZAP_SUCCESS) {
+                       if (zap_configure_span("analog", span, on_analog_signal, 
+                                                                  "tonemap", tonegroup, 
+                                                                  "digit_timeout", &to,
+                                                                  "max_dialstr", &max
+                                                                  ) != ZAP_SUCCESS) {
                                zap_log(ZAP_LOG_ERROR, "Error starting OpenZAP span %d\n", span_id);
                                continue;
                        }
@@ -1584,7 +1585,7 @@ static switch_status_t load_config(void)
                                switch_set_string(SPAN_CONFIG[span->span_id].hold_music, hold_music);
                        }
                        switch_copy_string(SPAN_CONFIG[span->span_id].type, "analog", sizeof(SPAN_CONFIG[span->span_id].type));
-                       zap_analog_start(span);
+                       zap_span_start(span);
                }
        }
 
@@ -1593,12 +1594,14 @@ static switch_status_t load_config(void)
                        char *id = (char *) switch_xml_attr_soft(myspan, "id");
                        char *context = "default";
                        char *dialplan = "XML";
-                       Q921NetUser_t mode = Q931_TE;
-                       Q931Dialect_t dialect = Q931_Dialect_National;
+                       //Q921NetUser_t mode = Q931_TE;
+                       //Q931Dialect_t dialect = Q931_Dialect_National;
+                       char *mode = NULL;
+                       char *dialect = NULL;
                        uint32_t span_id = 0;
                        zap_span_t *span = NULL;
                        char *tonegroup = NULL;
-                       zap_isdn_opts_t opts = ZAP_ISDN_OPT_NONE;
+                       uint32_t opts = 0;
                        
                        for (param = switch_xml_child(myspan, "param"); param; param = param->next) {
                                char *var = (char *) switch_xml_attr_soft(param, "name");
@@ -1607,16 +1610,13 @@ static switch_status_t load_config(void)
                                if (!strcasecmp(var, "tonegroup")) {
                                        tonegroup = val;
                                } else if (!strcasecmp(var, "mode")) {
-                                       mode = strcasecmp(val, "net") ? Q931_TE : Q931_NT;
+                                       mode = val;
                                } else if (!strcasecmp(var, "dialect")) {
-                                       dialect = q931_str2Q931Dialect_type(val);
-                                       if (dialect == Q931_Dialect_Count) {
-                                               dialect = Q931_Dialect_National;
-                                       }
+                                       dialect = val;
                                } else if (!strcasecmp(var, "context")) {
                                        context = val;
                                } else if (!strcasecmp(var, "suggest-channel") && switch_true(val)) {
-                                       opts |= ZAP_ISDN_OPT_SUGGEST_CHANNEL;
+                                       opts |= 1;
                                } else if (!strcasecmp(var, "dialplan")) {
                                        dialplan = val;
                                } 
@@ -1637,8 +1637,11 @@ static switch_status_t load_config(void)
                                zap_log(ZAP_LOG_ERROR, "Error finding OpenZAP span %d\n", span_id);
                                continue;
                        }
-
-                       if (zap_isdn_configure_span(span, mode, dialect, opts, on_clear_channel_signal) != ZAP_SUCCESS) {
+                       
+                       if (zap_configure_span("isdn", span, on_clear_channel_signal, 
+                                                                  "mode", mode, 
+                                                                  "dialect", dialect
+                                                                  ) != ZAP_SUCCESS) {
                                zap_log(ZAP_LOG_ERROR, "Error starting OpenZAP span %d mode: %d dialect: %d error: %s\n", span_id, mode, dialect, span->last_error);
                                continue;
                        }
@@ -1648,7 +1651,7 @@ static switch_status_t load_config(void)
                        switch_copy_string(SPAN_CONFIG[span->span_id].dialplan, dialplan, sizeof(SPAN_CONFIG[span->span_id].dialplan));
                        switch_copy_string(SPAN_CONFIG[span->span_id].type, "isdn", sizeof(SPAN_CONFIG[span->span_id].type));
 
-                       zap_isdn_start(span);
+                       zap_span_start(span);
                }
        }
 
@@ -1702,7 +1705,12 @@ static switch_status_t load_config(void)
                                continue;
                        }
 
-                       if (zap_ss7_boost_configure_span(span, local_ip, local_port, remote_ip, remote_port, on_clear_channel_signal) != ZAP_SUCCESS) {
+                       if (zap_configure_span("ss7_boost", span, on_clear_channel_signal, 
+                                                                  "local_ip", local_ip,
+                                                                  "local_port", &local_port,
+                                                                  "remote_ip", remote_ip,
+                                                                  "remote_port", &remote_port
+                                                                  ) != ZAP_SUCCESS) {
                                zap_log(ZAP_LOG_ERROR, "Error starting OpenZAP span %d error: %s\n", span_id, span->last_error);
                                continue;
                        }
@@ -1711,7 +1719,7 @@ static switch_status_t load_config(void)
                        switch_copy_string(SPAN_CONFIG[span->span_id].context, context, sizeof(SPAN_CONFIG[span->span_id].context));
                        switch_copy_string(SPAN_CONFIG[span->span_id].dialplan, dialplan, sizeof(SPAN_CONFIG[span->span_id].dialplan));
 
-                       zap_ss7_boost_start(span);
+                       zap_span_start(span);
                        switch_copy_string(SPAN_CONFIG[span->span_id].type, "ss7 (boost)", sizeof(SPAN_CONFIG[span->span_id].type));
                }
        }
index 5cc2bb0c40e1d5eacf82b1d0c7da1a5208293f00..8e252339a2253573560888058e08c17c831d7c2d 100644 (file)
@@ -230,6 +230,68 @@ hashtable_destroy(struct hashtable *h, int free_keys, int free_values)
     free(h);
 }
 
+struct hashtable_iterator *hashtable_next(struct hashtable_iterator *i)
+{
+
+       if (i->e) {
+               if ((i->e = i->e->next)) {
+                       return i;
+               } else {
+                       i->pos++;
+               }
+       }
+       
+       while(i->pos < i->h->tablelength && !i->h->table[i->pos]) {
+               i->pos++;
+       }
+       
+       if (i->pos >= i->h->tablelength) {
+               return NULL;
+       }
+       
+       if ((i->e = i->h->table[i->pos])) {
+               return i;
+       }
+
+       return NULL;
+}
+
+struct hashtable_iterator *hashtable_first(struct hashtable *h)
+{
+       h->iterator.pos = 0;
+       h->iterator.e = NULL;
+       h->iterator.h = h;
+       return hashtable_next(&h->iterator);
+}
+
+
+
+void hashtable_this(struct hashtable_iterator *i, const void **key, int *klen, void **val)
+{
+       if (i->e) {
+               if (key) {
+                       *key = i->e->k;
+               }
+               if (klen) {
+                       *klen = strlen(i->e->k);
+               }
+               if (val) {
+                       *val = i->e->v;
+               }
+       } else {
+               if (key) {
+                       *key = NULL;
+               }
+               if (klen) {
+                       *klen = 0;
+               }
+               if (val) {
+                       *val = NULL;
+               }
+       }
+}
+
+
 /*
  * Copyright (c) 2002, Christopher Clark
  * All rights reserved.
index 4c3c48f4bfa1b0fc244ce643b25f892a148c242d..243441c1d47c746ed5979d2ef9c9a529fc6e303a 100644 (file)
@@ -9,6 +9,7 @@
 #endif
 
 struct hashtable;
+struct hashtable_iterator;
 
 /* Example of use:
  *
@@ -168,6 +169,10 @@ hashtable_count(struct hashtable *h);
 void
 hashtable_destroy(struct hashtable *h, int free_keys, int free_values);
 
+struct hashtable_iterator *hashtable_first(struct hashtable *h);
+struct hashtable_iterator *hashtable_next(struct hashtable_iterator *i);
+void hashtable_this(struct hashtable_iterator *i, const void **key, int *klen, void **val);
+
 #endif /* __HASHTABLE_CWC22_H__ */
 
 /*
index ede652c6549fb7924b6f5479c9501f3ee2fdbb76..81197e6cb30b1ec339952a5c04281cec06683de3 100644 (file)
@@ -7,6 +7,7 @@
 
 
 /*****************************************************************************/
+
 struct entry
 {
     void *k, *v;
@@ -14,6 +15,12 @@ struct entry
     struct entry *next;
 };
 
+struct hashtable_iterator {
+       int pos;
+       struct entry *e;
+       struct hashtable *h;
+};
+
 struct hashtable {
     unsigned int tablelength;
     struct entry **table;
@@ -22,6 +29,7 @@ struct hashtable {
     unsigned int primeindex;
     unsigned int (*hashfn) (void *k);
     int (*eqfn) (void *k1, void *k2);
+       struct hashtable_iterator iterator;
 };
 
 /*****************************************************************************/
index 26b050181eacc981d08e1802b58a28c8e8aa1697..ff13d47386336912ad6148c9f53ef238d249cd22 100644 (file)
@@ -479,6 +479,7 @@ struct zap_span {
        zap_channel_t channels[ZAP_MAX_CHANNELS_SPAN];
        zio_channel_outgoing_call_t outgoing_call;
        zio_channel_request_t channel_request;
+       zap_span_start_t start;
        void *mod_data;
        char *type;
        int suggest_chan_id;
@@ -579,6 +580,10 @@ uint32_t zap_hash_hashfromstring(void *ky);
 uint32_t zap_running(void);
 zap_status_t zap_channel_complete_state(zap_channel_t *zchan);
 zap_status_t zap_channel_init(zap_channel_t *zchan);
+int zap_load_modules(void);
+zap_status_t zap_unload_modules(void);
+zap_status_t zap_configure_span(const char *type, zap_span_t *span, zio_signal_cb_t sig_cb, ...);
+zap_status_t zap_span_start(zap_span_t *span);
 
 ZIO_CODEC_FUNCTION(zio_slin2ulaw);
 ZIO_CODEC_FUNCTION(zio_ulaw2slin);
index 2c7be2b4be6fc4850dc80a43432c457749c4ec91..bf51f92b184bda5e95dcd4a88b852c96ede6f89c 100644 (file)
@@ -25,8 +25,8 @@ typedef void (*zap_func_ptr_t) (void);
 typedef void * zap_dso_lib_t;
 
 void zap_dso_destroy(zap_dso_lib_t *lib);
-zap_dso_lib_t zap_dso_open(const char *path, const char **err);
-zap_func_ptr_t zap_dso_func_sym(zap_dso_lib_t lib, const char *sym, const char **err);
+zap_dso_lib_t zap_dso_open(const char *path, char **err);
+void *zap_dso_func_sym(zap_dso_lib_t lib, const char *sym, char **err);
 
 
 #endif
diff --git a/libs/openzap/src/include/zap_skel.h b/libs/openzap/src/include/zap_skel.h
deleted file mode 100644 (file)
index a8a2458..0000000
+++ /dev/null
@@ -1,52 +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_SKEL_H
-#define ZAP_SKEL_H
-#include "openzap.h"
-
-zap_status_t skel_init(zap_software_interface_t **zint);
-zap_status_t skel_destroy(void);
-
-#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 expandtab:
- */
index 7c092e7f70a5d5d1a55ae1e3c6a05529d799d69f..9c14686f8cf6573a0aef376f92e31faaead6f4e0 100644 (file)
@@ -52,6 +52,7 @@ typedef int zap_filehandle_t;
 #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;
@@ -383,6 +384,7 @@ typedef struct zap_event zap_event_t;
 typedef struct zap_sigmsg zap_sigmsg_t;
 typedef struct zap_span zap_span_t;
 typedef struct zap_caller_data zap_caller_data_t;
+typedef struct zap_io_interface zap_io_interface_t;
 
 #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)
@@ -402,6 +404,11 @@ typedef struct zap_caller_data zap_caller_data_t;
 #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_SIG_UNLOAD_ARGS (void)
 
 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 ;
@@ -421,6 +428,11 @@ 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_io_unload_t) ZIO_IO_UNLOAD_ARGS ;
+typedef zap_status_t (*zio_sig_unload_t) ZIO_SIG_UNLOAD_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
@@ -440,6 +452,24 @@ typedef zap_status_t (*zio_write_t) ZIO_WRITE_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_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
+
+#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;
+       zap_dso_lib_t lib;
+       char path[256];
+} zap_module_t;
 
 #ifndef __FUNCTION__
 #define __FUNCTION__ (const char *)__func__
@@ -468,13 +498,13 @@ 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 zap_io_interface zap_io_interface_t;
 typedef struct hashtable zap_hash_t;
-typedef struct hashtable_itr zap_hash_itr_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 enum {
        ZAP_CAUSE_NONE = 0,
diff --git a/libs/openzap/src/include/zap_wanpipe.h b/libs/openzap/src/include/zap_wanpipe.h
deleted file mode 100644 (file)
index 0b2f4a9..0000000
+++ /dev/null
@@ -1,53 +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_WANPIPE_H
-#define ZAP_WANPIPE_H
-#include "openzap.h"
-
-zap_status_t wanpipe_init(zap_io_interface_t **zint);
-zap_status_t wanpipe_destroy(void);
-
-#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 expandtab:
- */
-
similarity index 95%
rename from libs/openzap/src/zap_analog.c
rename to libs/openzap/src/ozmod/ozmod_analog/ozmod_analog.c
index 64836c7436a100fe5862ab728db93b109cfb4196..fe438c2244ada13f4aa09372ec91fc8956fb936f 100644 (file)
@@ -70,9 +70,24 @@ static ZIO_CHANNEL_OUTGOING_CALL_FUNCTION(analog_fxs_outgoing_call)
        return ZAP_SUCCESS;
 }
 
-zap_status_t zap_analog_configure_span(zap_span_t *span, char *tonemap, uint32_t digit_timeout, uint32_t max_dialstr, zio_signal_cb_t sig_cb)
+
+static zap_status_t zap_analog_start(zap_span_t *span)
+{
+       zap_analog_data_t *analog_data = span->signal_data;
+       zap_set_flag(analog_data, ZAP_ANALOG_RUNNING);
+       return zap_thread_create_detached(zap_analog_run, span);
+}
+
+static ZIO_SIG_CONFIGURE_FUNCTION(zap_analog_configure_span)
+//zap_status_t zap_analog_configure_span(zap_span_t *span, char *tonemap, uint32_t digit_timeout, uint32_t max_dialstr, zio_signal_cb_t sig_cb)
 {
        zap_analog_data_t *analog_data;
+       char *tonemap = "us";
+       uint32_t digit_timeout = 10;
+       uint32_t max_dialstr = 11;
+       char *var, *val;
+       int *intval;
+
        assert(sig_cb != NULL);
 
        if (span->signal_type) {
@@ -92,6 +107,27 @@ zap_status_t zap_analog_configure_span(zap_span_t *span, char *tonemap, uint32_t
        memset(analog_data, 0, sizeof(*analog_data));
        assert(analog_data != NULL);
 
+
+       while(var = va_arg(ap, char *)) {
+               if (!strcasecmp(var, "tonemap")) {
+                       if (!(val = va_arg(ap, char *))) {
+                               break;
+                       }
+                       tonemap = val;
+               } else if (!strcasecmp(var, "digit_timeout")) {
+                       if (!(intval = va_arg(ap, int *))) {
+                               break;
+                       }
+                       digit_timeout = *intval;
+               } else if (!strcasecmp(var, "max_dialstr")) {
+                       if (!(intval = va_arg(ap, int *))) {
+                               break;
+                       }
+                       max_dialstr = *intval;
+               }
+       }
+
+       span->start = zap_analog_start;
        analog_data->digit_timeout = digit_timeout;
        analog_data->max_dialstr = max_dialstr;
        analog_data->sig_cb = sig_cb;
@@ -793,13 +829,21 @@ static void *zap_analog_run(zap_thread_t *me, void *obj)
 }
 
 
-zap_status_t zap_analog_start(zap_span_t *span)
+static ZIO_SIG_LOAD_FUNCTION(zap_analog_init)
 {
-       zap_analog_data_t *analog_data = span->signal_data;
-       zap_set_flag(analog_data, ZAP_ANALOG_RUNNING);
-       return zap_thread_create_detached(zap_analog_run, span);
+       return ZAP_SUCCESS;
 }
 
+zap_module_t zap_module = { 
+       "analog",
+       NULL,
+       NULL,
+       zap_analog_init,
+       zap_analog_configure_span,
+       NULL
+};
+
+
 /* For Emacs:
  * Local Variables:
  * mode:c
similarity index 91%
rename from libs/openzap/src/include/zap_analog.h
rename to libs/openzap/src/ozmod/ozmod_analog/zap_analog.h
index 5322463577bf34b7e26fa67ea29ab0182568ff5f..2d9091024472429afb6c71ff4860c6e092124b0a 100644 (file)
@@ -39,12 +39,9 @@ typedef enum {
        ZAP_ANALOG_RUNNING = (1 << 0)
 } zap_analog_flag_t;
 
-
+static void *zap_analog_run(zap_thread_t *me, void *obj);
 typedef struct zap_analog_data zap_analog_data_t;
 
-zap_status_t zap_analog_start(zap_span_t *span);
-zap_status_t zap_analog_configure_span(zap_span_t *span, char *tonemap, uint32_t digit_timeout, uint32_t max_dialstr, zio_signal_cb_t sig_cb);
-
 #endif
 
 /* For Emacs:
similarity index 97%
rename from libs/openzap/src/zap_isdn.c
rename to libs/openzap/src/ozmod/ozmod_isdn/ozmod_isdn.c
index 912a14fb0d9daf0afdcacd106d0ecca9c4f4e3f0..78792ba72c43ca2d20a67464994aed509bced67b 100644 (file)
@@ -663,7 +663,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
        zap_sigmsg_t sig;
        zap_status_t status;
 
-       zap_log(ZAP_LOG_ERROR, "%d:%d STATE [%s]\n", 
+       zap_log(ZAP_LOG_DEBUG, "%d:%d STATE [%s]\n", 
                        zchan->span_id, zchan->chan_id, zap_channel_state2str(zchan->state));
 
        memset(&sig, 0, sizeof(sig));
@@ -1134,7 +1134,7 @@ static void *zap_isdn_run(zap_thread_t *me, void *obj)
        return NULL;
 }
 
-zap_status_t zap_isdn_init(void)
+static ZIO_SIG_LOAD_FUNCTION(zap_isdn_init)
 {
        Q931Initialize();
 
@@ -1144,13 +1144,6 @@ zap_status_t zap_isdn_init(void)
        return ZAP_SUCCESS;
 }
 
-zap_status_t zap_isdn_start(zap_span_t *span)
-{
-       zap_isdn_data_t *isdn_data = span->signal_data;
-       zap_set_flag(isdn_data, ZAP_ISDN_RUNNING);
-       return zap_thread_create_detached(zap_isdn_run, span);
-}
-
 static int q931_rx_32(void *pvt, Q921DLMsg_t ind, L3UCHAR tei, L3UCHAR *msg, L3INT mlen)
 {
        int offset = 4;
@@ -1317,11 +1310,24 @@ static zap_state_map_t isdn_state_map = {
        }
 };
 
-zap_status_t zap_isdn_configure_span(zap_span_t *span, Q921NetUser_t mode, Q931Dialect_t dialect, zap_isdn_opts_t opts, zio_signal_cb_t sig_cb)
+static zap_status_t zap_isdn_start(zap_span_t *span)
+{
+       zap_isdn_data_t *isdn_data = span->signal_data;
+       zap_set_flag(isdn_data, ZAP_ISDN_RUNNING);
+       return zap_thread_create_detached(zap_isdn_run, span);
+}
+
+
+
+static ZIO_SIG_CONFIGURE_FUNCTION(zap_isdn_configure_span)
 {
        uint32_t i, x = 0;
        zap_channel_t *dchans[2] = {0};
        zap_isdn_data_t *isdn_data;
+       char *var, *val;
+       Q931Dialect_t dialect = Q931_Dialect_National;
+       uint32_t opts = 0;
+
        if (span->signal_type) {
                snprintf(span->last_error, sizeof(span->last_error), "Span is already configured for signalling [%d].", span->signal_type);
                return ZAP_FAIL;
@@ -1352,21 +1358,46 @@ zap_status_t zap_isdn_configure_span(zap_span_t *span, Q921NetUser_t mode, Q931D
                return ZAP_FAIL;
        }
 
-       
        isdn_data = malloc(sizeof(*isdn_data));
        assert(isdn_data != NULL);
        memset(isdn_data, 0, sizeof(*isdn_data));
        
+       isdn_data->mode = Q931_TE;
+       dialect = Q931_Dialect_National;
+       
+       while(var = va_arg(ap, char *)) {
+               if (!strcasecmp(var, "mode")) {
+                       if (!(val = va_arg(ap, char *))) {
+                               break;
+                       }
+                       isdn_data->mode = strcasecmp(val, "net") ? Q931_TE : Q931_NT;
+               } else if (!strcasecmp(var, "dialect")) {
+                       if (!(val = va_arg(ap, char *))) {
+                               break;
+                       }
+                       dialect = q931_str2Q931Dialect_type(val);
+                       if (dialect == Q931_Dialect_Count) {
+                               dialect = Q931_Dialect_National;
+                       }
+               } else if (!strcasecmp(var, "opts")) {
+                       int *optp;
+                       if (!(optp = va_arg(ap, int *))) {
+                               break;
+                       }
+                       opts = isdn_data->opts = *optp;
+               }
+       }
+
+       span->start = zap_isdn_start;
        isdn_data->sig_cb = sig_cb;
        isdn_data->dchans[0] = dchans[0];
        isdn_data->dchans[1] = dchans[1];
        isdn_data->dchan = isdn_data->dchans[0];
-       isdn_data->mode  = mode;
        
        Q921_InitTrunk(&isdn_data->q921,
                                   0,
                                   0,
-                                  mode,
+                                  isdn_data->mode,
                                   span->trunk_type == ZAP_TRUNK_BRI_PTMP ? Q921_PTMP : Q921_PTP,
                                   0,
                                   zap_isdn_921_21,
@@ -1379,7 +1410,7 @@ zap_status_t zap_isdn_configure_span(zap_span_t *span, Q921NetUser_t mode, Q931D
        
        Q931Api_InitTrunk(&isdn_data->q931,
                                          dialect,
-                                         mode,
+                                         isdn_data->mode,
                                          span->trunk_type,
                                          zap_isdn_931_34,
                                          (Q931Tx32CB_t)q931_rx_32,
@@ -1397,7 +1428,7 @@ zap_status_t zap_isdn_configure_span(zap_span_t *span, Q921NetUser_t mode, Q931D
        span->signal_data = isdn_data;
        span->signal_type = ZAP_SIGTYPE_ISDN;
        span->outgoing_call = isdn_outgoing_call;
-       isdn_data->opts = opts;
+
 
        if ((opts & ZAP_ISDN_OPT_SUGGEST_CHANNEL)) {
                span->channel_request = isdn_channel_request;
@@ -1408,6 +1439,17 @@ zap_status_t zap_isdn_configure_span(zap_span_t *span, Q921NetUser_t mode, Q931D
        return ZAP_SUCCESS;
 }
 
+
+zap_module_t zap_module = { 
+       "isdn",
+       NULL,
+       NULL,
+       zap_isdn_init,
+       zap_isdn_configure_span,
+       NULL
+};
+
+
 /* For Emacs:
  * Local Variables:
  * mode:c
similarity index 91%
rename from libs/openzap/src/include/zap_isdn.h
rename to libs/openzap/src/ozmod/ozmod_isdn/zap_isdn.h
index e18a51ab0a4890058e6f18a32b1f64e1ba6bd768..86a3f4015550304cbed09fcd45c8a46b78d6289b 100644 (file)
@@ -64,10 +64,6 @@ struct zap_isdn_data {
 
 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, zap_isdn_opts_t opts, zio_signal_cb_t sig_cb);
-
 #endif
 
 /* For Emacs:
similarity index 99%
rename from libs/openzap/src/zap_pika.c
rename to libs/openzap/src/ozmod/ozmod_pika/ozmod_pika.c
index ffe79e397cd47dba8303631555d2a26e5f4363e3..e3121309ec56cb893293d8a7624e20a889f3fd65 100644 (file)
@@ -1179,7 +1179,7 @@ static ZIO_GET_ALARMS_FUNCTION(pika_get_alarms)
 
 static zap_io_interface_t pika_interface;
 
-zap_status_t pika_init(zap_io_interface_t **zint)
+static ZIO_IO_LOAD_FUNCTION(pika_init)
 {
 
        PK_STATUS status;
@@ -1189,7 +1189,7 @@ zap_status_t pika_init(zap_io_interface_t **zint)
        PKH_TLogMasks m;
        TPikaHandle tmpHandle;
 
-       assert(zint != NULL);
+       assert(zio != NULL);
        memset(&pika_interface, 0, sizeof(pika_interface));
        memset(&globals, 0, sizeof(globals));
        globals.general_config.region = PKH_TRUNK_NA;
@@ -1271,7 +1271,7 @@ zap_status_t pika_init(zap_io_interface_t **zint)
        pika_interface.channel_destroy = pika_channel_destroy;
        pika_interface.span_destroy = pika_span_destroy;
        pika_interface.get_alarms = pika_get_alarms;
-       *zint = &pika_interface;
+       *zio = &pika_interface;
 
 
        zap_log(ZAP_LOG_INFO, "Dumping Default configs:\n");
@@ -1313,7 +1313,8 @@ zap_status_t pika_init(zap_io_interface_t **zint)
        return ZAP_SUCCESS;
 }
 
-zap_status_t pika_destroy(void)
+
+static ZIO_IO_UNLOAD_FUNCTION(pika_destroy)
 {
        uint32_t x;
        PK_STATUS status;
@@ -1339,6 +1340,12 @@ zap_status_t pika_destroy(void)
        return ZAP_SUCCESS;
 }
 
+zap_module_t zap_module = { 
+       "pika",
+       pika_init,
+       pika_destroy,
+};
+
 /* For Emacs:
  * Local Variables:
  * mode:c
similarity index 96%
rename from libs/openzap/src/include/zap_pika.h
rename to libs/openzap/src/ozmod/ozmod_pika/zap_pika.h
index a98c08cbe6ef9c66e1d85161e7d30811cc33b417..c8401c6aa1af67164b84cea2224bea39bb7f5b9a 100644 (file)
@@ -94,11 +94,6 @@ typedef enum {
 #define PIKA_SPAN_COMPAND_MODE_STRINGS "MU_LAW", "A_LAW"
 ZAP_STR2ENUM_P(pika_str2compand_mode, pika_compand_mode2str, PIKA_TSpanCompandMode)
 
-
-/* Openzap PIKA hardware interface functions */
-zap_status_t pika_init(zap_io_interface_t **zint);
-zap_status_t pika_destroy(void);
-
 #endif
 
 /* For Emacs:
similarity index 88%
rename from libs/openzap/src/zap_skel.c
rename to libs/openzap/src/ozmod/ozmod_skel/ozmod_skel.c
index 575550979a8ddebd41202382fb5c02835d9ac9ba..aa468a356f4bdf8a0852a4a16ce032d9df8be7cb 100644 (file)
 
 
 #include "openzap.h"
-#include "zap_skel.h"
+//#include "zap_skel.h"
 
 static ZIO_CONFIGURE_FUNCTION(skel_configure)
 {
-       ZIO_CONFIGURE_MUZZLE;
        return ZAP_FAIL;
 }
 
 static ZIO_CONFIGURE_SPAN_FUNCTION(skel_configure_span)
 {
-
+       return ZAP_FAIL;
 }
 
 static ZIO_OPEN_FUNCTION(skel_open) 
 {
-       ZIO_OPEN_MUZZLE;
        return ZAP_FAIL;
 }
 
 static ZIO_CLOSE_FUNCTION(skel_close)
 {
-       ZIO_CLOSE_MUZZLE;
-       return ZAP_FAIL;
-}
-
-static ZIO_SET_INTERVAL_FUNCTION(skel_set_interval)
-{
-       ZIO_SET_INTERVAL_MUZZLE;
        return ZAP_FAIL;
 }
 
 static ZIO_WAIT_FUNCTION(skel_wait)
 {
-       ZIO_WAIT_MUZZLE;
        return ZAP_FAIL;
 }
 
 static ZIO_READ_FUNCTION(skel_read)
 {
-       ZIO_READ_MUZZLE;
        return ZAP_FAIL;
 }
 
 static ZIO_WRITE_FUNCTION(skel_write)
 {
-       ZIO_WRITE_MUZZLE;
        return ZAP_FAIL;
 }
 
@@ -102,21 +90,21 @@ static ZIO_CHANNEL_DESTROY_FUNCTION(skel_channel_destroy)
        return ZAP_FAIL;
 }
 
-static ZIO_CHANNEL_DESTROY_FUNCTION(skel_span_destroy)
+static ZIO_SPAN_DESTROY_FUNCTION(skel_span_destroy)
 {
        return ZAP_FAIL;
 }
 
 static ZIO_GET_ALARMS_FUNCTION(skel_get_alarms)
 {
-       return zap_fail;
+       return ZAP_FAIL;
 }
 
 static zap_io_interface_t skel_interface;
 
-zap_status_t skel_init(zap_io_interface_t **zint)
+static ZIO_IO_LOAD_FUNCTION(skel_init)
 {
-       assert(zint != NULL);
+       assert(zio != NULL);
        memset(&skel_interface, 0, sizeof(skel_interface));
 
        skel_interface.name = "skel";
@@ -133,16 +121,24 @@ zap_status_t skel_init(zap_io_interface_t **zint)
        skel_interface.channel_destroy = skel_channel_destroy;
        skel_interface.span_destroy = skel_span_destroy;
        skel_interface.get_alarms = skel_get_alarms;
-       *zint = &skel_interface;
+       *zio = &skel_interface;
 
-       return ZAP_FAIL;
+       return ZAP_SUCCESS;
 }
 
-zap_status_t skel_destroy(void)
+static ZIO_IO_UNLOAD_FUNCTION(skel_destroy)
 {
-       return ZAP_FAIL;
+       return ZAP_SUCCESS;
 }
 
+
+zap_module_t zap_module = { 
+       "skel",
+       skel_init,
+       skel_destroy,
+};
+
+
 /* For Emacs:
  * Local Variables:
  * mode:c
similarity index 96%
rename from libs/openzap/src/zap_ss7_boost.c
rename to libs/openzap/src/ozmod/ozmod_ss7_boost/ozmod_ss7_boost.c
index 4a26054029048f8effb8c37e936d233c311aa7a4..64cad3c02d2aad856255fa7db13222708aa2fa60 100644 (file)
@@ -974,15 +974,15 @@ static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
        return NULL;
 }
 
-zap_status_t zap_ss7_boost_init(void)
+static ZIO_SIG_LOAD_FUNCTION(zap_ss7_boost_init)
 {
        zap_mutex_create(&request_mutex);
        zap_mutex_create(&signal_mutex);
-
+       
        return ZAP_SUCCESS;
 }
 
-zap_status_t zap_ss7_boost_start(zap_span_t *span)
+static zap_status_t zap_ss7_boost_start(zap_span_t *span)
 {
        zap_ss7_boost_data_t *ss7_boost_data = span->signal_data;
        zap_set_flag(ss7_boost_data, ZAP_SS7_BOOST_RUNNING);
@@ -1088,13 +1088,39 @@ static zap_state_map_t boost_state_map = {
        }
 };
 
-zap_status_t zap_ss7_boost_configure_span(zap_span_t *span,
-                                                                                 const char *local_ip, int local_port, 
-                                                                                 const char *remote_ip, int remote_port,
-                                                                                 zio_signal_cb_t sig_cb)
+static ZIO_SIG_CONFIGURE_FUNCTION(zap_ss7_boost_configure_span)
 {
        zap_ss7_boost_data_t *ss7_boost_data = NULL;
-       
+       char *local_ip = "127.0.0.65", *remote_ip = "127.0.0.66";
+       int local_port = 5300, remote_port = 5300;
+       char *var, *val;
+       int *intval;
+
+       while(var = va_arg(ap, char *)) {
+               if (!strcasecmp(var, "local_ip")) {
+                       if (!(val = va_arg(ap, char *))) {
+                               break;
+                       }
+                       local_ip = val;
+               } else if (!strcasecmp(var, "remote_ip")) {
+                       if (!(val = va_arg(ap, char *))) {
+                               break;
+                       }
+                       remote_ip = val;
+               } else if (!strcasecmp(var, "local_port")) {
+                       if (!(intval = va_arg(ap, int *))) {
+                               break;
+                       }
+                       local_port = *intval;
+               } else if (!strcasecmp(var, "remote_port")) {
+                       if (!(intval = va_arg(ap, int *))) {
+                               break;
+                       }
+                       remote_port = *intval;
+               }
+       }
+
+
        if (!local_ip && local_port && remote_ip && remote_port && sig_cb) {
                return ZAP_FAIL;
        }
@@ -1108,7 +1134,7 @@ zap_status_t zap_ss7_boost_configure_span(zap_span_t *span,
        zap_set_string(ss7_boost_data->mcon.cfg.remote_ip, remote_ip);
        ss7_boost_data->mcon.cfg.remote_port = remote_port;
        ss7_boost_data->signal_cb = sig_cb;
-       
+       span->start = zap_ss7_boost_start;
        span->signal_data = ss7_boost_data;
     span->signal_type = ZAP_SIGTYPE_SS7BOOST;
     span->outgoing_call = ss7_boost_outgoing_call;
@@ -1119,6 +1145,16 @@ zap_status_t zap_ss7_boost_configure_span(zap_span_t *span,
        return ZAP_SUCCESS;
 }
 
+
+zap_module_t zap_module = { 
+       "analog",
+       NULL,
+       NULL,
+       zap_ss7_boost_init,
+       zap_ss7_boost_configure_span,
+       NULL
+};
+
 /* For Emacs:
  * Local Variables:
  * mode:c
similarity index 88%
rename from libs/openzap/src/include/zap_ss7_boost.h
rename to libs/openzap/src/ozmod/ozmod_ss7_boost/zap_ss7_boost.h
index c5496b8aed8cf0ae88c14a987e590a528c44e689..b3f3e416bfbd3fa6dc8469fbdd45aa0d5eb94290 100644 (file)
@@ -48,14 +48,6 @@ typedef struct zap_ss7_boost_data {
        uint32_t flags;
 } zap_ss7_boost_data_t;
 
-zap_status_t zap_ss7_boost_start(zap_span_t *span);
-zap_status_t zap_ss7_boost_init(void);
-zap_status_t zap_ss7_boost_configure_span(zap_span_t *span,
-                                                                                 const char *local_ip, int local_port, 
-                                                                                 const char *remote_ip, int remote_port,
-                                                                                 zio_signal_cb_t sig_cb);
-
-
 #endif
 
 /* For Emacs:
similarity index 99%
rename from libs/openzap/src/zap_wanpipe.c
rename to libs/openzap/src/ozmod/ozmod_wanpipe/ozmod_wanpipe.c
index bbeb191b4ae374629d84851411d55dc52f23ee07..19d74cdb19d5c4afcb2356c7f0155d3a36a060ae 100644 (file)
 #include <stropts.h>
 #endif
 #include "openzap.h"
-#include "zap_wanpipe.h"
 #include <poll.h>
 #include <sys/socket.h>
-#include <wanpipe_tdm_api_iface.h>
+#include "wanpipe_tdm_api_iface.h"
 
 typedef enum {
        WP_RINGING = (1 << 0)
@@ -935,7 +934,7 @@ static ZIO_CHANNEL_DESTROY_FUNCTION(wanpipe_channel_destroy)
        return ZAP_SUCCESS;
 }
 
-zap_status_t wanpipe_init(zap_io_interface_t **zio)
+static ZIO_IO_LOAD_FUNCTION(wanpipe_init)
 {
        assert(zio != NULL);
        memset(&wanpipe_interface, 0, sizeof(wanpipe_interface));
@@ -964,12 +963,19 @@ zap_status_t wanpipe_init(zap_io_interface_t **zio)
        return ZAP_SUCCESS;
 }
 
-zap_status_t wanpipe_destroy(void)
+static ZIO_IO_UNLOAD_FUNCTION(wanpipe_destroy)
 {
        memset(&wanpipe_interface, 0, sizeof(wanpipe_interface));
        return ZAP_SUCCESS;
 }
 
+
+zap_module_t zap_module = { 
+       "wanpipe",
+       wanpipe_init,
+       wanpipe_destroy,
+};
+
 /* For Emacs:
  * Local Variables:
  * mode:c
similarity index 99%
rename from libs/openzap/src/zap_zt.c
rename to libs/openzap/src/ozmod/ozmod_zt/ozmod_zt.c
index 38c55ffae585c97fbdd50460165b78f150c875af..4b271ed6f50cac6c5a30e0be1d682e32aa6d3694 100644 (file)
@@ -33,7 +33,7 @@
 
 
 #include "openzap.h"
-#include "zap_zt.h"
+#include "ozmod_zt.h"
 
 
 static struct {
@@ -737,7 +737,7 @@ static ZIO_CHANNEL_DESTROY_FUNCTION(zt_channel_destroy)
 
 static zap_io_interface_t zt_interface;
 
-zap_status_t zt_init(zap_io_interface_t **zio)
+static ZIO_IO_LOAD_FUNCTION(zt_init)
 {
        assert(zio != NULL);
        memset(&zt_interface, 0, sizeof(zt_interface));
@@ -772,13 +772,20 @@ zap_status_t zt_init(zap_io_interface_t **zio)
        return ZAP_SUCCESS;
 }
 
-zap_status_t zt_destroy(void)
+static ZIO_IO_UNLOAD_FUNCTION(zt_destroy)
 {
        close(CONTROL_FD);
        memset(&zt_interface, 0, sizeof(zt_interface));
        return ZAP_SUCCESS;
 }
 
+
+zap_module_t zap_module = { 
+       "zt",
+       zt_init,
+       zt_destroy,
+};
+
 /* For Emacs:
  * Local Variables:
  * mode:c
similarity index 98%
rename from libs/openzap/src/include/zap_zt.h
rename to libs/openzap/src/ozmod/ozmod_zt/ozmod_zt.h
index 0e16d2939897089430050dc358fb08152d818bf6..c3e206758519c4a900bee12c6cb89aca7302d32f 100644 (file)
@@ -280,10 +280,6 @@ ZT_SIG_HDLCFCS                             = ((1 << 9)  | ZT_SIG_HDLCRAW)
 #define                ZT_ECHOTRAIN            _IOW  (ZT_CODE, 50, int)                                /* Control Echo Trainer */
 
 
-/* Openzap ZT hardware interface functions */
-zap_status_t zt_init(zap_io_interface_t **zint);
-zap_status_t zt_destroy(void);
-
 #endif
 
 /* For Emacs:
index 1ad530db8943812f55876d77a96b3329f0e546f5..813605decc1bbbb47d422f09cf427f9616c4c3f0 100644 (file)
@@ -1,5 +1,4 @@
 #include "openzap.h"
-#include "zap_analog.h"
 
 
 static void *test_call(zap_thread_t *me, void *obj)
@@ -59,11 +58,20 @@ static ZIO_SIGNAL_CB_FUNCTION(on_signal)
        return ZAP_SUCCESS;
 }
 
+static int R = 0;
+static void handle_SIGINT(int sig)
+{
+       if (sig);
+       R = 0;
+       return;
+}
+
 int main(int argc, char *argv[])
 {
        zap_span_t *span;
        int span_id;
-       zap_analog_data_t *analog_data;
+       int digit_timeout = 2000;
+       int max_dialstr = 11;
 
        if (argc < 2) {
                printf("usage %s <spanno>\n", argv[0]);
@@ -86,19 +94,22 @@ int main(int argc, char *argv[])
                goto done;
        }
        
-       if (zap_analog_configure_span(span, "us", 2000, 11, on_signal) != ZAP_SUCCESS) {
+
+       if (zap_configure_span("analog", span, on_signal, 
+                                                  "tonemap", "te", 
+                                                  "digit_timeout", &digit_timeout,
+                                                  "max_dialstr", &max_dialstr
+                                                  ) == ZAP_SUCCESS) {
                zap_log(ZAP_LOG_ERROR, "Error configuring OpenZAP span\n");
                goto done;
        }
-       analog_data = span->signal_data;
-       zap_analog_start(span);
-
-       while(zap_test_flag(analog_data, ZAP_ANALOG_RUNNING)) {
+       zap_span_start(span);
+       
+       while(zap_running() && R) {
                zap_sleep(1 * 1000);
        }
 
-
- done:
+done:
 
        zap_global_destroy();
 
index 4fb9ee12bad74cde77122f2aaf368e262b535105..c27636efabc7af26733e2e35a5c2e9d17e99022e 100644 (file)
@@ -1,15 +1,24 @@
 #include "openzap.h"
-#include "zap_ss7_boost.h"
 
 static ZIO_SIGNAL_CB_FUNCTION(on_signal)
 {
        return ZAP_FAIL;
 }
 
+static int R = 0;
+static void handle_SIGINT(int sig)
+{
+       if (sig);
+       R = 0;
+       return;
+}
+
 int main(int argc, char *argv[])
 {
        zap_span_t *span;
-       zap_ss7_boost_data_t *data;
+       int local_port, remote_port;
+
+       local_port = remote_port = 53000;
 
        zap_global_set_default_logger(ZAP_LOG_LEVEL_DEBUG);
 
@@ -30,16 +39,19 @@ int main(int argc, char *argv[])
                goto done;
        }
        
-
-       if (zap_ss7_boost_configure_span(span, "127.0.0.65", 53000, "127.0.0.66", 53000, on_signal) == ZAP_SUCCESS) {
-               data = span->signal_data;
-               zap_ss7_boost_start(span);
+       if (zap_configure_span("ss7_boost", span, on_signal, 
+                                                  "local_ip", "127.0.0.65",
+                                                  "local_port", &local_port,
+                                                  "remote_ip", "127.0.0.66",
+                                                  "remote_port", &remote_port
+                                                  ) == ZAP_SUCCESS) {
+               zap_span_start(span);
        } else {
                fprintf(stderr, "Error starting SS7_BOOST\n");
                goto done;
        }
 
-       while(zap_test_flag(data, ZAP_SS7_BOOST_RUNNING)) {
+       while(zap_running() && R) {
                zap_sleep(1 * 1000);
        }
 
index 88cc11371725481d52143df6e707c96cbdbc10ca..29bf4c952bf5f6326320d825e501b00810cbb4d2 100644 (file)
@@ -1,16 +1,24 @@
 #include "openzap.h"
-#include "zap_isdn.h"
+#include <signal.h>
+
 
 static ZIO_SIGNAL_CB_FUNCTION(on_signal)
 {
        return ZAP_FAIL;
 }
 
+static int R = 0;
+static void handle_SIGINT(int sig)
+{
+       if (sig);
+       R = 0;
+       return;
+}
+
 int main(int argc, char *argv[])
 {
        zap_span_t *span;
-       zap_isdn_data_t *data;
-
+       
        zap_global_set_default_logger(ZAP_LOG_LEVEL_DEBUG);
 
        if (argc < 2) {
@@ -31,15 +39,30 @@ int main(int argc, char *argv[])
        }
        
        
+#if 1
+
+       if (zap_configure_span("isdn", span, on_signal, 
+                                                  "mode", "te", 
+                                                  "dialect", "national"
+                                                  ) == ZAP_SUCCESS) {
+               zap_span_start(span);
+       } else {
+               fprintf(stderr, "Error starting ISDN D-Channel\n");
+               goto done;
+       }
+#else 
        if (zap_isdn_configure_span(span, Q931_TE, Q931_Dialect_National, 0, on_signal) == ZAP_SUCCESS) {
-               data = span->signal_data;
                zap_isdn_start(span);
        } else {
                fprintf(stderr, "Error starting ISDN D-Channel\n");
                goto done;
        }
 
-       while(zap_test_flag(data, ZAP_ISDN_RUNNING)) {
+#endif
+
+       signal(SIGINT, handle_SIGINT);
+       R = 1;
+       while(R) {
                zap_sleep(1 * 1000);
        }
 
index aceaa5f5e5aa191253385435d4cbbd28153082ce..07c25f29fd97470614b852a6641f98fa632e0e52 100644 (file)
 #include <dlfcn.h>
 
 void zap_dso_destroy(zap_dso_lib_t *lib) {
-       if (lib) {
-               dlclose(lib);
-               lib = NULL;
+       if (lib && *lib) {
+               dlclose(*lib);
+               *lib = NULL;
        }
 }
 
-zap_dso_lib_t zap_dso_open(const char *path, const char **err) {
+zap_dso_lib_t zap_dso_open(const char *path, char **err) {
        void *lib = dlopen(path, RTLD_NOW | RTLD_LOCAL);
        if (lib == NULL) {
                *err = strdup(dlerror());
@@ -48,8 +48,8 @@ zap_dso_lib_t zap_dso_open(const char *path, const char **err) {
        return lib;
 }
 
-zap_func_ptr_t zap_dso_func_sym(zap_dso_lib_t lib, const char *sym, const char **err) {
-       zap_dso_lib_t func = (zap_dso_lib_t)dlsym(lib, sym);
+void *zap_dso_func_sym(zap_dso_lib_t lib, const char *sym, char **err) {
+       void *func = dlsym(lib, sym);
        if (!func) {
                *err = strdup(dlerror());
        }
index 2c24cc5d85f3ad2fe09d02fa25a4dc07807e4010..7eb6bda296fa74e9753fed1e37aaff17e4fdede1 100644 (file)
  */
 
 #ifndef WIN32
-#define ZAP_ZT_SUPPORT
-#define ZAP_WANPIPE_SUPPORT
 #endif
 #include "openzap.h"
-#include "zap_isdn.h"
-#include "zap_ss7_boost.h"
+//#include "zap_isdn.h"
+//#include "zap_ss7_boost.h"
 #include <stdarg.h>
 #ifdef WIN32
 #include <io.h>
 #endif
-#ifdef ZAP_WANPIPE_SUPPORT
-#include "zap_wanpipe.h"
-#endif
-#ifdef ZAP_ZT_SUPPORT
-#include "zap_zt.h"
-#endif
 #ifdef ZAP_PIKA_SUPPORT
 #include "zap_pika.h"
 #endif
@@ -83,6 +75,7 @@ zap_time_t zap_current_time_in_ms(void)
 
 static struct {
        zap_hash_t *interface_hash;
+       zap_hash_t *module_hash;
        zap_mutex_t *mutex;
        struct zap_span spans[ZAP_MAX_SPANS_INTERFACE];
        uint32_t span_index;
@@ -1929,8 +1922,6 @@ zap_status_t zap_channel_write(zap_channel_t *zchan, void *data, zap_size_t data
 }
 
 static struct {
-       zap_io_interface_t *wanpipe_interface;
-       zap_io_interface_t *zt_interface;
        zap_io_interface_t *pika_interface;
 } interfaces;
 
@@ -2104,6 +2095,173 @@ static zap_status_t process_module_config(zap_io_interface_t *zio)
        return ZAP_SUCCESS;
 }
 
+int zap_load_modules(void)
+{
+       char cfg_name[] = "modules.conf";
+       char path[128] = "";
+       zap_config_t cfg;
+       char *err;
+       char *var, *val;
+       zap_module_t *mod;
+       int count = 0;
+
+#ifdef WIN32
+    const char *ext = ".dll";
+    //const char *EXT = ".DLL";
+#elif defined (MACOSX) || defined (DARWIN)
+    const char *ext = ".dylib";
+    //const char *EXT = ".DYLIB";
+#else
+    const char *ext = ".so";
+    //const char *EXT = ".SO";
+#endif
+
+       
+       if (!zap_config_open_file(&cfg, cfg_name)) {
+        return ZAP_FAIL;
+    }
+
+       while (zap_config_next_pair(&cfg, &var, &val)) {
+        if (!strcasecmp(cfg.category, "modules")) {
+                       if (!strcasecmp(var, "load")) {
+                               zap_dso_lib_t lib;
+                               int x = 0;
+
+                               if (*val == *ZAP_PATH_SEPARATOR) {
+                                       snprintf(path, sizeof(path), "%s%s", val, ext);
+                               } else {
+                                       snprintf(path, sizeof(path), "%s%s%s%s", ZAP_MOD_DIR, ZAP_PATH_SEPARATOR, val, ext);
+                               }
+                               
+                               if (!(lib = zap_dso_open(path, &err))) {
+                                       zap_log(ZAP_LOG_ERROR, "Error loading %s [%s]\n", path, err);
+                                       free(err);
+                                       continue;
+                               }
+                               
+                               if (!(mod = (zap_module_t *) zap_dso_func_sym(lib, "zap_module", &err))) {
+                                       zap_log(ZAP_LOG_ERROR, "Error loading %s [%s]\n", path, err);
+                                       free(err);
+                                       continue;
+                               }
+
+                               if (mod->io_load) {
+                                       zap_io_interface_t *interface;
+
+                                       if (mod->io_load(&interface) != ZAP_SUCCESS || !interface) {
+                                               zap_log(ZAP_LOG_ERROR, "Error loading %s [%s]\n", path, err);
+                                       } else {
+                                               zap_log(ZAP_LOG_INFO, "Loading IO from %s\n", path);
+                                               zap_mutex_lock(globals.mutex);
+                                               hashtable_insert(globals.interface_hash, (void *)interface->name, interface);
+                                               process_module_config(interface);
+                                               zap_mutex_unlock(globals.mutex);
+                                               x++;
+                                       }
+                               }
+
+                               if (mod->sig_load) {
+                                       if (mod->sig_load() != ZAP_SUCCESS) {
+                                               zap_log(ZAP_LOG_ERROR, "Error loading %s [%s]\n", path, err);
+                                       } else {
+                                               zap_log(ZAP_LOG_INFO, "Loading SIG from %s\n", path);
+                                               x++;
+                                       }
+                               }
+
+                               if (x) {
+                                       char *p;
+                                       mod->lib = lib;
+                                       zap_set_string(mod->path, path);
+                                       if (mod->name[0] == '\0') {
+                                               if (!(p = strrchr(path, *ZAP_PATH_SEPARATOR))) {
+                                                       p = path;
+                                               }
+                                               zap_set_string(mod->name, p);
+                                       }
+
+                                       hashtable_insert(globals.module_hash, (void *)mod->name, mod);
+                                       count++;
+                               } else {
+                                       zap_log(ZAP_LOG_ERROR, "Unloading %s\n", path);
+                                       zap_dso_destroy(&lib);
+                               }
+                       }
+               }
+       }
+                       
+       return count;
+}
+
+zap_status_t zap_unload_modules(void)
+{
+       zap_hash_iterator_t *i;
+       zap_dso_lib_t lib;
+
+       for (i = hashtable_first(globals.module_hash); i; i = hashtable_next(i)) {
+               const void *key;
+               void *val;
+
+               hashtable_this(i, &key, NULL, &val);
+               
+               if (key && val) {
+                       zap_module_t *mod = (zap_module_t *) val;
+
+                       if (!mod) {
+                               continue;
+                       }
+
+                       if (mod->io_unload) {
+                               if (mod->io_unload() == ZAP_SUCCESS) {
+                                       zap_log(ZAP_LOG_INFO, "Unloading IO %s\n", mod->name);
+                               } else {
+                                       zap_log(ZAP_LOG_ERROR, "Error unloading IO %s\n", mod->name);
+                               }
+                       } 
+
+                       if (mod->sig_unload) {
+                               if (mod->sig_unload() == ZAP_SUCCESS) {
+                                       zap_log(ZAP_LOG_INFO, "Unloading SIG %s\n", mod->name);
+                               } else {
+                                       zap_log(ZAP_LOG_ERROR, "Error unloading SIG %s\n", mod->name);
+                               }
+                       } 
+                       
+
+                       zap_log(ZAP_LOG_INFO, "Unloading %s\n", mod->path);
+                       lib = mod->lib;
+                       zap_dso_destroy(&lib);
+                       
+               }
+       }
+
+       return ZAP_SUCCESS;
+}
+
+zap_status_t zap_configure_span(const char *type, zap_span_t *span, zio_signal_cb_t sig_cb, ...)
+{
+       zap_module_t *mod = (zap_module_t *) hashtable_search(globals.module_hash, (void *)type);
+       zap_status_t status = ZAP_FAIL;
+
+       if (mod && mod->sig_configure) {
+               va_list ap;
+               va_start(ap, sig_cb);
+               status = mod->sig_configure(span, sig_cb, ap);
+               va_end(ap);
+       }
+       return status;
+}
+
+zap_status_t zap_span_start(zap_span_t *span)
+{
+       if (span->start) {
+               return span->start(span);
+       }
+
+       return ZAP_FAIL;
+}
+
+
 zap_status_t zap_global_init(void)
 {
        int modcount;
@@ -2111,50 +2269,17 @@ zap_status_t zap_global_init(void)
        memset(&globals, 0, sizeof(globals));
 
        time_init();
-       zap_isdn_init();
-       zap_ss7_boost_init();
+       //zap_isdn_init();
+       //zap_ss7_boost_init();
        
        memset(&interfaces, 0, sizeof(interfaces));
        globals.interface_hash = create_hashtable(16, zap_hash_hashfromstring, zap_hash_equalkeys);
+       globals.module_hash = create_hashtable(16, zap_hash_hashfromstring, zap_hash_equalkeys);
        modcount = 0;
        zap_mutex_create(&globals.mutex);
        
-#ifdef ZAP_WANPIPE_SUPPORT
-       if (wanpipe_init(&interfaces.wanpipe_interface) == ZAP_SUCCESS) {
-               zap_mutex_lock(globals.mutex);
-               hashtable_insert(globals.interface_hash, (void *)interfaces.wanpipe_interface->name, interfaces.wanpipe_interface);
-               process_module_config(interfaces.wanpipe_interface);
-               zap_mutex_unlock(globals.mutex);
-               modcount++;
-       } else {
-               zap_log(ZAP_LOG_ERROR, "Error initilizing wanpipe.\n"); 
-       }
-#endif
-
-#ifdef ZAP_ZT_SUPPORT
-       if (zt_init(&interfaces.zt_interface) == ZAP_SUCCESS) {
-               zap_mutex_lock(globals.mutex);
-               hashtable_insert(globals.interface_hash, (void *)interfaces.zt_interface->name, interfaces.zt_interface);
-               process_module_config(interfaces.zt_interface);
-               zap_mutex_unlock(globals.mutex);
-               modcount++;
-       } else {
-               zap_log(ZAP_LOG_ERROR, "Error initilizing zt.\n");      
-       }
-#endif
-
-#ifdef ZAP_PIKA_SUPPORT
-    if (pika_init(&interfaces.pika_interface) == ZAP_SUCCESS) {
-        zap_mutex_lock(globals.mutex);
-        hashtable_insert(globals.interface_hash, (void *)interfaces.pika_interface->name, interfaces.pika_interface);
-        process_module_config(interfaces.pika_interface);
-        zap_mutex_unlock(globals.mutex);
-        modcount++;
-    } else {
-        zap_log(ZAP_LOG_ERROR, "Error initilizing pika.\n");
-    }
-#endif
 
+       modcount = zap_load_modules();
 
        if (!modcount) {
                zap_log(ZAP_LOG_ERROR, "Error initilizing anything.\n");        
@@ -2209,27 +2334,11 @@ zap_status_t zap_global_destroy(void)
                }
        }
 
-
-#ifdef ZAP_ZT_SUPPORT
-       if (interfaces.zt_interface) {
-               zt_destroy();           
-       }
-#endif
-
-#ifdef ZAP_PIKA_SUPPORT
-       if (interfaces.pika_interface) {
-               pika_destroy();         
-       }
-#endif
-
-#ifdef ZAP_WANPIPE_SUPPORT
-       if (interfaces.wanpipe_interface) {
-               wanpipe_destroy();
-       }
-#endif
+       zap_unload_modules();
 
        zap_mutex_lock(globals.mutex);
        hashtable_destroy(globals.interface_hash, 0, 0);
+       hashtable_destroy(globals.module_hash, 0, 0);
        zap_mutex_unlock(globals.mutex);
        zap_mutex_destroy(&globals.mutex);
 
@@ -2409,7 +2518,6 @@ void print_bits(uint8_t *b, int bl, char *buf, int blen, zap_endian_t e, uint8_t
 
 }
 
-
 /* For Emacs:
  * Local Variables:
  * mode:c