Commit Graph

1206 Commits

Author SHA1 Message Date
Moises Silva 7542c5877c freetdm: E&M: Set the line offhook when suspended 2013-11-08 02:22:36 -05:00
Moises Silva 3b0e8d9e2d freetdm: ftmod_zt: Refactor event processing to store OOB events that arrive during read/write operations 2013-11-08 02:22:05 -05:00
Moises Silva 545d1e5079 freetdm: Fix hangup supervision on inbound calls for Analog E&M 2013-11-08 02:19:41 -05:00
Moises Silva 271eda310e freetdm: Added CAS hangup bit checking to the E&M signaling module 2013-10-24 19:05:35 -04:00
Moises Silva 2b3c98b069 ftmod_analog_em: Block/unblock signaling when a span is stopped/started 2013-10-24 19:05:12 -04:00
Moises Silva 21b129e940 Allow setting/getting signaling status from E&M channels 2013-10-06 19:08:45 -04: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
Moises Silva a48bfafddd Fix log line in ftmod_analog.c 2013-09-09 02:06:17 -04:00
Moises Silva d8a9da2044 mod_freetdm: E&M Analog fixes
* Rename option ringback-during-collect to immediate-ringback
* Allow regular ringback tone with immediate-ringback, not just a wav file
* Do not request full frame of data, just packet_len which is what we receive per IO interval
* Ignore user data when playing ringback tone
2013-08-21 18:21:02 -04:00
Moises Silva bd4a5914dc freetdm: Override regular media with ringback in E&M when a ringback file is specified 2013-06-26 00:10:04 -04:00
Moises Silva 626dd2551a mod_freetdm: Expose new ringback E&M parameters in the XML config 2013-06-25 23:41:59 -04:00
Moises Silva cc6ee0322e Added ability to play a wav file as ringback tone during the COLLECT state of E&M signaling module
This is configured through 2 new parameters:
ringback-during-collect=yes|no
ringback-file=<wav file path>

You may not want to use this if your E&M lines are connected to traditional phones, otherwise
you will hear ringback tone while pressing digits. This is mostly useful with old switches that do
not provide ringback tone but the user is already done dialing (perhaps the signaling was converted from
ISDN to E&M and the full number was received in a single SETUP message)
2013-06-25 22:19:24 -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
Brian West b4ed2f55bf Up this buffer to prevent boxes from locking up if they receive more than 1000 bytes. 2013-06-04 17:10:05 -05: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 b793ccbe43 FreeTDM: Fix implicit conversion between enumeration types error
Full clang error message:

  error: implicit conversion from enumeration type 'ftdm_bool_t' to
  different enumeration type 'ftdm_status_t' [-Werror,-Wconversion]

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2013-05-10 19:04:10 +02:00
Stefan Knoblich cbf22d8a32 FreeTDM: Silence -Wtautological-compare warnings emitted by clang
Fixes "warning: comparison of unsigned expression >= 0 is always true".

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2013-05-10 19:04:09 +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
David Yat Sin 20110f4569 Freetdm - ISDN:Fix for race condition where we receive a new call, and did not finish clearing existing call internally. 2013-03-19 14:32:03 -04:00
David Yat Sin 79324e1fe9 Changed default setting for 5ESS to send CONNECT ACK to match spec 2013-02-19 16:56:11 -05:00
Moises Silva 7c6ba6a34c OPENZAP-207 --resolve Rework the zt_read function
Break the read loop when receiving ELAST
2013-02-11 11:35:30 -05:00
Moises Silva 29bfcb16be freetdm: ftmod_pritap: Allow specifying different audio mixing modes 2013-01-11 14:52:33 -05:00
Stefan Knoblich 42bb1040de ftmod_pritap: Use strcmp() for "none" and "all" in parse_debug()
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2013-01-10 18:41:16 +01:00
Stefan Knoblich fe4d5748c6 ftmod_pritap: Hexdump I/O buffers if q921_raw debug is enabled, improve parse_debug()
Add support for "q921_all"/"q931_all" to parse_debug() ("debug" span parameter), taken from
ftmod_libpri.

Passive libpri's raw dump feature is broken (e.g. I-frames missing), so
add "q921_raw" hexdump support to the pritap I/O read/write function.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2013-01-10 18:31:30 +01: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
Stefan Knoblich 2bb859e2b4 ftmod_misdn: Fix brown paperbag logic bug in handle_b_channel_event()
Yeah, right, discard the incoming audio data when the b-channel is active...

Reverse the check, so ftdm_read() on an active mISDN b-channel will
be able to read audio data from the RX socketpair and not kill
the call from repeatedly timing out in poll().

Fixes:
    [WARNING] mod_freetdm.c:775 Too many timeouts while waiting I/O in channel FreeTDM/1:1/XX device 1:1!
    [ERR] mod_freetdm.c:820 clearing IO in channel FreeTDM/1:1/XX device 1:1!

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2013-01-07 18:04:00 +01:00
Stefan Knoblich 95ac0ecc2f ftmod_misdn: Retry recvfrom() in case of EAGAIN
epoll_wait() on the B-channel socket may indicate pending messages, but
recvfrom() returns EAGAIN. Retry a few more times (up to 5 retries)
to get the pending message.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2013-01-07 13:35:38 +01:00
Stefan Knoblich f2c325bf3e ftmod_misdn: Fix %lx vs.__u64 format string error
Fixes:
      src/ftmod/ftmod_misdn/ftmod_misdn.c:924:3: error: format '%lx' expects
      argument of type 'long unsigned int', but argument 13 has type '__u64'
      [-Werror=format]

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
Reported-by: hyper_ch #freetdm @ irc.freenode.net
2013-01-06 13:47:06 +01:00
Moises Silva 56846c02c6 freetdm: ftmod_analog_em: If the destination number DTMF was already generated, do not generate it again
This bug was cause when answer-supervision is used because now we do not move from DIALING to UP
         as soon as the line is ringing, but instead we wait for the CAS bit change
2012-12-20 12:18:24 -05:00
Moises Silva 27a8ec93de freetdm: Added Analog E&M outbound call answer supervision
You must add answer-supervision=yes in your freetdm.conf.xml
         Also added dial-timeout parameter which was previously hard-coded
2012-12-18 22:55:14 -05:00
Moises Silva 6e9dc465cc freetdm: ftmod_analog_em: Fix incorrect read length 2012-12-18 14:24:00 -05:00
Moises Silva 6f5438eded freetdm: ftmod_zt:
Handle driver events while reading media

         ftmod_analog_em:
         Initialize read data len to avoid crashing when
         the freetdm read function does not read anything
2012-12-18 14:23:31 -05:00
Moises Silva a7f8e4259e OPENZAP-201 --resolve 2012-11-26 14:26:41 -05:00
Moises Silva b64cc02390 freetdm: ftmod_zt - Declare tone mode at the top to avoid compilation errors 2012-11-19 10:24:25 -05:00
Moises Silva db673a043f freetdm: ftmod_zt - Integrated HW DTMF support 2012-11-18 23:57:52 -05: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
Moises Silva 9bc3dfc874 fretdm: little white lie 2012-11-09 16:53:39 -05:00
Moises Silva d39269b217 freetdm: ftmod_pritap - Fix memory corruption due to freeing a call
pointer that was still in use
2012-10-29 15:34:08 -04:00
Moises Silva 87a1d78e42 freetdm: ftmod_pritap - Use a single thread per every pair of spans tapping a single line 2012-10-29 15:33:59 -04:00
Moises Silva aeb07172b0 freetdm: ftmod_pritap - Do not print an error when the crv is no longer in use
since this is a valid code path
2012-10-29 15:33:50 -04:00
Moises Silva e4e6fa65d0 freetdm: ftmod_pritap - Lock the channel during call setup
Destroy the peer before the master channel
2012-10-29 15:33:41 -04:00
Moises Silva d88e79e632 freetdm: ftmod_pritap - Use uint8 for flags (I smell a bug somewhere with bitfields) 2012-10-29 15:33:31 -04:00
Moises Silva 7d5a4a7172 freetdm: ftmod_pritap - Destroy call references as soon as possible 2012-10-29 15:33:22 -04:00
Moises Silva 3cb1fd267f Try to fix pritap segfault 2012-10-29 15:33:09 -04:00
Moises Silva 0a92094995 freetdm: ftmod_pritap - Add interface type parameter (cpe/net) 2012-10-29 15:32:57 -04:00
Moises Silva d2a73cc0e4 Updated ftmod_pritap.c to send SIGEVENT_UP when the tapped line is answered 2012-10-29 15:32:16 -04: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
Moises Silva 004ebe4f12 OPENZAP-196 Fix casting issue - Apparently this fixes libpri BRI issues 2012-10-23 13:00:16 -04:00
David Yat Sin 15ef8925c3 Fix for Q.921 not always recovering 2012-09-27 23:48:18 -04:00
Moises Silva fff6e50a9b freetdm: Fix E&M answer procedure for DAHDI 2012-09-19 20:03:09 -04:00
Brian West 98063854c6 This already has a new line in it 2012-09-19 15:54:38 -05:00
David Yat Sin 7018a15bf1 fix for compile warning 2012-09-19 15:25:38 -04:00
David Yat Sin aa8f48c7e3 Fix for compile warning 2012-09-18 23:14:27 -04:00
David Yat Sin 2aa5b78514 freetdm: Fix for DL re-establishment on NFAS 2012-09-18 23:11:05 -04:00
Stefan Knoblich 715c538922 ftmod_misdn: Handle incoming PH_CONTROL_IND messages on b-channels
Also add a few more PH_CONTROL_IND message types.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-09-17 21:43:59 +02:00
Stefan Knoblich bc414df510 ftmod_misdn: Discard incoming audio data if b-channel is not active
Silences the "Device or resource busy" error messages caused by the RX pipe
filling up.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-09-17 21:40:59 +02:00
Stefan Knoblich dd4a995b34 ftmod_libpri: Default disable NT-mode idle b-channel restart
Some people, it seems, were having sleepless nights from the
log messages this feature produces every 15 minutes.

Default disable the feature, because i hate repeating myself
over and over, explaining them this is a non-issue and intended
behaviour and how to disable it in the config.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-09-16 14:07:55 +02:00
David Yat Sin 83d7f4282c Fix for compilation errors 2012-09-13 00:00:26 -04:00
David Yat Sin 9297863a4d Fix for compile warnings 2012-09-12 13:13:51 -04:00
David Yat Sin 4340c4d74c Merged latest FreeTDM code from Sangoma's repo
Merge remote branch 'smgfs/master'

Conflicts:
	build/modules.conf.in
	configure.in
	libs/esl/fs_cli.c
	libs/freetdm/mod_freetdm/mod_freetdm.c
	libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h
	libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c
	libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c
	libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c
	src/include/switch_types.h
	src/mod/applications/mod_commands/mod_commands.c
	src/mod/applications/mod_spandsp/mod_spandsp.c
	src/mod/endpoints/mod_opal/mod_opal.cpp
	src/mod/endpoints/mod_opal/mod_opal.h
	src/mod/endpoints/mod_sofia/mod_sofia.h
	src/mod/endpoints/mod_sofia/rtp.c
	src/switch.c
	src/switch_core.c
	src/switch_rtp.c
2012-09-12 11:05:39 -04:00
David Yat Sin c425955670 Merge branch 'nsg-4.3' 2012-09-11 15:01:26 -04:00
David Yat Sin 848db87c26 Merge branch 'releases.3.5' into nsg-4.3 2012-09-11 14:56:22 -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
David Yat Sin c0e4ca47bc Freetdm: ISDN fix for link not always recovering after T1/E1 alarm 2012-09-11 01:22:31 -04:00
Stefan Knoblich 17329d04ad ftmod_libpri: Print warning message in lpwrap_stop_timer(), if timer is not on the active list
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-09-07 00:04:40 +02:00
Stefan Knoblich a035182582 ftmod_libpri: Append new lpwrap timers in correct order.
List is sorted in ascending order of expiration time,
fix the if clause in lpwrap_start_timer().

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-09-07 00:02:32 +02:00
David Yat Sin f49ee5ebf9 FreeTDM: Added function to listen for mg-tdm-dtmfremoval command to disable/enable DTMF removal per channel 2012-09-06 16:53:58 -04:00
Nenad Corbic 0c49449746 Changed MTP2 events from ERROR to WARN 2012-09-05 23:06:08 -04:00
Nenad Corbic c260bc4b8a Update mtp2 loglevels
Alignment loss - wanring
Alignment up - info
2012-09-05 18:03:08 -04:00
Moises Silva 15fa227699 freetdm: Fix ss7 logger broken compilation 2012-09-05 02:26:39 -04: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 1a47eb933b ftmod_libpri: Reset timer parameters in lpwrap_run_expired() before invoking the callback.
Allowing us to restart the timer from the callback with lpwrap_start_timer().

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-09-05 00:42:32 +02:00
David Yat Sin 3a57b0bed6 Merge remote branch 'fsorig/master' into nfas
Conflicts:
	libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c
	libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c
2012-09-03 22:34:13 -04:00
David Yat Sin b0f6e0384d freetdm - ISDN:Fix for invalidating logical span id = 0 for nfas 2012-09-03 22:26:03 -04: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
Kapil 4569bbec22 redmine task# 5692 fix, changing log level for link error cases 2012-08-31 11:54:24 -04:00
Stefan Knoblich 5b499e8a59 ftmod_misdn: Use a per-span I/O thread to handle B-channel data.
Move the B-channel message handling into a per-span I/O thread,
to solve most of the problems caused by the intermixed data + control
socket interface of mISDN, missing write poll() support on
mISDN B-channels and the FreeTDM I/O model. This eliminates most of
the audio problems (except for a few minor glitches).

A unix stream socket pair is used as a bi-directional pipe replacement
(the pipe code is still included in this commit, but will be removed later),
with the RX and TX buffer sizes carefully tuned to avoid excessive buffering
(= latency) and a deadlock situation between the write() call in ftdm_write()
and the code in misdn_span_run() that needs a minimum amount of data in the
TX buffer, before sending out a PH_DATA_REQ to the mISDN socket
(see misdn_span_run() comments for more details).

The minimum size for pipes is PAGE_SIZE (4k), which is ~500 ms worth of
audio. A socket pair RX/TX buffer size of 3k, seems to hold a maximum
amount of around 500 bytes data in practice, giving us a much lower
maximum latency than a unix pipe. (The socket pair might be replaced by a
custom ring buffer / fifo data structure to get even more fine grained
control of the maximum latency.)

The newly introduced span_start / span_stop callbacks in
ftdm_io_interface_t are used to start / stop the I/O thread. The callback
functions will wait up to 10 seconds for the thread to successfully
start up or shut down (using a mutex + condition var).

NOTE: Using any of the locking ftdm_span_() functions in the I/O will cause
      a deadlock between the I/O thread (trying to lock span->mutex) and the
      thread calling ftdm_start()/_stop() (holding the span->mutex).
      (The I/O thread currently uses direct span member access to avoid this.)

The I/O thread uses the epoll(7) family of functions for event handling.
An epoll context is created on startup and all B-channel sockets are
registered (READ, PRI and ERR). Before entering the event loop,
the I/O thread will send a signal on the condition variable, to
indicate it has completed the startup procedure.

Incoming b-channel and command pipe events are handled by the event loop.
Payload of incoming PH_DATA_IND frames (= audio data) is sent to the
rx_audio_pipe_in end of the b-channel's socket pair and, if enough data is
available, a PH_DATA_REQ of the same size is sent to the b-channel mISDN socket
to transmit audio.

A MISDN_CMD_STOP command on the event pipe will wake up the I/O thread and
cause it to shut down. All b-channels will be unregistered from the epoll context
and the epoll fd closed. The I/O thread terminates itself after signalling the
successfull shutdown on the condition variable.

TODOs:
    - Move D-Channel into I/O thread too

    - Custom FIFO/ring buffer for data (even lower latency)

    - Improve epoll() code (per-channel struct w/ callback, for epfd.data.ptr)

    - Use mISDN DSP for audio (e.g. tone generator, dtmf detector, echo cancel)

    - Use a per-port / span control socket to execute channel commands
      synchronously, or add misdn_commands (queue?) that can be used that way

    - Name I/O threads 'mISDN-%SPAN_NAME%', e.g. 'mISDN-M_BRI1'
      (= add ftdm_thread_set_namef(thread, fmt, ...) / ftdm_thread_set_name(thread, name))

TL;DR: "tweak", solves "booboo" with audio

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-08-24 18:03:31 +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
Kapil Gupta 12e61692dd adding signaling FTDM_SIGTYPE_M2UA type 2012-08-17 19:05:12 -04:00
Moises Silva f3160f9ecf freetdm: ss7 - Fix bug where TDM alarms are not delivered when the span is in M2UA mode 2012-08-16 19:08:34 -04:00
Stefan Knoblich 2ad2b6d31b ftmod_isdn: Avoid stack smashing buffer overflow in isdn_tones_run().
The len variable can, in certain situations (large burst of incoming non-SLIN audio),
exceed the size of the on-stack frame buffer, which causes ftdm_buffer_read_loop() to
overwrite the dt_buffer pointer.

Use ftdm_min() to make sure len (after conversion to SLIN units) isn't larger
than the frame buffer size.

Also adds are couple more code comments.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-08-10 17:16:05 +02:00
Moises Silva 16692837c1 freetdm: Process OOB events even in M2UA mode 2012-08-08 09:58:41 -04:00
Stefan Knoblich 964d14c012 ftmod_isdn: Fix channel state handling in NT mode w/ early disconnect.
In this particular case: NO_ROUTE_DESTINATION caused by missing context.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-08-07 17:22:17 +02:00
Stefan Knoblich c6cf92d766 ftmod_isdn: Use ftdm_time_t for dialtone timeout.
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-08-07 17:22:17 +02:00
Kapil Gupta 34000bf188 adding "interface-identifier" field to configuration 2012-08-03 12:07:02 -04:00
Stefan Knoblich ac0eec9de4 ftmod_isdn: Fix set-but-unused warning.
Resolves OPENZAP-189

Fixes:
	src/ftmod/ftmod_isdn/ftmod_isdn.c: In function 'ftdm_isdn_931_34':
	src/ftmod/ftmod_isdn/ftmod_isdn.c:902:21: error: variable 'status' set but not used [-Werror=unused-but-set-variable]

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-08-03 12:33:40 +02:00
David Yat Sin 6906c00342 Merge branch 'releases.3.4' into releases.3.5
Conflicts:
	src/include/switch_channel.h
	src/switch_channel.c
2012-07-31 14:18:36 -04:00
David Yat Sin 2a1eb6e8fa Merge branch 'releases.3.4' of ssh://git.sangoma.com/smg_freeswitch into releases.3.4 2012-07-28 10:42:18 -04:00
David Yat Sin 4bbb8c014a Fixed compile error 2012-07-28 10:41:55 -04:00
David Yat Sin a6503b4952 Fixed compile warning 2012-07-28 09:59:47 -04:00
James Zhang a4255e140b freetdm: adding variables for ansi outgoing IAMs
. added called party number INN variable
           ie. <action application="export" data="freetdm_ss7_cld_inn=0"/>
         . added multiple variables to set User Service Information IE
           variables are :
              ss7_iam_usi_trans_cap
              ss7_iam_usi_code_standard
              ss7_iam_usi_trans_mode
              ss7_iam_usi_trans_rate_0
              ss7_iam_usi_trans_rate_1
              ss7_iam_usi_layer1_ident
              ss7_iam_usi_layer1_prot
              ss7_iam_usi_layer2_ident
              ss7_iam_usi_layer2_prot
              ss7_iam_usi_layer3_ident
              ss7_iam_usi_layer3_prot
              ss7_iam_usi_chan_struct
              ss7_iam_usi_config
              ss7_iam_usi_establish
              ss7_iam_usi_symmetry
              ss7_iam_usi_rate_multiplier

         . ss7_iam_usi_trans_cap is a string variable, the others are all integers
         . ss7_iam_usi_trans_cap has options of :
              - SPEECH
              - UNRESTRICTED
              - RESTRICTED
              - 31KHZ
              - 7KHZ
              - 15KHZ
              - VIDEO
           default value is SPEECH, if the parameter is wrong, set to SPEECH. If not
           set, this field is not present
2012-07-27 11:53:00 -04:00
Stefan Knoblich dc1422998a FreeTDM: Add FTDM_XINT64_FMT 64bit hex format string and use it in ftmod_misdn.
Fixes:
  src/ftmod/ftmod_misdn/ftmod_misdn.c: In function 'misdn_handle_mph_information_ind':
  src/ftmod/ftmod_misdn/ftmod_misdn.c:871:3: error: format '%lx' expects argument of type 'long unsigned int', but argument 13 has type 'uint64_t' [-Werror=format]

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-07-27 14:33:46 +02:00
Stefan Knoblich 5ebc68fb51 ftmod_isdn: Fix per-channel teletone buffer offset wraparound.
Do a "soft" wraparound with modulo, removes the ~0.5s tone glitch.
(Multiply ts.rate (samples) by two to match the offset unit (bytes, 2 per sample).)

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
2012-07-26 09:14:51 +02:00