summaryrefslogtreecommitdiffstats
path: root/src/gsm
Commit message (Collapse)AuthorAgeFilesLines
* gsm: add osmo_mnc_from_str(), osmo_mnc_cmp(), osmo_plmn_cmp() for 3-digit MNCNeels Hofmeyr2018-02-282-0/+80
| | | | | | | | | | | 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-285-59/+241
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert "Add function to encode classmark"Harald Welte2018-02-222-17/+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-152-0/+17
| | | | | | The code is based on Osmocom-BB implementation. Change-Id: I78f6968edaa3ed535673411fb2a80060a472290f
* Add generic Mobile Identity encoderMax2018-02-152-14/+18
| | | | | | | | 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
* tlv_parser: Report *first* occurrence of repeated IEsHarald Welte2018-02-091-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
* GSUP: change osmo_gsup_encode() return typeMax2018-02-051-4/+9
| | | | | | | | | | * 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
* SMS: Add value_string for TS 04.11 CP and RP stateHarald Welte2018-01-243-0/+16
| | | | Change-Id: I1b2f6fc6f455b0ba2a5732c567a4867bca97c3b0
* gsm48_pdisc_names: Use conscise, short namesHarald Welte2018-01-241-15/+15
| | | | | | | Some times I *really* regret ever having merged OSMO_VALUE_STRING, as it generates completely unusable and way too long strings :( Change-Id: I8de7c01f9ea1d66c384e57449c4140186f5ce6c5
* MNCC: Add MNCC to string dumperHarald Welte2018-01-193-1/+420
| | | | | | | | 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: parse optional IEs for RELEASE COMPLETE messageVadim Yanitskiy2018-01-171-1/+5
| | | | | | | | According to GSM 04.80 section 2.5 "Release complete", a message of the mentioned type may contain optional IEs, such as Cause and Facility. Let's parse them. Change-Id: Ib8fc1f6bae472b0b264b6158f372b6cce255b222
* gsm0480: parse all SS info elements in a messageVadim Yanitskiy2018-01-171-1/+10
| | | | | | | Some SS messages (e.g. RELEASE COMPLETE) may contai multiple IEs (Information Elements). Let's parse them all. Change-Id: I20cc59c25fdbda176bcf76437174cda829518d60
* gsm0480: correct parse_ss_info_elements() declarationVadim Yanitskiy2018-01-171-1/+1
| | | | Change-Id: I64df293188908c7eb10a61941db76656340d3a8e
* gsm0480: refactor gsm0480_decode_ss_requestVadim Yanitskiy2018-01-171-7/+14
| | | | Change-Id: Iba734db97ab516f8fce816c4e4225b97b93619f1
* gsm0480: move SS request length check to parse_ss()Vadim Yanitskiy2018-01-171-12/+11
| | | | Change-Id: I8e7ce5bd97f3a8731924264c92afb9a7183937dc
* gsm0480: pass exact GSM 04.80 payload length to parse_ss()Vadim Yanitskiy2018-01-171-4/+4
| | | | Change-Id: I9608d4ad16d7581320615c140beaac36628c31a4
* gsm0480: add specification reference to SS message typeVadim Yanitskiy2018-01-171-0/+1
| | | | Change-Id: Iff0210e995053e270939a774db33f55b22545204
* gsm0480: handle GSM0480_OP_CODE_PROCESS_USS_DATAVadim Yanitskiy2018-01-171-0/+5
| | | | Change-Id: I470290c2b544555e53cedd849b1d6a961db7b5a4
* gsm0480: handle USS_NOTIFY and USS_REQUEST with PROCESS_USS_REQVadim Yanitskiy2018-01-171-0/+2
| | | | Change-Id: If7cc6a966dfc17d37e22338ecc1f239f908a9f2e
* gsm0480: handle GSM0480_CTYPE_RETURN_RESULTVadim Yanitskiy2018-01-171-0/+82
| | | | Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
* gsm0480: parse GSM0480_MTYPE_FACILITY separatelyVadim Yanitskiy2018-01-171-1/+17
| | | | Change-Id: I6e029c436a50fa8c2823ea39c5d123ee701becfa
* gsm0480: handle UnstructuredSS Request with DSC != 0x0FVadim Yanitskiy2018-01-171-0/+20
| | | | | | | | | | | According to GSM 04.08, 4.4.2 "ASN.1 data types": the USSD-DataCodingScheme shall indicate use of the default alphabet using the 0x0F value. Previously, the UnstructuredSS Request messages with not default alphabet were not being handled. Let's fix this. Change-Id: I73d602f6f20b0afe7600d16bbd432069ae7be788
* gsm0480: clean up the parse_process_uss_req() codeVadim Yanitskiy2018-01-171-19/+20
| | | | | | This change reduces the degree of code nesting... Change-Id: I467f75794c5ac9df75c001245b18bbdfcfaadd88
* gsm0480: fix USSD OCTET STRING length confusionVadim Yanitskiy2018-01-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | 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
* gsm0480: skip length check for 'RELEASE COMPLETE' messageSergey Kostanbaev2018-01-171-3/+10
| | | | | | | | According to GSM 04.80 Section 2.5 'Release complete' Table 2.5, the 'RELEASE COMPLETE' message payload is optional, so let's drop the length check in gsm0480_decode_ss_request() for this type. Change-Id: I63b7f8ce403169a9dbdbdb031db16693de2196d6
* Log lapd_datalink state on errorsMax2018-01-161-5/+5
| | | | | | | It's not very useful to get just the raw pointer address in case of lapd_datalink receive error. Log it's state in addition. Change-Id: Ie8c5df262312f886f509113f2707e36811df3bd5
* TLVP_PRESENT() should not return TRUE after tlv_parse() fails.Stefan Sperling2018-01-121-4/+10
| | | | | | | | | | | | If the length provided in the patcket exceeds the buffer length, tlv_parse() returns -2 but leaves tlv.val and tlv.len initializd. Many callers of tlv_parse() do not check its return value, but rely on TLVP_PRESENT() to see if a particular TLV was parsed successfully. By clearing tlv.val and tlv.len we make it less likely that those callers will use an overlong TLV length value. Change-Id: I4dda6938e1650b4bcaac45809a4763f86f5a9794
* gsm: add gsm0808_speech_codec_type_namesNeels Hofmeyr2018-01-122-0/+15
| | | | | | | Used for logging Speech Codec List entries in osmo-bsc, during handover decision. Change-Id: Ie6418d16db333188e9bcd2b32b7216f277ae8832
* Add function to properly encode RAIMax2018-01-082-20/+22
| | | | | | | | | | | | | 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
* add osmo_auth_c3() (separate from gsm_milenage())Neels Hofmeyr2017-12-183-3/+16
| | | | | | | | | | | | | | | To send a Ciphering Mode Command, we may need to derive a Kc from UMTS AKA tokens. gsm_milenage() derives Kc from 3G tokens, but also derives an SRES. For SRES, it requires an OPC, which may need to be derived from OP first. All we need is a Kc, so we could feed a zero OPC ... but to simplify the function call for cases where just a Kc is required, separate the c3 function out from gsm_milenage(), as osmo_auth_c3(). Obviously call osmo_auth_c3() from gsm_milenage() (meaning that osmo-hlr's 55.205 derived auc tests still cover exactly that implementation). Prepares: If04e405426c55a81341747a9b450a69188525d5c (osmo-msc) Related: OS#2745 Change-Id: I85a1d6ae95ad9e5ce9524ef7fc06414848afc2aa
* gsm0808_create_cipher_reject: Fix encoding of Cause IEHarald Welte2017-12-171-1/+2
| | | | | | | | | The Cause IE in the 08.08 CIPHER MODE REJECT is a normal TLV IE, and not just a value. Let's make sure we encode the cause value properly. Change-Id: I4f5b231edf6dcb0a9c2bbafb2a59f301f3b2402b Closes: OS#2766
* Add functions for extended RACH codingMax2017-12-111-0/+1
| | | | | | | | | | | Add support for extended RACH (11 bit) according 3GPP TS 45.003 §5.3.2: * convolutional code with puncturing * encoding/decoding routines * corresponding tests Change-Id: I85a34a82d5cd39a594ee89d91a2338226066ab5d Related: OS#1548
* Fix malformed Abis/RSL messages with extra L3 Information fieldPau Espin Pedrol2017-12-102-8/+1
| | | | | | | | | | | | | | | | | Some Abis/RSL messages such as "Release Indication" contained 3 extra bytes from an L3 Information header which should not be there according to specs in GSM 08.58 (section 8.3 "Radio link layer management messages"). Other RSL messages were affected by the same issue, except for "Establish Indication", which had already a workaround in send_rslms_dlsap. This commit fixes the issue in a generic way, removes the "Establish Indication" and fixes the test accounting for the bug, as it otherwise fails after applying the changes. Fixes: OS#1635, OS#2336 Change-Id: Ibb116214e8b1798d65a8b0917150496a3c14f344
* Fix LAPD UA msgb memory leak.Jean-Francois Dionne2017-12-101-0/+3
| | | | Change-Id: Ia4f0606810e00aa6f1779d11893e4acc01976f9a
* cosmetic: Fix trailing whitespacePau Espin Pedrol2017-12-102-8/+8
| | | | Change-Id: I0c7a414789f8ce6516369327430f71164e2cbd94
* Fix embedded buildMax2017-12-042-0/+10
| | | | | | | Do not attempt to load auth plugins - this does not make sense on embedded target anyway. Change-Id: Ie92d2eea21e19e499b3f3bb4d5a82e31fbbea3f0
* gsm: Use correct include for getrandomPau Espin Pedrol2017-11-161-1/+1
| | | | | | | | | | | "man getrandom" states sys/random.h is required. Fixes warning below: warning: implicit declaration of function ‘getrandom’; did you mean ‘srandom’? [-Wimplicit-function-declaration] rc = getrandom(out, len, GRND_NONBLOCK); ^~~~~~~~~ Change-Id: I2e73fd018e887893dc5527d6d73644d627eb963a
* Fix/Update copyright notices; Add SPDX annotationHarald Welte2017-11-1345-23/+132
| | | | | | | | 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
* Enable GnuTLS fallbackMax2017-11-022-5/+19
| | | | | | | | | | | | | | | | On systems with GNU/Linux kernel older than 3.17 (Debian 8 "jessie" for example) the osmo_get_rand_id() would always return failure due to missing getrandom() syscall. To support such systems, let's add fallback code which uses GnuTLS library. It can be disabled explicitly via '--disable-gnutls' option at compile-time, otherwise ./configure will fail if both getrandom() and GnuTLS are not available. When building with '--enable-embedded' the fallback is disabled automatically. Related: OS#1694 Change-Id: Ic77866ce65acf524b768882c751a4f9c0635740b
* Move additional libraries to appropriate placeMax2017-10-301-2/+2
| | | | | | | | | | | | | According to https://www.gnu.org/software/automake/manual/automake.html#Libtool-Flags the libraries supposed to be added to *_LDADD or *_LIBADD while *_LDFLAGS should contain additional libtool linking flags. Previously we used both. Let's unify this and move all the libraries into proper automake variable. While at it - also add libosmocore.la for tests to LDADD since all the tests link against it anyway. Change-Id: Ia657a66db75df831421af5df1175a992da5ba80f
* Tag/Release version 0.10.0Harald Welte2017-10-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's been way too long since the last release. Almost one year and 468 commits. A brief summary of the changes below: * Doxygen for libosmo{coding,gb} * pseudotalloc for embedded builds, jenkins for arm-none-gnueabi * --disable-doxygen, --disable-ctrl, --disable-simd * update debian packaging * gsm0503 coding routines * osmo_hton[sl] * statistics.h -> counter.h * QCDIAG in gsmtap * llist_{first,last}_entry() * llist_count() * LOGPSRC() macro * msgb_pull_to_l2() * msgb_printf() * prbs * osmo_sock_init2() * osmo_sock_mcast_{name,loop_set,ttl_set,all_set,subscribe,ip}() * OSMO_STRINGIFY() * OSMO_VALUE_STRING() * OSMO_BYTES_FOR_BITS() * osmo_talloc_asprintf() * osmo_sub_auth_type_name() * osmo_sub_auth_data support for IND/SQN_MS * osmo_fsm ctrl interface * ctrl_handle_alloc2() * ctrl_interface_setup_dynip2() * OSMO_CTRL_PORT_HLR * bssgp_tx_bvc_ptp_reset() * gprs_ns_inst connect/remote_{ip,port} * osmo_gprs_{ul,dl}_block_size_{bits,bytes}() * osmo_gprs_{dl,ul}_cs_by_block_bytes() * gprs_ns_pdu_strings[] * more BSSGP cause values * abis_nm_admin_name() * AoIP support in gsm0808 * gsm_fn_as_gsmtime_str() * osmo_dump_gsmtime() * gsup charging support * ipa_ccm_make_id_resp() * ipa_ccm_make_id_resp_from_req() * struct gsm48_gprs_susp_req * gsm_04_14.h * rsl measurement preprocessing related IEs * abis_nm_event_cause_names[] * abis_nm_sw_desc and friends * more SYSINFO_TYPE_ values * osmo_earfcn_bit_size_ext() * t16lv_put() * msgb_t16lv_put() * tlvp_val16be() * tlvp_val32be() * osmo_tlvp_copy() * osmo_tlvp_merge() * many additional VTY nodes * cmd_node.name member * bitvec_set_u64() * bitvec_rl_curbit * ctrl_lookup_register() * osmo_fsm_find_by_name() * osmo_fsm_inst_find_by_name() * osmo_fsm_inst_find_by_id() Change-Id: Ieb5db2e910a90db780ea058b3280f2facbd68d76
* Make osmo_apn_to_str() more robustMax2017-10-201-0/+3
| | | | | | | Previously it would crash on NULL input. Let's handle it gracefully instead. Corresponding test case is also added. Change-Id: I587153e49d1c92128fac3ae5c124adba9592378e
* [doc] Properly define gsm0800 group and move all related files into itHarald Welte2017-10-172-3/+4
| | | | Change-Id: I91920c69c86d6a1932172becacb76faff2d3eb1e
* [doc] Properly define 'oap' group and add introductory textHarald Welte2017-10-171-2/+1
| | | | Change-Id: I1e875991ae1dd93862f850f85d40b3dac61ece72
* [doc] Define 'gsup' group with proper name, add intro textHarald Welte2017-10-171-2/+1
| | | | Change-Id: Ieee6213dc5aad082a2d439c7418b51f281b80b1a
* [doc] make sure all SMS related code is part of the 'sms' groupHarald Welte2017-10-174-7/+7
| | | | Change-Id: I24c56ccb56d5b39cfb887808f91b715da54c0f8b
* [doc] gea has separate group; A5 is not part of crypto but a5 groupHarald Welte2017-10-172-14/+11
| | | | Change-Id: I2fd24c86f9b52244073ec800a3287e3d38e660d9
* gsm: make osmo_imsi_str_valid() NULL-safeNeels Hofmeyr2017-10-101-0/+2
| | | | | | | | | No callers that would pass NULL exist, but let's check against NULL from the start. Fixup for recent change I1e94f5b0717b947d2a7a7d36bacdf04a75cb3522. Change-Id: I111fbf29228929f2cd6ffa06bcb1f69da223224e
* Fix build on older systemsMax2017-10-101-0/+3
| | | | | | | | Make sure GRND_NONBLOCK is always defined, even when using syscall directly. Change-Id: I1bcac37ee1847596b49122f9307bd2689ba71b1b Related: OS#1694
* auth: add OSMO_MILENAGE_IND_BITLEN_MAXNeels Hofmeyr2017-10-091-1/+1
| | | | | | Will be used by OsmoHLR to validate VTY and CTRL input. Change-Id: Ic39f3404d1a49ffd06070aa9897b36f219eacf4d