mirror of https://gerrit.osmocom.org/libosmocore
tlv_parser: Report *first* occurrence of repeated IEs
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
This commit is contained in:
parent
6de34ee46b
commit
bf383a1d83
|
@ -276,8 +276,13 @@ int tlv_parse(struct tlv_parsed *dec, const struct tlv_definition *def,
|
|||
&buf[ofs], buf_len-ofs);
|
||||
if (rv < 0)
|
||||
return rv;
|
||||
dec->lv[tag].val = val;
|
||||
dec->lv[tag].len = len;
|
||||
/* Most GSM related protocols clearly indicate that in case of duplicate
|
||||
* IEs, only the first occurrence shall be used, while any further occurrences
|
||||
* shall be ignored. See e.g. 3GPP TS 24.008 Section 8.6.3 */
|
||||
if (dec->lv[tag].val == NULL) {
|
||||
dec->lv[tag].val = val;
|
||||
dec->lv[tag].len = len;
|
||||
}
|
||||
ofs += rv;
|
||||
num_parsed++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue