Merge branch 'master' into smgmaster

Conflicts:
	build/modules.conf.in
This commit is contained in:
Moises Silva committed 2011-06-16 13:43:37 -04:00
commit 2a9046fdb8
608 files changed
+33546 -20511

No files matched your search

+21 -21
View File
@@ -90,7 +90,7 @@ library_include_HEADERS = \
$(SRC)/include/ftdm_dso.h
lib_LTLIBRARIES = libfreetdm.la
libfreetdm_la_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
libfreetdm_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS)
libfreetdm_la_LDFLAGS = -version-info 1:0:0 $(AM_LDFLAGS)
libfreetdm_la_LIBADD = $(LIBS)
@@ -104,39 +104,39 @@ noinst_PROGRAMS = testtones detect_tones detect_dtmf testpri testr2 testanalog
testapp_SOURCES = $(SRC)/testapp.c
testapp_LDADD = libfreetdm.la
testapp_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
testapp_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS)
testcid_SOURCES = $(SRC)/testcid.c
testcid_LDADD = libfreetdm.la
testcid_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
testcid_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS)
testtones_SOURCES = $(SRC)/testtones.c
testtones_LDADD = libfreetdm.la
testtones_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
testtones_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS)
detect_tones_SOURCES = $(SRC)/detect_tones.c
detect_tones_LDADD = libfreetdm.la
detect_tones_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
detect_tones_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS)
detect_dtmf_SOURCES = $(SRC)/detect_dtmf.c
detect_dtmf_LDADD = libfreetdm.la
detect_dtmf_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
detect_dtmf_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS)
#testisdn_SOURCES = $(SRC)/testisdn.c
#testisdn_LDADD = libfreetdm.la
#testisdn_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
#testisdn_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS)
testpri_SOURCES = $(SRC)/testpri.c
testpri_LDADD = libfreetdm.la
testpri_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
testpri_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS)
testr2_SOURCES = $(SRC)/testr2.c
testr2_LDADD = libfreetdm.la
testr2_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
testr2_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS)
testanalog_SOURCES = $(SRC)/testanalog.c
testanalog_LDADD = libfreetdm.la
testanalog_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
testanalog_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS)
#
# ftmod modules
@@ -144,22 +144,22 @@ testanalog_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
mod_LTLIBRARIES = ftmod_zt.la ftmod_skel.la ftmod_analog.la ftmod_analog_em.la
ftmod_zt_la_SOURCES = $(SRC)/ftmod/ftmod_zt/ftmod_zt.c
ftmod_zt_la_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
ftmod_zt_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS)
ftmod_zt_la_LDFLAGS = -shared -module -avoid-version
ftmod_zt_la_LIBADD = libfreetdm.la
ftmod_skel_la_SOURCES = $(SRC)/ftmod/ftmod_skel/ftmod_skel.c
ftmod_skel_la_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
ftmod_skel_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS)
ftmod_skel_la_LDFLAGS = -module -avoid-version
ftmod_skel_la_LIBADD = libfreetdm.la
ftmod_analog_la_SOURCES = $(SRC)/ftmod/ftmod_analog/ftmod_analog.c
ftmod_analog_la_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
ftmod_analog_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS)
ftmod_analog_la_LDFLAGS = -shared -module -avoid-version
ftmod_analog_la_LIBADD = libfreetdm.la
ftmod_analog_em_la_SOURCES = $(SRC)/ftmod/ftmod_analog_em/ftmod_analog_em.c
ftmod_analog_em_la_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
ftmod_analog_em_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS)
ftmod_analog_em_la_LDFLAGS = -shared -module -avoid-version
ftmod_analog_em_la_LIBADD = libfreetdm.la
@@ -168,7 +168,7 @@ mod_LTLIBRARIES += ftmod_wanpipe.la
ftmod_wanpipe_la_SOURCES = $(SRC)/ftmod/ftmod_wanpipe/ftmod_wanpipe.c
# some structures within Wanpipe drivers are not c99 compatible, so we need to compile ftmod_wanpipe
# without c99 flags, use FTDM_COMPAT_CFLAGS instead
ftmod_wanpipe_la_CFLAGS = $(AM_CFLAGS) $(FTDM_COMPAT_CFLAGS) -D__LINUX__ -I/usr/include/wanpipe
ftmod_wanpipe_la_CFLAGS = $(FTDM_COMPAT_CFLAGS) $(AM_CFLAGS) -D__LINUX__ -I/usr/include/wanpipe
ftmod_wanpipe_la_LDFLAGS = -shared -module -avoid-version -lsangoma
ftmod_wanpipe_la_LIBADD = libfreetdm.la
endif
@@ -176,7 +176,7 @@ endif
if HAVE_LIBISDN
mod_LTLIBRARIES += ftmod_isdn.la
ftmod_isdn_la_SOURCES = $(SRC)/ftmod/ftmod_isdn/ftmod_isdn.c
ftmod_isdn_la_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS) -D_GNU_SOURCE $(LIBISDN_CPPFLAGS) $(PCAP_CPPFLAGS)
ftmod_isdn_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) -D_GNU_SOURCE $(LIBISDN_CPPFLAGS) $(PCAP_CPPFLAGS)
ftmod_isdn_la_LDFLAGS = -shared -module -avoid-version $(LIBISDN_LDFLAGS) $(PCAP_LDFLAGS)
ftmod_isdn_la_LIBADD = libfreetdm.la $(LIBISDN_LIBS) $(PCAP_LIBS)
endif
@@ -184,7 +184,7 @@ endif
if HAVE_LIBPRI
mod_LTLIBRARIES += ftmod_libpri.la
ftmod_libpri_la_SOURCES = $(SRC)/ftmod/ftmod_libpri/ftmod_libpri.c $(SRC)/ftmod/ftmod_libpri/lpwrap_pri.c
ftmod_libpri_la_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
ftmod_libpri_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS)
ftmod_libpri_la_LDFLAGS = -shared -module -avoid-version -lpri
ftmod_libpri_la_LIBADD = libfreetdm.la
endif
@@ -192,7 +192,7 @@ endif
if HAVE_PRITAP
mod_LTLIBRARIES += ftmod_pritap.la
ftmod_pritap_la_SOURCES = $(SRC)/ftmod/ftmod_pritap/ftmod_pritap.c
ftmod_pritap_la_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
ftmod_pritap_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS)
ftmod_pritap_la_LDFLAGS = -shared -module -avoid-version -lpri
ftmod_pritap_la_LIBADD = libfreetdm.la
endif
@@ -215,7 +215,7 @@ ftmod_sangoma_ss7_la_SOURCES = \
$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c \
$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c
ftmod_sangoma_ss7_la_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS) -D_GNU_SOURCE
ftmod_sangoma_ss7_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) -D_GNU_SOURCE
ftmod_sangoma_ss7_la_LDFLAGS = -shared -module -avoid-version -lsng_ss7
ftmod_sangoma_ss7_la_LIBADD = libfreetdm.la
endif
@@ -235,7 +235,7 @@ ftmod_sangoma_isdn_la_SOURCES = \
$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c \
$(SRC)/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c
ftmod_sangoma_isdn_la_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS) -D_GNU_SOURCE
ftmod_sangoma_isdn_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS) -D_GNU_SOURCE
ftmod_sangoma_isdn_la_LDFLAGS = -shared -module -avoid-version -lsng_isdn
ftmod_sangoma_isdn_la_LIBADD = libfreetdm.la
endif
@@ -243,7 +243,7 @@ endif
if HAVE_OPENR2
mod_LTLIBRARIES += ftmod_r2.la
ftmod_r2_la_SOURCES = $(SRC)/ftmod/ftmod_r2/ftmod_r2.c $(SRC)/ftmod/ftmod_r2/ftmod_r2_io_mf_lib.c
ftmod_r2_la_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
ftmod_r2_la_CFLAGS = $(FTDM_CFLAGS) $(AM_CFLAGS)
ftmod_r2_la_LDFLAGS = -shared -module -avoid-version -lopenr2
ftmod_r2_la_LIBADD = libfreetdm.la
endif
+61 -37
View File
@@ -42,6 +42,9 @@
#define FREETDM_VAR_PREFIX "freetdm_"
#define FREETDM_VAR_PREFIX_LEN (sizeof(FREETDM_VAR_PREFIX)-1)
/* How many consecutive IO errors before giving up */
#define FTDM_MAX_READ_WRITE_ERRORS 10
SWITCH_MODULE_LOAD_FUNCTION(mod_freetdm_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_freetdm_shutdown);
SWITCH_MODULE_DEFINITION(mod_freetdm, mod_freetdm_load, mod_freetdm_shutdown, NULL);
@@ -110,7 +113,8 @@ struct private_object {
switch_mutex_t *mutex;
switch_mutex_t *flag_mutex;
ftdm_channel_t *ftdmchan;
uint32_t wr_error;
uint32_t write_error;
uint32_t read_error;
};
/* private data attached to FTDM channels (only FXS for now) */
@@ -624,12 +628,11 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
ftdm_status_t status;
int total_to;
int chunk, do_break = 0;
uint32_t span_id, chan_id;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
@@ -638,6 +641,13 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
return SWITCH_STATUS_FALSE;
}
if (!tech_pvt->ftdmchan) {
return SWITCH_STATUS_FALSE;
}
span_id = ftdm_channel_get_span_id(tech_pvt->ftdmchan);
chan_id = ftdm_channel_get_id(tech_pvt->ftdmchan);
/* Digium Cards sometimes timeout several times in a row here.
Yes, we support digium cards, ain't we nice.......
6 double length intervals should compensate */
@@ -697,8 +707,13 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
len = tech_pvt->read_frame.buflen;
if (ftdm_channel_read(tech_pvt->ftdmchan, tech_pvt->read_frame.data, &len) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_WARNING, "failed to read from device\n");
goto fail;
ftdm_log(FTDM_LOG_WARNING, "failed to read from device %d:%d\n", span_id, chan_id);
if (++tech_pvt->read_error > FTDM_MAX_READ_WRITE_ERRORS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "too many I/O read errors on device %d:%d!\n", span_id, chan_id);
goto fail;
}
} else {
tech_pvt->read_error = 0;
}
*frame = &tech_pvt->read_frame;
@@ -736,6 +751,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
ftdm_size_t len;
unsigned char data[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0};
ftdm_wait_flag_t wflags = FTDM_WRITE;
uint32_t span_id, chan_id;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -743,10 +759,6 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
if (!tech_pvt->ftdmchan) {
return SWITCH_STATUS_FALSE;
}
if (switch_test_flag(tech_pvt, TFLAG_DEAD)) {
return SWITCH_STATUS_FALSE;
}
@@ -758,6 +770,14 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
goto fail;
}
if (!tech_pvt->ftdmchan) {
return SWITCH_STATUS_FALSE;
}
span_id = ftdm_channel_get_span_id(tech_pvt->ftdmchan);
chan_id = ftdm_channel_get_id(tech_pvt->ftdmchan);
if (switch_test_flag(frame, SFF_CNG)) {
frame->data = data;
@@ -779,12 +799,14 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
len = frame->datalen;
if (ftdm_channel_write(tech_pvt->ftdmchan, frame->data, frame->buflen, &len) != FTDM_SUCCESS) {
if (++tech_pvt->wr_error > 10) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "too many I/O write errors!\n");
ftdm_log(FTDM_LOG_WARNING, "failed to write to device %d:%d\n", span_id, chan_id);
if (++tech_pvt->write_error > FTDM_MAX_READ_WRITE_ERRORS) {
switch_log_printf(SWITCH_CHANNEL_LOG,
SWITCH_LOG_ERROR, "too many I/O write errors on device %d:%d!\n", span_id, chan_id);
goto fail;
}
} else {
tech_pvt->wr_error = 0;
tech_pvt->write_error = 0;
}
return SWITCH_STATUS_SUCCESS;
@@ -1855,29 +1877,31 @@ static FIO_SIGNAL_CB_FUNCTION(on_common_signal)
break;
}
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "span-name", "%s", ftdm_channel_get_span_name(sigmsg->channel));
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "span-number", "%d", ftdm_channel_get_span_id(sigmsg->channel));
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "chan-number", "%d", ftdm_channel_get_id(sigmsg->channel));
if (event) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "span-name", "%s", ftdm_channel_get_span_name(sigmsg->channel));
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "span-number", "%d", ftdm_channel_get_span_id(sigmsg->channel));
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "chan-number", "%d", ftdm_channel_get_id(sigmsg->channel));
if (alarmbits & FTDM_ALARM_RED) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "red");
if (alarmbits & FTDM_ALARM_RED) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "red");
}
if (alarmbits & FTDM_ALARM_YELLOW) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "yellow");
}
if (alarmbits & FTDM_ALARM_RAI) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "rai");
}
if (alarmbits & FTDM_ALARM_BLUE) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "blue");
}
if (alarmbits & FTDM_ALARM_AIS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "ais");
}
if (alarmbits & FTDM_ALARM_GENERAL) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "general");
}
switch_event_fire(&event);
}
if (alarmbits & FTDM_ALARM_YELLOW) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "yellow");
}
if (alarmbits & FTDM_ALARM_RAI) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "rai");
}
if (alarmbits & FTDM_ALARM_BLUE) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "blue");
}
if (alarmbits & FTDM_ALARM_AIS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "ais");
}
if (alarmbits & FTDM_ALARM_GENERAL) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alarm", "general");
}
switch_event_fire(&event);
return FTDM_BREAK;
}
@@ -2483,10 +2507,10 @@ static uint32_t enable_analog_option(const char *str, uint32_t current_options)
}
#define CONFIG_ERROR(...) do { \
#define CONFIG_ERROR(...) { \
ftdm_log(FTDM_LOG_ERROR, __VA_ARGS__); \
globals.config_error = 1; \
} while(0)
}
/* create ftdm_conf_node_t tree based on a fixed pattern XML configuration list
* last 2 args are for limited aka dumb recursivity
* */
@@ -2871,9 +2895,9 @@ static switch_status_t load_config(void)
} else if (!strcasecmp(var, "hold-music")) {
switch_set_string(globals.hold_music, val);
} else if (!strcasecmp(var, "crash-on-assert")) {
globals.crash_on_assert = switch_true(val);
globals.crash_on_assert = (uint8_t)switch_true(val);
} else if (!strcasecmp(var, "fail-on-error")) {
globals.fail_on_error = switch_true(val);
globals.fail_on_error = (uint8_t)switch_true(val);
} else if (!strcasecmp(var, "sip-headers")) {
globals.sip_headers = switch_true(val);
} else if (!strcasecmp(var, "enable-analog-option")) {
+12 -6
View File
@@ -1549,6 +1549,7 @@ static ftdm_status_t _ftdm_channel_open_by_group(uint32_t group_id, ftdm_directi
int best_rate = 0;
uint32_t i = 0;
uint32_t count = 0;
uint32_t first_channel = 0;
if (group_id) {
ftdm_group_find(group_id, &group);
@@ -1573,6 +1574,7 @@ static ftdm_status_t _ftdm_channel_open_by_group(uint32_t group_id, ftdm_directi
i = 0;
} else if (direction == FTDM_RR_DOWN || direction == FTDM_RR_UP) {
i = rr_next(group->last_used_index, 0, group->chan_count - 1, direction);
first_channel = i;
} else {
i = group->chan_count-1;
}
@@ -1605,6 +1607,9 @@ static ftdm_status_t _ftdm_channel_open_by_group(uint32_t group_id, ftdm_directi
group->last_used_index = i;
}
i = rr_next(i, 0, group->chan_count - 1, direction);
if (first_channel == i) {
break;
}
} else {
if (i == 0) {
break;
@@ -1663,6 +1668,7 @@ static ftdm_status_t _ftdm_channel_open_by_span(uint32_t span_id, ftdm_direction
int best_rate = 0;
uint32_t i = 0;
uint32_t count = 0;
uint32_t first_channel = 0;
*ftdmchan = NULL;
@@ -1696,6 +1702,7 @@ static ftdm_status_t _ftdm_channel_open_by_span(uint32_t span_id, ftdm_direction
i = 1;
} else if (direction == FTDM_RR_DOWN || direction == FTDM_RR_UP) {
i = rr_next(span->last_used_index, 1, span->chan_count, direction);
first_channel = i;
} else {
i = span->chan_count;
}
@@ -1706,10 +1713,6 @@ static ftdm_status_t _ftdm_channel_open_by_span(uint32_t span_id, ftdm_direction
if (i > span->chan_count) {
break;
}
} else if (direction == FTDM_RR_DOWN || direction == FTDM_RR_UP) {
if (i == span->last_used_index) {
break;
}
} else {
if (i == 0) {
break;
@@ -1738,6 +1741,9 @@ static ftdm_status_t _ftdm_channel_open_by_span(uint32_t span_id, ftdm_direction
span->last_used_index = i;
}
i = rr_next(i, 1, span->chan_count, direction);
if (first_channel == i) {
break;
}
} else {
i--;
}
@@ -3583,7 +3589,7 @@ skipdebug:
return status;
}
FIO_WRITE_FUNCTION(ftdm_raw_write)
FT_DECLARE(ftdm_status_t) ftdm_raw_write (ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen)
{
int dlen = (int) *datalen;
@@ -3610,7 +3616,7 @@ FIO_WRITE_FUNCTION(ftdm_raw_write)
return ftdmchan->fio->write(ftdmchan, data, datalen);
}
FIO_READ_FUNCTION(ftdm_raw_read)
FT_DECLARE(ftdm_status_t) ftdm_raw_read (ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen)
{
ftdm_status_t status;
@@ -1584,6 +1584,13 @@ static int on_dchan_down(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_
static int on_anything(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent)
{
ftdm_log(FTDM_LOG_DEBUG, "-- Caught Event span %d %u (%s)\n", ftdm_span_get_id(spri->span), event_type, lpwrap_pri_event_str(event_type));
switch (pevent->e) {
case PRI_EVENT_CONFIG_ERR:
{
ftdm_log(FTDM_LOG_WARNING, "-- PRI error event: %s\n", pevent->err.err);
}
break;
}
return 0;
}
@@ -436,6 +436,13 @@ static __inline openr2_calling_party_category_t ftdm_r2_ftdm_cpc_to_openr2_cpc(f
case FTDM_CPC_PAYPHONE:
return OR2_CALLING_PARTY_CATEGORY_PAY_PHONE;
case FTDM_CPC_OPERATOR_FRENCH:
case FTDM_CPC_OPERATOR_ENGLISH:
case FTDM_CPC_OPERATOR_GERMAN:
case FTDM_CPC_OPERATOR_RUSSIAN:
case FTDM_CPC_OPERATOR_SPANISH:
return OR2_CALLING_PARTY_CATEGORY_COLLECT_CALL;
case FTDM_CPC_INVALID:
return OR2_CALLING_PARTY_CATEGORY_UNKNOWN;
}
@@ -238,6 +238,10 @@
RelativePath=".\ftmod_sangoma_isdn_trace.c"
>
</File>
<File
RelativePath=".\ftmod_sangoma_isdn_transfer.c"
>
</File>
</Filter>
</Files>
<Globals>
@@ -189,6 +189,7 @@
<ClCompile Include="ftmod_sangoma_isdn_stack_rcv.c" />
<ClCompile Include="ftmod_sangoma_isdn_support.c" />
<ClCompile Include="ftmod_sangoma_isdn_trace.c" />
<ClCompile Include="ftmod_sangoma_isdn_transfer.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\msvc\freetdm.2010.vcxproj">
@@ -199,4 +200,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
@@ -47,7 +47,6 @@ static ftdm_status_t ftdm_sangoma_isdn_start(ftdm_span_t *span);
static ftdm_status_t ftdm_sangoma_isdn_dtmf(ftdm_channel_t *ftdmchan, const char* dtmf);
ftdm_channel_t* ftdm_sangoma_isdn_process_event_states(ftdm_span_t *span, sngisdn_event_data_t *sngisdn_event);
static void ftdm_sangoma_isdn_poll_events(ftdm_span_t *span);
static void ftdm_sangoma_isdn_process_phy_events(ftdm_span_t *span, ftdm_oob_event_t event);
static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan);
static void ftdm_sangoma_isdn_process_stack_event (ftdm_span_t *span, sngisdn_event_data_t *sngisdn_event);
@@ -59,8 +58,8 @@ static sng_isdn_event_interface_t g_sngisdn_event_interface;
ftdm_sngisdn_data_t g_sngisdn_data;
FTDM_ENUM_NAMES(SNGISDN_TRANSFER_TYPE_NAMES, SNGISDN_TRANSFER_TYPE_STRINGS)
FTDM_STR2ENUM(ftdm_str2sngisdn_transfer_type, sngisdn_transfer_type2str, sngisdn_transfer_type_t, SNGISDN_TRANSFER_TYPE_NAMES, SNGISDN_TRANSFER_INVALID)
SNGISDN_ENUM_NAMES(SNGISDN_TRANSFER_TYPE_NAMES, SNGISDN_TRANSFER_TYPE_STRINGS)
SNGISDN_STR2ENUM(ftdm_str2sngisdn_transfer_type, sngisdn_transfer_type2str, sngisdn_transfer_type_t, SNGISDN_TRANSFER_TYPE_NAMES, SNGISDN_TRANSFER_INVALID)
ftdm_state_map_t sangoma_isdn_state_map = {
{
@@ -313,28 +312,6 @@ static void ftdm_sangoma_isdn_process_phy_events(ftdm_span_t *span, ftdm_oob_eve
}
}
static void ftdm_sangoma_isdn_poll_events(ftdm_span_t *span)
{
ftdm_status_t ret_status;
ret_status = ftdm_span_poll_event(span, 0, NULL);
switch(ret_status) {
case FTDM_SUCCESS:
{
ftdm_event_t *event;
while (ftdm_span_next_event(span, &event) == FTDM_SUCCESS) {
ftdm_sangoma_isdn_process_phy_events(span, event->enum_id);
}
}
break;
case FTDM_TIMEOUT:
/* No events pending */
break;
default:
ftdm_log(FTDM_LOG_WARNING, "%s:Failed to poll span event\n", span->name);
}
}
static void ftdm_sangoma_isdn_dchan_set_queue_size(ftdm_channel_t *dchan)
{
ftdm_status_t ret_status;
@@ -365,7 +342,7 @@ static void ftdm_sangoma_isdn_wakeup_phy(ftdm_channel_t *dchan)
static void *ftdm_sangoma_isdn_io_run(ftdm_thread_t *me, void *obj)
{
uint8_t data[1000];
unsigned i;
unsigned i = 0;
ftdm_status_t status = FTDM_SUCCESS;
ftdm_wait_flag_t wflags = FTDM_READ;
ftdm_span_t *span = (ftdm_span_t*) obj;
@@ -374,6 +351,7 @@ static void *ftdm_sangoma_isdn_io_run(ftdm_thread_t *me, void *obj)
unsigned waitms = 10000;
ftdm_iterator_t *chaniter = NULL;
ftdm_iterator_t *citer = NULL;
ftdm_event_t *event;
short *poll_events = ftdm_malloc(sizeof(short) * span->chan_count);
/* Initialize the d-channel */
@@ -394,6 +372,8 @@ static void *ftdm_sangoma_isdn_io_run(ftdm_thread_t *me, void *obj)
wflags = FTDM_READ;
memset(poll_events, 0, sizeof(short)*span->chan_count);
poll_events[i] |= FTDM_EVENTS;
for (i = 0, citer = ftdm_span_get_chan_iterator(span, chaniter); citer; citer = ftdm_iterator_next(citer), i++) {
ftdmchan = ftdm_iterator_current(citer);
@@ -416,6 +396,7 @@ static void *ftdm_sangoma_isdn_io_run(ftdm_thread_t *me, void *obj)
case FTDM_TIMEOUT:
break;
case FTDM_SUCCESS:
/* Check if there are any channels that have data available */
for (citer = ftdm_span_get_chan_iterator(span, chaniter); citer; citer = ftdm_iterator_next(citer)) {
len = 1000;
ftdmchan = ftdm_iterator_current(citer);
@@ -444,6 +425,12 @@ static void *ftdm_sangoma_isdn_io_run(ftdm_thread_t *me, void *obj)
}
}
}
/* Check if there are any channels that have events available */
while (ftdm_span_next_event(span, &event) == FTDM_SUCCESS) {
ftdm_sangoma_isdn_process_phy_events(span, event->enum_id);
}
break;
default:
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "Unhandled IO event\n");
@@ -487,7 +474,6 @@ static void *ftdm_sangoma_isdn_run(ftdm_thread_t *me, void *obj)
}
while (ftdm_running() && !(ftdm_test_flag(span, FTDM_SPAN_STOP_THREAD))) {
/* Check if there are any timers to process */
ftdm_sched_run(signal_data->sched);
ftdm_span_trigger_signals(span);
@@ -525,9 +511,6 @@ static void *ftdm_sangoma_isdn_run(ftdm_thread_t *me, void *obj)
ftdm_log(FTDM_LOG_ERROR, "%s: ftdm_interrupt_wait returned with unknown code\n", span->name);
break;
}
/* Poll for events, e.g HW DTMF */
ftdm_sangoma_isdn_poll_events(span);
}
/* clear the IN_THREAD flag so that we know the thread is done */
@@ -177,7 +177,7 @@ typedef enum {
SNGISDN_TRANSFER_INVALID,
} sngisdn_transfer_type_t;
#define SNGISDN_TRANSFER_TYPE_STRINGS "NONE", "ATT_COURTESY_VRU", "ATT_COURTERY_VRU_DATA", "INVALID"
FTDM_STR2ENUM_P(ftdm_str2sngisdn_transfer_type, sngisdn_transfer_type2str, sngisdn_transfer_type_t)
SNGISDN_STR2ENUM_P(ftdm_str2sngisdn_transfer_type, sngisdn_transfer_type2str, sngisdn_transfer_type_t)
/* From section 4.2 of TR50075, max length of data is 100 when single UUI is sent */
#define COURTESY_TRANSFER_MAX_DATA_SIZE 100
@@ -251,7 +251,8 @@ typedef struct sngisdn_span_data {
uint8_t raw_trace_q931; /* TODO: combine with trace_flags */
uint8_t raw_trace_q921; /* TODO: combine with trace_flags */
uint8_t timer_t3;
uint8_t restart_opt;
uint8_t restart_opt;
uint8_t force_sending_complete;
char* local_numbers[SNGISDN_NUM_LOCAL_NUMBERS];
ftdm_sched_t *sched;
ftdm_queue_t *event_queue;
@@ -323,6 +324,11 @@ typedef struct ftdm_sngisdn_data {
uint8_t num_dchan;
sngisdn_dchan_data_t dchans[MAX_L1_LINKS+1];
sngisdn_span_data_t *spans[MAX_L1_LINKS+1]; /* spans are indexed by link_id */
#ifdef SANGOMA_ISDN_CHAN_ID_INVERT_BIT
/* Since this is a global configuration, place it here instead of sngisdn_span_data_t */
uint8_t chan_id_invert_extend_bit;
#endif
}ftdm_sngisdn_data_t;
typedef struct ftdm2trillium
@@ -286,7 +286,8 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_
signal_data->restart_opt = SNGISDN_OPT_DEFAULT;
signal_data->link_id = span->span_id;
signal_data->transfer_timeout = 20000;
signal_data->att_remove_dtmf = 1;
signal_data->att_remove_dtmf = SNGISDN_OPT_DEFAULT;
signal_data->force_sending_complete = SNGISDN_OPT_DEFAULT;
span->default_caller_data.dnis.plan = FTDM_NPI_INVALID;
span->default_caller_data.dnis.type = FTDM_TON_INVALID;
@@ -386,10 +387,18 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_
parse_yesno(var, val, &signal_data->raw_trace_q931);
} else if (!strcasecmp(var, "q921-raw-trace")) {
parse_yesno(var, val, &signal_data->raw_trace_q921);
} else if (!strcasecmp(var, "force-sending-complete")) {
parse_yesno(var, val, &signal_data->force_sending_complete);
} else if (!strcasecmp(var, "early-media-override")) {
if (parse_early_media(val, span) != FTDM_SUCCESS) {
return FTDM_FAIL;
}
} else if (!strcasecmp(var, "chan-id-invert-extend-bit")) {
#ifdef SANGOMA_ISDN_CHAN_ID_INVERT_BIT
parse_yesno(var, val, &g_sngisdn_data.chan_id_invert_extend_bit);
#else
ftdm_log(FTDM_LOG_WARNING, "chan-id-invert-extend-bit is not supported in your version of libsng_isdn\n");
#endif
} else {
ftdm_log(FTDM_LOG_WARNING, "Ignoring unknown parameter %s\n", ftdm_parameters[paramindex].var);
}
@@ -624,7 +624,7 @@ ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span)
cfg.t.cfg.s.inDLSAP.tCbCfg = TRUE;
cfg.t.cfg.s.inDLSAP.tCbId = signal_data->cc_id;
if (signal_data->facility == SNGISDN_OPT_TRUE) {
cfg.t.cfg.s.inDLSAP.facilityHandling = IN_FACILITY_STANDRD;
} else {
@@ -720,6 +720,16 @@ ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span)
}
cfg.t.cfg.s.inDLSAP.useSubAdr = 0; /* call routing on subaddress */
#ifdef SANGOMA_ISDN_CHAN_ID_INVERT_BIT
if (signal_data->switchtype == SNGISDN_SWITCH_DMS100 &&
g_sngisdn_data.chan_id_invert_extend_bit == SNGISDN_OPT_TRUE) {
/* Since this feature is not standard, we modified Trillium to check
the useSubAdr field and remove the extended bit if this is set, this
is a global configuration and once set, applies to all spans configured
as DMS 100 */
cfg.t.cfg.s.inDLSAP.useSubAdr = PRSNT_NODEF;
}
#endif
cfg.t.cfg.s.inDLSAP.adrPref = 0; /* use of prefix for international calls */
cfg.t.cfg.s.inDLSAP.nmbPrefDig = 0; /* number of digits used for prefix */
for (i = 0; i < IN_MAXPREFDIG; i++)
@@ -882,6 +882,12 @@ void sngisdn_process_sta_cfm (sngisdn_event_data_t *sngisdn_event)
uint8_t call_state = 0;
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
if (!suInstId && !spInstId) {
/* We already cleared this call */
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Dropping STATUS CONFIRM (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId);
return;
}
if (staEvnt->callSte.eh.pres && staEvnt->callSte.callGlblSte.pres) {
call_state = staEvnt->callSte.callGlblSte.val;
@@ -1137,7 +1143,7 @@ static ftdm_status_t sngisdn_force_down(ftdm_channel_t *ftdmchan)
sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)ftdmchan->call_data;
ftdm_status_t status = FTDM_SUCCESS;
ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "Forcing channel to DOWN state (%s)\n", ftdm_channel_state2str(ftdmchan->state));
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Forcing channel to DOWN state (%s)\n", ftdm_channel_state2str(ftdmchan->state));
switch (ftdmchan->state) {
case FTDM_CHANNEL_STATE_DOWN:
/* Do nothing */
@@ -51,9 +51,10 @@ void sngisdn_snd_setup(ftdm_channel_t *ftdmchan)
ftdm_mutex_unlock(g_sngisdn_data.ccs[signal_data->cc_id].mutex);
memset(&conEvnt, 0, sizeof(conEvnt));
if (signal_data->switchtype == SNGISDN_SWITCH_EUROISDN) {
if (signal_data->switchtype == SNGISDN_SWITCH_EUROISDN || signal_data->force_sending_complete == SNGISDN_OPT_TRUE) {
conEvnt.sndCmplt.eh.pres = PRSNT_NODEF;
}
if (ftdmchan->span->trunk_type == FTDM_TRUNK_BRI_PTMP &&
signal_data->signalling == SNGISDN_SIGNALING_NET) {
sngisdn_info->ces = CES_MNGMNT;
@@ -502,12 +502,16 @@ void sngisdn_rcv_sta_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, St
sngisdn_event_data_t *sngisdn_event = NULL;
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
/* We sometimes receive a STA CFM after receiving a RELEASE/RELEASE COMPLETE, so we need to lock
here in case we are calling clear_call_data at the same time this function is called */
ftdm_mutex_lock(g_sngisdn_data.ccs[suId].mutex);
if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) &&
!(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) {
ftdm_log(FTDM_LOG_CRIT, "Could not find matching call suId:%u suInstId:%u spInstId:%u\n", suId, suInstId, spInstId);
ftdm_assert(0, "Inconsistent call states\n");
ftdm_mutex_unlock(g_sngisdn_data.ccs[suId].mutex);
return;
}
@@ -526,6 +530,7 @@ void sngisdn_rcv_sta_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, St
memcpy(&sngisdn_event->event.staEvnt, staEvnt, sizeof(*staEvnt));
ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event);
ftdm_mutex_unlock(g_sngisdn_data.ccs[suId].mutex);
ISDN_FUNC_TRACE_EXIT(__FUNCTION__);
}
@@ -99,13 +99,14 @@ void clear_call_data(sngisdn_chan_data_t *sngisdn_info)
ftdm_mutex_lock(g_sngisdn_data.ccs[cc_id].mutex);
g_sngisdn_data.ccs[cc_id].active_spInstIds[sngisdn_info->spInstId]=NULL;
g_sngisdn_data.ccs[cc_id].active_suInstIds[sngisdn_info->suInstId]=NULL;
ftdm_mutex_unlock(g_sngisdn_data.ccs[cc_id].mutex);
sngisdn_info->suInstId = 0;
sngisdn_info->spInstId = 0;
sngisdn_info->globalFlg = 0;
sngisdn_info->flags = 0;
sngisdn_info->transfer_data.type = SNGISDN_TRANSFER_NONE;
ftdm_mutex_unlock(g_sngisdn_data.ccs[cc_id].mutex);
return;
}
@@ -273,7 +273,7 @@ ftdm_status_t sngisdn_att_transfer_process_dtmf(ftdm_channel_t *ftdmchan, const
att_courtesy_transfer_complete(sngisdn_info, sngisdn_info->transfer_data.response);
}
if (signal_data->att_remove_dtmf) {
if (signal_data->att_remove_dtmf != SNGISDN_OPT_FALSE) {
/* If we return FTDM_BREAK, dtmf event is not queue'ed to user */
status = FTDM_BREAK;
}
@@ -584,6 +584,20 @@ ftdm_status_t handle_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circ
break;
/**************************************************************************/
case FTDM_CHANNEL_STATE_HANGUP_COMPLETE:
/* already hangup complete, just ignore it */
/*
* i.e. collision REL & ANM
* IAM ->
* <- ACM
* REL -> <- ANM (if REL gets processed first, ANM needs to be ignored)
* <- RLC
*/
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx ANM/CON Ignoring it because we already hung up\n", sngss7_info->circuit->cic);
break;
/**************************************************************************/
default: /* incorrect state...reset the CIC */
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx ANM/CON\n", sngss7_info->circuit->cic);
@@ -1267,7 +1281,7 @@ ftdm_status_t handle_resume(uint32_t suInstId, uint32_t spInstId, uint32_t circu
/* confirm that the circuit is active on our side otherwise move to the next circuit */
if (!sngss7_test_flag(&g_ftdm_sngss7_data.cfg.isupCkt[i], SNGSS7_ACTIVE)) {
SS7_ERROR("[CIC:%d]Circuit is not active yet, skipping!\n",g_ftdm_sngss7_data.cfg.isupCkt[i].cic);
ftdm_log(FTDM_LOG_DEBUG, "[CIC:%d]Circuit is not active yet, skipping!\n",g_ftdm_sngss7_data.cfg.isupCkt[i].cic);
i++;
continue;
}
+10 -6
View File
@@ -1072,16 +1072,20 @@ static __inline__ ftdm_status_t zt_channel_process_event(ftdm_channel_t *fchan,
break;
case ZT_EVENT_BADFCS:
{
ftdm_log_chan_msg(fchan, FTDM_LOG_ERROR, "Bad frame checksum (ZT_EVENT_BADFCS)!\n");
/* What else could we do? */
*event_id = FTDM_OOB_NOOP;
ftdm_log_chan_msg(fchan, FTDM_LOG_ERROR, "Bad frame checksum (ZT_EVENT_BADFCS)\n");
*event_id = FTDM_OOB_NOOP; /* What else could we do? */
}
break;
case ZT_EVENT_OVERRUN:
{
ftdm_log_chan_msg(fchan, FTDM_LOG_ERROR, "Driver overrun! (ZT_EVENT_OVERRUN)\n");
/* What else could we do? */
*event_id = FTDM_OOB_NOOP;
ftdm_log_chan_msg(fchan, FTDM_LOG_ERROR, "HDLC frame overrun (ZT_EVENT_OVERRUN)\n");
*event_id = FTDM_OOB_NOOP; /* What else could we do? */
}
break;
case ZT_EVENT_ABORT:
{
ftdm_log_chan_msg(fchan, FTDM_LOG_ERROR, "HDLC abort frame received (ZT_EVENT_ABORT)\n");
*event_id = FTDM_OOB_NOOP; /* What else could we do? */
}
break;
case ZT_EVENT_NONE:
+2 -2
View File
@@ -599,8 +599,8 @@ FT_DECLARE(ftdm_iterator_t *) ftdm_get_iterator(ftdm_iterator_type_t type, ftdm_
FT_DECLARE(ftdm_status_t) ftdm_channel_process_media(ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen);
FIO_WRITE_FUNCTION(ftdm_raw_write);
FIO_READ_FUNCTION(ftdm_raw_read);
FT_DECLARE(ftdm_status_t) ftdm_raw_read (ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen);
FT_DECLARE(ftdm_status_t) ftdm_raw_write (ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen);
/*!
* \brief Retrieves an event from the span