summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-05-12 11:59:25 -0400
committerDamjan Marion <dmarion.lists@gmail.com>2017-05-17 18:37:10 +0000
commitbfd9227e6da567e0e19e026afe94cd4c0b65f725 (patch)
tree78d7b0995d12d26191554c9c53e33cdaec84fdcd /src
parent3291ecaec66158ba9743e67b7f183cf659f0e8b5 (diff)
Add vl_msg_api_get_message_length[_inline]
Change-Id: I6d86cf7966d51ec7a507bbb59c586adbfb45be05 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src')
-rw-r--r--src/vlibapi/api.h11
-rw-r--r--src/vlibapi/api_shared.c6
2 files changed, 17 insertions, 0 deletions
diff --git a/src/vlibapi/api.h b/src/vlibapi/api.h
index 7538050e7b2..3403e1c60d7 100644
--- a/src/vlibapi/api.h
+++ b/src/vlibapi/api.h
@@ -25,6 +25,7 @@
#include <vlib/vlib.h>
#include <vlibmemory/unix_shared_memory_queue.h>
#include <vlib/unix/unix.h>
+#include <stddef.h>
typedef enum
{
@@ -280,6 +281,7 @@ u16 vl_msg_api_get_msg_ids (const char *name, int n);
void vl_msg_api_add_msg_name_crc (api_main_t * am, const char *string,
u32 id);
u32 vl_api_get_msg_index (u8 * name_and_crc);
+u32 vl_msg_api_get_msg_length (void *msg_arg);
/* node_serialize.c prototypes */
u8 *vlib_node_serialize (vlib_node_main_t * nm, u8 * vector,
@@ -336,6 +338,15 @@ static void __vl_msg_api_add_##tag##_function_##x (void) \
_error = _f (ci); \
})
+static inline u32
+vl_msg_api_get_msg_length_inline (void *msg_arg)
+{
+ u8 *msg = (u8 *) msg_arg;
+
+ msgbuf_t *header = (msgbuf_t *) (msg - offsetof (msgbuf_t, data));
+
+ return clib_net_to_host_u32 (header->data_len);
+}
#endif /* included_api_h */
/*
diff --git a/src/vlibapi/api_shared.c b/src/vlibapi/api_shared.c
index 0817f38e40a..5c1a9940dc7 100644
--- a/src/vlibapi/api_shared.c
+++ b/src/vlibapi/api_shared.c
@@ -624,6 +624,12 @@ vl_msg_api_replay_handler (void *the_msg)
/* do NOT free the message buffer... */
}
+u32
+vl_msg_api_get_msg_length (void *msg_arg)
+{
+ return vl_msg_api_get_msg_length_inline (msg_arg);
+}
+
/*
* vl_msg_api_socket_handler
*/