Add option to flush zrtp cache to persistent storage automatically
immediately after the cache is modified. See
zrtp_config_t#cache_auto_store.
Modified-by: Travis Cross <tc@traviscross.com>
Signed-off-by: Travis Cross <tc@traviscross.com>
libzrtp was forcing a new SAS rendering even when SasRelay
sashash was zero.
Modified-by: Travis Cross <tc@traviscross.com>
Signed-off-by: Travis Cross <tc@traviscross.com>
Remove some old tests and implement a few test-cases to emulate zrtp
enrollment and sasrelay logic
Modified-by: Travis Cross <tc@traviscross.com>
Signed-off-by: Travis Cross <tc@traviscross.com>
Move all the GNU build files to the root directory so that we look
like a normal *NIX-centric project.
Thanks to Viktor Krikrun for an initial patch here. For this commit,
I ended up redoing the move from scratch to separate out this move
from other changes.
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>
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>
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>
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>
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
Various modules which lacked routines to get at the sub-structures now
have them.
The tests have been tweaked so they only access internals where essential.
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
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
get an EOP, we no longer worry whether the final stages tidy up. This helps
tolerate the increasing number of VoIP calls which hang up before the audio has
flushed down the line.
A few little cleanups.
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>
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>
"Safer" version of ftdm_clamp(), that swaps min/max parameters if
vmin happens to be larger than vmax, making sure the output will
always satisfy vmin <= x <= vmax.
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
The default remains the same: we show the huge ClueCon nag banner on
startup and in fs_cli.
However, if you pass --disable-huge-cluecon-nag, no banner will be
shown.
If you pass --enable-modest-cluecon-nag, a modest text-based ClueCon
reminder will be shown instead.
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>
FTDM_SIGEVENT_UP was falling through to FTDM_SIGEVENT_PROGRESS_MEDIA, which
does (almost) the same, so no harm, but still fix it.
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
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>
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>
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>
AC_PROG_LIBTOOL
m4_include(m4/acinclude.m4)
Adding these and taking out all the Makefile.in files from the tiff-4.0.2
directory seems to sort out the build issues.
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>
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>
Enhancements to trace logging, include threads and context ID.
Changed default opal_conf.xml to allow more than just G.711 uLaw and not to clutter log file with debug logs.
Added to opal_conf.xml item for "disable-transcoding".
Updated build/buildopal.sh to use correct ./configure items for PTLib, allow for something other than standard install directory for PTLib/OPAL and be able to easily bind to a specific release of PTLib/OPAL.
Callbacks are invoked from ftdm_span_start/_stop().
I/O is started before SIG and shut down in reverse order.
This is needed for ftmod_misdn, to move the mISDN message handling
into a separate thread (solving the mISDN socket vs. FreeTDM API issues).
With these callbacks, the I/O thread can be started after the span I/O configuration
has been (successfully) completed and stopped before destroying the span.
NOTE: Both SIG and I/O callbacks are called with the span mutex locked,
so threads created or destroyed synchronously in either of the custom
start/stop functions, can not use ftdm_span_*() functions that lock
the span mutex (e.g. ftdm_span_get_channel_count()).
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
The --enable-builtin-tiff option appends libs/tiff-3.8.2/libtiff/libtiff.la
to LIBS, causing the AC_CHECK_LIB([jpeg]...) check to fail, because
libtiff.la does not exist at configure time.
Temporarily store tiff and jpeg libs in TIFF_-/JPEG_LIBS variables and
append them to LIBS after all library checks have run.
Example error output:
configure:20049: checking for jpeg_start_compress in -ljpeg
configure:20074: cc -o conftest -O2 -pipe -fno-strict-aliasing -L/usr/local/lib conftest.c -ljpeg -lm /usr/home/ports/net/freeswitch-core-devel/work/freeswitch-1.2.1/libs/tiff-3.8.2/libtiff/libtiff.la >&5
cc: /usr/home/ports/net/freeswitch-core-devel/work/freeswitch-1.2.1/libs/tiff-3.8.2/libtiff/libtiff.la: No such file or directory
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
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>
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>
. 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
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>
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>
Store the offset in the teletone buffer in the b-channel private data.
An NT-mode setup with ftmod_misdn showed severe (dial-)tone distortions
in a sound editor (330Hz sine wave phase errors), caused by
using a global teletone buffer offset.
Switching to a per-channel offset, that is advanced by the amount
of data actually written to the channel, removes (almost) all
distortions.
There is still a minimal phase error every ~500ms (audible) that
needs more investigating.
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
Might as well import these too...
ftdm_offset_of() - Get offset of member in structure.
ftdm_container_of() - Get pointer to enclosing structure from pointer to structure member.
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
ftdm_min(x,y) - Returns the smaller of the two values x and y.
ftdm_max(x,y) - Returns the larger of the two values x and y.
ftdm_clamp(val, min, max) - Returns value that is in the range [vmin,vmax].
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
Remove the 'state' variable of per-channel data, use active flag exclusively to track
open/close state.
Add misdn_activate_channel()/misdn_deactivate_channel() helper functions, rename old
one to _misdn_toggle_channel() (internal).
Add _nowait variant of channel de-/activation function, that just sends the mISDN request message.
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
Store call CRV in caller_data.call_reference and use call private to hold the
FreeTDM channel object.
Remove isdn_data->channels_{local,remote,outbound}_crv arrays.
Allow (and force) inbound call state transition DIALTONE -> DOWN for
incoming RELEASE COMPLETE messages in NT mode.
Dialtone in NT mode works, everything else needs more testing.
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
ftmod_misdn currently returns len == 0 if the incoming message,
that triggered the read() call, does not contain any data.
Users of ftdm_channel_read() need to handle this case, or they
may possibly end up in an endless loop.
This patch reworks the ftdm_channel_read() handling in ftmod_isdn
and prevents it from entering an endless loop. The read error counter
is reset on first sucessful read w/ data.
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
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>
Fixes:
cp ESL.so /var/tmp/por.../image/usr/lib64/php5.3/lib/extensions/no-debug-zts-20090626
cp: cannot create regular file `/var/tmp/por.../image/usr/lib64/php5.3/lib/extensions/no-debug-zts-20090626': No such file or directory
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
Two fixes:
Use ftdm_set_string() instead of sprintf() (seriously, wtf?).
Drop invalid, needless argument to ftdm_log().
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
Neither of them accepts extra arguments and ftmod_sangoma_isdn is calling
ftmod_assert() with a char * msg argument.
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
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>
Output the current trunk_type in "add X-channel vs. trunk_type" error messages and
check this for B-/D-channels too.
ISDN (= digital) spans need to have a trunk_type set before adding channels,
bail out early with an error message (actually two) if this is not the case.
(Adding channels should really be moved out of the parsing loop, to catch
certain types of errors easier.)
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
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>
Portability fix for uClibc and other (linux) environments that lack execinfo.h.
ftdm_backtrace_walk() and related return FTDM_NOTIMPL and print a message
if backtraces are not available in the current environment.
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
Indicator in IAM message.
- ss7_iam_nature_connection_hex is the channel variable to carry
HEX value from/to IAM message
- X-FreeTDM-IAM-NATURE-CONN-HEX is the x-header string to carry
HEX value from/to sip invite message
- This IE is 8 bit hex, which turns into 2 chars
- Only Satellite indicator, Continuity check indicator, and Echo
control device indicator are supported. Spare value are not taken.
Spare value is always set to all zero.
- example:
To set 00010101 (bit H-A), set X-FreeTDM-IAM-NATURE-CONN-HEX string
value to 15 in the sip invite message to NSG.
When NSG send out sip invite, if the incoming IAM message comes with
Nature of Connection IE, NSG will put X-FreeTDM-IAM-NATURE-CONN-HEX
in the invite x-header. For example, if the IE value is 00001010 in
the IAM, NSG will send X-FreeTDM-IAM-NATURE-CONN-HEX with value string
of "0A".
- Two characters are madatory. "0A" must be specified rather than "A". If
invalid format or characters are found, this x-header will be ommited.
- Valid characters include 0-9, A-F, and a-f
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>
readfile returns a value of type ssize_t (signed) and returns -1 if an
error occurs. In auth_readdb_internal, however, we were assigning the
return value of readfile to a variable of type size_t (unsigned), but
then testing this unsigned value to see if it was < 0, a
contradiction. We would thus simultaneously fail to report the error
in readfile and would end up with a corrupted length value.
sres_cached_answers_sockaddr is supposed to return ENOENT if no cached
records are found. Because of the missing return statement, however,
it would never do this and would instead return something very likely
to be garbage.
base64_d returns a value of size_t, which is unsigned. The value
therefore cannot be less than zero. The second check testing whether
it is >= INT_MAX is not a contradiction, but it doesn't make any sense
to check for this (as far as I can tell).