提交 b485f25f authored 作者: Moises Silva's avatar Moises Silva

freetdm: add PRI tapping starting code

上级 fd254766
...@@ -172,6 +172,10 @@ if LIBPRI ...@@ -172,6 +172,10 @@ if LIBPRI
mod_LTLIBRARIES += ftmod_libpri.la mod_LTLIBRARIES += ftmod_libpri.la
endif endif
if PRITAP
mod_LTLIBRARIES += ftmod_pritap.la
endif
if SNGSS7 if SNGSS7
mod_LTLIBRARIES += ftmod_sangoma_ss7.la mod_LTLIBRARIES += ftmod_sangoma_ss7.la
endif endif
...@@ -252,6 +256,13 @@ ftmod_libpri_la_LDFLAGS = -module -avoid-version -lpri ...@@ -252,6 +256,13 @@ ftmod_libpri_la_LDFLAGS = -module -avoid-version -lpri
ftmod_libpri_la_LIBADD = $(MYLIB) ftmod_libpri_la_LIBADD = $(MYLIB)
endif endif
if PRITAP
ftmod_pritap_la_SOURCES = $(SRC)/ftmod/ftmod_pritap/ftmod_pritap.c
ftmod_pritap_la_CFLAGS = $(AM_CFLAGS) $(MY_CFLAGS)
ftmod_pritap_la_LDFLAGS = -module -avoid-version -lpri
ftmod_pritap_la_LIBADD = $(MYLIB)
endif
if SNGSS7 if SNGSS7
ftmod_sangoma_ss7_la_SOURCES = $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c \ ftmod_sangoma_ss7_la_SOURCES = $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c \
$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c \ $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c \
......
...@@ -165,6 +165,11 @@ AC_ARG_WITH([libpri], ...@@ -165,6 +165,11 @@ AC_ARG_WITH([libpri],
[AS_HELP_STRING([--with-libpri], [Install ftmod_libpri])], [enable_libpri="yes"], [enable_libpri="no"]) [AS_HELP_STRING([--with-libpri], [Install ftmod_libpri])], [enable_libpri="yes"], [enable_libpri="no"])
AC_SUBST(enable_libpri) AC_SUBST(enable_libpri)
# pritap?
AC_ARG_WITH([pritap],
[AS_HELP_STRING([--with-pritap], [Install ftmod_pritap])], [enable_pritap="yes"], [enable_pritap="no"])
AC_SUBST(enable_pritap)
# debug dtmf? # debug dtmf?
AC_ARG_WITH([debugdtmf], AC_ARG_WITH([debugdtmf],
[AS_HELP_STRING([--with-debugdtmf], [Debug DTMF])], [enable_debugdtmf="yes"], [enable_debugdtmf="no"]) [AS_HELP_STRING([--with-debugdtmf], [Debug DTMF])], [enable_debugdtmf="yes"], [enable_debugdtmf="no"])
...@@ -175,6 +180,8 @@ AM_CONDITIONAL([LIBSANGOMA],[test "${have_libsangoma}" = "yes"]) ...@@ -175,6 +180,8 @@ AM_CONDITIONAL([LIBSANGOMA],[test "${have_libsangoma}" = "yes"])
AM_CONDITIONAL([LIBPRI],[test "${enable_libpri}" = "yes"]) AM_CONDITIONAL([LIBPRI],[test "${enable_libpri}" = "yes"])
AM_CONDITIONAL([PRITAP],[test "${enable_pritap}" = "yes"])
AM_CONDITIONAL([DEBUGDTMF],[test "${enable_debugdtmf}" = "yes"]) AM_CONDITIONAL([DEBUGDTMF],[test "${enable_debugdtmf}" = "yes"])
AC_CHECK_LIB([sng_ss7], [sng_isup_init], [have_sng_ss7="yes"]) AC_CHECK_LIB([sng_ss7], [sng_isup_init], [have_sng_ss7="yes"])
......
...@@ -2938,6 +2938,59 @@ static switch_status_t load_config(void) ...@@ -2938,6 +2938,59 @@ static switch_status_t load_config(void)
} }
} }
if ((spans = switch_xml_child(cfg, "pritap_spans"))) {
for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) {
char *name = (char *) switch_xml_attr(myspan, "name");
ftdm_status_t zstatus = FTDM_FAIL;
unsigned paramindex = 0;
ftdm_conf_parameter_t spanparameters[10];
const char *context = "default";
const char *dialplan = "XML";
ftdm_span_t *span = NULL;
int span_id = 0;
if (!name) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "span missing required attribute 'name'\n");
continue;
}
for (param = switch_xml_child(myspan, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
if (!strcasecmp(var, "context")) {
context = val;
} else if (!strcasecmp(var, "dialplan")) {
dialplan = val;
} else {
spanparameters[paramindex].var = var;
spanparameters[paramindex].val = val;
paramindex++;
}
}
zstatus = ftdm_span_find_by_name(name, &span);
if (zstatus != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "Error finding FreeTDM span %s\n", name);
continue;
}
span_id = ftdm_span_get_id(span);
if (ftdm_configure_span_signaling(span, "pritap", on_clear_channel_signal, spanparameters) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "Error configuring FreeTDM span %s\n", name);
continue;
}
SPAN_CONFIG[span_id].span = span;
switch_copy_string(SPAN_CONFIG[span_id].context, context, sizeof(SPAN_CONFIG[span_id].context));
switch_copy_string(SPAN_CONFIG[span_id].dialplan, dialplan, sizeof(SPAN_CONFIG[span_id].dialplan));
switch_copy_string(SPAN_CONFIG[span_id].type, "isdn", sizeof(SPAN_CONFIG[span_id].type));
ftdm_span_start(span);
}
}
if ((spans = switch_xml_child(cfg, "libpri_spans"))) { if ((spans = switch_xml_child(cfg, "libpri_spans"))) {
......
...@@ -1334,21 +1334,28 @@ static __inline__ int chan_is_avail(ftdm_channel_t *check) ...@@ -1334,21 +1334,28 @@ static __inline__ int chan_is_avail(ftdm_channel_t *check)
ftdm_test_flag(check, FTDM_CHANNEL_INUSE) || ftdm_test_flag(check, FTDM_CHANNEL_INUSE) ||
ftdm_test_flag(check, FTDM_CHANNEL_SUSPENDED) || ftdm_test_flag(check, FTDM_CHANNEL_SUSPENDED) ||
ftdm_test_flag(check, FTDM_CHANNEL_IN_ALARM) || ftdm_test_flag(check, FTDM_CHANNEL_IN_ALARM) ||
check->state != FTDM_CHANNEL_STATE_DOWN || check->state != FTDM_CHANNEL_STATE_DOWN) {
!FTDM_IS_VOICE_CHANNEL(check)) {
return 0; return 0;
} }
return 1; return 1;
} }
static __inline__ int request_channel(ftdm_channel_t *check, ftdm_channel_t **ftdmchan, static __inline__ int chan_voice_is_avail(ftdm_channel_t *check)
{
if (!FTDM_IS_VOICE_CHANNEL(check)) {
return 0;
}
return chan_is_avail(check);
}
static __inline__ int request_voice_channel(ftdm_channel_t *check, ftdm_channel_t **ftdmchan,
ftdm_caller_data_t *caller_data, ftdm_direction_t direction) ftdm_caller_data_t *caller_data, ftdm_direction_t direction)
{ {
ftdm_status_t status; ftdm_status_t status;
if (chan_is_avail(check)) { if (chan_voice_is_avail(check)) {
/* unlocked testing passed, try again with the channel locked */ /* unlocked testing passed, try again with the channel locked */
ftdm_mutex_lock(check->mutex); ftdm_mutex_lock(check->mutex);
if (chan_is_avail(check)) { if (chan_voice_is_avail(check)) {
if (check->span && check->span->channel_request) { if (check->span && check->span->channel_request) {
/* I am only unlocking here cuz this function is called /* I am only unlocking here cuz this function is called
* sometimes with the group or span lock held and were * sometimes with the group or span lock held and were
...@@ -1468,7 +1475,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_group(uint32_t group_id, ftdm_dir ...@@ -1468,7 +1475,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_group(uint32_t group_id, ftdm_dir
break; break;
} }
if (request_channel(check, ftdmchan, caller_data, direction)) { if (request_voice_channel(check, ftdmchan, caller_data, direction)) {
status = FTDM_SUCCESS; status = FTDM_SUCCESS;
break; break;
} }
...@@ -1579,7 +1586,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_span(uint32_t span_id, ftdm_direc ...@@ -1579,7 +1586,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_open_by_span(uint32_t span_id, ftdm_direc
break; break;
} }
if (request_channel(check, ftdmchan, caller_data, direction)) { if (request_voice_channel(check, ftdmchan, caller_data, direction)) {
status = FTDM_SUCCESS; status = FTDM_SUCCESS;
break; break;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论