aboutsummaryrefslogtreecommitdiffstats
path: root/tests/tlv
AgeCommit message (Collapse)AuthorFilesLines
2023-05-02Fix 'Fix parsing of TLV_TYPE_SINGLE_TV'Pau Espin Pedrol1-4/+2
A commit was merged recently attempting to fix decoding of TLV_TYPE_SINGLE_TV. It did mostly a good job, but missed updating the o_tag pointer used to fill in the structures. This commit fixes that specific part missing. Fixes: 559a6ee68359dab691a483573982e6f8c6439ae2 Change-Id: Id619459c17976b77cd2c7e4179123bb06807285c
2023-05-02tlv: Show bug in decoded tlv_parsed for type TLV_TYPE_SINGLE_TVPau Espin Pedrol1-0/+27
A commit was merged recently attempting to fix decoding of TLV_TYPE_SINGLE_TV. It did mostly a good job, but missed updating the o_tag pointer used to fill in the structures. This new unit test showcases the mentioned problem. A follow-up patch will fix the bug. Change-Id: Ia17c84059a413f80c2bcf194034ebac586ecf7e1
2022-11-03Support building with -Werror=strict-prototypes / -Werror=old-style-definitionHarald Welte1-5/+5
Unfortunately "-std=c99" is not sufficient to make gcc ignore code that uses constructs of earlier C standards, which were abandoned in C99. See https://lwn.net/ml/fedora-devel/Y1kvF35WozzGBpc8@redhat.com/ for some related discussion. Change-Id: I84fd99442d0cc400fa562fa33623c142649230e2
2021-03-18tlv: Fix length returned by t{l16,16l}v_putDaniel Willmann1-0/+32
Every other function returns a pointer to the first byte after the tlv that was just written. tl16v seems to be a copy and paste error from tlv16 above and t16lv seems to count the 16-bit tag twice. The new tests verify that the return value of *_put(buf, tag, len, val) points to buf + *_GROSS_LEN(len). Change-Id: I268a7e11fb5dce67ce1bd7974ab86c4d2bd002f7
2021-01-12tlv_parser: Fix various out-of-bounds accessesHarald Welte2-0/+99
The libosmocore TLV parser had a number of insufficient bounds checks leading to reads beyond the end of the respective input buffer. This patch * adds proper out-of-bounds checks to all TLV types * simplifies some of the existing checks * introduces test cases to test all the corner cases where either TAG, or length, or value are not fully contained in the input buffer. Thanks to Ilja Van Sprundel for reporting these problems. Change-Id: I98b02c914c9e3ecf56050af846292aa6979d7508
2019-05-19TLV: Add one-shot TLV encoderHarald Welte2-0/+49
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
2018-04-13add tlv_parse2(), capable of multiple instances of the same IENeels Hofmeyr1-0/+11
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
2018-04-06use osmo_init_logging2() with proper talloc ctxNeels Hofmeyr1-1/+1
Ironically, when deprecating osmo_init_logging() in I216837780e9405fdaec8059c63d10699c695b360, I forgot to change the callers within libosmocore itself, i.e. in the various regression tests. Change-Id: Ia36c248f99353d5baaa2533f46a2f60a8579bdf8
2018-03-16add a regression test for TLV parsing with repeated IEsStefan Sperling1-0/+31
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
2017-06-18tlv_test.c: Fix compilation warningsPau Espin Pedrol1-19/+25
Several warnings like the one below are fixed: warning: array subscript is below array bounds [-Warray-bounds] uint8_t *unchanged_ptr = buf - 1; Change-Id: I35d7d926939c14700cbca732bd64e588c75424b4
2016-05-05tlv: Import osmo_shift_* and osmo_match_shift_* from openbscHarald Welte2-0/+252
These routines have nothing to do with specifically the BSC, so import them to the TLV parser we keep in libosmogsm.