It appears that opening "/dev/dahdi/channel" and using
ioctl(DAHDI_SPECIFY) is possible at least since dahdi 2.4 (from 2010),
and opening "/dev/dahdi/%u" has been deprecated ever since. One
advantage of the new interface is that you can use channel numbers
larger than 250, which is quite easily possible if you have more than
eight E1 lines on a system. It also makes libosmo-abis work on systems
where there are no udev rules for creating the legacy device nodes.
Change-Id: Id6c8f27d7ae948b50e9cf5a38f039d782ff78e1d
When closing a link which failed on open,
ipa_server_link_close() would crash it when calling osmo_fd_unregister.
Change-Id: I672d4de25464c3829b08aff26b1a6d4ad92e7684
The new and improved fsm supports multipe use cases:
1) plain old ipa server/client operation
2) ipa client/server operation with custom send callback (i.e. to bypass
the tx queue)
3) all of the above + custom timeout callback
4) fully generic operation that will pass opaque data to the callbacks
The current code will always kill the fsm and deallocate it upon
timeout, so the timeout callback will now return a value: 1 means the
fsm will be automatically terminated, 0 means no action, which allows
manually stopping/starting the fsm to reuse it.
Change-Id: Ie453fdee8bfd7fc1a3f1ed67ef0331f0abb1d59b
The patch sets TCP_USER_TIMEOUT to the same timeout value,
since keepalive only applies to idle connections, but we obviously want
to fail as fast as possible even if there is data to send and it's not
acked.
Change-Id: I5e7425958472aa5d758e09bfbefc7d7d37bf6f5f
If we receive an OSMO_IPA_KA_E_STOP in INIT state, we are trying to
re-enter INIT, which is not permitted as per the FSM definition.
Adding this permission avoids the below error message from hitting the
logs every time this happens:
<0003> input/ipa_keepalive.c:158 IPA-KEEPALIVE(server)[0x612000000520]{INIT}: transition to state INIT not permitted!
Change-Id: I8db2f2e708fc4fbb81f5019973098a80e8f540d2
We had the allstate_action function registered, and that function
implemented handling of OSMO_IPA_KA_E_STOP. However, the
allstate_event_mask was not set, rendering this functionality
inaccessible.
Change-Id: I83fd991bdacb7bab794878e47c7797fecf8b9286
The IPA keep-alive FSM code takes care of periodically transmitting
and IPA CCM PING and expecting an IPA CCM PONG in return.
Change-Id: I2763da49a74de85046ac07d53592c89973314ca6
The bound RTP socket will wait for incoming RTP packets and as soon as it
sees one, will 'connect' to it, so all replies will go to that sources and
incoming messages from other sources will be discarded. This obviously only
works once.
Change-Id: I5b54ca4296901fcf37794faf29e0b2acca27bd1b
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
In some situations, the user code called by the closed_cb call-back
might be tempted to call itself ipa_server_conn_destroy(), which would lead
to a double-llist_del during osmo_fd_unregister() and also a subsequent
double talloc_free(). Let's prevent such misuse by existing early in
such situations.
Change-Id: I0fef264ed5b4218906cdbca243ffa11b891025c6
* log port from which we accept() the connection in addition to address
* use macro helper for logging
Change-Id: I186974dae1819af8c92f9ea9eeb966ec7c9c9f55
When creating IPA link for server we might be called without explicit
address (which is legit - it means bind to all available
addresses). However in this case we won't have 'addr' field of
ipa_server_link initialized properly.
Fix this by following changes:
* don't copy NULL value as address
* use socket's local IP when no address set explicitly
Change-Id: I33679bb35f426d4cafb223b9200fccbf407e0cf6
Due to apparent copy-paste errors, wrong values were being
logged for IPA tags in ipa_bts_id_resp().
Fixes: 4c57eef663
Change-Id: I29a0401db0760219b9b9176709a88d589312261b
Related: OS#3355
dev->trx_id points to a structure used for whole BTS and doesn't point
to related TRX ID, which is encoded in priv_nr.
Change-Id: I00b01790990c8d21fdbe0f5750fa02f13ddb2009
The unix(7) man page recommends that sun_path is NUL-terminated
when struct sockaddr_un is passed to a bind() or connect() call.
Non-NUL-terminated paths only need to be dealt with at the
receiving end of a UNIX domain socket.
Commit b24efa5 erroneously assumed otherwise.
Change-Id: I9beecfa500db75cb679b1edcc352c893bf098b13
Fixes: b24efa551d
Related: OS#2673
When parsing the configuration, reject a socket path which
exceeds the maximum size supported by the operating system.
In unixsocket_line_update() stop copying the line's socket path to a
local buffer. The path will be copied again in osmo_sock_unix_init().
Both changes are portable; we don't assume any particular socket
path length since the size differs between implementations of Unix,
and we rely only on information from the generic sys/un.h header.
Change-Id: I36344805a825f5d0e0c9d218d438d8fd985ed9ca
Related: OS#2673
As we are closing the socket, there's no need for lower layers to
continue handling it, so let's return -EBADF.
Change-Id: I961b0ef7e598a09ce48a83038c0d90a415e0e11c
Similar to what we do in other osmo_fd cb, check for read_cb returning
-EBADF and in that case don't attempt using the osmo_fd anymore, either
because the fd was already closed (no need to then signal WRITE) or
because osmo_fd struct itself has been freed.
Change-Id: I4b968b72285f23a9552519cea67398a43d5003d2
Similar to what we do in other osmo_fd cb, check for read_cb returning
-EBADF and in that case don't attempt using the osmo_fd anymore, either
because the fd was already closed (no need to then signal WRITE) or
because osmo_fd struct itself has been freed.
Change-Id: I0e449a2bdf7f0411feeccd262cd731ca6fba3fc1
By doing this change we remove a duplicated error code path and thus
avoid having to maintain an extra code path with function pointers.
Change-Id: I5bce9f92209cc2fb37b78792e34f7898c71d2327
By doing this change we remove a duplicated error code path and thus
avoid having to maintain an extra code path with function pointers.
Change-Id: Ic044894980ae2b882d99eb30d9df50066671d8f3
ipaccess_bts_read_cb() only initializes signalling links if it has received an
IPA ID GET message on it, and so far happily accesses the uninitialized
sign_links list anyway if it hasn't.
Reproduce: simply don't send an IPA ID GET message when connecting to an IPA
server run by libosmo-abis, then continue to use the link --> segfault.
Fix the segfault: make sure that the e1inp_ts' type has been set, i.e. that
e1inp_ts_config_sign() has been called and the sign_links llist is initialized,
before calling e1inp_lookup_sign_link() on it.
../../../src/libosmo-abis/src/e1_input.c:511:2: runtime error: member access within null pointer of type 'struct e1inp_sign_link'
../../../src/libosmo-abis/src/e1_input.c:512:11: runtime error: member access within null pointer of type 'struct e1inp_sign_link'
ASAN:SIGSEGV
=================================================================
==5702==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000038 (pc 0x7f28a379ea34 sp 0x7ffd7d8933f0 bp 0x62e000000a98 T0)
#0 0x7f28a379ea33 in e1inp_lookup_sign_link ../../../src/libosmo-abis/src/e1_input.c:512
#1 0x7f28a37b97d4 in ipaccess_bts_read_cb ../../../src/libosmo-abis/src/input/ipaccess.c:778
#2 0x7f28a37b0277 in ipa_client_read ../../../src/libosmo-abis/src/input/ipa.c:76
#3 0x7f28a37b0277 in ipa_client_fd_cb ../../../src/libosmo-abis/src/input/ipa.c:139
#4 0x7f28a2ac1a34 in osmo_fd_disp_fds ../../../src/libosmocore/src/select.c:217
#5 0x7f28a2ac1a34 in osmo_select_main ../../../src/libosmocore/src/select.c:257
#6 0x444ba3 in bts_main ../../../../src/osmo-bts/src/common/main.c:364
#7 0x7f28a17ddb44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b44)
#8 0x405e54 (/usr/local/bin/osmo-bts-trx+0x405e54)
Related: OS#3498
Change-Id: I2487ca37a0fe9aa56733f66bcad9dcf91fc11144
Commit 56ae85fd52 modified code in
ipaccess_rcvmsg to use osmo_fd_setup. During this change, a "|="
operator was converted to "=". Fix this change by manually ORing old and
new values passed to osmo_fd_setup.
Change-Id: Ie59072f07ca50d853c413fa038e447dcdee30a76
We have a public API in libosmocore, so let's use it istead of manually
filling each struct field.
Change-Id: I09479c3d5b0b9bd69a56c080b8c533a32824cc66
In libosmocore Change-ID I1834d90fbcdbfcb05f5b8cfe39bfe9543737ef8f
we have introduced ipa_ccm_id_resp_parse() as a bugfixed replacement
of ipa_ccm_idtag_parse().
The main difference is that the returned "value" parts now have
a correct reported "length", whereas before this commit they all
reported a one-byte too-long "length" for each IE.
Change-Id: Id4c9ff821a43a37cbacce905d44fee43d1b2c879
The '.' is illegal character in counter names, as they are exported
via CTRL interface, where '.' has a special meaning that cannot be
used by strings comprising the variable name.
Change-Id: I730d1acdd5562cd2c1758ceee31193010b14337d
We discovered that enabling the scheduler caused a segfault on the
ARM build of osmo-bts. So we have to revert the following two changes:
Change-Id I3a63c23f5ede47773b6a249a48ecebd5d3b45ace
Change-Id I4b8f0349d5503bbe53745cc8903beb26f149f219
This reverts commit 5a236ce1d4.
Change-Id: Ic81062d79a304038a50658b955f7d05edb3fa28e
Related: OS#3299
We discovered that enabling the scheduler caused a segfault on the
ARM build of osmo-bts. So we have to revert the following two changes:
Change-Id I3a63c23f5ede47773b6a249a48ecebd5d3b45ace
Change-Id I4b8f0349d5503bbe53745cc8903beb26f149f219
This reverts commit 7632278ea3.
Change-Id: Ie375b9eb0dc8ec4f8d4ca12940a7bc5dfc1f6235
Related: OS#3299
we use some functionalities of libortp that require to use rtp sessions
with the scheduled mode enabled. Since we do not enable the scheduled mode,
yet, we receive error messages in the log that complain about a non enabled
scheduled mode.
- Turn on scheduled mode using rtp_session_set_scheduling_mode() when
osmo_rtp_socket_create() is called.
Note: this patch is related to chane:
I3a63c23f5ede47773b6a249a48ecebd5d3b45ace Unfortunately we observed a
segfault with ortp version 0.25.0 (ARM), which seems to be related to an
unintialized scheduling mode. We expect this patch to fix the problem.
Change-Id: I4b8f0349d5503bbe53745cc8903beb26f149f219
Closes: OS#3299
libortp detects an ssrc jump using a packet count thresold. This
threshold is set to 50 by default. This means that libortp has
to see 50 rtp packets with the new SSRC before it accepts the
new stream. In our application we want to detect the changed
SSRC (Handover) as fast as possible. So we should change the
threshold to zero.
- use rtp_session_set_ssrc_changed_threshold() to set a thresold
of 0 packets when osmo_rtp_socket_create() is called.
Change-Id: Id88c2c44d29a409affc2e47fdb932e1187020593
Related: OS#3299
When libortp detects a timestamp jump, we resynchronize the session
in order to restore proper rtp frame reception. However, we do not
resynchronize on an SSRC change. An SSRC change usually indicates
the change of an RTP stream source, which is a much more profound
event than a timestamp change, so we should even reset the session
on SSRC changes.
Also, not resynchronizing the session on an SSRC change causes
problems when the jitter buffer feature is used. In those cases
it takes libortp a long time until it finally detects the timestamp
jump and the session resyhcornization happens late.
- reset the ession on SSRC changes by calling rtp_session_reset()
Change-Id: I8688a55cd20d0e14493c357db80754851e12f2fb
Related OS#3299
the function osmo_rtp_init() is initializing ortp at the start of the
application. However, it does not start the scheduler of ortp, which
leads into error log messages in some situatios.
- make sure that ortp_scheduler_init() is called with osmo_rtp_init()
Change-Id: I3a63c23f5ede47773b6a249a48ecebd5d3b45ace
Related: OS#3299
Ensure that pointers in cloned e1inp_lines point to valid memory.
Some members of struct e1inp_line can simply be deep-copied.
Use talloc reference counting for pointers to objects which may
be shared between clones (driver-private state and counters).
Prevents double-free bugs, e.g. when multiple links referring
to the same line are closed.
Also, do not forget to unlink struct e1inp_line's counter group from
the counter list. Fixes use-after-free in rate_ctr_timer_cb() during
osmo-bts shutdown.
Change-Id: I9f4724b4a5a064801591e9acf4f2fd1db006d082
Related: OS#3011
Related: OS#3137
Those values are not used anymore, since the old bfd is unregistered and
the values for the new one will be overwritten by osmo_fd_register.
Change-Id: I7ac74843cbed920a2fdc6ade7aef4d4de905939a
ipaccess_rcvmsg() disposes of a temporary osmo_fd structure after
the RSL link comes up. It copies data from its temporary osmo_fd
to the new one returned by sign_link_up(). However, in doing so,
it clobbered the 'when' flags, which could differ between the two
osmo_fd structures.
For instance, BSC_FD_WRITE could be set on the new osmo_fd but
not on the old one, in case sign_link_up() has already enqueued
outbound messages using the new osmo_fd.
Because of this behaviour, a patch committed to osmo-bsc to address
issue #2719 did not work as intended and had to be reverted.
After this change, that osmo-bsc patch should work as intended
and issue #2719 can hopefully be resolved.
Change-Id: I52f7c903212b38e9c87e4d45e52b231b6f1ae9f5
Related: OS#2719
This allows the users of libosmotrau to set the content of the SDES
items to something more useful than their compile-time defaults.
Change-Id: Ice794f9e0c6caeea1c67520c12efbfa375d1fb82
Related: OS#2701
vty_install_default() and install_default() will soon be deprecated.
Depends: I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b
Change-Id: I7771131a27d0b7ad0397715ceb3be035062bc010
Make ipa_server_conn_write() a lot simpler and shorter by using msgb_dequeue()
and avoiding local pointer that was used only once.
Change-Id: Id968e60d081a6d69de482a908ca3fe5e1044aaa3
In case the counter group allocation fails, we must handle this
gracefully and fail the allocation of the parent object, too.
Change-Id: Iff8506832d3472ab193b19b43cfbe7a9511075d1
Related: OS#2361
Duration of an RTP frames dictates the timestamp used for the next
frame, not for the one being sent now. It was done like this before to
account for possible losses.
Implementation wise, the duration was understood as "duration
between last frame was sent and now when current one is sent". It makes
more sense to use it as the duration in number of sampling ticks
as described on the function documentation, specially now that we can
account for extra time by means of osmo_rtp_skipped_frame.
Change-Id: Ib8f5fa5509059fe908c09a4381844c613d478548
This API will be used by osmo-bts to maintain the sampling clock of the
RTP socket whenever a frame should be sent but it is not available, for
instance due to low quality of signal.
Change-Id: Id6099372b6231c0a4b6ea0716f46f5daee7049e1
Since ortp commit 5ab29c50adc7948b11449e3aeee66010379ff7dc preceeding
ortp 0.24, the API is fixed and requests a pointer instead of an
unsigned long.
As we now require at least ortp 0.22 since libosmo-abis
15d9b7929d, we need to support both old
and new version of the API to continue having support for 0.22 but still
supporting new versions of the library.
Change-Id: I2dbd0498d75160358eca4336850e1a0ad2efdbeb
Explicitly state that we are using an internal API from ortp, and
define the function we are using to avoid printing a warning.
Change-Id: I9cadcb31ce7ade3632d83753be97fdc9ea518b5b
This reverts commit d517db06ce, which for
some reason broke the IPA client functionality. This needs to be
investigated and properly fixed. But until that happens: revert.
Change-Id: Ic168f437c5bf1fcdb7441b0541c80a4805463004
In Chanage-Id Icbcd8827a75fd5f3393351c1ca372de85275ad35 we introduced a
very similar function to libosocore. Let's use that rather than our own
version here.
Change-Id: I858920db1fb5f5d66e71b676d28c84d330d7904a
Duration passed to osmo_rtp_send_frame_ext function is based
on the last frame and the current one. Duration must then be
added to the timestamp before being transmitted.
Change-Id: I0593d6530c097cca34125a0ae2dd1b019b4dd80d
Commit 0c8d9ddaea8c1afdc0e9b8c37a31c9d158e57efd in ortp broke old API:
function ortp_set_log_level_mask requires one new parameter 'domain'.
This commit fixes compilation in my Archlinux box using ortp 1.0.1.
Change-Id: I46e565f1873c7baf3c3b0aafe73951d20ce083b4
Add pointer address output to the sap alloc/free functions in
order to track the objects later in the debug output (we have three
of them)
Change-Id: I9b961d5e36967cfd953551b24696849541257a1c
N200, which controls the maxium number of LAPD retransmissions,
is set to 300. This will cause a long waiting time until
LAPD detects a failed link. This commit reduces the retransmission
count to 50 in order to get a faster link re-establishment in
case of link failure. This patch will only affect the ericsson
LAPD profile, all other lapd profiles will not be touched.
Change-Id: I4f56f9d00520adc0c0a4497547762cd054030867
alpine linux is using the musl libc and this triggered some minor
compilation issues. Remove unused mISDN include and defines from
the general E1 input handling and address the other warnings and
errors.
/usr/include/sys/fcntl.h:1:2: warning: #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h> [-Wcpp]
#warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h>
^~~~~~~
In file included from input/misdn.c:48:0:
../include/mISDNif.h:286:2: error: unknown type name 'u_int'
u_int id;
^~~~~
Change-Id: I997e45a456faedb5f370fd02ded300c1e36b791b
Remove dup: call function to obtain IPA address only once. Log
explicitly IP address and ports to which IPA is bound or connected.
Change-Id: I841c40abdcba0fdd695a43231391c5d7cee20fae
* check RTP socket parameter and enable necessary jitter buffering
* return the status of requested jitter buffering instead of always
returning 0
* document function parameters and return value
Change-Id: I87d4d9fe990683adbb02b64cb39b78de533d8046
ortp: use extra parameter for network_error callback in log message as
it's described in oRTP documentation (error string).
Change-Id: I581db499d453b80230198d95000f0f6fc20752d1
If osmo_sock_init() would ever return a negative FD together with
errno == EINPROGRESS, we would have attempted to register that negative
FD with the select() main loop handling, whihc of course doesn't work.
EINPROGRESS for a non-blocking connecting socket is handled inside
osmo_sock_init() and would result in it returning a positive FD, so the
above case is of theoretical significance only.
Change-Id: Id01eb0d48eea6cab1fbc720c52361101b8ea4e35
Fixes: Coverity CID 57856
Ericsson's RBS2111-BTS (and similar) implements a lapdm dialect which uses
a link establishment method that differs from the standard. While the BSC
is transmitting sabm frames on one specific timeslot, the BTS will
periodically scan through all timeslots to check for incoming sabm frames.
When the BTS detcts the sabm fames on one of the timeslots it will stay
there and continue to commence the link establishment.
The described procedure requires a slightly modified lapd profile, the t200
retransmission timeout has to be configured to exactly 300 msek. Otherwise
the link establishment will fail. Since the BTS will switch from timeslot
to timeslot most of the sabm frames will not be seen by the BTS, so the
maximum retransmission has to be increased. This patch suggests a maximum
retry count of 300, which is an educated guess and has worked fine during
our tests.
Change-Id: I892af57013d7ab4216e9e2d0873a69129aaeb8e5
Use separate pointer for payload to make sure mblk->b_rptr is not
advanced (which breaks the use of rtp_get_* macros that assume
mblk->b_rptr is pointing to the RTP header, not the payload).
Committed by: Max <msuraev@sysmocom.de>
Change-Id: I205630e1da98693ba0ac25e86e21780284185077
Related: OS#1802
While debugging low-level RTP issues it is handy to be able to match
exact RTP packet with the payload available to higher-level
functions. Having Sequence number and Timestamp RTP fields as parameter
to receiving callback is the easiest way to do so.
Change-Id: I0c9b08d247d7342d6139badca77ce64fda0cf274
This is useful for protocols that use HDLC framing for signalling on E1
timeslots, but which don't use LAPD inside (our E1INP_TS_TYPE_SIGN).
Examples are particularly a MTP2/MTP3 SS7 stack, like it is used on the
A interfaces or on the core network interfaces of classic
circuit-switched networks.
Change-Id: I2d75801df4d7cbb8dad325f4d6689841f0196fa6
In the past, the A-bis E1 input system only unederstood LAPD signalling
time-slots and trau-slots with 16kBps sub-slots. This adds the notion
of a 'raw' transparent 64kBps slot, without any furthe de-multiplexing
nor any HLDC inside.
Change-Id: I0c25c2688eddd0c55c15b280a8c6e8a49629516b
It is quite useful for the signal receiver to know on which of the many
E1/T1 timeslots a given event (like a 'link down' event) has happened.
The line number, TEI and SAPI are isnuficcient in case there are
multiple signalling TS in the line.
Change-Id: I07f0f79e0cda09766f357032ffb4e7ad643d448a
This will prevent the timestamp jump to occur between each call for DTX
if something goes wrong. It's handy as oRTP does not manage well
timestamp jump if it is not resynced.
Fixes: OS#1803
Change-Id: Iae5da832218dbd1ede7a9451102074f2a5eb66df
This reverts commit c77c2a6aa1,
and explicitly sets connected mode to zero for set_remote_addr to work around
internal libortp problems. See https://osmocom.org/issues/1661#note-15.
Related: OS#1661
Change-Id: I9d146c3bd76e02685b09278167b56029152221a0
Require version 0.22.0 which matches Debian stable ATM to simplify
testing and maintenance across all supported BTS models and
corresponding toolchains.
Change-Id: I005d60bb50889edad3e6fc0cd9f7f180aeaf1dab
Fixes: SYS#2569
Previously rs->rtp_bfd.when and rs->rtcp_bfd.when value of BSC_FD_READ
was overridden by 0. Fix it.
Reported by coverity: CID 1357763.
Change-Id: I11940cbf50361c4ea262d7001a16f9a982392f27
Previously RTP receive callback ignored Marker bit from RTP
headers. Extend API to include it explicitly.
Change-Id: I3c2b6365d8a51bf98805614e07344d2639875fde
Related: OS#1750
In libortp, rtp_session_set_connected_mode() sets a flag that is used in
rtp_session_set_remote_addr().
The name rtp_session_set_remote_addr() is misleading: this function actually
does take a lot of action, including an attempt to connect to the remote
server. Thus the "connected mode" flag needs to be set before this.
Suggested-by: NuRan Wireless <nuranwireless.com>
Change-Id: I92308ddffc376af8d4d65e6b9cbeee222b7bff5e
The e1_input code for PCAP writing uses the Layer3 RSL/OML message and
prepends a fake LAPD header. This means that all frames look like UI
frames in wireshark. In case we use in-kernel LAPD of mISDN, this is
the best we can do. However, in case of software (libosmocore) LAPD,
we can do better, by dumping the real LAPD frames at the interface
between LAPD code and the physical layer.
Related: OS#1763
Change-Id: Id0815690b5bc0a9b7f29f5cfde9d2f24c4f88ee5
We want the direction of the packet to be properly reflected in the
pseudo-header, so wireshark can display if the packet is sent in
network->user (BSC->BTS) direction, or in th reverse direction.
Related: OS#1764
Change-Id: I19afca0ce7e8b068bc64fa14bce6feb35aa9f1fc
This way the caller can hand in an already-open file descriptor, rather
than calling osmo_pcap_lapd_open() with a file path name.
Change-Id: Ic7193907a96b0e2284cb6a8a942d2bf0fb95d7e4
Add osmo_rtp_send_frame_ext() which accept boolean parameter in addition
to arguments of osmo_rtp_send_frame() to explicitly set marker bit in
RTP header. Previously it was always unset which resulted in degradation
of speech quality for codecs with explicit talkspurt events (was tested
with AMR's ONSET).
Related: OS#1562
Change-Id: I23e6dccfad5643e662391a0a2abebbb45597ffd9
Reviewed-on: https://gerrit.osmocom.org/82
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Just because the IPA server is requesting certain identities via the CCM
protocol, doesn't mean that the client actually has those fields
available and initialized in struct ipaccess_unit.
Instad of segfaulting the client, let's check if the respective
identities are known. If yes, send them. If not, send the empty string
for that particular identity.
An ipa_server implementation may call ipa_server_conn_ccm for
the CCM processing on the server side of the connection. This
function in turn will call a conn->ccm_cb() function for messages to be
handled by the server implementation, such as the ID_RESP message,
which contains the Unit ID of the client that has just connected.
ortp: according to oRTP documentation rtp_session_set_connected_mode()
uses the address set by rtp_session_set_remote_addr() - move the
function call accordingly.
Fixes: OS#1661
Previously it was possible to send RTP data to port 0. This produce
multiple errors during the beginning of RTP transmission.
To address this OSMO_RTP_F_DISABLED flag was introduced. It's set by
default for all new RTP sessions. It can be manually unset after the
call to osmo_rtp_socket_create(). When the flag is set it prevents
transmission and reception of RTP frames for the session. The flag is
unset automatically in osmo_rtp_socket_connect() when session is bound
to non-zero remote port.
Fixes: OS#1662
Add VTY function to set the ipa bind address:
e1_input
ipa bind A.B.C.D
Add a priv pointer to struct e1inp_driver in order to communicate the bind
address parameter to ipaccess_line_update(). Add two "internal.h" functions to
get/set it in the ipa driver struct.
Add static ip_bind_addr() to use the IP address set from the VTY or, if NULL,
use "0.0.0.0". Apply in ipaccess_line_update().
ortp 0.18 has introduced the jitter_stats but we only check for
0.21 an later. It is okay that at some point the jitter stats
will be reported. For previous versions it is 0.
We might want to know how many things arrived at the BTS and
ortp is already counting for us. We don't intend to use RTCP
so I am not sure what the last "sender report" is and how
accurate the jitter is.
nullbytes has never been used, I assume the code ended up
using memset instead of copying from nullbytes.
Fixes:
subchan_demux.c:47:22: warning: unused variable 'nullbytes' [-Wunused-const-variable]
static const uint8_t nullbytes[SYNC_HDR_BITS];
Jacob noticed that after a re-connect old messages would be
sent. This can be the wanted behavior but add a method that
allows a caller to clear the tx queue. The implementation has
not been verified and there is no existing unit test where
I could easily add this code to.
When the link is being created BSC_FD_WRITE and BSC_FD_READ are
being ored into the flag. When the socket connects the first time
the ipa_client_fd_cb function is called and the link->state is
moved from connecting to connect.
In case the connection drops and ipa_client_conn_open is called
again the BSC_FD_WRITE flag might not be set. This means that after
the socket is connected, ipa_client_fd_cb will not be called. This
means that the updown_cb will not be called until after the first
write or read on the socket. It might even lead to missing some
data.
When re-connecting set the write flag again.
The check was always hit by osmo-bts master leading to the RSL
connection never being made. This is because the type of the line
will be set _after_ the RSL connection has been made. E.g. inside
osmo-bts/src/common/abis.c:
static struct e1inp_sign_link *sign_link_up(void *unit, struct e1inp_line *line,
enum e1inp_sign_type type)
{
struct e1inp_sign_link *sign_link = NULL;
switch (type) {
...
case E1INP_SIGN_RSL:
LOGP(DABIS, LOGL_INFO, "RSL Signalling link up\n");
e1inp_ts_config_sign(&line->ts[E1INP_SIGN_RSL-1], line);
...
Only the call to e1inp_ts_config_sign will set the type to be
E1INP_TS_TYPE_SIGN. Before the call the type is still _NONE and
the connect was rejected.
libosmo-abis/0.3.0+gitrAUTOINC+b6d2834eef-r2.14.0/git/src/input/dahdi.c:25:26: fatal error: ../../config.h: No such file or directory
#include "../../config.h"
In order to support multiple TRX, multiple RSL connections can be
establised. e1inp_ipa_bts_rsl_connect() requires an additional parameter
to set the TRX number.
The ts[] array (member of struct e1inp_line) refers to OML and RSL.
ts[0] refers to OML link, ts[1] to RSL link of first TRX, ts[2] to
RSL link of second TRX (if exists) and so on.
The code was successfully tested with osmobts-trx and UmTRX with two
transceivers.
The user of e1inp_ipa_bts_rsl_connect() (which is osmo-bts) can use
the new function like this (backwards compatibility function provided):
src/common/oml.c
- rc = e1inp_ipa_bts_rsl_connect(oml_link->ts->line, inet_ntoa(in), port);
+ rc = e1inp_ipa_bts_rsl_connect_n(oml_link->ts->line, inet_ntoa(in), port,
+ trx->nr);
libosmo-abis is about forming A-bis interfaces/lines by means
of E1 or the IPA multiplex (or possibly other link layers).
The IPA multiplex is used in other contexts, such as the Control
interface, or the A interface. In that context, it makes sense to have
generic IPA related functions in libosmocore.
In order to make use of the IPAC_PROTO_OSMO stream_id of the IPA
multiplex via the e1_input abstraction layer, we need to define
E1INP_SIGN_OSMO and treat it like other signalling (OML/RSL).
This is required for the upcoming code that uses IPAC_PROTO_OSMO
to remotely insert routing table entries into the OML router (e.g. from
osmo-bts).
The generic functionality of responding to IPA CCM messages doesn't need
to be intertwined with our e1input abstraction. We split this out
as new exported function ipaccess_bts_handle_ccm() and modify
ipaccess_bts_read_cb() to make use of that function.
If the ipa_client_conn is lost and ther user issues a new
ipa_client_conn_open(), then we need to re-set our internal state
to IPA_CLIENT_LINK_STATE_CONNECTING, as otherwise we wouldn't call the
updown_cb() once the link is up again.
Pick a random timestamp when creating the session.
RFC 3550:
The initial value of the timestamp SHOULD be random, as for the
sequence number.
Fixes: SYS#403
The usage of random() is not that unpredictable but the closest
we can get right now.
RFC 3550:
The initial value of the sequence number SHOULD be random
(unpredictable) to make known-plaintext attacks on encryption
more difficult, even if the source itself does not encrypt
according to the method in Section 9.1, because the packets
may flow through a translator that does. Techniques for
choosing unpredictable numbers are discussed in [17].
Fixes: SYS#403
Currently ipa_msg_recv() fails, when messages are received partially.
This patch provides a new function ipa_msg_recv_buffered() that uses
an additional ** to a message buffer to store partial data. When
this happens, -EAGAIN is returned. If NULL is used, the function
behaves similar to ipa_msg_recv() and fails on partial read.
In addition in case of errors the return value is now always -EXXX
and the contents of errno is undefined.
Note that this feature needs support by the calling code insofar that
*tmp_msg must be set to NULL initially and it must be freed and
set to NULL manually when the socket is closed.
Note also that ipa_msg_recv() is then a wrapper around
ipa_msg_recv_buffered() which mimics the old error behaviour by
setting errno explicitely to -rc and returning -1 when an error has
happened.
Ticket: OW#728
Sponsored-by: On-Waves ehf
This patch adds a generic keep alive configuration layer that mainly
consists of additional fields in e1_input structs and VTY commands
and extensions.
Ticket: OW#1060
Sponsored-by: On-Waves ehf
Keep alive has only been used for OML so far.
This patch refactors the socket configuration into an own function
and uses it for RSL, too.
Ticket: OW#1060
Sponsored-by: On-Waves ehf
This was basically a link to configure/ipa which is not cleanly
supported by the current VTY framework.
The test program uses the default implementation for
go_parent_cb/vty_go_parent() and is_config_node, since config-ipa is
a top level config node which is assumed by default.
This patch removes the local 'end' and 'exit' implementations and
uses the generic ones provided by libosmocore instead, which are
enabled automatically when vty_install_default() is used.
The second check used the cached result for ORTP. Store the result
in ORTP_VERSION and my system properly detects that it is running
on < 0.21.
The HAVE_ORTP_021 will always be defined so just use #if and not
the #ifdef to fix the build.
in order to keep the message ordering right, we first send the
ID_ACK/ID_RESP messages, before handing sign_link_up() into the
application. This ensures that no OML messages get transmitted before
the ID_ACK/ID_RESP has been completed
When an IPA link is in client (BTS) mode, we should not automatically
re-connect in the lowest (ipa) layer. Instead, we properly close the
socket if the link is dead, and we call link->updown_cb() to notify
the user that the link is down.
The e1inp/ipaccess layer translates this into a line->sign_link_down()
callback that propagates up to the user.
This would create linked list coruption in osmo_fd_unregister().
The fact that multiple calls of osmo_fd_unrgeister() on the same fd
happen is due to the fact that ipaccess_drop() and others already close
the file descriptor.
If a write on an IPA file descriptor fails, then we call
ipaccess_drop(). However, only in the BSC side the assumption that
bfd->data == e1inp_line holds true. On the BTS side, ofd->data
references to the ipa_client_conn structure. In order to avoid the
problem, call ipaccess_drop() with an explicit reference to the line in
which the link was dropped.
If we have a BTS-side e1inp_line, we can only establish OML at the
time of line_update. We have to wait with RSL until the BTS explicitly
tells us the RSL destination IP and port (received via OML from BSC).
This is now handled in a new function called
e1inp_ipa_bts_rsl_connect().
input/ipa.c: In function 'ipa_server_link_create':
input/ipa.c:344:2: warning: implicit declaration of function 'osmo_generate_backtrace' [-Wimplicit-function-declaration]
input/ipaccess.c: In function 'ipaccess_bts_cb':
input/ipaccess.c:873:2: warning: implicit declaration of function 'osmo_generate_backtrace' [-Wimplicit-function-declaration]
Add assertion as suggested by Holger. This function does not make
much sense with the accept callback set. While at it, check return
value of the accept callback and release the peer socket in case
such callback returns an error.
Reported by Holger.
Reference: CID 1040692
e1_input.c: In function 'e1inp_tx_ts':
e1_input.c:620:6: warning: variable 'len' set but not used [-Wunused-but-set-variable]
Fix it by performing a stricter checking on the muxed bits
before transmission. Let's see if this spots some hidden bug
in this code.
The line->port_nr is compared to the array size of the span config
and then the array can be potentially accessed one element outside
of the array.
Fixes: Coverity 1042368
CC e1_input.lo
e1_input.c: In function 'e1_set_pcap_fd':
e1_input.c:143:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
e1_set_pcap_fd returns now the result of write. OpenBSC is still
assuming that this function returns nothing, so it simply ignores
this return value by now.
In theory argc could be negative and this code would crash with
a null pointer dereference on the line pointer. Check for <= to
avoid this warning.
Fixes: Coverity CID 1040699
We want to store stream ids 0 to 0xff. This means we need to have
256 entries in this array.
Fixes: Coverity CID 1040697, CID 1040696, CID 1040695, CID 1040694
Warning:
input/misdn.c:252:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is
true [-Wsometimes-uninitialized]
if (mline->use_userspace_lapd) {
^~~~~~~~~~~~~~~~~~~~~~~~~
input/misdn.c:289:9: note: uninitialized use occurs here
return ret;
^~~
input/misdn.c:252:2: note: remove the 'if' if its condition is always false
if (mline->use_userspace_lapd) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input/misdn.c:241:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
1 warning generated.
This was spotted by clang3.3 and got broken in git revision
f42280b6a2 when moving to the
C99 initializer.
Warning:
input/lapd.c:106:30: warning: initializer overrides prior initialization of this subobject
[-Winitializer-overrides]
.t203_sec = 20, .t203_sec = 0,
^
input/lapd.c:106:14: note: previous initialization is here
.t203_sec = 20, .t203_sec = 0,
^~
1 warning generated.
If we bind a local socket to INADDR_ANY, then getsockname() will always
return 0.0.0.0 for the local IP address _unless_ the socket was
previously connected to a specific remote IP/port using connect().
This will have the side effect that we only accept RTP packets from the
one IP/port that we have connect()ed to, but that is actually
intentional and useful in our applications.
This patch relaxes the behaviour on error coming from the signalling
layer. This is probably too strict for recoverable errors.
Don't release msgb in this case, as this is controled by the signaling link
layer.
Thanks to Lennart Müller <mueller.lennart@googlemail.com> for the report.
There is no interworking function (IWF) here. The contents of an uplink
frame simply gets copied into a downlink frame. For this to work both
sides of the call need to connect with the same speed and parameters.
The sync header consists of 16 zero-bits followed by 1 one-bit. Before,
subchan_demux only tested for the 16 zero-bits. But if the previous
frame ended in one or more zero-bits these were then already counted as
belonging to the sync header, leading to a frame that was shifted by one
or more bits.
This patch allows you to create PCAP traces between the BSC and BTS including
the LAPD frames. Useful for debugging communication issues.
So far, it was only possible to create layer 3 traces containing
OML/RSL. LAPD traces can be also interesting to debug communication
issues between the BSC and the BTS.
To enable PCAP of LAPD, you only have to invoke:
li->pcap_fd = osmo_pcap_lapd_open("/tmp/file.pcap", 0600);
By default, li->pcap_fd is set to -1 which means disabled.
openBSC needs a patch to replace all usage of e1_set_pcap_fd by
osmo_pcap_lapd_open.
If we hit any error, spot an error message containing the reason
and close the links to start over.
This patch has been tested by injecting errors in:
* ipaccess_send, by randomly returning -1.
* returning error from the ->sign_link_up callback, both from the
OML and RSL links.
* returning error from the ->sign_link callback, both for the
OML and RSL links.
With this patch, Valgrind shows no "definitely lost" memory blocks
anymore (including the error path that has been tested) and the
ipaccess driver behaves more robustly in case of errors.
Acked-by: Holger Freyther <holger@freyther.de>
Holger reported a leak in the ipaccess_drop path and a patch to
fix this. This is a new version of the patch posted that also
handle the case in which only one of the link (OML / RSL) is
established and no ID_RESP was received.
Based on patch of Holger Freyther.
This spares us another recursion, and allows a much higher
parallelisation, since trau is only one source unit and one standalone
library.
Incidentally, also make sure that the version specification for
libosmoabis is applied.
Signed-off-by: Diego Elio Pettenò <flameeyes@flameeyes.eu>
automake is well capable of building sources present in sub-directory
without requiring a recursion, so there is no reason to use a
non-installed library just for the extra files.
Signed-off-by: Diego Elio Pettenò <flameeyes@flameeyes.eu>
Also contextually remove the AC_PROG_LIBTOOL call (which is an
obsolete name for what is now LT_INIT).
Signed-off-by: Diego Elio Pettenò <flameeyes@flameeyes.eu>
When many applications write to the stdout it is not clear that
'network_error' comes from osmo-bts due the usage of oRTP. At least
provide a hint that oRTP is involved.
* HSL/IPA had different socket closing code for the same thing,
create one method for it.
* Both methods tried to send an event but as we are on the close
path the sign_link was already removed from the list and the
input event sending method couldn't find the sign_link using the
sapi/tei provided.
We used to write as many messages as we received from mISDN for
b-channels. Now we write as many _bytes_ as we have received, which
seems to be the more logical thing to do.