From 0d056e5ede136cd0111dc3f9f41ef7b36a938027 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Thu, 28 Sep 2017 15:11:16 -0400 Subject: vppapigen: support per-file (major,minor,patch) version stamps Add one of these statements to foo.api: vl_api_version 1.2.3 to generate a version tuple stanza in foo.api.h: /****** Version tuple *****/ vl_api_version_tuple(foo, 1, 2, 3) Change-Id: Ic514439e4677999daa8463a94f948f76b132ff15 Signed-off-by: Dave Barach Signed-off-by: Ole Troan --- src/vlibmemory/memclnt.api | 23 +++++++++++++++++++++++ src/vlibmemory/memory_vlib.c | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) (limited to 'src/vlibmemory') diff --git a/src/vlibmemory/memclnt.api b/src/vlibmemory/memclnt.api index 94c99ad5d45..6d6a1fe06dc 100644 --- a/src/vlibmemory/memclnt.api +++ b/src/vlibmemory/memclnt.api @@ -14,6 +14,8 @@ * limitations under the License. */ +vl_api_version 1.0.0 + /* * Create a client registration */ @@ -98,6 +100,27 @@ define get_first_msg_id_reply { u16 first_msg_id; }; +/* + * Get API version table (includes built-in and plugins) + */ +typeonly define module_version { + u32 major; + u32 minor; + u32 patch; + u8 name[64]; +}; +define api_versions { + u32 client_index; + u32 context; +}; +define api_versions_reply { + u32 client_index; + u32 context; + i32 retval; + u32 count; + vl_api_module_version_t api_versions[count]; +}; + /* * Trace the plugin message-id allocator * so we stand a chance of dealing with different sets of plugins diff --git a/src/vlibmemory/memory_vlib.c b/src/vlibmemory/memory_vlib.c index 2242abcfedf..c3aef65e854 100644 --- a/src/vlibmemory/memory_vlib.c +++ b/src/vlibmemory/memory_vlib.c @@ -470,12 +470,48 @@ vl_api_memclnt_keepalive_t_handler (vl_api_memclnt_keepalive_t * mp) vl_msg_api_send_shmem (shmem_hdr->vl_input_queue, (u8 *) & rmp); } +void +vl_api_api_versions_t_handler (vl_api_api_versions_t * mp) +{ + api_main_t *am = &api_main; + vl_api_api_versions_reply_t *rmp; + unix_shared_memory_queue_t *q; + u32 nmsg = vec_len (am->api_version_list); + int msg_size = sizeof (*rmp) + sizeof (rmp->api_versions[0]) * nmsg; + int i; + + q = vl_api_client_index_to_input_queue (mp->client_index); + if (q == 0) + return; + + rmp = vl_msg_api_alloc (msg_size); + memset (rmp, 0, msg_size); + rmp->_vl_msg_id = ntohs (VL_API_API_VERSIONS_REPLY); + + /* fill in the message */ + rmp->context = mp->context; + rmp->count = htonl (nmsg); + + for (i = 0; i < nmsg; ++i) + { + api_version_t *vl = &am->api_version_list[i]; + rmp->api_versions[i].major = htonl (vl->major); + rmp->api_versions[i].minor = htonl (vl->minor); + rmp->api_versions[i].patch = htonl (vl->patch); + strncpy ((char *) rmp->api_versions[i].name, vl->name, 64); + } + + vl_msg_api_send_shmem (q, (u8 *) & rmp); + +} + #define foreach_vlib_api_msg \ _(MEMCLNT_CREATE, memclnt_create) \ _(MEMCLNT_DELETE, memclnt_delete) \ _(GET_FIRST_MSG_ID, get_first_msg_id) \ _(MEMCLNT_KEEPALIVE, memclnt_keepalive) \ -_(MEMCLNT_KEEPALIVE_REPLY, memclnt_keepalive_reply) +_(MEMCLNT_KEEPALIVE_REPLY, memclnt_keepalive_reply) \ +_(API_VERSIONS, api_versions) /* * vl_api_init -- cgit 1.2.3-korg