summaryrefslogtreecommitdiffstats
path: root/include/osmocom/gsm
Commit message (Collapse)AuthorAgeFilesLines
* gsm_08_08: correct speech codec defaultsPhilipp Maier2018-03-231-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
* abis_nm: Introduce abis_nm_dump_foh()Harald Welte2018-03-171-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
* support for more cell ID list types in libosmocoreStefan Sperling2018-03-134-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
* 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
* 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
* features: move bts feature related functionality to libosmocorePhilipp Maier2018-03-021-0/+43
| | | | | | | | | | | | | | | 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
* 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
* gsm: add osmo_mnc_from_str(), osmo_mnc_cmp(), osmo_plmn_cmp() for 3-digit MNCNeels Hofmeyr2018-02-281-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
* implement support for 3-digit MNC with leading zerosNeels Hofmeyr2018-02-283-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
* 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
* Revert "Add function to encode classmark"Harald Welte2018-02-221-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
* Add function to encode classmarkMax2018-02-151-0/+1
| | | | | | The code is based on Osmocom-BB implementation. Change-Id: I78f6968edaa3ed535673411fb2a80060a472290f
* Add generic Mobile Identity encoderMax2018-02-151-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
* Add helper functions for ACC bit flags in rach control IE.Stefan Sperling2018-02-131-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
* Add GSM 04.08 type-of-number / numbering-plan-id definitionsHarald Welte2018-02-091-0/+22
| | | | Change-Id: Idd8d8a7a1c7f0b6cb9318e4f19ebadb415df2ed1
* GSUP: change osmo_gsup_encode() return typeMax2018-02-051-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
* gsm48_hdr_msg_type(): SS is in the same group as MM/CCHarald Welte2018-02-031-1/+1
| | | | Change-Id: I1ddadeacced9650885f454b81f3f0df531ea1e5d
* gsm48_hdr_msg_type[_r99]: Fix bit-masksHarald Welte2018-02-031-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
* gsm_04_08.h: Reduce T310 default to 30s.Harald Welte2018-01-271-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
* gsm_04_08.h: Clearly annotate timers that don't have a 3GPP Default valueHarald Welte2018-01-271-7/+7
| | | | Change-Id: I44fffaec1f7c0d819aa2ebc85e97f19581fc689c
* SMS: Add value_string for TS 04.11 CP and RP stateHarald Welte2018-01-242-0/+11
| | | | Change-Id: I1b2f6fc6f455b0ba2a5732c567a4867bca97c3b0
* MNCC: Add MNCC to string dumperHarald Welte2018-01-191-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
* gsm0480: fix USSD OCTET STRING length confusionVadim Yanitskiy2018-01-171-2/+22
| | | | | | | | | | | | | | | | | | | | | | According to the GSM 04.80 (version 5.0.0) specification Annex A "Expanded ASN.1 Module "SS-Protocol", the maximum size of a USSD OCTET STRING is 160 bytes. Thus according to ETSI TS 123 038 (version 10.0.0) specification 6.1.2.3 "USSD packing of 7 bit characters", in 160 octets, it's possible to pack (160 * 8) / 7 = 182.8, that is 182 characters. The remaining 6 bits are set to zero. This change defines both mentioned values: - GSM0480_USSD_OCTET_STRING_LEN 160 - GSM0480_USSD_7BIT_STRING_LEN 182 keeping the old MAX_LEN_USSD_STRING 'as is' due to compatibility reasons. Now the new value is used for ss_request structure, while old one is still used for deprecated ussd_request structure. Change-Id: I6dead74f9ecea079752ff2400cdaf7c30187784e
* Deprecate gsm48_construct_ra()Max2018-01-121-1/+1
| | | | | | | | It's just a tiny wrapper around gsm48_encode_ra() with less strict type signature. Related OS#1640 Change-Id: I79d6d1133afbf32e891a6b0e3a244c6885ea9614
* gsm: add gsm0808_speech_codec_type_namesNeels Hofmeyr2018-01-121-0/+5
| | | | | | | Used for logging Speech Codec List entries in osmo-bsc, during handover decision. Change-Id: Ie6418d16db333188e9bcd2b32b7216f277ae8832
* Add function to properly encode RAIMax2018-01-081-0/+1
| | | | | | | | | | | | | Add gsm48_encode_ra() which takes appropriate struct as [out] parameter instead of generic buffer. Using uint8_t buffer instead of proper struct type prooved to be error-prone - see Coverity CID57877, CID57876. Old gsm48_construct_ra() is made into tiny wrapper around new function. The test output is adjusted because of the change in function return value which was constant and hence ignored anyway. Related: OS#1640 Change-Id: I31f9605277f4945f207c2c44ff82e62399f8db74
* Fix incorrect spec referenceMax2018-01-041-1/+1
| | | | | | RAI is defined in 3GPP TS 24.008 ยง 10.5.5.15 Change-Id: I484485d8c4c56b58dfecc1193bcdd48e61957422
* tlv_put: guard against NULL val and 0 lenNeels Hofmeyr2017-11-201-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | For example encode_auth_info() from gsup.c calls msgb_tlv_put(msg, iei, 0, NULL) to put a tag and len with content data following later. However, this would cause a memcpy() from a NULL pointer, in tlv_put(). Allow passing NULL and len = 0 for cases like the above: If val is NULL, use memset(0) instead of memcpy(). If len is zero, do not copy nor memset anything. Hence make tlv_put() behave in a well-defined and valid way for any and all input args; no negative fallout is possible from this patch. Add proper API doc comment. Fixes a sanitizer build failure in gsup_test: ../../../../src/libosmocore/include/osmocom/gsm/tlv.h:99:2: runtime error: null pointer passed as argument 2, which is declared to never be null Helps fix sanitizer build on debian 9. Change-Id: I13dce9cd1228817890d3e81edeeb660c893c1d64
* Fix/Update copyright notices; Add SPDX annotationHarald Welte2017-11-133-9/+12
| | | | | | | | Let's fix some erroneous/accidential references to wrong license, update copyright information where applicable and introduce a SPDX-License-Identifier to all files. Change-Id: I39af26c6aaaf5c926966391f6565fc5936be21af
* abis_nm: Add abis_nm_admin_name() APIPau Espin Pedrol2017-10-231-0/+7
| | | | | | | | | Similar APIs exist for opstate and availability status. This patch does not break backward compatibility because osmo-bsc still requires direct use of the structure in get_string_value(). Change-Id: Ieace734aaff3f07606113feddde65b75202d96d6
* [doc] Properly define gsm0800 group and move all related files into itHarald Welte2017-10-172-2/+10
| | | | Change-Id: I91920c69c86d6a1932172becacb76faff2d3eb1e
* [doc] Properly define 'oap' group and add introductory textHarald Welte2017-10-171-2/+11
| | | | Change-Id: I1e875991ae1dd93862f850f85d40b3dac61ece72
* [doc] Define 'gsup' group with proper name, add intro textHarald Welte2017-10-171-2/+19
| | | | Change-Id: Ieee6213dc5aad082a2d439c7418b51f281b80b1a
* [doc] make sure all SMS related code is part of the 'sms' groupHarald Welte2017-10-174-4/+20
| | | | Change-Id: I24c56ccb56d5b39cfb887808f91b715da54c0f8b
* [doc] gea has separate group; A5 is not part of crypto but a5 groupHarald Welte2017-10-172-4/+7
| | | | Change-Id: I2fd24c86f9b52244073ec800a3287e3d38e660d9
* [doc] TLV parser has far grown beyond GSM L3Harald Welte2017-10-161-1/+1
| | | | | | Let's hence not call the group "GSM L3 compatible TLV parser" Change-Id: Ic53f9c0d5ee787f994f42cf2aff313c6e131fbe6
* [doc] Rename "RSL" to "A-bis RSL" in documentation.Harald Welte2017-10-161-1/+1
| | | | | | | We also have "A-bis OML" and it's a bit odd to have one with prefix and the other without. Change-Id: Ida325f8a9c40b40c1aeaa4edfd1123ced7cc92b8
* Add function to generate random identifierMax2017-10-091-0/+5
| | | | | | | | | | | | | | | | | The function is a wrapper on top of getrandom() (if available via glibc) or corresponding syscall. If neither is available than failure is always returned. It's intended to generate small random data good enough for session identifiers and keys. To generate long-term cryptographic keys it's better to use special crypto libraries (like GnuTLS for example) instead. As an example it's used to replace old insecure random number generator in osmo-auc-gen utility. Change-Id: I0241b814ea4c4ce1458f7ad76e31d390383c2048 Related: OS#1694
* add osmo_imsi_str_valid() and osmo_msisdn_str_valid()Neels Hofmeyr2017-10-052-0/+5
| | | | | | | | | Add GSM23003_IMSI_MIN_DIGITS definition. Add regression test gsm23003_test.c to test the two new functions. Will be used by OsmoHLR to validate VTY and CTRL input. Change-Id: I1e94f5b0717b947d2a7a7d36bacdf04a75cb3522
* tlv: add [msgb_]t16lv_put() for 16bit tag + 8 bit len TLVsHarald Welte2017-08-091-1/+20
| | | | | | | | | | | In the Protocol Configuration Options IE (see 3GPP TS 24.008 10.5.6.3) there is yet another new TLV format (derived from PPP IPCP/LCP/...) which uses 16bit tag and 8bit length. Let's add functions so we can generate related TLVs. Parsing is unfortunately not possible in our existing structure as our tlv_parsed array only has 256 entries and thus cannot cope with 16bit tags. Change-Id: I9799130e2eba8fae8c4480fbb8a900c30232b694
* GSUP: define default GSUP port as 4222Neels Hofmeyr2017-07-221-0/+2
| | | | | | | | | | | See also: https://osmocom.org/projects/cellular-infrastructure/wiki/Port_Numbers https://gerrit.osmocom.org/#/c/3195/2/include/openbsc/osmo_msc.h@13 (change-id I639544a6cdda77a3aafc4e3446a55393f60e4050) Change-Id: I4222e21686c823985be8ff1f16b1182be8ad6175
* extend osmo_sysinfo_type with missing SYSINFO_TYPEHarald Welte2017-07-151-1/+6
| | | | | | The list should now be complete up to Releae 14 Change-Id: I693cabe1a3b00a8c4198f7a4a1c647c5d7dc6c41
* LC15: Add IPAC Directed Retry Enquiry data structureMinh-Quang Nguyen2017-07-141-0/+7
| | | | Change-Id: I8d2746eefe1f22dba5b19636ebc9444e458fc802
* IPAC manufacture-defined measurement pre-processing definitionsMinh-Quang Nguyen2017-07-141-0/+122
| | | | Change-Id: Ie1853697f4cff5ff98654fa1cae6c68e28a0076b
* utils: add function gsm_fn_as_gsmtime_str()Philipp Maier2017-07-111-0/+3
| | | | | | | Convert a given frame number into a printable string that displays the sub components of the frame number. Change-Id: I8015d2ded3940b01b35df7b72fc35c70c25e9926
* gsm_04_08.h: Add struct for 9.1.13b GPRS suspension requestHarald Welte2017-07-101-0/+8
| | | | Change-Id: I90113044460a6c511ced14f588876c4280d1cac7
* gsm_utils: Add osmo_dump_gsmtimePau Espin Pedrol2017-07-101-0/+3
| | | | | | Used by osmo-bts, moved from osmo-bts l1sap.c:dump_gsmtime. Change-Id: Ib5452e2c20f53006c0f6d197fb055728947125d8
* gsm_04_08/sgsn: Add another IE for internal usage in the sgsnHolger Hans Peter Freyther2017-07-091-0/+1
| | | | | | | | | The PDP charging characteristics will be returned from the PDP selection code and be used in the SGSN. It is following the same approach as the QoS and PDP addr. It is a bit of a pity that we have to define this in a different project. Change-Id: I7815c5dfd7b7fb0ea78d816ebfb3abfbf0090afe
* gsup: Add encoding/decoding for the pdp charging characteristicsHolger Hans Peter Freyther2017-07-071-0/+8
| | | | | | | | These fields can be in the ISD and the PDP Context inofmration. Store pointers to this IE in both cases. It needs to be used by the SGSN when opening a PDP context. Change-Id: Iedc7c02adcf77ca5c9545119e19c968dfbbb3e6b