diff --git a/Makefile.am b/Makefile.am index 653974d67c..8c61da454a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -585,6 +585,9 @@ libs/openzap/Makefile: cd libs/openzap && autoconf cd libs/openzap && ./configure +version: + git log -1 | head -3 + reinstall: modwipe uninstall install update-clean: clean libs/openzap/Makefile python-reconf @@ -619,9 +622,7 @@ sndfile-reconf: tiff-reconf: cd libs/tiff-4.0.2 && autoreconf -fi cd libs/tiff-4.0.2 && sh ./configure.gnu - cd libs/spandsp && autoreconf -fi - cd libs/spandsp && sh ./configure.gnu - make mod_voipcodecs-clean + cd libs/tiff-4.0.2 && make python-reconf: rm -f src/mod/languages/mod_python/Makefile @@ -644,7 +645,7 @@ iks-reconf: cd libs/iksemel && sh ./configure.gnu --prefix=$(prefix) $(MAKE) mod_dingaling-clean -spandsp-reconf: +spandsp-reconf: tiff-reconf cd libs/spandsp && $(MAKE) clean || echo cd libs/spandsp && autoreconf -fi cd libs/spandsp && sh ./configure.gnu --prefix=$(prefix) @@ -694,7 +695,7 @@ modclean: $(switch_builddir)/modules.conf @cd src/mod && $(MAKE) $(AM_MAKEFLAGS) clean modwipe: - rm -f $(modulesdir)/*.${DYNAMIC_LIB_EXTEN} + rm -f $(modulesdir)/*.${DYNAMIC_LIB_EXTEN} $(modulesdir)/*.la dox: cd docs && doxygen $(PWD)/docs/Doxygen.conf diff --git a/debian/README.source b/debian/README.source index d76b4d2f1e..f432311158 100644 --- a/debian/README.source +++ b/debian/README.source @@ -55,13 +55,33 @@ directory of your FS git working tree: ./build/set-fs-version.sh "$ver" git add configure.in && git commit -m "bump to custom v$ver" (cd debian && ./bootstrap.sh -c $distro) - dch -b -m -v "$ver" --force-distribution -D "$suite" "Custom build." - git-buildpackage -b -us -uc \ - --git-verbose \ - --git-pbuilder --git-dist=$distro \ - --git-compression-level=1v --git-compression=xz + dch -b -m -v "$ver" --force-distribution -D "unstable" "Custom build." + dpkg-buildpackage -b -us -uc -Zxz -z9 git reset --hard HEAD^ +To build for a stable branch, do this: + + distro=sid # update as needed + stable_ver="1.2.1" # update as needed + # if you only want to build some modules, put them one per line here, e.g.: + #echo "applications/mod_commands" >> debian/modules.conf + ver="$(echo "$stable_ver" | sed -e 's/-/~/g')~n$(date +%Y%m%dT%H%M%SZ)-1~${distro}+1" + git clean -fdx && git reset --hard refs/tags/v${stable_ver} + ./build/set-fs-version.sh "$ver" + git add configure.in && git commit -m "bump to custom v$ver" + (cd debian && ./bootstrap.sh -c $distro) + dch -b -m -v "$ver" --force-distribution -D "unstable" "Custom build." + dpkg-buildpackage -b -us -uc -Zxz -z9 + git reset --hard origin/master + +Alternatively, you can build using our automated tools: + + aptitude install cowbuilder + # if you only want to build some modules, create a modules.conf + # outside the source tree and add -f ../path/to/modules.conf to the + # command below. + ./debian/util.sh build-all -bn -a amd64 -c sid # update as needed + The source packages for sounds and music on hold are maintained in a separate repository. Each set of sounds has a separate version number and the processing of the sounds is quite different from what we're @@ -74,4 +94,4 @@ freeswitch-music-*: git clone https://github.com/traviscross/freeswitch-sounds.git cd freeswitch-sounds && cat debian/README.source - -- Travis Cross , Mon, 20 Aug 2012 08:14:49 +0000 + -- Travis Cross , Tue, 4 Sep 2012 14:56:52 +0000 diff --git a/libs/esl/fs_cli.c b/libs/esl/fs_cli.c index a984327963..95629da76e 100644 --- a/libs/esl/fs_cli.c +++ b/libs/esl/fs_cli.c @@ -926,7 +926,14 @@ static void print_banner(FILE *stream) #include #ifdef WIN32 - fprintf(stream, "%s%s\n%s\n", banner, cc, inf); + /* Print banner in yellow with blue background */ + SetConsoleTextAttribute(hStdout, ESL_SEQ_FYELLOW | BACKGROUND_BLUE); + WriteFile(hStdout, banner, (DWORD) strlen(banner), NULL, NULL); + WriteFile(hStdout, cc, (DWORD) strlen(cc), NULL, NULL); + SetConsoleTextAttribute(hStdout, wOldColorAttrs); + + /* Print the rest info in default colors */ + fprintf(stream, "\n%s\n", inf); #else fprintf(stream, "%s%s%s%s%s%s\n%s\n", diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 2f66edd019..0813e630ed 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -1917,10 +1917,8 @@ static FIO_SIGNAL_CB_FUNCTION(on_common_signal) return FTDM_FAIL; } if (sigmsg->event_id == FTDM_SIGEVENT_ALARM_CLEAR) { - ftdm_log(FTDM_LOG_NOTICE, "Alarm cleared on channel %d:%d\n", spanid, chanid); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "ftdm-alarm-clear"); } else { - ftdm_log(FTDM_LOG_NOTICE, "Alarm raised on channel %d:%d\n", spanid, chanid); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "ftdm-alarm-trap"); } } @@ -2525,7 +2523,7 @@ static FIO_SIGNAL_CB_FUNCTION(on_clear_channel_signal) break; case FTDM_SIGEVENT_SIGSTATUS_CHANGED: { - ftdm_signaling_status_t sigstatus = sigmsg->ev_data.sigstatus.status; + ftdm_signaling_status_t sigstatus = sigmsg->ev_data.sigstatus.status; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%d:%d signalling changed to :%s\n", spanid, chanid, ftdm_signaling_status2str(sigstatus)); } diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c index 32a7e09b83..9412d75c9b 100644 --- a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c +++ b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c @@ -38,6 +38,10 @@ static ftdm_status_t ftdm_libpri_start(ftdm_span_t *span); static ftdm_io_interface_t ftdm_libpri_interface; +static int on_timeout_t302(struct lpwrap_pri *spri, struct lpwrap_timer *timer); +static int on_timeout_t316(struct lpwrap_pri *spri, struct lpwrap_timer *timer); +static int on_timeout_t3xx(struct lpwrap_pri *spri, struct lpwrap_timer *timer); + static void _ftdm_channel_set_state_force(ftdm_channel_t *chan, const ftdm_channel_state_t state) { @@ -737,7 +741,7 @@ static ftdm_state_map_t isdn_state_map = { ZSD_OUTBOUND, ZSM_UNACCEPTABLE, {FTDM_CHANNEL_STATE_RESTART, FTDM_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_END} + {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_SUSPENDED, FTDM_END} }, { ZSD_OUTBOUND, @@ -804,6 +808,12 @@ static ftdm_state_map_t isdn_state_map = { {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_END}, {FTDM_CHANNEL_STATE_DOWN, FTDM_END}, }, + { + ZSD_OUTBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_END}, + {FTDM_CHANNEL_STATE_DOWN, FTDM_END}, + }, /****************************************/ { @@ -816,7 +826,7 @@ static ftdm_state_map_t isdn_state_map = { ZSD_INBOUND, ZSM_UNACCEPTABLE, {FTDM_CHANNEL_STATE_RESTART, FTDM_END}, - {FTDM_CHANNEL_STATE_DOWN, FTDM_END} + {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_SUSPENDED, FTDM_END} }, { ZSD_INBOUND, @@ -892,6 +902,12 @@ static ftdm_state_map_t isdn_state_map = { {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_END}, {FTDM_CHANNEL_STATE_DOWN, FTDM_END}, }, + { + ZSD_INBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_END}, + {FTDM_CHANNEL_STATE_DOWN, FTDM_END}, + }, } }; @@ -902,8 +918,10 @@ static ftdm_state_map_t isdn_state_map = { */ static ftdm_status_t state_advance(ftdm_channel_t *chan) { - ftdm_libpri_data_t *isdn_data = chan->span->signal_data; - q931_call *call = (q931_call *)chan->call_data; + ftdm_span_t *span = ftdm_channel_get_span(chan); + ftdm_libpri_data_t *isdn_data = span->signal_data; + ftdm_libpri_b_chan_t *chan_priv = chan->call_data; + q931_call *call = chan_priv->call; ftdm_status_t status; ftdm_sigmsg_t sig; @@ -920,21 +938,30 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) switch (ftdm_channel_get_state(chan)) { case FTDM_CHANNEL_STATE_DOWN: { - ftdm_channel_t *chtmp = chan; + if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { + ftdm_channel_t *chtmp = chan; - if (call) { - pri_destroycall(isdn_data->spri.pri, call); - chan->call_data = NULL; - } + if (call) { + pri_destroycall(isdn_data->spri.pri, call); + chan_priv->call = NULL; + } - if (ftdm_channel_close(&chtmp) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_WARNING, "-- Failed to close channel %d:%d\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); - } else { - ftdm_log(FTDM_LOG_DEBUG, "-- Closed channel %d:%d\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan)); + /* Stop T302 */ + lpwrap_stop_timer(&isdn_data->spri, &chan_priv->t302); + + /* Stop T316 and reset counter */ + lpwrap_stop_timer(&isdn_data->spri, &chan_priv->t316); + chan_priv->t316_timeout_cnt = 0; + + if (ftdm_channel_close(&chtmp) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_WARNING, "-- Failed to close channel %d:%d\n", + ftdm_channel_get_span_id(chan), + ftdm_channel_get_id(chan)); + } else { + ftdm_log(FTDM_LOG_DEBUG, "-- Closed channel %d:%d\n", + ftdm_channel_get_span_id(chan), + ftdm_channel_get_id(chan)); + } } } break; @@ -943,7 +970,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) { if (ftdm_test_flag(chan, FTDM_CHANNEL_OUTBOUND)) { sig.event_id = FTDM_SIGEVENT_PROGRESS; - if ((status = ftdm_span_send_signal(ftdm_channel_get_span(chan), &sig) != FTDM_SUCCESS)) { + if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); } } else if (call) { @@ -958,7 +985,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) { if (ftdm_test_flag(chan, FTDM_CHANNEL_OUTBOUND)) { sig.event_id = FTDM_SIGEVENT_RINGING; - if ((status = ftdm_span_send_signal(ftdm_channel_get_span(chan), &sig) != FTDM_SUCCESS)) { + if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); } } else if (call) { @@ -974,7 +1001,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) { if (ftdm_test_flag(chan, FTDM_CHANNEL_OUTBOUND)) { sig.event_id = FTDM_SIGEVENT_PROGRESS_MEDIA; - if ((status = ftdm_span_send_signal(ftdm_channel_get_span(chan), &sig) != FTDM_SUCCESS)) { + if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); } } else if (call) { @@ -994,7 +1021,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) if (ftdm_test_flag(chan, FTDM_CHANNEL_OUTBOUND)) { /* PROCEED from other end, notify user */ sig.event_id = FTDM_SIGEVENT_PROCEED; - if ((status = ftdm_span_send_signal(ftdm_channel_get_span(chan), &sig) != FTDM_SUCCESS)) { + if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { ftdm_log(FTDM_LOG_ERROR, "Failed to send PROCEED sigevent on Channel %d:%d\n", ftdm_channel_get_span_id(chan), ftdm_channel_get_id(chan)); @@ -1024,6 +1051,11 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) caller_data->hangup_cause = FTDM_CAUSE_DESTINATION_OUT_OF_ORDER; ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); } + else { + /* Start T302 */ + lpwrap_start_timer(&isdn_data->spri, &chan_priv->t302, + isdn_data->overlap_timeout_ms, &on_timeout_t302); + } } else { ftdm_log_chan_msg(chan, FTDM_LOG_ERROR, "Overlap receiving on outbound call?\n"); ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RESTART); @@ -1042,7 +1074,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) pri_proceeding(isdn_data->spri.pri, call, ftdm_channel_get_id(chan), 0); // pri_acknowledge(isdn_data->spri.pri, call, ftdm_channel_get_id(chan), 0); sig.event_id = FTDM_SIGEVENT_START; - if ((status = ftdm_span_send_signal(ftdm_channel_get_span(chan), &sig) != FTDM_SUCCESS)) { + if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); } } else { @@ -1054,10 +1086,26 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) case FTDM_CHANNEL_STATE_RESTART: { - chan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_UNSPECIFIED; - sig.event_id = FTDM_SIGEVENT_RESTART; - status = ftdm_span_send_signal(ftdm_channel_get_span(chan), &sig); - ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_DOWN); + if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { + chan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_UNSPECIFIED; + sig.event_id = FTDM_SIGEVENT_RESTART; + status = ftdm_span_send_signal(span, &sig); + + if (ftdm_span_get_trunk_type(span) == FTDM_TRUNK_BRI_PTMP) { + /* Just put the channel into DOWN state, libpri won't send RESTART on BRI PTMP */ + ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_DOWN); + + } else if (!(chan_priv->flags & FTDM_LIBPRI_B_REMOTE_RESTART)) { + /* Locally triggered restart, send RESTART to remote, wait for ACK */ + pri_reset(isdn_data->spri.pri, ftdm_channel_get_id(chan)); + /* Start T316 */ + lpwrap_start_timer(&isdn_data->spri, &chan_priv->t316, isdn_data->t316_timeout_ms, &on_timeout_t316); + } else { + /* Remote restart complete, clear flag (RESTART ACK already sent by libpri) */ + chan_priv->flags &= ~FTDM_LIBPRI_B_REMOTE_RESTART; + ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_DOWN); + } + } } break; @@ -1065,7 +1113,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) { if (ftdm_test_flag(chan, FTDM_CHANNEL_OUTBOUND)) { sig.event_id = FTDM_SIGEVENT_UP; - if ((status = ftdm_span_send_signal(ftdm_channel_get_span(chan), &sig) != FTDM_SUCCESS)) { + if ((status = ftdm_span_send_signal(span, &sig) != FTDM_SUCCESS)) { ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP); } } else if (call) { @@ -1109,7 +1157,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) ton = isdn_data->ton; } - chan->call_data = call; + chan_priv->call = call; sr = pri_sr_new(); if (!sr) { @@ -1155,7 +1203,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) pri_hangup(isdn_data->spri.pri, call, caller_data->hangup_cause); // pri_destroycall(isdn_data->spri.pri, call); -// chan->call_data = NULL; +// chan_priv->call = NULL; } ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); } @@ -1165,7 +1213,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) { // if (call) { // pri_destroycall(isdn_data->spri.pri, call); -// chan->call_data = NULL; +// chan_priv->call = NULL; // } ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_DOWN); } @@ -1174,7 +1222,7 @@ static ftdm_status_t state_advance(ftdm_channel_t *chan) case FTDM_CHANNEL_STATE_TERMINATING: { sig.event_id = FTDM_SIGEVENT_STOP; - status = ftdm_span_send_signal(ftdm_channel_get_span(chan), &sig); + status = ftdm_span_send_signal(span, &sig); /* user moves us to HANGUP and from there we go to DOWN */ } default: @@ -1203,18 +1251,48 @@ static __inline__ void check_state(ftdm_span_t *span) } } + /** - * \brief Handler for libpri information event (incoming call?) + * \brief Handler for libpri keypad digit event * \param spri Pri wrapper structure (libpri, span, dchan) * \param event_type Event type (unused) * \param pevent Event * \return 0 */ -static int on_info(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) +static int on_keypad_digit(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) { ftdm_span_t *span = spri->span; ftdm_channel_t *chan = ftdm_span_get_channel(span, pevent->ring.channel); + + if (!chan) { + ftdm_log(FTDM_LOG_ERROR, "-- Keypad event on invalid channel %d:%d\n", + ftdm_span_get_id(span), pevent->ring.channel); + return 0; + } + + ftdm_log_chan(chan, FTDM_LOG_DEBUG, "-- Keypad event received, incoming digits: '%s'\n", + pevent->digit.digits); + + /* Enqueue DTMF digits on channel */ + ftdm_channel_queue_dtmf(chan, pevent->digit.digits); + return 0; +} + + +/** + * \brief Handler for libpri information event (overlap receiving) + * \param spri Pri wrapper structure (libpri, span, dchan) + * \param event_type Event type (unused) + * \param pevent Event + * \return 0 + */ +static int on_information(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) +{ + ftdm_span_t *span = spri->span; + ftdm_channel_t *chan = ftdm_span_get_channel(span, pevent->ring.channel); + ftdm_libpri_b_chan_t *chan_priv = NULL; ftdm_caller_data_t *caller_data = NULL; + ftdm_libpri_data_t *isdn_data = span->signal_data; if (!chan) { ftdm_log(FTDM_LOG_CRIT, "-- Info on channel %d:%d but it's not in use?\n", ftdm_span_get_id(span), pevent->ring.channel); @@ -1222,11 +1300,19 @@ static int on_info(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event } caller_data = ftdm_channel_get_caller_data(chan); + chan_priv = chan->call_data; switch (ftdm_channel_get_state(chan)) { case FTDM_CHANNEL_STATE_COLLECT: /* TE-mode overlap receiving */ - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "-- Incoming INFORMATION indication, current called number: '%s', number complete: %s\n", - pevent->ring.callednum, pevent->ring.complete ? "yes" : "no"); + case FTDM_CHANNEL_STATE_DIALTONE: /* NT-mode overlap receiving */ + + ftdm_log_chan(chan, FTDM_LOG_DEBUG, "-- Incoming INFORMATION indication, received digits: '%s', number complete: %c, collected digits: '%s'\n", + pevent->ring.callednum, + pevent->ring.complete ? 'Y' : 'N', + caller_data->dnis.digits); + + /* Stop T302 */ + lpwrap_stop_timer(spri, &chan_priv->t302); /* append digits to dnis */ if (!ftdm_strlen_zero(pevent->ring.callednum)) { @@ -1241,7 +1327,7 @@ static int on_info(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event len = ftdm_min(sizeof(caller_data->dnis.digits) - 1 - offset, digits); /* max. length without terminator */ if (len < digits) { - ftdm_log_chan(chan, FTDM_LOG_WARNING, "Length %d of digit string exceeds available space %d of DNIS, truncating!\n", + ftdm_log_chan(chan, FTDM_LOG_WARNING, "Digit string of length %d exceeds available space %d of DNIS, truncating!\n", digits, len); } if (len) { @@ -1250,25 +1336,16 @@ static int on_info(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event } } if (pevent->ring.complete) { - ftdm_log_chan_msg(chan, FTDM_LOG_DEBUG, "Number complete indicated, moving channel to RING state\n"); + ftdm_log_chan_msg(chan, FTDM_LOG_DEBUG, "Number complete indication received, moving channel to RING state\n"); /* notify switch */ ftdm_set_state(chan, FTDM_CHANNEL_STATE_RING); - } - break; - case FTDM_CHANNEL_STATE_DIALTONE: /* NT-mode overlap receiving */ - ftdm_log_chan(chan, FTDM_LOG_DEBUG, "-- Incoming INFORMATION indication, current called number: '%s'\n", - pevent->ring.callednum); - - /* Need to add proper support for overlap receiving in NT-mode (requires FreeSWITCH + FreeTDM core support) */ - if (strlen(pevent->ring.callednum) > 3) { - ftdm_log(FTDM_LOG_DEBUG, "final number is: %s\n", pevent->ring.callednum); - pri_answer(spri->pri, pevent->ring.call, 0, 1); + } else { + /* Restart T302 */ + lpwrap_start_timer(spri, &chan_priv->t302, isdn_data->overlap_timeout_ms, &on_timeout_t302); } break; default: - ftdm_log_chan(chan, FTDM_LOG_ERROR, "-- INFORMATION indication on channel %d:%d in invalid state '%s'\n", - ftdm_channel_get_span_id(chan), - ftdm_channel_get_id(chan), + ftdm_log_chan(chan, FTDM_LOG_ERROR, "-- INFORMATION indication in invalid state '%s'\n", ftdm_channel_get_state_str(chan)); } return 0; @@ -1650,6 +1727,7 @@ static int on_ring(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event { ftdm_span_t *span = spri->span; ftdm_libpri_data_t *isdn_data = span->signal_data; + ftdm_libpri_b_chan_t *chan_priv = NULL; ftdm_channel_t *chan = NULL; ftdm_caller_data_t *caller_data = NULL; int ret = 0; @@ -1730,11 +1808,14 @@ static int on_ring(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event } } - if (chan->call_data) { + /* Get per-channel private data */ + chan_priv = chan->call_data; + + if (chan_priv->call) { /* we could drop the incoming call, but most likely the pointer is just a ghost of the past, * this check is just to detect potentially unreleased pointers */ - ftdm_log_chan(chan, FTDM_LOG_WARNING, "Channel already has call %p!\n", chan->call_data); - chan->call_data = NULL; + ftdm_log_chan(chan, FTDM_LOG_WARNING, "Channel already has call %p!\n", chan_priv->call); + chan_priv->call = NULL; } caller_data = ftdm_channel_get_caller_data(chan); @@ -1761,7 +1842,7 @@ static int on_ring(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event // scary to trust this pointer, you'd think they would give you a copy of the call data so you own it...... /* hurr, this is valid as along as nobody releases the call */ - chan->call_data = pevent->ring.call; + chan_priv->call = pevent->ring.call; /* Open Channel if inband information is available */ if ((pevent->ring.progressmask & PRI_PROG_INBAND_AVAILABLE)) { @@ -1799,6 +1880,77 @@ done: return ret; } + +/** + * Timeout handler for T302 (overlap receiving) + */ +static int on_timeout_t302(struct lpwrap_pri *spri, struct lpwrap_timer *timer) +{ + ftdm_libpri_b_chan_t *chan_priv = ftdm_container_of(timer, ftdm_libpri_b_chan_t, t302); + ftdm_channel_t *chan = chan_priv->channel; + + ftdm_log_chan_msg(chan, FTDM_LOG_INFO, "-- T302 timed out, going to state RING\n"); + ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RING); + return 0; +} + +/** + * Timeout handler for T316 (RESTART ACK timer) + */ +static int on_timeout_t316(struct lpwrap_pri *spri, struct lpwrap_timer *timer) +{ + ftdm_libpri_b_chan_t *chan_priv = ftdm_container_of(timer, ftdm_libpri_b_chan_t, t316); + ftdm_libpri_data_t *isdn_data = ftdm_container_of(spri, ftdm_libpri_data_t, spri); + ftdm_channel_t *chan = chan_priv->channel; + + if (++chan_priv->t316_timeout_cnt > isdn_data->t316_max_attempts) { + ftdm_log_chan(chan, FTDM_LOG_ERROR, "-- T316 timed out, channel reached restart attempt limit '%d' and is suspended\n", + isdn_data->t316_max_attempts); + + ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_SUSPENDED); + } else { + ftdm_log_chan_msg(chan, FTDM_LOG_WARNING, "-- T316 timed out, resending RESTART request\n"); + pri_reset(spri->pri, ftdm_channel_get_id(chan)); + + /* Restart T316 */ + lpwrap_start_timer(spri, timer, isdn_data->t316_timeout_ms, &on_timeout_t316); + } + return 0; +} + + +/** + * Timeout handler for T3xx (NT-mode idle restart) + */ +static int on_timeout_t3xx(struct lpwrap_pri *spri, struct lpwrap_timer *timer) +{ + ftdm_span_t *span = spri->span; + ftdm_libpri_data_t *isdn_data = span->signal_data; + ftdm_iterator_t *iter = NULL; + + ftdm_log_chan_msg(isdn_data->dchan, FTDM_LOG_INFO, "-- T3xx timed out, restarting idle b-channels\n"); + ftdm_mutex_lock(span->mutex); + + /* Iterate b-channels */ + for (iter = ftdm_span_get_chan_iterator(span, NULL); iter; iter = ftdm_iterator_next(iter)) { + ftdm_channel_t *cur = ftdm_iterator_current(iter); + /* Skip non-b-channels */ + if (ftdm_channel_get_type(cur) != FTDM_CHAN_TYPE_B) + continue; + /* Restart idle b-channels */ + if (ftdm_channel_get_state(cur) == FTDM_CHANNEL_STATE_DOWN) { + ftdm_set_state_locked(cur, FTDM_CHANNEL_STATE_RESTART); + } + } + ftdm_iterator_free(iter); + ftdm_mutex_unlock(span->mutex); + + /* Start timer again */ + lpwrap_start_timer(spri, timer, isdn_data->idle_restart_timeout_ms, &on_timeout_t3xx); + return 0; +} + + /** * \brief Processes freetdm event * \param span Span on which the event was fired @@ -1826,22 +1978,15 @@ static __inline__ ftdm_status_t process_event(ftdm_span_t *span, ftdm_event_t *e } ftdm_set_flag(event->channel, FTDM_CHANNEL_SUSPENDED); - ftdm_channel_get_alarms(event->channel, &alarmbits); - ftdm_log(FTDM_LOG_WARNING, "channel %d:%d (%d:%d) has alarms! [%s]\n", - ftdm_channel_get_span_id(event->channel), ftdm_channel_get_id(event->channel), - ftdm_channel_get_ph_span_id(event->channel), ftdm_channel_get_ph_id(event->channel), - ftdm_channel_get_last_error(event->channel)); + ftdm_log_chan_msg(event->channel, FTDM_LOG_WARNING, "channel has alarms!\n"); } break; case FTDM_OOB_ALARM_CLEAR: { - ftdm_log(FTDM_LOG_WARNING, "channel %d:%d (%d:%d) alarms Cleared!\n", - ftdm_channel_get_span_id(event->channel), ftdm_channel_get_id(event->channel), - ftdm_channel_get_ph_span_id(event->channel), ftdm_channel_get_ph_id(event->channel)); - ftdm_clear_flag(event->channel, FTDM_CHANNEL_SUSPENDED); ftdm_channel_get_alarms(event->channel, &alarmbits); + ftdm_log_chan_msg(event->channel, FTDM_LOG_WARNING, "channel alarms cleared!\n"); } break; } @@ -1892,11 +2037,6 @@ static __inline__ void check_events(ftdm_span_t *span) static int check_flags(lpwrap_pri_t *spri) { ftdm_span_t *span = spri->span; - - if (!ftdm_running() || ftdm_test_flag(span, FTDM_SPAN_STOP_THREAD)) { - return -1; - } - check_state(span); check_events(span); return 0; @@ -1911,24 +2051,84 @@ static int check_flags(lpwrap_pri_t *spri) */ static int on_restart(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) { + ftdm_channel_t *chan = NULL; ftdm_span_t *span = spri->span; - ftdm_channel_t *chan = ftdm_span_get_channel(span, pevent->restart.channel); - - ftdm_log(FTDM_LOG_NOTICE, "-- Restarting %d:%d\n", ftdm_span_get_id(span), pevent->restart.channel); - _ftdm_channel_set_state_force(spri->dchan, FTDM_CHANNEL_STATE_UP); - - if (!chan) { - return 0; - } + int i; if (pevent->restart.channel < 1) { - ftdm_set_state_all(span, FTDM_CHANNEL_STATE_RESTART); - } else { + ftdm_log_chan_msg(spri->dchan, FTDM_LOG_NOTICE, "-- Restarting interface\n"); + + for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { + chan = ftdm_span_get_channel(span, i); + if (!chan) + continue; + if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { + ftdm_libpri_b_chan_t *chan_priv = chan->call_data; + chan_priv->flags |= FTDM_LIBPRI_B_REMOTE_RESTART; /* Remote triggered RESTART, set flag */ + ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RESTART); + } + } + } + else if ((chan = ftdm_span_get_channel(span, pevent->restart.channel))) { + ftdm_libpri_b_chan_t *chan_priv = chan->call_data; + + ftdm_log_chan_msg(chan, FTDM_LOG_NOTICE, "-- Restarting single channel\n"); + chan_priv->flags |= FTDM_LIBPRI_B_REMOTE_RESTART; ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_RESTART); } + else { + ftdm_log(FTDM_LOG_ERROR, "Invalid restart indicator / channel id '%d' received\n", + pevent->restart.channel); + } + + _ftdm_channel_set_state_force(spri->dchan, FTDM_CHANNEL_STATE_UP); return 0; } +/** + * \brief Handler for libpri restart acknowledge event + * \param spri Pri wrapper structure (libpri, span, dchan) + * \param event_type Event type (unused) + * \param pevent Event + * \return 0 + */ +static int on_restart_ack(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event *pevent) +{ + ftdm_channel_t *chan = NULL; + ftdm_span_t *span = spri->span; + int i; + + if (pevent->restartack.channel < 1) { + ftdm_log_chan_msg(spri->dchan, FTDM_LOG_NOTICE, "-- Restart of interface completed\n"); + + for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { + chan = ftdm_span_get_channel(span, i); + if (!chan) + continue; + if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { + ftdm_libpri_b_chan_t *chan_priv = chan->call_data; + if (!(chan_priv->flags & FTDM_LIBPRI_B_REMOTE_RESTART)) { + ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_DOWN); + } + } + } + } + else if ((chan = ftdm_span_get_channel(span, pevent->restart.channel))) { + ftdm_log_chan_msg(chan, FTDM_LOG_NOTICE, "-- Restart of channel completed\n"); + ftdm_set_state_locked(chan, FTDM_CHANNEL_STATE_DOWN); + } + else { + ftdm_log(FTDM_LOG_ERROR, "Invalid restart indicator / channel id '%d' received\n", + pevent->restartack.channel); + } + + _ftdm_channel_set_state_force(spri->dchan, FTDM_CHANNEL_STATE_UP); + return 0; +} + + + + /* * FACILITY Advice-On-Charge handler */ @@ -2117,6 +2317,7 @@ static int on_dchan_up(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_ev if (!ftdm_test_flag(spri, LPWRAP_PRI_READY)) { ftdm_signaling_status_t status = FTDM_SIG_STATE_UP; ftdm_span_t *span = spri->span; + ftdm_libpri_data_t *isdn_data = span->signal_data; ftdm_sigmsg_t sig; int i; @@ -2137,6 +2338,15 @@ static int on_dchan_up(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_ev sig.ev_data.sigstatus.status = status; ftdm_span_send_signal(span, &sig); } + + /* NT-mode idle b-channel restart timer */ + if (ftdm_span_get_trunk_type(span) != FTDM_TRUNK_BRI_PTMP && + isdn_data->mode == PRI_NETWORK && isdn_data->idle_restart_timeout_ms > 0) + { + ftdm_log_chan(isdn_data->dchan, FTDM_LOG_INFO, "Starting NT-mode idle b-channel restart timer (%d ms)\n", + isdn_data->idle_restart_timeout_ms); + lpwrap_start_timer(&isdn_data->spri, &isdn_data->t3xx, isdn_data->idle_restart_timeout_ms, &on_timeout_t3xx); + } } return 0; } @@ -2153,6 +2363,7 @@ static int on_dchan_down(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_ if (ftdm_test_flag(spri, LPWRAP_PRI_READY)) { ftdm_signaling_status_t status = FTDM_SIG_STATE_DOWN; ftdm_span_t *span = spri->span; + ftdm_libpri_data_t *isdn_data = span->signal_data; ftdm_sigmsg_t sig; int i; @@ -2173,9 +2384,19 @@ static int on_dchan_down(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_ sig.ev_data.sigstatus.status = status; ftdm_span_send_signal(span, &sig); - } - } + if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { + ftdm_libpri_b_chan_t *chan_priv = chan->call_data; + /* Stop T316 and reset counter */ + lpwrap_stop_timer(spri, &chan_priv->t316); + chan_priv->t316_timeout_cnt = 0; + } + } + + /* NT-mode idle b-channel restart timer */ + ftdm_log_chan_msg(isdn_data->dchan, FTDM_LOG_INFO, "Stopping NT-mode idle b-channel restart timer\n"); + lpwrap_stop_timer(&isdn_data->spri, &isdn_data->t3xx); + } return 0; } @@ -2224,110 +2445,88 @@ static void *ftdm_libpri_run(ftdm_thread_t *me, void *obj) ftdm_span_t *span = (ftdm_span_t *) obj; ftdm_libpri_data_t *isdn_data = span->signal_data; int down = 0; - int got_d = 0; int res = 0; + int i; ftdm_set_flag(span, FTDM_SPAN_IN_THREAD); + isdn_data->dchan = NULL; + /* + * Open D-Channel + */ + for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { + ftdm_channel_t *chan = ftdm_span_get_channel(span, i); + + if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_DQ921) { + if (ftdm_channel_open(ftdm_span_get_id(span), i, &isdn_data->dchan) == FTDM_SUCCESS) { + ftdm_log_chan_msg(chan, FTDM_LOG_DEBUG, "Opened D-Channel\n"); + break; + } else { + ftdm_log_chan_msg(chan, FTDM_LOG_CRIT, "Failed to open D-Channel\n"); + goto out; + } + } + } + + /* + * Initialize BRI/PRI context + */ + res = lpwrap_init_pri(&isdn_data->spri, span, isdn_data->dchan, + isdn_data->dialect, isdn_data->mode, isdn_data->debug_mask); + + if (res) { + ftdm_log(FTDM_LOG_CRIT, "Failed to initialize BRI/PRI on span %d\n", + ftdm_span_get_id(span)); + goto out; + } + +#ifdef HAVE_LIBPRI_AOC + /* + * Only enable facility on trunk if really required, + * this may help avoid problems on troublesome lines. + */ + if (isdn_data->opts & FTMOD_LIBPRI_OPT_FACILITY_AOC) { + pri_facility_enable(isdn_data->spri.pri); + } +#endif + /* Support the different switch of service status */ + if (isdn_data->service_message_support) { + pri_set_service_message_support(isdn_data->spri.pri, 1); + } + + /* Callbacks for libpri events */ + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_ANY, on_anything); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RING, on_ring); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RINGING, on_ringing); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_PROCEEDING, on_proceeding); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_PROGRESS, on_progress); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_ANSWER, on_answer); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_DCHAN_UP, on_dchan_up); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_DCHAN_DOWN, on_dchan_down); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_HANGUP_REQ, on_hangup); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_HANGUP_ACK, on_hangup); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_HANGUP, on_hangup); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_INFO_RECEIVED, on_information); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_KEYPAD_DIGIT, on_keypad_digit); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RESTART, on_restart); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RESTART_ACK, on_restart_ack); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_IO_FAIL, on_io_fail); + LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_FACILITY, on_facility); + + /* Callback invoked on each iteration of the lpwrap_run_pri() event loop */ + isdn_data->spri.on_loop = check_flags; + + /* + * Event loop + */ while (ftdm_running() && !ftdm_test_flag(span, FTDM_SPAN_STOP_THREAD)) { - if (!got_d) { - int i, x; - - for (i = 1, x = 0; i <= ftdm_span_get_chan_count(span); i++) { - ftdm_channel_t *chan = ftdm_span_get_channel(span, i); - - if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_DQ921) { - if (ftdm_channel_open(ftdm_span_get_id(span), i, &isdn_data->dchan) == FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_DEBUG, "opening D-Channel #%d %d:%d\n", x, - ftdm_channel_get_span_id(isdn_data->dchan), ftdm_channel_get_id(isdn_data->dchan)); - got_d = 1; - x++; - break; - } else { - ftdm_log(FTDM_LOG_ERROR, "failed to open D-Channel #%d %d:%d\n", x, - ftdm_channel_get_span_id(chan), ftdm_channel_get_id(chan)); - } - } - } - } - if (!got_d || !isdn_data->dchan) { - ftdm_log(FTDM_LOG_ERROR, "Failed to get a D-Channel in span %d\n", ftdm_span_get_id(span)); - break; + if (down) { + ftdm_log(FTDM_LOG_INFO, "PRI back up on span %d\n", ftdm_span_get_id(span)); + ftdm_set_state_all(span, FTDM_CHANNEL_STATE_RESTART); + down = 0; } - /* Initialize libpri trunk */ - switch (ftdm_span_get_trunk_type(span)) { - case FTDM_TRUNK_E1: - case FTDM_TRUNK_T1: - case FTDM_TRUNK_J1: - res = lpwrap_init_pri(&isdn_data->spri, span, isdn_data->dchan, - isdn_data->dialect, isdn_data->mode, isdn_data->debug_mask); - break; - case FTDM_TRUNK_BRI: - res = lpwrap_init_bri(&isdn_data->spri, span, isdn_data->dchan, - isdn_data->dialect, isdn_data->mode, 1, isdn_data->debug_mask); -#ifndef HAVE_LIBPRI_BRI - goto out; -#endif - break; - case FTDM_TRUNK_BRI_PTMP: - res = lpwrap_init_bri(&isdn_data->spri, span, isdn_data->dchan, - isdn_data->dialect, isdn_data->mode, 0, isdn_data->debug_mask); -#ifndef HAVE_LIBPRI_BRI - goto out; -#endif - break; - default: - snprintf(span->last_error, sizeof(span->last_error), "Invalid trunk type"); - goto out; - } - -#ifdef HAVE_LIBPRI_AOC - /* - * Only enable facility on trunk if really required, - * this may help avoid problems on troublesome lines. - */ - if (isdn_data->opts & FTMOD_LIBPRI_OPT_FACILITY_AOC) { - pri_facility_enable(isdn_data->spri.pri); - } -#endif - /* Support the different switch of service status */ - if (isdn_data->service_message_support) { - pri_set_service_message_support(isdn_data->spri.pri, 1 /* True */); - } - - if (res == 0) { - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_ANY, on_anything); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RING, on_ring); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RINGING, on_ringing); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_PROCEEDING, on_proceeding); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_PROGRESS, on_progress); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_ANSWER, on_answer); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_DCHAN_UP, on_dchan_up); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_DCHAN_DOWN, on_dchan_down); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_HANGUP_REQ, on_hangup); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_HANGUP_ACK, on_hangup); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_HANGUP, on_hangup); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_INFO_RECEIVED, on_info); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_RESTART, on_restart); - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_IO_FAIL, on_io_fail); -#ifdef HAVE_LIBPRI_AOC - LPWRAP_MAP_PRI_EVENT(isdn_data->spri, LPWRAP_PRI_EVENT_FACILITY, on_facility); -#endif - if (down) { - ftdm_log(FTDM_LOG_INFO, "PRI back up on span %d\n", ftdm_span_get_id(span)); - ftdm_set_state_all(span, FTDM_CHANNEL_STATE_RESTART); - down = 0; - } - - isdn_data->spri.on_loop = check_flags; - - lpwrap_run_pri(&isdn_data->spri); - } else { - ftdm_log(FTDM_LOG_CRIT, "PRI init failed!\n"); - snprintf(span->last_error, sizeof(span->last_error), "PRI init failed!"); - break; - } + lpwrap_run_pri(&isdn_data->spri); if (!ftdm_running() || ftdm_test_flag(span, FTDM_SPAN_STOP_THREAD)) { break; @@ -2353,8 +2552,7 @@ out: /* close d-channel, if set */ if (isdn_data->dchan) { if (ftdm_channel_close(&isdn_data->dchan) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "Failed to close D-Channel %d:%d\n", - ftdm_channel_get_span_id(isdn_data->dchan), ftdm_channel_get_id(isdn_data->dchan)); + ftdm_log_chan_msg(isdn_data->dchan, FTDM_LOG_ERROR, "Failed to close D-Channel\n"); } } @@ -2363,6 +2561,7 @@ out: ftdm_clear_flag(span, FTDM_SPAN_IN_THREAD); ftdm_clear_flag(isdn_data, FTMOD_LIBPRI_RUNNING); + lpwrap_destroy_pri(&isdn_data->spri); return NULL; } @@ -2381,11 +2580,14 @@ static ftdm_status_t ftdm_libpri_stop(ftdm_span_t *span) return FTDM_FAIL; } - ftdm_set_state_all(span, FTDM_CHANNEL_STATE_RESTART); + ftdm_log(FTDM_LOG_INFO, "Stopping span [s%d][%s]\n", + ftdm_span_get_id(span), ftdm_span_get_name(span)); + ftdm_set_state_all(span, FTDM_CHANNEL_STATE_RESTART); check_state(span); ftdm_set_flag(span, FTDM_SPAN_STOP_THREAD); + lpwrap_stop_pri(&isdn_data->spri); while (ftdm_test_flag(span, FTDM_SPAN_IN_THREAD)) { ftdm_sleep(100); @@ -2411,6 +2613,9 @@ static ftdm_status_t ftdm_libpri_start(ftdm_span_t *span) return FTDM_FAIL; } + ftdm_log(FTDM_LOG_INFO, "Starting span [s%d][%s]\n", + ftdm_span_get_id(span), ftdm_span_get_name(span)); + ftdm_clear_flag(span, FTDM_SPAN_STOP_THREAD); ftdm_clear_flag(span, FTDM_SPAN_IN_THREAD); @@ -2542,6 +2747,53 @@ static uint32_t parse_opts(const char *in) return flags; } +/** + * Parse timeout value with (convenience) modifier suffix + * \param[in] in Input string, e.g. '1d' = 1 day, '7w' = 7 weeks, '3s' = 3 seconds + * \todo Could be simplified by using strtol() instead of atoi() + */ +static int parse_timeout(const char *in) +{ + const char *p_end = NULL, *p_start = in; + int msec = 0; + + if (ftdm_strlen_zero(in)) + return 0; + + p_end = in + strlen(in); + + /* skip whitespace at start */ + while (p_start != p_end && *p_start == ' ') + p_start++; + + /* skip whitespace at end */ + while (p_end != p_start && (*p_end == ' ' || *p_end == '\0')) + p_end--; + + msec = atoi(p_start); + + switch (p_end[0]) { + case 's': /* seconds */ + msec *= 1000; + break; + case 'm': /* minutes */ + if (p_end[1] != 's') msec *= 60 * 1000; + break; + case 'h': /* hours */ + msec *= 3600 * 1000; + break; + case 'd': /* days */ + msec *= 86400 * 1000; + break; + case 'w': /* weeks */ + msec *= 604800 * 1000; + break; + default: /* miliseconds */ + break; + } + return msec; +} + /** * \brief Initialises a libpri span from configuration variables * \param span Span to configure @@ -2552,7 +2804,6 @@ static uint32_t parse_opts(const char *in) static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) { ftdm_libpri_data_t *isdn_data = NULL; - //ftdm_channel_t *dchan = NULL; uint32_t bchan_count = 0; uint32_t dchan_count = 0; uint32_t i; @@ -2569,23 +2820,10 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) case FTDM_CHAN_TYPE_DQ921: if (dchan_count > 1) { ftdm_log(FTDM_LOG_ERROR, "Span has more than 2 D-Channels!\n"); - snprintf(span->last_error, sizeof(span->last_error), "Span has more than 2 D-Channels!"); return FTDM_FAIL; - } else { -#if 0 - if (ftdm_channel_open(ftdm_span_get_id(span), i, &dchan) == FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_DEBUG, "opening D-Channel %d:%d\n", ftdm_channel_get_span_id(dchan), ftdm_channel_get_id(dchan)); - _ftdm_channel_set_state_force(dchan, FTDM_CHANNEL_STATE_UP); - } else { - ftdm_log(FTDM_LOG_ERROR, "Failed to open D-Channel %d:%d\n", ftdm_channel_get_span_id(chan), ftdm_channel_getid(chan)); - snprintf(span->last_error, sizeof(span->last_error), "Failed to open D-Channel %d:%d\n", ftdm_channel_get_span_id(chan), ftdm_channel_getid(chan)); - return FTDM_FAIL; - } -#endif - dchan_count++; } + dchan_count++; break; - case FTDM_CHAN_TYPE_B: bchan_count++; break; @@ -2595,12 +2833,10 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) } if (!dchan_count) { ftdm_log(FTDM_LOG_ERROR, "Span has no D-Channel!\n"); - snprintf(span->last_error, sizeof(span->last_error), "Span has no D-Channel!"); return FTDM_FAIL; } if (!bchan_count) { ftdm_log(FTDM_LOG_ERROR, "Span has no B-Channels!\n"); - snprintf(span->last_error, sizeof(span->last_error), "Span has no B-Channels!"); return FTDM_FAIL; } @@ -2609,7 +2845,17 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) memset(isdn_data, 0, sizeof(*isdn_data)); /* set some default values */ - isdn_data->ton = PRI_UNKNOWN; + isdn_data->ton = PRI_UNKNOWN; + isdn_data->overlap_timeout_ms = OVERLAP_TIMEOUT_MS_DEFAULT; + isdn_data->idle_restart_timeout_ms = IDLE_RESTART_TIMEOUT_MS_DEFAULT; + + /* + * T316 restart ack timeout and retry limit + * (ITU-T Q.931 05/98 Paragraph 5.5.1 and Table 9-1) + */ + isdn_data->t316_timeout_ms = T316_TIMEOUT_MS_DEFAULT; + isdn_data->t316_max_attempts = T316_ATTEMPT_LIMIT_DEFAULT; + /* Use span's trunk_mode as a reference for the default libpri mode */ if (ftdm_span_get_trunk_mode(span) == FTDM_TRUNK_MODE_NET) { @@ -2623,7 +2869,6 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) case FTDM_TRUNK_BRI_PTMP: #ifndef HAVE_LIBPRI_BRI ftdm_log(FTDM_LOG_ERROR, "Unsupported trunk type: '%s', libpri too old\n", ftdm_span_get_trunk_type_str(span)); - snprintf(span->last_error, sizeof(span->last_error), "Unsupported trunk type [%s], libpri too old", ftdm_span_get_trunk_type_str(span)); goto error; #endif case FTDM_TRUNK_E1: @@ -2639,7 +2884,6 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) break; default: ftdm_log(FTDM_LOG_ERROR, "Invalid trunk type: '%s'\n", ftdm_span_get_trunk_type_str(span)); - snprintf(span->last_error, sizeof(span->last_error), "Invalid trunk type [%s]", ftdm_span_get_trunk_type_str(span)); goto error; } @@ -2648,7 +2892,6 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) */ if (msn_filter_init(isdn_data) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_ERROR, "Failed to init MSN filter\n"); - snprintf(span->last_error, sizeof(span->last_error), "Failed to init MSN filter"); goto error; } @@ -2663,7 +2906,6 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) if (ftdm_strlen_zero(val)) { ftdm_log(FTDM_LOG_ERROR, "Parameter '%s' has no value\n", var); - snprintf(span->last_error, sizeof(span->last_error), "Parameter [%s] has no value", var); goto error; } @@ -2691,6 +2933,52 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) isdn_data->overlap = FTMOD_LIBPRI_OVERLAP_NONE; } } + else if (!strcasecmp(var, "digit_timeout") || !strcasecmp(var, "t302")) { + int tmp = parse_timeout(val); + if (!tmp) { + isdn_data->overlap_timeout_ms = 0; /* disabled */ + } + else if ((isdn_data->overlap_timeout_ms = ftdm_clamp(tmp, OVERLAP_TIMEOUT_MS_MIN, OVERLAP_TIMEOUT_MS_MAX)) != tmp) { + ftdm_log(FTDM_LOG_WARNING, "'%s' value %d ms ('%s') outside of range [%d:%d] ms, using %d ms instead\n", + var, tmp, val, OVERLAP_TIMEOUT_MS_MIN, OVERLAP_TIMEOUT_MS_MAX, + isdn_data->overlap_timeout_ms); + } + } + else if (!strcasecmp(var, "idle_restart_interval")) { + int tmp = parse_timeout(val); + if (!tmp) { + isdn_data->idle_restart_timeout_ms = 0; /* disabled */ + } + else if ((isdn_data->idle_restart_timeout_ms = ftdm_clamp(tmp, IDLE_RESTART_TIMEOUT_MS_MIN, IDLE_RESTART_TIMEOUT_MS_MAX)) != tmp) { + ftdm_log(FTDM_LOG_WARNING, "'%s' value %d ms ('%s') outside of range [%d:%d] ms, using %d ms instead\n", + var, tmp, val, IDLE_RESTART_TIMEOUT_MS_MIN, IDLE_RESTART_TIMEOUT_MS_MAX, + isdn_data->idle_restart_timeout_ms); + } + } + else if (!strcasecmp(var, "restart_timeout") || !strcasecmp(var, "t316")) { + int tmp = parse_timeout(val); + if (tmp <= 0) { + ftdm_log(FTDM_LOG_ERROR, "'%s' value '%s' is invalid\n", var, val); + goto error; + } + else if ((isdn_data->t316_timeout_ms = ftdm_clamp(tmp, T316_TIMEOUT_MS_MIN, T316_TIMEOUT_MS_MAX)) != tmp) { + ftdm_log(FTDM_LOG_WARNING, "'%s' value %d ms ('%s') outside of range [%d:%d] ms, using %d ms instead\n", + var, tmp, val, T316_TIMEOUT_MS_MIN, T316_TIMEOUT_MS_MAX, + isdn_data->t316_timeout_ms); + } + } + else if (!strcasecmp(var, "restart_attempts") || !strcasecmp(var, "t316_limit")) { + int tmp = atoi(val); + if (tmp <= 0) { + ftdm_log(FTDM_LOG_ERROR, "'%s' value '%s' is invalid\n", var, val); + goto error; + } + else if ((isdn_data->t316_max_attempts = ftdm_clamp(tmp, T316_ATTEMPT_LIMIT_MIN, T316_ATTEMPT_LIMIT_MAX)) != tmp) { + ftdm_log(FTDM_LOG_WARNING, "'%s' value %d ('%s') outside of range [%d:%d], using %d instead\n", + var, tmp, val, T316_ATTEMPT_LIMIT_MIN, T316_ATTEMPT_LIMIT_MAX, + isdn_data->t316_max_attempts); + } + } else if (!strcasecmp(var, "debug")) { if (parse_debug(val, &isdn_data->debug_mask) == -1) { ftdm_log(FTDM_LOG_ERROR, "Invalid debug flag, ignoring parameter\n"); @@ -2705,13 +2993,11 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) else if (!strcasecmp(var, "local-number") || !strcasecmp(var, "msn")) { if (msn_filter_add(isdn_data, val) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_ERROR, "Invalid MSN/DDI(s) '%s' specified\n", val); - snprintf(span->last_error, sizeof(span->last_error), "Invalid MSN/DDI(s) '%s' specified!", val); goto error; } } else { ftdm_log(FTDM_LOG_ERROR, "Unknown parameter '%s', aborting configuration\n", var); - snprintf(span->last_error, sizeof(span->last_error), "Unknown parameter [%s]", var); goto error; } } @@ -2748,8 +3034,28 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_libpri_configure_span) ftdm_set_flag(span, FTDM_SPAN_SUGGEST_CHAN_ID); } + /* Allocate per-channel private data */ + for (i = 1; i <= ftdm_span_get_chan_count(span); i++) { + ftdm_channel_t *chan = ftdm_span_get_channel(span, i); + + if (!chan) + continue; + + if (ftdm_channel_get_type(chan) == FTDM_CHAN_TYPE_B) { + ftdm_libpri_b_chan_t *priv = NULL; + + priv = calloc(1, sizeof(*priv)); + if (!priv) { + ftdm_log_chan_msg(chan, FTDM_LOG_CRIT, "Failed to allocate per-channel private data\n"); + goto error; + } + priv->channel = chan; + chan->call_data = priv; + } + } return FTDM_SUCCESS; error: + /* TODO: free per-channel private data */ msn_filter_destroy(isdn_data); ftdm_safe_free(isdn_data); return FTDM_FAIL; diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.h b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.h index 260df0fe35..f439694886 100644 --- a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.h +++ b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.h @@ -35,6 +35,27 @@ #include "freetdm.h" #include "lpwrap_pri.h" +/* T302 Overlap receiving inter-digit timeout */ +#define OVERLAP_TIMEOUT_MS_DEFAULT 5000 /* 5 sec */ +#define OVERLAP_TIMEOUT_MS_MIN 3000 /* 3 sec */ +#define OVERLAP_TIMEOUT_MS_MAX 30000 /* 30 sec */ + +/* NT-mode idle b-channel restart timer */ +#define IDLE_RESTART_TIMEOUT_MS_DEFAULT 900000 /* 15 min */ +#define IDLE_RESTART_TIMEOUT_MS_MIN 10000 /* 10 sec */ +#define IDLE_RESTART_TIMEOUT_MS_MAX 86400000 /* 1 day */ + +/* T316 RESTART ACK wait timer */ +#define T316_TIMEOUT_MS_DEFAULT 30000 /* 30 sec */ +#define T316_TIMEOUT_MS_MIN 10000 /* 10 sec */ +#define T316_TIMEOUT_MS_MAX 300000 /* 5 min */ + +/* T316 restart attempts until channel is suspended */ +#define T316_ATTEMPT_LIMIT_DEFAULT 3 +#define T316_ATTEMPT_LIMIT_MIN 1 +#define T316_ATTEMPT_LIMIT_MAX 10 + + typedef enum { SERVICE_CHANGE_STATUS_INSERVICE = 0, SERVICE_CHANGE_STATUS_MAINTENANCE, @@ -71,6 +92,10 @@ struct ftdm_libpri_data { int mode; int dialect; int overlap; /*!< Overlap dial flags */ + int overlap_timeout_ms; /*!< Overlap dial timeout */ + int idle_restart_timeout_ms; /*!< NT-mode idle b-channel restart */ + int t316_timeout_ms; /*!< T316 RESTART ACK timeout */ + int t316_max_attempts; /*!< T316 timeout limit */ unsigned int layer1; unsigned int ton; unsigned int service_message_support; @@ -80,10 +105,36 @@ struct ftdm_libpri_data { /* MSN filter */ ftdm_hash_t *msn_hash; ftdm_mutex_t *msn_mutex; + + /* NT-mode idle restart timer */ + struct lpwrap_timer t3xx; }; typedef struct ftdm_libpri_data ftdm_libpri_data_t; + +/* + * b-channel flags + */ +enum { + FTDM_LIBPRI_B_NONE = 0, + FTDM_LIBPRI_B_REMOTE_RESTART = (1 << 0), /*!< Remote triggered channel restart */ +}; + +/** + * Per-b-channel private data + */ +struct ftdm_libpri_b_chan { + struct lpwrap_timer t302; /*!< T302 overlap receive timer */ + struct lpwrap_timer t316; /*!< T316 restart ack timer */ + ftdm_channel_t *channel; /*!< back-pointer to b-channel */ + q931_call *call; /*!< libpri opaque call handle */ + uint32_t flags; /*!< channel flags */ + uint32_t t316_timeout_cnt; /*!< T316 timeout counter */ +}; + +typedef struct ftdm_libpri_b_chan ftdm_libpri_b_chan_t; + #endif /* For Emacs: diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c b/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c index facbc27033..fb478901b3 100644 --- a/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c +++ b/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.c @@ -36,51 +36,7 @@ #include "private/ftdm_core.h" #include "lpwrap_pri.h" -#ifndef HAVE_GETTIMEOFDAY -#ifdef WIN32 -#include - -static __inline int gettimeofday(struct timeval *tp, void *nothing) -{ -#ifdef WITHOUT_MM_LIB - SYSTEMTIME st; - time_t tt; - struct tm tmtm; - /* mktime converts local to UTC */ - GetLocalTime (&st); - tmtm.tm_sec = st.wSecond; - tmtm.tm_min = st.wMinute; - tmtm.tm_hour = st.wHour; - tmtm.tm_mday = st.wDay; - tmtm.tm_mon = st.wMonth - 1; - tmtm.tm_year = st.wYear - 1900; tmtm.tm_isdst = -1; - tt = mktime (&tmtm); - tp->tv_sec = tt; - tp->tv_usec = st.wMilliseconds * 1000; -#else - /** - ** The earlier time calculations using GetLocalTime - ** had a time resolution of 10ms.The timeGetTime, part - ** of multimedia apis offer a better time resolution - ** of 1ms.Need to link against winmm.lib for this - **/ - unsigned long Ticks = 0; - unsigned long Sec =0; - unsigned long Usec = 0; - Ticks = timeGetTime(); - - Sec = Ticks/1000; - Usec = (Ticks - (Sec*1000))*1000; - tp->tv_sec = Sec; - tp->tv_usec = Usec; -#endif /* WITHOUT_MM_LIB */ - (void)nothing; - return 0; -} -#endif /* WIN32 */ -#endif /* HAVE_GETTIMEOFDAY */ - -static struct lpwrap_pri_event_list LPWRAP_PRI_EVENT_LIST[] = { +static struct lpwrap_pri_event_list LPWRAP_PRI_EVENT_LIST[LPWRAP_PRI_EVENT_MAX] = { {0, LPWRAP_PRI_EVENT_ANY, "ANY"}, {1, LPWRAP_PRI_EVENT_DCHAN_UP, "DCHAN_UP"}, {2, LPWRAP_PRI_EVENT_DCHAN_DOWN, "DCHAN_DOWN"}, @@ -103,8 +59,6 @@ static struct lpwrap_pri_event_list LPWRAP_PRI_EVENT_LIST[] = { {19, LPWRAP_PRI_EVENT_IO_FAIL, "IO_FAIL"}, }; -#define LINE "--------------------------------------------------------------------------------" - const char *lpwrap_pri_event_str(lpwrap_pri_event_t event_id) { if (event_id < 0 || event_id >= LPWRAP_PRI_EVENT_MAX) @@ -170,6 +124,10 @@ static int __pri_lpwrap_write(struct pri *pri, void *buf, int buflen) return (int)buflen; } + +/* + * Unified init function for BRI + PRI libpri spans + */ int lpwrap_init_pri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int debug) { int ret = -1; @@ -179,115 +137,257 @@ int lpwrap_init_pri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t * spri->span = span; if (!spri->dchan) { - ftdm_log(FTDM_LOG_ERROR, "No D-Channel available, unable to create PRI\n"); + ftdm_log(FTDM_LOG_ERROR, "No D-Channel available, unable to create BRI/PRI\n"); return ret; } - if ((spri->pri = pri_new_cb(spri->dchan->sockfd, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri))) { - unsigned char buf[4] = { 0 }; - size_t buflen = sizeof(buf), len = 0; - - pri_set_debug(spri->pri, debug); -#ifdef HAVE_LIBPRI_AOC - pri_aoc_events_enable(spri->pri, 1); -#endif - ftdm_channel_write(spri->dchan, buf, buflen, &len); - - ret = 0; - } else { - ftdm_log(FTDM_LOG_ERROR, "Unable to create PRI\n"); + if (ftdm_mutex_create(&spri->timer_mutex) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_ERROR, "Failed to create timer list mutex\n"); + return ret; } - return ret; -} - -int lpwrap_init_bri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int ptp, int debug) -{ - int ret = -1; + switch (ftdm_span_get_trunk_type(span)) { + case FTDM_TRUNK_E1: + case FTDM_TRUNK_J1: + case FTDM_TRUNK_T1: + spri->pri = pri_new_cb(spri->dchan->sockfd, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri); + break; #ifdef HAVE_LIBPRI_BRI - memset(spri, 0, sizeof(struct lpwrap_pri)); - spri->dchan = dchan; - spri->span = span; - - if (!spri->dchan) { - ftdm_log(FTDM_LOG_ERROR, "No D-Channel available, unable to create BRI\n"); + case FTDM_TRUNK_BRI: + spri->pri = pri_new_bri_cb(spri->dchan->sockfd, 1, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri); + break; + case FTDM_TRUNK_BRI_PTMP: + spri->pri = pri_new_bri_cb(spri->dchan->sockfd, 0, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri); + break; +#endif + default: + ftdm_log(FTDM_LOG_CRIT, "Invalid/unsupported trunk type '%s'\n", + ftdm_span_get_trunk_type_str(span)); + ftdm_mutex_destroy(&spri->timer_mutex); return ret; } - if ((spri->pri = pri_new_bri_cb(spri->dchan->sockfd, ptp, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri))) { - unsigned char buf[4] = { 0 }; - size_t buflen = sizeof(buf), len = 0; - + if (spri->pri) { pri_set_debug(spri->pri, debug); #ifdef HAVE_LIBPRI_AOC pri_aoc_events_enable(spri->pri, 1); #endif - ftdm_channel_write(spri->dchan, buf, buflen, &len); - ret = 0; } else { - ftdm_log(FTDM_LOG_ERROR, "Unable to create BRI\n"); + ftdm_log(FTDM_LOG_CRIT, "Unable to create BRI/PRI\n"); + ftdm_mutex_destroy(&spri->timer_mutex); } -#else - ftdm_log(FTDM_LOG_ERROR, "Installed libpri version (%s) has no BRI support\n", - pri_get_version()); -#endif return ret; } -int lpwrap_one_loop(struct lpwrap_pri *spri) +#define timeval_to_ms(x) \ + (((ftdm_time_t)(x)->tv_sec * 1000) + (ftdm_time_t)((x)->tv_usec / 1000)) + +int lpwrap_start_timer(struct lpwrap_pri *spri, struct lpwrap_timer *timer, const uint32_t timeout_ms, timeout_handler callback) { - fd_set rfds, efds; - struct timeval now = {0,0}, *next = NULL; + struct lpwrap_timer **prev, *cur; + + if (!spri || !timer || timer->timeout) + return -1; + + ftdm_log_chan(spri->dchan, FTDM_LOG_DEBUG, "-- Starting timer %p with timeout %u ms\n", + timer, timeout_ms); + + timer->timeout = ftdm_current_time_in_ms() + timeout_ms; + timer->callback = callback; + timer->next = NULL; + + ftdm_mutex_lock(spri->timer_mutex); + + for (prev = &spri->timer_list, cur = spri->timer_list; cur; prev = &(*prev)->next, cur = cur->next) { + if (cur->timeout < timer->timeout) { + *prev = timer; + timer->next = cur; + break; + } + } + if (!cur) { + *prev = timer; + } + + ftdm_mutex_unlock(spri->timer_mutex); + return 0; +} + +int lpwrap_stop_timer(struct lpwrap_pri *spri, struct lpwrap_timer *timer) +{ + struct lpwrap_timer **prev, *cur; + + if (!spri || !timer) + return -1; + + if (!timer->timeout) + return 0; + + ftdm_log_chan(spri->dchan, FTDM_LOG_DEBUG, "-- Stopping timer %p\n", timer); + + ftdm_mutex_lock(spri->timer_mutex); + + for (prev = &spri->timer_list, cur = spri->timer_list; cur; prev = &(*prev)->next, cur = cur->next) { + if (cur == timer) { + *prev = cur->next; + break; + } + } + + ftdm_mutex_unlock(spri->timer_mutex); + + timer->next = NULL; + timer->timeout = 0; + timer->callback = NULL; + return 0; +} + +static struct lpwrap_timer *lpwrap_timer_next(struct lpwrap_pri *spri) +{ + return spri ? spri->timer_list : NULL; +} + +static int lpwrap_run_expired(struct lpwrap_pri *spri, ftdm_time_t now_ms) +{ + struct lpwrap_timer *expired_list = NULL; + struct lpwrap_timer **prev, *cur; + + if (!spri || !spri->timer_list) + return 0; + + ftdm_mutex_lock(spri->timer_mutex); + + /* Move all timers to expired list */ + expired_list = spri->timer_list; + + for (prev = &expired_list, cur = expired_list; cur; prev = &(*prev)->next, cur = cur->next) { + if (cur->timeout > now_ms) { + *prev = NULL; + break; + } + } + /* Move non-expired timer to front of timer_list (or clear list if there are none) */ + spri->timer_list = cur; + + ftdm_mutex_unlock(spri->timer_mutex); + + /* fire callbacks */ + while ((cur = expired_list)) { + timeout_handler handler = cur->callback; + expired_list = cur->next; + + /* Stop timer */ + cur->next = NULL; + cur->timeout = 0; + cur->callback = NULL; + + if (handler) + handler(spri, cur); + } + return 0; +} + + +#define LPWRAP_MAX_TIMEOUT_MS 100 +#define LPWRAP_MAX_ERRORS 2 + +int lpwrap_run_pri_once(struct lpwrap_pri *spri) +{ + struct timeval *next = NULL; + struct lpwrap_timer *timer = NULL; pri_event *event = NULL; - event_handler handler; - int sel; + ftdm_wait_flag_t flags; + ftdm_time_t now_ms, next_ms, timeout_ms, tmp_ms; + int ret; if (spri->on_loop) { - if ((sel = spri->on_loop(spri)) < 0) { - return sel; + if ((ret = spri->on_loop(spri)) < 0) + return FTDM_FAIL; + } + + /* Default timeout when no scheduled events are pending */ + timeout_ms = LPWRAP_MAX_TIMEOUT_MS; + next_ms = 0; + now_ms = ftdm_current_time_in_ms(); + + /* + * Get the next scheduled timer from libpri to set the maximum timeout, + * but limit it to MAX_TIMEOUT_MS (100ms). + */ + if ((next = pri_schedule_next(spri->pri))) { + next_ms = timeval_to_ms(next); + if (now_ms >= next_ms) { + /* Already late, handle timeout */ + timeout_ms = 0; + } else { + /* Calculate new timeout and limit it to MAX_TIMEOUT_MS miliseconds */ + tmp_ms = ftdm_min(next_ms - now_ms, LPWRAP_MAX_TIMEOUT_MS); + timeout_ms = ftdm_min(timeout_ms, tmp_ms); } } - if (spri->errs >= 2) { - spri->errs = 0; - return -1; + /* + * Next lpwrap_timer timeout + */ + if ((timer = lpwrap_timer_next(spri))) { + if (now_ms >= timer->timeout) { + /* Already late, handle timeout */ + timeout_ms = 0; + } else { + /* Calculate new timeout and limit it to MAX_TIMEOUT_MS miliseconds */ + tmp_ms = ftdm_min(timer->timeout - now_ms, LPWRAP_MAX_TIMEOUT_MS); + timeout_ms = ftdm_min(timeout_ms, tmp_ms); + } } - FD_ZERO(&rfds); - FD_ZERO(&efds); + /* */ + if (timeout_ms > 0) { + flags = FTDM_READ | FTDM_EVENTS; + ret = ftdm_channel_wait(spri->dchan, &flags, timeout_ms); -#ifdef _MSC_VER - //Windows macro for FD_SET includes a warning C4127: conditional expression is constant -#pragma warning(push) -#pragma warning(disable:4127) -#endif + if (spri->flags & LPWRAP_PRI_ABORT) + return FTDM_SUCCESS; - FD_SET(pri_fd(spri->pri), &rfds); - FD_SET(pri_fd(spri->pri), &efds); + if (ret == FTDM_TIMEOUT) { + now_ms = ftdm_current_time_in_ms(); -#ifdef _MSC_VER -#pragma warning(pop) -#endif - - now.tv_sec = 0; - now.tv_usec = 100000; - - sel = select(pri_fd(spri->pri) + 1, &rfds, NULL, &efds, &now); - if (!sel) { - if ((next = pri_schedule_next(spri->pri))) { - gettimeofday(&now, NULL); - if (now.tv_sec >= next->tv_sec && (now.tv_usec >= next->tv_usec || next->tv_usec <= 100000)) { - //ftdm_log(FTDM_LOG_DEBUG, "Check event\n"); + if (next) { + if (next_ms < now_ms) { + ftdm_log_chan(spri->dchan, FTDM_LOG_DEBUG, "pri timer %d ms late\n", + (int)(now_ms - next_ms)); + } event = pri_schedule_run(spri->pri); } + if (timer) { + if (timer->timeout < now_ms) { + ftdm_log_chan(spri->dchan, FTDM_LOG_DEBUG, "lpwrap timer %d ms late\n", + (int)(now_ms - timer->timeout)); + } + lpwrap_run_expired(spri, now_ms); + } + } else if (flags & (FTDM_READ | FTDM_EVENTS)) { + event = pri_check_event(spri->pri); + } + } else { + /* + * Scheduled event has already expired, handle it immediately + */ + if (next) { + event = pri_schedule_run(spri->pri); + } + if (timer) { + lpwrap_run_expired(spri, now_ms); } - } else if (sel > 0) { - event = pri_check_event(spri->pri); } + if (spri->flags & LPWRAP_PRI_ABORT) + return FTDM_SUCCESS; + if (event) { + event_handler handler; + /* 0 is catchall event handler */ if (event->e < 0 || event->e >= LPWRAP_PRI_EVENT_MAX) { handler = spri->eventmap[0]; @@ -303,28 +403,47 @@ int lpwrap_one_loop(struct lpwrap_pri *spri) ftdm_log(FTDM_LOG_CRIT, "No event handler found for event %d.\n", event->e); } } - return sel; + + return FTDM_SUCCESS; } int lpwrap_run_pri(struct lpwrap_pri *spri) { int ret = 0; - for (;;) { - if ((ret = lpwrap_one_loop(spri)) < 0) { -#ifndef WIN32 //This needs to be adressed fror WIN32 still - if (errno == EINTR){ - /* Igonore an interrupted system call */ - continue; - } -#endif - ftdm_log(FTDM_LOG_CRIT, "Error = %i [%s]\n", ret, strerror(errno)); + while (!(spri->flags & LPWRAP_PRI_ABORT)) { + ret = lpwrap_run_pri_once(spri); + if (ret) { + ftdm_log(FTDM_LOG_ERROR, "Error = %d, [%s]\n", + ret, strerror(errno)); + spri->errs++; + } else { + spri->errs = 0; + } + if (!ftdm_running()) + break; + if (spri->errs >= LPWRAP_MAX_ERRORS) { + ftdm_log(FTDM_LOG_CRIT, "Too many errors on span, restarting\n"); + spri->errs = 0; break; } } return ret; } +int lpwrap_stop_pri(struct lpwrap_pri *spri) +{ + spri->flags |= LPWRAP_PRI_ABORT; + return FTDM_SUCCESS; +} + +int lpwrap_destroy_pri(struct lpwrap_pri *spri) +{ + if (spri->timer_mutex) + ftdm_mutex_destroy(&spri->timer_mutex); + return FTDM_SUCCESS; +} + /* For Emacs: * Local Variables: * mode:c diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.h b/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.h index 052f3b080d..89708da270 100644 --- a/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.h +++ b/libs/freetdm/src/ftmod/ftmod_libpri/lpwrap_pri.h @@ -92,10 +92,14 @@ typedef enum { } lpwrap_pri_switch_t; typedef enum { - LPWRAP_PRI_READY = (1 << 0) + LPWRAP_PRI_READY = (1 << 0), + LPWRAP_PRI_ABORT = (1 << 1) } lpwrap_pri_flag_t; struct lpwrap_pri; +struct lpwrap_timer; + +typedef int (*timeout_handler)(struct lpwrap_pri *, struct lpwrap_timer *); typedef int (*event_handler)(struct lpwrap_pri *, lpwrap_pri_event_t, pri_event *); typedef int (*loop_handler)(struct lpwrap_pri *); @@ -108,6 +112,8 @@ struct lpwrap_pri { event_handler eventmap[LPWRAP_PRI_EVENT_MAX]; loop_handler on_loop; int errs; + struct lpwrap_timer *timer_list; + ftdm_mutex_t *timer_mutex; }; typedef struct lpwrap_pri lpwrap_pri_t; @@ -118,15 +124,21 @@ struct lpwrap_pri_event_list { const char *name; }; +struct lpwrap_timer { + struct lpwrap_timer *next; + ftdm_time_t timeout; + timeout_handler callback; +}; +int lpwrap_start_timer(struct lpwrap_pri *spri, struct lpwrap_timer *timer, const uint32_t timeout_ms, timeout_handler callback); +int lpwrap_stop_timer(struct lpwrap_pri *spri, struct lpwrap_timer *timer); #define LPWRAP_MAP_PRI_EVENT(spri, event, func) spri.eventmap[event] = func; - const char *lpwrap_pri_event_str(lpwrap_pri_event_t event_id); -int lpwrap_one_loop(struct lpwrap_pri *spri); -int lpwrap_init_pri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int debug); -int lpwrap_init_bri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int ptp, int debug); -int lpwrap_run_pri(struct lpwrap_pri *spri); -#define lpwrap_run_bri(x) lpwrap_run_pri(x) +int lpwrap_init_pri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int debug); +int lpwrap_destroy_pri(struct lpwrap_pri *spri); +int lpwrap_run_pri_once(struct lpwrap_pri *spri); +int lpwrap_run_pri(struct lpwrap_pri *spri); +int lpwrap_stop_pri(struct lpwrap_pri *spri); #endif diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c index 5e1c414a23..65f17fa47b 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c @@ -281,8 +281,8 @@ ftdm_state_map_t sangoma_isdn_state_map = { static void ftdm_sangoma_isdn_process_phy_events(ftdm_span_t *span, ftdm_oob_event_t event) { sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; - sngisdn_snd_event(signal_data->dchan, event); - + sngisdn_snd_event(signal_data, event); + switch (event) { /* Check if the span woke up from power-saving mode */ case FTDM_OOB_ALARM_CLEAR: @@ -354,7 +354,6 @@ static void *ftdm_sangoma_isdn_io_run(ftdm_thread_t *me, void *obj) short *poll_events = ftdm_malloc(sizeof(short) * span->chan_count); /* Initialize the d-channel */ - ftdm_assert(((sngisdn_span_data_t*)span->signal_data)->dchan, "Span does not have a dchannel"); chaniter = ftdm_span_get_chan_iterator(span, NULL); if (!chaniter) { ftdm_log(FTDM_LOG_CRIT, "Failed to allocate channel iterator for span %s!\n", span->name); @@ -1039,21 +1038,11 @@ static ftdm_status_t ftdm_sangoma_isdn_dtmf(ftdm_channel_t *ftdmchan, const char return FTDM_SUCCESS; } -static ftdm_status_t ftdm_sangoma_isdn_start(ftdm_span_t *span) +static ftdm_status_t ftdm_sangoma_isdn_perform_start(ftdm_span_t *span) { sngisdn_span_data_t *signal_data = span->signal_data; - ftdm_log(FTDM_LOG_INFO,"Starting span %s:%u.\n",span->name,span->span_id); - - ftdm_channel_set_feature(((sngisdn_span_data_t*)span->signal_data)->dchan, FTDM_CHANNEL_FEATURE_IO_STATS); - ftdm_channel_open_chan(((sngisdn_span_data_t*)span->signal_data)->dchan); - ftdm_sangoma_isdn_dchan_set_queue_size(((sngisdn_span_data_t*)span->signal_data)->dchan); - - if (sngisdn_stack_start(span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "Failed to start span %s\n", span->name); - return FTDM_FAIL; - } - + ftdm_log(FTDM_LOG_DEBUG, "Actually starting span:%s\n", span->name); /* clear the monitor thread stop flag */ ftdm_clear_flag(span, FTDM_SPAN_STOP_THREAD); ftdm_clear_flag(span, FTDM_SPAN_IN_THREAD); @@ -1085,12 +1074,64 @@ static ftdm_status_t ftdm_sangoma_isdn_start(ftdm_span_t *span) if (signal_data->restart_timeout) { ftdm_log(FTDM_LOG_DEBUG, "%s:Scheduling Restart timeout\n", signal_data->ftdm_span->name); ftdm_sched_timer(signal_data->sched, "restart_timeout", signal_data->restart_timeout, - sngisdn_restart_timeout, (void*) signal_data, &signal_data->timers[SNGISDN_SPAN_TIMER_RESTART]); + sngisdn_restart_timeout, (void*) signal_data, &signal_data->timers[SNGISDN_SPAN_TIMER_RESTART]); } + ftdm_log(FTDM_LOG_DEBUG,"Finished starting span %s\n", span->name); return FTDM_SUCCESS; } + +static ftdm_status_t ftdm_sangoma_isdn_start(ftdm_span_t *span) +{ + sngisdn_span_data_t *signal_data = span->signal_data; + + ftdm_log(FTDM_LOG_INFO,"Starting span %s:%u.\n",span->name,span->span_id); + + if (signal_data->dchan) { + ftdm_channel_set_feature(signal_data->dchan, FTDM_CHANNEL_FEATURE_IO_STATS); + ftdm_channel_open_chan(signal_data->dchan); + ftdm_sangoma_isdn_dchan_set_queue_size(signal_data->dchan); + } + + if (signal_data->nfas.trunk) { + if (signal_data->nfas.trunk->num_spans == signal_data->nfas.trunk->num_spans_configured) { + int i; + ftdm_log(FTDM_LOG_DEBUG, "Starting span for all spans within trunkgroup:%s\n", signal_data->nfas.trunk->name); + + sngisdn_stack_start(signal_data->nfas.trunk->dchan->ftdm_span); + ftdm_sangoma_isdn_perform_start(signal_data->nfas.trunk->dchan->ftdm_span); + + if (signal_data->nfas.trunk->backup) { + sngisdn_stack_start(signal_data->nfas.trunk->backup->ftdm_span); + ftdm_sangoma_isdn_perform_start(signal_data->nfas.trunk->backup->ftdm_span); + } + + for (i = 0; i < signal_data->nfas.trunk->num_spans; i++) { + if (signal_data->nfas.trunk->spans[i] && + signal_data->nfas.trunk->spans[i]->nfas.sigchan == SNGISDN_NFAS_DCHAN_NONE) { + sngisdn_stack_start(signal_data->nfas.trunk->spans[i]->ftdm_span); + ftdm_sangoma_isdn_perform_start(signal_data->nfas.trunk->spans[i]->ftdm_span); + } + } + + return FTDM_SUCCESS; + } else { + ftdm_log(FTDM_LOG_DEBUG, "Delaying span start until all spans within trunkgroup are started: %s\n", signal_data->nfas.trunk->name); + return FTDM_SUCCESS; + } + } + + if (sngisdn_stack_start(span) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_CRIT, "Failed to start span %s\n", span->name); + return FTDM_FAIL; + } + + ftdm_sangoma_isdn_perform_start(span); + + return FTDM_SUCCESS; +} + static ftdm_status_t ftdm_sangoma_isdn_stop(ftdm_span_t *span) { ftdm_iterator_t *chaniter = NULL; @@ -1138,13 +1179,13 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_isdn_span_config) ftdm_iterator_t *chaniter = NULL; ftdm_iterator_t *curr = NULL; - sngisdn_span_data_t *span_data; + sngisdn_span_data_t *signal_data; ftdm_log(FTDM_LOG_INFO, "Configuring ftmod_sangoma_isdn span = %s\n", span->name); - span_data = ftdm_calloc(1, sizeof(sngisdn_span_data_t)); - span_data->ftdm_span = span; - span->signal_data = span_data; + signal_data = ftdm_calloc(1, sizeof(sngisdn_span_data_t)); + signal_data->ftdm_span = span; + span->signal_data = signal_data; chaniter = ftdm_span_get_chan_iterator(span, NULL); for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { @@ -1160,79 +1201,98 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_isdn_span_config) return FTDM_FAIL; } - if (sngisdn_stack_cfg(span) != FTDM_SUCCESS) { + if (signal_data->nfas.trunk) { + if (signal_data->nfas.trunk->num_spans == ++signal_data->nfas.trunk->num_spans_configured) { + int i; + ftdm_log(FTDM_LOG_DEBUG, "Starting stack configuration for all spans within trunkgroup:%s\n", signal_data->nfas.trunk->name); + + sngisdn_stack_cfg(signal_data->nfas.trunk->dchan->ftdm_span); + if (signal_data->nfas.trunk->backup) { + sngisdn_stack_cfg(signal_data->nfas.trunk->backup->ftdm_span); + } + + for (i = 0; i < signal_data->nfas.trunk->num_spans; i++) { + if (signal_data->nfas.trunk->spans[i] && + signal_data->nfas.trunk->spans[i]->nfas.sigchan == SNGISDN_NFAS_DCHAN_NONE) { + sngisdn_stack_cfg(signal_data->nfas.trunk->spans[i]->ftdm_span); + } + } + } else { + ftdm_log(FTDM_LOG_DEBUG, "Delaying span stack configuration until all spans within trunkgroup are started:%s\n", signal_data->nfas.trunk->name); + } + } else if (sngisdn_stack_cfg(span) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "Sangoma ISDN Stack configuration failed\n"); return FTDM_FAIL; } - if (span_data->cid_name_method == SNGISDN_CID_NAME_AUTO) { - switch (span_data->switchtype) { + if (signal_data->cid_name_method == SNGISDN_CID_NAME_AUTO) { + switch (signal_data->switchtype) { case SNGISDN_SWITCH_EUROISDN: if (FTDM_SPAN_IS_BRI(span)) { - span_data->cid_name_method = SNGISDN_CID_NAME_USR_USR_IE; + signal_data->cid_name_method = SNGISDN_CID_NAME_USR_USR_IE; } else { - span_data->cid_name_method = SNGISDN_CID_NAME_DISPLAY_IE; + signal_data->cid_name_method = SNGISDN_CID_NAME_DISPLAY_IE; } break; case SNGISDN_SWITCH_DMS100: - span_data->cid_name_method = SNGISDN_CID_NAME_DISPLAY_IE; + signal_data->cid_name_method = SNGISDN_CID_NAME_DISPLAY_IE; break; case SNGISDN_SWITCH_NI2: case SNGISDN_SWITCH_5ESS: case SNGISDN_SWITCH_4ESS: - span_data->cid_name_method = SNGISDN_CID_NAME_FACILITY_IE; + signal_data->cid_name_method = SNGISDN_CID_NAME_FACILITY_IE; break; default: break; } } - if (span_data->send_cid_name == SNGISDN_OPT_DEFAULT) { - switch (span_data->switchtype) { + if (signal_data->send_cid_name == SNGISDN_OPT_DEFAULT) { + switch (signal_data->switchtype) { case SNGISDN_SWITCH_EUROISDN: #ifdef SNGISDN_SUPPORT_CALLING_NAME_IN_FACILITY case SNGISDN_SWITCH_NI2: case SNGISDN_SWITCH_5ESS: case SNGISDN_SWITCH_4ESS: #endif - if (span_data->signalling == SNGISDN_SIGNALING_NET) { - span_data->send_cid_name = SNGISDN_OPT_TRUE; + if (signal_data->signalling == SNGISDN_SIGNALING_NET) { + signal_data->send_cid_name = SNGISDN_OPT_TRUE; } else { - span_data->send_cid_name = SNGISDN_OPT_FALSE; + signal_data->send_cid_name = SNGISDN_OPT_FALSE; } break; case SNGISDN_SWITCH_DMS100: - span_data->send_cid_name = SNGISDN_OPT_TRUE; + signal_data->send_cid_name = SNGISDN_OPT_TRUE; break; #ifndef SNGISDN_SUPPORT_CALLING_NAME_IN_FACILITY case SNGISDN_SWITCH_NI2: case SNGISDN_SWITCH_5ESS: case SNGISDN_SWITCH_4ESS: - span_data->send_cid_name = SNGISDN_OPT_FALSE; + signal_data->send_cid_name = SNGISDN_OPT_FALSE; break; #endif default: - span_data->send_cid_name = SNGISDN_OPT_FALSE; + signal_data->send_cid_name = SNGISDN_OPT_FALSE; break; } - } else if (span_data->send_cid_name == SNGISDN_OPT_TRUE) { - switch (span_data->switchtype) { + } else if (signal_data->send_cid_name == SNGISDN_OPT_TRUE) { + switch (signal_data->switchtype) { case SNGISDN_SWITCH_NI2: case SNGISDN_SWITCH_5ESS: case SNGISDN_SWITCH_4ESS: #ifndef SNGISDN_SUPPORT_CALLING_NAME_IN_FACILITY ftdm_log(FTDM_LOG_WARNING, "Sending Calling Name in Facility IE not supported, please update your libsng_isdn library\n"); - span_data->send_cid_name = SNGISDN_OPT_FALSE; + signal_data->send_cid_name = SNGISDN_OPT_FALSE; #endif break; case SNGISDN_SWITCH_INSNET: /* Don't know how to transmit caller ID name on INSNET */ case SNGISDN_SWITCH_QSIG: /* It seems like QSIG does not support Caller ID */ - span_data->send_cid_name = SNGISDN_OPT_FALSE; + signal_data->send_cid_name = SNGISDN_OPT_FALSE; break; case SNGISDN_SWITCH_EUROISDN: break; default: - span_data->send_cid_name = SNGISDN_OPT_FALSE; + signal_data->send_cid_name = SNGISDN_OPT_FALSE; break; } } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h index 51cb0b02fd..fc93155ffa 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h @@ -58,7 +58,8 @@ /* Theoretical limit for MAX_SPANS_PER_NFAS_LINK is 31, but set to 8 for now to save some memory */ -#define MAX_SPANS_PER_NFAS_LINK 8 +#define MAX_SPANS_PER_NFAS_LINK 16 +#define MAX_NFAS_GROUPS 16 #define NUM_E1_CHANNELS_PER_SPAN 32 #define NUM_T1_CHANNELS_PER_SPAN 24 #define NUM_BRI_CHANNELS_PER_SPAN 2 @@ -66,6 +67,9 @@ #define SNGISDN_EVENT_POLL_RATE 100 #define SNGISDN_NUM_LOCAL_NUMBERS 8 #define SNGISDN_DCHAN_QUEUE_LEN 200 +#define MAX_NFAS_GROUP_NAME 50 + +#define NSG #ifndef MI_NOTIFY #define MI_NOTIFY 0x14 @@ -242,16 +246,25 @@ typedef struct sngisdn_chan_data { ftdm_size_t raw_data_len; } sngisdn_chan_data_t; +struct sngisdn_nfas_data; +typedef struct sngisdn_nfas_data sngisdn_nfas_data_t; + +typedef enum { + SNGISDN_NFAS_DCHAN_NONE, + SNGISDN_NFAS_DCHAN_PRIMARY, + SNGISDN_NFAS_DCHAN_BACKUP, +} sngisdn_nfas_sigchan_t; + /* Span specific data */ typedef struct sngisdn_span_data { ftdm_span_t *ftdm_span; ftdm_channel_t *dchan; uint8_t link_id; uint8_t switchtype; - uint8_t signalling; /* SNGISDN_SIGNALING_CPE or SNGISDN_SIGNALING_NET */ + uint8_t signalling; /* SNGISDN_SIGNALING_CPE or SNGISDN_SIGNALING_NET */ uint8_t cc_id; - uint8_t dchan_id; - uint8_t span_id; + ftdm_signaling_status_t sigstatus; + uint8_t tei; uint8_t min_digits; uint8_t trace_flags; /* TODO change to bit map of sngisdn_tracetype_t */ @@ -274,7 +287,7 @@ typedef struct sngisdn_span_data { uint8_t restart_timeout; uint8_t force_sending_complete; uint8_t cid_name_method; - uint8_t send_cid_name; + uint8_t send_cid_name; int32_t timer_t301; int32_t timer_t302; @@ -292,11 +305,20 @@ typedef struct sngisdn_span_data { int32_t timer_t318; int32_t timer_t319; int32_t timer_t322; - + char* local_numbers[SNGISDN_NUM_LOCAL_NUMBERS]; ftdm_timer_id_t timers[SNGISDN_NUM_SPAN_TIMERS]; ftdm_sched_t *sched; ftdm_queue_t *event_queue; + + struct nfas_info { + sngisdn_nfas_data_t *trunk; + sngisdn_nfas_sigchan_t sigchan; + uint8_t interface_id; + } nfas; + + uint32_t num_chans; + sngisdn_chan_data_t *channels[NUM_E1_CHANNELS_PER_SPAN]; } sngisdn_span_data_t; typedef struct sngisdn_event_data { @@ -331,19 +353,18 @@ typedef struct sngisdn_event_data { } sngisdn_event_data_t; -/* dchan_data can have more than 1 span when running NFAS */ -typedef struct sngisdn_dchan_data { - uint8_t num_spans; - sngisdn_span_data_t *spans[MAX_L1_LINKS+1]; - uint16_t num_chans; - /* worst case for number of channel is when using NFAS, and NFAS is only used on T1, - so we can use MAX_SPANS_PER_NFAS_LINK*NUM_T1_CHANNELS_PER_SPAN instead of - MAX_SPANS_PER_NFAS_LINK*NUM_E1_CHANNELS_PER_SPAN - */ - /* Never seen NFAS on E1 yet, so use NUM_T1_CHANNELS_PER_SPAN */ - /* b-channels are arranged by physical id's not logical */ - sngisdn_chan_data_t *channels[MAX_SPANS_PER_NFAS_LINK*NUM_T1_CHANNELS_PER_SPAN]; -}sngisdn_dchan_data_t; +struct sngisdn_nfas_data { + char name[MAX_NFAS_GROUP_NAME]; + + char dchan_span_name[20]; + sngisdn_span_data_t *dchan; /* Span that contains primary d-channel */ + + char backup_span_name[20]; + sngisdn_span_data_t *backup; /* Span that contains backup d-channel */ + uint8_t num_spans; /* Number of spans within this NFAS */ + uint8_t num_spans_configured; + sngisdn_span_data_t *spans[MAX_SPANS_PER_NFAS_LINK+1]; //indexed by logical span id +}; typedef struct sngisdn_cc { /* TODO: use flags instead of config_done and activation_done */ @@ -360,10 +381,10 @@ typedef struct sngisdn_cc { /* Global sngisdn data */ typedef struct ftdm_sngisdn_data { uint8_t gen_config_done; - uint8_t num_cc; /* 1 ent per switchtype */ - struct sngisdn_cc ccs[MAX_VARIANTS+1]; - uint8_t num_dchan; - sngisdn_dchan_data_t dchans[MAX_L1_LINKS+1]; + uint8_t num_cc; /* 1 ent per switchtype */ + struct sngisdn_cc ccs[MAX_VARIANTS+1]; + uint8_t num_nfas; + sngisdn_nfas_data_t nfass[MAX_NFAS_GROUPS+1]; sngisdn_span_data_t *spans[MAX_L1_LINKS+1]; /* spans are indexed by link_id */ #ifdef SANGOMA_ISDN_CHAN_ID_INVERT_BIT @@ -424,7 +445,7 @@ void sngisdn_snd_info_req(ftdm_channel_t *ftdmchan); void sngisdn_snd_status_enq(ftdm_channel_t *ftdmchan); void sngisdn_snd_restart(ftdm_channel_t *ftdmchan); void sngisdn_snd_data(ftdm_channel_t *dchan, uint8_t *data, ftdm_size_t len); -void sngisdn_snd_event(ftdm_channel_t *dchan, ftdm_oob_event_t event); +void sngisdn_snd_event(sngisdn_span_data_t *signal_data, ftdm_oob_event_t event); /* Inbound Call Control functions */ void sngisdn_rcv_con_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, ConEvnt *conEvnt, int16_t dChan, uint8_t ces); @@ -554,6 +575,7 @@ static __inline__ void sngisdn_set_flag(sngisdn_chan_data_t *sngisdn_info, sngis void handle_sng_log(uint8_t level, char *fmt,...); void sngisdn_delayed_setup(void* p_sngisdn_info); void sngisdn_delayed_release(void* p_sngisdn_info); +void sngisdn_delayed_release_nfas(void *p_sngisdn_info); void sngisdn_delayed_connect(void* p_sngisdn_info); void sngisdn_delayed_disconnect(void* p_sngisdn_info); void sngisdn_facility_timeout(void* p_sngisdn_info); @@ -565,6 +587,7 @@ ftdm_status_t sngisdn_stack_cfg(ftdm_span_t *span); ftdm_status_t sngisdn_stack_start(ftdm_span_t *span); ftdm_status_t sngisdn_stack_stop(ftdm_span_t *span); ftdm_status_t sngisdn_wake_up_phy(ftdm_span_t *span); +sngisdn_span_data_t *sngisdn_dchan(sngisdn_span_data_t *signal_data); ftdm_status_t sngisdn_show_l1_stats(ftdm_stream_handle_t *stream, ftdm_span_t *span); ftdm_status_t sngisdn_show_spans(ftdm_stream_handle_t *stream); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c index 151fe847f5..47da32d865 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c @@ -37,6 +37,7 @@ static ftdm_status_t parse_timer(const char* val, int32_t *target); static ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span); static ftdm_status_t parse_signalling(const char* signalling, ftdm_span_t *span); +static ftdm_status_t parse_trunkgroup(const char *_trunkgroup); static ftdm_status_t add_local_number(const char* val, ftdm_span_t *span); static ftdm_status_t parse_yesno(const char* var, const char* val, uint8_t *target); static ftdm_status_t set_switchtype_defaults(ftdm_span_t *span); @@ -81,7 +82,7 @@ static ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span unsigned i; ftdm_iterator_t *chaniter = NULL; ftdm_iterator_t *curr = NULL; - sngisdn_dchan_data_t *dchan_data; + //sngisdn_dchan_data_t *dchan_data; sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; switch(span->trunk_type) { @@ -133,13 +134,15 @@ static ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span ftdm_log(FTDM_LOG_ERROR, "%s:Unsupported trunktype:%s\n", span->name, ftdm_trunk_type2str(span->trunk_type)); return FTDM_FAIL; } + /* see if we have profile with this switch_type already */ - for (i=1; i <= g_sngisdn_data.num_cc; i++) { + for (i = 1; i <= g_sngisdn_data.num_cc; i++) { if (g_sngisdn_data.ccs[i].switchtype == signal_data->switchtype && g_sngisdn_data.ccs[i].trunktype == span->trunk_type) { break; } } + /* need to create a new switch_type */ if (i > g_sngisdn_data.num_cc) { g_sngisdn_data.num_cc++; @@ -151,20 +154,9 @@ static ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span /* add this span to its ent_cc */ signal_data->cc_id = i; - /* create a new dchan */ /* for NFAS - no-dchan on b-channels-only links */ - g_sngisdn_data.num_dchan++; - signal_data->dchan_id = g_sngisdn_data.num_dchan; - - dchan_data = &g_sngisdn_data.dchans[signal_data->dchan_id]; - dchan_data->num_spans++; - - signal_data->span_id = dchan_data->num_spans; - dchan_data->spans[signal_data->span_id] = signal_data; - g_sngisdn_data.spans[signal_data->link_id] = signal_data; - ftdm_log(FTDM_LOG_DEBUG, "%s: cc_id:%d dchan_id:%d span_id:%d link_id:%d\n", span->name, signal_data->cc_id, signal_data->dchan_id, signal_data->span_id, signal_data->link_id); - + ftdm_log(FTDM_LOG_DEBUG, "%s: cc_id:%d link_id:%d\n", span->name, signal_data->cc_id, signal_data->link_id); chaniter = ftdm_span_get_chan_iterator(span, NULL); for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { @@ -175,17 +167,16 @@ static ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span signal_data->dchan = ftdmchan; } else { /* Add the channels to the span */ - /* NFAS is not supported on E1, so span_id will always be 1 for E1 so this will work for E1 as well */ - chan_id = ((signal_data->span_id-1)*NUM_T1_CHANNELS_PER_SPAN)+ftdmchan->physical_chan_id; - dchan_data->channels[chan_id] = (sngisdn_chan_data_t*)ftdmchan->call_data; - dchan_data->num_chans++; + chan_id = ftdmchan->physical_chan_id; + signal_data->channels[chan_id] = (sngisdn_chan_data_t*)ftdmchan->call_data; + signal_data->num_chans++; } } ftdm_iterator_free(chaniter); return FTDM_SUCCESS; } -static ftdm_status_t parse_signalling(const char* signalling, ftdm_span_t *span) +static ftdm_status_t parse_signalling(const char *signalling, ftdm_span_t *span) { sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; if (!strcasecmp(signalling, "net") || @@ -205,6 +196,146 @@ static ftdm_status_t parse_signalling(const char* signalling, ftdm_span_t *span) return FTDM_SUCCESS; } +static ftdm_status_t parse_spanmap(const char *_spanmap, ftdm_span_t *span) +{ + int i; + char *p, *name, *spanmap; + uint8_t logical_span_id = 0; + ftdm_status_t ret = FTDM_SUCCESS; + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; + + spanmap = ftdm_strdup(_spanmap); + + p = name = NULL; + + i = 0; + for (p = strtok(spanmap, ","); p; p = strtok(NULL, ",")) { + while (*p == ' ') { + p++; + } + switch(i++) { + case 0: + name = ftdm_strdup(p); + break; + case 1: + logical_span_id = atoi(p); + break; + } + } + + if (!name) { + ftdm_log(FTDM_LOG_ERROR, "Invalid spanmap syntax %s\n", _spanmap); + ret = FTDM_FAIL; + goto done; + } + + for (i = 0; i < g_sngisdn_data.num_nfas; i++) { + if (!ftdm_strlen_zero(g_sngisdn_data.nfass[i].name) && + !strcasecmp(g_sngisdn_data.nfass[i].name, name)) { + + signal_data->nfas.trunk = &g_sngisdn_data.nfass[i]; + break; + } + } + + if (!signal_data->nfas.trunk) { + ftdm_log(FTDM_LOG_ERROR, "Could not find trunkgroup with name %s\n", name); + ret = FTDM_FAIL; + goto done; + } + + if (signal_data->nfas.trunk->spans[logical_span_id]) { + ftdm_log(FTDM_LOG_ERROR, "trunkgroup:%s already had a span with logical span id:%d\n", name, logical_span_id); + } else { + signal_data->nfas.trunk->spans[logical_span_id] = signal_data; + signal_data->nfas.interface_id = logical_span_id; + } + + if (!strcasecmp(signal_data->ftdm_span->name, signal_data->nfas.trunk->dchan_span_name)) { + + signal_data->nfas.sigchan = SNGISDN_NFAS_DCHAN_PRIMARY; + signal_data->nfas.trunk->dchan = signal_data; + } + + if (!strcasecmp(signal_data->ftdm_span->name, signal_data->nfas.trunk->backup_span_name)) { + + signal_data->nfas.sigchan = SNGISDN_NFAS_DCHAN_BACKUP; + signal_data->nfas.trunk->backup = signal_data; + } + +done: + ftdm_safe_free(spanmap); + ftdm_safe_free(name); + return ret; +} + +static ftdm_status_t parse_trunkgroup(const char *_trunkgroup) +{ + int i; + char *p, *name, *dchan_span, *backup_span, *trunkgroup; + uint8_t num_spans; + ftdm_status_t ret = FTDM_SUCCESS; + + trunkgroup = ftdm_strdup(_trunkgroup); + + p = name = dchan_span = backup_span = NULL; + + /* format: name, num_chans, dchan_span, [backup_span] */ + + i = 0; + for (p = strtok(trunkgroup, ","); p; p = strtok(NULL, ",")) { + while (*p == ' ') { + p++; + } + switch(i++) { + case 0: + name = ftdm_strdup(p); + break; + case 1: + num_spans = atoi(p); + break; + case 2: + dchan_span = ftdm_strdup(p); + break; + case 3: + backup_span = ftdm_strdup(p); + } + } + + if (!name || !dchan_span || num_spans <= 0) { + ftdm_log(FTDM_LOG_ERROR, "Invalid parameters for trunkgroup:%s\n", _trunkgroup); + ret = FTDM_FAIL; + goto done; + } + + for (i = 0; i < g_sngisdn_data.num_nfas; i++) { + if (!ftdm_strlen_zero(g_sngisdn_data.nfass[i].name) && + !strcasecmp(g_sngisdn_data.nfass[i].name, name)) { + + /* We already configured this trunkgroup */ + goto done; + } + } + + /* Trunk group was not found, need to configure it */ + strncpy(g_sngisdn_data.nfass[i].name, name, sizeof(g_sngisdn_data.nfass[i].name)); + g_sngisdn_data.nfass[i].num_spans = num_spans; + strncpy(g_sngisdn_data.nfass[i].dchan_span_name, dchan_span, sizeof(g_sngisdn_data.nfass[i].dchan_span_name)); + + if (backup_span) { + strncpy(g_sngisdn_data.nfass[i].backup_span_name, backup_span, sizeof(g_sngisdn_data.nfass[i].backup_span_name)); + } + + + g_sngisdn_data.num_nfas++; +done: + ftdm_safe_free(trunkgroup); + ftdm_safe_free(name); + ftdm_safe_free(dchan_span); + ftdm_safe_free(backup_span); + return FTDM_SUCCESS; +} + static ftdm_status_t parse_early_media(const char* opt, ftdm_span_t *span) { sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; @@ -314,6 +445,19 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_ /* Cannot set default bearer_layer1 yet, as we do not know the switchtype */ span->default_caller_data.bearer_layer1 = FTDM_INVALID_INT_PARM; + /* Find out if NFAS is enabled first */ + for (paramindex = 0; ftdm_parameters[paramindex].var; paramindex++) { + ftdm_log(FTDM_LOG_DEBUG, "Sangoma ISDN key=value, %s=%s\n", ftdm_parameters[paramindex].var, ftdm_parameters[paramindex].val); + var = ftdm_parameters[paramindex].var; + val = ftdm_parameters[paramindex].val; + + if (!strcasecmp(var, "trunkgroup")) { + if (parse_trunkgroup(val) != FTDM_SUCCESS) { + return FTDM_FAIL; + } + } + } + for (paramindex = 0; ftdm_parameters[paramindex].var; paramindex++) { ftdm_log(FTDM_LOG_DEBUG, "Sangoma ISDN key=value, %s=%s\n", ftdm_parameters[paramindex].var, ftdm_parameters[paramindex].val); var = ftdm_parameters[paramindex].var; @@ -331,6 +475,10 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_ if (parse_signalling(val, span) != FTDM_SUCCESS) { return FTDM_FAIL; } + } else if (!strcasecmp(var, "spanmap")) { + if (parse_spanmap(val, span) != FTDM_SUCCESS) { + return FTDM_FAIL; + } } else if (!strcasecmp(var, "tei")) { uint8_t tei = atoi(val); if (tei > 127) { @@ -465,6 +613,8 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_ parse_timer(val, &signal_data->timer_t319); } else if (!strcasecmp(var, "timer-t322")) { parse_timer(val, &signal_data->timer_t322); + } else if (!strcasecmp(var, "trunkgroup")) { + /* Do nothing, we already parsed this parameter */ } else { ftdm_log(FTDM_LOG_WARNING, "Ignoring unknown parameter %s\n", ftdm_parameters[paramindex].var); } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c index 15def40218..754aff1187 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c @@ -40,6 +40,8 @@ void sngisdn_set_chan_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status void sngisdn_set_chan_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status) { ftdm_sigmsg_t sig; + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)ftdmchan->span->signal_data; + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Signalling link status changed to %s\n", ftdm_signaling_status2str(status)); memset(&sig, 0, sizeof(sig)); @@ -52,7 +54,6 @@ void sngisdn_set_chan_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status if (FTDM_SPAN_IS_BRI(ftdmchan->span)) { sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)ftdmchan->span->signal_data; if (ftdm_test_flag(sngisdn_info, FLAG_ACTIVATING)) { ftdm_clear_flag(sngisdn_info, FLAG_ACTIVATING); @@ -67,6 +68,7 @@ void sngisdn_set_span_sig_status(ftdm_span_t *span, ftdm_signaling_status_t stat ftdm_iterator_t *chaniter = NULL; ftdm_iterator_t *curr = NULL; + ((sngisdn_span_data_t*)span->signal_data)->sigstatus = status; chaniter = ftdm_span_get_chan_iterator(span, NULL); for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c index 7c6322c3bc..52daf3ad7b 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c @@ -62,6 +62,8 @@ ftdm_status_t sngisdn_stack_cfg(ftdm_span_t *span) { sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; + ftdm_log(FTDM_LOG_DEBUG, "Starting stack configuration for span:%s\n", span->name); + if (!g_sngisdn_data.gen_config_done) { g_sngisdn_data.gen_config_done = 1; ftdm_log(FTDM_LOG_DEBUG, "Starting general stack configuration\n"); @@ -91,33 +93,33 @@ ftdm_status_t sngisdn_stack_cfg(ftdm_span_t *span) ftdm_log(FTDM_LOG_INFO, "General stack configuration done\n"); } - /* TODO: for NFAS, should only call these function for spans with d-chans */ - if (sngisdn_stack_cfg_phy_psap(span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "%s:phy_psap configuration failed\n", span->name); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "%s:phy_psap configuration done\n", span->name); - - if (sngisdn_stack_cfg_q921_msap(span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "%s:q921_msap configuration failed\n", span->name); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "%s:q921_msap configuration done\n", span->name); - - if (sngisdn_stack_cfg_q921_dlsap(span, 0) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "%s:q921_dlsap configuration failed\n", span->name); - return FTDM_FAIL; - } - ftdm_log(FTDM_LOG_DEBUG, "%s:q921_dlsap configuration done\n", span->name); - - if (span->trunk_type == FTDM_TRUNK_BRI_PTMP) { - if (sngisdn_stack_cfg_q921_dlsap(span, 1) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "%s:q921_dlsap management configuration failed\n", span->name); + if (signal_data->dchan) { + if (sngisdn_stack_cfg_phy_psap(span) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_ERROR, "%s:phy_psap configuration failed\n", span->name); return FTDM_FAIL; } - ftdm_log(FTDM_LOG_DEBUG, "%s:q921_dlsap management configuration done\n", span->name); + ftdm_log(FTDM_LOG_DEBUG, "%s:phy_psap configuration done\n", span->name); + + if (sngisdn_stack_cfg_q921_msap(span) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_ERROR, "%s:q921_msap configuration failed\n", span->name); + return FTDM_FAIL; + } + ftdm_log(FTDM_LOG_DEBUG, "%s:q921_msap configuration done\n", span->name); + + if (sngisdn_stack_cfg_q921_dlsap(span, 0) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_ERROR, "%s:q921_dlsap configuration failed\n", span->name); + return FTDM_FAIL; + } + ftdm_log(FTDM_LOG_DEBUG, "%s:q921_dlsap configuration done\n", span->name); + + if (span->trunk_type == FTDM_TRUNK_BRI_PTMP) { + if (sngisdn_stack_cfg_q921_dlsap(span, 1) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_ERROR, "%s:q921_dlsap management configuration failed\n", span->name); + return FTDM_FAIL; + } + ftdm_log(FTDM_LOG_DEBUG, "%s:q921_dlsap management configuration done\n", span->name); + } } - if (sngisdn_stack_cfg_q931_dlsap(span) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_ERROR, "%s:q931_dlsap configuration failed\n", span->name); @@ -125,11 +127,13 @@ ftdm_status_t sngisdn_stack_cfg(ftdm_span_t *span) } ftdm_log(FTDM_LOG_DEBUG, "%s:q931_dlsap configuration done\n", span->name); - if (sngisdn_stack_cfg_q931_lce(span) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "%s:q931_lce configuration failed\n", span->name); - return FTDM_FAIL; + if (signal_data->dchan) { + if (sngisdn_stack_cfg_q931_lce(span) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_ERROR, "%s:q931_lce configuration failed\n", span->name); + return FTDM_FAIL; + } + ftdm_log(FTDM_LOG_DEBUG, "%s:q931_lce configuration done\n", span->name); } - ftdm_log(FTDM_LOG_DEBUG, "%s:q931_lce configuration done\n", span->name); if (!g_sngisdn_data.ccs[signal_data->cc_id].config_done) { g_sngisdn_data.ccs[signal_data->cc_id].config_done = 1; @@ -216,7 +220,7 @@ ftdm_status_t sngisdn_stack_cfg_phy_psap(ftdm_span_t *span) cfg.hdr.entId.inst = S_INST; cfg.hdr.elmId.elmnt = STPSAP; - cfg.hdr.elmId.elmntInst1 = signal_data->dchan_id; + cfg.hdr.elmId.elmntInst1 = signal_data->link_id; if (!signal_data->dchan) { ftdm_log(FTDM_LOG_ERROR, "%s:No d-channels specified\n", span->name); @@ -242,7 +246,7 @@ ftdm_status_t sngisdn_stack_cfg_phy_psap(ftdm_span_t *span) return FTDM_FAIL; } - cfg.t.cfg.s.l1PSAP.spId = signal_data->dchan_id; + cfg.t.cfg.s.l1PSAP.spId = signal_data->link_id; if (sng_isdn_phy_config(&pst, &cfg)) { return FTDM_FAIL; @@ -316,7 +320,7 @@ ftdm_status_t sngisdn_stack_cfg_q921_msap(ftdm_span_t *span) cfg.hdr.entId.inst = S_INST; cfg.hdr.elmId.elmnt = STMSAP; - cfg.t.cfg.s.bdMSAP.lnkNmb = signal_data->dchan_id; + cfg.t.cfg.s.bdMSAP.lnkNmb = signal_data->link_id; cfg.t.cfg.s.bdMSAP.maxOutsFrms = 24; /* MAC window */ cfg.t.cfg.s.bdMSAP.tQUpperTrs = 32; /* Tx Queue Upper Threshold */ @@ -409,7 +413,7 @@ ftdm_status_t sngisdn_stack_cfg_q921_dlsap(ftdm_span_t *span, uint8_t management cfg.hdr.entId.inst = S_INST; cfg.hdr.elmId.elmnt = STDLSAP; - cfg.t.cfg.s.bdDLSAP.lnkNmb = signal_data->dchan_id; + cfg.t.cfg.s.bdDLSAP.lnkNmb = signal_data->link_id; cfg.t.cfg.s.bdDLSAP.n201 = 1028; /* n201 */ if (span->trunk_type == FTDM_TRUNK_BRI_PTMP || @@ -614,8 +618,8 @@ ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span) cfg.hdr.response.selector=0; - cfg.t.cfg.s.inDLSAP.sapId = signal_data->dchan_id; - cfg.t.cfg.s.inDLSAP.spId = signal_data->dchan_id; + cfg.t.cfg.s.inDLSAP.sapId = signal_data->link_id; + cfg.t.cfg.s.inDLSAP.spId = signal_data->link_id; cfg.t.cfg.s.inDLSAP.swtch = sng_isdn_stack_switchtype(signal_data->switchtype); @@ -630,11 +634,9 @@ ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span) } else { cfg.t.cfg.s.inDLSAP.facilityHandling = 0; } - - /* TODO : NFAS configuration */ - cfg.t.cfg.s.inDLSAP.nfasInt = FALSE; /* pass this later */ - - if (!cfg.t.cfg.s.inDLSAP.nfasInt) { + + if (!signal_data->nfas.trunk) { + cfg.t.cfg.s.inDLSAP.nfasInt = FALSE; cfg.t.cfg.s.inDLSAP.intId = 0; cfg.t.cfg.s.inDLSAP.sigInt = 0; cfg.t.cfg.s.inDLSAP.bupInt = 0; @@ -645,19 +647,55 @@ ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span) cfg.t.cfg.s.inDLSAP.ctldInt[i] = IN_INT_NOT_CFGD; } else { - /* Need to get these parameters from NFAS */ - cfg.t.cfg.s.inDLSAP.intId = 0; - cfg.t.cfg.s.inDLSAP.sigInt = 0; - cfg.t.cfg.s.inDLSAP.bupInt = 1; - cfg.t.cfg.s.inDLSAP.nmbNfasInt = 2; - cfg.t.cfg.s.inDLSAP.buIntPr = 1; + cfg.t.cfg.s.inDLSAP.nfasInt = TRUE; + cfg.t.cfg.s.inDLSAP.intId = signal_data->nfas.interface_id; for (i = 0; i < IN_MAX_NMB_INTRFS; i++) cfg.t.cfg.s.inDLSAP.ctldInt[i] = IN_INT_NOT_CFGD; - /* For primary and backup interfaces, need to initialize this array */ - cfg.t.cfg.s.inDLSAP.ctldInt[0] = 0; /* This is primary if for NFAS */ - cfg.t.cfg.s.inDLSAP.ctldInt[1] = 1; + switch (signal_data->nfas.sigchan) { + case SNGISDN_NFAS_DCHAN_PRIMARY: + cfg.t.cfg.s.inDLSAP.sigInt = signal_data->nfas.trunk->dchan->link_id; + cfg.t.cfg.s.inDLSAP.nmbNfasInt = signal_data->nfas.trunk->num_spans; + + if (signal_data->nfas.trunk->backup) { + cfg.t.cfg.s.inDLSAP.buIntPr = TRUE; + cfg.t.cfg.s.inDLSAP.bupInt = signal_data->nfas.trunk->backup->link_id; + } else { + cfg.t.cfg.s.inDLSAP.buIntPr = FALSE; + } + + for (i = 0; i < MAX_SPANS_PER_NFAS_LINK; i++) { + if (signal_data->nfas.trunk->spans[i]) { + cfg.t.cfg.s.inDLSAP.ctldInt[i] = signal_data->nfas.trunk->spans[i]->link_id; + } + } + + break; + case SNGISDN_NFAS_DCHAN_BACKUP: + cfg.t.cfg.s.inDLSAP.sigInt = signal_data->nfas.trunk->dchan->link_id; + cfg.t.cfg.s.inDLSAP.nmbNfasInt = signal_data->nfas.trunk->num_spans; + + if (signal_data->nfas.trunk->backup) { + cfg.t.cfg.s.inDLSAP.buIntPr = TRUE; + cfg.t.cfg.s.inDLSAP.bupInt = signal_data->nfas.trunk->backup->link_id; + } else { + cfg.t.cfg.s.inDLSAP.buIntPr = FALSE; + } + + for (i = 0; i < MAX_SPANS_PER_NFAS_LINK; i++) { + if (signal_data->nfas.trunk->spans[i]) { + cfg.t.cfg.s.inDLSAP.ctldInt[i] = signal_data->nfas.trunk->spans[i]->link_id; + } + } + + break; + case SNGISDN_NFAS_DCHAN_NONE: + cfg.t.cfg.s.inDLSAP.sigInt = signal_data->nfas.trunk->dchan->link_id; + cfg.t.cfg.s.inDLSAP.nmbNfasInt = 0; + + break; + } } cfg.t.cfg.s.inDLSAP.numRstInd = 255; @@ -905,13 +943,27 @@ ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span) break; case FTDM_TRUNK_T1: case FTDM_TRUNK_J1: - /* if NFAS, could be 0 if no signalling */ - cfg.t.cfg.s.inDLSAP.dChannelNum = 24; - cfg.t.cfg.s.inDLSAP.nmbBearChan = NUM_T1_CHANNELS_PER_SPAN; - cfg.t.cfg.s.inDLSAP.firstBChanNum = 1; + /* if NFAS, could be 0 if no signalling */ cfg.t.cfg.s.inDLSAP.callRefLen = 2; cfg.t.cfg.s.inDLSAP.teiAlloc = IN_STATIC; cfg.t.cfg.s.inDLSAP.intCfg = IN_INTCFG_PTPT; + cfg.t.cfg.s.inDLSAP.firstBChanNum = 1; + + if (signal_data->nfas.trunk) { + if (signal_data->nfas.sigchan == SNGISDN_NFAS_DCHAN_PRIMARY || + signal_data->nfas.sigchan == SNGISDN_NFAS_DCHAN_BACKUP) { + + cfg.t.cfg.s.inDLSAP.dChannelNum = 24; + cfg.t.cfg.s.inDLSAP.nmbBearChan = NUM_T1_CHANNELS_PER_SPAN - 1; + } else { + cfg.t.cfg.s.inDLSAP.dChannelNum = 0; + cfg.t.cfg.s.inDLSAP.nmbBearChan = NUM_T1_CHANNELS_PER_SPAN; + } + } else { + cfg.t.cfg.s.inDLSAP.dChannelNum = 24; + cfg.t.cfg.s.inDLSAP.nmbBearChan = NUM_T1_CHANNELS_PER_SPAN; + cfg.t.cfg.s.inDLSAP.firstBChanNum = 1; + } break; case FTDM_TRUNK_BRI: cfg.t.cfg.s.inDLSAP.dChannelNum = 0; /* Unused for BRI */ @@ -971,7 +1023,7 @@ ftdm_status_t sngisdn_stack_cfg_q931_lce(ftdm_span_t *span) cfg.hdr.response.selector=0; - cfg.t.cfg.s.inLCe.sapId = signal_data->dchan_id; + cfg.t.cfg.s.inLCe.sapId = signal_data->link_id; if (span->trunk_type == FTDM_TRUNK_BRI_PTMP) { /* Stack will send Restart CFM's each time link is established (TEI negotiated), @@ -998,13 +1050,13 @@ ftdm_status_t sngisdn_stack_cfg_q931_lce(ftdm_span_t *span) cfg.t.cfg.s.inLCe.t314.enb = FALSE; /* if segmentation enabled, set to TRUE */ cfg.t.cfg.s.inLCe.t314.val = 35; - cfg.t.cfg.s.inLCe.t332i.enb = FALSE; /* set to TRUE for NFAS */ - -#ifdef NFAS - cfg.t.cfg.s.inLCe.t332i.val = 35; -#else - cfg.t.cfg.s.inLCe.t332i.val = 0; -#endif + if (signal_data->nfas.trunk) { + cfg.t.cfg.s.inLCe.t332i.enb = TRUE; + cfg.t.cfg.s.inLCe.t332i.val = 35; + } else { + cfg.t.cfg.s.inLCe.t332i.enb = FALSE; + cfg.t.cfg.s.inLCe.t332i.val = 35; + } #if (ISDN_NI1 || ISDN_NT || ISDN_ATT) cfg.t.cfg.s.inLCe.tSpid.enb = TRUE; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c index f7193e20c1..1cc23ddb8d 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c @@ -55,10 +55,12 @@ ftdm_status_t sngisdn_stack_start(ftdm_span_t *span) { sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - - if (sngisdn_cntrl_q921(span, ABND_ENA, NOTUSED) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_CRIT, "%s:Failed to activate stack q921\n", span->name); - return FTDM_FAIL; + if (signal_data->dchan) { + if (sngisdn_cntrl_q921(span, ABND_ENA, NOTUSED) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_CRIT, "%s:Failed to activate stack q921\n", span->name); + return FTDM_FAIL; + } + ftdm_log(FTDM_LOG_DEBUG, "%s:Stack q921 activated\n", span->name); } /* Try to find an alternative for this */ @@ -67,8 +69,7 @@ ftdm_status_t sngisdn_stack_start(ftdm_span_t *span) LdUiDatConReq when activated, and this requires the Mac SAP to be already bound first */ ftdm_sleep(500); - - ftdm_log(FTDM_LOG_DEBUG, "%s:Stack q921 activated\n", span->name); + if (!g_sngisdn_data.ccs[signal_data->cc_id].activation_done) { g_sngisdn_data.ccs[signal_data->cc_id].activation_done = 1; if (sngisdn_activate_cc(span) != FTDM_SUCCESS) { @@ -78,7 +79,6 @@ ftdm_status_t sngisdn_stack_start(ftdm_span_t *span) ftdm_log(FTDM_LOG_DEBUG, "%s:Stack CC activated\n", span->name); } - if (sngisdn_cntrl_q931(span, ABND_ENA, SAELMNT) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "%s:Failed to activate stack q931\n", span->name); return FTDM_FAIL; @@ -91,7 +91,11 @@ ftdm_status_t sngisdn_stack_start(ftdm_span_t *span) ftdm_status_t sngisdn_stack_stop(ftdm_span_t *span) { + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; /* Stop L1 first, so we do not receive any more frames */ + if (!signal_data->dchan) { + return FTDM_SUCCESS; + } if (sngisdn_deactivate_phy(span) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "%s:Failed to deactivate stack phy\n", span->name); return FTDM_FAIL; @@ -147,7 +151,7 @@ ftdm_status_t sngisdn_deactivate_phy(ftdm_span_t *span) cntrl.t.cntrl.action = AUBND_DIS; cntrl.t.cntrl.subAction = SAELMNT; - cntrl.t.cntrl.sapId = signal_data->dchan_id; + cntrl.t.cntrl.sapId = signal_data->link_id; if (sng_isdn_phy_cntrl(&pst, &cntrl)) { return FTDM_FAIL; @@ -182,7 +186,7 @@ ftdm_status_t sngisdn_wake_up_phy(ftdm_span_t *span) cntrl.t.cntrl.action = AENA; cntrl.t.cntrl.subAction = SAELMNT; - cntrl.t.cntrl.sapId = signal_data->dchan_id; + cntrl.t.cntrl.sapId = signal_data->link_id; if (sng_isdn_phy_cntrl(&pst, &cntrl)) { return FTDM_FAIL; @@ -226,33 +230,34 @@ ftdm_status_t sngisdn_activate_cc(ftdm_span_t *span) ftdm_status_t sngisdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t trace_opt) { - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; + sngisdn_span_data_t *signal_data = sngisdn_dchan((sngisdn_span_data_t*)span->signal_data); + switch (trace_opt) { case SNGISDN_TRACE_DISABLE: if (sngisdn_test_trace_flag(signal_data, SNGISDN_TRACE_Q921)) { - ftdm_log(FTDM_LOG_INFO, "s%d Disabling q921 trace\n", signal_data->link_id); + ftdm_log(FTDM_LOG_INFO, "%s:Disabling q921 trace\n", signal_data->ftdm_span->name); sngisdn_clear_trace_flag(signal_data, SNGISDN_TRACE_Q921); - if (sngisdn_cntrl_q921(span, ADISIMM, SATRC) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "s%d Failed to disable q921 trace\n", signal_data->link_id); + if (sngisdn_cntrl_q921(signal_data->ftdm_span, ADISIMM, SATRC) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_INFO, "%s:Failed to disable q921 trace\n", signal_data->ftdm_span->name); } } if (sngisdn_test_trace_flag(signal_data, SNGISDN_TRACE_Q931)) { - ftdm_log(FTDM_LOG_INFO, "s%d Disabling q931 trace\n", signal_data->link_id); + ftdm_log(FTDM_LOG_INFO, "%s:Disabling q921 trace\n", signal_data->ftdm_span->name); sngisdn_clear_trace_flag(signal_data, SNGISDN_TRACE_Q931); - if (sngisdn_cntrl_q931(span, ADISIMM, SATRC) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "s%d Failed to disable q931 trace\n", signal_data->link_id); + if (sngisdn_cntrl_q931(signal_data->ftdm_span, ADISIMM, SATRC) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_INFO, "%s:Failed to disable q921 trace\n", signal_data->ftdm_span->name); } } break; case SNGISDN_TRACE_Q921: if (!sngisdn_test_trace_flag(signal_data, SNGISDN_TRACE_Q921)) { - ftdm_log(FTDM_LOG_INFO, "s%d Enabling q921 trace\n", signal_data->link_id); + ftdm_log(FTDM_LOG_INFO, "%s:Enabling q921 trace\n", signal_data->ftdm_span->name); sngisdn_set_trace_flag(signal_data, SNGISDN_TRACE_Q921); - if (sngisdn_cntrl_q921(span, AENA, SATRC) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "s%d Failed to enable q921 trace\n", signal_data->link_id); + if (sngisdn_cntrl_q921(signal_data->ftdm_span, AENA, SATRC) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_INFO, "%s:Failed to enable q921 trace\n", signal_data->ftdm_span->name); } } break; @@ -261,8 +266,8 @@ ftdm_status_t sngisdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t trac ftdm_log(FTDM_LOG_INFO, "s%d Enabling q931 trace\n", signal_data->link_id); sngisdn_set_trace_flag(signal_data, SNGISDN_TRACE_Q931); - if (sngisdn_cntrl_q931(span, AENA, SATRC) != FTDM_SUCCESS) { - ftdm_log(FTDM_LOG_ERROR, "s%d Failed to enable q931 trace\n", signal_data->link_id); + if (sngisdn_cntrl_q931(signal_data->ftdm_span, AENA, SATRC) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_INFO, "%s:Failed to enable q931 trace\n", signal_data->ftdm_span->name); } } break; @@ -301,7 +306,7 @@ ftdm_status_t sngisdn_cntrl_q931(ftdm_span_t *span, uint8_t action, uint8_t suba cntrl.t.cntrl.trcLen = -1; /* Trace the entire message buffer */ } - cntrl.t.cntrl.sapId = signal_data->dchan_id; + cntrl.t.cntrl.sapId = signal_data->link_id; cntrl.t.cntrl.ces = 0; if(sng_isdn_q931_cntrl(&pst, &cntrl)) { @@ -342,11 +347,11 @@ ftdm_status_t sngisdn_cntrl_q921(ftdm_span_t *span, uint8_t action, uint8_t suba cntrl.t.cntrl.subAction = subaction; #if (SMBD_LMINT3 || BD_LMINT3) - cntrl.t.cntrl.lnkNmb = signal_data->dchan_id; + cntrl.t.cntrl.lnkNmb = signal_data->link_id; cntrl.t.cntrl.sapi = NOTUSED; cntrl.t.cntrl.tei = NOTUSED; #else /* _LMINT3 */ - cntrl.hdr.elmId.elmntInst1 = signal_data->dchan_id; + cntrl.hdr.elmId.elmntInst1 = signal_data->link_id; cntrl.hdr.elmId.elmntInst2 = NOTUSED; cntrl.hdr.elmId.elmntInst3 = NOTUSED; #endif /* _LMINT3 */ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c index 3769726f9f..c2d18f01a9 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c @@ -58,6 +58,19 @@ void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event) switch (ftdmchan->state) { case FTDM_CHANNEL_STATE_DOWN: /* Proper state to receive a SETUP */ + if (signal_data->nfas.trunk) { + ftdm_alarm_flag_t alarmflag = 0; + + ftdm_channel_get_alarms(ftdmchan, &alarmflag); + if (alarmflag) { + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_INFO, "Received SETUP but channel has physical layer alarm - rejecting\n"); + + ftdmchan->caller_data.hangup_cause = 0x2C; /* Channel requested not available */ + ftdm_sched_timer(signal_data->sched, "delayed_release", 1, sngisdn_delayed_release, (void*) sngisdn_info, NULL); + break; + } + } + if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INUSE) || ftdm_channel_open_chan(ftdmchan) != FTDM_SUCCESS) { @@ -1183,7 +1196,7 @@ void sngisdn_process_rst_cfm (sngisdn_event_data_t *sngisdn_event) uint8_t chan_no = 0; Rst *rstEvnt = &sngisdn_event->event.rstEvnt; - sngisdn_span_data_t *signal_data = g_sngisdn_data.dchans[dChan].spans[1]; + sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[dChan]; if (!signal_data) { ftdm_log(FTDM_LOG_CRIT, "Received RESTART CFM on unconfigured span (suId:%d)\n", suId); return; @@ -1211,6 +1224,16 @@ void sngisdn_process_rst_cfm (sngisdn_event_data_t *sngisdn_event) chan_no = rstEvnt->chanId.chanNmbSlotMap.val[0]; } } + + if (signal_data->nfas.trunk) { + if (!rstEvnt->chanId.intIdent.pres) { + ftdm_log(FTDM_LOG_CRIT, "Failed to determine interface from RESTART\n"); + return; + } else if (signal_data->nfas.interface_id != rstEvnt->chanId.intIdent.val) { + /* This RESTART is for another interface */ + return; + } + } } if (!chan_no) { ftdm_log(FTDM_LOG_CRIT, "Failed to determine channel from RESTART\n"); @@ -1273,10 +1296,7 @@ void sngisdn_process_rst_ind (sngisdn_event_data_t *sngisdn_event) rstEvnt = &sngisdn_event->event.rstEvnt; - /* TODO: readjust this when NFAS is implemented as signal_data will not always be the first - * span for that d-channel */ - - signal_data = g_sngisdn_data.dchans[dChan].spans[1]; + signal_data = g_sngisdn_data.spans[dChan]; if (!signal_data) { ftdm_log(FTDM_LOG_CRIT, "Received RESTART IND on unconfigured span (suId:%d)\n", suId); @@ -1307,6 +1327,16 @@ void sngisdn_process_rst_ind (sngisdn_event_data_t *sngisdn_event) chan_no = rstEvnt->chanId.chanNmbSlotMap.val[0]; } } + + if (signal_data->nfas.trunk) { + if (!rstEvnt->chanId.intIdent.pres) { + ftdm_log(FTDM_LOG_CRIT, "Failed to determine interface from RESTART\n"); + return; + } else if (signal_data->nfas.interface_id != rstEvnt->chanId.intIdent.val) { + /* This RESTART is for another interface */ + return; + } + } } if (!chan_no) { ftdm_log(FTDM_LOG_CRIT, "Failed to determine channel from RESTART\n"); @@ -1315,7 +1345,7 @@ void sngisdn_process_rst_ind (sngisdn_event_data_t *sngisdn_event) break; case IN_CL_SNGINT: /* Single interface */ case IN_CL_ALLINT: /* All interfaces */ - /* In case restart class indicates all interfaces, we will duplicate + /* In case restart class indicates all interfaces, we will duplicated this event on each span associated to this d-channel in sngisdn_rcv_rst_cfm, so treat it as a single interface anyway */ chan_no = 0; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c index f705d717ab..b05ee41356 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c @@ -36,10 +36,10 @@ void sngisdn_snd_setup(ftdm_channel_t *ftdmchan) { - ConEvnt conEvnt; + ConEvnt conEvnt; sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data; sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - ftdm_sngisdn_progind_t prog_ind = {SNGISDN_PROGIND_LOC_USER, SNGISDN_PROGIND_DESCR_INVALID}; + ftdm_sngisdn_progind_t prog_ind = {SNGISDN_PROGIND_LOC_USER, SNGISDN_PROGIND_DESCR_INVALID}; ftdm_assert((!sngisdn_info->suInstId && !sngisdn_info->spInstId), "Trying to call out, but call data was not cleared\n"); @@ -76,9 +76,9 @@ void sngisdn_snd_setup(ftdm_channel_t *ftdmchan) set_facility_ie(ftdmchan, &conEvnt.facilityStr); set_prog_ind_ie(ftdmchan, &conEvnt.progInd, prog_ind); - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending SETUP (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending SETUP (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - if (sng_isdn_con_request(signal_data->cc_id, sngisdn_info->suInstId, &conEvnt, signal_data->dchan_id, sngisdn_info->ces)) { + if (sng_isdn_con_request(signal_data->cc_id, sngisdn_info->suInstId, &conEvnt, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused SETUP request\n"); } @@ -104,9 +104,9 @@ void sngisdn_snd_setup_ack(ftdm_channel_t *ftdmchan) - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending SETUP ACK (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending SETUP ACK (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &cnStEvnt, MI_SETUPACK, signal_data->dchan_id, sngisdn_info->ces)) { + if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &cnStEvnt, MI_SETUPACK, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused SETUP ACK request\n"); } return; @@ -136,9 +136,9 @@ void sngisdn_snd_con_complete(ftdm_channel_t *ftdmchan) set_chan_id_ie(ftdmchan, &cnStEvnt.chanId); } - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending CONNECT COMPL (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending CONNECT COMPL (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - if(sng_isdn_con_comp(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &cnStEvnt, signal_data->dchan_id, sngisdn_info->ces)) { + if(sng_isdn_con_comp(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &cnStEvnt, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused CONNECT ACK request\n"); } return; @@ -172,9 +172,9 @@ void sngisdn_snd_proceed(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_i set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind); set_facility_ie(ftdmchan, &cnStEvnt.facilityStr); - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending PROCEED (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending PROCEED (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &cnStEvnt, MI_CALLPROC, signal_data->dchan_id, sngisdn_info->ces)) { + if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &cnStEvnt, MI_CALLPROC, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused PROCEED request\n"); } return; @@ -204,8 +204,8 @@ void sngisdn_snd_progress(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind); set_facility_ie(ftdmchan, &cnStEvnt.facilityStr); - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending PROGRESS (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); - if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId,&cnStEvnt, MI_PROGRESS, signal_data->dchan_id, sngisdn_info->ces)) { + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending PROGRESS (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); + if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId,&cnStEvnt, MI_PROGRESS, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused PROGRESS request\n"); } return; @@ -230,9 +230,9 @@ void sngisdn_snd_alert(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind); set_facility_ie(ftdmchan, &cnStEvnt.facilityStr); - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending ALERT (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending ALERT (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId,&cnStEvnt, MI_ALERTING, signal_data->dchan_id, sngisdn_info->ces)) { + if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId,&cnStEvnt, MI_ALERTING, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused ALERT request\n"); } return; @@ -266,8 +266,8 @@ void sngisdn_snd_connect(ftdm_channel_t *ftdmchan) set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind); set_facility_ie(ftdmchan, &cnStEvnt.facilityStr); - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending CONNECT (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); - if (sng_isdn_con_response(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &cnStEvnt, signal_data->dchan_id, sngisdn_info->ces)) { + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending CONNECT (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); + if (sng_isdn_con_response(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &cnStEvnt, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused CONNECT request\n"); } return; @@ -298,9 +298,9 @@ void sngisdn_snd_fac_req(ftdm_channel_t *ftdmchan) facEvnt.facElmt.facStr.val[1] = (uint8_t)facEvnt.facElmt.facStr.len; facEvnt.facElmt.facStr.len +=2; /* Need to include the size of identifier + len */ - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending FACILITY (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending FACILITY (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - if (sng_isdn_facility_request(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &facEvnt, MI_FACIL, signal_data->dchan_id, sngisdn_info->ces)) { + if (sng_isdn_facility_request(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &facEvnt, MI_FACIL, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused FACILITY request\n"); } return; @@ -323,9 +323,9 @@ void sngisdn_snd_info_req(ftdm_channel_t *ftdmchan) memset(&cnStEvnt, 0, sizeof(cnStEvnt)); - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending INFO REQ (suId:%d dchan:%d ces:%d)\n", signal_data->cc_id, signal_data->dchan_id, sngisdn_info->ces); + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending INFO REQ (suId:%d dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - if (sng_isdn_con_status(signal_data->cc_id, 0, 0, &cnStEvnt, MI_INFO, signal_data->dchan_id, sngisdn_info->ces)) { + if (sng_isdn_con_status(signal_data->cc_id, 0, 0, &cnStEvnt, MI_INFO, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused INFO request\n"); } return; @@ -349,9 +349,9 @@ void sngisdn_snd_notify_req(ftdm_channel_t *ftdmchan) set_not_ind_ie(ftdmchan, &cnStEvnt.notInd); - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending NOTIFY (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending NOTIFY (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); - if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId,&cnStEvnt, MI_NOTIFY, signal_data->dchan_id, sngisdn_info->ces)) { + if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId,&cnStEvnt, MI_NOTIFY, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces)) { ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused NOTIFY request\n"); } return; @@ -369,7 +369,7 @@ void sngisdn_snd_status_enq(ftdm_channel_t *ftdmchan) memset(&staEvnt, 0, sizeof(StaEvnt)); - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending Status ENQ on suId:%d suInstId:%u spInstId:%d dchan:%d ces:%d\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending Status ENQ on suId:%d suInstId:%u spInstId:%d dchan:%d ces:%d\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, sngisdn_dchan(signal_data)->link_id, sngisdn_info->ces); if (sng_isdn_status_request(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &staEvnt, MI_STATENQ)) { ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused Status ENQ request\n"); } @@ -469,9 +469,9 @@ void sngisdn_snd_restart(ftdm_channel_t *ftdmchan) set_chan_id_ie(ftdmchan, &rstEvnt.chanId); set_restart_ind_ie(ftdmchan, &rstEvnt.rstInd); - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending RESTART (suId:%d dchan:%d ces:%d)\n", signal_data->cc_id, signal_data->dchan_id, CES_MNGMNT); + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending RESTART (suId:%d dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_dchan(signal_data)->link_id, CES_MNGMNT); - if (sng_isdn_restart_request(signal_data->cc_id, &rstEvnt, signal_data->dchan_id, CES_MNGMNT, IN_SND_RST)) { + if (sng_isdn_restart_request(signal_data->cc_id, &rstEvnt, sngisdn_dchan(signal_data)->link_id, CES_MNGMNT, IN_SND_RST)) { ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused RESTART request\n"); } return; @@ -536,25 +536,26 @@ void sngisdn_snd_data(ftdm_channel_t *dchan, uint8_t *data, ftdm_size_t len) ftdm_log_chan(dchan, FTDM_LOG_CRIT, "\nL1 RX [%s] flags:%x\n", string, l1_frame.flags); } #endif - sng_isdn_data_ind(signal_data->dchan_id, &l1_frame); + sng_isdn_data_ind(signal_data->link_id, &l1_frame); } -void sngisdn_snd_event(ftdm_channel_t *dchan, ftdm_oob_event_t event) +void sngisdn_snd_event(sngisdn_span_data_t *signal_data, ftdm_oob_event_t event) { sng_l1_event_t l1_event; - sngisdn_span_data_t *signal_data = NULL; + + if (!signal_data->dchan) { + return; + } memset(&l1_event, 0, sizeof(l1_event)); - - - signal_data = (sngisdn_span_data_t*) dchan->span->signal_data; + switch(event) { case FTDM_OOB_ALARM_CLEAR: l1_event.type = SNG_L1EVENT_ALARM_OFF; - sng_isdn_event_ind(signal_data->dchan_id, &l1_event); + sng_isdn_event_ind(signal_data->link_id, &l1_event); break; case FTDM_OOB_ALARM_TRAP: l1_event.type = SNG_L1EVENT_ALARM_ON; - sng_isdn_event_ind(signal_data->dchan_id, &l1_event); + sng_isdn_event_ind(signal_data->link_id, &l1_event); break; default: /* We do not care about the other OOB events for now */ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c index b0e7d77284..a5ba7c54b9 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c @@ -33,17 +33,19 @@ */ #include "ftmod_sangoma_isdn.h" +//static void sngisdn_rcv_q931_ind_span(sngisdn_span_data_t *signal_data, InMngmt *status); void sngisdn_rcv_con_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, ConEvnt *conEvnt, int16_t dChan, uint8_t ces) { uint8_t bchan_no = 0; + int8_t interface_id = -1; /* Specifies which interface for NFAS */ sngisdn_chan_data_t *sngisdn_info = NULL; sngisdn_event_data_t *sngisdn_event = NULL; ISDN_FUNC_TRACE_ENTER(__FUNCTION__); ftdm_assert(g_sngisdn_data.ccs[suId].activation_done != 0, "Con Ind on unconfigured cc\n"); - ftdm_assert(g_sngisdn_data.dchans[dChan].num_spans != 0, "Con Ind on unconfigured dchan\n"); + ftdm_assert(g_sngisdn_data.spans[dChan], "Con Ind on unconfigured dchan\n"); if (conEvnt->chanId.eh.pres != PRSNT_NODEF) { /* TODO: Implement me */ @@ -58,19 +60,38 @@ void sngisdn_rcv_con_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, Co bchan_no = conEvnt->chanId.infoChanSel.val; } + if (conEvnt->chanId.intIdent.pres) { + interface_id = conEvnt->chanId.intIdent.val; + } + if (!bchan_no) { ftdm_log(FTDM_LOG_ERROR, "Failed to obtain b-channel number from SETUP message\n"); ISDN_FUNC_TRACE_EXIT(__FUNCTION__); return; } - if (g_sngisdn_data.dchans[dChan].channels[bchan_no] == NULL) { - ftdm_log(FTDM_LOG_ERROR, "Incoming call on unconfigured b-channel:%d\n", bchan_no); - ISDN_FUNC_TRACE_EXIT(__FUNCTION__); - return; + if (g_sngisdn_data.spans[dChan]->nfas.trunk) { + if (interface_id < 0) { + ftdm_log(FTDM_LOG_ERROR, "Interface ID not present on NFAS interface\n"); + ISDN_FUNC_TRACE_EXIT(__FUNCTION__); + return; + } else if (!g_sngisdn_data.spans[dChan]->nfas.trunk->spans[interface_id]) { + ftdm_log(FTDM_LOG_ERROR, "NFAS group:%s does not have logical interface %d\n", g_sngisdn_data.spans[dChan]->nfas.trunk->name, interface_id); + ISDN_FUNC_TRACE_EXIT(__FUNCTION__); + return; + } else { + sngisdn_info = g_sngisdn_data.spans[dChan]->nfas.trunk->spans[interface_id]->channels[bchan_no]; + } + } else { + if (g_sngisdn_data.spans[dChan]->channels[bchan_no] == NULL) { + ftdm_log(FTDM_LOG_ERROR, "Incoming call on unconfigured b-channel:%d\n", bchan_no); + ISDN_FUNC_TRACE_EXIT(__FUNCTION__); + return; + } + + sngisdn_info = g_sngisdn_data.spans[dChan]->channels[bchan_no]; } - - sngisdn_info = g_sngisdn_data.dchans[dChan].channels[bchan_no]; + ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received SETUP (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); @@ -103,7 +124,7 @@ void sngisdn_rcv_con_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, Cn ISDN_FUNC_TRACE_ENTER(__FUNCTION__); ftdm_assert(g_sngisdn_data.ccs[suId].activation_done != 0, "Con Cfm on unconfigured cc\n"); - ftdm_assert(g_sngisdn_data.dchans[dChan].num_spans != 0, "Con Cfm on unconfigured dchan\n"); + ftdm_assert(g_sngisdn_data.spans[dChan] != 0, "Con Cfm on unconfigured dchan\n"); if (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); @@ -147,7 +168,7 @@ void sngisdn_rcv_cnst_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, C ISDN_FUNC_TRACE_ENTER(__FUNCTION__); ftdm_assert(g_sngisdn_data.ccs[suId].activation_done != 0, "Cnst Ind on unconfigured cc\n"); - ftdm_assert(g_sngisdn_data.dchans[dChan].num_spans != 0, "Cnst Ind on unconfigured dchan\n"); + ftdm_assert(g_sngisdn_data.spans[dChan] != 0, "Cnst Ind on unconfigured dchan\n"); if (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); @@ -537,37 +558,41 @@ void sngisdn_rcv_sta_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, St void sngisdn_rcv_srv_ind (int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces) { - unsigned i; + sngisdn_span_data_t *signal_data; sngisdn_event_data_t *sngisdn_event = NULL; ISDN_FUNC_TRACE_ENTER(__FUNCTION__); ftdm_log(FTDM_LOG_INFO, "Received SERVICE IND (dChan:%d ces:%u)\n", dChan, ces); - - /* Enqueue the event to each span within the dChan */ - for(i=1; i<=g_sngisdn_data.dchans[dChan].num_spans; i++) { - signal_data = g_sngisdn_data.dchans[dChan].spans[i]; - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); - sngisdn_event->event_id = SNGISDN_EVENT_SRV_IND; - sngisdn_event->suId = suId; - sngisdn_event->dChan = dChan; - sngisdn_event->ces = ces; - sngisdn_event->signal_data = signal_data; - - memcpy(&sngisdn_event->event.srvEvnt, srvEvnt, sizeof(*srvEvnt)); - ftdm_queue_enqueue((signal_data)->event_queue, sngisdn_event); + signal_data = g_sngisdn_data.spans[dChan]; + + if (signal_data->nfas.trunk) { + unsigned i; + for (i = 0; i < signal_data->nfas.trunk->num_spans; i++) { + sngisdn_span_data_t *my_signal_data = signal_data->nfas.trunk->spans[i]; + + sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); + ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); + memset(sngisdn_event, 0, sizeof(*sngisdn_event)); + sngisdn_event->event_id = SNGISDN_EVENT_SRV_IND; + sngisdn_event->suId = suId; + sngisdn_event->dChan = dChan; + sngisdn_event->ces = ces; + sngisdn_event->signal_data = my_signal_data; + memcpy(&sngisdn_event->event.srvEvnt, srvEvnt, sizeof(*srvEvnt)); + ftdm_queue_enqueue(my_signal_data->event_queue, sngisdn_event); + } + } else { + ftdm_queue_enqueue(signal_data->event_queue, sngisdn_event); } ISDN_FUNC_TRACE_EXIT(__FUNCTION__); } void sngisdn_rcv_srv_cfm (int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces) -{ - unsigned i; +{ sngisdn_span_data_t *signal_data = NULL; sngisdn_event_data_t *sngisdn_event = NULL; @@ -575,59 +600,65 @@ void sngisdn_rcv_srv_cfm (int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces ftdm_log(FTDM_LOG_INFO, "Received SERVICE CFM (dChan:%d ces:%u)\n", dChan, ces); - /* Enqueue the event to each span within the dChan */ - for(i=1; i<=g_sngisdn_data.dchans[dChan].num_spans; i++) { - signal_data = g_sngisdn_data.dchans[dChan].spans[i]; - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); + signal_data = g_sngisdn_data.spans[dChan]; - sngisdn_event->event_id = SNGISDN_EVENT_SRV_CFM; - sngisdn_event->suId = suId; - sngisdn_event->dChan = dChan; - sngisdn_event->ces = ces; - sngisdn_event->signal_data = signal_data; + if (signal_data->nfas.trunk) { + unsigned i; + for (i = 0; i < signal_data->nfas.trunk->num_spans; i++) { + sngisdn_span_data_t *my_signal_data = signal_data->nfas.trunk->spans[i]; - memcpy(&sngisdn_event->event.srvEvnt, srvEvnt, sizeof(*srvEvnt)); - ftdm_queue_enqueue((signal_data)->event_queue, sngisdn_event); + sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); + ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); + memset(sngisdn_event, 0, sizeof(*sngisdn_event)); + sngisdn_event->event_id = SNGISDN_EVENT_SRV_CFM; + sngisdn_event->suId = suId; + sngisdn_event->dChan = dChan; + sngisdn_event->ces = ces; + sngisdn_event->signal_data = my_signal_data; + memcpy(&sngisdn_event->event.srvEvnt, srvEvnt, sizeof(*srvEvnt)); + ftdm_queue_enqueue(my_signal_data->event_queue, sngisdn_event); + } + } else { + ftdm_queue_enqueue(signal_data->event_queue, sngisdn_event); } ISDN_FUNC_TRACE_EXIT(__FUNCTION__); } void sngisdn_rcv_rst_ind (int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces, uint8_t evntType) -{ - unsigned i; +{ sngisdn_span_data_t *signal_data = NULL; sngisdn_event_data_t *sngisdn_event = NULL; ISDN_FUNC_TRACE_ENTER(__FUNCTION__); ftdm_log(FTDM_LOG_INFO, "Received RESTART IND (dChan:%d ces:%u type:%u)\n", dChan, ces, evntType); - - /* Enqueue the event to each span within the dChan */ - for(i=1; i<=g_sngisdn_data.dchans[dChan].num_spans; i++) { - signal_data = g_sngisdn_data.dchans[dChan].spans[i]; - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); + signal_data = g_sngisdn_data.spans[dChan]; - sngisdn_event->event_id = SNGISDN_EVENT_RST_IND; - sngisdn_event->suId = suId; - sngisdn_event->dChan = dChan; - sngisdn_event->ces = ces; - sngisdn_event->evntType = evntType; - sngisdn_event->signal_data = signal_data; + if (signal_data->nfas.trunk) { + unsigned i; + for (i = 0; i < signal_data->nfas.trunk->num_spans; i++) { + sngisdn_span_data_t *my_signal_data = signal_data->nfas.trunk->spans[i]; - memcpy(&sngisdn_event->event.rstEvnt, rstEvnt, sizeof(*rstEvnt)); + sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); + ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); + memset(sngisdn_event, 0, sizeof(*sngisdn_event)); + sngisdn_event->event_id = SNGISDN_EVENT_RST_IND; + sngisdn_event->suId = suId; + sngisdn_event->dChan = dChan; + sngisdn_event->ces = ces; + sngisdn_event->signal_data = my_signal_data; + memcpy(&sngisdn_event->event.rstEvnt, rstEvnt, sizeof(*rstEvnt)); + ftdm_queue_enqueue(my_signal_data->event_queue, sngisdn_event); + } + } else { ftdm_queue_enqueue(signal_data->event_queue, sngisdn_event); } ISDN_FUNC_TRACE_EXIT(__FUNCTION__); } void sngisdn_rcv_rst_cfm (int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces, uint8_t evntType) -{ - unsigned i; +{ sngisdn_span_data_t *signal_data; sngisdn_event_data_t *sngisdn_event = NULL; @@ -636,22 +667,26 @@ void sngisdn_rcv_rst_cfm (int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces ftdm_log(FTDM_LOG_INFO, "Received RESTART CFM (dChan:%d ces:%u type:%u)\n", dChan, ces, evntType); - /* Enqueue the event to each span within the dChan */ - for(i=1; i<=g_sngisdn_data.dchans[dChan].num_spans; i++) { - signal_data = g_sngisdn_data.dchans[dChan].spans[i]; - sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); - ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); - memset(sngisdn_event, 0, sizeof(*sngisdn_event)); + signal_data = g_sngisdn_data.spans[dChan]; - sngisdn_event->event_id = SNGISDN_EVENT_RST_CFM; - sngisdn_event->suId = suId; - sngisdn_event->dChan = dChan; - sngisdn_event->ces = ces; - sngisdn_event->evntType = evntType; - sngisdn_event->signal_data = signal_data; + if (signal_data->nfas.trunk) { + unsigned i; + for (i = 0; i < signal_data->nfas.trunk->num_spans; i++) { + sngisdn_span_data_t *my_signal_data = signal_data->nfas.trunk->spans[i]; - memcpy(&sngisdn_event->event.rstEvnt, rstEvnt, sizeof(*rstEvnt)); - ftdm_queue_enqueue((signal_data)->event_queue, sngisdn_event); + sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event)); + ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n"); + memset(sngisdn_event, 0, sizeof(*sngisdn_event)); + sngisdn_event->event_id = SNGISDN_EVENT_RST_CFM; + sngisdn_event->suId = suId; + sngisdn_event->dChan = dChan; + sngisdn_event->ces = ces; + sngisdn_event->signal_data = my_signal_data; + memcpy(&sngisdn_event->event.rstEvnt, rstEvnt, sizeof(*rstEvnt)); + ftdm_queue_enqueue(my_signal_data->event_queue, sngisdn_event); + } + } else { + ftdm_queue_enqueue(signal_data->event_queue, sngisdn_event); } ISDN_FUNC_TRACE_EXIT(__FUNCTION__); } @@ -660,7 +695,7 @@ void sngisdn_rcv_rst_cfm (int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces void sngisdn_rcv_phy_ind(SuId suId, Reason reason) { if (reason != LL1_REASON_CON_REQ_FAIL) { - ftdm_log(FTDM_LOG_INFO, "[SNGISDN PHY] D-chan %d : %s\n", suId, DECODE_LL1_REASON(reason)); + ftdm_log(FTDM_LOG_DEBUG, "[SNGISDN PHY] D-chan %d : %s\n", suId, DECODE_LL1_REASON(reason)); } return; } @@ -669,7 +704,7 @@ void sngisdn_rcv_q921_ind(BdMngmt *status) { ftdm_span_t *ftdmspan; - sngisdn_span_data_t *signal_data = g_sngisdn_data.dchans[status->t.usta.lnkNmb].spans[1]; + sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[status->t.usta.lnkNmb]; if (!signal_data) { ftdm_log(FTDM_LOG_INFO, "Received q921 status on unconfigured span (lnkNmb:%d)\n", status->t.usta.lnkNmb); @@ -722,8 +757,43 @@ void sngisdn_rcv_q921_ind(BdMngmt *status) } return; } + +#if 0 +static void sngisdn_rcv_q931_ind_span(sngisdn_span_data_t *signal_data, InMngmt *status) +{ + ftdm_span_t *ftdmspan = signal_data->ftdm_span; + uint32_t chan_no = status->t.usta.evntParm[2]; + + if (!signal_data) { + ftdm_log(FTDM_LOG_INFO, "Received q931 status on unconfigured span (lnkNmb:%d)\n", status->t.usta.suId); + return; + } + + ftdm_log(FTDM_LOG_INFO, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n", + status->t.usta.suId, + DECODE_LCM_CATEGORY(status->t.usta.alarm.category), + DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event, + DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause); + + if (chan_no) { + ftdm_channel_t *ftdmchan = ftdm_span_get_channel(ftdmspan, chan_no); + if (ftdmchan) { + sngisdn_set_chan_sig_status(ftdmchan, (status->t.usta.alarm.event == LCM_EVENT_UP) ? FTDM_SIG_STATE_UP : FTDM_SIG_STATE_DOWN); + sngisdn_set_chan_avail_rate(ftdmchan, (status->t.usta.alarm.event == LCM_EVENT_UP) ? SNGISDN_AVAIL_UP: SNGISDN_AVAIL_PWR_SAVING); + } else { + ftdm_log(FTDM_LOG_CRIT, "stack alarm event on invalid channel :%d\n", chan_no); + } + } else { + sngisdn_set_span_sig_status(ftdmspan, (status->t.usta.alarm.event == LCM_EVENT_UP) ? FTDM_SIG_STATE_UP : FTDM_SIG_STATE_DOWN); + sngisdn_set_span_avail_rate(ftdmspan, (status->t.usta.alarm.event == LCM_EVENT_UP) ? SNGISDN_AVAIL_UP: SNGISDN_AVAIL_PWR_SAVING); + } +} +#endif + void sngisdn_rcv_q931_ind(InMngmt *status) -{ +{ + sngisdn_span_data_t *signal_data = NULL; + ftdm_span_t *ftdmspan = NULL; #ifndef WIN32 if (status->t.usta.alarm.cause == 287) { sngisdn_get_memory_info(); @@ -731,47 +801,53 @@ void sngisdn_rcv_q931_ind(InMngmt *status) } #endif + signal_data = g_sngisdn_data.spans[status->t.usta.suId]; + if (!signal_data) { + ftdm_log(FTDM_LOG_INFO, "Received q931 status on unconfigured span (lnkNmb:%d)\n", status->t.usta.suId); + return; + } + + ftdmspan = signal_data->ftdm_span; + switch (status->t.usta.alarm.event) { case LCM_EVENT_UP: case LCM_EVENT_DOWN: { - ftdm_span_t *ftdmspan; - sngisdn_span_data_t *signal_data = g_sngisdn_data.dchans[status->t.usta.suId].spans[1]; - if (!signal_data) { - ftdm_log(FTDM_LOG_INFO, "Received q931 status on unconfigured span (lnkNmb:%d)\n", status->t.usta.suId); - return; - } - ftdmspan = signal_data->ftdm_span; - - if (status->t.usta.alarm.event == LCM_EVENT_UP) { - uint32_t chan_no = status->t.usta.evntParm[2]; - ftdm_log(FTDM_LOG_INFO, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n", - status->t.usta.suId, - DECODE_LCM_CATEGORY(status->t.usta.alarm.category), - DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event, - DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause); + int i; + sngisdn_nfas_data_t *nfas_data = NULL; + ftdm_log(FTDM_LOG_INFO, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n", + status->t.usta.suId, + DECODE_LCM_CATEGORY(status->t.usta.alarm.category), + DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event, + DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause); - if (chan_no) { - ftdm_channel_t *ftdmchan = ftdm_span_get_channel(ftdmspan, chan_no); - if (ftdmchan) { - sngisdn_set_chan_sig_status(ftdmchan, FTDM_SIG_STATE_UP); - sngisdn_set_chan_avail_rate(ftdmchan, SNGISDN_AVAIL_UP); - } else { - ftdm_log(FTDM_LOG_CRIT, "stack alarm event on invalid channel :%d\n", chan_no); + nfas_data = signal_data->nfas.trunk; + + if (nfas_data && status->t.usta.alarm.event == LCM_EVENT_UP) { + for (i = 0; i < ftdm_array_len(nfas_data->spans); i++) { + if (nfas_data->spans[i] && nfas_data->spans[i]->nfas.sigchan == SNGISDN_NFAS_DCHAN_NONE) { + + sngisdn_set_span_sig_status(nfas_data->spans[i]->ftdm_span, FTDM_SIG_STATE_UP); + sngisdn_set_span_avail_rate(nfas_data->spans[i]->ftdm_span, SNGISDN_AVAIL_UP); + } + } + } + + sngisdn_set_span_sig_status(ftdmspan, (status->t.usta.alarm.event == LCM_EVENT_UP) ? FTDM_SIG_STATE_UP : FTDM_SIG_STATE_DOWN); + sngisdn_set_span_avail_rate(ftdmspan, (status->t.usta.alarm.event == LCM_EVENT_UP) ? SNGISDN_AVAIL_UP: SNGISDN_AVAIL_PWR_SAVING); + + if (nfas_data && status->t.usta.alarm.event == LCM_EVENT_DOWN) { + if (nfas_data->dchan->sigstatus == FTDM_SIG_STATE_DOWN && + (nfas_data->backup && nfas_data->backup->sigstatus == FTDM_SIG_STATE_DOWN)) { + + for (i = 0; i < ftdm_array_len(nfas_data->spans); i++) { + if (nfas_data->spans[i] && nfas_data->spans[i]->nfas.sigchan == SNGISDN_NFAS_DCHAN_NONE) { + + sngisdn_set_span_sig_status(nfas_data->spans[i]->ftdm_span, FTDM_SIG_STATE_DOWN); + sngisdn_set_span_avail_rate(nfas_data->spans[i]->ftdm_span, SNGISDN_AVAIL_PWR_SAVING); + } } - } else { - sngisdn_set_span_sig_status(ftdmspan, FTDM_SIG_STATE_UP); - sngisdn_set_span_avail_rate(ftdmspan, SNGISDN_AVAIL_UP); } - } else { - ftdm_log(FTDM_LOG_WARNING, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n", - status->t.usta.suId, - DECODE_LCM_CATEGORY(status->t.usta.alarm.category), - DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event, - DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause); - - sngisdn_set_span_sig_status(ftdmspan, FTDM_SIG_STATE_DOWN); - sngisdn_set_span_avail_rate(ftdmspan, SNGISDN_AVAIL_PWR_SAVING); } } break; @@ -805,7 +881,7 @@ void sngisdn_rcv_q931_trace(InMngmt *trc, Buffer *mBuf) ftdm_trace_dir_t dir; uint8_t tdata[1000]; - sngisdn_span_data_t *signal_data = g_sngisdn_data.dchans[trc->t.trc.suId].spans[1]; + sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[trc->t.trc.suId]; ftdm_assert(mBuf != NULLP, "Received a Q931 trace with no buffer"); mlen = ((SsMsgInfo*)(mBuf->b_rptr))->len; @@ -851,7 +927,7 @@ void sngisdn_rcv_q921_trace(BdMngmt *trc, Buffer *mBuf) ftdm_trace_dir_t dir; uint8_t tdata[1000]; - sngisdn_span_data_t *signal_data = g_sngisdn_data.dchans[trc->t.trc.lnkNmb].spans[1]; + sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[trc->t.trc.lnkNmb]; if (trc->t.trc.evnt == TL2TMR) { return; @@ -900,7 +976,7 @@ int16_t sngisdn_rcv_l1_data_req(uint16_t spId, sng_l1_frame_t *l1_frame) { ftdm_status_t status; ftdm_wait_flag_t flags = FTDM_WRITE; - sngisdn_span_data_t *signal_data = g_sngisdn_data.dchans[spId].spans[1]; + sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[spId]; ftdm_size_t length = l1_frame->len; ftdm_assert(signal_data, "Received Data request on unconfigured span\n"); @@ -952,7 +1028,7 @@ int16_t sngisdn_rcv_l1_data_req(uint16_t spId, sng_l1_frame_t *l1_frame) int16_t sngisdn_rcv_l1_cmd_req(uint16_t spId, sng_l1_cmd_t *l1_cmd) { - sngisdn_span_data_t *signal_data = g_sngisdn_data.dchans[spId].spans[1]; + sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[spId]; ftdm_assert(signal_data, "Received Data request on unconfigured span\n"); switch(l1_cmd->type) { diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c index 0606f79643..5f63f384d7 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c @@ -1081,11 +1081,12 @@ ftdm_status_t set_cause_ie(ftdm_channel_t *ftdmchan, CauseDgn *causeDgn) ftdm_status_t set_chan_id_ie(ftdm_channel_t *ftdmchan, ChanId *chanId) { + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)ftdmchan->call_data; if (!ftdmchan) { return FTDM_SUCCESS; } - + ftdm_set_flag(sngisdn_info, FLAG_SENT_CHAN_ID); chanId->eh.pres = PRSNT_NODEF; @@ -1104,6 +1105,12 @@ ftdm_status_t set_chan_id_ie(ftdm_channel_t *ftdmchan, ChanId *chanId) chanId->infoChanSel.pres = PRSNT_NODEF; chanId->infoChanSel.val = ftdmchan->physical_chan_id; } else { + if (signal_data->nfas.trunk) { + chanId->intIdentPres.val = IN_IIP_EXPLICIT; + chanId->intIdent.pres = PRSNT_NODEF; + chanId->intIdent.val = signal_data->nfas.interface_id; + } + chanId->intType.pres = PRSNT_NODEF; chanId->intType.val = IN_IT_OTHER; chanId->infoChanSel.pres = PRSNT_NODEF; @@ -1118,6 +1125,7 @@ ftdm_status_t set_chan_id_ie(ftdm_channel_t *ftdmchan, ChanId *chanId) chanId->chanNmbSlotMap.len = 1; chanId->chanNmbSlotMap.val[0] = ftdmchan->physical_chan_id; } + return FTDM_SUCCESS; } @@ -1237,6 +1245,23 @@ void sngisdn_delayed_setup(void *p_sngisdn_info) return; } +void sngisdn_delayed_release_nfas(void *p_sngisdn_info) +{ + sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)p_sngisdn_info; + ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; + + ftdm_mutex_lock(ftdmchan->mutex); + + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending delayed RELEASE (suId:%d suInstId:%u spInstId:%u)\n", + signal_data->cc_id, sngisdn_info->spInstId, sngisdn_info->suInstId); + + sngisdn_snd_release(ftdmchan, 0); + + ftdm_mutex_unlock(ftdmchan->mutex); + return; +} + void sngisdn_delayed_release(void *p_sngisdn_info) { sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)p_sngisdn_info; @@ -1433,7 +1458,7 @@ ftdm_status_t sngisdn_show_l1_stats(ftdm_stream_handle_t *stream, ftdm_span_t *s sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; memset(&sts, 0, sizeof(sts)); - sng_isdn_phy_stats(signal_data->link_id , &sts); + sng_isdn_phy_stats(sngisdn_dchan(signal_data)->link_id , &sts); stream->write_function(stream, "\n---------------------------------------------------------------------\n"); stream->write_function(stream, " Span:%s", span->name); @@ -1568,6 +1593,14 @@ void sngisdn_send_signal(sngisdn_chan_data_t *sngisdn_info, ftdm_signal_event_t ftdm_span_send_signal(ftdmchan->span, &sigev); } +sngisdn_span_data_t *sngisdn_dchan(sngisdn_span_data_t *signal_data) +{ + if (!signal_data->nfas.trunk) { + return signal_data; + } + return signal_data->nfas.trunk->dchan; +} + /* For Emacs: * Local Variables: diff --git a/libs/spandsp/configure.ac b/libs/spandsp/configure.ac index f1bed65c51..22fccd6d25 100644 --- a/libs/spandsp/configure.ac +++ b/libs/spandsp/configure.ac @@ -238,10 +238,8 @@ AC_CHECK_HEADERS([FL/Fl.H]) AC_CHECK_HEADERS([FL/Fl_Overlay_Window.H]) AC_CHECK_HEADERS([FL/Fl_Light_Button.H]) AC_CHECK_HEADERS([FL/fl_draw.H]) -AC_CHECK_HEADERS([FL/Fl_Cartesian.H], [], [], [],[[#include -]]) -AC_CHECK_HEADERS([FL/Fl_Audio_Meter.H], [], [], [],[[#include -]]) +AC_CHECK_HEADERS([FL/Fl_Cartesian.H]) +AC_CHECK_HEADERS([FL/Fl_Audio_Meter.H]) AC_LANG([C]) @@ -520,6 +518,8 @@ if test "$enable_builtin_tiff" = "yes" ; then save_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -I$abs_tiffdir/libtiff" AC_CHECK_HEADERS([tiffio.h]) + AC_CHECK_HEADERS([tif_dir.h], [], [], [#include +]) CFLAGS="$save_CFLAGS" COMP_VENDOR_CFLAGS="-I$abs_tiffdir/libtiff $COMP_VENDOR_CFLAGS" COMP_VENDOR_LDFLAGS="-L$abs_tiffdir/libtiff $COMP_VENDOR_LDFLAGS" @@ -527,8 +527,18 @@ if test "$enable_builtin_tiff" = "yes" ; then AC_DEFINE([HAVE_LIBTIFF], [1], [Define to 1 if you have the `tiff' library (-ltiff).]) else AC_CHECK_HEADERS([tiffio.h]) + AC_CHECK_HEADERS([tif_dir.h], [], [], [#include +]) AC_CHECK_LIB([tiff], [TIFFOpen], [TIFF_LIBS="-ltiff"], AC_MSG_ERROR("Cannot build without libtiff (does your system require a libtiff-devel package?)"), -lm) fi + +if test "$ac_cv_header_tif_dir_h" = "yes" ; then + AC_DEFINE([SPANDSP_SUPPORT_TIFF_FX], [1], [Support TIFF/FX in TIFF file handling]) + SPANDSP_SUPPORT_TIFF_FX="#define SPANDSP_SUPPORT_TIFF_FX" +else + SPANDSP_SUPPORT_TIFF_FX="#undef SPANDSP_SUPPORT_TIFF_FX" +fi + AC_CHECK_HEADERS([jpeglib.h]) AC_CHECK_LIB([jpeg], [jpeg_start_compress], [JPEG_LIBS="-ljpeg"]) @@ -551,6 +561,7 @@ AC_SUBST(SPANDSP_USE_EXPORT_CAPABILITY) AC_SUBST(SPANDSP_SUPPORT_T42) AC_SUBST(SPANDSP_SUPPORT_T43) AC_SUBST(SPANDSP_SUPPORT_V34) +AC_SUBST(SPANDSP_SUPPORT_TIFF_FX) AC_SUBST(INSERT_INTTYPES_HEADER) AC_SUBST(INSERT_STDINT_HEADER) AC_SUBST(INSERT_TGMATH_HEADER) diff --git a/libs/spandsp/src/spandsp.h.in b/libs/spandsp/src/spandsp.h.in index 0b1f7aec9b..8dcafa50e8 100644 --- a/libs/spandsp/src/spandsp.h.in +++ b/libs/spandsp/src/spandsp.h.in @@ -36,6 +36,7 @@ @SPANDSP_SUPPORT_T42@ @SPANDSP_SUPPORT_T43@ @SPANDSP_SUPPORT_V34@ +@SPANDSP_SUPPORT_TIFF_FX@ #include @INSERT_INTTYPES_HEADER@ diff --git a/libs/spandsp/src/spandsp/t31.h b/libs/spandsp/src/spandsp/t31.h index 80a676b207..df842b0972 100644 --- a/libs/spandsp/src/spandsp/t31.h +++ b/libs/spandsp/src/spandsp/t31.h @@ -57,6 +57,12 @@ extern "C" SPAN_DECLARE(void) t31_call_event(t31_state_t *s, int event); +/*! Return the amount of free space in the AT COMMAND BUFFER. + \brief Return the amount of free space in the AT COMMAND BUFFER. + \param s The T.31 modem context. + \return The number of bytes of free space. */ +SPAN_DECLARE(int) t31_at_rx_free_space(t31_state_t *s); + SPAN_DECLARE(int) t31_at_rx(t31_state_t *s, const char *t, int len); /*! Process a block of received T.31 modem audio samples. diff --git a/libs/spandsp/src/spandsp/t4_tx.h b/libs/spandsp/src/spandsp/t4_tx.h index 7c100793c1..3eccc679c8 100644 --- a/libs/spandsp/src/spandsp/t4_tx.h +++ b/libs/spandsp/src/spandsp/t4_tx.h @@ -28,8 +28,6 @@ #if !defined(_SPANDSP_T4_TX_H_) #define _SPANDSP_T4_TX_H_ -#define SPANDSP_SUPPORT_TIFF_FX - /*! This function is a callback from the image decoders, to read the unencoded bi-level image, row by row. It is called for each row, with len set to the number of bytes per row expected. \return len for OK, or zero to indicate the end of the image data. */ @@ -41,8 +39,7 @@ typedef int (*t4_row_read_handler_t)(void *user_data, uint8_t buf[], size_t len) */ typedef struct t4_tx_state_s t4_tx_state_t; -#if defined(SPANDSP_SUPPORT_TIFF_FX) -/* TIFF-FX related extensions to the tag set supported by libtiff */ +/* TIFF-FX related extensions to the TIFF tag set */ /* Indexed(346) = 0, 1. SHORT @@ -55,7 +52,7 @@ Indexed(346) = 0, 1. SHORT profile supports palette-color images with the ITULAB encoding. The SamplesPerPixel value must be 1. -GlobalParametersIFD (400) IFD +GlobalParametersIFD (400) IFD/LONG An IFD containing global parameters. It is recommended that a TIFF writer place this field in the first IFD, where a TIFF reader would find it quickly. @@ -177,6 +174,9 @@ ImageLayer(34732) LONG 3: ... */ +/* Define the TIFF/FX tags to extend libtiff, when using a version of libtiff where this + stuff has not been merged. */ +#if defined(SPANDSP_SUPPORT_TIFF_FX) && !defined(TIFFTAG_FAXPROFILE) #define TIFFTAG_INDEXED 346 #define TIFFTAG_GLOBALPARAMETERSIFD 400 #define TIFFTAG_PROFILETYPE 401 diff --git a/libs/spandsp/src/spandsp/version.h b/libs/spandsp/src/spandsp/version.h index a07f2f061d..469cd37b08 100644 --- a/libs/spandsp/src/spandsp/version.h +++ b/libs/spandsp/src/spandsp/version.h @@ -28,9 +28,9 @@ /* The date and time of the version are in UTC form. */ -#define SPANDSP_RELEASE_DATE 20100724 +#define SPANDSP_RELEASE_DATE 20120902 #define SPANDSP_RELEASE_TIME 163333 -#define SPANDSP_RELEASE_DATETIME_STRING "20100724 163333" +#define SPANDSP_RELEASE_DATETIME_STRING "20120902 163333" #endif /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/t31.c b/libs/spandsp/src/t31.c index 897bd066e3..8e747c4d0f 100644 --- a/libs/spandsp/src/t31.c +++ b/libs/spandsp/src/t31.c @@ -2180,6 +2180,12 @@ SPAN_DECLARE(void) t31_call_event(t31_state_t *s, int event) } /*- End of function --------------------------------------------------------*/ +SPAN_DECLARE(int) t31_at_rx_free_space(t31_state_t *s) +{ + return T31_TX_BUF_LEN - (s->tx.in_bytes - s->tx.out_bytes) - 1; +} +/*- End of function --------------------------------------------------------*/ + SPAN_DECLARE(int) t31_at_rx(t31_state_t *s, const char *t, int len) { if (s->dte_data_timeout) @@ -2215,7 +2221,7 @@ SPAN_DECLARE(int) t31_at_rx(t31_state_t *s, const char *t, int len) if (s->tx.out_bytes) { /* Make room for new data in existing data buffer. */ - s->tx.in_bytes = &s->tx.data[s->tx.in_bytes] - &s->tx.data[s->tx.out_bytes]; + s->tx.in_bytes -= s->tx.out_bytes; memmove(&s->tx.data[0], &s->tx.data[s->tx.out_bytes], s->tx.in_bytes); s->tx.out_bytes = 0; } diff --git a/libs/spandsp/src/t4_rx.c b/libs/spandsp/src/t4_rx.c index b9533c0e1c..f3b34167b2 100644 --- a/libs/spandsp/src/t4_rx.c +++ b/libs/spandsp/src/t4_rx.c @@ -81,6 +81,10 @@ /*! The number of centimetres in one inch */ #define CM_PER_INCH 2.54f +#if defined(SPANDSP_SUPPORT_TIFF_FX) +extern TIFFFieldArray tiff_fx_field_array; +#endif + SPAN_DECLARE(const char *) t4_encoding_to_str(int encoding) { switch (encoding) @@ -126,17 +130,20 @@ static int set_tiff_directory_info(t4_rx_state_t *s) /* Prepare the directory entry fully before writing the image, or libtiff complains */ switch (t->output_encoding) { - case T4_COMPRESSION_ITU_T6: - output_compression = COMPRESSION_CCITT_T6; - output_t4_options = 0; + case T4_COMPRESSION_ITU_T4_1D: + default: + output_compression = COMPRESSION_CCITT_T4; + output_t4_options = GROUP3OPT_FILLBITS; break; case T4_COMPRESSION_ITU_T4_2D: output_compression = COMPRESSION_CCITT_T4; output_t4_options = GROUP3OPT_FILLBITS | GROUP3OPT_2DENCODING; break; - default: - output_compression = COMPRESSION_CCITT_T4; - output_t4_options = GROUP3OPT_FILLBITS; + case T4_COMPRESSION_ITU_T6: + output_compression = COMPRESSION_CCITT_T6; + break; + case T4_COMPRESSION_ITU_T85: + output_compression = COMPRESSION_T85; break; } @@ -146,10 +153,21 @@ static int set_tiff_directory_info(t4_rx_state_t *s) case COMPRESSION_CCITT_T4: TIFFSetField(t->tiff_file, TIFFTAG_T4OPTIONS, output_t4_options); TIFFSetField(t->tiff_file, TIFFTAG_FAXMODE, FAXMODE_CLASSF); + TIFFSetField(t->tiff_file, TIFFTAG_ROWSPERSTRIP, -1L); break; case COMPRESSION_CCITT_T6: TIFFSetField(t->tiff_file, TIFFTAG_T6OPTIONS, 0); TIFFSetField(t->tiff_file, TIFFTAG_FAXMODE, FAXMODE_CLASSF); + TIFFSetField(t->tiff_file, TIFFTAG_ROWSPERSTRIP, -1L); + break; + case COMPRESSION_T85: + TIFFSetField(t->tiff_file, TIFFTAG_FAXMODE, FAXMODE_CLASSF); + TIFFSetField(t->tiff_file, TIFFTAG_ROWSPERSTRIP, -1L); + break; + default: + TIFFSetField(t->tiff_file, + TIFFTAG_ROWSPERSTRIP, + TIFFDefaultStripSize(t->tiff_file, 0)); break; } #if defined(SPANDSP_SUPPORT_TIFF_FX) @@ -162,21 +180,10 @@ static int set_tiff_directory_info(t4_rx_state_t *s) TIFFSetField(t->tiff_file, TIFFTAG_BITSPERSAMPLE, 1); TIFFSetField(t->tiff_file, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); TIFFSetField(t->tiff_file, TIFFTAG_SAMPLESPERPIXEL, 1); - if (output_compression == COMPRESSION_CCITT_T4 - || - output_compression == COMPRESSION_CCITT_T6) - { - TIFFSetField(t->tiff_file, TIFFTAG_ROWSPERSTRIP, -1L); - } - else - { - TIFFSetField(t->tiff_file, - TIFFTAG_ROWSPERSTRIP, - TIFFDefaultStripSize(t->tiff_file, 0)); - } TIFFSetField(t->tiff_file, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(t->tiff_file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); TIFFSetField(t->tiff_file, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB); + /* TIFFTAG_STRIPBYTECOUNTS and TIFFTAG_STRIPOFFSETS are added automatically */ x_resolution = s->metadata.x_resolution/100.0f; y_resolution = s->metadata.y_resolution/100.0f; @@ -266,6 +273,13 @@ static int set_tiff_directory_info(t4_rx_state_t *s) TIFFSetField(t->tiff_file, TIFFTAG_IMAGELENGTH, t85_decode_get_image_length(&s->decoder.t85)); break; } +#if defined(SPANDSP_SUPPORT_TIFF_FX) + if (s->current_page == 0) + { + /* Create a placeholder for the global parameters IFD, to be filled in later */ + TIFFSetField(t->tiff_file, TIFFTAG_GLOBALPARAMETERSIFD, 0); + } +#endif return 0; } /*- End of function --------------------------------------------------------*/ @@ -280,15 +294,45 @@ static int open_tiff_output_file(t4_rx_state_t *s, const char *file) static int write_tiff_image(t4_rx_state_t *s) { - if (s->tiff.image_buffer == NULL || s->tiff.image_size <= 0) + t4_rx_tiff_state_t *t; +#if defined(SPANDSP_SUPPORT_TIFF_FX) + uint64_t offset; +#endif + + t = &s->tiff; + if (t->image_buffer == NULL || t->image_size <= 0) return -1; /* Set up the TIFF directory info... */ set_tiff_directory_info(s); /* ...and then write the image... */ - if (TIFFWriteEncodedStrip(s->tiff.tiff_file, 0, s->tiff.image_buffer, s->tiff.image_size) < 0) - span_log(&s->logging, SPAN_LOG_WARNING, "%s: Error writing TIFF strip.\n", s->tiff.file); + if (TIFFWriteEncodedStrip(t->tiff_file, 0, t->image_buffer, t->image_size) < 0) + span_log(&s->logging, SPAN_LOG_WARNING, "%s: Error writing TIFF strip.\n", t->file); /* ...then the directory entry, and libtiff is happy. */ - TIFFWriteDirectory(s->tiff.tiff_file); + if (!TIFFWriteDirectory(t->tiff_file)) + span_log(&s->logging, SPAN_LOG_WARNING, "%s: Failed to write directory for page %d.\n", t->file, s->current_page); +#if defined(SPANDSP_SUPPORT_TIFF_FX) + if (s->current_page == 0) + { + if (!TIFFCreateCustomDirectory(t->tiff_file, &tiff_fx_field_array)) + { + TIFFSetField(t->tiff_file, TIFFTAG_FAXPROFILE, PROFILETYPE_G3_FAX); + TIFFSetField(t->tiff_file, TIFFTAG_PROFILETYPE, FAXPROFILE_S); + TIFFSetField(t->tiff_file, TIFFTAG_VERSIONYEAR, "1998"); + + offset = 0; + if (!TIFFWriteCustomDirectory(t->tiff_file, &offset)) + printf("Failed to write custom directory.\n"); + + /* Now go back and patch in the pointer to the new IFD */ + if (!TIFFSetDirectory(t->tiff_file, s->current_page)) + printf("Failed to set directory.\n"); + if (!TIFFSetField(t->tiff_file, TIFFTAG_GLOBALPARAMETERSIFD, offset)) + printf("Failed to set field.\n"); + if (!TIFFWriteDirectory(t->tiff_file)) + span_log(&s->logging, SPAN_LOG_WARNING, "%s: Failed to write directory for page %d.\n", t->file, s->current_page); + } + } +#endif return 0; } /*- End of function --------------------------------------------------------*/ @@ -308,9 +352,11 @@ static int close_tiff_output_file(t4_rx_state_t *s) need to set the correct total page count associated with each page. */ for (i = 0; i < s->current_page; i++) { - TIFFSetDirectory(t->tiff_file, (tdir_t) i); + if (!TIFFSetDirectory(t->tiff_file, (tdir_t) i)) + span_log(&s->logging, SPAN_LOG_WARNING, "%s: Failed to set directory to page %d.\n", s->tiff.file, i); TIFFSetField(t->tiff_file, TIFFTAG_PAGENUMBER, i, s->current_page); - TIFFWriteDirectory(t->tiff_file); + if (!TIFFWriteDirectory(t->tiff_file)) + span_log(&s->logging, SPAN_LOG_WARNING, "%s: Failed to write directory for page %d.\n", s->tiff.file, i); } } TIFFClose(t->tiff_file); diff --git a/libs/spandsp/src/t4_tx.c b/libs/spandsp/src/t4_tx.c index 8dde6e8e98..6aeef44d22 100644 --- a/libs/spandsp/src/t4_tx.c +++ b/libs/spandsp/src/t4_tx.c @@ -79,15 +79,15 @@ #include "faxfont.h" -#if 0 #if defined(SPANDSP_SUPPORT_TIFF_FX) #include #endif -#endif /*! The number of centimetres in one inch */ #define CM_PER_INCH 2.54f +static void t4_tx_set_image_length(t4_tx_state_t *s, int image_length); + #if defined(SPANDSP_SUPPORT_TIFF_FX) /* TIFF-FX related extensions to the tag set supported by libtiff */ static const TIFFFieldInfo tiff_fx_tiff_field_info[] = @@ -106,7 +106,6 @@ static const TIFFFieldInfo tiff_fx_tiff_field_info[] = {TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, FIELD_CUSTOM, FALSE, FALSE, (char *) "ImageLayer"}, }; -#if 0 static TIFFField tiff_fx_tiff_fields[] = { { TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, (char *) "Indexed" }, @@ -124,9 +123,6 @@ static TIFFField tiff_fx_tiff_fields[] = }; TIFFFieldArray tiff_fx_field_array = { tfiatOther, 0, 12, tiff_fx_tiff_fields }; -#endif - -static void t4_tx_set_image_length(t4_tx_state_t *s, int image_length); static TIFFExtendProc _ParentExtender = NULL; @@ -164,6 +160,7 @@ static int test_resolution(int res_unit, float actual, float expected) } /*- End of function --------------------------------------------------------*/ +#if defined(SPANDSP_SUPPORT_TIFF_FX) static int read_colour_map(t4_tx_state_t *s, int bits_per_sample) { int i; @@ -187,7 +184,7 @@ static int read_colour_map(t4_tx_state_t *s, int bits_per_sample) /* Sweep the colormap in the proper order */ for (i = 0; i < (1 << bits_per_sample); i++) { - s->colour_map[3*i] = (map_L[i] >> 8) & 0xFF; + s->colour_map[3*i + 0] = (map_L[i] >> 8) & 0xFF; s->colour_map[3*i + 1] = (map_a[i] >> 8) & 0xFF; s->colour_map[3*i + 2] = (map_b[i] >> 8) & 0xFF; span_log(&s->logging, SPAN_LOG_FLOW, "Map %3d - %5d %5d %5d\n", i, s->colour_map[3*i], s->colour_map[3*i + 1], s->colour_map[3*i + 2]); @@ -196,8 +193,8 @@ static int read_colour_map(t4_tx_state_t *s, int bits_per_sample) /* Sweep the colormap in the order that seems to work for l04x_02x.tif */ for (i = 0; i < (1 << bits_per_sample); i++) { - s->colour_map[i] = (map_L[i] >> 8) & 0xFF; - s->colour_map[256 + i] = (map_a[i] >> 8) & 0xFF; + s->colour_map[0*256 + i] = (map_L[i] >> 8) & 0xFF; + s->colour_map[1*256 + i] = (map_a[i] >> 8) & 0xFF; s->colour_map[2*256 + i] = (map_b[i] >> 8) & 0xFF; } #endif @@ -207,6 +204,7 @@ static int read_colour_map(t4_tx_state_t *s, int bits_per_sample) return 0; } /*- End of function --------------------------------------------------------*/ +#endif static int get_tiff_directory_info(t4_tx_state_t *s) { @@ -240,6 +238,7 @@ static int get_tiff_directory_info(t4_tx_state_t *s) {1200.0f/CM_PER_INCH, T4_Y_RESOLUTION_1200}, { -1.00f, -1} }; +#if defined(SPANDSP_SUPPORT_TIFF_FX) static const char *tiff_fx_fax_profiles[] = { "???", @@ -250,18 +249,19 @@ static int get_tiff_directory_info(t4_tx_state_t *s) "profile L", "profile M" }; - uint16_t res_unit; - uint8_t parm8; - uint16_t parm16; - uint32_t parm32; char *u; char uu[10]; + uint8_t parm8; + uint16_t parm16; +#endif + uint32_t parm32; float x_resolution; float y_resolution; int i; t4_tx_tiff_state_t *t; uint16_t bits_per_sample; uint16_t samples_per_pixel; + uint16_t res_unit; t = &s->tiff; bits_per_sample = 1; diff --git a/libs/tiff-4.0.2/Makefile.am b/libs/tiff-4.0.2/Makefile.am index 8e93e3c3da..87c8d6a3c0 100644 --- a/libs/tiff-4.0.2/Makefile.am +++ b/libs/tiff-4.0.2/Makefile.am @@ -25,7 +25,7 @@ docdir = $(LIBTIFF_DOCDIR) -AUTOMAKE_OPTIONS = 1.11 dist-zip foreign +AUTOMAKE_OPTIONS = 1.7 dist-zip foreign ACLOCAL_AMFLAGS = -I m4 docfiles = \ diff --git a/libs/tiff-4.0.2/Makefile.in b/libs/tiff-4.0.2/Makefile.in deleted file mode 100644 index ff8e35ff21..0000000000 --- a/libs/tiff-4.0.2/Makefile.in +++ /dev/null @@ -1,867 +0,0 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -# Tag Image File Format (TIFF) Software -# -# Copyright (C) 2004, Andrey Kiselev -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. - -# Process this file with automake to produce Makefile.in. - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = . -DIST_COMMON = README $(am__configure_deps) $(dist_doc_DATA) \ - $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(srcdir)/libtiff-4.pc.in $(top_srcdir)/configure ChangeLog \ - TODO config/compile config/config.guess config/config.sub \ - config/depcomp config/install-sh config/ltmain.sh \ - config/missing config/mkinstalldirs -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ - configure.lineno config.status.lineno -mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h -CONFIG_CLEAN_FILES = libtiff-4.pc -CONFIG_CLEAN_VPATH_FILES = -AM_V_GEN = $(am__v_GEN_$(V)) -am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) -am__v_GEN_0 = @echo " GEN " $@; -AM_V_at = $(am__v_at_$(V)) -am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) -am__v_at_0 = @ -SOURCES = -DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ - html-recursive info-recursive install-data-recursive \ - install-dvi-recursive install-exec-recursive \ - install-html-recursive install-info-recursive \ - install-pdf-recursive install-ps-recursive install-recursive \ - installcheck-recursive installdirs-recursive pdf-recursive \ - ps-recursive uninstall-recursive -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__installdirs = "$(DESTDIR)$(docdir)" "$(DESTDIR)$(pkgconfigdir)" -DATA = $(dist_doc_DATA) $(pkgconfig_DATA) -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ - $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ - distdir dist dist-all distcheck -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -distdir = $(PACKAGE)-$(VERSION) -top_distdir = $(distdir) -am__remove_distdir = \ - { test ! -d "$(distdir)" \ - || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -fr "$(distdir)"; }; } -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -DIST_ARCHIVES = $(distdir).tar.gz $(distdir).zip -GZIP_ENV = --best -distuninstallcheck_listfiles = find . -type f -print -distcleancheck_listfiles = find . -type f -print -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AS = @AS@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GLUT_CFLAGS = @GLUT_CFLAGS@ -GLUT_LIBS = @GLUT_LIBS@ -GLU_CFLAGS = @GLU_CFLAGS@ -GLU_LIBS = @GLU_LIBS@ -GL_CFLAGS = @GL_CFLAGS@ -GL_LIBS = @GL_LIBS@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBDIR = @LIBDIR@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTIFF_ALPHA_VERSION = @LIBTIFF_ALPHA_VERSION@ -LIBTIFF_DOCDIR = @LIBTIFF_DOCDIR@ -LIBTIFF_MAJOR_VERSION = @LIBTIFF_MAJOR_VERSION@ -LIBTIFF_MICRO_VERSION = @LIBTIFF_MICRO_VERSION@ -LIBTIFF_MINOR_VERSION = @LIBTIFF_MINOR_VERSION@ -LIBTIFF_RELEASE_DATE = @LIBTIFF_RELEASE_DATE@ -LIBTIFF_VERSION = @LIBTIFF_VERSION@ -LIBTIFF_VERSION_INFO = @LIBTIFF_VERSION_INFO@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PTHREAD_CC = @PTHREAD_CC@ -PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ -PTHREAD_LIBS = @PTHREAD_LIBS@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -XMKMF = @XMKMF@ -X_CFLAGS = @X_CFLAGS@ -X_EXTRA_LIBS = @X_EXTRA_LIBS@ -X_LIBS = @X_LIBS@ -X_PRE_LIBS = @X_PRE_LIBS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -ax_pthread_config = @ax_pthread_config@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = $(LIBTIFF_DOCDIR) -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -tiff_libs_private = @tiff_libs_private@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AUTOMAKE_OPTIONS = 1.11 dist-zip foreign -ACLOCAL_AMFLAGS = -I m4 -docfiles = \ - COPYRIGHT \ - ChangeLog \ - README \ - README.vms \ - RELEASE-DATE \ - TODO \ - VERSION - -EXTRA_DIST = \ - HOWTO-RELEASE \ - Makefile.vc \ - SConstruct \ - autogen.sh \ - configure.com \ - nmake.opt \ - libtiff-4.pc.in - -dist_doc_DATA = $(docfiles) -SUBDIRS = port libtiff tools build contrib test man html -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libtiff-4.pc -all: all-recursive - -.SUFFIXES: -am--refresh: - @: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ - $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - echo ' $(SHELL) ./config.status'; \ - $(SHELL) ./config.status;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - $(SHELL) ./config.status --recheck - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - $(am__cd) $(srcdir) && $(AUTOCONF) -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) -$(am__aclocal_m4_deps): -libtiff-4.pc: $(top_builddir)/config.status $(srcdir)/libtiff-4.pc.in - cd $(top_builddir) && $(SHELL) ./config.status $@ - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -rm -f libtool config.lt -install-dist_docDATA: $(dist_doc_DATA) - @$(NORMAL_INSTALL) - test -z "$(docdir)" || $(MKDIR_P) "$(DESTDIR)$(docdir)" - @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \ - done - -uninstall-dist_docDATA: - @$(NORMAL_UNINSTALL) - @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(docdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(docdir)" && rm -f $$files -install-pkgconfigDATA: $(pkgconfig_DATA) - @$(NORMAL_INSTALL) - test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" - @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ - done - -uninstall-pkgconfigDATA: - @$(NORMAL_UNINSTALL) - @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(pkgconfigdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(pkgconfigdir)" && rm -f $$files - -# This directory's subdirectories are mostly independent; you can cd -# into them and run `make' without going through this Makefile. -# To change the values of `make' variables: instead of editing Makefiles, -# (1) if the variable is set in `config.status', edit `config.status' -# (which will cause the Makefiles to be regenerated when you run `make'); -# (2) otherwise, pass the desired values on the `make' command line. -$(RECURSIVE_TARGETS): - @fail= failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -$(RECURSIVE_CLEAN_TARGETS): - @fail= failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - rev=''; for subdir in $$list; do \ - if test "$$subdir" = "."; then :; else \ - rev="$$subdir $$rev"; \ - fi; \ - done; \ - rev="$$rev ."; \ - target=`echo $@ | sed s/-recursive//`; \ - for subdir in $$rev; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done && test -z "$$fail" -tags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ - done -ctags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - $(am__remove_distdir) - test -d "$(distdir)" || mkdir "$(distdir)" - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done - -test -n "$(am__skip_mode_fix)" \ - || find "$(distdir)" -type d ! -perm -755 \ - -exec chmod u+rwx,go+rx {} \; -o \ - ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ - || chmod -R a+r "$(distdir)" -dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) - -dist-bzip2: distdir - tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 - $(am__remove_distdir) - -dist-lzma: distdir - tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma - $(am__remove_distdir) - -dist-xz: distdir - tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz - $(am__remove_distdir) - -dist-tarZ: distdir - tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z - $(am__remove_distdir) - -dist-shar: distdir - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz - $(am__remove_distdir) -dist-zip: distdir - -rm -f $(distdir).zip - zip -rq $(distdir).zip $(distdir) - $(am__remove_distdir) - -dist dist-all: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - -rm -f $(distdir).zip - zip -rq $(distdir).zip $(distdir) - $(am__remove_distdir) - -# This target untars the dist file and tries a VPATH configuration. Then -# it guarantees that the distribution is self-contained by making another -# tarfile. -distcheck: dist - case '$(DIST_ARCHIVES)' in \ - *.tar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ - *.tar.bz2*) \ - bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ - *.tar.lzma*) \ - lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ - *.tar.xz*) \ - xz -dc $(distdir).tar.xz | $(am__untar) ;;\ - *.tar.Z*) \ - uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ - *.shar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ - *.zip*) \ - unzip $(distdir).zip ;;\ - esac - chmod -R a-w $(distdir); chmod a+w $(distdir) - mkdir $(distdir)/_build - mkdir $(distdir)/_inst - chmod a-w $(distdir) - test -d $(distdir)/_build || exit 0; \ - dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ - && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ - && am__cwd=`pwd` \ - && $(am__cd) $(distdir)/_build \ - && ../configure --srcdir=.. --prefix="$$dc_install_base" \ - $(DISTCHECK_CONFIGURE_FLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) dvi \ - && $(MAKE) $(AM_MAKEFLAGS) check \ - && $(MAKE) $(AM_MAKEFLAGS) install \ - && $(MAKE) $(AM_MAKEFLAGS) installcheck \ - && $(MAKE) $(AM_MAKEFLAGS) uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ - distuninstallcheck \ - && chmod -R a-w "$$dc_install_base" \ - && ({ \ - (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ - distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ - } || { rm -rf "$$dc_destdir"; exit 1; }) \ - && rm -rf "$$dc_destdir" \ - && $(MAKE) $(AM_MAKEFLAGS) dist \ - && rm -rf $(DIST_ARCHIVES) \ - && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ - && cd "$$am__cwd" \ - || exit 1 - $(am__remove_distdir) - @(echo "$(distdir) archives ready for distribution: "; \ - list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ - sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' -distuninstallcheck: - @$(am__cd) '$(distuninstallcheck_dir)' \ - && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ - || { echo "ERROR: files left after uninstall:" ; \ - if test -n "$(DESTDIR)"; then \ - echo " (check DESTDIR support)"; \ - fi ; \ - $(distuninstallcheck_listfiles) ; \ - exit 1; } >&2 -distcleancheck: distclean - @if test '$(srcdir)' = . ; then \ - echo "ERROR: distcleancheck can only run from a VPATH build" ; \ - exit 1 ; \ - fi - @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ - || { echo "ERROR: files left in build directory after distclean:" ; \ - $(distcleancheck_listfiles) ; \ - exit 1; } >&2 -check-am: all-am -check: check-recursive -all-am: Makefile $(DATA) -installdirs: installdirs-recursive -installdirs-am: - for dir in "$(DESTDIR)$(docdir)" "$(DESTDIR)$(pkgconfigdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-recursive - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-libtool \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: install-dist_docDATA install-pkgconfigDATA - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf $(top_srcdir)/autom4te.cache - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-dist_docDATA uninstall-pkgconfigDATA - -.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ - install-am install-strip tags-recursive - -.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ - all all-am am--refresh check check-am clean clean-generic \ - clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \ - dist-gzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \ - distcheck distclean distclean-generic distclean-libtool \ - distclean-tags distcleancheck distdir distuninstallcheck dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dist_docDATA install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-pkgconfigDATA install-ps \ - install-ps-am install-strip installcheck installcheck-am \ - installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ - uninstall uninstall-am uninstall-dist_docDATA \ - uninstall-pkgconfigDATA - - -release: - (rm -f $(top_srcdir)/RELEASE-DATE && echo $(LIBTIFF_RELEASE_DATE) > $(top_srcdir)/RELEASE-DATE) - (rm -f $(top_srcdir)/VERSION && echo $(LIBTIFF_VERSION) > $(top_srcdir)/VERSION) - (rm -f $(top_srcdir)/libtiff/tiffvers.h && sed 's,LIBTIFF_VERSION,$(LIBTIFF_VERSION),;s,LIBTIFF_RELEASE_DATE,$(LIBTIFF_RELEASE_DATE),' $(top_srcdir)/libtiff/tiffvers.h.in > $(top_srcdir)/libtiff/tiffvers.h) - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/libs/tiff-4.0.2/build/Makefile.in b/libs/tiff-4.0.2/build/Makefile.in deleted file mode 100644 index 04efe139c3..0000000000 --- a/libs/tiff-4.0.2/build/Makefile.in +++ /dev/null @@ -1,622 +0,0 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -# -# Tag Image File Format (TIFF) Software -# -# Copyright (C) 2007, Andrey Kiselev -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. - -# Process this file with automake to produce Makefile.in. -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = build -DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -AM_V_GEN = $(am__v_GEN_$(V)) -am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) -am__v_GEN_0 = @echo " GEN " $@; -AM_V_at = $(am__v_at_$(V)) -am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) -am__v_at_0 = @ -SOURCES = -DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ - html-recursive info-recursive install-data-recursive \ - install-dvi-recursive install-exec-recursive \ - install-html-recursive install-info-recursive \ - install-pdf-recursive install-ps-recursive install-recursive \ - installcheck-recursive installdirs-recursive pdf-recursive \ - ps-recursive uninstall-recursive -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ - $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ - distdir -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AS = @AS@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GLUT_CFLAGS = @GLUT_CFLAGS@ -GLUT_LIBS = @GLUT_LIBS@ -GLU_CFLAGS = @GLU_CFLAGS@ -GLU_LIBS = @GLU_LIBS@ -GL_CFLAGS = @GL_CFLAGS@ -GL_LIBS = @GL_LIBS@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBDIR = @LIBDIR@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTIFF_ALPHA_VERSION = @LIBTIFF_ALPHA_VERSION@ -LIBTIFF_DOCDIR = @LIBTIFF_DOCDIR@ -LIBTIFF_MAJOR_VERSION = @LIBTIFF_MAJOR_VERSION@ -LIBTIFF_MICRO_VERSION = @LIBTIFF_MICRO_VERSION@ -LIBTIFF_MINOR_VERSION = @LIBTIFF_MINOR_VERSION@ -LIBTIFF_RELEASE_DATE = @LIBTIFF_RELEASE_DATE@ -LIBTIFF_VERSION = @LIBTIFF_VERSION@ -LIBTIFF_VERSION_INFO = @LIBTIFF_VERSION_INFO@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PTHREAD_CC = @PTHREAD_CC@ -PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ -PTHREAD_LIBS = @PTHREAD_LIBS@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -XMKMF = @XMKMF@ -X_CFLAGS = @X_CFLAGS@ -X_EXTRA_LIBS = @X_EXTRA_LIBS@ -X_LIBS = @X_LIBS@ -X_PRE_LIBS = @X_PRE_LIBS@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -ax_pthread_config = @ax_pthread_config@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -tiff_libs_private = @tiff_libs_private@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -EXTRA_DIST = README -SUBDIRS = -all: all-recursive - -.SUFFIXES: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign build/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign build/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -# This directory's subdirectories are mostly independent; you can cd -# into them and run `make' without going through this Makefile. -# To change the values of `make' variables: instead of editing Makefiles, -# (1) if the variable is set in `config.status', edit `config.status' -# (which will cause the Makefiles to be regenerated when you run `make'); -# (2) otherwise, pass the desired values on the `make' command line. -$(RECURSIVE_TARGETS): - @fail= failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -$(RECURSIVE_CLEAN_TARGETS): - @fail= failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - rev=''; for subdir in $$list; do \ - if test "$$subdir" = "."; then :; else \ - rev="$$subdir $$rev"; \ - fi; \ - done; \ - rev="$$rev ."; \ - target=`echo $@ | sed s/-recursive//`; \ - for subdir in $$rev; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done && test -z "$$fail" -tags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ - done -ctags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-recursive -all-am: Makefile -installdirs: installdirs-recursive -installdirs-am: -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-recursive - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: - -.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ - install-am install-strip tags-recursive - -.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ - all all-am check check-am clean clean-generic clean-libtool \ - ctags ctags-recursive distclean distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ - uninstall uninstall-am - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/libs/tiff-4.0.2/config/depcomp b/libs/tiff-4.0.2/config/depcomp index ca5ea4e1ef..04701da536 100755 --- a/libs/tiff-4.0.2/config/depcomp +++ b/libs/tiff-4.0.2/config/depcomp @@ -1,10 +1,9 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2006-10-15.18 +scriptversion=2005-07-09.11 -# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software -# Foundation, Inc. +# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -92,20 +91,7 @@ gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. -## Unfortunately, FreeBSD c89 acceptance of flags depends upon -## the command line argument order; so add the flags where they -## appear in depend2.am. Note that the slowdown incurred here -## affects only configure: in makefiles, %FASTDEP% shortcuts this. - for arg - do - case $arg in - -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; - *) set fnord "$@" "$arg" ;; - esac - shift # fnord - shift # $arg - done - "$@" + "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else @@ -290,46 +276,6 @@ icc) rm -f "$tmpdepfile" ;; -hp2) - # The "hp" stanza above does not work with aCC (C++) and HP's ia64 - # compilers, which have integrated preprocessors. The correct option - # to use with these is +Maked; it writes dependencies to a file named - # 'foo.d', which lands next to the object file, wherever that - # happens to be. - # Much of this is similar to the tru64 case; see comments there. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - if test "$libtool" = yes; then - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir.libs/$base.d - "$@" -Wc,+Maked - else - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir$base.d - "$@" +Maked - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" - # Add `dependent.h:' lines. - sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" "$tmpdepfile2" - ;; - tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. @@ -342,13 +288,13 @@ tru64) if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a - # static library. This mechanism is used in libtool 1.4 series to + # static library. This mecanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two - # compilations output dependencies in $dir.libs/$base.o.d and + # compilations output dependencies in in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is diff --git a/libs/tiff-4.0.2/config/missing b/libs/tiff-4.0.2/config/missing index 1c8ff7049d..894e786e16 100755 --- a/libs/tiff-4.0.2/config/missing +++ b/libs/tiff-4.0.2/config/missing @@ -1,9 +1,9 @@ #! /bin/sh # Common stub for a few missing GNU programs while installing. -scriptversion=2006-05-10.23 +scriptversion=2005-06-08.21 -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006 +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005 # Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. @@ -33,8 +33,6 @@ if test $# -eq 0; then fi run=: -sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' -sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. @@ -46,7 +44,7 @@ fi msg="missing on your system" -case $1 in +case "$1" in --run) # Try to run requested program, and just exit if it succeeds. run= @@ -79,7 +77,6 @@ Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' - autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c @@ -109,7 +106,7 @@ esac # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). -case $1 in +case "$1" in lex|yacc) # Not GNU programs, they don't have --version. ;; @@ -138,7 +135,7 @@ esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. -case $1 in +case "$1" in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if @@ -167,7 +164,7 @@ WARNING: \`$1' is $msg. You should only need it if test -z "$files" && files="config.h" touch_files= for f in $files; do - case $f in + case "$f" in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; @@ -195,8 +192,8 @@ WARNING: \`$1' is needed, but is $msg. You can get \`$1' as part of \`Autoconf' from any GNU archive site." - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` + test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` if test -f "$file"; then touch $file else @@ -217,25 +214,25 @@ WARNING: \`$1' $msg. You should only need it if in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h - if test $# -ne 1; then + if [ $# -ne 1 ]; then eval LASTARG="\${$#}" - case $LASTARG in + case "$LASTARG" in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if test -f "$SRCFILE"; then + if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if test -f "$SRCFILE"; then + if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.h fi ;; esac fi - if test ! -f y.tab.h; then + if [ ! -f y.tab.h ]; then echo >y.tab.h fi - if test ! -f y.tab.c; then + if [ ! -f y.tab.c ]; then echo 'main() { return 0; }' >y.tab.c fi ;; @@ -247,18 +244,18 @@ WARNING: \`$1' is $msg. You should only need it if in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c - if test $# -ne 1; then + if [ $# -ne 1 ]; then eval LASTARG="\${$#}" - case $LASTARG in + case "$LASTARG" in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if test -f "$SRCFILE"; then + if [ -f "$SRCFILE" ]; then cp "$SRCFILE" lex.yy.c fi ;; esac fi - if test ! -f lex.yy.c; then + if [ ! -f lex.yy.c ]; then echo 'main() { return 0; }' >lex.yy.c fi ;; @@ -270,9 +267,11 @@ WARNING: \`$1' is $msg. You should only need it if \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` + fi + if [ -f "$file" ]; then touch $file else test -z "$file" || exec >$file @@ -290,17 +289,11 @@ WARNING: \`$1' is $msg. You should only need it if DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n ' - /^@setfilename/{ - s/.* \([^ ]*\) *$/\1/ - p - q - }' $infile` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi @@ -324,13 +317,13 @@ WARNING: \`$1' is $msg. You should only need it if fi firstarg="$1" if shift; then - case $firstarg in + case "$firstarg" in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac - case $firstarg in + case "$firstarg" in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 diff --git a/libs/tiff-4.0.2/config/mkinstalldirs b/libs/tiff-4.0.2/config/mkinstalldirs index ef7e16fdaf..259dbfcd35 100755 --- a/libs/tiff-4.0.2/config/mkinstalldirs +++ b/libs/tiff-4.0.2/config/mkinstalldirs @@ -1,7 +1,7 @@ #! /bin/sh # mkinstalldirs --- make directory hierarchy -scriptversion=2006-05-11.19 +scriptversion=2005-06-29.22 # Original author: Noah Friedman # Created: 1993-05-16 @@ -11,9 +11,6 @@ scriptversion=2006-05-11.19 # bugs to or send patches to # . -nl=' -' -IFS=" "" $nl" errstatus=0 dirmode= diff --git a/libs/tiff-4.0.2/configure.ac b/libs/tiff-4.0.2/configure.ac index 1405eb57ae..ba3601edc7 100644 --- a/libs/tiff-4.0.2/configure.ac +++ b/libs/tiff-4.0.2/configure.ac @@ -24,11 +24,13 @@ dnl OF THIS SOFTWARE. dnl Process this file with autoconf to produce a configure script. -AC_PREREQ(2.64) +AC_PREREQ(2.59) AC_INIT([LibTIFF Software],[4.0.2],[tiff@lists.maptools.org],[tiff]) AC_CONFIG_AUX_DIR(config) AC_CONFIG_MACRO_DIR(m4) AC_LANG(C) +AC_PROG_LIBTOOL +m4_include(m4/acinclude.m4) dnl Compute the canonical host (run-time) system type variable AC_CANONICAL_HOST @@ -144,15 +146,15 @@ AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes") dnl Tests for Windows -AC_EXEEXT -AC_OBJEXT +#AC_EXEEXT +#AC_OBJEXT dnl initialize libtool -LT_INIT([win32-dll]) -LT_LANG([C++]) +#LT_INIT([win32-dll]) +#LT_LANG([C++]) # Enable support for silent build rules -AM_SILENT_RULES +#AM_SILENT_RULES dnl Checks for libraries. AC_CHECK_LIB([c], [main]) diff --git a/libs/tiff-4.0.2/configure.gnu b/libs/tiff-4.0.2/configure.gnu new file mode 100644 index 0000000000..c78238de46 --- /dev/null +++ b/libs/tiff-4.0.2/configure.gnu @@ -0,0 +1,4 @@ +#! /bin/sh +srcpath=$(dirname $0 2>/dev/null ) || srcpath="." +$srcpath/configure "$@" --disable-shared --with-pic + diff --git a/libs/tiff-4.0.2/test/Makefile.am b/libs/tiff-4.0.2/test/Makefile.am index e7d45482e6..4a1dea4411 100644 --- a/libs/tiff-4.0.2/test/Makefile.am +++ b/libs/tiff-4.0.2/test/Makefile.am @@ -23,7 +23,7 @@ # Process this file with automake to produce Makefile.in. -AUTOMAKE_OPTIONS = 1.11 color-tests parallel-tests foreign +AUTOMAKE_OPTIONS = 1.7 LIBTIFF = $(top_builddir)/libtiff/libtiff.la diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index 15c6d124f9..2ef5c7fca9 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -2247,7 +2247,7 @@ static void fifo_caller_del(const char *uuid) if (uuid) { sql = switch_mprintf("delete from fifo_callers where uuid='%q'", uuid); } else { - sql = switch_mprintf("delete from fifo_callers", uuid); + sql = switch_mprintf("delete from fifo_callers"); } fifo_execute_sql(sql, globals.sql_mutex); @@ -4251,7 +4251,6 @@ static switch_status_t load_config(int reload, int del_all) } } switch_mutex_unlock(globals.mutex); - fifo_caller_del(NULL); } diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c index c15f9afe67..57fb05a439 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c @@ -357,7 +357,7 @@ static int phase_b_handler(t30_state_t *s, void *user_data, int result) static int phase_d_handler(t30_state_t *s, void *user_data, int msg) { - t4_stats_t t4_stats; + t30_stats_t t30_stats; char *fax_image_resolution = NULL; char *fax_image_size = NULL; char *fax_image_pixel_size = NULL; @@ -379,60 +379,56 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int msg) channel = switch_core_session_get_channel(session); switch_assert(channel); - if (pvt->app_mode == FUNCTION_TX) { - t4_tx_get_transfer_statistics(&s->t4.tx, &t4_stats); - } else { - t4_rx_get_transfer_statistics(&s->t4.rx, &t4_stats); - } + t30_get_transfer_statistics(s, &t30_stats); /* Set Channel Variable */ - fax_image_resolution = switch_core_session_sprintf(session, "%ix%i", t4_stats.x_resolution, t4_stats.y_resolution); + fax_image_resolution = switch_core_session_sprintf(session, "%ix%i", t30_stats.x_resolution, t30_stats.y_resolution); if (fax_image_resolution) { switch_channel_set_variable(channel, "fax_image_resolution", fax_image_resolution); } - fax_image_pixel_size = switch_core_session_sprintf(session, "%ix%i", t4_stats.width, t4_stats.length); + fax_image_pixel_size = switch_core_session_sprintf(session, "%ix%i", t30_stats.width, t30_stats.length); if (fax_image_pixel_size) { switch_channel_set_variable(channel, "fax_image_pixel_size", fax_image_pixel_size);; } - fax_image_size = switch_core_session_sprintf(session, "%d", t4_stats.line_image_size); + fax_image_size = switch_core_session_sprintf(session, "%d", t30_stats.image_size); if (fax_image_size) { switch_channel_set_variable(channel, "fax_image_size", fax_image_size); } - fax_bad_rows = switch_core_session_sprintf(session, "%d", t4_stats.bad_rows); + fax_bad_rows = switch_core_session_sprintf(session, "%d", t30_stats.bad_rows); if (fax_bad_rows) { switch_channel_set_variable(channel, "fax_bad_rows", fax_bad_rows); } - fax_longest_bad_row_run = switch_core_session_sprintf(session, "%d", t4_stats.longest_bad_row_run); + fax_longest_bad_row_run = switch_core_session_sprintf(session, "%d", t30_stats.longest_bad_row_run); if (fax_longest_bad_row_run) { switch_channel_set_variable(channel, "fax_longest_bad_row_run", fax_longest_bad_row_run); } - fax_encoding = switch_core_session_sprintf(session, "%d", t4_stats.encoding); + fax_encoding = switch_core_session_sprintf(session, "%d", t30_stats.encoding); if (fax_encoding) { switch_channel_set_variable(channel, "fax_encoding", fax_encoding); } - switch_channel_set_variable(channel, "fax_encoding_name", t4_encoding_to_str(t4_stats.encoding)); + switch_channel_set_variable(channel, "fax_encoding_name", t4_encoding_to_str(t30_stats.encoding)); - fax_document_transferred_pages = switch_core_session_sprintf(session, "%d", t4_stats.pages_transferred); + fax_document_transferred_pages = switch_core_session_sprintf(session, "%d", (pvt->app_mode == FUNCTION_TX) ? t30_stats.pages_tx : t30_stats.pages_rx); if (fax_document_transferred_pages) { switch_channel_set_variable(channel, "fax_document_transferred_pages", fax_document_transferred_pages); } switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "==== Page %s===========================================================\n", pvt->app_mode == FUNCTION_TX ? "Sent ====": "Received "); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Page no = %d\n", t4_stats.pages_transferred); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Image size = %d x %d pixels\n", t4_stats.width, t4_stats.length); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Image resolution = %d/m x %d/m\n", t4_stats.x_resolution, t4_stats.y_resolution); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Compression = %s (%d)\n", t4_encoding_to_str(t4_stats.encoding), t4_stats.encoding); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Compressed image size = %d bytes\n", t4_stats.line_image_size); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Bad rows = %d\n", t4_stats.bad_rows); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Longest bad row run = %d\n", t4_stats.longest_bad_row_run); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Page no = %d\n", (pvt->app_mode == FUNCTION_TX) ? t30_stats.pages_tx : t30_stats.pages_rx); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Image size = %d x %d pixels\n", t30_stats.width, t30_stats.length); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Image resolution = %d/m x %d/m\n", t30_stats.x_resolution, t30_stats.y_resolution); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Compression = %s (%d)\n", t4_encoding_to_str(t30_stats.encoding), t30_stats.encoding); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Compressed image size = %d bytes\n", t30_stats.image_size); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Bad rows = %d\n", t30_stats.bad_rows); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Longest bad row run = %d\n", t30_stats.longest_bad_row_run); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "==============================================================================\n"); switch_channel_execute_on(channel, "execute_on_fax_phase_d"); @@ -446,7 +442,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int msg) switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-bad-rows", fax_bad_rows); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-longest-bad-row-run", fax_longest_bad_row_run); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-encoding", fax_encoding); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-encoding-name", t4_encoding_to_str(t4_stats.encoding)); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-encoding-name", t4_encoding_to_str(t30_stats.encoding)); switch_event_fire(&event); } @@ -713,12 +709,12 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) fax_set_transmit_on_idle(fax, TRUE); - span_log_set_message_handler(&fax->logging, spanfax_log_message, NULL); - span_log_set_message_handler(&t30->logging, spanfax_log_message, NULL); + span_log_set_message_handler(fax_get_logging_state(fax), spanfax_log_message, NULL); + span_log_set_message_handler(t30_get_logging_state(t30), spanfax_log_message, NULL); if (pvt->verbose) { - span_log_set_level(&fax->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_level(&t30->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_level(fax_get_logging_state(fax), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_level(t30_get_logging_state(t30), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); } break; case T38_MODE: @@ -769,12 +765,12 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) } } - span_log_set_message_handler(&t38->logging, spanfax_log_message, NULL); - span_log_set_message_handler(&t30->logging, spanfax_log_message, NULL); + span_log_set_message_handler(t38_terminal_get_logging_state(t38), spanfax_log_message, NULL); + span_log_set_message_handler(t30_get_logging_state(t30), spanfax_log_message, NULL); if (pvt->verbose) { - span_log_set_level(&t38->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_level(&t30->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_level(t38_terminal_get_logging_state(t38), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_level(t30_get_logging_state(t30), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); } } break; @@ -824,12 +820,12 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode) } - span_log_set_message_handler(&pvt->t38_gateway_state->logging, spanfax_log_message, NULL); - span_log_set_message_handler(&pvt->t38_core->logging, spanfax_log_message, NULL); + span_log_set_message_handler(t38_gateway_get_logging_state(pvt->t38_gateway_state), spanfax_log_message, NULL); + span_log_set_message_handler(t38_core_get_logging_state(pvt->t38_core), spanfax_log_message, NULL); if (pvt->verbose) { - span_log_set_level(&pvt->t38_gateway_state->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); - span_log_set_level(&pvt->t38_core->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_level(t38_gateway_get_logging_state(pvt->t38_gateway_state), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_level(t38_core_get_logging_state(pvt->t38_core), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); } t38_set_t38_version(pvt->t38_core, 0); diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_modem.c b/src/mod/applications/mod_spandsp/mod_spandsp_modem.c index f7fd57ba23..eb54c217aa 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_modem.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_modem.c @@ -1279,7 +1279,7 @@ static void *SWITCH_THREAD_FUNC modem_thread(switch_thread_t *thread, void *obj) modem->last_event = switch_time_now(); } - avail = sizeof(buf) - modem->t31_state->tx.in_bytes + modem->t31_state->tx.out_bytes - 1; + avail = t31_at_rx_free_space(modem->t31_state); if (avail == 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Buffer Full, retrying....\n"); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index f7bfc6cb59..a5f8d8d11f 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -2898,7 +2898,7 @@ static int show_reg_callback_xml(void *pArg, int argc, char **argv, char **colum cb->stream->write_function(cb->stream, " %s\n", switch_str_nil(argv[0])); cb->stream->write_function(cb->stream, " %s@%s\n", switch_str_nil(argv[1]), switch_str_nil(argv[2])); cb->stream->write_function(cb->stream, " %s\n", switch_amp_encode(switch_str_nil(argv[3]), xmlbuf, buflen)); - cb->stream->write_function(cb->stream, " %s\n", switch_str_nil(argv[7])); + cb->stream->write_function(cb->stream, " %s\n", switch_amp_encode(switch_str_nil(argv[7]), xmlbuf, buflen)); cb->stream->write_function(cb->stream, " %s(%s) exp(%s) expsecs(%d)\n", switch_str_nil(argv[4]), switch_str_nil(argv[5]), exp_buf, exp_secs); cb->stream->write_function(cb->stream, " %s\n", switch_str_nil(argv[11])); diff --git a/src/mod/languages/mod_managed/managed/ManagedSession.cs b/src/mod/languages/mod_managed/managed/ManagedSession.cs index 07832ae102..9629215c70 100644 --- a/src/mod/languages/mod_managed/managed/ManagedSession.cs +++ b/src/mod/languages/mod_managed/managed/ManagedSession.cs @@ -145,6 +145,8 @@ namespace FreeSWITCH.Native switch_state_handler_t_delegate del = ptr => { using (var sess = new ManagedSession(new SWIGTYPE_p_switch_core_session(ptr, false))) { handler(sess); + sess.SetAutoHangup(false); + sess.destroy(); return switch_status_t.SWITCH_STATUS_SUCCESS; } }; diff --git a/src/mod/languages/mod_managed/managed/swig.cs b/src/mod/languages/mod_managed/managed/swig.cs index 9167e028a0..ead2b8b2a4 100644 --- a/src/mod/languages/mod_managed/managed/swig.cs +++ b/src/mod/languages/mod_managed/managed/swig.cs @@ -23352,6 +23352,7 @@ public enum switch_channel_flag_t { CF_TRACKED, CF_TRACKABLE, CF_NO_CDR, + CF_EARLY_OK, CF_FLAG_MAX } @@ -25245,6 +25246,7 @@ public enum switch_core_session_message_types_t { SWITCH_MESSAGE_INDICATE_JITTER_BUFFER, SWITCH_MESSAGE_INDICATE_RECOVERY_REFRESH, SWITCH_MESSAGE_INDICATE_SIGNAL_DATA, + SWITCH_MESSAGE_INDICATE_MESSAGE, SWITCH_MESSAGE_INDICATE_INFO, SWITCH_MESSAGE_INDICATE_AUDIO_DATA, SWITCH_MESSAGE_INDICATE_BLIND_TRANSFER_RESPONSE, diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 0f98a9b856..95f0e901d8 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -560,7 +560,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se if (!switch_channel_test_flag(channel, CF_BROADCAST)) { switch_channel_set_flag(channel, CF_BROADCAST); - inner--; + if (inner) { + inner--; + } } if (hold_bleg && switch_true(hold_bleg)) { @@ -611,7 +613,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se if (switch_core_session_execute_application(session, app_name, app_arg) != SWITCH_STATUS_SUCCESS) { if (!inner || switch_channel_test_flag(channel, CF_STOP_BROADCAST)) switch_channel_clear_flag(channel, CF_BROADCAST); - goto done; + break; } aftr = switch_micro_time_now(); diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index 9fc7819f29..2c9c772a21 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -191,6 +191,7 @@ static void *SWITCH_THREAD_FUNC collect_thread_run(switch_thread_t *thread, void if (switch_channel_up_nosig(channel)) { switch_channel_set_flag(channel, CF_WINNER); + switch_channel_set_variable(channel, "group_dial_status", "winner"); } goto wbreak; } @@ -225,6 +226,7 @@ static void *SWITCH_THREAD_FUNC collect_thread_run(switch_thread_t *thread, void if (!strcmp(collect->key, buf)) { switch_channel_set_flag(channel, CF_WINNER); + switch_channel_set_variable(channel, "group_dial_status", "winner"); goto wbreak; } else if (collect->error_file) { switch_ivr_play_file(collect->session, NULL, collect->error_file, NULL); @@ -701,6 +703,13 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat switch_channel_clear_flag(originate_status[i].peer_channel, CF_EARLY_OK); } + if (caller_channel && switch_channel_test_flag(caller_channel, CF_EARLY_OK)) { + if (!oglobals->early_ok) { + oglobals->early_ok = 1; + } + switch_channel_clear_flag(caller_channel, CF_EARLY_OK); + } + state = switch_channel_get_state(originate_status[i].peer_channel); if (state >= CS_HANGUP || state == CS_RESET || switch_channel_test_flag(originate_status[i].peer_channel, CF_TRANSFER) || switch_channel_test_flag(originate_status[i].peer_channel, CF_REDIRECT) || @@ -1344,7 +1353,10 @@ static void *SWITCH_THREAD_FUNC enterprise_originate_thread(switch_thread_t *thr if (handle->done != 2) { if (handle->status == SWITCH_STATUS_SUCCESS) { - switch_channel_hangup(switch_core_session_get_channel(handle->bleg), SWITCH_CAUSE_LOSE_RACE); + switch_channel_t *channel = switch_core_session_get_channel(handle->bleg); + + switch_channel_set_variable(channel, "group_dial_status", "loser"); + switch_channel_hangup(channel, SWITCH_CAUSE_LOSE_RACE); switch_core_session_rwunlock(handle->bleg); } } @@ -3283,6 +3295,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess switch_ivr_uuid_bridge(holding, switch_core_session_get_uuid(originate_status[i].peer_session)); holding = NULL; } else { + if (force_reason == SWITCH_CAUSE_LOSE_RACE || reason == SWITCH_CAUSE_LOSE_RACE) { + switch_channel_set_variable(originate_status[i].peer_channel, "group_dial_status", "loser"); + } switch_channel_hangup(originate_status[i].peer_channel, force_reason ? force_reason : reason); } } diff --git a/src/switch_utils.c b/src/switch_utils.c index d877061e39..3961d89089 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -463,6 +463,42 @@ SWITCH_DECLARE(char *) switch_amp_encode(char *s, char *buf, switch_size_t len) for (p = s; x < len; p++) { switch (*p) { + + case '"': + if (x + 6 > len - 1) { + goto end; + } + *q++ = '&'; + *q++ = 'q'; + *q++ = 'u'; + *q++ = 'o'; + *q++ = 't'; + *q++ = ';'; + x += 6; + break; + case '\'': + if (x + 6 > len - 1) { + goto end; + } + *q++ = '&'; + *q++ = 'a'; + *q++ = 'p'; + *q++ = 'o'; + *q++ = 's'; + *q++ = ';'; + x += 6; + break; + case '&': + if (x + 5 > len - 1) { + goto end; + } + *q++ = '&'; + *q++ = 'a'; + *q++ = 'm'; + *q++ = 'p'; + *q++ = ';'; + x += 5; + break; case '<': if (x + 4 > len - 1) { goto end;