Analogous to NFTNL_SET_DESC_CONCAT, introduce a data structure describing individual data lengths of elements' concatenated data fields. Signed-off-by: Phil Sutter <phil@xxxxxx> --- include/libnftnl/set.h | 1 + include/set.h | 2 ++ src/set.c | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/include/libnftnl/set.h b/include/libnftnl/set.h index 1ffb6c415260d..958bbc9065f67 100644 --- a/include/libnftnl/set.h +++ b/include/libnftnl/set.h @@ -33,6 +33,7 @@ enum nftnl_set_attr { NFTNL_SET_EXPR, NFTNL_SET_EXPRESSIONS, NFTNL_SET_DESC_BYTEORDER, + NFTNL_SET_DESC_CONCAT_DATA, __NFTNL_SET_MAX }; #define NFTNL_SET_MAX (__NFTNL_SET_MAX - 1) diff --git a/include/set.h b/include/set.h index 816bd24faf651..a9f6225401a4e 100644 --- a/include/set.h +++ b/include/set.h @@ -28,6 +28,8 @@ struct nftnl_set { uint32_t byteorder; uint8_t field_len[NFT_REG32_COUNT]; uint8_t field_count; + uint8_t data_len[NFT_REG32_COUNT]; + uint8_t data_count; } desc; struct list_head element_list; diff --git a/src/set.c b/src/set.c index 651eaf5503dee..e793282175eb5 100644 --- a/src/set.c +++ b/src/set.c @@ -100,6 +100,7 @@ void nftnl_set_unset(struct nftnl_set *s, uint16_t attr) case NFTNL_SET_TIMEOUT: case NFTNL_SET_GC_INTERVAL: case NFTNL_SET_DESC_BYTEORDER: + case NFTNL_SET_DESC_CONCAT_DATA: break; case NFTNL_SET_USERDATA: xfree(s->user.data); @@ -221,6 +222,10 @@ int nftnl_set_set_data(struct nftnl_set *s, uint16_t attr, const void *data, case NFTNL_SET_DESC_BYTEORDER: s->desc.byteorder = *(uint32_t *)data; break; + case NFTNL_SET_DESC_CONCAT_DATA: + memcpy(&s->desc.data_len, data, data_len); + while (s->desc.data_len[++s->desc.data_count]); + break; } s->flags |= (1 << attr); return 0; @@ -318,6 +323,9 @@ const void *nftnl_set_get_data(const struct nftnl_set *s, uint16_t attr, case NFTNL_SET_DESC_BYTEORDER: *data_len = sizeof(uint32_t); return &s->desc.byteorder; + case NFTNL_SET_DESC_CONCAT_DATA: + *data_len = s->desc.data_count; + return s->desc.data_len; } return NULL; } -- 2.33.0