Commit Graph

105 Commits

Author SHA1 Message Date
Harald Welte a341d58fbd ftmod_libpri: Fix NULL pointer deref in on_hangup() 2019-12-29 00:26:14 +01:00
Harald Welte 83f6bf5276 ftmod_libpri: Don't hardcode SPEECH bearer capability
FreeTDM actually knows which bearer capability to set; let's use
it rather than discarding that and overriding it with SPEECH.
2019-12-29 00:24:56 +01:00
Davide Colombo 5e5bc23f47 OPENZAP-241: set always STATE_HANGUP_COMPLETE 2016-03-10 14:46:05 +01:00
Matteo Brancaleoni 0127e9bf47 FS-7620 Correctly set calling number presentation and screening fields. 2015-06-08 17:54:30 +02:00
Moises Silva 98de925e46 Merge pull request #171 in FS/freeswitch from ~MBRANCA/freeswitch:bugfix/FS-7209-improve-ani-ton-and-type-when-not to master
* commit '3cd62df96f78a0ea3255c4fced2e2f32f97c0a42':
  If ANI ton is not interpreted correctly by libpri, fallback to calling ton/type.
2015-01-28 10:35:09 -06:00
Moises Silva c9ebd0fcdf Merge pull request #165 in FS/freeswitch from ~MBRANCA/freeswitch:bugfix/FS-7197-libpri-spans-fails-to-stop-when-unloading to master
* commit 'e062f5e3c8355a6b5cb0d12ddb99300e95b38193':
  If the span has been already fully stopped and ftdm is not running, return success from the span stop function.
2015-01-28 10:33:47 -06:00
Matteo Brancaleoni 3cd62df96f If ANI ton is not interpreted correctly by libpri,
fallback to calling ton/type.
2015-01-28 11:13:37 +01:00
Matteo Brancaleoni e062f5e3c8 If the span has been already fully stopped and ftdm is not running,
return success from the span stop function.
2015-01-28 09:35:19 +01:00
Matteo Brancaleoni 8307e7842d Set ANI plan and ANI type for ftmod_libpri. 2015-01-27 15:56:00 +01:00
Matteo Brancaleoni 7ec7c920d1 OPENZAP-220 fix blocked into read and add cause for a correct hangup 2014-10-07 14:34:39 +02:00
Moises Silva 99c022b1dd FS-6500: freetdm: Add more enum compliance by defining proper enum values for FTDM_END and FTDM_ANY special state values 2014-05-01 20:24:03 -04:00
Brian West 6e8729a159 OPENZAP-222 --resolve 2014-04-18 15:18:41 -05:00
Ken Rice 6e7d5d0897 update copyright header for 2014 2014-02-12 12:08:56 -06:00
Moises Silva bb67ff5e0b OPENZAP-219 --resolve
Calling ton and caller ton is not parsed at all in libpri signaling module
Patched-by: Markus Schräder
2013-10-04 12:12:47 -04:00
Nathan Neulinger 32adc789f6 make noexpandtab explicit in all vim modelines other than xml files 2013-06-25 11:50:17 -05:00
Moises Silva e5f2282fe1 OPENZAP-215 --resolve
The state FTDM_CHANNEL_STATE_RINGING is not used when there is media available. We have
FTDM_CHANNEL_PROGRESS_MEDIA for that, therefore the pri_acknowledge() call should not set
the info argument to avoid sending an indication of media to the other end, as that may cause
the other end to not generate any ringing tone and at that moment we will not be generating
any ringing tone either and the caller will hear only silence
2013-06-23 21:52:31 -04:00
Stefan Knoblich 5154bd847b ftmod_libpri: Fix channel iterator memory leak
Keep the original iterator around to be able to actually free it
after use.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2013-06-01 21:09:48 +02:00
Stefan Knoblich 8019af49a4 ftmod_libpri: Fix possible NULL-ptr dereference crash in on_restart(_ack)()
Catch single channel RESTART/RESTART ACK events for non-B-channels,
that would lead to a NULL pointer dereference, because those do not have
per-channel private data (chan->call_data = chan_priv == NULL).

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2013-05-21 17:50:54 +02:00
Stefan Knoblich ae58a4c1ba FreeTDM: Use ftdm_unused_arg() to silence -Wunused-argument warnings
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2013-05-10 19:04:09 +02:00
Moises Silva 4ff826c27d OPENZAP-200 --resolve
Patch provided by: Spencer Thomason

Implement appropiate caller/called TON in ftmod_libpri
2013-04-09 12:29:47 -04:00
Stefan Knoblich bfef3e57c4 ftmod_libpri: Disable on_facility() event handler on older libpri versions
Those that lack PRI_EVENT_FACILITY (<= 1.4.10)

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2013-01-08 15:07:29 +01:00
Stefan Knoblich 221bcc9e90 ftmod_libpri: Also conditionally disable pri_set_service_message_support() call
Same as pri_maintenance_service(), use HAVE_LIBPRI_MAINT_SERVICE.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2013-01-08 15:07:29 +01:00
Stefan Knoblich 88e75bf9d7 ftmod_libpri: Add configure check for pri_maintenance_service()
Said function has been added in libpri-1.4.11 and breaks
building with older libpri versions (i.e. the passive one for ftmod_pritap).

Check for pri_maintenance_service() in configure and disable
the "maintenance" subcommand if it is not available.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2013-01-08 15:07:29 +01:00
Matteo Brancaleoni 8c58a10999 ftmod_libpri: Rework handling of peer-initiated hangup events
Use peerhangup flag variable to track whether a hangup has been
initiated by the peer or libpri itself (e.g. Layer 2 timeouts).

These changes fix a couple of problems with hangup events not being
handled properly in some situations:

  - Call abort caused by incoming RESTART on a channel in use
  - T309 timeout after L2 loss
  - Improved hangup handling in libpri-side on_hangup() event handler
    and state_advance() (FreeTDM side)

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-11-12 22:54:27 +01:00
Matteo Brancaleoni 3d090357cf ftmod_libpri: Always send PROGRESS messages with PROGRESS INDICATOR IE
PROGRESS without PROGRESS INDICATOR IE is invalid according to Q.931,
so always call pri_progress() with info flag set, even if we do not
have media yet.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-10-29 11:58:22 +01:00
Moises Silva 542e7153fc freetdm: Fix compilation with old libpri.h where AOC is not available 2012-10-23 13:01:40 -04:00
Stefan Knoblich a478a5de04 ftmod_libpri: Skip channels marked in use during NT-mode idle restart.
Channels can be in DOWN state but reserved by an incoming call
(FTDM_CHANNEL_INUSE flag). Additionally check the flag in on_timeout_t3xx()
and skip those channels.

Reported-by: privi #freetdm @ irc.freenode.net
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-09-11 11:09:40 +02:00
Stefan Knoblich 4ffcb7c9ef ftmod_libpri: Improve RESTART handling, add PTP NT idle channel restart and T316.
Do not try to send RESTART on BRI PTMP spans, libpri will just print
an error and do nothing, causing the channels to be stuck in RESTART
forever.

Add T316 (RESTART ACK timeout), which is not implemented by libpri.
The default timeout is 30 seconds (Q.931 recommends 2 minutes, but
that is a little long and libpri layer 2 is being stupid) and the
restart attempt limit to 3 (instead of 2).

Periodically send RESTART on idle b-channels in PTP NT mode.
Default interval is 15 minutes, feature can be disabled by setting
"idle_restart_interval" to 0 in the span configuration.

Allow timeout / interval values to have an additional time unit
suffix for convenience reasons, the default (no unit specified)
is milliseconds, valid units include:

	w (week), d (day), h (hour), m (minute), s (second)

Only full integers are accepted, no fractional numbers, valid examples:

	2w   = two weeks
	37m  = 37 minutes
	1h   = 1 hour

Combinations of multiple numbers and units (e.g. "1w5d") are not supported.

New span configuration parameters:

	idle_restart_interval		(milliseconds / time unit suffix /
					 0 = disabled)

	t316 / restart_timeout		(milliseconds / time unit suffix)
	t316_limit / restart_attempts	(number of max. attempts)

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-09-05 00:42:32 +02:00
Stefan Knoblich f012b7abf8 ftmod_libpri: Major rework of runtime thread, lpwrap event loop, restart b-channel handling and some new features.
Add per b-channel private data (ftdm_libpri_b_data_t), move the q.931 libpri
call pointer into it and use channel->call_data to make it accessible.

Use ftdm_channel_wait() instead of select() to wait for I/O events on
the D-Channel and rewrite the timeout handling, adding support for custom
timers that can be added to the b-channel private data and started/stopped
with lpwrap_timer_start()/_stop().

The (sorted) list of active lpwrap timers is protected by the timer_mutex,
which is initialized in the now unified lpwrap_init_pri() (see below) and
destroyed in the new lpwrap_destroy_pri() function.

Unify lpwrap_init_pri() and lpwrap_init_bri(). Use the span type to select
BRI/PRI and Point-to-Point vs. Multipoint settings.

Use the new custom lpwrap timer API to implement T302 (aka overlap receiving
digit timeout). The default T302 timeout is 3000 miliseconds and can be set
via the "digit_timeout" or "t302" span configuration parameter
(0 = disable timer, valid range = 3000 ... 30000 miliseconds).

The lpwrap_pri_init() changes made it neccessarry to rewrite the span runtime
thread event loop. The d-channel initialization and libpri event handler
registration have been moved out of the event loop. The b-channel restart
handling in the event loop has been left as-is, pending a further clean up in
the future.

Rename on_info() to on_information() and add a new on_keypad_digit() event
handler to convert incoming KEYPAD DIGIT messages to channel DTMF events
(only useful on BRI PTMP NT-mode).

The channel restart handling has been improved to distinguish between locally
triggered and restarts caused by the remote end (= incoming RESTART messages).
Restarts on the D-Channel now use pri_restart(), causing a Q.921 reset on
the span.

Large patch, i'd have loved to split this into smaller pieces and actually
test some of the bits more toroughly (restart handling), but some people
are f*cking annoying, so here it is.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-09-03 20:35:48 +02:00
Stefan Knoblich a4216351c0 ftmod_libpri: Implement channel hunting in NT-mode.
Hunt for a free channel for incoming calls that do not
preselect a channel (pevent->ring.channel == -1).

Verify the preselected channel for calls that do specify a channel
and in case the channel is already taken, hunt for a free one,
or abort with an error message (if the preselection was exclusive).

TE-mode channel selection is the same as before
(there's still room for improvement, though, but i'll save that for later).

The MSN/DDI filter code is moved into the TE-mode section (only useful there).

The duplicate ring detection had to be reworked. We now store the
call reference (CRV) in caller_data->call_reference of the selected channel
and do a CRV -> channel look up with find_channel_by_cref()
at the top of on_ring().

NOTE: This is only lightly tested (NT/TE mode), i'd either have to
      write a lot of custom code to check it toroughly or the need for
      a scriptable ISDN stack...

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-08-24 00:36:34 +02:00
Stefan Knoblich 716f4c0675 ftmod_libpri: Check for '#' key to leave overlap receiving state.
Same as ftmod_isdn, '#' key ends overlap receive and moves the incoming
call to RING state.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-08-23 22:26:49 +02:00
Stefan Knoblich c3d13d5e00 ftmod_libpri: Drop custom MIN() macro and use common ftdm_min()
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-07-25 16:07:39 +02:00
Stefan Knoblich 67442974b2 ftmod_libpri: Fix type-punned pointer warning in msn_filter_foreach().
cc1: warnings being treated as errors
./src/ftmod/ftmod_libpri/ftmod_libpri.c: In function 'msn_filter_foreach':
./src/ftmod/ftmod_libpri/ftmod_libpri.c:422: warning: dereferencing type-punned pointer will break strict-aliasing rules
make: *** [ftmod_libpri_la-ftmod_libpri.lo] Error 1

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-07-18 21:57:52 +02:00
Stefan Knoblich f384e247fc FreeTDM: Add gcc printf()-style format string checks to ftdm_log(), also add FTDM_(U)INT64_FMT and FTDM_TIME_FMT constants.
The format string checks already caught a couple crash-worthy bugs and this
commit fixes a couple more.

Also includes __ftdm_check_scanf(), for completeness (currently unused).

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-07-11 22:44:08 +02:00
Stefan Knoblich 7a12804577 FreeTDM: Add trunk mode (NET/CPE) to span configuration in freetdm.conf and use it in ftmod_misdn and ftmod_libpri.
Some I/O implementations (e.g. mISDN) need this information to correctly
set up the port configuration. In FreeTDM, the mode of a span has been.
up until now, a part of the signalling module configuration ("node" or "mode"
for libpri and isdn spans), which is parsed _after_ the I/O part of a span
has been initialized. This limitation currently prevents us from using mISDN
in NT mode.

To work around this problem (without adding a lot of new tunk_type values like "E1_NET" etc.),
add a new "trunk_mode" parameter to the span categories in freetdm.conf, which by default
is "CPE" for all trunk types, except "FXS" (which defaults to "NET").

ftmod_misdn uses trunk_type + trunk_mode to correctly choose the d-channel protocol
for a port.

ftmod_libpri uses trunk_mode as a hint for the default "mode" setting.
(NOTE: It will print a warning if trunk_mode and signalling mode do not match.)

All other modules currently ignore the value of trunk_mode.

Example freetdm.conf snippet for a mISDN span in NET/NT mode
(using a HFC-S USB dongle):

  [span misdn MBRI_1]
  trunk_type => BRI_PTMP
  trunk_mode => NET
  b-channel  => HFC-S_USB.1:1-2
  d-channel  => HFC-S_USB.1:3

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-07-11 19:15:35 +02:00
Stefan Knoblich a5e1101302 ftmod_libpri: Add doxygen documentation for new MSN/DDI filter functions.
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-07-06 11:08:34 +02:00
Stefan Knoblich c92a55d3f1 ftmod_libpri: Add MSN/DDI filter for incoming calls.
This feature allows ftmod_libpri to ignore calls with non-matching destination number.

You may want to use this on BRI PTMP lines (Point-to-MultiPoint),
to avoid conflicts between your FreeSWITCH server and other devices connected to the line.

The filter is disabled by default (all calls will be accepted),
setting one (or more) "local-number" parameters on the span configuration enables it.

Example configuration snippet:

   <libpri_spans>
      <span name="example01">
         <!-- ... other span settings omitted ... -->
         <param name="local-number" value="123456"/>
         <param name="local-number" value="654321"/>
      </span>
   </libpri_spans>

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-06-26 21:53:20 +02:00
Ken Rice 7a147e4762 Update a ton of copyright statements to make sure the dates are proper 2012-04-25 17:14:55 -05:00
Stefan Knoblich 997550c511 ftmod_libpri: Check for required features in configure and remove old-style log callbacks
Non-PRI_NEW_SET_API logging callbacks were only available in libpri-1.0 and older,
which also lacks PRI_IO_FUNCS (required) and wouldn't work anyway.

Explicitly check for both PRI_* feature defines at configure time and reject libpri
versions that lack them.

Remove the non-PRI_NEW_SET_API logging callbacks in ftmod_libpri.c.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-04-14 01:39:25 +02:00
Stefan Knoblich 020724e103 ftmod_libpri: Improve libpri message logging.
Use the PRI_NEW_SET_API define provided by >=libpri-1.2 to distinguish
between old style and new style pri_set_error() and pri_set_message()
callback functions.

Improve message logging by using ftdm_log_chan() if per-span
data with a valid (d-)channel object is available.
NOTE: pri_get_userdata() returns NULL if pri is NULL.

This will reduce the horizontal space for libpri output a bit, but allows
us to see which span the message/error came from.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-04-14 01:13:22 +02:00
Stefan Knoblich 2de175b574 ftmod_libpri: Improve output of ftdm libpri api 'invalid span' error messages.
No more "invalid span", now it's either "'foo' not a libpri span" or
"'foo' span not found" which makes it a lot more useful.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2011-11-18 23:58:01 +01:00
Stefan Knoblich 5897ec5992 ftmod_libpri: Print usage if 'ftdm libpri' has no arguments.
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2011-11-18 23:58:00 +01:00
Marc Olivier Chouinard d185978f8d mod_freetdm/libpri: Fix problem with some destination using early-media for IVR. FS wasn't switching to accept the media of the early media provided in some type of ISDN msg. This fix it for the situation I've experienced. 2011-10-28 15:18:58 -04:00
Stefan Knoblich e1a6fd27e0 ftmod_libpri: Always try to close the d-channel to avoid a possible deadlock in case something fails in the I/O module's channel open function.
Signed-off-by: Stefan Knoblich <s.knoblich@axsentis.de>
2011-09-01 01:48:03 +02:00
Marc Olivier Chouinard 2ecf2d6e62 freetdm/libpri: Add support to change status of an individual channel or multiple channel. This allow to put bchannel out of service on an active T1 without affecting active call. Allow graceful out of service of T1 trunk.
NOTE: There is bugs in libpri, even latest 1.4.12 as of this writing if you use NI2.   So rightnow it only work in DMS100/ATT mode.  Email me to get the NI2 patch (really stupid error).
NOTE2: The way libpri is build doesn't allow to do advance feature with the SERVICE feature, so if you put an channel out of service, and the far end send an restart, it will be bring back in service.  Lot of changes in libpri is required to allow this.  I need to figure out what would be the best steps to take since I don't have commit access to libpri release.
NOTE3: You need to enable this feature by setting service_message_support to true on the span
2011-08-05 22:50:58 -04:00
Moises Silva 492bc6b416 freetdm: ftmod_libpri - request channel exclusively 2011-07-23 12:53:04 -04:00
Stefan Knoblich 1c608f0a5d ftmod_libpri: final fix called number overlap receiving...
ftdm_copy_string() length parameter needs to include the terminating NUL byte.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
Tested-by: Stefan Knoblich <stkn@openisdn.net>
2011-06-30 23:53:36 +02:00
Stefan Knoblich c01c500153 ftmod_libpri: Incoming overlap receiving digits have to be appended to the DNIS.
Libpri doesn't do that for us, so handle things on our end.
Other parts of the previous patch seem to work fine.

Signed-off-by: Stefan Knoblich <s.knoblich@axsentis.de>
2011-06-30 13:01:19 +02:00
Stefan Knoblich d2ce252509 ftmod_libpri: Add experimental (untested) support for overlap receiving in TE mode.
Adds a new "overlapdial" configuration parameter that enables
incoming overlap dialing when set to "incoming", "yes" or "both" (possible values:
"no", "yes"/"both", "incoming"/"receive", "outgoing"/"send").

(Overlap dialing is disabled by default)

NOTE: only the non-overlap receive case has been tested (= doesn't break existing setups)

Signed-off-by: Stefan Knoblich <s.knoblich@axsentis.de>
2011-06-29 13:26:51 +02:00
Moises Silva 152ce41283 freetdm: print libpri error string on error events 2011-06-09 11:15:53 -04:00