summaryrefslogtreecommitdiffstats
path: root/src/gsm/tlv_parser.c
Commit message (Collapse)AuthorAgeFilesLines
* TLV: Add one-shot TLV encoderHarald Welte2019-05-191-0/+97
| | | | | | | | | | | | | | | | | 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
* add tlv_parse2(), capable of multiple instances of the same IENeels Hofmeyr2018-04-131-24/+68
| | | | | | | | | | | | | | | Allow passing multiple struct tlv_parsed in an array, to allow parsing as many repeated IEs as are expected by the caller. From tlv_parse(), call tlv_parse2() with dec_multiple = 1 to yield the previous behavior. tlv_parse() remains valid API. An example of multiple IEs is the BSSMAP Handover Request, containing Cell Identifier (Serving) and Cell Identifier (Target), both defined by 3GPP TS 48.008 3.2.2.17 with identical IE tags; both are mandatory. Related: OS#2283 (inter-BSC HO, BSC side) Change-Id: Id04008eaf0a1cafdbdc11b7efc556e3035b1c84d
* add a regression test for TLV parsing with repeated IEsStefan Sperling2018-03-161-2/+2
| | | | | | | | | | | | | Since commit bf383a1d83661af26ccd6521c49b655fb22531d4 tlv_parse() will return the first occurrence of a repeated IE. Add a test to verify this behaviour. This test passes with the current code and fails if bf383a1d83661af26ccd6521c49b655fb22531d4 is reverted. While here, fix lies in documentation about the return value of tlv_parse() and fix a typo in another comment. Change-Id: I041f38548c5e4236920991d6c681c1c1e04de9ca Related: OS#2904
* 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
* 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
* Fix/Update copyright notices; Add SPDX annotationHarald Welte2017-11-131-1/+4
| | | | | | | | 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-3/+2
| | | | | | | | | | | | | | | | | 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-7/+7
| | | | | | | | | | 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-1/+18
| | | | | | | | | 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
* Add parsed TLV helpers from OsmoBTSMax2017-01-061-0/+60
| | | | | | Add functions to copy and merge parsed TLV structures from OsmoBTS. Change-Id: Ieaaaed19da9c069fe451faa53d24c5b84d7d5615
* tlv: Import osmo_shift_* and osmo_match_shift_* from openbscHarald Welte2016-05-051-0/+171
| | | | | These routines have nothing to do with specifically the BSC, so import them to the TLV parser we keep in libosmogsm.
* fix some typosNeels Hofmeyr2015-11-021-2/+2
| | | | Sponsored-by: On-Waves ehi
* add missing copyright statements to source code filesHarald Welte2014-09-111-0/+19
| | | | | | Some source code files didn't have the usual copyright and licence statement at their top. I'm adding them baesed on information in the commitlog.
* misc: Doxygen tweaks: fixed some typos and minor errorsKaterina Barone-Adesi2013-02-151-1/+1
| | | | | Doxygen generates quite a lot of warnings on libosmocore. Some of them are obvious typos - this patch aims to fix such low-hanging fruit.
* TLV: add new "vTvLV" type for GANHarald Welte2012-07-141-1/+21
| | | | | | | | | | | | | This new TLV type is specific to TS 44.318. Contrary to the TvLV type of TS 08.16/08.18, it has an inverted meaning of the extension (0x80) bit: * if the extension bit is not set, 1-byte length * if the extension bit is set, 2-byte length Futhermore, it has support for variable-length tags, where the tag part can be optionally two bytes in length. As this esoteric option hasn't been seen in the wild yet, we only add encoding support but skip decoding for now.
* doc: Fix the Doxygen section endingsSylvain Munaut2012-04-181-1/+1
| | | | Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
* doxygen: Add documentation about TLV parserHarald Welte2011-08-171-15/+25
|
* include: reorganize headers file to include/osmocom/[gsm|core]Pablo Neira Ayuso2011-03-231-2/+2
| | | | | | | | | | | | 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/+179
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>