summaryrefslogtreecommitdiffstats
path: root/src/gsm
Commit message (Collapse)AuthorAgeFilesLines
* gsm_utils.c: fix Doxygen description for gsm_get_octet_len()Vadim Yanitskiy2019-04-111-4/+4
| | | | Change-Id: Id6fd2cd33be1cb7cd7ff6a43bfcfb1f368304522
* Add _c versions of functions that otherwise return static buffersHarald Welte2019-04-108-4/+238
| | | | | | | | | | | | | | We have a habit of returning static buffers from some functions, particularly when generating some kind of string values. This is convenient in terms of memory management, but it comes at the expense of not being thread-safe, and not allowing for two calls of the related function within one printf() statement. Let's introduce _c suffix versions of those functions where the caller passes in a talloc context from which the output buffer shall be allocated. Change-Id: I8481c19b68ff67cfa22abb93c405ebcfcb0ab19b
* gsm_utils: fix use buf_len instead of sizeof in osmo_dump_gsmtime_bufPhilipp Maier2019-04-081-1/+1
| | | | | | | | | | The function osmo_dump_gsmtime_buf gets a pointer *buf and a parameter buf_len. The pointer *buf is a string buffer and the function places an \0 at the end of the buffer before it exists. However it uses sizeof(buf) as part of the index calculation, which is incorrect. Lets correct this by using buf_len instead. Change-Id: Id24263aa7c9a53544f1639b6ceb09ce5615d5114
* Add _buf() functions to bypass static string buffersHarald Welte2019-04-038-77/+267
| | | | | | | | | | | | | | | We have a number of static buffers in use in libosmo*. This means the related functions are not usable in a thread-safe way. While we so far don't have many multi-threaded programs in the osmocom universe, the static buffers also prevent us from calling the same e.g. string-ify function twice within a single printf() call. Let's make sure there's an alternative function in all those cases, where the user can pass in a caller-allocated buffer + size, and make the 'classic' function with the static buffer a wrapper around that _buf() variant. Change-Id: Ibf85f79e93244f53b2684ff6f1095c5b41203e05
* ipa: Fix ipa_ccm_id_resp_parse on big endian systemsPau Espin Pedrol2019-03-281-2/+2
| | | | Change-Id: Iedc46ab53a4f76bbd98741c065fad3d9042a34a4
* ipa: Document ipa_ccm_idtag_parse_off and fix ipa_ccm_idtag_parsePau Espin Pedrol2019-03-281-1/+11
| | | | | | | | | | | | | | | | | | | | | ipa_ccm_idtag_parse_off is broken, and can only be used with len_offset=1 on ID Request messages, otherwise won't work correctly. Modify ipa_ccm_idtag_parse to at least parse those correctly, and document the limitations. Those two functions are already deprecated and only used in openbsc by 3 callers: * ipa_ccm_idtag_parse in ussd_read_cb(): Broken, that function can only work for Requests and it's used to parse a Response. * ipa_ccm_idtag_parse_off in forward_sccp_to_msc (NAT): Broken, it can only be used to parse Requests and it's used to parse a Response. Furthermore, len_offset=2 is passed which makes no sense and most probably it fails always, or can even make the program crash. * ipa_ccm_idtag_parse_off in (answer_challenge): This one is fine and could actually be replaced with ipa_ccm_id_get_parse after this commit is merged. Change-Id: I6efc852dfc041192f554e41a58290a0f63298021
* Revert "ipa_ccm_idtag_parse*: Fix reported length value"Oliver Smith2019-03-251-1/+1
| | | | | | | | | | | | This reverts commit 1261db15058cfa94615f26c1083bb8a38d09218b. The patch broke openbsc's external tests, and currently it is unclear whether it is just an error in the test or if openbsc makes wrong assumptions about the length value. Let's revert the patch to unblock the master-openbsc jenkins job. Related: OS#3851 Change-Id: I9adea35ff6de36c1611c7f85dde1b15bc1c0e786
* ipa_ccm_idtag_parse*: Fix reported length valueHarald Welte2019-03-191-1/+1
| | | | | | | | | | | | | | | IPA CCM is using a somewhat weird TLV encoding scheme: * 16bit length (of tag and value) * 8bit tag * value Our existing code mapping the CCM to 'struct tlv_parse' used the plain length value without accounting for the one-byte tag. This patch ensures we only report the length of the "value" part, excluding the tag. Change-Id: I435aaa33605bd48635715a2c81aa2d231c1abf51
* osmo_gsm48_classmark_a5_name(): fix 'no-cm3' labelNeels Hofmeyr2019-03-141-1/+1
| | | | Change-Id: Id84021858dfb2f7d6a7cf81ae73bd94cd47f6776
* Fix build on non-glibc systemsKarl Koscher2019-03-111-3/+8
| | | | Change-Id: Id5d577522a4889e152158f7e93ee1c99d3a21003
* gsm0808_utils: fix gsm48 multirate to S-bit converterPhilipp Maier2019-03-111-0/+10
| | | | | | | | | | | | The function gsm0808_sc_cfg_from_gsm48_mr_cfg() is used to convert a gsm48 multirate struct into a set of S-bits (S0 to S15). However, the conversion function currently does not take into account that bit S1 actually stands for four rates at once (Config-NB-Code = 1). Lets make sure that S1 is only set when the multirate configuration permits all four required rates. Change-Id: I6ad531d4e70c2252e32e2bbaca8e14a7ec6d9840 Related: SYS#4470
* gsm0808_utils: fix gsm48 multirate configuration generatorPhilipp Maier2019-03-111-21/+73
| | | | | | | | | | | | | | | | | The function gsm0808_sc_cfg_from_gsm48_mr_cfg() takes an S15 to S0 bitmask and converts that bitmask into an AMR multirate configuration struct. Unfortunately the current implementation implements 3GPP TS 28.062, Table 7.11.3.1.3-2 wrongly in some aspects. Lets fix this. - Fix wrong interpretation of the bitpatterns - 5,15K is invalid and must never be selected - Make sure that no more than 4 rates are selected in the active set - Extend unit-test Change-Id: I6fd7f4073b84093742c322752f2fd878d1071e15 Related: SYS#4470
* add gsm0808_cell_id_from_cgi(), gsm0808_cell_id_to_cgi()Neels Hofmeyr2019-03-082-0/+89
| | | | | | | | | | | | | | | | CGI to Cell ID: for example, for Paging, osmo-msc has a CGI for a subscriber and needs to send out a Cell Identifier IE. Makes sense to add this conversion here. Cell ID to CGI: for a Layer 3 Complete, a subscriber sends the current cell in the form of a Cell Identifier, which we store as a CGI, if necessary enriched with the local PLMN. Add enum with bitmask values to identify parts of a CGI, for the return value of gsm0808_cell_id_to_cgi(). Can't use enum CELL_IDENT for that, because it doesn't have a value for just a PLMN (and is not a bitmask). Change-Id: Ib9af67b100c4583342a2103669732dab2e577b04
* api doc: tweak gsm0808_cell_id_matches_list() docNeels Hofmeyr2019-03-051-1/+2
| | | | Change-Id: Ide94558d1c31356483252b83e04b061b4ee4d3bf
* fix api doc typo for osmo_plmn_name2()Neels Hofmeyr2019-02-261-1/+1
| | | | Change-Id: Ic2652c7e4ffe1e707022168ac6c0da7c88ae7f45
* LCLS: add string dump helpersMax2019-02-263-0/+45
| | | | | | | | | Add functions to dump LCLS (without GCR) and GCR. Dumping entire struct results in inconveniently long string hence the separate functions. Both use talloc functions so they expect caller to take care of providing proper allocation context and freeing memory. Change-Id: Ic3609224c8f3282d667e75f68bc20327e36eb9e6
* rsl: Support PDCH in rsl_chan_nr_strPau Espin Pedrol2019-02-181-0/+2
| | | | | | | | | | | | | | During log review lack of support for PDCH was spotted: scheduler.c:593 Configuring multiframe with PDCH trx=0 ts=4 rsl.c:1159 (bts=0,trx=0,ts=4,ss=0): chan_nr=UNKNOWN on TS4 type=0x00 mode=SIGNALLING rsl.c:741 (bts=0,trx=0,ts=4,pchan=TCH/F_TCH/H_PDCH as PDCH) (ss=0) PDTCH Tx CHAN ACT ACK Wireshark shows: 1100 0... = C-bits: PDCH (24) .... .100 = Time slot number (TN): 4 Change-Id: If6ed96c9eb0431eb24e2135634def61e0ea506ea
* gsm0808: comment about difference of gsm0808_create_clear_command()Harald Welte2019-02-181-1/+4
| | | | | | | | This single function has a quite different behavior than the other gsm0808_ functions in terms of how the resulting msgb l3h pointers are set. Let's document that to avoid more confusion. Change-Id: I0367760a588fc968c5a2dea46001ef1ee7965c8c
* Fix BSSMAP length generated by gsm0808_create_clear_command2()Harald Welte2019-02-181-1/+7
| | | | | | | | | | In Change-Id Id8a75e1da2d5f520064666e4ee413d1c91da6ae3 we recently introduced adding the "CSFB INDICATOR" IE to the CLEAR COMMAND, but we did so with a wrong length value. Change-Id: I4d07d25fb03ca0f89fd7b94226c54309c77a010a Closes: OS#3805 Related: OS#2778
* fix osmo_gsm48_classmark* libosmogsm.map entriesNeels Hofmeyr2019-02-151-6/+6
| | | | | | | | When the initial patch was tweaked from osmo_classmark_* to osmo_gsm48_classmark_* naming, the libosmogsm.map entries were forgotten to be changed as well. Change-Id: I53a41b5e965a529d3c146ee85102f7f1725c6014
* gsm/gsm0480: introduce gsm0480_create_release_complete()Vadim Yanitskiy2019-02-082-0/+23
| | | | | | | | | | | | In OsmoMSC, it's required to be able to specify a particular GSM 04.07 transaction ID for GSM 04.80 Release complete message instead of the hard-coded value, that is used gsm0480_create_ussd_release_complete(). Let's finally deprecate gsm0480_create_ussd_release_complete(), and introduce a new function without USSD prefix, as this message is also used in other "structured" supplementary services. Change-Id: Ie3ac85fcef90a5e532334ba3482804d5305c88d7
* gsm0808: Add CSFB indication IE to BSSMAP CLEAR COMMANDPhilipp Maier2019-02-052-0/+17
| | | | | | | | | | | When a call that was established in a CSFB context ends the CLEAR COMMAND that is send from the BSC to the MSC should contain a CSFB indication IE, which consists of just the IE byte itsslef. This additional IE tells the BSC to include other CSFB related IEs into the RR Release message. Change-Id: Id8a75e1da2d5f520064666e4ee413d1c91da6ae3 Related: OS#3778
* GSUP: deprecate osmo_gsup_get_err_msg_type()Oliver Smith2019-02-041-28/+3
| | | | | | | | | | | | | | Replace osmo_gsup_get_err_msg_type() with a wrapper to OSMO_GSUP_TO_MSGT_ERROR(). This macro assumes, that all error messages are (request message | 0x000001). Add a big comment header for osmo_gsup_message_type, describing this already implicitly followed rule and therefore making it explicit. With this change, we don't need to maintain the request -> error message mapping in osmo_gsup_get_err_msg_type() anymore. Related: Iec1b4ce4b7d8eb157406f006e1c4241e8fba2cd6 (osmo-gsm-manuals) Change-Id: I46d9f2327791978710e2f90b4d28a3761d723d8f
* add osmo_classmark_* APINeels Hofmeyr2019-01-292-0/+133
| | | | | | | | | osmo-bsc and osmo-msc implement identical Classmark structures. It makes sense to define once near the gsm48 protocol definitions. Also move along some generic Classmark API from osmo-msc. Change-Id: Ifd27bab0380f7ad0c44c719aa6c8bd62cf7b034c
* gsm0808: add BSSMAP Cell Identifier matching APINeels Hofmeyr2019-01-283-0/+181
| | | | | | | | | | | | | | | | | | | | | | | | | Add * osmo_lai_cmp() (to use in gsm0808_cell_id_u_matches()) * osmo_cgi_cmp() (to use in gsm0808_cell_id_u_matches()) * gsm0808_cell_id_u_match() (to re-use for single IDs and lists) * gsm0808_cell_ids_match() * gsm0808_cell_id_matches_list() * Unit tests in gsm0808_test.c Rationale: For inter-BSC handover, it is interesting to find matches between *differing* Cell Identity kinds. For example, if a cell as CGI 23-42-3-5, and a HO for LAC-CI 3-5 should be handled, we need to see the match. This is most interesting for osmo-msc, i.e. to direct the BSSMAP Handover Request towards the correct BSC or MSC. It is also interesting for osmo-bsc's VTY interface, to be able to manage cells' neighbors and to trigger manual handovers by various Cell Identity handles, as the user would expect them. Change-Id: I5535f0d149c2173294538df75764dd181b023312
* constrain gsm48_generate_mid() output array boundsHarald Welte2019-01-221-4/+8
| | | | | | | | | | | The longest BCd-digit type identity is the IMEISV with 16, so there's no point in trying to parse up to 255 decimal digits, which will do nothing but to overflow the caller-provided output buffer. Let's also clearly define the required minimum size of the output buffer and add a reltead #define for it. Change-Id: Ic8488bc7f77dc9182e372741b88f0f06100dddc9
* Rename msgb_wrap_with_TL()Max2019-01-211-9/+9
| | | | | | | | | | | | | | | This resolves an issue introduced in 84fb5bb6a09a6a358f98c654c84c3b99a0f24eef when msgb_wrap_with_TL() was introduced as an inline function with *exactly the same name* as in osmo-msc.git and openbsc.git. We *NEVER* do something like this. Functions moved from applications to library *MUST* always be renamed. This has been the case for almost a decade now. With this subsequent change we make sure the libosmocore function has a different name and doesn't clash. After this commit, old openbsc.git and osmo-bsc.git should again build fine. Change-Id: If1e851ac605c8d2fde3da565b0bd674ea6350c2e
* Bump version: 0.12.0.128-8dfde → 1.0.0Harald Welte2019-01-191-1/+1
| | | | Change-Id: I1bd973754b1ebc42283f6a07defa60f58523f5a3
* LCLS: make GCR into static member of osmo_lclsMax2019-01-191-5/+4
| | | | | | | | | Most of the time we'll have GCR filled anyway so it make sense to have it as static parameter instead of a pointer to separately allocated structure. Update tests to cover both static and dynamic osmo_lcls allocation variants. Change-Id: I905c36d8455911c68c30bc429379b7313dd46aea
* LCLS: add status parameter to Assignment Completed messageMax2019-01-192-7/+32
| | | | | | | | | | * add gsm0808_create_ass_compl2() with additional gsm0808_lcls_status parameter and make gsm0808_create_ass_compl() into trivial wrapper around it * update tests accordingly Change-Id: I547c6b8707123aa8c1ef636db88908df112d90a4 Related: OS#2487
* gsm29118: fix coverity issuesPhilipp Maier2019-01-181-1/+6
| | | | | | | | | | | | | The function msgb_sgsap_name_put() assignes the return code of osmo_apn_from_str() directly to len. Len is an uint8_t and the return code an int. If osmo_apn_from_str() returns -1. Len would become 0xFF causing a buffer overrun with msgb_tlv_put. Lets use the proper type to catch the return code and check it before using it as length. Change-Id: Ic0bc5114eee47bdcf2300a6e4b0df473d3d1903a Fixes: CID#190405 Fixes: CID#190401 Related: OS#3615
* LCLS: add GCR comparison helperMax2019-01-142-0/+22
| | | | Change-Id: I9e3b5560a058b976638d03cb819415d237ae9984
* change GSM48_CMSERV_* to enum type, add namesNeels Hofmeyr2019-01-142-0/+12
| | | | | | | Prepare handling multiple CM Service Requests in osmo-msc: an enum is more clear than an int and #defines for passing around and count CM Service types. Change-Id: I9c2a7adc45ab7a1a7519168e965e7d805e1481ff
* gsm23003: add osmo_imei_str_valid()Oliver Smith2019-01-142-0/+19
| | | | | | | | | | | Verify 14 digit and 15 digit IMEI strings. OsmoHLR will use the 14 digit version to check IMEIs before writing them to the DB. Place the Luhn checksum code in a dedicated osmo_luhn() function, so it can be used elsewhere. Related: OS#2541 Change-Id: Id2d2a3a93b033bafc74c62e15297034bf4aafe61
* port rest octets encoding code from osmo-bscStefan Sperling2019-01-122-0/+957
| | | | | | | | | | | | | | | | | | | | | | | | | | As part of fixing issue OS#3075, we want to migrate support for encoding system information from osmo-bsc to libosmocore. This change ports osmo-bsc code for encoding SI rest octets. The conversion was a bit tricky in some places because some functions receive a 'struct gsm_bts' parameter in osmo-bsc. In this libosmocore version, such functions expect parameters which correspond to the individual fields of 'struct gsm_bts' which are used by these functions. Several structs from osmo-bsc's system_information.h are now also declared in libosmocore headers, with an added osmo_ prefix to avoid collisions with existing definitions in osmo-bsc. Some helpers were ported from osmo-bsc's system_information.c to libosmocore's gsm48_rest_octets.c. Contrary to osmo-bsc's implementation they are now only visible within this file. Unfortunately, this code ported from osmo-bsc lacks unit tests. Change-Id: I47888965ab11bba1186c21987f1365c9270abeab Related: OS#3075
* port arfcn range encode support from osmo-bscStefan Sperling2019-01-123-1/+332
| | | | | | | | | | | | | | As part of fixing issue OS#3075, we want to migrate support for encoding system information from osmo-bsc to libosmocore. This change ports one of the prerequisites for doing so: osmo-bsc code for range-encoding ARFCNs, including tests. An osmo_gsm48_ prefix has been prepended to public symbols in order to avoid clashes with existing symbols in osmo-bsc code. Change-Id: Ia220764fba451be5e975ae7c5eefb1a25ac2bf2c Related: OS#3075
* add osmo_lu_type_names[], osmo_lu_type_name()Neels Hofmeyr2019-01-082-0/+9
| | | | | | Move lupd_names[] from osmo-msc to libosmo-gsm. Change-Id: Ica25919758ef6cba8348da199b0ae7e0ba628798
* add osmo_mi_name(), for MI-to-string like "IMSI-123456"Neels Hofmeyr2019-01-082-0/+37
| | | | | | | | We have gsm48_mi_to_string() and osmo_bcd2str(), but still lack a function that conveniently prints both MI type and value in one function call. Related: http://people.osmocom.org/neels/mi_mi_mi.jpg Change-Id: I7798c3ef983c2e333b2b9cbffef6f366f370bd81
* LCLS: fix LCLS-CONNECT-CONTROL encoderMax2019-01-071-8/+13
| | | | | | | | | | | Previously it could encode both incorrect values as well as incorrect message. Let's fix this by explicitly checking for invalid values and ensuring that at least one of the parameters is valid. This function have no external or internal users so it's better to fix type signature as well to match the rest of gsm0808_create_lcls_*(). Change-Id: I7b33a771acbd391c5f9a494d6450edb18511433f
* Automatically disable GnuTLS fallbackMax2019-01-071-0/+1
| | | | | | | | | Disable GnuTLS fallback if sufficient glibc version detected. Previously GnuTLS fallback was used regardless of getrandom() availability in glibc. Fix this by automatically disabling it when not needed. This does not affect the ability to manually disable it unconditionally. Change-Id: Ibe2117afc050261668a4d5a590044aabcd08aefe
* Streamline glibc version checkMax2019-01-071-7/+11
| | | | | | | | | | * use macro for version check * report glibc version upon random.h detection * comment where various #endif belongs to * explicitly check for embedded build (our target toolchain don't use libc so there's no point in checking its version) Change-Id: Ia54f0b7a861f955be65bb0cf06eb10af9372d062
* osmo_rat_type: add OSMO_RAT_EUTRAN_SGSNeels Hofmeyr2019-01-041-0/+1
| | | | | | | osmo-msc is about to implement the SGs interface and requires a RAT indicator for that. Change-Id: I00588396bfe03feba38ecb0717d584594f0b2b46
* gsm_utils: add enum osmo_rat_type, from osmo-msc enum ran_typeNeels Hofmeyr2019-01-032-0/+10
| | | | | | | | | | | | | | | In the MSC, we have RAN types GERAN_A and UTRAN_IU, now we need a similar enum in osmo-hlr's GSUP client. Naming: in the MAP specifications, the RAN type is mostly called RAT type, (Radio Access Network vs. Radio Access Technology?). Since GSUP is more about MAP messages, I'm calling the enum osmo_rat_type. Rationale: osmo-msc and osmo-sgsn want to tell the osmo-hlr which RAT a subscriber is calling on. A subsequent patch will extend the GSUP protocol and add a RAT types IE. Change-Id: I659687aef7a4d67ca372a39fef31dee07aed7631
* LCLS: enc/dec entire parameter set instead of GCRMax2018-12-233-21/+56
| | | | | | | | | | | | | In 3GPP TS 48.008 the Global Call Reference IE is only used in HANDOVER REQUEST (§3.2.1.8) and ASSIGNMENT REQUEST (§3.2.1.1) messages which also include LCLS Config and CSC parameters. Hence, there's no point in using GCR encode/decode functions alone. Introduce gsm0808_dec_lcls() and gsm0808_enc_lcls() as trivial wrappers on top of GCR enc/dec routines which are made static. Adjust tests accordingly. Test output intentionally left unchanged. Change-Id: Icfbb2404e1a1d500243e2071173299b557369335
* GSUP: add CHECK-IMEI messageOliver Smith2018-12-211-0/+23
| | | | | | | | | | | | | | Implement necessary messages for Procedure Check_IMEI_VLR (TS 23.018 Chapter 7.1.2.9). This lets the VLR ask the EIR to check if an IMEI is valid. In the Osmocom stack, we don't have an EIR and this request will be handled by the HLR. We will be able to store the IMEI in the HLR as side-effect (OS#2541). This is roughly based on TS 29.002 8.7.1 MAP_CHECK_IMEI service, but only implements the bare minimum required IEs (imei and imei_result). Related: OS#3733 Change-Id: I085819df0ea7f3bfeb0cabebb5fd1942a23c6155
* GSUP: fix missing osmo_gsup_get_err_msg_type()sOliver Smith2018-12-211-0/+8
| | | | | | | | | | | Add missing mappings of request to error message types in osmo_gsup_get_error_msg_type(): * PROC_SS_REQUEST * MO_FORWARD_SM_REQUEST * MT_FORWARD_SM_REQUEST * READY_FOR_SM_REQUEST Change-Id: I801a0d6ffe09cfc75b77ab602bd25b3dc40f19c0
* Use define for key buffersMax2018-12-201-2/+2
| | | | | | Add corresponding spec. references and comments where appropriate. Change-Id: If5e2aad86eaecd8eada667b3488ba415d81c6312
* LCLC: fix doc to match type signatureMax2018-12-191-2/+1
| | | | Change-Id: I8f7b3dca080ef0e632d47a907154f8404b0ec523
* Fix typos in SS opcode namesMax2018-12-191-2/+2
| | | | Change-Id: I8fa1961c85b3fd714bc8df56fe4af6be4060c208
* GSUP/SMS: introduce READY-FOR-SM messageVadim Yanitskiy2018-12-181-0/+13
| | | | | | | | | | | | | | | According to 3GPP TS 29.002, section 12.4, MAP-READY-FOR-SM is used between the MSC and VLR as well as between the VLR and the HLR to indicate that a subscriber has memory available for SMS. This change replicates this service in GSUP as READY_FOR_SM_*. The only mandatory IE for this service (excluding Invoke ID) is 'Alert Reason' that is replicated by OSMO_GSUP_SM_ALERT_RSN_IE. Change-Id: Ic37f3b2114b8095cfce22977e67133b9103942e3 Related Change-Id: (docs) I549b6c8840a1e86caac09e77fb8bc5042d939e62 Related Change-Id: (TTCN) If2256607527ecfcb10285583332fb8b0515d7c78 Related: OS#3587