diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2022-03-14 16:38:15 +0100 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2022-06-16 13:04:33 +0200 |
commit | 8b58faa4c2e1b52802293f4dce9fcc8dc3843b47 (patch) | |
tree | 45ac008dd575470212b72ac5d52df2cbc04e5d35 /include/osmocom/gtlv/gtlv_gen.h | |
parent | e011b04c6b2e31bdc46320e5d8a4f48715681f15 (diff) |
libosmo-gtlv: add TLIV capability
During code review, it was indicated that some TLV protocols that we
will likely deal with in the near future also employ an I, and 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: SYS#5599
Change-Id: I0a076e54dfba6038cc779cb7c8f3967d212226aa
Diffstat (limited to 'include/osmocom/gtlv/gtlv_gen.h')
-rw-r--r-- | include/osmocom/gtlv/gtlv_gen.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/include/osmocom/gtlv/gtlv_gen.h b/include/osmocom/gtlv/gtlv_gen.h index a2f088b..71cec92 100644 --- a/include/osmocom/gtlv/gtlv_gen.h +++ b/include/osmocom/gtlv/gtlv_gen.h @@ -37,6 +37,10 @@ struct osmo_gtlv_gen_ie; #define OSMO_GTLV_GEN_O_MULTI(MAX, TLV_GEN_IE, MEMB_NAME) { MEMB_NAME, .multi = MAX, .ie = &(TLV_GEN_IE) } #define OSMO_GTLV_GEN_M_MULTI(MAX, MAND_COUNT, TLV_GEN_IE, MEMB_NAME) \ { MEMB_NAME, .multi = MAX, .multi_mandatory = MAND_COUNT, .ie = &(TLV_GEN_IE) } +#define OSMO_GTLV_GEN_O_INST(INSTANCE, TLV_GEN_IE, MEMB_NAME) { MEMB_NAME, .optional = true, .instance = INSTANCE, .ie = &TLV_GEN_IE } +#define OSMO_GTLV_GEN_M_INST(INSTANCE, TLV_GEN_IE, MEMB_NAME) { MEMB_NAME, .instance = INSTANCE, .ie = &(TLV_GEN_IE) } + +#define OSMO_GTLV_GEN_NO_INSTANCE INT_MAX /*! osmo_gtlv_gen_ie with all members == NULL, so that all are derived from the member name. */ extern const struct osmo_gtlv_gen_ie osmo_gtlv_gen_ie_auto; @@ -81,6 +85,10 @@ struct osmo_gtlv_gen_ie_o { /*! Number of mandatory occurences of the IE, only has an effect if .multi > 0. */ unsigned int multi_mandatory; + /* If any, the instance nr to match, in C that yields an unsigned int. + * e.g. "1" or "MYPROTO_FOO_INST_ONE". */ + const char *instance; + /*! IE decoding / encoding instructions. If NULL, the entire IE definition is derived from .name. * 'MYPROTO_IEI_NAME', 'myproto_dec_name()', 'myproto_enc_name()', 'myproto_enc_to_str_name()'. * Your myproto_ies_custom.h needs to define an enum value MYPROTO_IEI_NAME and*/ @@ -96,7 +104,9 @@ struct osmo_gtlv_gen_ie { * When there are no nested IEs, the type needs to be defined manually by a myproto_ies_custom.h. */ const char *decoded_type; - /*! C name of this tag value, e.g. "MYPROTO_IEI_FOO". If NULL, take "MYPROTO_IEI_"+upper(name) instead. */ + /*! C name of this tag value, e.g. "foo" to use tag "MYPROTO_IEI_FOO". + * If NULL, take "MYPROTO_IEI_"+upper(memb_name) instead, where memb_name comes from the osmo_gtlv_gen_ie_o. + * decoded_type and/or dec_enc may be derived from this, if they are NULL. */ const char *tag_name; /*! Name suffix of the dec/enc functions. "foo" -> myproto_dec_foo(), myproto_enc_foo(), |