- When NSG receives INR from network, send back INF with calling
party category information IE and calling number information IE.
- Introduced a new global setting of "force-inr" for testing
purpose. Stinga generated INR/INF packets are not acceptable by
trillium stack since it misses call related information in the
packets. If configure force-inr to true in freetdm.conf.xml, when
NSG receives an incoming IAM, it'll send out INR packet regardless
of incoming IAM's IEs, and keep waiting for INF response from the
calling side.
- T.39 timer is introduced in order to handle INR timeout. The
default value of T.39 is 12 seconds and is configurable according
to spec.
- Only supports calling number IE and calling party category IE in
current fix. The customer only needs the calling number IE right now.
In ISUP spec, there are 6 optional IEs. NSG only supports calling
party number and calling category information IE since the other
IEs are not configurable in freetdm.conf.xml or included in IAM
message.
- In collect state, INR/INF implementation needs to work with existed
SAM messages. If NSG sent out INR and wait for SAM, collect state
check both INF received and enough dialed numbers received. If one
of these conditions are not met, it'll stay in collect state and wait
until either conditions met or timeout. After received INF and enough
dailed number, state moves to dailing and proceed as regular calls.
resource-cleanup responsibilities clearly between the 2 channels involved in the bridge
- Each channel is responsible for clearning its own peer_data and event queue
at the end of the call (when moving to DOWN state)
- Each channel dequeues messages only from its own queue and enqueues messages
in the peer's queue, with the only exception being messages received before
the bridge is stablished (IAM for sure and possible SAM messages) because
if the bridge is not yet stablished the messages must be queued by the channel
in its own queue temporarily until the bridge is ready
- When the bridge is ready it is the responsibility of the incoming channel to
move the messages that stored temporarily in its own queue to the bridged peer queue
- During hangup, each channel is responsible for moving itself to DOWN. The procedure
however differs slightly depending on the hangup conditions
If the user requests hangup (ie, FreeSWITCH) the request will be noted by setting the
FTDM_CHANNEL_USER_HANGUP flag but will not be processed yet because call control is
driven only by the link messages (so no hangup from ESL or command line allowed)
When REL message comes, the channel receiving it must move to TERMINATING state and:
- If the user has not hangup yet (FTDM_CHANNEL_USER_HANGUP flag not set) then
notify the user via SIGEVENT_STOP and wait for the user to move to HANGUP
state by calling ftdm_channel_call_hangup() before sending RLC
- If the user did hangup already (FTDM_CHANNEL_USER_HANGUP flag is set) then
skip user notification and move to HANGUP state directly where the RLC message
will be sent
- On HANGUP state the RLC is sent and the channel is moved to DOWN, final state
The peer channel will forward the REL message and wait for RLC from the network, when
RLC is received the channel can move straight to DOWN itself because the peer channel
is completing its own shutdown procedure when it received the REL message
This fixes an issue where ss7 native bridge was accidentally enabled
any time two freetdm channels were bridged regardless of the freetdm_native_sigbridge
variable value.
Use the amount of audio data received in misdn_read() to determine how many
bytes we need to send to the b-channel (= how much free space is left
in the b-channel tx queue). (This is how libosmo-abis and LCR handle it too.)
A pipe is used as a poll()-able audio tx buffer (filled in misdn_write()):
FTDM_WRITE wait requests are currently poll()-ed on the input side of the pipe,
whereas FTDM_READ and _EVENT requests are poll()-ed on the b-channel socket itself.
For every N-bytes of audio data read from the b-channel in misdn_read(),
we try to get as much out of the tx pipe, convert it into the ISDN_P_B_RAW
format and send it to the b-channel socket.
If there's less than N-bytes left in the pipe, we fill the remaining buffer
with silence to avoid buffer underflows.
B-Channel handling overview:
- misdn_wait(FTDM_WRITE) on audio pipe
- misdn_write() put audio data into pipe
- misdn_wait(FTDM_READ) for next incoming mISDN
message on b-channel socket
- misdn_read() handle mISDN event, for PH_DATA_IND:
- Write data into channel buffer and convert
to a/u-law using misdn_convert_audio_bits()
- Try to fetch N-bytes from audio pipe
- If not enough bytes in pipe: fill remaining space with silence
- Convert audio to raw format
- Send to b-channel (PH_DATA_REQ)
Known problems / bugs / further investigation:
1. Bridge aborted by "Write Buffer 0 bytes Failed!" error from switch_core_io.c.
This is "fixed" by _not_ setting the b-channel sockfd to non-blocking mode.
2. Audio glitches (maybe caused by FTDM_WRITE misdn_wait() handling or blocking I/O on sockfd?)
3. misdn_read() EBUSY error messages from sending data to b-channel sockfd after enabling channel.
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
The former fixes a strange "bug" with hfcsusb, where a b-channel deactivation
on a inactive channel (caused by a reset cycle) would cause the port to
lock up and stop processing events.
NOTE: this still needs to be investigated further, but this workaround will
at least prevent it from breaking completely.
We'll now keep track of the channel activation state and not send any
PH_ACTIVATE_REQ / PH_DEACTIVATE_REQ requests, if the channel already has the
desired state.
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
Use POLLIN on the socket instead, the b-channel should be able
to write when there is something to read.
Several other projects handle it this way, e.g. libosmo-abis.
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
The code was improperly using peer_data as an indicator that the sigbridge
ss7 mode was enabled. The channel flag FTDM_CHANNEL_NATIVE_SIGBRDIGE should
be used instead
- The outgoing tdm leg should not move to UP until
after the IAM is sent at the end of the function
- The UP state should be processed immediately otherwise
the state processor is not run due to the way the main
ss7 processing loop currently works
Use FTDM_SIZE_FMT where needed, don't treat ftdm_event_t as an int
(even if the e_type enum is the first member), datalen vs. *datalen fix
and other warnings.
All reported by __check_printf() (GCC + __attribute__((format(printf,x,y))) ).
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
... that could cause segmentation faults.
Caught while working on __check_printf() support for ftdm_log().
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
For compilers that seem to do the wrong thing(tm).
Speculative fix for:
segfault at 1 ip b72145d3 sp b58f8bfc error 4 in libc-2.11.3.so
#0 0xb7a5d5d3 in vfprintf () from /lib/i686/cmov/libc.so.6
#1 0xb7a7cec7 in vasprintf () from /lib/i686/cmov/libc.so.6
#2 0xb7dd7c5b in switch_vasprintf (...)
#3 0xb6296de2 in ftdm_logger (...)
#4 0xb621625d in misdn_handle_mph_information_ind (...) at ftmod_misdn.c:658
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
Only two mISDN hardware drivers emit MPH_INFORMATION_IND messages and both use a different payload:
- hfcsusb (HFC-based USB dongle) sends a set of ph_info + ph_info_ch structures
which contain the complete state information of the port
(including internal hw-specific state and flags).
- hfcmulti which sends a single integer, a single L1_SIGNAL_* event.
We now try to guess the type of message from the payload length.
The hfcmulti signals are converted to FreeTDM alarm flags; the hfcsusb
state/flags are defined in kernel internal hw-specific headers and are ignored ATM (todo).
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
Add MISDN_MSG_DATA() helper macro for easy access to mISDN message
payload.
Add forward declaration of misdn_handle_mph_information_ind() and use
it in misdn_activate_channel().
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
Add missing mISDN event/message types (e.g. MPH_INFORMATION_IND)
and use a helper macro (MISDN_EVENT_TYPE) to define the entries,
like we already do for misdn_control_types[].
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
- The queue size has been bumped again, long calls could potentially require more elements (multiple resume/suspend)
- The queue is only used when there is a call active
- redirect number in Transparent IAM
- redirect information in Transparent IAM
- called party number in Transparent IAM
- adding incoming uuid to x-header to check loop calls
On SIG Down we must not fail a call instead try hunting for another.
The only time we can fail the call and not bother hunting is
if sng_cc_resource_check fails.
Took out configuration retry as the config code is now
fixed in sng_ss7 library. Transaction id fix.
Unit Tested:
NSG UP -- start full load
kill NSG
NSG UP again on full load
make sure it comes up fine.
before hanging up the freetdm channel by force
seems to have a memory leak. I have increased the timeout
to 30sec and made the print statement WARNING level.
Where FS does not hangup the channel with in 3sec.
Without this fix, it was possible that 2 FS sessions
use the single span/chan freetdm session.
Merged the feature from git master of freetdm
SUSPEND will not only change the return state in few
cases.
I have retested all test cases from previous 2 commits.
What is missing is timer for each Tx Event. RSC,BLO,UBL.
Its possible to loose a message from Slave via relay to Master.
If that ever occours we will not know what state we are in.
Thus we need a timer that will re-transmit a packet if
it does not get acknowledged.
changed parameter name from cpu_reset_alarm_threshold to cpu_clear_alarm_threshold
(old parameter name still valid for backwards compatibility in configuration files)
used to clear ckt_flags, this was wrong.
if ctk_flags are blindly cleard a PAUSE might be cleared.
changed the code to clear only TX RESET and try to reset again.
Release Collision
If we get out of sync with other side we must
reset the circuit.
This condition occoured at 1+3 test box
Local Management Block
Its possible for stack to send us a BLO indicating to us
that we are local blocked. This case never worked and
we would get stuck there forever.
If we never manaully sent a LOCAL block, the BLO from
the stack will be acked and then unblocked.
This condition occoured at 1+3 test box
From previous commit, failed to clear the done flag _DN
which cause SUSPEND to think that there was a block
pending, causing state to remain in RESTART
S UP -> relay down -> Tx AIS -> relay up -> Tx AIS off
-> confirm all back up
-> In this condition BLO will not go out due to PAUSE
S UP -> Tx AIS -> relay down -> Tx AIS off -> relay up
-> confirm all back up
-> In this condition UBL will not go out due to PAUSE
Visually status of channels will only be DOWN once all resets/blocks are cleared.
Therefore if any reset/block is active on a channel, the channel state will be in RESTART not DOWN.
Logic Change
SUSPENDED
-> Originally used as intermediate state. Purpose is to handle a condition
from any state and go back to the previous state.
Conditions: such as block/ucic.
-> Updated logic is that SUSPEND will be smart enough not to
go back to just any state. SUSPEND will only go back to
UP - if call is still up
RESTART - if for any reason singaling is not up due to
blocks/resets/etc...
DOWN - if signaling is UP - no resets/blocks
In this case we avoid infinite loops due to state jumping
from STATE->SUSPEND->STATE->SUSPEND
HANGUP_COMPLETE
-> If call is in use and a RESET comes on a call
the RESTART state will first try the HANGUP_COMPLETE state.
HANGUP_COMPLETE will Tx RSC and wait for it.
Reset Response handle was updated if current state HANGUP/HANGUP_COMPLETE
go back to RESTART state. Which will call HANGUP COMPLETE due to
channel in usage and HANDLE_COMPLETE will clear RESET condition and go back to DOWN
TERMINATING
-> This state is used to hangup a call. Sends a signal to FS.
-> Usually TERMINATING state stays in TERMINATING until FS comes back.
-> I added a condition in case of RESET on the line though TERMINATING
will go back to RESTART.
This allows us to process RESET commands even though we are
in the middle of hanging up.
Block Handler
If BLO is received on circuit is already blocked,
we failed to trasmit BLA. We should always ack the BLO
even though it was alrady in blocked state.
Fixed & Tested
S UP --> place call --> relay down --> hangup --> relay up-->
Confirm that call is hungup properly.
In this condition, on relay up the circuit is put into RESET.
Since circuit is still in use, it will HANGUP first, then RESET
then clear pending BLOCK.
S UP --> place call -> Tx RSC on call.
Used to cause infitie loop
Confirm call is cleard properly
Re-Tested
S UP --> place call -> Rx RSC on call
Confirm call is cleard properly
S UP --> place call -> Rx BLO -> hangup -> place call
Confirm call cannot be placed
Tx UBL
Confirm call can be placed
S UP --> place call -> Rx BLO -> Tx BLO -> hangup -> place call
Confirm call cannot be placed
Tx UBL
Confirm call cannot be placed
Rx UBL
Confirm call can be placed
S UP --> place call -> relay down --> Rx BLO on channel from telco
--> relay up
Confirm that relay detects the BLO channels even though relay was down
Tx AIS -> S Start -> Confirm HW block -> Tx AIS off
-> Confirm hw block clear and UP
S UP -> Tx AIS -> Confirm HW block -> Tx AIS off
-> confirm hw block clear and UP
S UP -> relay down -> Tx AIS -> relay up -> Tx AIS off
-> confirm all back up
-> In this condition BLO will not go out due to PAUSE
S UP -> Tx AIS -> relay down -> Tx AIS off -> relay up
-> confirm all back up
-> In this condition UBL will not go out due to PAUSE
M UP -> S UP
M Down -> S UP -> M UP
M UP -> S UP -> relay down -> relay up
M UP -> S UP -> Kill M -> M UP
M Up -> S UP -> relay down -> M link down -> relay up -> M link up
Redmine Bug#1966
IAM ->
<-REL
<-ACM
<-ANM
ACM sets the reset flag
ANM sets the group reset flag
when both reset flags are set we got into infinite loop
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>
src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c
cc1: warnings being treated as errors
src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c: In function
'handle_con_ind':
src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c:255: warning: format '%x'
expects type 'unsigned int', but argument 3 has type 'U32'
make[6]: *** [ftmod_sangoma_ss7_la-ftmod_sangoma_ss7_handle.lo] Error 1
cpg_on_progress_media is default to TRUE if not xml option exists.
transparent_iam_max_size added to ccspan. Gloal value is used
if transparent_iam_max_size is not in ccSpan.
Fixed hw alarm handling: physical ids were not used which caused alarms
read wrong.
Tested sip hold
Group blocks/unblock
Group reset
Link down-> block -> unblock
FS start with link down then link up
FS start with link up, take link down and up -> make incoming call
This fixes a "AX_COMPILER_VENDOR: command not found" error on
systems with older autotools versions (CentOS 5.x in this case).
Not a problem on newer auto* toolchains, they either ignore
acinclude.m4 completely or handle it in a different way.
(In fact, acinclude.m4 is not even needed for the one on CentOS 5,
but we'll keep it for now.)
Tested-on: CentOS 5.7 x86_64 autoconf 2.59 / automake 1.9.6 / libtool 1.5.22
Tested-on: Gentoo 20111031 x86_64 autoconf 2.68 / automake 1.11 / libtool 2.4
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
* FreeTDM modules using the old FTDM_SPAN_STATE_CHANGE flag should be updated *
* until then, they are still vulnerable to deadlock situations *
* Modules pending update: (ftmod_analog, ftmod_libpri, ftmod_isdn) *
* Fixes Sangoma redmine ticket #1791 0 FTDM span stop deadlock *
* FreeTDM modules using the old FTDM_SPAN_STATE_CHANGE flag should be updated *
* until then, they are still vulnerable to deadlock situations *
* Modules pending update: (ftmod_analog, ftmod_libpri, ftmod_isdn) *
* Fixes Sangoma redmine ticket #1791 0 FTDM span stop deadlock *
This fixes all build errors.
(Stand-alone build of FreeTDM worked fine, for some
i-don't-really-want-to-know strange reason).
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
Needed for the mISDN/mISDNif.h header structs, linux/types.h only
provides them for kernel code:
In file included from src/ftmod/ftmod_misdn/ftmod_misdn.c:51:
/usr/include/mISDN/mISDNif.h:296: error: expected specifier-qualifier-list before 'u_int'
/usr/include/mISDN/mISDNif.h:306: error: expected specifier-qualifier-list before 'u_int'
/usr/include/mISDN/mISDNif.h:339: error: expected ')' before 'nr'
...
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
libteletone headers include each other, use #include ""
to look in the local dir rather than the include search path.
Unbreaking all of my (still) external FreeTDM projects.
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
This avoids hanging up a device that is no longer attached to the session, in the
weird situation where the FreeSWITCH core takes an awful lot of time (more than 3 seconds)
to come around to acknowledge the SIGEVENT_STOP signal.
- Misc fixes to log messages to aid debugging
- Added ftdm ioread command to read media from the channel
- Modified the ftdm_channel_open() API to return FTDM_EBUSY if the channel is already open
Add I/O plugin for mISDN stack that is included in the linux kernel
since version 2.6.27.
The in-kernel mISDN stack uses a socket based interface (AF_ISDN),
data and control commands are exchanged via datagram messages.
This makes writing a driver that doesn't use a separate (per-span)
thread to handle all incoming events a bit tricky, because responses
to control messages and incoming data are mixed and interfacing
with the synchronous FreeTDM I/O API is problematic.
B(*)/D-channel handling:
The current version uses misdn_wait() to poll() for activity on
the non-blocking channel sockets and misdn_read() to receive and
handle all pending events up to the first PH_DATA_IND (data) message
(which is what the caller of the read method is actually after).
In case no data has been received, misdn_read() returns FTDM_SUCCESS
with *datalen = 0, which is OK for all the signalling modules tested
(ftmod_libpri and (out-of-tree) ftmod_isdn).
To send data, misdn_write() is called, which just sends a PH_DATA_REQ
message to the mISDN channel socket.
(*) B-channels use a per-channel timerfd as a timing reference for
'ready-for-write' poll()ing in misdn_wait().
This is a workaround for a limitation of mISDN sockets, which do not
support POLLOUT waiting on b-channel sockets (in a useful way).
Sending/receiving of data works the same way as on d-channels, otherwise.
The module has received some minimal testing using a beronet
single-port HFC E1 and a HFC4-S quad-port BRI card on linux-3.0.x.
--- Limitations ---
- Only the most basic features have been implemented (alarms,
sending/receiving data/audio).
- Spans are limited to E1 and BRI/BRI_PTMP trunk types.
- D-Channels only work on 16 for PRI and 3 for BRI.
- NT/TE mode information is not available from freetdm.conf /
at configure_span()-time so the module assumes TE mode,
which should be only a problem for cards that can change
the port configuration (pin-out) from software.
- Current design (b-channel timerfd / misdn_wait()/_read()/_write())
should be fine for most SoHo use-cases
(scalability / cpu usage / timing precision).
--- Requirements ---
- mISDNif.h header (/usr/include/mISDN/mISDNif.h), provided by mISDNuser
(http://isdn.eversberg.eu/download/lcr-1.7/mISDNuser-20100525.tar.gz).
- Linux kernel with mISDN and timerfd enabled (>= 2.6.27)
and libc with timerfd support.
mISDN options can be found in the:
"Device Drivers" -> "ISDN support" -> "Modular ISDN driver"
section of make menuconfig. Timerfd is usually enabled by default.
The FreeTDM configure script will check for missing mISDNif.h
header and timerfd support and print a message.
You should see the following in the summary screen on success:
ftmod_misdn........................ yes
NOTE: Forcing mISDN support using the "--with-misdn" configure option,
will cause the configure script to fail on the first missing
dependency.
--- Usage ---
To use the module, make sure you have mISDN support in the kernel
(kernel modules loaded or kernel with built-in mISDN running),
the "misdn_info" application shipped with mISDNuser will output
a list of available mISDN ports on your system, e.g.:
Found 5 ports
Port 0 'hfc-4s.1-1': TE/NT-mode BRI S/T (for phone lines & phones)
2 B-channels: 1-2
B-protocols: RAW HDLC X75slp
...
Port 4 'hfc-e1.2': TE/NT-mode PRI E1 (for phone lines & E1 devices)
30 B-channels: 1-15 17-31
B-protocols: RAW HDLC X75slp
NOTE: ftmod_misdn will print an error message if mISDN support is not available,
or if there are no ports installed.
- Example freetdm.conf settings
[span misdn BRI_1]
trunk_type => BRI_PTMP
b-channel => 0:1,2
d-channel => 0:3
[span misdn PRI_1]
trunk_type => E1
b-channel => hfc-e1.2:1-15,17-31
d-channel => hfc-e1.2:16
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
Doing so will cause a NULL-deref segfault while removing the current span from the
global hash (cur_span->name == NULL) in ftdm_global_destroy().
Remove all the ftdm_safe_free() calls in the custom callback part of ftdm_span_destroy() and
let ftdm_global_destroy() handle that.
NOTE: Also adds a missing ftdm_safe_free(cur_span->dtmf_hangup) to ftdm_global_destroy().
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
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
addressed issue with multiple GRS at the same time in a single span
revisions merged: afcc831d6fa1fccaf7ef091b8c48b905a76d834d 9c815c9ecd7102e7d30c3988cd41682b8cbade0b
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>
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>
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>
ftmod_wanpipe.c:
Remove myerrno variable in wanpipe_read(),
snprintf does not set errno (according to the manpage),
so no need to save it (without even using it later).
Signed-off-by: Stefan Knoblich <s.knoblich@axsentis.de>
ftdm_io.c:
Remove cut_path() function and call since it didn't seem to
do anything useful anyway.
ftmod_analog.c/ftmod_analog_em.c:
Remove status variable that was used for the result of codec_func(),
but was never checked for errors or returned to the caller.
libteletone_generate.c:
Remove unused variable "var".
Signed-off-by: Stefan Knoblich <s.knoblich@axsentis.de>
This fixes the "[ERR] ftmod_libpri.c:128 Don't know how to SABME on a type 0 node" messages
from libpri, when there's no "node"/"mode" parameter set for the span.
NOTE: Now defaulting to CPE mode; EuroISDN on BRI/E1 and 4ESS on J1/T1 lines,
make sure you set dialect/switchtype!
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>