Commit Graph

2675 Commits

Author SHA1 Message Date
Neels Hofmeyr 09ecbb7674 configure: add --enable-werror
Provide a sane means of adding the -Werror compiler flag.

Currently, some of our jenkins.sh add -Werror by passing 'CFLAGS="-Werror"',
but that actually *overwrites* all the other CFLAGS we might want to have set.

Maintain these exceptions from -Werror:
a) deprecation (allow upstream to mark deprecation without breaking builds);
b) "#warning" pragmas (allow to remind ourselves of errors without breaking
   builds)

As a last configure step before generating the output files, print the complete
CFLAGS and CPPFLAGS by means of AC_MSG_RESULT.

Change-Id: Ic5c8e68b64cd890b3309b4b26c7f22bde1edba83
2018-03-13 00:00:30 +00:00
Vadim Yanitskiy 10959cdea2 src/msgb.c: avoid using internal talloc API
An internal symbol '_talloc_zero' of talloc library was used
during a msgb allocation. This is not actually good because:

  - it may be removed or modified by talloc developers;
  - the behaviour may be changed by talloc developers;
  - it's marked as internal using 'underscore';
  - there is public API to do the same.

So, let's use the public API.

Change-Id: I1080c9071e997944cc0f9fc3716129e9395437ad
2018-03-09 04:14:31 +07:00
Vadim Yanitskiy b42330516f src/msgb.c: print an error if msgb allocation failed
Printing an error message when msgb allocation failed was initially
intended, but have been commented out for years. This would
facilitate the bug hunting process, especially on embedded
platforms with limited resources (e.g. amount of RAM).

The GLOBAL logging subsystem with FATAL level is used
for printing such messages.

Change-Id: I3e2d1beabd6936fc28a1ad664c083ff1698bb644
2018-03-09 04:07:51 +07:00
Vadim Yanitskiy 68b1e8e99c src/msgb.c: remove dead includes from OpenBSC
The MSGB API is not a part of OpenBSC anymore, so let's remove
dead includes, which were probably left here during the
migration process.

Change-Id: Ief562a6e5b220a84902f95862d67279f953ee726
2018-03-08 21:14:47 +07:00
Vadim Yanitskiy 8c8e6d7e53 src/msgb.c: cosmetic: fix spelling mistakes
Change-Id: I6b473aadaa22d95f2a8cc87580c638ccd7e531a4
2018-03-08 21:10:23 +07:00
Philipp Maier bf86d71f58 features: define osmo_bts_*_feature() as static inline
The functions osmo_bts_set_feature() and osmo_bts_has_feature() are
currently defined as inline. Since inline is a hinting, the compiler
might choose not to inline the function. This eventually leads to
linker problems because the function is then defined multiple times.

- use "static inline" instead of "inline" only.

This patch is a follow up patch to
Change Id 680acae725

Change-Id: Iddd97415a17b06b69f69ddca2e2e296eb2f23a89
2018-03-05 17:37:46 +00:00
Pau Espin 075299db7c osmo-release.sh: Set correct version when generating the changelog
Otherwise, while updating osmo-trx 0.2.0->0.3.0, the version printed in
the changelog by gbp dch is 0.2.1

Change-Id: I744adb23b4602e5e47f80a012286578d1e59de88
2018-03-05 16:52:43 +01:00
Neels Hofmeyr 4d68fd0955 gsm23003: add osmo_mcc_from_str()
I found myself often using osmo_mnc_from_str() to also decode an MCC and be
strict about it, but each time I felt the need to comment like "using
osmo_mnc_from_str() also for MCC". Rather formalize this properly.

Use a static inline function, no need to add more symbols to libosmo-gsm.

Change-Id: I020a4f11791c61742a3d795f782805f7b7e8733e
2018-03-05 04:28:04 +01:00
Neels Hofmeyr 20f7d0ecb4 fix osmo_mnc_from_str(): don't try to parse NULL
In osmo_mnc_from_str() do not try to return some values even if the validation
fails; hence don't try to decode a NULL pointer. That whole idea was half-baked
and a can of worms to begin with.

Change-Id: Ibaaa128ac60b941a015a31134eb52aef56bc6e22
2018-03-05 04:27:40 +01:00
Philipp Maier 680acae725 features: move bts feature related functionality to libosmocore
osmo-bsc and osmo-bts share enums and value strings to describe
feature data that is exchanged via OML (manufacturer id) on startup.
Also the functions to set and get the respecitive bits in the feature
bitvectors are in osmo-bsc and osmo-bts. This is a code duplication
and should be resolved.

- add enum osmo_bts_features (replaces enum gsm_bts_features)
- add osmo_bts_features_descs (replaces gsm_bts_features_descs)
- add osmo_bts_set_feature (replaces gsm_btsmodel_set_feature)
- add osmo_bts_has_feature (replaces gsm_btsmodel_has_feature)

Change-Id: Id0c35aef11aa49aa40abe7deef1f9dbd12210776
2018-03-02 16:54:16 +01:00
Neels Hofmeyr 5b8b8c62b4 gsm23003_test: fix: compare members instead of bcmp
In certain builds (for me a build with no -O2 flag) the recently added
gsm23003_test test_mnc_from_str() fails, because bcmp() compares all bytes of
sizeof(struct test_mnc_from_str_result), which has valid data for 7 bytes plus
one padding byte that may contain arbitrary values. Instead of bcmp(), rather
compare the actual members one by one.

Change-Id: I28b28457c7b0462c950612fd9b87b5c7181d8bad
2018-03-01 19:34:37 +01:00
Neels Hofmeyr ccfc387fb9 introduce GSM_MCC_MNC_INVALID
In some cases, we want to mark an unset MCC-MNC. Define uint16-max for this
purpose.

osmo-bsc code is already doing so with a -1 and using int data types, which
will become inconvenient with the new API that handles MCC and MNC as uint16_t.

Change-Id: Ieee7add0bd6d94cf84743a49794bbcd38561b72f
2018-03-01 13:00:56 +00:00
Pau Espin 8d82780358 timer: Document osmo_gettimeofday API
Change-Id: I1f9e13645033c61ffaed97e457deb5e78a6bec58
2018-03-01 12:33:03 +00:00
Pau Espin 87fade88bd timer: Introduce osmo_clock_gettime to override clock_gettime
Change-Id: I5bebc6e01fc9d238065bc2517058f0ba85620349
2018-03-01 12:33:02 +00:00
Neels Hofmeyr 721aa6ded9 gsm: add osmo_mnc_from_str(), osmo_mnc_cmp(), osmo_plmn_cmp() for 3-digit MNC
osmo_mnc_from_str() preserves leading zeros in the string and is useful for
VTY config parsing (osmo-bsc, osmo-msc, osmo-sgsn, osmo-pcu).

osmo_{plmn,mnc}_cmp() takes care of the slight intricacy of ignoring the 3-digit flag
if the MNC is anyway >99. Will be used by osmo-sgsn.git and osmo-bsc.git.  (All
current users just care about identical MNC, but a proper cmp doesn't hurt.)

Change-Id: Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6
2018-02-28 19:26:43 +01:00
Neels Hofmeyr 6c7b3e21d6 gsm0408_test: add test cases for MNC with leading zeros
Change-Id: I9b387e09293a6bbef84b9620ccf21ee2f9ec751c
2018-02-28 19:26:43 +01:00
Neels Hofmeyr 4566f4e79d gsm0408_test: test new gsm48_{decode,generate}_lai2() functions
Change-Id: I4c8492b8055803d2857f1ef30aede088778b085b
2018-02-28 19:26:43 +01:00
Neels Hofmeyr dbb25132d7 gsm0408_test: check for new mnc_3_digits flag
Note that on the input side, the 3-digits flag may be left false when the MNC
is >99 anyway. On the decoded side, the flag is set accurately.

Change-Id: I89765613d8c5bd939a6957f7443ac88475f1b93c
2018-02-28 19:26:43 +01:00
Neels Hofmeyr c4fce1425e implement support for 3-digit MNC with leading zeros
Enable representing three-digit MNC with leading zeros. The MNCs 23 and 023 are
actually different; so far we treated both as 23. Re-encode an incoming BCD or
string of 023 as it were, i.e. not dropping the leading zero as 23.

Break ABI compatibility by changing the size and ordering of structs
gprs_ra_id, osmo_plmn_id, osmo_cell_global_id, ... by adding an mnc_3_digits
flag.

Change ordering in gprs_ra_id because the canonical oder is {Mobile Country
Code, Mobile Network Code}, so have the mcc member first.

ABI compatibility cannot be maintained for struct gprs_ra_id, since it is a
direct member of structs bssgp_bvc_ctx and bssgp_paging_info, and even just
adding a flag to the end would cause ABI changes of those structs. Similarly,
osmo_plmn_id is a direct member of osmo_location_area_id, and so forth.

Add new API to set and read this additional flag to preserve leading zeros:
- osmo_plmn_to_bcd(), osmo_plmn_from_bcd() after
  gsm48_mcc_mnc_to_bcd() and gsm48_mcc_mnc_from_bcd().
- gsm48_decode_lai2(), gsm48_generate_lai2() after
  gsm48_decode_lai(), gsm48_generate_lai().
- gsm0808_create_layer3_2() after gsm0808_create_layer3() and gsm0808_create_layer3_aoip().
- various osmo_*_name() functions in gsm23003.h (osmo_rai_name() still in
  gsm48.h close to struct gprs_ra_id definition). The amount and duplication of
  these may seem a bit overboard, but IMO they do make sense in this way.
  Though most code will soon see patches unifying the data structures used, in
  some cases (vty, ctrl) they are required singled out. Without these
  functions, the formatting ("%0*u", mnc_3_digits ?  3 : 2, mnc) would be
  duplicated all over our diverse repositories.

In various log output, include the leading MNC zeros.

Mark one TODO in card_fs_sim.c, I am not sure how to communicate a leading zero
to/from a SIM card FS. The focus here is on the core network / BSS.

To indicate ABI incompatibility, bump libosmogsm and libosmogb LIBVERSIONs;
adjust debian files accordingly.

Implementation choices:

- The default behavior upon zero-initialization will be the mnc_3_digits flag
  set to false, which yields exactly the previous behavior.

- I decided against packing the mnc with the mnc_3_digits field into a
  sub-struct because it would immediately break all builds of dependent
  projects: it would require immediate merging of numerous patches in other
  repositories, and it would make compiling older code against a newer
  libosmocore unneccessarily hard.

Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
2018-02-28 19:26:33 +01:00
Pau Espin 8fd85578bc core/logging.h: Add logging category for jitter buffer
Forthcoming jitter buffer code in libosmo-netif will make use of it.

Change-Id: I2434f9dfa401f736bc62a2ddce920e587cd8c517
2018-02-27 21:11:27 +00:00
Harald Welte 38c902b776 l1sap: Add fields for higher-precision timing offset values
So far, we used quarter-bits across the L1SAP between the hardware/PHY
specific part of OsmoBTS and the common part.  In order to increase
the resolution, let's add fields/members for 1/256th bit.

In order to keep ABI and API compatibility, we use a union around the
old and new values, so old code will still compile + work withe new
libosmocore.

Change-Id: Ibb58113c2819fe2d6d23ecbcfb8b3fce4055025d
2018-02-27 17:30:08 +01:00
Harald Welte a57f90c80b l1sap: Add RSSI, BER and quarter-bit accurate timing to PH-RACH.ind
Let's extend PH-RACH.ind with some useful data across the L1SAP
boundary.

Change-Id: I9439810c3a3ad89ea0302753617b850749af887c
Related: OS#3003
2018-02-27 17:13:04 +01:00
Pau Espin 726ba36201 core: Add timespec helper macros and make timer_compat.h public
If a monotonic clock must be used, then the clock_gettime API is used
which uses timespec structures. Linux systems by default don't provide
helpers to calculate time using timespecs, so let's add them here.

Let's also make this header public so these helpers can be used in other
projects using libosmocore (expected user: libosmo-netif).

Change-Id: I45fc993b9bb0a343763238bf463c8640f47b00f1
2018-02-27 15:44:29 +00:00
Stefan Sperling cc81722736 ensure VTY commands don't segfault if an FSM has no event names
If no event names are defined for an FSM, show a placeholder
message which points out the problem instead of segfaulting.

Change-Id: I87457945a7b76aa052305c9c531722be1ea0c1d1
Related: OS#3007
2018-02-26 19:01:10 +00:00
Stefan Sperling 888dc7d31a print BIG FAT ERROR message if osmo_fsm lacks event names
Event names are displayed in VTY commands so all FSM should have them.
Print an error message if an FSM is registered without event names.
We could also return an error code, however at present no caller checks
the return value of osmo_fsm_register() so this would be pointless.

Add event names to the test FSM and update expected output accordingly.

Change-Id: I08b100d62b5c50bf025ef87d31ea39072539cf37
Related: OS#3008
2018-02-26 19:00:23 +00:00
Harald Welte 6950b191e8 coding: Add BER-reporting RACH decode functions
For all other decode operations we report the BER, but not for the
RACH.  This results in osmo-bts-trx not being able to report BER
to the higher layers, which is possible on other BTS backends.

Let's close this gap by introducing gsm0503_rach_ext_decode_ber()
and gsm0503_rach_decode_ber() with the usual n_errors / n_bits_total
arguments.

Change-Id: I2b1926a37bde860dcfeb0d613eb55a71271928c5
2018-02-26 12:26:38 +01:00
Harald Welte 175a4ae93a rate_ctr: Add rate_ctr_inc2() as convenience wrapper
rate_ctr_inc2() is slightly easier to use than the old
rate_ctr_inc() variant.

Change-Id: Ie00706be201c32ec2981ea38b70354ed85e1aefd
2018-02-24 14:46:35 +01:00
Stefan Sperling 218c4de84f ensure that osmo_fsm vty commands are only installed once
There is a desire to install osmo_fsm vty commands automatically in
a library context, rather than requiring every application which
directly or indirectly uses osmo_fsm to run osmo_fsm_vty_add_cmd().

However, the function install_element_ve() asserts that elements
about to be installed have not already been installed.

This means we cannot shift responsibility into a library context
without first making sure that osmo_fsm commands are only installed
once per combined application+library context, because applications
won't know which commands any of its libraries has already installed.

A simple solution is to use a global flag which is checked by
osmo_fsm_vty_add_cmd() before installing osmo_fsm commands, and
is set once the commands have been installed. This way, no harm
is done if osmo_fsm_vty_add_cmd() is called multiple times.

Change-Id: I10b0b1c1c1bf44c3b8eafc465c1ee06ea2590682
Related: OS#2967
2018-02-23 11:55:54 +01:00
Harald Welte 92decf2aa9 Revert "Add function to encode classmark"
This breaks all existing / older osmocom-bb builds, and hence
cannot be accpeted. See also https://gerrit.osmocom.org/#/c/6679

Related: OS#2985

This reverts commit 3c38e60cd5.

Change-Id: Icfc52ca4e5cbe3a444d98037d27fa101e3614e06
2018-02-22 16:17:41 +01:00
Pau Espin 98a7a2646b ports.h: Add VTY and CTRL ports for osmo-trx
Change-Id: Ib79cdb62d45d8c78445c7b064e58eb7e9faeccf9
2018-02-22 08:03:06 +00:00
Neels Hofmeyr d5a577b043 gsm0408_test: also test gsm48_generate_lai() and gsm48_decode_lai()
Change-Id: Idd6cee090464bc92b654332904a9a08edf16e5c9
2018-02-22 06:04:41 +01:00
Neels Hofmeyr b9fd7eba15 gsm0408_test: RA test: include min/max value cases
(Preparation for adding 3-digit MNC)

Change-Id: Ifbc167de0cc039858112677b8d0cd14a2c8af086
2018-02-22 06:04:14 +01:00
Neels Hofmeyr c38b32dde9 gsm0408_test: include BCD and leading zeros in test output
(Preparation for adding 3-digit MNC)

Change-Id: I7f8ae05fa3e4a6fc004212757b05ca8a14c9ef45
2018-02-22 06:01:58 +01:00
Neels Hofmeyr 0bf93a6482 gsm0408_test: cosmetically re-order MCC to come before MNC
For consistency in human readability, MCC simply should come first, always.

Change-Id: Idb86a7088fac4d8a8c41190ab46f9801635f4eee
2018-02-20 22:06:56 +01:00
Neels Hofmeyr 22da145e4c cosmetic: gsm0408_test: RA test cases as array-of-struct
(Preparation for adding 3-digit MNC)

Change-Id: Ic6c645ebf82d5f8d9d51c4c4cc804a0172008156
2018-02-20 22:05:50 +01:00
Daniel Willmann f4cd228f1e contrib/jenkins_arch.sh: Fix script comparison and arm support
Change-Id: Ic53a675963cae328b296b4abaed9524451153271
2018-02-19 08:34:30 +00:00
Philipp Maier d1f5793b5e fsm: allow graceful exit on FSM termination
The function _osmo_fsm_inst_term() terminates all child FSMs befor
it calls fi->fsm_cleanup(). This prevents the cleanup callback to
perform last actions on the child FSMs (e.g.
osmo_fsm_inst_unlink_parent()).

- Since moving the cleanup callack to the beginning of the function
  would alter the termination behavior and possibly cause malfunction
  in already existing implementation that use OSMO fsm, a new
  optional callback that is called immediately at the beginning of
  the terminatopn process is added.

Change-Id: I0fdda9fe994753f975a658c0f3fb3615949cc8bb
Closes: OS#2915
2018-02-19 08:30:21 +00:00
Neels Hofmeyr 4a8a9f4210 memleak: _gsmtap_raw_output(): free msg in case of vsnprintf failure
Don't just return, free the allocated msg first.

Change-Id: I51431ae7baca33ce5bab085cc3efe25f1a10b6d1
2018-02-16 01:35:08 +01:00
Neels Hofmeyr a4952aa436 memleak: fix all libosmocore callers of gsmtap_sendmsg() to free on failure
gsmtap_sendmsg() does not free the msgb if it returns a failure rc, so the
callers must check the rc and free the msg.

Change-Id: I7cf64ed9b14247298ed8b4ab8735627f8235a499
2018-02-16 01:34:26 +01:00
Neels Hofmeyr 90539ac30b memleak: gsmtap_sendmsg(): don't return 0 when no data was written
If less than the msgb size was written by write(), we want to return -EIO.
Hence do not return zero when write() wrote zero bytes, return -EIO in that
case as well.

Previously, if write() returned zero, gsmtap_sendmsg() would return zero
*without* freeing the msg, hence neither would the (ideal) caller. So this
fixes a corner-case memleak.

Change-Id: I099ae1c663c018da5db884f7e9d52c45af3ed817
2018-02-16 01:33:35 +01:00
Neels Hofmeyr c9a4ce600a gsmtap_sendmsg(): clarify API doc concerning msgb ownership
Not freeing on error does enable callers to try to re-send as well, so it is a
kind of useful feature, even though I find it likely for callers to either
forget about freeing the msg on error or double-free by accident...

I considered changing gsmtap_sendmsg() to always free, but since it is public
API, I chose to keep and document its current behavior properly instead. We
don't know what callers may exist out there.

Change-Id: Id3266ce36442024f16eaf6afa3f516d201930c41
2018-02-16 01:29:37 +01:00
Daniel Willmann b0c43a6063 fsm: Add a function to change the FSM instance ID later
Sometimes we want to create an FSM instance before we know its name. In
that case we should be able to update the id later.

Change-Id: Ic216e5b11d4440f8e106a297714f4f06c1152945
2018-02-15 18:03:58 +00:00
Max 3c38e60cd5 Add function to encode classmark
The code is based on Osmocom-BB implementation.

Change-Id: I78f6968edaa3ed535673411fb2a80060a472290f
2018-02-15 16:14:19 +01:00
Max ebf149234e Add generic Mobile Identity encoder
Add generic function which allows caller to set Mobile Identity
explicitly. This allows to use IMEI or IMEISV for example. Make
gsm48_generate_mid_from_imsi() into wrapper around new function.

Change-Id: Id79be7abfff75ecd0d248bbeed93e605abeec9b3
2018-02-15 11:44:33 +01:00
Max d55d7d4fc7 Add test for gsm48_generate_mid_from_imsi()
Change-Id: Ibe5c0831268c788ceecd10fd7b22ece6480da817
2018-02-15 11:44:33 +01:00
Harald Welte 408a90093b talloc_ctx_vty: Fix help strings (missing \n at end of line)
This was causing build failures in applications using this library
feature:

Documentation error (missing docs):
<command id='show talloc-context (application|all) (full|brief|DEPTH) tree ADDRESS'>
        <param name='ADDRESS' doc='(null)' />

Documentation error (missing docs):
<command id='show talloc-context (application|all) (full|brief|DEPTH) filter REGEXP'>
        <param name='REGEXP' doc='(null)' />

Documentation error (missing docs):
<command id='show talloc-context (application|all) (full|brief|DEPTH) tree ADDRESS'>
        <param name='ADDRESS' doc='(null)' />

Documentation error (missing docs):
<command id='show talloc-context (application|all) (full|brief|DEPTH) filter REGEXP'>
        <param name='REGEXP' doc='(null)' />

Change-Id: I785c852e3313d20eade79746a7cd485d2d5908ea
2018-02-14 00:53:22 +00:00
Martin Hauke 13e7f05611 build: Ensure all .pc files are installed
Change-Id: I824e63087021adfda81bd0f867a3fdb5e9efcf7a
2018-02-14 00:47:19 +00:00
allesklar2 eb18282031 gsmtap.h: define TETRA DMO mode channels
Change-Id: I98976c0ff16a69b2508a79259ed1aeaec51e7549
2018-02-14 00:41:33 +00:00
Stefan Sperling 1859515c69 Add helper functions for ACC bit flags in rach control IE.
Add inline functions to manipulate and query ACC flag bits
in the rach_control.t2 and rach_control.t3 octets.
These function definitions also serve as documentation of
the purpose of rach_control.t2/t3.

Change-Id: I8f0a65c2980f86eb5c43f3bebe727f4d4d973163
Related: OS#2591
2018-02-13 15:11:20 +01:00
Harald Welte 554780836f Add GSM 04.08 type-of-number / numbering-plan-id definitions
Change-Id: Idd8d8a7a1c7f0b6cb9318e4f19ebadb415df2ed1
2018-02-09 22:40:09 +01:00