diff --git a/libs/openzap/conf/openzap.conf.xml b/libs/openzap/conf/openzap.conf.xml
index 1ca75c0e21..8326505177 100644
--- a/libs/openzap/conf/openzap.conf.xml
+++ b/libs/openzap/conf/openzap.conf.xml
@@ -16,6 +16,7 @@
+
diff --git a/libs/openzap/mod_openzap/mod_openzap.c b/libs/openzap/mod_openzap/mod_openzap.c
index 2aaa3296cf..18064e6486 100644
--- a/libs/openzap/mod_openzap/mod_openzap.c
+++ b/libs/openzap/mod_openzap/mod_openzap.c
@@ -1547,6 +1547,8 @@ static switch_status_t load_config(void)
char *dial_regex = NULL;
char *hold_music = NULL;
char *fail_dial_regex = NULL;
+ char *enable_callerid = "true";
+
uint32_t span_id = 0, to = 0, max = 0;
zap_span_t *span = NULL;
analog_option_t analog_options = ANALOG_OPTION_NONE;
@@ -1565,6 +1567,8 @@ static switch_status_t load_config(void)
dialplan = val;
} else if (!strcasecmp(var, "dial-regex")) {
dial_regex = val;
+ } else if (!strcasecmp(var, "enable-callerid")) {
+ enable_callerid = val;
} else if (!strcasecmp(var, "fail-dial-regex")) {
fail_dial_regex = val;
} else if (!strcasecmp(var, "hold-music")) {
@@ -1621,6 +1625,7 @@ static switch_status_t load_config(void)
"tonemap", tonegroup,
"digit_timeout", &to,
"max_dialstr", &max,
+ "enable_callerid", enable_callerid,
TAG_END) != ZAP_SUCCESS) {
zap_log(ZAP_LOG_ERROR, "Error starting OpenZAP span %d\n", span_id);
continue;
diff --git a/libs/openzap/src/include/openzap.h b/libs/openzap/src/include/openzap.h
index 0cdb98f834..4b705b0b74 100644
--- a/libs/openzap/src/include/openzap.h
+++ b/libs/openzap/src/include/openzap.h
@@ -458,13 +458,6 @@ struct zap_sigmsg {
};
-struct zap_analog_data {
- uint32_t flags;
- uint32_t max_dialstr;
- uint32_t digit_timeout;
- zio_signal_cb_t sig_cb;
-};
-
struct zap_span {
zap_data_type_t data_type;
char *name;
diff --git a/libs/openzap/src/ozmod/ozmod_analog/ozmod_analog.c b/libs/openzap/src/ozmod/ozmod_analog/ozmod_analog.c
index d1a6e31543..d6e2f5bb35 100644
--- a/libs/openzap/src/ozmod/ozmod_analog/ozmod_analog.c
+++ b/libs/openzap/src/ozmod/ozmod_analog/ozmod_analog.c
@@ -87,6 +87,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_analog_configure_span)
uint32_t max_dialstr = 11;
const char *var, *val;
int *intval;
+ uint32_t flags = ZAP_ANALOG_CALLERID;
assert(sig_cb != NULL);
@@ -110,6 +111,16 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_analog_configure_span)
break;
}
digit_timeout = *intval;
+ } else if (!strcasecmp(var, "enable_callerid")) {
+ if (!(val = va_arg(ap, char *))) {
+ break;
+ }
+
+ if (zap_true(val)) {
+ flags |= ZAP_ANALOG_CALLERID;
+ } else {
+ flags &= ~ZAP_ANALOG_CALLERID;
+ }
} else if (!strcasecmp(var, "max_dialstr")) {
if (!(intval = va_arg(ap, int *))) {
break;
@@ -128,6 +139,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_analog_configure_span)
}
span->start = zap_analog_start;
+ analog_data->flags = flags;
analog_data->digit_timeout = digit_timeout;
analog_data->max_dialstr = max_dialstr;
analog_data->sig_cb = sig_cb;
@@ -691,9 +703,12 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
zap_buffer_destroy(&dt_buffer);
}
- zap_clear_flag(closed_chan, ZAP_CHANNEL_INTHREAD);
+ if (zchan->state != ZAP_CHANNEL_STATE_DOWN) {
+ zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN);
+ }
- zap_log(ZAP_LOG_DEBUG, "ANALOG CHANNEL thread ended.\n");
+ zap_log(ZAP_LOG_DEBUG, "ANALOG CHANNEL %d:%d thread ended.\n", zchan->span_id, zchan->chan_id);
+ zap_clear_flag(closed_chan, ZAP_CHANNEL_INTHREAD);
return NULL;
}
@@ -725,7 +740,11 @@ static __inline__ zap_status_t process_event(zap_span_t *span, zap_event_t *even
goto end;
}
if (!event->channel->ring_count && (event->channel->state == ZAP_CHANNEL_STATE_DOWN && !zap_test_flag(event->channel, ZAP_CHANNEL_INTHREAD))) {
- zap_set_state_locked(event->channel, ZAP_CHANNEL_STATE_GET_CALLERID);
+ if (zap_test_flag(analog_data, ZAP_ANALOG_CALLERID)) {
+ zap_set_state_locked(event->channel, ZAP_CHANNEL_STATE_GET_CALLERID);
+ } else {
+ zap_set_state_locked(event->channel, ZAP_CHANNEL_STATE_IDLE);
+ }
event->channel->ring_count = 1;
zap_mutex_unlock(event->channel->mutex);
locked = 0;
diff --git a/libs/openzap/src/ozmod/ozmod_analog/zap_analog.h b/libs/openzap/src/ozmod/ozmod_analog/zap_analog.h
index 2d90910244..16b7d4f09a 100644
--- a/libs/openzap/src/ozmod/ozmod_analog/zap_analog.h
+++ b/libs/openzap/src/ozmod/ozmod_analog/zap_analog.h
@@ -36,9 +36,20 @@
#include "openzap.h"
typedef enum {
- ZAP_ANALOG_RUNNING = (1 << 0)
+ ZAP_ANALOG_RUNNING = (1 << 0),
+ ZAP_ANALOG_CALLERID = (1 << 1)
} zap_analog_flag_t;
+
+struct zap_analog_data {
+ uint32_t flags;
+ uint32_t max_dialstr;
+ uint32_t digit_timeout;
+ zio_signal_cb_t sig_cb;
+};
+
+
+
static void *zap_analog_run(zap_thread_t *me, void *obj);
typedef struct zap_analog_data zap_analog_data_t;
diff --git a/libs/openzap/src/ozmod/ozmod_analog_em/zap_analog_em.h b/libs/openzap/src/ozmod/ozmod_analog_em/zap_analog_em.h
index e20875d54c..9411844c44 100644
--- a/libs/openzap/src/ozmod/ozmod_analog_em/zap_analog_em.h
+++ b/libs/openzap/src/ozmod/ozmod_analog_em/zap_analog_em.h
@@ -44,6 +44,14 @@ typedef enum {
ZAP_ANALOG_EM_RUNNING = (1 << 0)
} zap_analog_em_flag_t;
+
+struct zap_analog_data {
+ uint32_t flags;
+ uint32_t max_dialstr;
+ uint32_t digit_timeout;
+ zio_signal_cb_t sig_cb;
+};
+
static void *zap_analog_em_run(zap_thread_t *me, void *obj);
typedef struct zap_analog_data zap_analog_em_data_t;