Commit Graph

3210 Commits

Author SHA1 Message Date
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 d8c74b81f9 fixup depreciation warning
Change-Id: Id2d016939c3a6185cc3cfa8631da0c8d187a8c5a
2020-03-08 17:37:39 +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 7dedebada5 Add CTRL port number for osmo-mgw
Related: OS#4441

Change-Id: I70ae237ea27972f6819fd217c3d5059dda009486
2020-03-08 10:42:51 +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
Harald Welte 1d3e9de26b gsmtap.h: Add definitions for voice inside GSMTAP
We so far are only able to transmit signalling data inside GSMTAP,
but not actual voice / user plane payload data.

we cannot use the existing TCHF/TCHH sub-types, as those are already
used [without further discrimination] for FACCH + SACCH Data on those
channels.

Instead, we will introduce a new GSMTAP_CHANNEL_VOICE sub-type, which
then will have the first byte for a sub-sub-type specifying the payload
format in detail.

Change-Id: If223020933b083fe359a2e8ff5fab1ce64a363d8
Related: OS#2557
2020-03-05 21:15:38 +00:00
Philipp Maier fde9fdc1d3 osmo-sim-test: check tlv_parsed struct tp before access
The variable struct tlv_parsed tp in dump_file() conditionally
initalized by tlv_parse() but later it is accessed under a different
condition without a check that makes sure that tp is only accessed when
tlv_parse() was called beforehand. Lets introduce a check that makes
sure tp can not be accessed when it is uninitalized.

Change-Id: I6b0209b966127a4195e6f4bcb43d49387c7646ce
Fixes: CID#208435
2020-03-04 20:49:13 +00: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 6e270e2530 tests/bitvec: add a unit test for bitvec_read_field()
The aim of this unit test is to demonstrate the problem described
in OS#4388: bitvec_read_field() can never return negative value
on error (e.g. out of bounds access).

Change-Id: I340ab5799fa53d5345edb02f3e2a3655527705c0
Related: OS#4388
2020-02-19 18:23:40 +07:00
Harald Welte 053bebc7ce osmo-sim-test: Fall-back to classic SIM
If selection of ADF_USIM fails, let's fall-back to reading/dumping
a classic TS 11.11 (51.011) SIM card.

Change-Id: I5a986fc65de76c24c5af52ce7e8c699cf302fda9
2020-02-15 19:04:43 +01:00
Harald Welte 3a1a3bb887 osmo-sim-test: Recurse through subdirectories
Don't just iterate over all files in the current working
directory (cwd), but also recurse through all sub-directories.

Change-Id: I737b01d9a845e37d8be9d4709ef0de04e749daec
2020-02-15 18:59:19 +01: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
Pau Espin cc0b5d527d value_string: Switch val from unsigned to int
There's nothing really preventing a user from user negative values.

Otherwise if we keep it like this then g++ is not happy when passing eg.
{ -2, "foobar" } when initializing a value_string array.

Change-Id: I754fa7e054cb89801ef82edc82199dcfbe59c6ab
2020-02-04 15:22:19 +00: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
Philipp Maier 7497b417a7 l1sap: add measurement related struct members
In order to dissolve info_meas_ind_param in ph_data_param and
ph_tch_param we need to add the measurement related struct members to
ph_data_param and ph_tch_param as well so that those indications can
also carry measurement data.

Change-Id: I2c34b02d329f9df190c5035c396403ca0a4f9c42
Related: OS#2977
2020-01-07 22:26:01 +00:00
Neels Hofmeyr b82cc772eb jenkins.sh: simpler invocation of verify_value_string_...
The script
osmo-ci/scripts/verify_value_string_arrays_are_terminated.py
is able to find .c/.h files in directory trees by itself.

Shorten the cmdline invocation of this script for libosmocore.

Change-Id: I888c20b9b19d777cd6581a541536842292f434b9
2020-01-07 22:18:56 +00: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
Pau Espin 2862f9082e Bump version: 1.2.0.108-c6a8-dirty → 1.3.0
Change-Id: I5698bfe45467a8b0e44549105aaf27b8da500de8
2020-01-02 18:42:30 +01:00
Pau Espin dddeaa9868 Drop empty file debian/patches/series
Change-Id: I1a4aa5d6785aa7ff7dc454930a84d73fe1114726
2020-01-02 18:35:50 +01:00
Pau Espin 5d39e05bf4 osmo-release.sh: Improve of PKG_CHECK_MODULES from configure.ac
Remove brackets and check for "(" after PKG_CHECK_MODULES to avoid
getting comments containing the keyword.

Change-Id: Ie2b9a65d42615aa3cce6906ddd53758bc3052942
2020-01-02 18:33:26 +01:00
Harald Welte c6a8697800 Introduce helper functions for safe fork+exec of processes
In some situations, we want to execute an external shell command
in a non-blocking way.  Similar to 'system', but without waiting for
the child to complete.  We also want to close all file descriptors
ahead of the exec() and filter + modify the environment.

Change-Id: Ib24ac8a083db32e55402ce496a5eabd8749cc888
Related: OS#4332
2019-12-17 13:49:28 +01:00
Harald Welte 22c7ec3b60 debian/control: Add missing libusb-1.0-0-dev dependency
In Change-Id I656a1a38cbb5b1f3a9145d2869d3b4d0adefcae3 we introduced
USB support and also updated debian pacakaging informatio for this
new package - however, I missed to add a realted Build-Depends line :(

Change-Id: Ib0446510c8ba49623914b6103ea9cfa88c208d50
Related: #4299
2019-12-17 13:49:28 +01:00
Harald Welte d462e3fa7b usb: Import a variety of libusb utility functions from simtrace
Those functions were originally developed as part of simtrace; let's
import them to libosmousb as they are truly generic.

Change-Id: I2c18b938e4e1ea5b8a521a386f00db3a7389e47a
Related: OS#4299
2019-12-16 00:17:27 +01:00
Harald Welte da432cdc35 libosmocore libusb integration
Osmocom applications typically use libosmocore select.[ch] event loop
code as their main event dispatch mechanism.  When they want to deal
with libusb in a non-blocking/asynchronous way, they need to integrate
libusb into that select().

The new libosmousb is doing exactly that: Providing a shared utility
library for Osmocom programs that wish to use libusb.  This is useful
for example in simtrace2 host utilitie as well as osmo-e1d.

Change-Id: I656a1a38cbb5b1f3a9145d2869d3b4d0adefcae3
Closes: OS#4299
2019-12-16 00:17:27 +01:00
Harald Welte 7d0fe2ae6f gprs_bssgp: Work around gcc-9 claiming "error=stringop-overflow"
gcc-9.2.1 issues the following errror when compiling with -Werror:

In function ‘tl16v_put’,
    inlined from ‘tvlv_put’ at ../../include/osmocom/gsm/tlv.h:156:9,
    inlined from ‘tvlv_put’ at ../../include/osmocom/gsm/tlv.h:147:24,
    inlined from ‘msgb_tvlv_put’ at ../../include/osmocom/gsm/tlv.h:223:9,
    inlined from ‘bssgp_tx_paging’ at gprs_bssgp.c:1250:2:
../../include/osmocom/gsm/tlv.h:131:2: error: ‘memcpy’ reading between 128 and 65535 bytes from a region of size 9 [-Werror=stringop-overflow=]
  131 |  memcpy(buf, val, len);
      |  ^~~~~~~~~~~~~~~~~~~~~

Unfortunately I've not been able to work around it with some nice GCC
	#pragma GCC diagnostic ignored "-Wstringop-overflow"

Change-Id: I22a0c399c6c00eaf87277002096a82844c9e198e
2019-12-15 21:56:39 +01:00
Oliver Smith a47d37c946 debian, utils: switch to python 3
Make build and external tests work with python3, so we can drop
the python2 dependency.

This should be merged shortly after osmo-python-tests was migrated to
python3, and the jenkins build slaves were (automatically) updated to
have the new osmo-python-tests installed.

Related: OS#2819
Depends: osmo-python-tests I3ffc3519bf6c22536a49dad7a966188ddad351a7
Change-Id: I84ef43f700e125c7a65f92347f12844e07e65655
2019-12-12 09:24:04 +00:00
Vadim Yanitskiy 87b51439c1 core/defs.h: introduce and use OSMO_DEPRECATED_OUTSIDE
The new OSMO_DEPRECATED_OUTSIDE macro is similar to the existing
OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE, but allows to override the
deprecation message.

Let's use it to suspend deprecation warnings related to:

  - gsm48_decode_bcd_number(),
  - osmo_ecu_fr_conceal(),
  - osmo_ecu_fr_reset(),

as they're intentionally used in scope of the library.

Change-Id: I1b0eff1396776900c1286e41da3aee3ff78b326e
2019-12-11 12:42:05 +00:00
Eric Wild 94cd4acef8 sim: allow opening reader# > 0
Change-Id: I4b1abc8d8aae4bd9a32f927269d7ebfef902d7c5
2019-12-09 12:54:43 +01:00