aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2018-03-02features: move bts feature related functionality to libosmocorePhilipp Maier5-1/+95
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-01gsm23003_test: fix: compare members instead of bcmpNeels Hofmeyr1-1/+3
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-01introduce GSM_MCC_MNC_INVALIDNeels Hofmeyr1-0/+4
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-01timer: Document osmo_gettimeofday APIPau Espin Pedrol1-1/+17
Change-Id: I1f9e13645033c61ffaed97e457deb5e78a6bec58
2018-03-01timer: Introduce osmo_clock_gettime to override clock_gettimePau Espin Pedrol8-4/+255
Change-Id: I5bebc6e01fc9d238065bc2517058f0ba85620349
2018-02-28gsm: add osmo_mnc_from_str(), osmo_mnc_cmp(), osmo_plmn_cmp() for 3-digit MNCNeels Hofmeyr5-0/+157
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-28gsm0408_test: add test cases for MNC with leading zerosNeels Hofmeyr2-0/+149
Change-Id: I9b387e09293a6bbef84b9620ccf21ee2f9ec751c
2018-02-28gsm0408_test: test new gsm48_{decode,generate}_lai2() functionsNeels Hofmeyr2-0/+50
Change-Id: I4c8492b8055803d2857f1ef30aede088778b085b
2018-02-28gsm0408_test: check for new mnc_3_digits flagNeels Hofmeyr2-4/+5
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-28implement support for 3-digit MNC with leading zerosNeels Hofmeyr15-75/+277
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-27core/logging.h: Add logging category for jitter bufferPau Espin Pedrol2-1/+7
Forthcoming jitter buffer code in libosmo-netif will make use of it. Change-Id: I2434f9dfa401f736bc62a2ddce920e587cd8c517
2018-02-27l1sap: Add fields for higher-precision timing offset valuesHarald Welte1-2/+8
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-27l1sap: Add RSSI, BER and quarter-bit accurate timing to PH-RACH.indHarald Welte1-0/+4
Let's extend PH-RACH.ind with some useful data across the L1SAP boundary. Change-Id: I9439810c3a3ad89ea0302753617b850749af887c Related: OS#3003
2018-02-27core: Add timespec helper macros and make timer_compat.h publicPau Espin Pedrol2-1/+45
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-26ensure VTY commands don't segfault if an FSM has no event namesStefan Sperling1-4/+8
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-26print BIG FAT ERROR message if osmo_fsm lacks event namesStefan Sperling3-4/+13
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-26coding: Add BER-reporting RACH decode functionsHarald Welte4-8/+54
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-24rate_ctr: Add rate_ctr_inc2() as convenience wrapperHarald Welte1-0/+9
rate_ctr_inc2() is slightly easier to use than the old rate_ctr_inc() variant. Change-Id: Ie00706be201c32ec2981ea38b70354ed85e1aefd
2018-02-23ensure that osmo_fsm vty commands are only installed onceStefan Sperling1-0/+12
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-22Revert "Add function to encode classmark"Harald Welte3-18/+0
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 3c38e60cd55814a7b4c34f22e0b2e6e671f883c4. Change-Id: Icfc52ca4e5cbe3a444d98037d27fa101e3614e06
2018-02-22ports.h: Add VTY and CTRL ports for osmo-trxPau Espin Pedrol2-0/+5
Change-Id: Ib79cdb62d45d8c78445c7b064e58eb7e9faeccf9
2018-02-22gsm0408_test: also test gsm48_generate_lai() and gsm48_decode_lai()Neels Hofmeyr2-0/+53
Change-Id: Idd6cee090464bc92b654332904a9a08edf16e5c9
2018-02-22gsm0408_test: RA test: include min/max value casesNeels Hofmeyr2-0/+22
(Preparation for adding 3-digit MNC) Change-Id: Ifbc167de0cc039858112677b8d0cd14a2c8af086
2018-02-22gsm0408_test: include BCD and leading zeros in test outputNeels Hofmeyr2-5/+8
(Preparation for adding 3-digit MNC) Change-Id: I7f8ae05fa3e4a6fc004212757b05ca8a14c9ef45
2018-02-20gsm0408_test: cosmetically re-order MCC to come before MNCNeels Hofmeyr2-7/+7
For consistency in human readability, MCC simply should come first, always. Change-Id: Idb86a7088fac4d8a8c41190ab46f9801635f4eee
2018-02-20cosmetic: gsm0408_test: RA test cases as array-of-structNeels Hofmeyr1-8/+12
(Preparation for adding 3-digit MNC) Change-Id: Ic6c645ebf82d5f8d9d51c4c4cc804a0172008156
2018-02-19contrib/jenkins_arch.sh: Fix script comparison and arm supportDaniel Willmann1-3/+3
Change-Id: Ic53a675963cae328b296b4abaed9524451153271
2018-02-19fsm: allow graceful exit on FSM terminationPhilipp Maier3-2/+16
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-16memleak: _gsmtap_raw_output(): free msg in case of vsnprintf failureNeels Hofmeyr1-1/+3
Don't just return, free the allocated msg first. Change-Id: I51431ae7baca33ce5bab085cc3efe25f1a10b6d1
2018-02-16memleak: fix all libosmocore callers of gsmtap_sendmsg() to free on failureNeels Hofmeyr2-2/+8
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-16memleak: gsmtap_sendmsg(): don't return 0 when no data was writtenNeels Hofmeyr1-1/+1
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-16gsmtap_sendmsg(): clarify API doc concerning msgb ownershipNeels Hofmeyr1-0/+3
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-15fsm: Add a function to change the FSM instance ID laterDaniel Willmann2-6/+27
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-15Add function to encode classmarkMax3-0/+18
The code is based on Osmocom-BB implementation. Change-Id: I78f6968edaa3ed535673411fb2a80060a472290f
2018-02-15Add generic Mobile Identity encoderMax3-14/+19
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-15Add test for gsm48_generate_mid_from_imsi()Max2-0/+14
Change-Id: Ibe5c0831268c788ceecd10fd7b22ece6480da817
2018-02-14talloc_ctx_vty: Fix help strings (missing \n at end of line)Harald Welte1-3/+3
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-14build: Ensure all .pc files are installedMartin Hauke1-1/+1
Change-Id: I824e63087021adfda81bd0f867a3fdb5e9efcf7a
2018-02-14gsmtap.h: define TETRA DMO mode channelsallesklar21-0/+5
Change-Id: I98976c0ff16a69b2508a79259ed1aeaec51e7549
2018-02-13Add helper functions for ACC bit flags in rach control IE.Stefan Sperling1-2/+43
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-09Add GSM 04.08 type-of-number / numbering-plan-id definitionsHarald Welte1-0/+22
Change-Id: Idd8d8a7a1c7f0b6cb9318e4f19ebadb415df2ed1
2018-02-09debian/control: Fix Vcs-Browser URLHarald Welte1-1/+1
Change-Id: I89bff8fcb8e0b7c0a0e415d4eee1636c21b8f8de
2018-02-09osmo_msgbdump_{l2,l3}(): Proper typecastHarald Welte1-2/+2
This avoids compiler warnings like /tmp/work/sysmobts_v2-poky-linux-gnueabi/osmo-pcu/0.4+gitAUTOINC+4c112dc5a6-r1.18/recipe-sysroot/usr/include/osmocom/core/msgb.h: In function 'const char* msgb_hexdump_l2(const msgb*)': error: invalid conversion from 'void*' to 'const unsigned char*' [-fpermissive] return osmo_hexdump(msgb_l2(msg), msgb_l2len(msg)); which we've been getting in osmo-pcu builds on some platforms. Change-Id: I0ec652a1a569ec1507d8411cf1ef87afabcca799
2018-02-09Revert "fsm: do not terminate child FSMs early"Harald Welte1-4/+3
This reverts commit 5ec91980ac2224aa1e9bf070a0e382d0d8c2b729. More or less like I expected, it creates fall-out. osmo-msc master builds are failing, as are the open build service builds. The patch has therefor *not* been sufficiently tested. Change-Id: I8d961d7bbd91b6a8d7691f24cb67720c3d001c7e
2018-02-09Revert "Use python 3 for utilities"Harald Welte3-3/+3
This reverts commit 76c6c50405c6cbb1d08bdd7b5d27c657fa5d38b6, which broke the obs builds. I'm really starting to get annoyed by ongoing python related breakage without ever fixing any bugs! Change-Id: I4d76e897d4f746ff9ea4e06f2efc708a12cc2944
2018-02-09fsm: do not terminate child FSMs earlyPhilipp Maier1-3/+4
The function _osmo_fsm_inst_term() terminates all child FSMs befor it calls fi->fsm_cleanup(). This prevnts the cleanup callback to perform last actions on the child FSMs (e.g. osmo_fsm_inst_unlink_parent()). move the function call to _osmo_fsm_inst_term_children() below the call to fi->fsm->cleanup(). Change-Id: Ie89d435417306c6bf897274eabc3ed0a46485c26
2018-02-09msgb: Add msgb_hexdump_{l2,l3}() to dump l2 or l3 part of message bufferHarald Welte1-0/+14
Change-Id: I98e85397fb541ee0fd711f2e1852f63f3bb87359
2018-02-09tlv_parser: Report *first* occurrence of repeated IEsHarald Welte1-2/+7
Most GSM related specifications require the receiver to use the *first* occurrence of repeated IEs. The Osmocom TLV parser so far did the opposite: It reported only the *last* occurrence in case of repeated IEs. Let's change our implementation to be more in-line with relevant specs, such as 3GPP TS 24.008 8.6.3. Change-Id: Icde09e075f68c842a7a96cf7160c8e44b77cf82d
2018-02-08tests: utils_test: Fix test failure when compiling with -O0Pau Espin Pedrol1-0/+1
It seems with default flags in_buf was being memzeroed by the compiler. When compiling with -O0, that's not the case anymore and printf prints after first 16 bytes, printing extra garbage which doesn't match the expected output. Change-Id: I736c1e4d625f647d3bb794fa717256e9dbf36e87
2018-02-08tests: coding_test: Fix compilation with -O0Pau Espin Pedrol1-2/+2
inline keyword is a hint for the compiler to inline the function, but it's not mandatory. If no static or extern is specified, the definition is only visible in the current unit but the identifier still has external linkage. When running with -O0 it seems the compiler (gcc 7.2.1) decides to use the external linkage but at the same time it seems it's not generating the function symbol. Fix it by explicitly stating that we want to use static linking for this function. coding/coding_test.o: In function `test_xcch': libosmocore/tests/coding/coding_test.c:86: undefined reference to `dump_ubits' libosmocore/tests/coding/coding_test.c:87: undefined reference to `dump_sbits' Change-Id: I18018adec05ce1c2ddbca38653311d74c7454ce8