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>
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).
Converting these macros to functions declared static inline allow the
C type-checker to work and avoid warnings about unused expression
values. These warnings break the build with clang.
This avoid warnings about expressions with unused values. These
warnings break the build with clang.
An optimizing compiler should still inline these calls. If that turns
out not to happen on some platform, we could rename the functions used
internally and declare them static inline.
The implementation clears the context / state data from memory when it
is finished with it. Prior to this commit, however, it was actually
only clearing the first 4 bytes on x86 or 8 bytes on x86_64.
clang warns:
warning: argument to 'sizeof' in 'memset' call is the same
expression as the destination; did you mean to dereference it?
[-Wsizeof-pointer-memaccess]
In a sofia profile, you can now set the parameter tls-timeout to a
positive integer value which represents the maximum time in seconds
that OpenSSL will keep a TLS session (and its ephemeral keys) alive.
This value is passed to OpenSSL's SSL_CTX_set_timeout(3).
OpenSSL's default value is 300 seconds, but the relevant standard
(RFC 2246) suggests that much longer session lifetimes are
acceptable (it recommends values less than 24 hours).
Longer values can be useful for extending battery life on mobile
devices.
Signed-off-by: Travis Cross <tc@traviscross.com>
* fixed bug with remote hello-hash buffer being too small
* removed unused hello-hash storage in zrtp stream context
* fixed bug with libzrtp rendered "empty" SAS hash from incoming
SasRelay packet
* incremented libzrtp version number to 1.15
Signed-off-by: Travis Cross <tc@traviscross.com>
It appears that libzrtp would prevent a non-passive client from
enrolling with a PBX because of a broken license mode comparison.
Thanks to Ivo Kutts for the report.
FS-4223 --resolve
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>
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>
Timer-based b-channel tx gating won't work anyway, so remove all those
"#if 0"-ed bits of cruft.
Also remove the mISDN-specific timerfd_create() check in configure.
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
Re-bootstrapping is needed after this change. Previously CentOS 5
systems wouldn't build correctly without this file in tree, but we've
adjusted bootstrap to compensate.
Thanks to Phil Zimmermann for the code and for the license exception
we needed to include it.
There remains some build system integration work to be done before
this code will build properly in the FreeSWITCH tree.
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>
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>
FS-3815 --resolve
This is a workaround for the fact that libedit counts terminal control
characters when calculating the length of the prompt. By not using
absolute positioning, we avoid the issue.
Thanks to Ivan Isaev for the workaround and testing.
cc1: warnings being treated as errors
libs/esl/src/esl.c: In function "esl_recv_event":
libs/esl/src/esl.c:1190: error: array subscript is above array bounds
libs/esl/src/esl.c:1227: error: array subscript is above array bounds
Clamp handle_recv() return value to safe values.
Signed-off-by: Stefan Knoblich <stkn@openisdn.net>