diff options
author | Hongjun Ni <hongjun.ni@intel.com> | 2016-08-02 00:55:03 +0800 |
---|---|---|
committer | Hongjun Ni <hongjun.ni@intel.com> | 2016-08-02 00:55:03 +0800 |
commit | e566590ed0b45b1b230239a6a066f40bc4da3fb8 (patch) | |
tree | 0613632afffdc7856309faa1d37e1cc5d26f5f9c /nsh-plugin/nsh/nsh.c | |
parent | b8812f176859d958fc09217bd827ef7382502fb7 (diff) |
Add nsh_map_dump API
Change-Id: If901cf638c9142c362afeb9634a7cbcd458c0125
Signed-off-by: Hongjun Ni <hongjun.ni@intel.com>
Diffstat (limited to 'nsh-plugin/nsh/nsh.c')
-rw-r--r-- | nsh-plugin/nsh/nsh.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/nsh-plugin/nsh/nsh.c b/nsh-plugin/nsh/nsh.c index 3e0da8a..21a972e 100644 --- a/nsh-plugin/nsh/nsh.c +++ b/nsh-plugin/nsh/nsh.c @@ -75,7 +75,8 @@ #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) + _(NSH_ADD_DEL_MAP, nsh_add_del_map) \ + _(NSH_MAP_DUMP, nsh_map_dump) clib_error_t * vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, @@ -628,6 +629,42 @@ static void vl_api_nsh_entry_dump_t_handler })); } +static void send_nsh_map_details +(nsh_map_t * t, unix_shared_memory_queue_t * q, u32 context) +{ + vl_api_nsh_map_details_t * rmp; + + rmp = vl_msg_api_alloc (sizeof (*rmp)); + memset (rmp, 0, sizeof (*rmp)); + + rmp->_vl_msg_id = ntohs(VL_API_NSH_MAP_DETAILS); + rmp->nsp_nsi = t->nsp_nsi; + rmp->mapped_nsp_nsi = t->mapped_nsp_nsi; + rmp->sw_if_index = t->sw_if_index; + rmp->next_node = t->next_node; + + rmp->context = context; + + vl_msg_api_send_shmem (q, (u8 *)&rmp); +} + +static void vl_api_nsh_map_dump_t_handler +(vl_api_nsh_map_dump_t * mp) +{ + unix_shared_memory_queue_t * q; + nsh_main_t * nm = &nsh_main; + nsh_map_t * t; + + q = vl_api_client_index_to_input_queue (mp->client_index); + if (q == 0) { + return; + } + + pool_foreach (t, nm->nsh_mappings, + ({ + send_nsh_map_details(t, q, mp->context); + })); +} static clib_error_t * show_nsh_entry_command_fn (vlib_main_t * vm, |