summaryrefslogtreecommitdiffstats
path: root/nsh-plugin/nsh/nsh.c
diff options
context:
space:
mode:
authorHongjun Ni <hongjun.ni@intel.com>2016-08-02 00:06:40 +0800
committerHongjun Ni <hongjun.ni@intel.com>2016-08-02 00:06:40 +0800
commitb8812f176859d958fc09217bd827ef7382502fb7 (patch)
treee04d686506868a421815f93f0cea2f5abaf54e5e /nsh-plugin/nsh/nsh.c
parented5a133ef8debf7580d6c5bc16187222244c8b0e (diff)
Add nsh entry dump API
Change-Id: I6664c9929b8332eb8f4d7bc33f0f99b458a71908 Signed-off-by: Hongjun Ni <hongjun.ni@intel.com>
Diffstat (limited to 'nsh-plugin/nsh/nsh.c')
-rw-r--r--nsh-plugin/nsh/nsh.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/nsh-plugin/nsh/nsh.c b/nsh-plugin/nsh/nsh.c
index 3c30af7..3e0da8a 100644
--- a/nsh-plugin/nsh/nsh.c
+++ b/nsh-plugin/nsh/nsh.c
@@ -74,6 +74,7 @@
#define foreach_nsh_plugin_api_msg \
_(NSH_ADD_DEL_ENTRY, nsh_add_del_entry) \
+ _(NSH_ENTRY_DUMP, nsh_entry_dump) \
_(NSH_ADD_DEL_MAP, nsh_add_del_map)
clib_error_t *
@@ -585,6 +586,49 @@ static void vl_api_nsh_add_del_entry_t_handler
REPLY_MACRO(VL_API_NSH_ADD_DEL_ENTRY_REPLY);
}
+static void send_nsh_entry_details
+(nsh_header_t * t, unix_shared_memory_queue_t * q, u32 context)
+{
+ vl_api_nsh_entry_details_t * rmp;
+
+ rmp = vl_msg_api_alloc (sizeof (*rmp));
+ memset (rmp, 0, sizeof (*rmp));
+
+ rmp->_vl_msg_id = ntohs(VL_API_NSH_ENTRY_DETAILS);
+ rmp->ver_o_c = t->ver_o_c;
+ rmp->length = t->length;
+ rmp->md_type = t->md_type;
+ rmp->next_protocol = t->next_protocol;
+ rmp->nsp_nsi = t->nsp_nsi;
+ rmp->c1 = t->c1;
+ rmp->c2 = t->c2;
+ rmp->c3 = t->c3;
+ rmp->c4 = t->c4;
+
+ rmp->context = context;
+
+ vl_msg_api_send_shmem (q, (u8 *)&rmp);
+}
+
+static void vl_api_nsh_entry_dump_t_handler
+(vl_api_nsh_entry_dump_t * mp)
+{
+ unix_shared_memory_queue_t * q;
+ nsh_main_t * nm = &nsh_main;
+ nsh_header_t * t;
+
+ q = vl_api_client_index_to_input_queue (mp->client_index);
+ if (q == 0) {
+ return;
+ }
+
+ pool_foreach (t, nm->nsh_entries,
+ ({
+ send_nsh_entry_details(t, q, mp->context);
+ }));
+}
+
+
static clib_error_t *
show_nsh_entry_command_fn (vlib_main_t * vm,
unformat_input_t * input,