diff options
author | 2019-07-08 08:51:15 -0400 | |
---|---|---|
committer | 2019-07-28 14:22:11 +0000 | |
commit | 3cf9e67f5963e5f317e849892a6ec55be70a782d (patch) | |
tree | d9bda9132d556653f1af0a3dff7b6baf194af36c /src/vpp/api/types.c | |
parent | 2648e4474eee9df539d644cf22e67cd04385f0ba (diff) |
api: add vl_api_version_t type
Type: feature
Depends-on: https://gerrit.fd.io/r/20484
Change-Id: Ifc8d7e00d7254db40856a088fdd352d9773f71d5
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'src/vpp/api/types.c')
-rw-r--r-- | src/vpp/api/types.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/vpp/api/types.c b/src/vpp/api/types.c index f9993b1883b..f2acf25ce62 100644 --- a/src/vpp/api/types.c +++ b/src/vpp/api/types.c @@ -102,6 +102,20 @@ format_vl_api_mac_address (u8 * s, va_list * args) return (format (s, "%U", format_ethernet_address, mac)); } +u8 * +format_vl_api_version (u8 * s, va_list * args) +{ + vl_api_version_t *ver = va_arg (*args, vl_api_version_t *); + s = format(s, "%d.%d.%d", ver->major, ver->minor, ver->patch); + if (ver->pre_release[0] != 0) + { + s = format(s, "-%v", ver->pre_release); + if (ver->build_metadata[0] != 0) + s = format(s, "+%v", ver->build_metadata); + } + return s; +} + uword unformat_vl_api_mac_address (unformat_input_t * input, va_list * args) { @@ -219,3 +233,19 @@ unformat_vl_api_mprefix (unformat_input_t * input, va_list * args) return (1); } +uword unformat_vl_api_version (unformat_input_t * input, va_list * args) +{ +vl_api_version_t *ver = va_arg (*args, vl_api_version_t *); + +if (unformat (input, "%d.%d.%d-%s+%s", ver->major, ver->minor, ver->patch, ver->pre_release, ver->build_metadata + )) + return (1); +else if (unformat (input, "%d.%d.%d-%s", ver->major, ver->minor, ver->patch, ver->pre_release + )) + return (1); +else if (unformat (input, "%d.%d.%d", ver->major, ver->minor, ver->patch + )) + return (1); + + return (0); +} |