Commit Graph

462 Commits

Author SHA1 Message Date
Harald Welte f776669df2 input/e1d: Fix support for TRAU slots
Change-Id: I2d7f85523089f4e1f2496d9836bced577eda4671
2020-08-02 11:29:46 +02:00
Harald Welte 182957bf69 dahdi: Use osmo_revbytebits_buf() instead of local flip table
We've had osmo_revbytebits_buf() in libosmocore for ages.  As it
recently turned out, the flip_bits[] lookup table approach implemented
here is faster at least on x86 systems of the last decade or so.

As of Change-Id I25029fe7e54c92979fb0119992fb8dc167e1536e in
libosmocore, it has been migrated to the lookup table approach. This
means there's no performance penalty of migrating to using it, and
hence no reason whatsoever to have a private implementation here.

Change-Id: I285a87a9fc6abae7d8b47923a46cd082f46829f8
2020-08-02 11:25:23 +02:00
Harald Welte ac290eec96 e1d: Fix compilation after I4a088f91f23aaad05c5ab84a4783c1915d85aca6
This slipped through the cracks as jenkins so far doesn't build with
--enable-e1d support (fixed in a separate patch).

Change-Id: I505331a4a9430001b049e9f5cc36abf4ce4ca19e
2020-08-02 10:48:50 +02:00
Pau Espin deb5c4f7ab ipaccess: Fix use-after-free in ipaccess_drop()
Recent commit b8ea0ff521 introduced a
heap-use-after-free while getting rid of memleaks and clearing up the
reference counting lifecycle of the line object.

In that commit, e1inp_line_put2() was added in ipaccess_drop() which may
potentially free the line object (and its children e1inp_ts objects)
under specific conditions/scenarions. However, the function still used
the child object e1i_ts which in those scenarios would access already
freed memory.

Let's keep a local reference during the life of the function to make
sure the object is non-freed during e1inp_line_put2(), so that we can
notify upper layers that the link is down.

Detected by enabling ASan and running BSC_Tests.TC_chopped_ipa_ping
TTCN3 test.

Related: OS#4688
Change-Id: I4f56af28ad8297846bcdc8ba7afe51fff0f9a00f
2020-07-31 13:03:43 +02:00
Harald Welte 8fc8ceff16 e1d: Add new osmo_e1dp_client_ts_open() argument
An additional argument was added to specify the timeslot read
buffer size.

Change-Id: I4a088f91f23aaad05c5ab84a4783c1915d85aca6
Depends: osmo-e1d I6d603778cce14c5d72fe5f54904905ea7e66d7ff
2020-07-22 09:48:59 +02:00
Pau Espin ffc92d5b23 lapd: Use lapd_dl_init2 instead of deprecated lapd_dl_init
Change-Id: If25957d10bf9e32d2fe601111a9c1311aee21094
2020-07-15 15:42:19 +02:00
Pau Espin 6ffeb9af89 cosmetic: lapd: Fix trailing whitespace
Change-Id: I7a6af2f417f6f924a3f27cfa12462158f2c2a1c6
2020-07-15 15:39:33 +02:00
Pau Espin 8a4e3d91f8 ipaccess_recvmsg: Untangle code updating line
This patch untangles the code a bit by changing the order where actions
are taken and variables are assigned.

The only real changes in behavour are the introduced assert, and that
bfd->data is set to NULL before releasing the related line.

Related: OS#4624
Change-Id: I947f64f8fa20f87fdc84538402623a6bcf35fdf9
2020-07-15 15:39:33 +02:00
Pau Espin 815117c246 ipaccess_recvmsg: Assert the new bfd from new line differs from the old one
Related: OS#4624
Change-Id: I45818e04af0da7b1109d909642a1ea378a85a636
2020-07-15 15:39:33 +02:00
Pau Espin dc55a5fa63 ipaccess_recvmsg: Clean up release steps upon error condition
Related: OS#4624
Change-Id: I47a3e477d6861620a741193d3d3d3e286836fd44
2020-07-15 15:39:33 +02:00
Pau Espin a2ff733ac0 ipaccess: Set bfd->data to NULL before releasing its reference
Since the reference is dropped, make sure no one accesses it through
that pointer anymore. It must be done before calling the put() method,
otherwise it may already be released when put() returns.

Change-Id: Ic3f261b2a995efcbc8eece9669ee3ae63af7b5c0
2020-07-15 15:39:33 +02:00
Pau Espin 8737ad4f75 ipacces: Fix e1inp_line reference put in ipaccess_close
Drop the function e1inp_close_socket since it's only used by the caller
at hand, and it's only exported through "internal.h", so no app is using
it. Remove it because there's only a caller, and furthermore because
keeping it (and putting bfd->data==line) would introduce a layer
violation because the bfd->data==line is only used for ipaccess so far.

Triggering path:
handle_ts1_read ret=0 "Sign link vanished"
  ipaccess_drop
line->ops->sign_link_down
  (osmo-bsc) ipaccess_drop_oml
e1inp_sign_link_destroy
  link->ts->line->driver->close
ipaccess_close

Related: OS#4624
Change-Id: If23cc722106a9f70c998e591369a4acafa52c519
2020-07-15 15:39:33 +02:00
Pau Espin b8ea0ff521 ipaccess: Drop e1inp_line reference in ipacess_drop()
the bfd->data handles a reference to the e1np_line (obtained through
e1inp_line_get() during bfd setup), so remember to drop it under this
condition.

Related: OS#4624
Change-Id: I418064df04872befe2e936e21768b6ea01263120
2020-07-15 15:39:33 +02:00
Pau Espin 5196cd5641 e1_input: Use osmo_use_count in e1inp_line
osmo_use_count is available since libosmocore 1.1.0 release, so bump
required libosmocore version in autotools and packages.

struct e1inp_line field refcnt is kept in order to keep ABI
compatibility accessing struct fields. The new use_count is added at the
end. Size of struct changing is fine since it is allocated through
an API and a pointer should be used by clients.

e1inp_line_clone API is changed but it's not used by anyone outside
libosmo-abis, so it's fine.

Related: OS#4624
Change-Id: I0658b2e9c452598025cc0f1d0b060076171767cc
2020-07-15 15:39:33 +02:00
Pau Espin 30e80d555c ipaccess: Fix log formatting of RESP_ID IPA attributes
Change-Id: Id5b4c39737a43c9ba68f3aacc889c10eba697920
2020-07-14 13:23:08 +02:00
Pau Espin 4ffd2a9c9b ipaccess.c: Drop repeated ipaccess_keepalive_fsm_cleanup in write error path
The function is already being called by ipaccess_drop().

Change-Id: I00d0557fe81861d4b913a4c76e4b56f93e656103
2020-07-14 12:18:24 +02:00
Harald Welte bcfd7ea184 subchan_demux: Fix out-of-bounds write
We cannot blindly append two ubits to the 320-ubit sized buffer.  In the
end, we may already fill the buffer after the first ubit, causing a
buffer overflow with the second ubit.

Lets check if the buffer is full after every bit.  Avoid copy+pasting
but move the code repeated per bit to a new function.

Change-Id: I58d946265372278051e4f29301d4f201ab98c0fc
Closes: OS#4648
2020-07-04 11:21:23 +02:00
Harald Welte 96034fcced input/dahdi.c: Don't simply read beyond end of msgb
Let's first add two bytes to the msgb before writing.  This way we
would assert in case there was no tailroom.  As we just added tailroom
in the previous patch of this series, we are fine

Change-Id: If84b31ea9a3fc7a6c8768918efed2822d1d58427
Closes: OS#4644
2020-07-03 19:26:16 +02:00
Harald Welte 47c247b940 input/lapd.c: Enlarge message buffers for DL-SAP primitives
The DL-SAP primitive msgbs are currently allocated
to only have headroom but no tailroom.  Let's change that

Change-Id: Ia476c8a2f70e6579be53230427923885a573f801
Related: OS#4644
2020-07-03 19:08:42 +02:00
Harald Welte ea7da44bdd lapd: Replace magic numbers with #defines
Related: OS#4644
Change-Id: I2971fb5bb27a7024abac7e2a4414eaf61f27ccb5
2020-07-03 19:08:37 +02:00
Harald Welte 36166d0a8d fix compilation with --enable-e1d
In Commit Ib81a749ae24013b17caaf5fd64ccd9acbbc3ce08 we introduced
a syntax error leading to compile failure sfor --enable-e1d ever since.

This hsan't been discovered as osmo-e1d support is not built
automatically anywhere.

Change-Id: If1f4bd9469a614470045716df4c35187ff2cc76b
2020-07-01 09:54:30 +02:00
Pau Espin 89c6b8a42e e1_input: refcount inc line during e1_sign_link_create, not during line update
Increase reference count when a new sign_link using the line is created.
Otherwise the line is freed too quickly during e1inp_sign_link_destroy()
with several TRX being used, since each RSL link is missing a reference.

That extra refcoutny in update() is not really needed given that we already
have a link assigned on the line when we call update.

Fixes: OS#3612
Fixes: OS#4094

Change-Id: I74405b0e87a89c17d58e87024f4aedbd30832013
2020-06-09 07:36:21 +00:00
Harald Welte b90318808b lapd: Always print context information when logging
Historically, OpenBSC has primarily been used with setups that have
a single E1 based BTS connected. This meant that an error message on
the E1 LAPD implicitly has to be related to that single BTS.

However, in more comprehensive setups, there may be many BTSs on many
E1 lines with many signaling slots.  At this point, it's important to
know which line/timeslot/tei/sapi a given log message relates to.

This patch introduces related log context.

Change-Id: Ib81a749ae24013b17caaf5fd64ccd9acbbc3ce08
Requires: libosmocore.git Change-Id Ie6742843fff809edffcac24c4dce4edf66bc71be
Related: OS#1938
2020-06-09 07:11:42 +00:00
Oliver Smith 62725d0b58 src/input/ipaccess.c: set TCP_NODELAY
Set TCP_NODELAY for all RSL/OML sockets.

Related: SYS#4906
Change-Id: Ia3d4c41bf0659e682f0b7ae5f3d58ed0f28edb58
2020-05-28 09:56:38 +00:00
Harald Welte db1bc21d73 trau_frame: Fix AMR frame decoding
Change-Id: I9b2dbca05217ee78cade2a47a02857f7cf7e0cd7
2020-05-14 15:48:09 +00:00
Harald Welte a684b84f11 subchan_demux: Use ubit_t where appropriate
the subchan_demux code predates ubit_t; let's use it to clarify
certain pointers refer to arrays of unpacked bits.

Change-Id: I944f05473954920d57e12d5514cf928fc78f2ea4
2020-05-11 08:40:01 +02:00
Harald Welte 6913b9a4e4 trau_frame: use 'ubit_t' for unpacked bits
Change-Id: I497dbb7e9e199c6276e585b977bd941a2b442b3b
2020-05-11 08:40:01 +02:00
Harald Welte 5226e5b926 subchan_demux: Use 'ubit_t' for unpacked bit buffer; use const
Change-Id: Ia082b9fddf03d02afd007825a1588a3ef0dbedae
2020-05-10 19:11:44 +02:00
Sylvain Munaut eb55e2f8d9 e1_input: Add VTY command to enable PCAP debug output
This command is also usable at run-time to dynamically
enable / disable e1 tracing on all active lines

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I0b4251702aecd6721b9d63c320351ef6cb513454
2020-05-09 10:45:20 +02:00
Sylvain Munaut 4b45e9d1a6 e1_input: Allow to change the pcap fd and/or unset it
This will update the pcap fd in all open lines and close
the previous one (if applicable).

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I5c7dd740ba0a90b40c69a53b3dcc9d6d6a98f660
2020-05-08 18:10:15 +02:00
Harald Welte 54c919ec48 ortp: disable SO_REUSEADDR + SO_REUSEPORT
ortp >= 0.24.0 doesn't differentiate between SO_REUSEADDR and
SO_REUSEPORT, and has both enabled by default.  The latter means that
we can end up with non-unique port bindings as we will not fail to
bind the same port twice.

This should have caused visible problems not only when operating multiple
osmo-bts on one machine (rare), but also with a single osmo-bts. Once the range
(default 16384-17407 ) wraps, there is a risk of new sockets (for new cals)
colliding with old ones. As two ports (RTP+RTCP) are used per call, this means
every 512 voice calls we expect the BTS to wrap. And from that point onwards
there's a risk of overlapping with previously allocated sockets.

Change-Id: I4fc9eee561c7958c70c63b4ffdc6cb700b795e28
Closes: OS#4444
2020-03-09 11:24:45 +01:00
Oliver Smith 3c51482e3d osmo_ortp: add osmo_rtp_socket_set_dscp()
Related: OS#4438
Change-Id: I41603db8c1286660ad57ac1c78a8fb393a2b080b
2020-03-07 15:07:27 +01:00
Eric Wild ef1f327c96 add ipa ping/pong keepalive for OML/RSL links between bts and bsc
Patch-by: ewild, osmith
Related: OS#4070
Change-Id: I30e3bd601e55355aaf738ee2f2c44c1ec2c46c6a
Depends: (libosmo-abis) Ie453fdee8bfd7fc1a3f1ed67ef0331f0abb1d59b
2020-01-24 14:35:09 +01:00
Oliver Smith 65ae42c62c ipaccess.c: line_already_initialized: int -> bool
Change-Id: I1cff638664029ef1a592b98cd499e1d8b703ada1
2020-01-22 11:24:52 +01:00
Harald Welte eed3916dee e1d: Implement varions non-LAPD timeslot modes
So far, the e1d input driver only contained code for LAPD signaling
slots, let's extend it with support for all the other slot types, as
well as support for run-time re-configuration.

Change-Id: I53369004145681bf9178543fe407dfc75e4ae63a
2020-01-12 15:30:51 +01:00
Harald Welte accd677414 e1d: Don't connect to e1d at program start time
Let's not print an error at program/library start time if osmo-e1d
cannot be reached.  This error is confusing to everyone who may
have a libosmo-abis with e1d support compiled in, but who is not
(currently) using any lines via this driver, but others drivers.

Change-Id: If0d033f8a2ab4f0e72549a811ffccc66b91fb0a8
2020-01-12 14:24:24 +01:00
Harald Welte 28898d1fa7 e1d: Use LOGPIL/LOGPITS logging macros to give context
Change-Id: I88ba83783ae1d8368990ec30cdc7ecff88884e41
2020-01-12 14:24:24 +01:00
Harald Welte ccf84ea3dd e1d: Use line->port_nr to specify e1d interface/line
This way we can support more than one E1 line via osmo-e1d.  As
neither mISDN nor DAHDI distinguish between mutliple cards of single
ports vs. multi-port cards, we havee to map both interface + line number
into a single uint8_t.

Change-Id: I3b6975624a0155a68d2c67bfdbc1fb751fb50b13
2020-01-12 14:24:24 +01:00
Harald Welte 52e14129f2 e1d: Remove bogus vty_show function.
It's optional for an input driver to provide this function, and e.g.
mISDN doesn't provide it, either.

Change-Id: I56ed4244121f2019ece80d15bd07d5a8ce958273
2020-01-12 14:24:24 +01:00
Harald Welte 6f674dea42 e1d: Remove EXCEPTFD handling
The file decscriptor 'except' handling was only added in the DAHDI
input module as the DAHDI kernel side is actually using those. I
don't think we can even use this in any way over unix domain sockets.

Change-Id: I718629179181a1de3b82e23447549f593046d91f
2020-01-12 14:24:24 +01:00
Harald Welte 43436034ee e1d: Don't use perror() directly, use osmocom logging instead
Change-Id: I98f337f8f517b98f9b78dc173e5761687609abd8
2020-01-12 14:24:24 +01:00
Harald Welte c6c70766b3 e1d: add missing forward-declaration of e1inp_e1d_init()
Change-Id: I0060e2c9772eb5c0293712cb0da7cc0477eb8abd
2020-01-12 14:24:20 +01:00
Harald Welte 52b0d45b8a e1d: Use HAVE_E1D in C source, not ENABLE_E1D
The config.h files contains HAVE_E1D.

Change-Id: Ib7d2db6703300b7d537c78ad9285948673d8b1d3
2020-01-12 14:24:15 +01:00
Sylvain Munaut b559a53263 e1d: Initial osmo-e1d support
osmo-e1d is part of the Osmocom 'software defined E1 interface,
which consists of a USB device for the actual E1 hardware interfacing,
and a daemon (osmo-e1d) implementing a libusb-based driver.

This commit adds initial support for talking to osmo-e1d using
the related libosmoe1d library.  You need to use '--enable-e1d'
at configure time to enable it.

Change-Id: Ia0431c124e3b5b4108aee7b109d8c4bb0d8b45d4
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2020-01-12 14:22:18 +01:00
Harald Welte b5af0991b3 introduce and use logging macros with context on E1 line / timeslot
Change-Id: I447a2360757fed97ed50f9db1e2efbf2f90e46a0
2020-01-12 13:31:35 +01:00
Harald Welte 510ae993a0 dahdi: Don't use perror() directly, use osmocom logging instead
Change-Id: I287e10ee49a8ac26eef903568b29a3b2abf3b43e
2020-01-12 12:17:54 +01:00
Neels Hofmeyr a160e4bfdb add/clean big-endian packed structs (struct_endianess.py)
Change-Id: I09c56f59631828ad219a5edd7d95cac8df462c84
2020-01-07 17:49:51 +01:00
Pau Espin c313d44272 Bump version: 0.7.0.8-4c2c-dirty → 0.8.0
Change-Id: If7099f91a3610d61d16e769406ac27f54e7363f3
2020-01-02 20:53:32 +01:00
Vadim Yanitskiy 4c2c088518 input/ipa_keepalive.c: make sure IPA keepalive FSM is registered
Change-Id: I36997b31f50fb1e051686a58dac09bc9ed391d17
Fixes: CID#206090
2020-01-01 13:59:59 +01:00
Harald Welte d4be696bbc Enable DAHDI support by default; require --disable-dahdi otherwise
libosmo-abis was built with DAHDI support, if the related header files
were present at built time, and without if not.  This kind of automagic
enabling/disabling of features is wrong.  Let's require DAHDI support by
default, and force the user to take a conscious decision by using an
explicit --disable-dahdi if he doesn't want it.

At the same time, update debian/control to list dahdi-source as build
dependency.

Change-Id: Id9f7f063e7ca9e3ab4aa96fc93f243caf50fb66a
Closes: OS#4248
2019-12-01 20:03:39 +00:00
Vadim Yanitskiy b43ce42411 e1_input.c: make reference counting get() / put() more verbose
Change-Id: I1c730d6d146b365712b28e3d37e038344ea850bc
2019-12-02 02:45:00 +07:00
Vadim Yanitskiy 69ae238f1e input/ipaccess.c: fix debug message on receipt of IPAC_MSGT_ID_GET
Change-Id: I83c52c9733852cfebf183819fb36bd634d84bf7d
2019-12-02 02:45:00 +07:00
Vadim Yanitskiy 1c94f6a50e input/ipaccess.c: propagate errors from ipa_parse_unitid()
Change-Id: Ic190daae31936959de8efb5a6de8744c016d5643
2019-12-02 02:45:00 +07:00
Harald Welte 7c1c8cc710 dahdi: Use ioctl(DAHDI_SPECIFY) instead of legacy /dev/dahdi/%u
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
2019-11-14 22:06:23 +00:00
Pau Espin b6e28bf77b ipa: Allow setting local addr and port for struct ipa_client_conn
Change-Id: I3133c6b01647506a5b9c67e4699bcad3ff59f843
2019-11-08 17:30:28 +01:00
Alexander Couzens e11afdaa0e ipa: ipa_server_link_close() add checks of link state
When closing a link which failed on open,
ipa_server_link_close() would crash it when calling osmo_fd_unregister.

Change-Id: I672d4de25464c3829b08aff26b1a6d4ad92e7684
2019-09-15 23:08:38 +02:00
Harald Welte 30249a15d5 Bump version: 0.6.0.13-b4a7 → 0.7.0
Change-Id: Ia5ecb2f69ce5436cae8d7a2d300e446ff24e84bc
2019-07-21 21:32:08 +02:00
Eric Wild 51b610095d extend the ipa keepalive fsm
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
2019-07-21 19:27:40 +00:00
Harald Welte b4a7db0f36 ipaccess.c: Avoid calling close(-1) on error path
Change-Id: Idabb9805a4a10c95ba0e01bc3f80ed8db87a9f85
Closes: CID#157118
2019-07-21 13:43:31 +00:00
Debian Mobcom Maintainers 418775c7a5 spelling
===================================================================

Change-Id: I22c98915648760a83abd5f0004af26d426a5e518
2019-07-17 10:55:43 +00:00
Eric Wild 6eb186c097 add TCP_USER_TIMEOUT to keepalive
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
2019-06-21 15:24:41 +00:00
Eric Wild b8242720b8 ipaccess: allow tcp keepalive for ipa clients
This allows using the e1_line x keepalive y z setting for clients like
osmo-bts.

Change-Id: Iadf22934ca6d3c44adac5573709ba53e75fa07da
2019-06-21 13:27:09 +00:00
Harald Welte 3e03bc2997 ipa_keepalive_fsm: Suppress error messages for INIT -> INIT transition
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
2019-04-06 20:26:25 +02:00
Harald Welte 02c5e9d1d0 ipa_keepalive_fsm: Fix OSMO_IPA_KA_E_STOP allstate event
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
2019-04-06 20:22:43 +02:00
Harald Welte 3d60dbd021 Add IPA keep-alive FSM implementation
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
2019-03-19 17:19:02 +01:00
Sylvain Munaut bab7ae7e88 rtp: Add 'autoconnect' feature to the osmo_rtp_socket
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>
2019-03-19 13:57:06 +00:00
Harald Welte c0a0ec494f ipa: Make ipa_server_conn_destroy() re-entrant
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
2019-03-08 16:35:43 +01:00
Max 3a2aa0975a Log peer's port in accept callback
* log port from which we accept() the connection in addition to address
* use macro helper for logging

Change-Id: I186974dae1819af8c92f9ea9eeb966ec7c9c9f55
2019-01-24 17:23:24 +00:00
Max 480073a660 Set local IP in ipa_server_link properly
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
2019-01-24 17:22:52 +00:00
Harald Welte 176a1fbab6 Bump version: 0.5.1.20-de57 → 0.6.0
Change-Id: I417065deb06ac7e8b3b8468b88cc803a41098c2d
2019-01-20 09:10:13 +00:00
Stefan Sperling 961776a2f9 log IPA tags correctly
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
2018-12-06 13:09:48 +01:00
Pau Espin de5758d307 osmo_ortp: Log domain and fix strings without endl char
Change-Id: Ib6df0df04cd6ba342753c84398274d04917ace40
2018-11-12 17:16:32 +01:00
Pau Espin b5cfc6b019 ipaccess: Simplify handling of ipaccess e1line ts
Handle encoding specifics behind a macro to make code easier to
understand and follow.

Change-Id: Ibf251673bff95b7a0b066b19ef4dc6c0f94fff6b
2018-10-03 12:10:43 +02:00
Pau Espin dd95eb6480 ipacces: Log correct trx_nr during IPA GET
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
2018-10-02 20:05:33 +02:00
Stefan Sperling 0d7d0b0a86 ensure unix socket paths are NUL-terminated for bind/connect
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
2018-09-20 17:40:59 +02:00
Stefan Sperling b24efa551d Properly deal with sockaddr_un socket path length limitations.
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
2018-09-04 11:51:47 +02:00
Pau Espin ed122f3c25 ipaccess: Allow passing return code in e1inp_line_ops->sign_link()
Change-Id: Ia83eead3622d86f55c1dc5e91acc78dde73a0367
2018-08-28 18:25:02 +02:00
Pau Espin 7ad2b15bc7 ipaccess: Return -EBADF when closing socket in ipaccess_bts_read_cb
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
2018-08-28 18:08:59 +02:00
Pau Espin 082876bb65 ipa: Allow signalling fd destroyed in ipa_server_conn_read
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
2018-08-28 18:08:59 +02:00
Pau Espin 2775798edb ipa: Allow signalling fd destroyed in ipa_client_read
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
2018-08-28 18:08:59 +02:00
Pau Espin 3750dea968 ipa: Simplify code in ipa_server_conn_read
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
2018-08-28 17:56:59 +02:00
Pau Espin 493c8e6008 ipa: Simplify code in ipa_client_read
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
2018-08-28 16:46:42 +02:00
Neels Hofmeyr fe6731181c ipa: don't crash on missing IPA ID GET message
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
2018-08-24 17:50:22 +02:00
Pau Espin 67902bbeb9 ipaccess_rcvmsg: Fix bug introduced in previous commit
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
2018-08-23 14:36:51 +02:00
Pau Espin 56ae85fd52 ipaccess: Use osmo_fd_setup to set up callbacks
We have a public API in libosmocore, so let's use it istead of manually
filling each struct field.

Change-Id: I09479c3d5b0b9bd69a56c080b8c533a32824cc66
2018-08-22 13:11:25 +02:00
Harald Welte 82eb55e5a1 Migrate from ipa_ccm_idtag_parse to ipa_ccm_id_resp_parse()
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
2018-08-01 13:22:55 +02:00
Neels Hofmeyr 4c57eef663 fix strncpy bugs in ipaccess.c, ipa_proxy.c
Change-Id: Iad53b603521c0a8f4857bd87dca777ba8e875cde
2018-07-27 18:51:30 +02:00
Pau Espin 026ff4574d Bump version: 0.5.0.10-a210-dirty → 0.5.1
Change-Id: I9a606d5d3f9ce6baf99e69d60529332a460a9504
2018-07-27 18:15:19 +02:00
Pau Espin a210684433 e1_input.c: Replace '.' in counter names with ':'
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
2018-07-24 15:00:15 +02:00
Philipp Maier e7761c6f6f Revert "ortp: enable scheduled mode on rtp socket creation"
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
2018-06-05 16:21:06 +02:00
Philipp Maier 05de362c81 Revert "ortp: make sure the ortp scheduler is started"
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
2018-06-05 16:19:10 +02:00
Philipp Maier 5a236ce1d4 ortp: enable scheduled mode on rtp socket creation
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
2018-05-31 17:43:07 +02:00
Philipp Maier c81b68f3e8 ortp: detect ssrc changes immediately
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
2018-05-30 14:31:34 +02:00
Philipp Maier 28eeb6bc93 ortp: reset rtp session on SSRC changes
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
2018-05-30 14:07:17 +02:00
Philipp Maier 7632278ea3 ortp: make sure the ortp scheduler is started
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
2018-05-29 16:07:50 +02:00
Stefan Sperling b0162077da fix double-free/use-after-free of pointers in struct e1inp_line
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
2018-05-24 14:57:36 +02:00
Pau Espin 7edc25d9d5 ipaccess: Avoid using released line and bfd in ipaccess_fd_cb
Related: OS#3282

Change-Id: I52faa9e6717137a7dab9c4e006eaa50b7367fc3e
2018-05-23 20:39:29 +02:00
Pau Espin cfe2260c00 ipaccess: ipaccess_rcvmsg: Drop unneeded memcpy
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
2018-05-23 20:38:15 +02:00
Pau Espin 7b89f12e66 Bump version: 0.4.0.21-60fd-dirty → 0.5.0
libosmotrau library version in debian package was wrong, fix it while
releasing.

Change-Id: I399618c7353a4150e3d571758b522dd2e9d9724f
2018-05-03 16:12:04 +02:00
Stefan Sperling 49917c129b preserve 'when' flags of new osmo_fd in ipaccess_rcvmsg()
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
2018-03-22 20:28:25 +01:00
Max f446367a63 IPA: log remote address
Wrap IPA logging to always print peer's address to simplify
troubleshooting.

Change-Id: I19ebaea45812aad6b3d3480cac0f1f833daf428d
2018-02-13 15:17:27 +01:00
Max 7139352e67 cosmetic: update ipaccess_bts_handle_ccm()
* mark internal function parameter as const
* log unit IDs

Change-Id: Ifcf8baf4bf5670efaa8689ca7386597fe2797bda
2018-01-08 15:42:00 +01:00
Harald Welte d1dd22c38e Add a new osmo_rtp_set_source_desc() function to set the RTCP SDES items
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
2017-12-03 11:03:50 +01:00
Alexander Couzens 2d4888dd08 unixsocket: fix a potential string overflow
Change-Id: I8e3ec741247d728232f8c07c94eb63f068597d80
Found-by: coverity
2017-11-21 11:57:01 +01:00
Harald Welte 323d39d784 Add SPDX-License-Identifier to all source files
Change-Id: I9f2bc8c5d8a2c0bb0dd6caa4de5e2cb11be210e7
2017-11-13 01:09:21 +09:00
Neels Hofmeyr e2d33bf02d vty: skip installing cmds now always installed by default
vty_install_default() and install_default() will soon be deprecated.

Depends: I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b
Change-Id: I7771131a27d0b7ad0397715ceb3be035062bc010
2017-11-01 00:44:19 +01:00
Neels Hofmeyr 01543a1ea3 cosmetic: ipa.c: use msgb_dequeue(), drop local var
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
2017-09-14 04:59:32 +02:00
Max 7f17b8c45d Bump version: 0.3.2 → 0.4.0
Change-Id: Ibefe53a7f5b06fb8a9294574af41dacac68bdbe9
2017-08-25 16:12:37 +02:00
Harald Welte ff8eed24e7 check for missing result of rate_ctr_group_alloc()
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
2017-07-12 00:38:25 +02:00
Pau Espin 9e992c2435 osmo_ortp.c: Duration of a RTP frame affects timestamp of the next one
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
2017-06-29 18:04:32 +02:00
Pau Espin 524923a96a osmo_ortp: Add osmo_rtp_drop_frame API
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
2017-06-29 17:27:25 +02:00
Pau Espin 05df2d65a7 osmo_ortp.c: Fix warning: check ortp API in rtp_session_signal_connect
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
2017-06-22 19:27:16 +02:00
Pau Espin b0c3a4a30f osmo_ortp.c: Fix warning: implicit use of function
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
2017-06-22 19:26:57 +02:00
Pablo Neira Ayuso b26f2fd825 src: use osmo_timer_setup()
Use new function available in libosmocore to set up timers. Compile
tested only.

Change-Id: I4ca4950e49a09c63b608b13ac7561ebbd351889a
2017-06-07 18:34:49 +02:00
Harald Welte e416e2e09d Revert "ipacces.c: Remove ipa_bts_id_resp() and use libosmocore"
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
2017-05-26 13:12:14 +02:00
Harald Welte cac78fe9e9 Add value_string for input signal names (e1inp_signal_names)
Change-Id: I1662d4a969d2d12677646f3120b25be9a20c6d22
2017-05-25 19:13:13 +02:00
Harald Welte d517db06ce ipacces.c: Remove ipa_bts_id_resp() and use libosmocore
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
2017-04-15 19:12:01 +02:00
Jean-Francois Dionne 5e87fdfcab Fix RTP jitter buffer that never stop to increase.
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
2017-03-29 13:40:22 +00:00
Pau Espin Pedrol c42bf19cc5 configure: Fix compilation with new libortp
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
2017-03-27 15:21:48 +02:00
Philipp Maier 027e119363 lapd: log pointer addresses
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
2017-03-15 13:00:24 +00:00
Philipp Maier d75bac40d1 lapd: Reduce N200 (SABM retransmission count)
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
2017-03-14 18:32:33 +01:00
Alexander Couzens beb10ef02a add basic unixsocket support
Allow to connect to a unix socket for communicating with LAPD.

Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a
2017-03-08 10:14:05 +00:00
Holger Hans Peter Freyther 254745880b misc: Fix build failure/warning when building on alpine linux
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
2017-01-23 19:49:07 +01:00
Neels Hofmeyr 30ffa7ade5 undup: subchan_demux.c: use libosmocore's llist_count()
Depends on libosmocore Change-Id Ic49adc7a346f5722bf624d7d3b4a735e4220ae15

Change-Id: I47f1831f1835dc07925dabbc115677087e48fa1b
2017-01-21 01:18:02 +01:00
Max c9fa25e831 handle_ts1_read(): log sign_link() error
Change-Id: I95779ee8590ab16b7af4ad2c79ede68da3a12e5a
2017-01-09 13:24:26 +01:00
Max 4c4a1c2035 ipaccess_line_update(): log connection IP addresses and ports
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
2016-12-31 18:41:39 +00:00
Max bf42e0a91f Enable adaptive jitter compensation
* 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
2016-12-16 13:26:28 +01:00
Max ac2ad3b437 Remove obsolete compile-time conditional
Change-Id: If8f87587227b09635361b758873f75d8b6aa3497
2016-12-16 13:04:19 +01:00
Max 7c840be476 Expand network error callback
ortp: use extra parameter for network_error callback in log message as
it's described in oRTP documentation (error string).

Change-Id: I581db499d453b80230198d95000f0f6fc20752d1
2016-12-12 11:08:02 +00:00
Max 78d0486ffd osmo_rtp_socket_poll(): Fix log message to match function name
Change-Id: I5c36bbc35e2ba794b5e446f52a0752bcf1367d11
2016-12-05 15:22:07 +00:00
Harald Welte b0a4235805 don't pass negative error to strerror()
Change-Id: I48c25c78148d1fe9ce4e4a88cdfe5cf74dc95b17
Fixes: Coverity CID 57858
2016-11-26 09:44:33 +01:00
Harald Welte 519217f0ea call strerror() not on negative value
Change-Id: I0ba1eab49f93d9b34d162682f2528d106b56d6d6
Fixes: Coverity CID 57857
2016-11-26 09:43:46 +01:00
Harald Welte 14dd30a13e fix signed/unsigned bug in ipa_client_conn_open()
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
2016-11-26 09:37:09 +01:00
Harald Welte 34260c8923 osmo_rtp_socket_fdreg(): Check return value of osmo_fd_register()
Change-Id: I4969e0a9e7109d426066e6c2b80ed44c396b65b5
Fixes: Coverity CID 57631
2016-11-26 09:27:46 +01:00
Harald Welte ae3a993bd6 input/ipaccess.c: Check return value of osmo_fd_register()
Change-Id: I81659e0533ceb5d43292d97a63300b500044add7
Fixes: Coverity CID 57630
2016-11-26 09:25:23 +01:00
Alexander Couzens 35daa67763 e1_input: remove superflous semi colon
Change-Id: I7e9079cbac1d9920da2aace35810682b49ec532f
2016-11-16 10:08:02 +00:00
Philipp Maier 0c7d5f4a61 lapd: adding support for ericsson's lapd dialect
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
2016-11-02 09:23:01 +00:00
Harald Welte 7895e0456a Fix metadata corruption
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
2016-10-28 09:03:22 +00:00
Max f69060066c Unify RTP receiving
* Remove code duplication
* Use return value of rtp_get_payload() instead of pointer arithmetic

Change-Id: Id42e85b55eab33c5eb81ac7a2cdea7962b2e30ef
2016-10-27 18:06:20 +02:00
Max 02ceea8342 Extend RTP RX callback parameters
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
2016-10-21 19:45:00 +02:00
Harald Welte 7a228ebc60 Add HDLC timeslot mode
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
2016-10-17 22:15:55 +02:00
Harald Welte a0108e78a9 Implement new 'raw' input type for E1 timeslots
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
2016-10-17 22:14:19 +02:00
Harald Welte 4ca5c53f7f Convert e1inp_{sign,ts}type_name() to use struct value_string
Change-Id: I0546c3f5aefe5e1cc33d8d82f1783fa467e37ff0
2016-10-16 22:14:08 +00:00
Harald Welte f35d8898ab e1_input: Add E1 timeslot number to input_signal_data
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
2016-10-16 22:13:46 +00:00
Yves Godin 2c32f0a269 Resync RTP session in case of timestamp jump
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
2016-10-12 09:26:00 +00:00
Neels Hofmeyr a0ff942e92 Really fix order of set_connected_mode and set_remote_addr
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
2016-10-06 15:50:18 +02:00
Max 15d9b7929d Bump minimum oRTP version
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
2016-09-24 16:30:22 +02:00
Max fc47015d91 Use callback for polling data
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
2016-09-20 19:17:02 +02:00
Max 6dab90f39f Change API to convey marker bit
Previously RTP receive callback ignored Marker bit from RTP
headers. Extend API to include it explicitly.

Change-Id: I3c2b6365d8a51bf98805614e07344d2639875fde
Related: OS#1750
2016-09-09 06:34:54 +00:00
Neels Hofmeyr c77c2a6aa1 osmo_ortp.c: fix order of set_connected_mode and set_remote_addr
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
2016-09-05 14:18:08 +02:00