summaryrefslogtreecommitdiffstats
path: root/src/gsm
Commit message (Collapse)AuthorAgeFilesLines
* 04.80: Deprecate gsm0480_create_ussd_resp()Harald Welte2019-11-301-0/+1
| | | | | | | | | In July 2018 in commit Ide240279240322f643e142229eb7829f538c6314 we introduced the successor gsm0480_gen_ussd_resp_7bit(), which is also what both libosmogsm-internal code as well as osmo-hlr have been ported to. For some reason it wasn't marked deprecated back then. Change-Id: Iff4c91b5b98a73d9a30aa42f6b2a1ebcc8a45343
* Introduce fields related to DTAP DLCIPau Espin Pedrol2019-11-272-0/+8
| | | | Change-Id: Iec448af02d28e6c5c573e68a0b4a86067ec7e561
* GSUP: rename E_ROUTING_ERROR to ROUTING_ERRORNeels Hofmeyr2019-11-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | GSUP routing was introduced when adding the E interface. Hence that was the first realm where routing errors could occur. I did notice back then that this message type was special: it does not convey a response to a particular message kind -- it does not make sense, for example, to return an Updating Location Error cause, and do that for all conceivable message types. Instead, this tells the sender that a deeper error exists, i.e. that the desired peer is completely gone and unreachable. I did not foresee though that for D-GSM, there would also be arbitrary GSUP proxy routing, and that this error is not limited to E interface semantics. From today's point of view, adding the "_E_" in the name was a mistake. Remove that "_E_" to yield OSMO_GSUP_MSGT_ROUTING_ERROR (with unchanged message type discriminator), but provide a #define linking the old name OSMO_GSUP_MSGT_E_ROUTING_ERROR to the new one. The only visible change should be that osmo_gsup_message_type_names[] now returns the new name without "_E_". I am not aware of any regression test fallout from that. Change-Id: Ic8e8bd11522d6c51ac7aaf946516cbce26bc6e1e
* libosmogsm: add support for XOR authenticationDaniel Willmann2019-11-222-1/+188
| | | | | Change-Id: I1afaf0a9e2dce43aec87964bacefb21ed4d3d565 Related: OS#2475
* gsm: gsm_utils: Fix return type of API ms_class_gmsk_dbm() and add unit testsPau Espin Pedrol2019-11-041-2/+2
| | | | | | | | Only known user of API is in osmocom-bb and it compiles fine after the change. Related: OS#4244 Change-Id: Ia10345008b3aca50b30482ef3b852b03eca71995
* gsm_04_08.h: Introduce API osmo_gsm48_rfpowercap2powerclass()Pau Espin Pedrol2019-11-032-0/+22
| | | | | Related: OS#4244 Change-Id: I32e9cc1c2397b44f0d48db2acdf782a821365b63
* gsm0508: add functions to calculate beginning of a blockPhilipp Maier2019-10-282-0/+158
| | | | | | | | | | | The calculation of the beginning of a block for TCH/F, TCH/H and FACCH can be challenging since those channels are affected by the diagonal interleaving of the TCH channels. However, GSM 05.02 Section 7 Table 1 of 5 specifies how the blocks are distributed over the TDMA frame interval. Lets add a mapping function that is based on that table Related: OS#3803 Change-Id: I3d71c66f8c401f5afbad9b1c86c24580dab9e0ce
* gsup: add OSMO_GSUP_SUPPORTED_RAT_TYPES_IE and OSMO_GSUP_CURRENT_RAT_TYPE_IENeels Hofmeyr2019-09-281-0/+35
| | | | | | | | | | | | | | OSMO_GSUP_SUPPORTED_RAT_TYPES_IE corresponds to the Supported RAT Types Indicator from 3GPP TS 29.002. See 8.1.2 MAP_UPDATE_LOCATION service, which indicates the capabilities of the MSC/VLR to the HLR. So far, have room for eight RAT types in the gsup_msg. That is an arbitrary random choice without any rationale. OSMO_GSUP_CURRENT_RAT_TYPE_IE is useful to communicate the currently used RAN / RAT type of the current subscriber during Location Updating Request. Change-Id: I93850710ab55a605bf61b95063a69682a2899bb1
* Introduce BTS_FEAT_ETWS_PN for communicating ETWS PN capabilityHarald Welte2019-09-051-0/+1
| | | | | | | | | | As 3GPP doesn't specify how the BSC shall communicate ETWS Primary Notifications over Abis/RSL, we have to use a vendor-specific RSL message for this. And in order to know if the peer supports this feature, we introduces BTS_FEAT_ETWS_PN. Change-Id: I89c24a81ada6627694a9632e87485a61cbd3e680 Related: OS#4046, OS#4047
* gsm_08_58: Add vendor-specific Message Type for ETWS Primary WarningHarald Welte2019-09-051-0/+1
| | | | | Change-Id: I36fc2ffc22728887d1cb8768c7fcd9739a8ec0fc Related: OS#4046, OS#4047
* cbsp: Fix decoding of WRITE-REPLACE payloadHarald Welte2019-09-011-2/+2
| | | | | | | The user length is the first IE *in* the fixed-length TV, make sure cbsp_dec_write_repl() respects that. Change-Id: I864cafac2466a89a4bd9644bc73363fff2babd03
* cbsp: Remove printf() statement from early development/debuggingHarald Welte2019-08-311-1/+0
| | | | Change-Id: I6916e2330e004f20a22f273147fa6288d18b5d0d
* cbsp: Fix endless loop iteration when decoding cell list IEsHarald Welte2019-08-312-4/+25
| | | | | | | | The CBSP code assumed that gsm0808_decode_cell_id_u() would return the number of bytes it has consumed/parsed. But it actually always returns '0', whcih makes us run in an endless loop :( Change-Id: I5758af4ec11a827d4b888a3a16c4ec22de90a7d6
* Bump version: 1.1.0.107-afce-dirty → 1.2.0Pau Espin Pedrol2019-08-061-1/+1
| | | | Change-Id: I05dd1f2725e05f856f1d27c9201a0005de101b8f
* gsm/gsm48.h: drop meaningless 'const' from gsm48_mi_to_string()Vadim Yanitskiy2019-07-261-2/+1
| | | | Change-Id: I5eb17edadf89ac47b4ca86c9e822037f7c0e518e
* gsm/gsm0480.c: use DLGLOBAL and LOGL_ERROR for loggingVadim Yanitskiy2019-07-211-13/+13
| | | | Change-Id: Id38272ff93fae6d2fdf39df4ffc74856d6c9a898
* gsm/gsm0480.c: parse_ss(): drop needless debug printVadim Yanitskiy2019-07-211-2/+0
| | | | Change-Id: Ie18c291d0cfe3b246d09ac6cfd9591951a2984c8
* osmo_get_rand_id(): Avoid dead code by proper #if/#else/#endifHarald Welte2019-07-211-1/+2
| | | | | Change-Id: I34e465dead179487f7d4508e0e6ecf0e838c6eb7 Closes: CID#177910
* cbsp.c: Remove dead codeHarald Welte2019-07-211-3/+1
| | | | | Change-Id: I0888fbad0f9094ec1b31e2cceecfc9cd372399bd Closes: CID#202057
* cbsp: Introduce osmo_cbsp_errstrHarald Welte2019-07-202-28/+100
| | | | | | | | | | | | | | Rather than having the encoder/decoder library print some log messages in case of encoding/decoding errors, let's provide something akin to 'errno', but with a string instead of a numeric error code. The 'osmo_cbsp_errstr' global variable (if set) contains a human-readable string describing the most recent encoding/decoding error. It exists separately for each thread and hence can be used safely in multi-threaded environments. Change-Id: Id9a5a595a76ba278647aee9470ded213d8464103
* CBSP (Cell Broadcast Service Protocol; 3GPP TS 48.049) supportHarald Welte2019-07-204-1/+1532
| | | | | | | | | | This introduces definitions as well as a parser+encoder for the Cell Broadcast Service Protocol (CBSP) as specified in 3GPP TS 48.049. CBSP is used on the interface between CBC and BSC. Related: OS#3537 Change-Id: I5b7ae08f67e415967b60ac4b824db9e22ca00935
* osmo_gsm48_rest_octets_si3_decode(): fix copy-paste error in commentVadim Yanitskiy2019-07-181-1/+1
| | | | Change-Id: I57a330e16cc2910597672e1b27cf971499cea5bc
* utils.h: require a semi colon after OSMO_ASSERTAlexander Couzens2019-07-081-3/+3
| | | | | | | | | When using `OSMO_ASSERT(exp);` clang will warn about an empty expression because the semi colon was superflous. Use do {} while (0) to enfore the need of a semi colon. This might break other test. Change-Id: I2272d29a81496164bebd1696a694383a28a86434
* gsm: lapd_core: Log timeout used upon start of T200Pau Espin Pedrol2019-06-211-1/+2
| | | | | | | | The timeout is calculated dynamically in t200_by_lchan() based on FN advance value estimated by bts_get_avg_fn_advance(), so it's informative to have the final value printed out. Change-Id: Ib50a9c23de881c66c9218833703cc41101e06bfd
* fix isdigit taking unsigned as inputKévin Redon2019-06-131-1/+1
| | | | | | | | | | | | | fixes the following error warnings when cross-compiling using: ./configure --enable-static --prefix=/usr/local/arm-none-eabi --host=arm-none-eabi --enable-embedded --disable-doxygen --disable-shared --disable-pseudotalloc --enable-external-tests CFLAGS="-Os -ffunction-sections -fdata-sections -nostartfiles -nodefaultlibs -Werror -Wno-error=deprecated -Wno-error=deprecated-declarations -Wno-error=cpp -mthumb -Os -mlong-calls -g3 -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -Wno-error=format" utils.c:1002:18: error: array subscript has type 'char' [-Werror=char-subscripts] 1002 | if (!isdigit(in[i])) gsm23003.c:414:34: error: array subscript has type 'char' [-Werror=char-subscripts] 414 | if (!mnc_str || !isdigit(mnc_str[0]) || strlen(mnc_str) > 3) Change-Id: Ia13fd5ee79fc6dc3291c0b99958ab3c01afee17d
* gsm48_decode_bcd_number2: fix ENOSPC edge caseOliver Smith2019-06-071-3/+13
| | | | | | | | | | | | | Return ENOSPC if the decoding buffer is one byte too small, instead of returning 0 and silently truncating the string. Add a new "truncated" variable to detect if the loop breaks in the final iteration. The string is not truncated if there is exactly one 0xf ('\0') higher nibble remaining. This is covered by the existing test case "long 15-digit (maximum) MSISDN, limited buffer". Related: OS#4049 Change-Id: Ie05900aca50cc7fe8a45d17844dbfcd905fd82fe
* lapd_core: Perform N200 retransmissions, not N200-1Harald Welte2019-06-051-4/+4
| | | | | | | | | | | | | | | During testing with BTS_Tests_LAPDm.TC_t200_n200() it was discovered that the existing LAPD[m] implementation always gave up at N200-1 retransmissions, rather than N200 retransmissions. The first transmission doesn't count, and hence we must have N200 actual re-transmissions. The Error message is then described as "T200 expired N200+1 times", i.e. we start T200 one more time after the last re-transmission and only give up if it expires again (i.e. no ACK received) Change-Id: Ic33854ee61311f73b7db55eeef10280349151097 Related: OS4037
* lapdm: Allow user to specify T200 values; Use correct N200 valuesHarald Welte2019-06-052-12/+76
| | | | | | | | | | | | | | | | | | TS 04.06 specifies a N200 re-transmission counter that depends on the channel type, which we didn't care about at all so far. Let's have the caller tell us the channel type so we can internally look up the correct N200 value for it. At the same time, permit the user to specify T200 re-transmission timer values for each SAPI on both DCCH and ACCH, which is required at least in the BTS as per GSM TS 12.21. Also, extend the timer resolution of the API from seconds to milli-seconds, which is more applicable as particularly on the FACCH the recommended values are in the 200ms range. Change-Id: I90fdc4dd4720d4e02213197c894eb0a55a39158c Related: OS#3906 Related: OS#2294 Related: OS#4037
* gsm0808_utils: Add gsm0808_decode_cell_id_u()Harald Welte2019-06-042-11/+59
| | | | | | | | | This function parses a single Cell ID list element into a 'union gsm0808_cell_id_u'. This function is going to be used by the upcoming CBSP support. Related: OS#3537 Change-Id: I08b33881667aa32f01e53ccb70d44d5b79c7c986
* make all library-internal static buffers thread-localHarald Welte2019-06-047-21/+21
| | | | | | | | | | | | | | | We have a number of library-internal static global buffers which are mainly used for various stringification functions. This worked as all of the related Osmocom programs were strictly single-threaded. Let's make those buffers at least thread-local. This way every thread gets their own set of buffers, and it's safe for multiple threads to execute the same functions once. They're of course still not re-entrant. If you need re-entrancy, you will need to use the _c() or _buf() suffix version of those functions and work with your own (stack or heap) buffers. Change-Id: I50eb2436a7c1261d79a9d2955584dce92780ca07
* lapdm: Don't truncate L3 payload at 200 bytes lengthHarald Welte2019-06-021-1/+1
| | | | | | | | | 3GPP TS 04.06 is quite clear that the [segmented] L3 payload can be as long as 251 bytes. Our libosmocore lapdm implementation truncated already at 200 bytes :( Change-Id: I6769986f27dda1d429ed7b2e32c36d34663acba9 Closes: OS#4035
* gsm48_encode_bcd_number(): clarify optional LHV header initializationVadim Yanitskiy2019-05-291-1/+7
| | | | Change-Id: Iafd911dd55691b3715391e3899cd6971245c8d7f
* rest_octets: Remove SI2ter + SI2bis encoders that don't do anythingHarald Welte2019-05-282-33/+0
| | | | | | | | The library should either provide functions that implement encoding of those rest octets, or it shouldn't. Providing a function that doesn't do anything but pad the buffer is useless. Change-Id: Ie10684de6a6b2663e2a871fcdb2b275b6ad7a1e7
* rest_octets: Implement actual SI6 rest octets encodingHarald Welte2019-05-281-11/+35
| | | | | | | | | There's very little sense behind introducing a function into libosmogsm which doesn't implement 90% of the spec. Let's allow the caller to provide the various optional bits of information to the encoder, rather than generating mostly static SI6 rest octets. Change-Id: Id75005a0c4a02ce7f809692d58b3bd226bc582b2
* rest_octets: Add function to parse SI3 rest octetsHarald Welte2019-05-282-0/+79
| | | | | | Change-Id: I690cf308311f910005a325d50f5d5d825678d2b2 Related: OS#3075 Related: OS#4023
* rest_octets: Suffix encoder functiosn with _encodeHarald Welte2019-05-282-18/+20
| | | | | | ... otherwise it's not really clear what they do. Change-Id: I08e0ca9a8d13c7aa40b9d90f34f0e13adb87d4e0
* rest_octets: Fix export of osmo_gsm48_rest_octetsHarald Welte2019-05-281-8/+8
| | | | | | | | the symbols had an omso_ prefix, while the entry in the .map file didn't. As a result, all related symbols were never exported and hence not usable by any users of the dynamic library. Change-Id: I8b1ee2405f6338507e9dfb5f1f437c4c2db2e330
* rest_octets: Actually include gsm48_rest_octets.c in Makefile.amHarald Welte2019-05-281-1/+1
| | | | | | | | | The gsm48_rest_octets.c file was added in Change-Id I47888965ab11bba1186c21987f1365c9270abeab, but it never actually ended up being compiled as it wasn't listed in the makefile :/ Change-Id: I0355115c2645f236c9e32cf7a563cf51a857e8a3 Relsted: OS#3075
* rest_octets: Use correct symbols names for range encoderHarald Welte2019-05-281-4/+4
| | | | | | | | | As gsm48_rest_octets.c is not listed in the Makefile.am, it's never actually compiled and we never noticed that it's calling functions by symbol names that don't exist :/ Change-Id: I7b1e436f70e0c60979261db87606f38271ec47d3 Related: OS#3075
* gsm48_rest_octets: Fix license: GPLv2+ instead of AGPLv3+Harald Welte2019-05-281-4/+6
| | | | | | | | | | | | | | libosmo{core,gsm,vty} code is GPLv2+. The rest octet code originated in osmo-bsc.git and was moved here without changing the license. That was a mistake, it always was meant to be under GPLv2-or-later after moving to libosmocore.git. Original copyright is mine. For contributions by sysmocom, I as the managing director can approve the license change. This means only Holger needs to ACK this. Change-Id: Ief3009dc28dd83e1e26a7101af2eed2341684a87
* gsm48_decode_bcd_number2(): return -EINVAL if LV has too big lengthVadim Yanitskiy2019-05-281-2/+2
| | | | Change-Id: Ie07b2e8bc2f9628904e88448b4ee63b359655123
* gsm48_decode_bcd_number2(): fix: return -ENOSPC on truncationVadim Yanitskiy2019-05-281-3/+13
| | | | | | | | The documentation of gsm48_decode_bcd_number2() clearly states that the output truncation is a erroneous case, so it should actually return negative in such cases. Let's return -ENOSPC. Change-Id: I75680f232001ba419a587fed4c24f32c70c3ad2b
* gsm48_decode_bcd_number2(): fix output truncationVadim Yanitskiy2019-05-281-2/+2
| | | | | | | | | | | | | | | | | Thanks to the new unit test for BCD number encoding / decoding, it was discovered that gsm48_decode_bcd_number2() does not properly handle encoded LV if the output buffer size is equal to the original MSISDN length + 1 (\0-terminator): one digit is lost. For example, decoding of 15-digit long MSISDN to a buffer of size 16 (15 digits + 1 for \0) would give us only 14 digits. The problem was that 'output_len' was being decremented before checking the remaining buffer length and writing a digit to it. As a result, the maximum length was always one byte shorter. Change-Id: I61d49387fedbf7b238e21540a5eff22f6861e27a Fixes: OS#4025
* oap_client: Fix license: GPLv2+ instead of AGPLv3+Harald Welte2019-05-271-4/+6
| | | | | | | | | | | | libosmo{core,gsm,vty} code is GPLv2+. The OAP code originated in osmo-msc.git and was moved here without changing the license. That was a mistake, it always was meant to be under GPLv2-or-later after moving to libosmocore.git. Copyright is with sysmocom, so I as the managing director can approve the license change. Change-Id: I08311fa8214c15f8df8945b9894226608cf96f15
* rsl: Add osmocom-specific extensions to RSL channel numbers for CBCHHarald Welte2019-05-271-0/+10
| | | | | | | | | | | We don't really *need* it in libosmocore as such, but the lack of having all osmocom extensions listed here lead to using overlapping definitions: 0x18 was used for dynamic PDCH on the Abis side, but also for CBCH on the L1SAP side. Let's list them all here to increase visibility in case anyone wants to extend this further... Related: OS#4027 Change-Id: I93e557358cf1c1b622f77f906959df7ca6d5cb12
* lapdm_rslms_recvmsg: Fix memory leak in error pathHarald Welte2019-05-191-1/+3
| | | | | | | | | | | | The caller of lapdm_rslms_recvmsg() (e.g. osmo-bts/src/common/rsl.c) assumes the message ownership is transferred. However, in one of the two error paths, msgb_free() was not called and hence we had a memory leak. Also clarify the msgb ownership transfer in a comment. Related: OS#3750 Change-Id: Id60cb45e50bfc89224d97df6c68fcd2949751895
* TLV: Add one-shot TLV encoderHarald Welte2019-05-192-0/+100
| | | | | | | | | | | | | | | | | So far, the TLV code contained two types of functions * tlp_parse() to parse all TLVs according to definition into tlvp_parsed * various helper functions to encode individual TLVs during message generation This patch implements the inverse of tlv_parse(): tlv_encode(), which takes a full 'struct tlv_pared' and encodes all IEs found in it. The order of IEs is in numerically ascending order of the tag. As many protocols have different IE/TLV ordering requirements, let's add a tlv_encode_ordered() function where the caller can specify the TLV ordering during the one-shot encode. Change-Id: I761a30bf20355a9f80a4a8e0c60b0b0f78515efe
* gsm_23_003: add GSM23003_MSISDN_{MIN,MAX}_DIGITSOliver Smith2019-05-151-1/+1
| | | | | | | | | | | Add the constant, so it can be used in create-subscriber-on-demand related patches. ITU-T Rec. E.164 6.1 states that maximum international number length should be 15. I did not find a source for a minimum length, but I've added the constant and set it to 1 for consistency (based on the existing osmo_msisdn_str_valid() function). Related: OS#2542 Change-Id: Idc74f4d94ad44b9fc1b6d43178f5f33d551ebfb1
* gsm0808: Introduce Osmocom extensions to announce Osmux supportPau Espin Pedrol2019-05-133-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | IE GSM0808_IE_OSMO_OSMUX_SUPPORT (T, 1 byte) is sent in AoIP appended to BSSMAP RESET in order to announce the peer that its MGW supports handling Osmux streams upon call set up. IE GSM0808_IE_OSMO_OSMUX_CID (TV, T 1 byte & V 1 byte) is sent in AoIP during call set up: * MSC->BSC Assignment Request * BSC->MSC Assignemnt Complete The 1 byte value contains the local Osmux CID, aka the recvCID aka CID where the peer sending the Assign Req/Compl will look for Osmux frames on that call. Hence, the peer receiving this CID value must use it to send Osmux frames for that call. As a result, a given call leg BSC<->MSC can have one different Osmux CID per direction. For example: * MS => MGW_BSC ==CID 0==> MGW_MSC * MS <= MGW_BSC <=CID 1=== MGW_MSC This allows for setups with 256 call legs per BSC on scenarios where NAT is not a problem, where MSC can have a pool of 256 CID per MGW_BSC (or remote peer). Related: OS#2551 Change-Id: I28f83e2e32b9533c99e65ccc1562900ac2aec74e
* gsm0808_utils: Introduce gsm0808_msgb_put_cell_id_u()Harald Welte2019-05-102-41/+43
| | | | | | | | | | | | This function is doing the bulk work of encoding a given Cell ID List item. gsm0808_enc_cell_id_list2() is modified to be a wrapper / loop around the new function. The purpose of this is to expose Cell ID List Entry encoding so that the upcoming CBSP protocol encoder can re-use this code. Related: OS#3537 Change-Id: I6cc567798e20365e6587e6b2988e834306d8c80c