aboutsummaryrefslogtreecommitdiffstats
path: root/src/gsm
AgeCommit message (Collapse)AuthorFilesLines
2019-02-08gsm/gsm0480: introduce gsm0480_create_release_complete()Vadim Yanitskiy2-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
2019-02-05gsm0808: Add CSFB indication IE to BSSMAP CLEAR COMMANDPhilipp Maier2-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
2019-02-04GSUP: deprecate osmo_gsup_get_err_msg_type()Oliver Smith1-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
2019-01-29add osmo_classmark_* APINeels Hofmeyr2-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
2019-01-28gsm0808: add BSSMAP Cell Identifier matching APINeels Hofmeyr3-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
2019-01-22constrain gsm48_generate_mid() output array boundsHarald Welte1-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
2019-01-21Rename msgb_wrap_with_TL()Max1-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
2019-01-19Bump version: 0.12.0.128-8dfde → 1.0.01.0.0Harald Welte1-1/+1
Change-Id: I1bd973754b1ebc42283f6a07defa60f58523f5a3
2019-01-19LCLS: make GCR into static member of osmo_lclsMax1-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
2019-01-19LCLS: add status parameter to Assignment Completed messageMax2-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
2019-01-18gsm29118: fix coverity issuesPhilipp Maier1-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
2019-01-14LCLS: add GCR comparison helperMax2-0/+22
Change-Id: I9e3b5560a058b976638d03cb819415d237ae9984
2019-01-14change GSM48_CMSERV_* to enum type, add namesNeels Hofmeyr2-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
2019-01-14gsm23003: add osmo_imei_str_valid()Oliver Smith2-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
2019-01-12port rest octets encoding code from osmo-bscStefan Sperling2-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
2019-01-12port arfcn range encode support from osmo-bscStefan Sperling3-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
2019-01-08add osmo_lu_type_names[], osmo_lu_type_name()Neels Hofmeyr2-0/+9
Move lupd_names[] from osmo-msc to libosmo-gsm. Change-Id: Ica25919758ef6cba8348da199b0ae7e0ba628798
2019-01-08add osmo_mi_name(), for MI-to-string like "IMSI-123456"Neels Hofmeyr2-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
2019-01-07LCLS: fix LCLS-CONNECT-CONTROL encoderMax1-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
2019-01-07Automatically disable GnuTLS fallbackMax1-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
2019-01-07Streamline glibc version checkMax1-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
2019-01-04osmo_rat_type: add OSMO_RAT_EUTRAN_SGSNeels Hofmeyr1-0/+1
osmo-msc is about to implement the SGs interface and requires a RAT indicator for that. Change-Id: I00588396bfe03feba38ecb0717d584594f0b2b46
2019-01-03gsm_utils: add enum osmo_rat_type, from osmo-msc enum ran_typeNeels Hofmeyr2-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
2018-12-23LCLS: enc/dec entire parameter set instead of GCRMax3-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
2018-12-21GSUP: add CHECK-IMEI messageOliver Smith1-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
2018-12-21GSUP: fix missing osmo_gsup_get_err_msg_type()sOliver Smith1-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
2018-12-20Use define for key buffersMax1-2/+2
Add corresponding spec. references and comments where appropriate. Change-Id: If5e2aad86eaecd8eada667b3488ba415d81c6312
2018-12-19LCLC: fix doc to match type signatureMax1-2/+1
Change-Id: I8f7b3dca080ef0e632d47a907154f8404b0ec523
2018-12-19Fix typos in SS opcode namesMax1-2/+2
Change-Id: I8fa1961c85b3fd714bc8df56fe4af6be4060c208
2018-12-18GSUP/SMS: introduce READY-FOR-SM messageVadim Yanitskiy1-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
2018-12-18GSUP/SMS: introduce MO-/MT-FORWARD-SM messagesVadim Yanitskiy4-2/+336
According to 3GPP TS 29.002, there are two services: - MAP-MO-FORWARD-SHORT-MESSAGE (see 12.2), - MAP-MT-FORWARD-SHORT-MESSAGE (see 12.9), which are used to forward MO/MT short messages. This change replicates both services as GSUP messages: - OSMO_GSUP_MSGT_MO_FORWARD_SM_*, - OSMO_GSUP_MSGT_MT_FORWARD_SM_*. Please note, that only the 'must-have' IEs are introduced by this change, in particular the following: - OSMO_GSUP_SM_RP_MR_IE (see note below), - OSMO_GSUP_SM_RP_DA_IE (see 7.6.8.1), - OSMO_GSUP_SM_RP_OA_IE (see 7.6.8.2), - OSMO_GSUP_SM_RP_UI_IE (see 7.6.8.4), - OSMO_GSUP_SM_RP_MMS_IE (see 7.6.8.7), - OSMO_GSUP_SM_RP_CAUSE_IE (see GSM TS 04.11, 8.2.5.4), where both SM_RP_DA and SM_RP_OA IEs basically contain a single nested TV of the following format: - T: identity type (see 'osmo_gsup_sms_sm_rp_oda_t'), - V: encoded identity itself (optional). According to GSM TS 04.11, every single message on the SM-RL has an unique message reference (see 8.2.3), that is used to link an RP-ACK or RP-ERROR message to the associated (preceding) RP-DATA or RP-SMMA message transfer attempt. In case of TCAP/MAP, this message reference is being mapped to the Invoke ID. But since GSUP has no 'Invoke ID' IE, and it is not required for other applications (other than SMS), this change introduces a special 'SM_RP_MR' IE that doesn't exist in MAP. Change-Id: Ibe325c64ae2d6c626b232533bb4cbc65fc2b5d71 Related Change-Id: (docs) Ie0150756c33c1352bc4eb49421824542c711175c Related Change-Id: (TTCN) Ibf49474a81235096c032ea21f217170f523bd94e Related: OS#3587
2018-12-14LCLS: add gsm0808_create_ass2()Max2-6/+48
It allows setting additional assignment parameters explicitly. Change-Id: Id89765df3f8c12f55f73f1d7a9d90c8883eb3bba Related: OS#2487
2018-12-14LCLS, TS 48.008: add GCR IE encoding/decodingMax2-0/+37
* add functions to encode Global Call. Ref. from TS 29.205 as 3GPP TS 48.008 §3.2.2.115 information element * add corresponding tests Change-Id: I82ce0207dc8de50689a8806c6471ad7fbae6219d
2018-12-14LCLS, TS 29.205: add GCR routinesMax3-1/+97
Add functions to encode and decode Global Call Reference as per 3GPP TS 29.205 Table B 2.1.9.1 add corresponding tests. Change-Id: Iee95aa4e5c056645b6cb5667e4a067097d52dfbf Related: OS#2487
2018-12-14gsm0480: fix copy-pasted note for gsm0480_gen_return_error()Vadim Yanitskiy1-3/+0
InvokeID is mandatory for ReturnError component. Change-Id: Ie1c7116d368c2029b9f524cb74ffa316e282ec83
2018-12-10gsm48_mi_to_string(): do not read from zero length input bufferNeels Hofmeyr1-1/+1
Change-Id: I12cada7c2c5187146ca5a33d1ebfefb4cad65632
2018-12-10gsm48_mi_to_string(): guard against zero length output bufferNeels Hofmeyr1-5/+5
All successful cases already return from the switch(), so simply handle all errors below it by returning an empty string (if there is enough string buffer). Change-Id: I709ac3b9efb7b4258d8660715b10312e11b9b571
2018-12-10gsm48_generate_mid(): mask out ODD flag from mi_typeNeels Hofmeyr1-1/+1
For MI encoding, see 3GPP TS 24.008, 10.5.1.4 Mobile Identity. The 'odd' flag indicates whether the last BCD nibble is used. Of course that flag should be made sure to reflect the actual length. Change-Id: Id6e695ebf9f86b295eaa7e2c6228989256f37e68
2018-12-10gsm48_mi_to_string: use osmo_bcd2str(), fix some corner casesNeels Hofmeyr1-13/+12
By using osmo_bcd2str(), ensure that the resulting string is always nul terminated, and always return strlen()+1 whether truncated or not. Still keep up the previous return value style, even if that isn't consistent at all. The difference between IMSI/IMEI and TMSI return values remains and is not part of this patch. Change-Id: I1b51b72a721e1cc9d69796b804ebda741ff0f36b
2018-12-10api doc: gsm48_mi_to_string(): warn of return value implementationNeels Hofmeyr1-1/+4
Change-Id: If5e7abd15dddf39cdfad8071f4cd5ca8244eabe0
2018-12-08gsm0808: add encoder for cause codes and use itPhilipp Maier3-12/+43
At the moment the all gsm0808 cause codes are encoded directly using the tlv API directly to put a one byte TLV field. This works ok for most situations where the cause code consists of a single byte. However, gsm0808 specifies a two byte cause code model where cause codes may be extended up to two bytes. Instead of implementing the encoding over and over and again, let's rather have an encoder function we can call. - Add an encoder function that can generate single byte and extended cause codeds and makes the length decision automatically. - Use only this function to append cause codes Change-Id: I71d58fad89502a43532f60717ca022c15c73f8bb
2018-12-07gsm29118: add generator functions for GSM29118 messagesPhilipp Maier2-0/+290
We already have some GSM29118 related definitions and functions in libosmocore. Lets also add some functions to generate GSM29118 messages (similar to those we have for GSM0808). Change-Id: Ic87f8a771b87b52215d0a7451b67794557b80b8a Related: OS#3615
2018-12-07cosmetic apn: correct whitespace errorPhilipp Maier1-1/+1
there is a whitespace between the * and osmo_apn_to_str(). Lets remove this. Change-Id: I094e6eb08eacf2d6459c47a7370837601aa92925
2018-12-03gsm0808: add message generator for BSSMAP HANDOVER PERFORMEDPhilipp Maier2-0/+47
We currently have no generator function that can generate BSSMAP HANDOVER PERFORMED messages. Lets add function for this. Change-Id: I825106858bd89afc9837811b8fed2e8accc82441 Related: OS#3645
2018-11-30Move BSSMAP_MSG_* defines to header fileMax1-3/+0
This will be reused be several tests related to TS 48.008 and TS 29.205 in follow-up commits. Change-Id: I4d8cc05b8df8e70c1f6257e53ae3acec7901681f
2018-11-22Update gsm0808_create_ass() doxygenMax1-2/+2
* add spec reference * remove LCLS note: CI parameter is optional but have nothing to do with LCLS It's pretty hard to decipher from the spec what CI is useful for and we have not used it anyway so let's just keep it as "Optional" for now. Change-Id: I5552732afcec48047d993ae6ffb73a3e5d7c9202
2018-11-20gsm: Deprecate buggy gsm_arfcn2band API and introduce gsm_arfcn2band_rcPau Espin Pedrol2-23/+49
ARFCNs are values in well defined ranges. Until this patch, ARFCNs not belonging to any band were blindly assigned to DCS1800 by gsm_arfcn2band, causing unnoticed bugs and misconfigurations in osmo-bsc. Previous API gsm_arfcn2band cannot accomodate this kind of check easily, so let's deprecate it to tell people to use a new API gsm_arfcn2band_rc which performs this kind of checks and allows callers to log failures, misconfigurations, etc. At the same time, modify implementation of gsm_arfcn2band to abort if an invalid ARFCN is passed, this way users of this API can notice they are passing wrong data to it that most probably will produce unexpected results. Related: OS#3063 Change-Id: I780d452dcebce385469e32ef2fd844df6033393a
2018-11-19Support cipher mode reject with extended causeMax3-0/+42
* add function to generate cipher mode reject with extended (2-byte) Cause IE * add function to get (extended) Cause value * add corresponding (extended cause) test * update existing (non-extended cause) test * use enum as a parameter for existing non-extended version to make interface more unified Change-Id: Id5509b94a18180a44f45300caaa02b843c166fa3 Related: OS#3187
2018-11-19Move msgb_push helpers to public headerMax1-39/+10
The msgb_wrap_with_TL() is generally useful so it make sense to make it public to facilitate code re-use. Other helpers can be implemented as trivial wrappers over existing tlv.h functions. Update headers and code accordingly. Change-Id: I37e91d031fba28cf1c6735b8069b0265746f55e6
2018-11-18gsm48: gsm48_decode_freq_list: Improve documentation of paramter fPau Espin Pedrol1-1/+1
Change-Id: Id8e3afff737211ded3c5689f2c83b1a544b42f9d