aboutsummaryrefslogtreecommitdiffstats
path: root/include
AgeCommit message (Collapse)AuthorFilesLines
2018-04-13add gsm0808_cell_id_list_add() to combine two cell identifier listsNeels Hofmeyr1-0/+1
This will be used by the upcoming neighbor_ident API in osmo-bsc, where the vty interface allows composing neihbor BSS cell identifier lists, and we want to allow adding individual items from individual user commands. It will also be useful to accumulate cell identifiers in case a subscriber sees multiple alternative cells from a neighboring BSS, and we want to pass these on to the MSC in a Handover Required. Related: OS#2283 (inter-BSC HO, BSC side) Change-Id: I5781f5fa5339c92ab2e2620489b002829d206925
2018-04-13add osmo_cgi_name()Neels Hofmeyr1-0/+2
This will be used by cell idenitifier list code, like upcoming neighbor_ident VTY in osmo-bsc and regression tests. Change-Id: Iebc5cdf61b697b1603900993fc265af3eca0cedf
2018-04-11msgb: msgb_pull: Abort when pulling more than avail sizePau Espin Pedrol1-0/+3
Change-Id: I512ff2035ae7a929e6c96df82938cc1ddbcc4e2a
2018-04-11msgb: msgb_get: Drop unneeded tmp varPau Espin Pedrol1-2/+1
Change-Id: I27bb2ab59408c9cd1363b3b5acb2263128c55732
2018-04-10deprecate PLMN de-/coding functions incapable of 3-digit MNC with leading zerosNeels Hofmeyr2-7/+12
All our projects have seen patches to move to 3-digit MNC handling. Furthermore, since our builds no longer break from deprecation warnings, I shall no longer refrain from deprecating old API. Change-Id: I55dfaf7ce74870de44120b26c42d45bb7b184341
2018-04-09fix issue on big endian architectureThorsten Alteholz1-1/+1
OSMO_IS_LITTLE_ENDIAN is always defined and has a value of either 0 or 1 as a result in byteswap.h the corresponding swap functions will be always called, independent of the endianess Signed-off-by: Thorsten Alteholz <osmocom@alteholz.de> Change-Id: I4a09d2d8ccf155e70a3977ae1747758b6bc5125e
2018-04-09add gsm48_reject_value_namesNeels Hofmeyr1-0/+4
There seems to be quite some confusion / overlap between enum gsm48_reject_value, gsm48_gsm_cause and gsm48_gmm_cause. I tried to go with gsm48_gsm_cause_names[], but e.g. GSM48_REJECT_CONGESTION is not represented. Instead of attempting to mix/merge those enums, provide a separate value string array for enum gsm48_reject_value. This will be used by osmo-msc's libvlr (refactoring of FSM result handling), I27bf8d68737ff1f8dc6d11fb1eac3d391aab0cb1. Change-Id: I6661f139e68a498fb1bef10c266c2f064b72774a
2018-04-09add osmo_fsm_inst_update_id_f()Neels Hofmeyr1-0/+1
In the osmo-msc, I would like to set the subscr conn FSM identifier by a string format, to include the type of Complete Layer 3 that is taking place. I could each time talloc a string and free it again. This API is more convenient. From osmo_fsm_inst_update_id(), call osmo_fsm_inst_update_id_f() with "%s" (or pass NULL). Put the name updating into separate static update_name() function to clarify. Adjust the error message for erratic ID: don't say "allocate", it might be from an update. Adjust test expectation. Change-Id: I76743a7642f2449fd33350691ac8ebbf4400371d
2018-04-09add osmo_quote_str(),osmo_quote_str_buf() and testNeels Hofmeyr1-0/+2
Rationale: with osmo_escape_str(), you get the escaped contents of the string, but not so graceful handling of NULL strings. The caller needs to quote it, and for NULL strings not quote it. osmo_quote_str() is like osmo_escape_str() but always quotes a non-NULL string, and for a NULL string returns a literal NULL, i.e. it should (tm) give the exact C representation of a string. That's useful in testing, to show exactly what char* situation we have, without jumping through hoops like if (str) printf("\"%s\"", osmo_escape_str(str, -1)); else printf("NULL"); Copy the unit test for osmo_escape_str() and adjust. To indicate that the double quotes are returned by osmo_quote_str(), use single quotes in the test printf()s. I considered allowing to pick the quoting characters by further arguments, but that complicates things: we'd need to escape the quoting characters. Just hardcode double quotes like C. Change-Id: I6f1b3709b32c23fc52f70ad9ecc9439c62b02a12
2018-04-05ctrl: fix deferred commands (and hence fix osmo-bts-sysmo 'clock-info' cmd)Neels Hofmeyr1-0/+3
The CTRL interface has a ctrl_cmd_def_* API that allows deferring a CTRL command reply until later. However, the command handling currently fails to acknowledge this and deallocates the struct ctrl_cmd anyway. Fix: in struct ctrl_cmd, add a defer pointer to be populated by ctrl_cmd_def_make(). A cmd thus marked as deferred is not deallocated at the end of command handling. This fix needs no change in calling code. (Another idea was to return a different code than CTRL_CMD_HANDLED when the command is to be deferred, but that would require adjusting each user of ctrl_cmd_def_make(). The implicit marking is safer and easier.) Show that handling deferred commands is fixed by adjusting the expectations of ctrl_test.c's test_deferred_cmd() and removing the now obsolete exit_early label. One symptom of the breakage is that osmo-bts-sysmo crashes when asked to report a trx's clock-info, which is aggravated by the fact that the sysmobts-mgr does ask osmo-bts-sysmo for a clock-info. The crash appears since Id583b413f8b8bd16e5cf92a8a9e8663903646381 -- it looked like just fixing an obvious memory leak, which it did as shown by the unit test, but deferred ctrl commands actually relied on that leak. Both fixed now. Related: OS#3120 Change-Id: I24232be7dcf7be79f4def91ddc8b8f8005b56318
2018-04-04gsm0480: copy the raw USSD data, its DCS and lengthVadim Yanitskiy1-0/+12
As it was already documented before, the 'ss_request' struct has a rudiment of deprecated 'ussd_request' struct - the 'ussd_text' field. It represents the data either of an INVOKE component, either of a RETURN_RESULT component, encoded as ASCII in case if DCS is 0x0f (i.e. decoded by the code itself), otherwise raw bytes 'as is'. Previously, there was no possibility to distinguish between ASCII and raw bytes with different DCS. Moreover, the payload decoding is not desired in some cases. Let's introduce the new fields, which will carry the raw unmodified payload, its length and DCS (Data Coding Scheme). Change-Id: Ia193d175021e145bb3b131290231f307dbefc64a
2018-04-04gsm0480: document the 'ss_request' structureVadim Yanitskiy1-0/+31
Change-Id: I22144dd759e0c1bb1965574b7ddd676606e5d6b7
2018-03-29gsm0808: Add value strings for BSSMAP cause codesPhilipp Maier1-0/+1
libosmocore has no value strings for BSSMAP cause codes yet. - Add value strings for BSSMAP cause codes and a function to retrieve them Change-Id: I313dd8d7b06374e1e35ddc18b7a42562d9e25d45 Related: OS#1609
2018-03-28fix logging talloc ctx: add osmo_init_logging2()Neels Hofmeyr1-1/+5
Deprecate osmo_init_logging() for the benefit of adding an explicit talloc context argument to new function osmo_init_logging2(). Pass a ctx to log_init() instead of hardcoded NULL. Before now, *all* of our code uses a NULL ctx for logging, which amounts to talloc "leaks" hit by address sanitizer builds on newer gcc (e.g. gcc 7.3.0 on debian 9). This commit helps fixing "leaks" detected in e.g. osmo-bsc unit tests by a sanitize build with gcc (Debian 7.3.0-12) 7.3.0. Change-Id: I216837780e9405fdaec8059c63d10699c695b360
2018-03-23gsm_08_08: correct speech codec defaultsPhilipp Maier1-4/+4
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
2018-03-17abis_nm: Introduce abis_nm_dump_foh()Harald Welte1-5/+3
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
2018-03-13support for more cell ID list types in libosmocoreStefan Sperling4-4/+46
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
2018-03-05features: define osmo_bts_*_feature() as static inlinePhilipp Maier1-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
2018-03-05gsm23003: add osmo_mcc_from_str()Neels Hofmeyr1-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
2018-03-02features: move bts feature related functionality to libosmocorePhilipp Maier2-0/+44
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-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: Introduce osmo_clock_gettime to override clock_gettimePau Espin Pedrol1-0/+6
Change-Id: I5bebc6e01fc9d238065bc2517058f0ba85620349
2018-02-28gsm: add osmo_mnc_from_str(), osmo_mnc_cmp(), osmo_plmn_cmp() for 3-digit MNCNeels Hofmeyr1-0/+5
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-28implement support for 3-digit MNC with leading zerosNeels Hofmeyr3-1/+23
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 Pedrol1-1/+2
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-26coding: Add BER-reporting RACH decode functionsHarald Welte1-2/+8
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-22Revert "Add function to encode classmark"Harald Welte1-1/+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-19fsm: allow graceful exit on FSM terminationPhilipp Maier1-0/+2
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-15fsm: Add a function to change the FSM instance ID laterDaniel Willmann1-0/+2
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 classmarkMax1-0/+1
The code is based on Osmocom-BB implementation. Change-Id: I78f6968edaa3ed535673411fb2a80060a472290f
2018-02-15Add generic Mobile Identity encoderMax1-0/+1
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-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-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-09msgb: Add msgb_hexdump_{l2,l3}() to dump l2 or l3 part of message bufferHarald Welte1-0/+14
Change-Id: I98e85397fb541ee0fd711f2e1852f63f3bb87359
2018-02-05GSUP: change osmo_gsup_encode() return typeMax1-1/+1
* match return type of osmo_gsup_encode() with osmo_gsup_decode() to allow propagating error to caller * check return value of osmo_gsup_encode() in GSUP test * return errors instead of braking app with aseert Change-Id: Idaa1deecb6d9e15329bd51867b4f6a03357461f0 Related: OS#2864
2018-02-05utils: add helper wrapper for osmo_strlcpy()Max1-0/+3
Add wrapper for osmo_strlcpy() which uses sizeof() to automatically determine buffer's size and use it for GSMTAP logging. This is pretty common use case for osmo_strlcpy() so it's a good idea to save some typing by using generic define. Related: OS#2864 Change-Id: I03d0d3d32a8d572ad573d03c603e14cdc27a3f7b
2018-02-03gsm48_hdr_msg_type(): SS is in the same group as MM/CCHarald Welte1-1/+1
Change-Id: I1ddadeacced9650885f454b81f3f0df531ea1e5d
2018-02-03gsm48_hdr_msg_type[_r99]: Fix bit-masksHarald Welte1-2/+2
TS 24.007 is quite clear: The upper two bits of the message type octet are *not* part of the message type in any of the L3 protocols which implement sequence numbers. it doesn't matter if it's R98 or R99, or whether the sequence number is 1bit or 2bits wide. Related: OS#2908 Change-Id: Iec875a77f5458322dfbef174f5abfc0e8c09d464
2018-01-27gsm_04_08.h: Reduce T310 default to 30s.Harald Welte1-1/+1
3GPP doesn't specify a network-side T310 default, but waiting for 180s (3 minutes!) for the next message after CALL CONFIRMED is clearly way too long and will just use radio resources for no good reason. Change-Id: Ia52f9358bc86b23c72af9c80e2fff5cb0004b57a Related: OS#2884
2018-01-27gsm_04_08.h: Clearly annotate timers that don't have a 3GPP Default valueHarald Welte1-7/+7
Change-Id: I44fffaec1f7c0d819aa2ebc85e97f19581fc689c
2018-01-24SMS: Add value_string for TS 04.11 CP and RP stateHarald Welte2-0/+11
Change-Id: I1b2f6fc6f455b0ba2a5732c567a4867bca97c3b0
2018-01-24fsm: add functions for unlinking and changing parentsPhilipp Maier1-0/+4
At the moment it is not possible to unlink a child from from its parent, nor is it possible to assign a new parent to a child FSM. - osmo_fsm_inst_unlink_parent(): Make it possible to unlink childs from a parent. - osmo_fsm_inst_change_parent(): Make it possible to change the parent of a child. Change-Id: I6d18cbd4ada903cf3720b3ad2a89fc643085beef
2018-01-19MNCC: Add MNCC to string dumperHarald Welte1-0/+9
As MNCC is rather hard to debug (wireshark cannot trace UNIX domain sockets), let's add our own decoder that we can use from related debug log statements in the respective programs. Change-Id: I216aaf70868ba5f3860a60c4b2442957531a3011