summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* show failure in gsm0808_enc_cell_id_list2() in gsm0808_testNeels Hofmeyr2018-03-231-4/+8
| | | | Change-Id: I763b18d2922701ad97382269747ff0cbb7bd657b
* gsm0808_test: cosmetic: test non-hex MCCNeels Hofmeyr2018-03-231-6/+6
| | | | | | | | | | | | | | | The test currently sets the MCC by a hex value, which is a weird choice. The MCC gets BCD'd and hence we will see the decimal values 1:1 in the encoded octets as hex digits. Using hex as input obscures that: Right now it sets mcc = 0x123, which is actually 291 in decimal, and we hence see "92 .1" in the expected BCD result. Using 0x124 in the test source actually makes it hard to see where the 0x123 went. Change the MCC to decimal notation (123, 124, 125) and adjust the expected encoded output. Change-Id: I973835c54a90fefe50d2b3581324d12556715f58
* gsm0808_test: cosmetic: re-arrange struct init; print hexdump on failureNeels Hofmeyr2018-03-231-24/+32
| | | | | | | | | | | I am going to ehance the test to actually include leading-zero MNC, but first I would like to simplify how the test source struct is initialized, before I edit around in it. Also, when the memcmp() fails, print hexdumps of expected and actual result for comparison. I needed it to figure out a test failure, might as well keep it. Change-Id: I77cd4b9142510c6914298b720d9c19ab68f9ebef
* gsm_08_08: correct speech codec defaultsPhilipp Maier2018-03-233-13/+13
| | | | | | | | | | | | The speech codec defaults are not correct. The defaults recommended in 3GPP TS 28.062, Table 7.11.3.1.3-2 are limited by 3GPP TS 48.008, Section 3.2.2.103. Some defaults are actually reserved for future use. Also the endianess of the 16 bit values is reversed. - correct values so that they match the specification - transmit bytes in the correct endianess Change-Id: I6c3a34d39a375d71c4128fd38f06629e8b98b100
* fsm: Update the name as well if the id is updated and accept NULLDaniel Willmann2018-03-192-14/+26
| | | | | | | | | If the name stays the same the log messages will still log with the old id. Since we can now change the id we need to update the name as well. NULL as id was allowed before so we should allow that as well. Change-Id: I6b01eb10b8a05fee3e4a5cdefdcf3ce9f79545b4
* abis_nm: Introduce abis_nm_dump_foh()Harald Welte2018-03-173-9/+15
| | | | | | | | This is a more modern way of printing the Abis OML Formatted Object Header, without assuming that it would be used in a log statement or prescribing the log level to be used. Change-Id: I9b2c2afec28882b817d104d5b062651ade7aadd8
* add a regression test for TLV parsing with repeated IEsStefan Sperling2018-03-162-2/+33
| | | | | | | | | | | | | Since commit bf383a1d83661af26ccd6521c49b655fb22531d4 tlv_parse() will return the first occurrence of a repeated IE. Add a test to verify this behaviour. This test passes with the current code and fails if bf383a1d83661af26ccd6521c49b655fb22531d4 is reverted. While here, fix lies in documentation about the return value of tlv_parse() and fix a typo in another comment. Change-Id: I041f38548c5e4236920991d6c681c1c1e04de9ca Related: OS#2904
* add a test for CELL_IDENT_WHOLE_GLOBAL cell identifier listsStefan Sperling2018-03-161-0/+61
| | | | | | | | | Add a regression test which encodes and decodes a cell identifier list of type CELL_IDENT_WHOLE_GLOBAL. Change-Id: Ie633d9e55c6a30555c0153d35aaf9f982d6e0088 Depends: If0fafbc7171da2a3044bfa9a167208a1afa1c07b Related: OS#2847
* fix parse_cell_id_lac_and_ci_list()Stefan Sperling2018-03-162-6/+49
| | | | | | | | | | | The implementation was entirely broken, reading data from wrong offsets and always writing to the first element of the decoded list. Also, add a new test for this function which found the problems. Change-Id: If0fafbc7171da2a3044bfa9a167208a1afa1c07b Related: OS#2847 Depends: Ife4e485e2b86c6f3321c9700611700115ad247b2
* fix bug in parse_cell_id_ci_list()Stefan Sperling2018-03-162-1/+36
| | | | | | | | | | | Cell ID lists with CI were misparsed because parse_cell_id_ci_list() failed to report the amount of consumed bytes to its caller. Also add a regression test which uncovered the bug. Change-Id: Ife4e485e2b86c6f3321c9700611700115ad247b2 Depends: If6b941720de33dca66b6b1aa2cb95a3275708b7f Related: OS#2847
* use gsm48_decode_lai2() in gsm0808_dec_cell_id_list()Stefan Sperling2018-03-152-9/+63
| | | | | | | | This makes gsm0808_dec_cell_id_list() properly decode 3-digit MNCs. Add a test which encodes/decodes a LAI_AND_LAC list with 3-digit MNCs. Change-Id: If6b941720de33dca66b6b1aa2cb95a3275708b7f Related: OS#2847
* fix cell identifier decoding in libosmocoreStefan Sperling2018-03-152-15/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The cell ID list decoder merged in 11a4d9dd91216fe353e94bfdbbab53bc4f891c0d has a bug which was introduced part-way through the review process in gerrit at https://gerrit.osmocom.org/#/c/6509/ When Neels suggested "why not just {...}id_list[MAXLEN] once?" I changed the cell identifier list from a union of arrays to an array of unions. After this change, elements smaller than the largest type in the union were not laid out consecutively in memory anymore. E.g. uint16_t lac values now occur at offsets of sizeof(id_list[0]) instead of offsets of sizeof(uint16_t). The problem is that I forgot to adjust the decoder accordingly, so the decoder writes to the wrong offsets and returns cell identifier lists which appear to contain uninitialized values when read back by API consumers. I found this problem while adding new regression tests to libosmocore to test encoding and decoding. This commit adds one such tests for LAC list decoding, which failed due to the above bug. I plan to write more tests, however because this first test already uncovered a severe issue I chose to submit a fix now and work on additional tests in later commits. Change-Id: Ie1a5a9d858226be578cf11a03cf996d509bd51fb Related: OS#2847
* fix a cell identifier parsing bug in libosmocoreStefan Sperling2018-03-141-2/+2
| | | | | | | | | | | | Global and LAI+LAC cell IDs were being misparsed due to an off-by-one. This code was incorrectly converted from osmo-bsc, where an additional offset of one byte was needed to skip the cell identifier field. In libosmocore, these parsing routines receive a buffer pointer which is already positioned at the start of the cell identifier field. Change-Id: I7f3e8ace26176e9cbfe2542961d2a95662aa4d97 Related: OS#2847
* support for more cell ID list types in libosmocoreStefan Sperling2018-03-138-34/+360
| | | | | | | | | | | | | | | | | | | | | | | | Introduce gsm0808_dec_cell_id_list2() with supports additional types of cell identifier lists. The new parsing routines are based on similar routines used by the paging code in osmo-bsc's osmo_bsc_bssap.c. Likewise, introduce gsm0808_enc_cell_id_list2() with support for the same additional types of cell identifier lists. The old API using struct gsm0808_cell_id_list is deprecated. The previous definition was insufficient because it assumed that all decoded cell ID types could be represented with a single uint16_t. It was declared in a GSM protocol header (gsm/protocol/gsm_08_08.h) despite being a host-side representation of data in an IE. The only user I am aware of is in osmo-msc, where this struct is used for one local variable. osmo-msc releases >= 1.1.0 make use of this API. While here, fix a small bug in a test: test_gsm0808_enc_dec_cell_id_list_bss() set the cell ID type to 'LAC' but obviously wants to use type 'BSS'. Change-Id: Ib7e754f538df0c83298a3c958b4e15a32fcb8abb Related: OS#2847
* jenkins_amd64.sh: use --enable-werror configure flag, not CFLAGSNeels Hofmeyr2018-03-131-1/+1
| | | | | | | Note that the jenkins_arm.sh passes various CFLAGS and potentially overwrites ./configure internal CFLAGS like that. I'm staying out of that for now. Change-Id: I81b50c39cd6e908c4c95651829b679425de87a28
* configure: add --enable-werrorNeels Hofmeyr2018-03-131-0/+21
| | | | | | | | | | | | | | | | | 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
* src/msgb.c: avoid using internal talloc APIVadim Yanitskiy2018-03-091-2/+4
| | | | | | | | | | | | | | 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
* src/msgb.c: print an error if msgb allocation failedVadim Yanitskiy2018-03-091-1/+3
| | | | | | | | | | | | 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
* src/msgb.c: remove dead includes from OpenBSCVadim Yanitskiy2018-03-081-3/+0
| | | | | | | | 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
* src/msgb.c: cosmetic: fix spelling mistakesVadim Yanitskiy2018-03-081-3/+3
| | | | Change-Id: I6b473aadaa22d95f2a8cc87580c638ccd7e531a4
* features: define osmo_bts_*_feature() as static inlinePhilipp Maier2018-03-051-2/+2
| | | | | | | | | | | | | | 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 680acae725b2b8dda2f239ff20073306fdfb3f6e Change-Id: Iddd97415a17b06b69f69ddca2e2e296eb2f23a89
* osmo-release.sh: Set correct version when generating the changelogPau Espin Pedrol2018-03-051-1/+1
| | | | | | | 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
* gsm23003: add osmo_mcc_from_str()Neels Hofmeyr2018-03-051-0/+11
| | | | | | | | | | 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
* fix osmo_mnc_from_str(): don't try to parse NULLNeels Hofmeyr2018-03-053-23/+21
| | | | | | | | 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
* features: move bts feature related functionality to libosmocorePhilipp Maier2018-03-025-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
* gsm23003_test: fix: compare members instead of bcmpNeels Hofmeyr2018-03-011-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
* introduce GSM_MCC_MNC_INVALIDNeels Hofmeyr2018-03-011-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
* timer: Document osmo_gettimeofday APIPau Espin Pedrol2018-03-011-1/+17
| | | | Change-Id: I1f9e13645033c61ffaed97e457deb5e78a6bec58
* timer: Introduce osmo_clock_gettime to override clock_gettimePau Espin Pedrol2018-03-018-4/+255
| | | | Change-Id: I5bebc6e01fc9d238065bc2517058f0ba85620349
* gsm: add osmo_mnc_from_str(), osmo_mnc_cmp(), osmo_plmn_cmp() for 3-digit MNCNeels Hofmeyr2018-02-285-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
* gsm0408_test: add test cases for MNC with leading zerosNeels Hofmeyr2018-02-282-0/+149
| | | | Change-Id: I9b387e09293a6bbef84b9620ccf21ee2f9ec751c
* gsm0408_test: test new gsm48_{decode,generate}_lai2() functionsNeels Hofmeyr2018-02-282-0/+50
| | | | Change-Id: I4c8492b8055803d2857f1ef30aede088778b085b
* gsm0408_test: check for new mnc_3_digits flagNeels Hofmeyr2018-02-282-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
* implement support for 3-digit MNC with leading zerosNeels Hofmeyr2018-02-2815-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
* core/logging.h: Add logging category for jitter bufferPau Espin Pedrol2018-02-272-1/+7
| | | | | | Forthcoming jitter buffer code in libosmo-netif will make use of it. Change-Id: I2434f9dfa401f736bc62a2ddce920e587cd8c517
* l1sap: Add fields for higher-precision timing offset valuesHarald Welte2018-02-271-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
* l1sap: Add RSSI, BER and quarter-bit accurate timing to PH-RACH.indHarald Welte2018-02-271-0/+4
| | | | | | | | Let's extend PH-RACH.ind with some useful data across the L1SAP boundary. Change-Id: I9439810c3a3ad89ea0302753617b850749af887c Related: OS#3003
* core: Add timespec helper macros and make timer_compat.h publicPau Espin Pedrol2018-02-272-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
* ensure VTY commands don't segfault if an FSM has no event namesStefan Sperling2018-02-261-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
* print BIG FAT ERROR message if osmo_fsm lacks event namesStefan Sperling2018-02-263-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
* coding: Add BER-reporting RACH decode functionsHarald Welte2018-02-264-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
* rate_ctr: Add rate_ctr_inc2() as convenience wrapperHarald Welte2018-02-241-0/+9
| | | | | | | rate_ctr_inc2() is slightly easier to use than the old rate_ctr_inc() variant. Change-Id: Ie00706be201c32ec2981ea38b70354ed85e1aefd
* ensure that osmo_fsm vty commands are only installed onceStefan Sperling2018-02-231-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
* Revert "Add function to encode classmark"Harald Welte2018-02-223-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
* ports.h: Add VTY and CTRL ports for osmo-trxPau Espin Pedrol2018-02-222-0/+5
| | | | Change-Id: Ib79cdb62d45d8c78445c7b064e58eb7e9faeccf9
* gsm0408_test: also test gsm48_generate_lai() and gsm48_decode_lai()Neels Hofmeyr2018-02-222-0/+53
| | | | Change-Id: Idd6cee090464bc92b654332904a9a08edf16e5c9
* gsm0408_test: RA test: include min/max value casesNeels Hofmeyr2018-02-222-0/+22
| | | | | | (Preparation for adding 3-digit MNC) Change-Id: Ifbc167de0cc039858112677b8d0cd14a2c8af086
* gsm0408_test: include BCD and leading zeros in test outputNeels Hofmeyr2018-02-222-5/+8
| | | | | | (Preparation for adding 3-digit MNC) Change-Id: I7f8ae05fa3e4a6fc004212757b05ca8a14c9ef45
* gsm0408_test: cosmetically re-order MCC to come before MNCNeels Hofmeyr2018-02-202-7/+7
| | | | | | For consistency in human readability, MCC simply should come first, always. Change-Id: Idb86a7088fac4d8a8c41190ab46f9801635f4eee
* cosmetic: gsm0408_test: RA test cases as array-of-structNeels Hofmeyr2018-02-201-8/+12
| | | | | | (Preparation for adding 3-digit MNC) Change-Id: Ic6c645ebf82d5f8d9d51c4c4cc804a0172008156