api: add to_net parameter to endian messages 25/40825/7
authorOle Troan <otroan@employees.org>
Fri, 26 Apr 2024 12:11:20 +0000 (14:11 +0200)
committerDamjan Marion <dmarion@0xa5.net>
Tue, 7 May 2024 09:59:31 +0000 (09:59 +0000)
commit1a319aadc68c218f741a7cb23acbe70c4addae92
tree766211fc3f5b37de2626f2f7895094fc5c44f896
parent4013851e42b94ebfa0a2ae398c58ecc9ea9b5c95
api: add to_net parameter to endian messages

The VPP API auto-generated endian conversion functions are intended to
be symmetrical. They are used both by the API client and the API server.
Called on send to convert from host endian to network endian and on
receive to convert back.

For variable length arrays, we have to iterate over the array and call
a more specific handler for the array type. Unfortunately the length of
the array is part of the api definition, and if it's endian swapped
prior to the for loop, unexpected behaviour will ensue.

There was an earlier fix, for some specific messages, but unfortunately
that only fixed the problem from the VPP (server) side.

This adds a new parameters to the endian handler, so the boundary
argument to the loop can be treated differently depending on if this
message is to the network or from the network.

Type: fix
Change-Id: I43011aed384e3b847579a1dd2c390867ae17a9ad
Signed-off-by: Ole Troan <otroan@employees.org>
13 files changed:
src/plugins/acl/acl_test.c
src/plugins/ikev2/ikev2_api.c
src/plugins/ikev2/ikev2_test.c
src/plugins/nat/nat44-ed/nat44_ed_api.c
src/plugins/nat/nat44-ei/nat44_ei_api.c
src/plugins/nat/pnat/pnat_api.c
src/tools/vppapigen/vppapigen_c.py
src/vat2/vat2_helpers.h
src/vlibapi/api_common.h
src/vlibapi/api_helper_macros.h
src/vlibapi/api_shared.c
src/vlibmemory/memory_api.c
src/vlibmemory/vlib_api_cli.c