summaryrefslogtreecommitdiffstats
path: root/include/osmocom
Commit message (Collapse)AuthorAgeFilesLines
* fix OSMO_SOCKADDR_STR_FMT for IPv6Neels Hofmeyr2019-11-111-2/+6
| | | | | | | | | | | | | The format prints IP:port separated by a colon, which of course is confusing when the IPv6 address itself contains mostly colons. The new format adds square braces. cafe:face::1:42 -> [cafe:face::1]:42 The IPv4 format remains unchanged: 1.2.3.4:42 Change-Id: I161f8427729ae31be0eac719b7a4a9290715e37f
* GPRS/BSSGP: introduce bssgp_bvc_ctx_free()Vadim Yanitskiy2019-11-091-0/+2
| | | | | | | | | | So far we had a function to allocate a new bssgp_bvc_ctx, but not the opposite one. Let's finally introduce it, so it will be used at least in OsmoPCU. Please note that the new symbol has 'bssgp_' prefix, not 'btsctx_'. Change-Id: Ia78979379dbdccd6e4628c16f00d0c06d9212172
* select: Make file descriptor lists per-threadHarald Welte2019-11-071-0/+1
| | | | | | | | | | In a multi-threaded environemnt, it's likely that each thread will have its own, distinct set of file descriptors that it wants to watch. Hence, let's make the osmo_fd_* functions configure not one global list of file descriptors, but a thread-local list of file descriptors. Change-Id: I5082ed3e500ad1a7516e1785bc57e008da2fac9a
* gsm: gsm_04_08.h: Allow accessing classmark2 as struct instead of uint32_tPau Espin Pedrol2019-11-041-5/+28
| | | | | | | New fields are put inside a union to keep backward compatibility with potential older users of the struct. Change-Id: I235635800c0de47b1e2b9ec9c7191418f6003554
* gsm: gsm_utils: Fix return type of API ms_class_gmsk_dbm() and add unit testsPau Espin Pedrol2019-11-041-2/+1
| | | | | | | | Only known user of API is in osmocom-bb and it compiles fine after the change. Related: OS#4244 Change-Id: Ia10345008b3aca50b30482ef3b852b03eca71995
* gsm: Fix compilation error under some compilersPau Espin Pedrol2019-11-042-2/+2
| | | | | | | | | | | | | | Some compilers don't like declaration of enums in header files like we do sometimes for structs: enum gsm_band; void foobar(enum gsm_band band); triggers: error: use of enum 'gsm_band' without previous declaration Fixes: b99f4ca2d8517d99cdf8aa183dbfda7b233bb781 Related: OS#4244 Change-Id: I6c2102c763f565bbe3c8dd7e5b4e04c4a45fff67
* gsm_04_08.h: Introduce API osmo_gsm48_rfpowercap2powerclass()Pau Espin Pedrol2019-11-031-1/+2
| | | | | Related: OS#4244 Change-Id: I32e9cc1c2397b44f0d48db2acdf782a821365b63
* add osmo_sockaddr_str_is_nonzero()Neels Hofmeyr2019-11-011-0/+1
| | | | | | | | | | | | | | | | | | | | | Often, an IP address of 0.0.0.0 is considered an unset value (for clients requiring a server address; not for listening on "any"). osmo_sockaddr_str_is_set() does return false when the port is 0, but there is no simple way to tell whether the IP address is actually set to a server address. Add osmo_sockaddr_str_is_nonzero() to return false if: - the port is zero, or - the IP address is zero (0.0.0.0 or ::0), or - the IP address cannot be parsed. A practical use example: osmo-msc so far accepts an RTP IP address of 0.0.0.0 as valid. I noticed when trying to trigger error handling from a ttcn3 test. osmo-msc can use this function to reject invalid addresses from MGCP messages. Related: I53ddb19a70fda3deb906464e1b89c12d9b4c7cbd (osmo-msc) Change-Id: I73cbcab90cffcdc9a5f8d5281c57c1f87b2c3550
* cosmetic: gsm_04_08.h: Fix trailing whitespacePau Espin Pedrol2019-11-011-3/+3
| | | | Change-Id: I4b34dbd5f0176d1d8aa8cc96f642ed35d4214b7e
* add osmo_fsm_set_dealloc_ctx(), to help with use-after-freeNeels Hofmeyr2019-10-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a simpler and more general solution to the problem so far solved by osmo_fsm_term_safely(true). This extends use-after-free fixes to arbitrary functions, not only FSM instances during termination. The aim is to defer talloc_free() until back in the main loop. Rationale: I discovered an osmo-msc use-after-free crash from an invalid message, caused by this pattern: void event_action() { osmo_fsm_inst_dispatch(foo, FOO_EVENT, NULL); osmo_fsm_inst_dispatch(bar, BAR_EVENT, NULL); } Usually, FOO_EVENT takes successful action, and afterwards we also notify bar. However, in this particular case, FOO_EVENT caused failure, and the immediate error handling directly terminated and deallocated bar. In such a case, dispatching BAR_EVENT causes a use-after-free; this constituted a DoS vector just from sending messages that cause *any* failure during the first event dispatch. Instead, when this is enabled, we do not deallocate 'foo' until event_action() has returned back to the main loop. Test: duplicate fsm_dealloc_test.c using this, and print the number of items deallocated in each test loop, to ensure the feature works. We also verify that the deallocation safety works simply by fsm_dealloc_test.c not crashing. We should probably follow up by refusing event dispatch and state transitions for FSM instances that are terminating or already terminated: see I0adc13a1a998e953b6c850efa2761350dd07e03a. Change-Id: Ief4dba9ea587c9b4aea69993e965fbb20fb80e78
* gsm0508: add functions to calculate beginning of a blockPhilipp Maier2019-10-281-0/+12
| | | | | | | | | | | The calculation of the beginning of a block for TCH/F, TCH/H and FACCH can be challenging since those channels are affected by the diagonal interleaving of the TCH channels. However, GSM 05.02 Section 7 Table 1 of 5 specifies how the blocks are distributed over the TDMA frame interval. Lets add a mapping function that is based on that table Related: OS#3803 Change-Id: I3d71c66f8c401f5afbad9b1c86c24580dab9e0ce
* socket: Introduce API osmo_sock_init2_multiaddr()Pau Espin Pedrol2019-10-181-0/+7
| | | | | | | | | This API will be used by libosmo-netif's osmo_stream for SCTP sockets, which in turn will be used by libosmo-sccp to support multi-homed connections. Related: OS#3608 Change-Id: Ic8681d9e093216c99c6bca4be81c31ef83688ed1
* logging: Introduce mutex API to manage log_target in multi-thread envsPau Espin Pedrol2019-10-091-0/+14
| | | | | | | | | | | | | | | | | | | | log_enable_multithread() enables use of locks inside the implementation. Lock use is disabled by default, this way only multi-thread processes need to enable it and suffer related complexity/performance penalties. Locks are required around osmo_log_target_list and items inside it, since targets can be used, modified and deleted by different threads concurrently (for instance, user writing "logging disable" in VTY while another thread is willing to write into that target). Multithread apps and libraries aiming at being used in multithread apps should update their code to use the locks introduced here when containing code iterating over osmo_log_target_list explictly or implicitly by obtaining a log_target (eg. osmo_log_vty2tgt()). Related: OS#4088 Change-Id: Id7711893b34263baacac6caf4d489467053131bb
* tdef: Introduce min_val and max_val fieldsPau Espin Pedrol2019-10-071-0/+6
| | | | | | | | | | | This is useful for timers expected to have a range of valid or expected values. Validation is done at runtime when timer values are set by the app or by the user through the VTY. Related: OS#4190 Change-Id: I4661ac41c29a009a1d5fc57d87aaee6041c7d1b2
* API doc tweaks (mncc.h, gsm_08_08.h)Neels Hofmeyr2019-10-042-5/+7
| | | | Change-Id: I9b4c7e737c83c65e358496e4540c14be5abc5474
* gsup: add OSMO_GSUP_SUPPORTED_RAT_TYPES_IE and OSMO_GSUP_CURRENT_RAT_TYPE_IENeels Hofmeyr2019-09-281-0/+7
| | | | | | | | | | | | | | OSMO_GSUP_SUPPORTED_RAT_TYPES_IE corresponds to the Supported RAT Types Indicator from 3GPP TS 29.002. See 8.1.2 MAP_UPDATE_LOCATION service, which indicates the capabilities of the MSC/VLR to the HLR. So far, have room for eight RAT types in the gsup_msg. That is an arbitrary random choice without any rationale. OSMO_GSUP_CURRENT_RAT_TYPE_IE is useful to communicate the currently used RAN / RAT type of the current subscriber during Location Updating Request. Change-Id: I93850710ab55a605bf61b95063a69682a2899bb1
* msgb: Allow size==headroom in msgb_alloc_headroom*()Pau Espin Pedrol2019-09-261-2/+2
| | | | | | | | | Nothinh really forbids this case, it's totally fine allocating all space of msgb as headroom. osmo-pcu actually does that in gprs_rlcmac_ul_tbf::snd_ul_ud(). Related: OS#4029 Change-Id: Ibe05d08e3169a2603e891f76682a3b352a93ec7a
* logging: Move extern declaration of osmo_log_target_list from logging.h to ↵Pau Espin Pedrol2019-09-202-1/+1
| | | | | | | | | logging_internal.h This list is really not needed by applications and currently only used internally in logging.c and logging_vty.c. Change-Id: I5dca069512bfcd0826194427c5482fad8bfd0232
* ecu_fr: increase test coverage for FR ECU implementationPhilipp Maier2019-09-201-2/+4
| | | | | | | | | | | | | The ECU implementation for FR is currently tested by calling the related functions directly and by using the generic ECU abstraction layer. However, the test "test_fr_concealment" only tests directly. Lets add a version that uses the generic ECU abstraction layer as well. The generic ECU abstraction layer obsolets the public API functions osmo_ecu_fr_reset() and osmo_ecu_fr_conceal(), lets tag those functions as dprecated. Change-Id: Ib0c8a9b164f14ea4fa00688f760a76cdb4890af4
* cosmetic: Add comment on GSM-FR ECU structPhilipp Maier2019-09-201-0/+1
| | | | Change-Id: Ic0a3a407c592262104af315f845f0bbd116ab26b
* cosmetic: Move comment to the right placePhilipp Maier2019-09-201-1/+1
| | | | Change-Id: I3d548fcc7d500baf37134b14af91bc7b284ce6ad
* logging.h: add L1 SAPI related context and filterOliver Smith2019-09-181-0/+2
| | | | | | | First user is osmo-bts in I6b7bb2e1d61502b61214f854a4ec5cbb7267545b. Related: OS#2356 Change-Id: I814cb3328d99faca9220adb5a80ffb934f219d7d
* logging_internal.h: Fix osmo_log_info definitionPau Espin Pedrol2019-09-171-1/+1
| | | | | | | | | Global symbol osmo_log_info is declared in logging.c as non-const, because it is modified. As soon as logging_internal.h is included into logging.c, the compiler warns about osmo_log_info being declared twice differently. Change-Id: Iea961c3caeb12ddf60c99d4dca644bb9ab538767
* tdef: fixup osmo_tdef_set()Neels Hofmeyr2019-09-111-1/+1
| | | | | | | | | | | | I missed code review, so here are my comments in form of a follow-up patch for Id56a1226d724a374f04231df85fe5b49ffd2c43c. - Fix 'as_unit' arg name to 'val_unit' as in the C file and API doc. - Explain rounding-up behavior of value conversion in API doc. - Use osmo_tdef_get_entry() instead of a loop. Related: OS#4190 Change-Id: Ia91c2f17e40fb9e79ffa5a7f28ce9c3605664402
* tdef_vty.h: Add missing header dependenciesPau Espin Pedrol2019-09-071-0/+3
| | | | | | | enum node_type is defined in osmocom/vty/command.h va_list is defined in stdarg.h Change-Id: Ia439a7097ae7a9765e229e5f66e07af3fe490ecc
* tdef: Introduce API osmo_tdef_set()Pau Espin Pedrol2019-09-071-0/+1
| | | | | | | | | This API is already useful for users willing to set a given timer to a given value. It will also contain code later that checks for value being inside valid range for that timer. Related: OS#4190 Change-Id: Id56a1226d724a374f04231df85fe5b49ffd2c43c
* Introduce BTS_FEAT_ETWS_PN for communicating ETWS PN capabilityHarald Welte2019-09-051-0/+1
| | | | | | | | | | As 3GPP doesn't specify how the BSC shall communicate ETWS Primary Notifications over Abis/RSL, we have to use a vendor-specific RSL message for this. And in order to know if the peer supports this feature, we introduces BTS_FEAT_ETWS_PN. Change-Id: I89c24a81ada6627694a9632e87485a61cbd3e680 Related: OS#4046, OS#4047
* gsm_08_58: Add vendor-specific Message Type for ETWS Primary WarningHarald Welte2019-09-051-0/+2
| | | | | Change-Id: I36fc2ffc22728887d1cb8768c7fcd9739a8ec0fc Related: OS#4046, OS#4047
* codec/ecu: Introduce new generic Error Concealment Unit abstractionHarald Welte2019-09-021-0/+54
| | | | | | | | | | | | | | | | | | | | We don't want to expose the details of a given ECU implementation to the user (e.g. osmo-bts), but have a generic abstraction layer where an ECU implementation can simply register a few call-back functions with the generic core. As the developer and copyright holder of the related code, I hereby state that any ECU implementation using 'struct osmo_ecu_ops' and registering with the 'osmo_ecu_register()' function shall not be considered as a derivative work under any applicable copyright law; the copyleft terms of GPLv2 shall hence not apply to any such ECU implementation. The intent of the above exception is to allow anyone to combine third party Error Concealment Unit implementations with libosmocore, including but not limited to such published by ETSI. Change-Id: I4d33c9c7c2d4c7462ff38a49c178b65accae1915
* cbsp: Fix endless loop iteration when decoding cell list IEsHarald Welte2019-08-311-0/+1
| | | | | | | | The CBSP code assumed that gsm0808_decode_cell_id_u() would return the number of bytes it has consumed/parsed. But it actually always returns '0', whcih makes us run in an endless loop :( Change-Id: I5758af4ec11a827d4b888a3a16c4ec22de90a7d6
* OSMO_SOCKADDR_STR_FMT_ARGS: guard against NULL pointerNeels Hofmeyr2019-08-301-1/+1
| | | | | | | The pointless '(R)->ip?' condition of the previous commit made me want to protect against R == NULL instead. Change-Id: Ie2f47ad8ae585aaf67a6476c67f8e014820a72bc
* OSMO_SOCKADDR_STR_FMT_ARGS: remove useless conditionNeels Hofmeyr2019-08-301-1/+1
| | | | | | | Since (R)->ip is a char[], it is always non-NULL. The (x ? : "") condition is completely pointless. Remove it. Change-Id: I13ed06776a784cfa99bbdfca2bb4dfe12913a1ec
* context: Add support for [per-thread] global talloc contextsHarald Welte2019-08-272-3/+26
| | | | | | | | | | Rather than having applications maintain their own talloc cotexts, let's offer some root talloc contexts in libosmocore. Let's also make them per thread right from the beginning. This will help some multi-threaded applications to use talloc in a thread-safe way. Change-Id: Iae39cd57274bf6753ecaf186f229e582b42662e3
* Cosmetic: l1sap.h: change /* !< to /*!<Oliver Smith2019-08-231-5/+5
| | | | Change-Id: Icaec95a9c6105fd17bc1151fdc77394f4efd3b70
* osmo_tdef_get(): allow passing -1 as default timeoutNeels Hofmeyr2019-08-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The intention of osmo_tdef_get()'s val_if_not_present argument was to return a default timeout, or to optionally abort the program for missing timer definitions if the default timeout is < 0. This was the case in the original implementation of this API in osmo-bsc, but in the migration to libosmocore, the argument was by accident changed to an unsigned type. In consequence, the assertion in the implementation that was intended to abort the program seemed bogus to coverity, and was fixed by removal in I7a544d2d43b83135def296674f777e48fe5fd80a -- the wrong direction, as is obvious from the API doc for osmo_tdef_get(). Note that osmo-bsc master passes -1 in various places and expects the program-abort behavior that was missing from the libosmocore implementation. Change the val_if_not_present argument to a signed type, and revert removal of the assertion, so that passing -1 has the effect described in the API doc: program abort on missing timer definition. This bug was not detected because it is hard to write tests that expect a program abort to happen, hence no tests for this API feature exist. Related: OS#4152 Change-Id: Ie61c3c85069916336e6dbd91a2c16f7634816417
* codec/ecu_fr: Mark input TCH frame as 'const' as we only read itHarald Welte2019-08-121-1/+1
| | | | Change-Id: I64c6d3dc08ff87b673ba6225f98546e86f91bcfd
* gsm/gsm48.h: drop meaningless 'const' from gsm48_mi_to_string()Vadim Yanitskiy2019-07-261-2/+1
| | | | Change-Id: I5eb17edadf89ac47b4ca86c9e822037f7c0e518e
* Add Cell Broadcast related definitions from 3GPP TS 23.041Harald Welte2019-07-201-0/+89
| | | | Change-Id: I1e2c62cb9047648907c91b99f764f6caba8f4493
* cbsp: Introduce osmo_cbsp_errstrHarald Welte2019-07-201-0/+2
| | | | | | | | | | | | | | Rather than having the encoder/decoder library print some log messages in case of encoding/decoding errors, let's provide something akin to 'errno', but with a string instead of a numeric error code. The 'osmo_cbsp_errstr' global variable (if set) contains a human-readable string describing the most recent encoding/decoding error. It exists separately for each thread and hence can be used safely in multi-threaded environments. Change-Id: Id9a5a595a76ba278647aee9470ded213d8464103
* CBSP (Cell Broadcast Service Protocol; 3GPP TS 48.049) supportHarald Welte2019-07-202-0/+420
| | | | | | | | | | This introduces definitions as well as a parser+encoder for the Cell Broadcast Service Protocol (CBSP) as specified in 3GPP TS 48.049. CBSP is used on the interface between CBC and BSC. Related: OS#3537 Change-Id: I5b7ae08f67e415967b60ac4b824db9e22ca00935
* libosmogsm/l1sap.h: extend ph_rach_ind_param with lqual_cbVadim Yanitskiy2019-07-101-0/+1
| | | | | | | | | | | | The link quality, defined by C/I (Carrier-to-Interference) ratio, can be computed from the training sequence of each burst, where we can compare the "ideal" training sequence with the actual training sequence and then express that in cB (centiBels, dB * 10). By analogy with both RSSI and ToA, it can be used to filter out false-positive detections and ghost Access Bursts. Change-Id: Ie2a66ebd040b61d6daf49e04bf8a84d3d64764ee
* Revert "utils.h: require a semi colon after OSMO_ASSERT"Vadim Yanitskiy2019-07-091-2/+2
| | | | | | | | | | | | | This reverts commit 4e284b637943980a405a8c44f2712b749ded428f. Unfortunately, some projects such as OsmoMSC, OsmoBTS and OpenBSC do contain OSMO_ASSERT statements without a semi colon. Thus, this change causes compilation errors when building them. Please note that only the OSMO_ASSERT's definition is reverted, while changes to other files (adding missing semicolons) are kept. Change-Id: I6da4d7397d993f6c1af658cb5ae1e49c92a1b350
* utils.h: require a semi colon after OSMO_ASSERTAlexander Couzens2019-07-081-2/+2
| | | | | | | | | When using `OSMO_ASSERT(exp);` clang will warn about an empty expression because the semi colon was superflous. Use do {} while (0) to enfore the need of a semi colon. This might break other test. Change-Id: I2272d29a81496164bebd1696a694383a28a86434
* add define for magic tmsi constantEric Wild2019-06-171-0/+1
| | | | Change-Id: I52b9f6b5f3e96d85a390ba2af21d7814df8aaeec
* (minor) fix typo in commentsKévin Redon2019-06-131-3/+3
| | | | Change-Id: I697af428a2ea9a0ccd3f04ba8ec4664935ae29f8
* minor: don't redefine macrosKévin Redon2019-06-132-0/+4
| | | | | | | | | | | the DEBUG macro name and ARRAY_SIZE macro function are frequently used in other projects. If these projects also use libosmocore, the macros will be redefined. This also generates a warning message during compilation. Not redefining the macros removes the warning message and possible (but unlikely) mis-redefinition. Change-Id: I0ba91eae8eacc5542d1647601b372e417ed1713c
* protocol/gsm_04_08.h: do not check if unsigned is positiveVadim Yanitskiy2019-06-121-3/+3
| | | | Change-Id: I6b486b52a3733d5fd5e8ba18acbc9374e2e8bd7e
* core/utils: drop meaningless const from return value of osmo_luhn()Vadim Yanitskiy2019-06-121-1/+1
| | | | Change-Id: I085da06f31a0a6862ae2ba041fafc134cc240f7e
* fsm: Allow millisecond granularity in osmo_fsm built-in timerHarald Welte2019-06-051-0/+15
| | | | | | | | | | | | | | | | | | | | | | | So far, the public API of osmo_fsm only allowed integral seconds as timeout. Let's change that to milli-seconds in order to cover more use cases. This introduces * osmo_fsm_inst_state_chg_ms() * osmo_fsm_inst_state_chg_keep_or_start_timer_ms() Which both work exactly like their previous counterparts without the _ms suffix - the only difference being that the timeout parameter is specified in milli-seconds, not in seconds. The value range for an unsigned long in milli-seconds even on a 32bit platform extends to about 48 days. This patch also removes the documentation notice about limiting the maximum value to 0x7fffffff due to time_t signed-ness. We don't use time_t but unsigned long. Change-Id: I35b330e460e80bb67376c77e997e464439ac5397
* lapdm: Allow user to specify T200 values; Use correct N200 valuesHarald Welte2019-06-051-3/+9
| | | | | | | | | | | | | | | | | | TS 04.06 specifies a N200 re-transmission counter that depends on the channel type, which we didn't care about at all so far. Let's have the caller tell us the channel type so we can internally look up the correct N200 value for it. At the same time, permit the user to specify T200 re-transmission timer values for each SAPI on both DCCH and ACCH, which is required at least in the BTS as per GSM TS 12.21. Also, extend the timer resolution of the API from seconds to milli-seconds, which is more applicable as particularly on the FACCH the recommended values are in the 200ms range. Change-Id: I90fdc4dd4720d4e02213197c894eb0a55a39158c Related: OS#3906 Related: OS#2294 Related: OS#4037