diff options
| author | Jakub Kicinski <kuba@kernel.org> | 2025-04-29 08:46:59 -0700 |
|---|---|---|
| committer | Paolo Abeni <pabeni@redhat.com> | 2025-05-02 12:41:02 +0200 |
| commit | 0ea8cf56cc20ed51cfbef7c6410874ac7fd07642 (patch) | |
| tree | c97c26fa4812415fd3df3d71bea9bc22b914d082 /tools/net/ynl/lib | |
| parent | 49398830a4aa650c00b402477042c90db7d6214c (diff) | |
| download | linux-next-0ea8cf56cc20ed51cfbef7c6410874ac7fd07642.tar.gz linux-next-0ea8cf56cc20ed51cfbef7c6410874ac7fd07642.zip | |
tools: ynl-gen: multi-attr: type gen for string
Add support for multi attr strings (needed for link alt_names).
We record the length individual strings in a len member, to do
the same for multi-attr create a struct ynl_string in ynl.h
and use it as a layer holding both the string and its length.
Since strings may be arbitrary length dynamically allocate each
individual one.
Adjust arg_member and struct member to avoid spacing the double
pointers to get "type **name;" rather than "type * *name;"
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Link: https://patch.msgid.link/20250429154704.2613851-8-kuba@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'tools/net/ynl/lib')
| -rw-r--r-- | tools/net/ynl/lib/ynl.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/net/ynl/lib/ynl.h b/tools/net/ynl/lib/ynl.h index 59256e258130..6b8a625aaa5f 100644 --- a/tools/net/ynl/lib/ynl.h +++ b/tools/net/ynl/lib/ynl.h @@ -85,6 +85,19 @@ struct ynl_sock { unsigned char raw_buf[]; }; +/** + * struct ynl_string - parsed individual string + * @len: length of the string (excluding terminating character) + * @str: value of the string + * + * Parsed and nul-terminated string. This struct is only used for arrays of + * strings. Non-array string members are placed directly in respective types. + */ +struct ynl_string { + unsigned int len; + char str[]; +}; + struct ynl_sock * ynl_sock_create(const struct ynl_family *yf, struct ynl_error *e); void ynl_sock_destroy(struct ynl_sock *ys); |
