Commit Graph

1852 Commits

Author SHA1 Message Date
Kirill Zakharenko 357ab3abba Merge master into fairwaves/production 2020-05-01 18:21:58 +03:00
Kirill Zakharenko 1405163e3d statsd: do not omit index==0 when sending stat item groups 2020-04-23 19:02:08 +03:00
Harald Welte 100e44ed49 timerfd: call osmo_fd_unregister() when closing on read error
Change-Id: I8513126286083ebf02d14043cf072c8297878dd7
2020-04-19 08:27:27 +00:00
Eric Wild 06747d5720 timer.c: make timers thread safe
This is implicitly used by the libosmocore select abstraction, which
might be used in multiple threads at the same time.

Change-Id: I5a3802c94af6ff0315f1553f20870342d51ce726
2020-04-19 02:21:05 +02:00
Harald Welte a70ac85f5b select.c: Introduce support for signalfd
The signalfd(2) mechanism of Linux allows signals to be delivered
and processed via normal file descriptor I/O.  This avoids any of the
usual problems about re-entrancy of signal processing, as signals can
be processed from the osmocom select() loop abstraction just like any
other event.

Change-Id: If8d89dd1f6989e1cd9b9367fad954d65f91ada30
2020-04-18 21:16:12 +02:00
Harald Welte f3cc731d40 exec: Introduce osmo_system_nowait2() to allow specify a user
For a process running as root, it may be desirable to drop privileges
down to a normal user  before executing an external command.  Let's
add a new API function for that.

Change-Id: If1431f930f72a8d6c1d102426874a11b7a2debd9
2020-04-18 15:06:59 +02:00
Philipp Maier 898c9c6af8 dtx: add decoding for AMR-DTX frames
gsm0503_coding contains AMR decoder functions for HR and FR. Those can
only decode AMR payload frames but not amr DTX frames. Lets add
functionality to detect DTX frames. Also lets add decoding for SID_UPDATE
frames as well as error checking for the SID frame recognition patterns.

Related: OS#2978
Change-Id: I2bbdb39ea20461ca08b2e6f1a33532cb55cd5195
2020-04-14 13:22:44 +00:00
Pau Espin d1cd527541 gsm0503_tables: Document USF encoding tables
Change-Id: I596c10960bd1ff1b1ec14ad953ce5e1ed040d35a
2020-04-07 13:26:59 +02:00
Pau Espin 63ebc368af gsm0503_coding: Fix USF encoding in MCS1-4
osmo-gsm-tester raised an ASan warning in osmo-bts-trx  during execution
of a test with EGPRS enabled and a modem connecting to it (see OS#4483
for full trace):
==12388==ERROR: AddressSanitizer: global-buffer-overflow on address 0x7fa20b9ab8d0 at pc 0x7fa20b982894 bp 0x7ffdfea8b9c0 sp 0x7ffdfea8b9b8
READ of size 1 at 0x7fa20b9ab8d0 thread T0
 #0 0x7fa20b982893 in gsm0503_mcs1_dl_interleave /home/osmocom-build/jenkins/workspace/osmo-gsm-tester_build-osmo-bts/libosmocore/src/coding/gsm0503_interleaving.c:165

Function gsm0503_mcs1_dl_interleave() was being passed the 6-bit USF
encoding while clrearly expecting a 12 element array. TS 05.03 5.1.5.1.2
"USF precoding" also clearly states that 12bit encoding is to be used
for MCS1-4.

Fixes: OS#4483
Change-Id: I94db14de770070b17894a9071aa14391d26e776c
2020-04-07 13:15:38 +02:00
Pau Espin f62f073c79 gsm0503_coding: Fix misleading comment UL vs DL
Change-Id: I563c60271e218f9953e26f9bf0304d442c6acd43
2020-04-07 13:12:21 +02:00
Vadim Yanitskiy 9e713f3828 coding: fix bit ordering in 11-bit RACH coding functions
According to 3GPP TS 44.004, figure 7.4a.b, the format of 11-bit
RACH uplink / Uplink access burst block is as defined follows:

  <---------------------------------------------------

      8     7     6     5     4     3     2     1
  +--------------------------------------------------+
  |  11 bit RACH uplink / Uplink access burst block  | OCT1
  +--------------------------------------------------+
                                 |                   | OCT2
                                 +-------------------+

As was (correctly) assumed in [1], the bit ordering in 11-bit RACH
coding functions is wrong. The problem is that neither of generic
functions from bit16gen.h can be used to load / store the RA11
value (regardless of the endianness), because they assume that
the payload is 16 bit long.

With this patch applied, RA11 values from [1] look correct:

  < EGPRS Packet channel request message content > ::=
    < Signalling : 110011  < RandomBits : 00111 > > |
    < Signalling : 110011  < RandomBits : 00110 > > |
    < Signalling : 110011  < RandomBits : 01111 > > |
    < Signalling : 110011  < RandomBits : 01100 > > |
    < Signalling : 110011  < RandomBits : 00111 > > |
    < Signalling : 110011  < RandomBits : 10110 > > ;

[1] Id80e471d252b9416217b56f4c8c0a8f5f1289fee

Change-Id: I43d30611dd69f77f2b3b46f4b56056a8891d3c24
Related: OS#1548
2020-04-01 01:09:31 +07:00
Vadim Yanitskiy 8055cddbe2 coding: fix documentation of PDTCH encoding functions
Change-Id: Ia38723fb9424551eaf5747d736ae73ab20873def
2020-03-31 15:37:27 +07:00
Harald Welte 2954aa9b8a sim: Add HPSIM application support
Change-Id: I883faae5e170803b8301d10c8b9fad7892da009c
2020-03-21 16:31:17 +01:00
Harald Welte e92f3628a8 card_fs_{usim,isim}: Update to 15.7.0 / Release 15
Various new files and some new status words have been defined
by now. Let's add them.

Change-Id: Ia007281bcb61dcd8260d0a77203abeff21d5255f
2020-03-21 16:31:17 +01:00
Harald Welte 58d173ade1 osmo-sim-test: Also [attempt to] dump DF.GSM on USIM cards
an USIM application can very well exist on a UICC without supporting
classic DF.GSM access.  However, most commonly, both are found on
cards.

Change-Id: I6180a3f81a7d3006e8ece4302c2433db2588bfaa
2020-03-21 16:31:17 +01:00
Harald Welte 429adecfd8 sim: re-structure how we support cards + applications
Before this change, a card application (USIM, ISIM, ...) didn't
exist as a separate concept from a card profile.  This meant,
we had a manual combination of UICC card profile with USIM application,
and another one of UICC card profile and ISIM application.  But what
if there's a combined USIM+ISIM?

In reality, applications exist as separate objects, on top of an
ETSI UICC.  Lets therefore register all known applications to the
osim library core, and add code to osmo-sim-test which dynamically
detects all applications present on a given card (by reading EF.DIR).

Change-Id: Ic4b4ac433a9976842b30a017fb0fc347d87201cd
2020-03-21 16:31:17 +01:00
Harald Welte bf90d747ad sim: add osim_file_desc_find_aid()
Change-Id: I80468c8c4f4590c262019f42285e8d8fd3444f7f
2020-03-21 16:31:17 +01:00
Harald Welte 2d284df17b card_fs_sim: Avoid '/' in file names
... as that doesn't work if we want to create a similarly-named
file in the local file system.

Change-Id: Ib8734e2e4b81c915ab0fbd0d9b6662275b1d33d1
2020-03-21 16:24:53 +01:00
Harald Welte b8c1da1762 sim: card_fs_usim.c: Fix FID of EF.EXT4
The 3GPP spec document also contains this error at one point, and
it seems I copied it from there :/

Change-Id: I7ad9f491c06f6540747b77017678ee37e6a1550d
2020-03-21 11:31:12 +01:00
Harald Welte 3c44a646bd libosmosim: Build irrespective of PC/SC support
libosmosim contains a variety of definitions and utility fuinctions
useful when working with SIM card [protocol].  They can not only
be used with PC/SC readers but also in other contexts.

Change-Id: I741940d3dc2a5653c760e9d1597d7f08afb3b631
2020-03-16 11:28:21 +01:00
Philipp Maier 3a5917bd50 gsm690: Fix amr speech bit length table
The table amr_len_by_ft represents the length of the raw AMR speech bits
in bytes. The table is based on the Table found in RFC 4867 §3.6, Table 1,
Column "Total speech bits". The number of bits is divided by 8 and then
rounded up to get the number of consumed octets.

An AMR SID frame (including STI and MI) takes up 39 bits, this will
result in 5 octets, not in 7. Lets correct this.

Related: OS#2978
Change-Id: Icf330450981b32be5d1cee5b10aa92bac4cb72f5
2020-03-13 10:52:22 +01:00
Harald Welte 44b9926c84 socket: Add osmo_sock_mcast_iface_set() to bind multicast to device
Change-Id: Ib52d22710020b56965aefcef09bde8247ace4a9c
Related: OS#2966
2020-03-10 19:08:51 +01:00
Philipp Maier 31c29ea051 conv: add convolutional coder for AMR SID UPDATE frames
AMR SID update frames are protected using an 1/4 convolutional coder,
wich is similar to the one used with 6,7 kbit voice frames. Except that
there is no puncturing and the length is different.

Change-Id: Ia35ed4178a7f0d816052b7e5d6478b93a1d9744f
Related: OS#2978
2020-03-09 13:40:27 +01:00
Philipp Maier 1c46d19e43 parity: add amr crc14 definition
AMR not only specifies a 6 bit CRC for regular voice information. It also
specifies a 14 bit CRC to protect the comfort noise updates contained in
the SID_UPDATE frames.

Change-Id: I5cfd8ca806aba8d42cb9787f69605cea7de6e900
Related: OS#2978
2020-03-09 13:40:27 +01:00
Harald Welte 6773304de8 gsmtap: Solve TCH / FACCH confusion once and for all
* What we used to call TCH/F and TCH/H in gsmtap are actually only
  FACCH/F and FACCH/H, i.e. the signaling part of Bm/Lm channels

* Give them proper names with backwards compatibility #define

* Split VOICE into VOICE_F and VOICE_H.  If we don't differentiate this,
  a receiver is not able to determine the RSL channel ID of a frame
  without looking at external state/context.  That in turn has been a
  design feature of GSMTAP Um format so far, and programs like
  osmo-bts-virtual rely on it.

Change-Id: I952044a17334f35712e087dc41781805000aebc1
Related: OS#2557
2020-03-08 17:27:00 +01:00
Harald Welte 20618cabe7 Add GSMTAP_CHANNEL_VOICE to gsmtap_gsm_channel_names[] value_string
In Change-Id If223020933b083fe359a2e8ff5fab1ce64a363d8 we introduced
GSMTAP_CHANNEL_VOICE, but we didn't add it to gsmtap_gsm_channel_names[]

Change-Id: I7ab696d3e0edb13632e048a9e05be03612d3d28c
Related: OS#2557
2020-03-08 10:42:51 +01:00
Alexander Chemeris 99532b00e0 WIP: gb: Standard-compliant Static Gb over IP
The current implementation of the Gb over IP in Osmocom is derived
from the ip.access implementation of it, which is a "weird combination
of Gb over FR and Gb over IP" in that it runs over UDP/IP but uses
procedures like NS-RESET and NS-BLOCK which are only specified
for Gb over FR.

This makes it impossible to use OsmoPCU and OsmoGbProxy with
standard SGSNs like from Huawei in "Static IP-GB" mode
(i.e. without SNS procedure).

This patch is a hack to remove NS-RESET procedure and use NS-ALIVE
to setup an NS link and keep it open.

One could argue that SNS is a much better way and should be used
instead of the old "static" config but in pratical installations
you do ant to use osmo-gb-proxy to aggregate multiple links and
it doesn't support SNS yet. So using this hack is the easiest way
to get multiple OsmoPCU's to connect to a standrd-compliant SGSN.

NOTE: This patch is a quick hack and lacks any unit-testing or
configuration.

Change-Id: I1b1b28913488a40e4fceb65e646c3d89e8a431a4
2020-03-06 18:01:42 +03:00
Alexander Chemeris 07cdd76ffd gb: Print signalling and data weights on NS-VC creation.
Change-Id: Ieebec5487f5d995a453d15bc024931299d5cf5bf
2020-03-04 01:01:54 +03:00
Alexander Chemeris 8abe45d86a gb: Fix typos in gprs_ns.c comments
Change-Id: I24605c8616015b5f7d45297afc65d6a93d2edbaf
2020-03-04 01:01:49 +03:00
Harald Welte ac7fabe34f chantype_rsl2gsmtap(): Add entries for CBCH
This adds missing entries for CBCH in the conversion between RSL-style
channel numbers and GSMTAP channel types.

Without this change, you will see tons of messages like
virtphy[19865]: Wed Feb 26 16:16:28 2020 DVIRPHY <0002> gsmtapl1_if.c:267 MS 0000: Ignoring unknown channel type UNKNOWN (0)
if running virtphy of osmocom-bb with a BTS that broadcasts CBCH.

Change-Id: I19bbd2942adf441f58955ac896ef968bfd8aec5f
2020-02-28 10:46:42 +00:00
Vadim Yanitskiy 4960ee4511 bitvec: avoid redundant zero-initialization in bitvec_alloc()
All the fields of the structure are set explicitly anyway.

Change-Id: I40c0322d5f2febd98bae6fbe0ec2132eda6fb35b
2020-02-19 18:33:39 +07:00
Vadim Yanitskiy c866b326d3 bitvec: cosmetic: init i only once in bitvec_[un]pack()
Change-Id: I5606ca34a72d42a9b6aafed662b995f9fa77be09
2020-02-19 18:33:39 +07:00
Vadim Yanitskiy a500bc3d27 bitvec: fix misleading description of bitvec_spare_padding()
Change-Id: Ie60bf7d993fe80d3c0fcd04e4c3dd81da4a2ea0b
2020-02-19 18:23:40 +07:00
Vadim Yanitskiy 832d8b8633 bitvec: fix bitvec_unhex(): do not return 1 on success
This function is supposed to return 0 on success or 1 in case of
error. However, it used to return 1 even in case of success. The
reason is that length of the input string was not taken into
account and sscanf() was failing on '\0'.

Let's use osmo_hexparse() and rely on its return value.

P.S. Funny that the unit test expectations were wrong too.

Change-Id: I441a22c7964bb31688071d8bcf6a282d8c0187ff
2020-02-19 18:23:40 +07:00
Vadim Yanitskiy 4c9a36cb40 bitvec: make bitvec_free() safe against NULL
Change-Id: Ifafb65e9d0adc286e16104274db440f38a86d800
Related: CID#208181, CID#208179
2020-02-10 14:22:07 +07:00
Vadim Yanitskiy 979c3b7e7e exec: propogate errors from osmo_environment_[filter|append]
Change-Id: If7d6e0441f73092a4fb455340c076ba4dc60af3f
2020-02-09 05:06:42 +07:00
Vadim Yanitskiy d419f652bb exec: prevent uninitialized memory access in osmo_system_nowait()
If (!env_whitelist && addl_env), osmo_environment_append() would
access uninitialized memory. If both are false, execle() would
also deal with garbage values. Let's ensure that at least the
first element of new_env[] is initialized.

Change-Id: Id3901de4692ef44e9e9c67b1804e027fc4ce7c18
Fixes: CID#206571
2020-02-09 05:03:37 +07:00
Vadim Yanitskiy 775a6b0ddd osmo_libusb: check return value of osmo_fd_register()
Most likely, we should not assert() here, but let's at least log
an error message in case if osmo_fd_register() fails.

Change-Id: Ia20755ec12ee9fb0eba8322551642a96e68e1570
Related: CID#206572
2020-02-09 04:27:50 +07:00
Vadim Yanitskiy a8809f0a16 conv: prevent theoretical NULL pointer dereference in osmo_conv_encode()
A caller shall never pass NULL to osmo_conv_encode().

Change-Id: Ice0050cd7c7e3fcbf57c2c73682ca28843a92d8b
Fixes: CID#208174
2020-02-09 04:27:47 +07:00
Vadim Yanitskiy df4f6085cd tdef_vty: do not enforce enum 'node_type' in osmo_tdef_vty_groups_init()
Some osmo-* applications may need to use their own VTY node as a
parent for the timer configuration commands. Therefore it makes
more sense to use 'unsigned int' instead of 'enum node_type'.

Let's also clarify that osmo_tdef_vty_groups_init() accepts parent
node for configuration commands only: 'parent_node' -> 'parent_cfg_node'.

Change-Id: Ifb4c406c85d76a25fc53fc235484599aa87dc77c
2020-02-06 01:06:14 +07:00
Eric Wild 18caa87778 pcsc: don't leak memory
Change-Id: I183882ff2eae82754d55189b154863fad9cce4aa
2020-01-29 14:41:18 +01:00
Vadim Yanitskiy 89c0428825 gsm/gsm48049.c: fix use of GNU 'missing =' extension in designator
Found by clang with enabled LTO (Link Time Optimization).

Change-Id: Ibda4600b4d23b93cf79ff13bb934dfc396aa7d93
2020-01-21 18:34:04 +07:00
Vadim Yanitskiy 685f7c375f usb/Makefile.am: fix copy-pasted library name: s/libosmosim/libosmousb/
src/usb/Makefile.am:16: warning: variable 'libosmosim_la_LIBADD' is defined but no program or
src/usb/Makefile.am:16: library has 'libosmosim_la' as canonical name (possible typo)
src/usb/Makefile.am:15: warning: variable 'libosmosim_la_LDFLAGS' is defined but no program or
src/usb/Makefile.am:15: library has 'libosmosim_la' as canonical name (possible typo)

Change-Id: I062ea640a75f4521818ba71d5ffea2d08bf3052a
2020-01-21 18:27:01 +07:00
Harald Welte e51cbe4cc7 osmo_libusb: Check return of libusb_get_string_descriptor_ascii()
Change-Id: Ifc0133737627a8277635f8f3662b3f6e922be149
Closes: CID#207713
2020-01-18 21:50:47 +01:00
Harald Welte c45787bf5c usb: Add osmo_libusb_find_matching_dev_{path,serial}
Thise two helper functions allow the user application to find
a unique match among the existing USB devices, using either a user-
provided iSerial string, or a user-provided physical USB path.

Change-Id: I8ff3fb3e1a77e10cb313473480ce5e7673749a93
2020-01-12 11:52:09 +01:00
Neels Hofmeyr 7e689c6577 add crcXXgen.c.tpl to EXTRA_DIST
'make distcheck' distributes the generated .c files, but it is good GPL
practice to also distribute the template.

Change-Id: I988acd3bc629e98985a99780d3142112125d13f7
2020-01-07 17:25:51 +01:00
Harald Welte 424eac8b6a usb: Use OSMO_STRLCPY where appropriate
Change-Id: I6b2a90fd8f4b042a1e38dbf8e99414a94a290375
2020-01-06 18:12:14 +01:00
Pau Espin 57d1118c25 logging_vty.c: Avoid acquiring log tgt lock in logging level cmd when not needed
Change-Id: Ia6780221174070cee408625e24513f2c11cc9dfc
2020-01-03 22:16:08 +00:00
Pau Espin 9b90ca8c44 gb: Fix typo in bssgp_cause_strings description
Change-Id: I2474bbe99bf0aa35aab046a1987047a8368beff6
2020-01-03 17:45:36 +01:00
Pau Espin 2b98cbe5f7 bitvec: Fix return value in doc for bitvec_write_field()
Change-Id: I629e71242cb6bafa3c1b1d65ae7ec6687ec203d1
2020-01-03 17:36:11 +01:00