Commit Graph

143 Commits

Author SHA1 Message Date
Harald Welte 14277e3375 trau: Introduce osmo_rtp_socket_set_priority()
For consistency reasons with osmo_rtp_socket_set_dscp(), let's also
introduce a osmo_rtp_socket_set_priority() function to wrap the two
calls to osmo_sock_set_priority().

Change-Id: I52c08f4b2a46981d002ef0c21e6549445d845a6e
2021-04-29 21:44:18 +02:00
Harald Welte 41547559da e1_input: Allow (vty) configuration of IP DSCP and socket priority
Change-Id: I8991dd6eb406a5b9a70498974fc1ad339452f871
Related: SYS#5427
2021-04-29 21:24:28 +02:00
Harald Welte 6bcc32bcfa ipa: Introduce support for user-specific DSCP and priority
This adds new members to struct ipa_server_link and ipa_client_conn,
which can be set by the user before ipa_client_conn_open() or
ipa_server_link_open() to ensure DSCP / priority values are applied
from the first outgoing packet onwards.

Change-Id: I5ab22d35d9b11eca47d9ea12208e5589a1a5713c
Depends: libosmocore.git If22988735fe05e51226c6b091a5348dcf1208cdf
2021-04-29 21:21:56 +02:00
Keith Whyte 2672a2a2a7 Configure E1 pcap file per line
In order to allow configuration of pcap files per e1_line
the vty command is now (for example line 0):

  e1_line 0 pcap /tmp/e1cap.pcap

in place of:

  pcap /tmp/e1cap.pcap

Also ensures that a configured pcap appears in 'show running-config'
and is written to the config file on issuing 'write'

This commit deprecates e1_set_pcap_fd()

Change-Id: I316c3d6a839e84c2f52a148c6b8dd6f5933cf4bf
2021-04-13 23:28:02 +02:00
Harald Welte b3952c60f1 e1_input: Support I.460 timeslot type
Unlike the legacy TRAU mode, this only adds I460 mux/demux,
without any TRAU frame synchronization.  The user must still be
adding the actual sub-channels using osmo_i460_subchan_add()
depending on his requirements.

Change-Id: I44da6dfec77ef475adb35001a0e4fa11d549aa02
2021-02-03 08:49:07 +00:00
Philipp Maier 8d15001910 trau_sync: make sync pattern configurable
When a trau sync fsm is allocated, the user must set the sync pattern,
which can not be changed during the whole fsm lifecycle. However on
codec changes it might be necessary to change the sync pattern on the
fly.

- Add function to change the sync pattern

Change-Id: I1caff93b4c8eace8ba8cd6e32e996a9e1503232b
Related: OS#2659
2020-08-07 17:18:46 +02:00
Harald Welte cd90ed2dd5 TRAU frame RTP conversion
This adds code that converts codec frames between (decoded) TRAU format
and RTP payload format.  The FR + EFR functions have been lifted from
OsmoNITB and exended slightly.

The HR functions have been written from scratch. There is also
incomplete code for AMR that needs to be completed + tested.

Change-Id: I7f6993cce2b95318203043e2e14952e581941b79
2020-08-03 02:57:42 +02:00
Harald Welte 78861c0aef Add new TRAU frame sync code
This code is able to detect and sync against a variety of TRAU
frame sync patterns.  Focus is so far on those patterns present on
16k sub-slots, but 8k sub-slots are expected to be supported soon,
too.

A new codebase for this is required as the old OsmoNITB code had
conflated a 16k sub-slot multiplexer with TRAU frame synchronization,
so there was no way to separate those two parts and hence no way to
support 8k sub-slots.

Change-Id: Ia6fe6228b0b8b9a27999f37ce1115ed5558881ea
2020-08-03 02:29:21 +02:00
Harald Welte dd9ee98d7e trau_frame: Introduce support for Downlink Time Alignment
In the uplink direction, we provide osmo_trau_frame_dl_ta_us()
to determine the time alignment as requested by the CCU in the BTS.

In the downlink direction, the TRAU frame encoder will perform
time alignment as requested by the user in osmo_trau_frame.dl_ta_usec.

Change-Id: I3981becafc56c9a50119b9ba6bf67aa0391cc76e
2020-08-03 02:29:21 +02:00
Harald Welte 254b924536 trau_frame: New API
The old TRAU frame code in src/trau_frame.c (which is for some strange
reason part of libosmo-abis, and not libosmo-trau!) was introduced more
than a decade ago for the needs of bs11_abis AKA OpenBSC aka OsmoNITB.

It is too constrained to implement TRAU frame parsing in a generic way,
including:
* no way to add support for 8k sub-slots
* no way to handle CRC bits or UFI (i.e. no AMR)
* no real API design, it was just ripped out from OsmoNITB and moved into
  a library (even the wrong one)

For those reasons, let's introduce a new API for TRAU frame
encoding/decoding - one that supports all the relevant use cases.

Change-Id: I5cf42e6c445d9224be18503cebc7584b3beba08c
2020-08-03 02:29:21 +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 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 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 837fb6e471 cosmetic: e1_input.h: Fix trailing whitespace
Change-Id: Ie323a28409a44aeeef6646b247f244d278758f66
2020-07-15 15:09:44 +02: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
Harald Welte 2f182e4047 trau_frame.h: Fix definition of TRAU_FT_OM_UP
Change-Id: Ifd3393fca2ce65f93e8ec6c150474011a5713ccd
2020-05-11 08:40:01 +02: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
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
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
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
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 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
Pau Espin 4179207e0e e1_input.h: Set correct type for input_signal_data->link_type
link_type field holds values from link->type as set in
e1inp_int_snd_event().

Change-Id: Iaa33b793f89f2d16c9d949503c5ecc195bbcd2a4
2018-10-03 13:18:40 +02: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 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 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 db0700a5a3 e1_input.h: Remove dead declaration of unexistent API ipaccess_setup
The function was removed long time ago in
af8ed983ff.

Change-Id: I34debe01d1d8b6f4420354666d2a25807dacc25c
2018-04-06 13:19:28 +02: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
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
Harald Welte cac78fe9e9 Add value_string for input signal names (e1inp_signal_names)
Change-Id: I1662d4a969d2d12677646f3120b25be9a20c6d22
2017-05-25 19:13:13 +02: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
Harald Welte ab3b5606fe lapd_pcap.h: Add missing #include lines
we reference 'struct msgb' and mode_t, so we have to #include
the right header files.

Change-Id: Iac8f905182b60782202bdf75e04d47ea89dc3863
2016-11-16 10:07:24 +00:00
Arran Cudbard-Bell 67b81eb6fe e1_input.h: add missing extern for value string arrays
Mark two value string arrays as extern, so symbols aren't created for
each source file that includes the headers.

Tweaked-by: nhofmeyr (commit log)
Signed-off-by: Arran Cudbard-Bell <a.cudbardb@freeradius.org>
Change-Id: Iebf4b3922a48ca2cc20d478aba06224dd89d38cb
2016-11-03 12:24:01 +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
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
Harald Welte 1129040594 remove non-existant e1inp_update_ts() from e1_input.h
This function didn't exist ever since the inception of libomso-abis.

Change-Id: Ib471f03a93a73efe18fbd69d6eb1cb35bdb4e9a3
2016-10-16 21:46:00 +00: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
Harald Welte 47bee5bed5 Add osmo_pcap_lapd_set_fd() function
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
2016-07-04 10:25:02 +02:00
Max c1cf14cae8 Fix macro definitions
Wrap macro parameter in brackets to make sure macros always work
properly: without it GSM_FN_TO_MS(a - b) will result in a - b *
GSM_TDMA_FRAME_MS contrary to the user's expectation of (a - b) *
GSM_TDMA_FRAME_MS.

Change-Id: I38937469eb7948e2b8e6c1d7fba2c2adeba45b41
Reviewed-on: https://gerrit.osmocom.org/217
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-06-12 15:45:25 +00:00
Max c42c2ca8e0 Add defines for FN to SAMPLE conversion
Add defines necessary to correctly convert number of TDMA frames into
number of voice samples. Defines are proposed by Harald in comments on
gerrit.

Change-Id: I1d8345352fb2ac76f71e88cb40f089fe3f9aae7e
Related: OS#1562
Reviewed-on: https://gerrit.osmocom.org/200
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-06-06 10:05:53 +00:00