diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/vpp/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/vpp/api/types.c | 30 | ||||
-rw-r--r-- | src/vpp/api/types.h | 2 | ||||
-rw-r--r-- | src/vpp/api/vpe_all_api_h.h | 1 | ||||
-rw-r--r-- | src/vpp/api/vpe_types.api | 13 |
5 files changed, 47 insertions, 0 deletions
diff --git a/src/vpp/CMakeLists.txt b/src/vpp/CMakeLists.txt index a5ac2f6d81a..401f1d01190 100644 --- a/src/vpp/CMakeLists.txt +++ b/src/vpp/CMakeLists.txt @@ -34,6 +34,7 @@ add_custom_target(vpp_version_h option(VPP_API_TEST_BUILTIN "Use builtin VPP API test." ON) set(VPP_API_FILES + api/vpe_types.api api/vpe.api ) 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); +} diff --git a/src/vpp/api/types.h b/src/vpp/api/types.h index 95797b4da2e..e77b52e6cf7 100644 --- a/src/vpp/api/types.h +++ b/src/vpp/api/types.h @@ -33,6 +33,7 @@ extern uword unformat_vl_api_ip4_address (unformat_input_t * input, va_list * ar extern uword unformat_vl_api_ip6_address (unformat_input_t * input, va_list * args); extern uword unformat_vl_api_prefix (unformat_input_t * input, va_list * args); extern uword unformat_vl_api_mprefix (unformat_input_t * input, va_list * args); +extern uword unformat_vl_api_version (unformat_input_t * input, va_list * args); extern u8 *format_vl_api_address (u8 * s, va_list * args); extern u8 *format_vl_api_address_family (u8 * s, va_list * args); @@ -42,5 +43,6 @@ extern u8 *format_vl_api_address_union (u8 * s, va_list * args); extern u8 *format_vl_api_prefix (u8 * s, va_list * args); extern u8 *format_vl_api_mprefix (u8 * s, va_list * args); extern u8 *format_vl_api_mac_address (u8 * s, va_list * args); +extern u8 *format_vl_api_version (u8 * s, va_list * args); #endif diff --git a/src/vpp/api/vpe_all_api_h.h b/src/vpp/api/vpe_all_api_h.h index 397cd8074b3..7f8a2265aae 100644 --- a/src/vpp/api/vpe_all_api_h.h +++ b/src/vpp/api/vpe_all_api_h.h @@ -26,6 +26,7 @@ #undef included_from_layer_3 /* Include the current layer (third) vpp API definition layer */ +#include <vpp/api/vpe_types.api.h> #include <vpp/api/vpe.api.h> /* diff --git a/src/vpp/api/vpe_types.api b/src/vpp/api/vpe_types.api new file mode 100644 index 00000000000..f1d6e5456cd --- /dev/null +++ b/src/vpp/api/vpe_types.api @@ -0,0 +1,13 @@ + +typeonly define version +{ + u32 major; + u32 minor; + u32 patch; + + /* since we can't guarantee that only fixed length args will follow the typedef, + string type not supported for typedef for now. */ + u8 pre_release[17]; /* 16 + "\0" */ + u8 build_metadata[17]; /* 16 + "\0" */ +}; + |