Attention is currently required from: neels. Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/libosmocore/+/28286
to look at the new patch set (#2).
Change subject: add libosmo-gtlv, moved from osmo-upf.git ......................................................................
add libosmo-gtlv, moved from osmo-upf.git
libosmo-gtlv does not strictly conform to the libosmocore Makefile.am structure, because it was first added in osmo-upf.git, and because we use other Makefile.am conventions outside of libosmocore.git: - use of SUBDIRS instead of single top level Makefile.am - name of libosmo-gtlv with a dash, other libs here omit a dash. - name of src dirs being "libosmo-gtlv" instead of just "gtlv".
I hope that code review agrees with this choice of rather keeping the code conforming to our conventions that we established later, and not strictly changing to follow "legacy" conventions in libosmocore.git.
Pasting initial libosmo-gtlv commit logs from osmo-upf.git:
(1) TLV skeleton traversal:
An all new TLV parser supporting:
- Any size of T and L (determined by callback function), - "Grouped IEs", so that an IE payload is a nested IE structure, - optional/mandatory/multi-occurence IEs, - decoding unordered tags (or enforcing strict order).
Will be used for PFCP message decoding and encoding, a T16L16V protocol which requires above features.
Upcoming patches add - translating PDUs to plain C structs and vice versa - TLV generator to reduce repetition a in protocol definition - TLIV capability
Previously, the way we deal with TLVs causes a lot of code re-implementation: the TL decoding is taken care of by the API, but for encoding, we essentially re-implement each protocol and each encoded message in the individual programs. This API is an improvement in that we only once implement the TL coding (or just use osmo_t8l8v_cfg / osmo_t16l16v_cfg), get symmetric de- and encoding of the TL, and only need to deal with the value part of each IE.
The common pattern of - store TL preliminarily, - write V data and - update L after V is complete is conveniently done by osmo_gtlv_put_update_tl().
(2) Decoding and encoding user data:
Add osmo_gtlv_coding: describe the value part of a TLV (decode and encode), describe a struct with its members, and get/put readily decoded structs from/to a raw PDU, directly.
With osmo_gtlv_coding defined for a protocol's tags, we only deal with encoded PDUs or fully decoded C structs, no TLV related re-implementations clutter up the message handling code.
A usage example is given in gtlv_dec_enc_test. The first real use will be the PFCP protocol in osmo-upf.git.
With osmo_gtlv_coding, there still is a lot of monkey work involved in describing the decoded structs. A subsequent patch adds a generator for osmo_gtlv_coding and message structs from tag value lists.
(3) TLIV support:
During code review, it was indicated that some TLV protocols that we will likely deal with in the near future also employ an I, an instance value of a tag. Add TLIV support.
A usage example for a manually implemented TLIV structure is found in tests/libosmo-gtlv/gtlv_test.c.
A usage example for a generated TLIV protocol is found in tests/libosmo-gtlv/test_tliv/.
Related: OS#5599 Related: Id72cdf94da60d4b6d09d0044c74e672c4412c15d (osmo-upf) Change-Id: I25ab400f0c5707fdc0d8e480aca19871c2e26e71 --- M Makefile.am M configure.ac M include/Makefile.am A include/osmocom/gtlv/gtlv.h A include/osmocom/gtlv/gtlv_dec_enc.h A include/osmocom/gtlv/gtlv_gen.h A libosmo-gtlv.pc.in A src/libosmo-gtlv/Makefile.am A src/libosmo-gtlv/gtlv.c A src/libosmo-gtlv/gtlv_dec_enc.c A src/libosmo-gtlv/gtlv_gen.c M tests/Makefile.am A tests/libosmo-gtlv/Makefile.am A tests/libosmo-gtlv/gtlv_dec_enc_test.c A tests/libosmo-gtlv/gtlv_dec_enc_test.ok A tests/libosmo-gtlv/gtlv_test.c A tests/libosmo-gtlv/gtlv_test.ok A tests/libosmo-gtlv/test_gtlv_gen/Makefile.am A tests/libosmo-gtlv/test_gtlv_gen/gen__myproto_ies_auto.c A tests/libosmo-gtlv/test_gtlv_gen/gtlv_gen_test.c A tests/libosmo-gtlv/test_gtlv_gen/gtlv_gen_test.ok A tests/libosmo-gtlv/test_gtlv_gen/myproto_ies_custom.c A tests/libosmo-gtlv/test_gtlv_gen/myproto_ies_custom.h A tests/libosmo-gtlv/test_tliv/Makefile.am A tests/libosmo-gtlv/test_tliv/gen__myproto_ies_auto.c A tests/libosmo-gtlv/test_tliv/myproto_ies_custom.c A tests/libosmo-gtlv/test_tliv/myproto_ies_custom.h A tests/libosmo-gtlv/test_tliv/tliv_test.c A tests/libosmo-gtlv/test_tliv/tliv_test.ok M tests/testsuite.at 30 files changed, 4,780 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/86/28286/2