summaryrefslogtreecommitdiffstats
path: root/src/gsm/gsm48_ie.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
* gsm48_encode_bcd_number(): clarify optional LHV header initializationVadim Yanitskiy2019-05-291-1/+7
| | | | Change-Id: Iafd911dd55691b3715391e3899cd6971245c8d7f
* 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
* gsm48_decode_bcd_number2(): allow avoiding deprecationNeels Hofmeyr2019-05-051-23/+25
| | | | | | | | gsm48_decode_bcd_number() is marked as deprecated, so gsm48_decode_bcd_number2() will cause deprecation warnings as long as it calls gsm48_decode_bcd_number(). Hence move the code to gsm48_decode_bcd_number2(). Change-Id: I81925e9afb3451de9b8a268d482f79ee20ca14d6
* gsm48_decode_bcd_number2(): fix input len checkNeels Hofmeyr2019-05-051-2/+3
| | | | | | | | | The input_len argument for gsm48_decode_bcd_number2() includes the BCD length *and* the length byte itself, so add the missing +1. Also clarify the API doc for the input_len argument. Change-Id: I87599641325c04aae2be224ec350b1a145039528
* add gsm48_decode_bcd_number2() from osmo-mscNeels Hofmeyr2019-05-031-1/+27
| | | | | | | | | | | | gsm48_decode_bcd_number() is unable to provide proper bounds validation of input and output data, hence osmo-msc's vlr.c introduced a static decode_bcd_number_safe() a long time ago. Move to libosmocore. I need to use the same function to decode an MSISDN during inter-MSC Handover, instead of making it public in osmo-msc, rather deprecate the unsafe function and provide a safer version for all callers. Mark the old one deprecated. Change-Id: Idb6ae6e2f3bea11ad420dae14d021ac36d99e921
* gsm48: gsm48_decode_freq_list: Improve documentation of paramter fPau Espin Pedrol2018-11-181-1/+1
| | | | Change-Id: Id8e3afff737211ded3c5689f2c83b1a544b42f9d
* Fix/Update copyright notices; Add SPDX annotationHarald Welte2017-11-131-0/+2
| | | | | | | | 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
* doxygen: unify use of \file across the boardNeels Hofmeyr2017-06-231-4/+5
| | | | | | | | | | | | | | | | | Considering the various styles and implications found in the sources, edit scores of files to follow the same API doc guidelines around the doxygen grouping and the \file tag. Many files now show a short description in the generated API doc that was so far only available as C comment. The guidelines and reasoning behind it is documented at https://osmocom.org/projects/cellular-infrastructure/wiki/Guidelines_for_API_documentation In some instances, remove file comments and add to the corresponding group instead, to be shared among several files (e.g. bitvec). Change-Id: Ifa70e77e90462b5eb2b0457c70fd25275910c72b
* doxygen: enable AUTOBRIEF, drop \briefNeels Hofmeyr2017-06-231-35/+35
| | | | | | | | | | Especially for short descriptions, it is annoying to have to type \brief for every single API doc. Drop all \brief and enable the AUTOBRIEF feature of doxygen, which always takes the first sentence of an API doc as the brief description. Change-Id: I11a8a821b065a128108641a2a63fb5a2b1916e87
* update/extend doxygen documentationHarald Welte2017-06-121-35/+87
| | | | | | | | | It's a pity that even with this patch we still are fare away from having the whole API documented. However, at least we have a more solid foundation. Updates not only extend the documentation, but also make sure it is rendered properly in the doxygen HTML. Change-Id: I1344bd1a6869fb00de7c1899a8db93bba9bafce3
* gsm/gsm48ie: Fix range 256 W[i] decodingJacob Erlbeck2014-01-131-4/+4
| | | | | | | | | Currently w[14]/w[15] and w[18]/w[19] are swapped in range 256 format decoding in gsm48_decode_freq_list(). This patch fixes this. Sponsored-by: On-Waves ehf
* GSM 04.08: Add support for parsing CSD related bearer capabilitiesHarald Welte2012-08-241-5/+90
| | | | Also adds a test case for both encoder and decoder of this IE
* gsm48_ie: annotate functions with chapter numbers from 04.08 specHarald Welte2012-08-241-29/+29
|
* gsm/gsm48_ie: Fix other range format decodingAndreas.Eversberg2011-09-021-66/+63
| | | | | | | | As it turns out, the other range were affected too, so Anreas wrote the fix for them as well. Written-by: Andreas.Eversberg <jolly@eversberg.eu> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
* gsm/gsm48_ie: Fix Range 256 format decodingSylvain Munaut2011-09-011-20/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From the mail: --- appended is another patch for fixing a bug in the calculation of the frequency lists. This time the patch is for the "Range 256 format". The problem is that the operand for the "smod" operation might be negative, in this case the simplified version won't work as expected. In the patch I introduced a separate function for "smod" which takes care of the sign. I have not yet checked if the other formats are also affected, this would be the case if the "smod" operand can be negative. There might be other solutions to fix the problem without the need for a separate function, however I have not thought further about it. A test vector is the following frequency list ("Range 256 format", first byte is the length): 09 8b 1c 83 8c 15 ef 02 2d 30 The correct ARFCNs are 569 571 576 578 586 608 712 715 719 The uncorrected version would instead return: 444 457 460 464 569 576 578 586 608 This means four ARFCNs are wrong which will cause problems if for example the frequency list contains the ARFCNs for hopping. ---- Written-by: Dieter Spaar <spaar@mirider.augusta.de> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
* gsm/gsm48_ie: Fix frequency list decodingAndreas.Eversberg2011-07-301-1/+1
| | | | | Fix-by: Andreas.Eversberg <jolly@eversberg.eu> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
* include: reorganize headers file to include/osmocom/[gsm|core]Pablo Neira Ayuso2011-03-231-6/+6
| | | | | | | | | | | | This patch moves all GSM-specific definitions to include/osmocom/gsm. Moreover, the headers in include/osmocore/ have been moved to include/osmocom/core. This has been proposed by Harald Welte and Sylvain Munaunt. Tested with `make distcheck'. Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
* This patch moves the GSM-specific functions to the new libraryPablo Neira Ayuso2011-03-231-0/+1095
libosmogsm which is provided by libosmocore. I have also moved generate_backtrace() to backtrace.c instead of gsm_utils.c, otherwise the timer and msgfile tests depend on libosmogsm. Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>