diff options
| author | Igor Ryzhov <iryzhov@nfware.com> | 2024-01-29 01:05:14 +0200 |
|---|---|---|
| committer | Igor Ryzhov <iryzhov@nfware.com> | 2024-01-31 02:20:13 +0200 |
| commit | c19d0a5bf3428fd7bb11275bb8882e3d65e77d16 (patch) | |
| tree | 7560975c1532e31d90e516b3c9c33a5fcad1d0ec /lib/mgmt_msg_native.h | |
| parent | dda5de0340f30ed15cc172046b451e013ad5e16e (diff) | |
mgmtd: add our own format definitions for frontend messages
It allows people not familiar with libyang and FRR internals to use
mgmtd FE API by looking only at `mgmt_msg_native.h` header. We still use
the same values to avoid a lot of mapping code, and ensure that any
change doesn't slip unnoticed by using static asserts.
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'lib/mgmt_msg_native.h')
| -rw-r--r-- | lib/mgmt_msg_native.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/mgmt_msg_native.h b/lib/mgmt_msg_native.h index ab305b125b..7273170a13 100644 --- a/lib/mgmt_msg_native.h +++ b/lib/mgmt_msg_native.h @@ -162,6 +162,22 @@ DECLARE_MTYPE(MSG_NATIVE_NOTIFY); #define MGMT_MSG_DATASTORE_RUNNING 2 #define MGMT_MSG_DATASTORE_OPERATIONAL 3 +/* + * Formats + */ +#define MGMT_MSG_FORMAT_XML 1 +#define MGMT_MSG_FORMAT_JSON 2 +#define MGMT_MSG_FORMAT_BINARY 3 /* non-standard libyang internal format */ + +/* + * Now we're using LYD_FORMAT directly to avoid mapping code, but having our + * own definitions allows us to create such a mapping in the future if libyang + * makes a backwards incompatible change. + */ +_Static_assert(MGMT_MSG_FORMAT_XML == LYD_XML, "Format mismatch"); +_Static_assert(MGMT_MSG_FORMAT_JSON == LYD_JSON, "Format mismatch"); +_Static_assert(MGMT_MSG_FORMAT_BINARY == LYD_LYB, "Format mismatch"); + /** * struct mgmt_msg_header - Header common to all native messages. * @@ -244,8 +260,8 @@ _Static_assert(sizeof(struct mgmt_msg_tree_data) == "Size mismatch"); /* Flags for get-data request */ -#define GET_DATA_FLAG_STATE 0x01 /* get only "config false" data */ -#define GET_DATA_FLAG_CONFIG 0x02 /* get only "config true" data */ +#define GET_DATA_FLAG_STATE 0x01 /* include "config false" data */ +#define GET_DATA_FLAG_CONFIG 0x02 /* include "config true" data */ #define GET_DATA_FLAG_EXACT 0x04 /* get exact data node instead of the full tree */ /* |
