diff options
author | 2016-07-19 14:47:43 -0700 | |
---|---|---|
committer | 2016-07-19 14:47:43 -0700 | |
commit | c61080e76c9771de6f2beaba23fabe3aa4764a9b (patch) | |
tree | 254a447737a2c2797252629fc56e7f1a9a5c9b0e /vpp/vpp-api/api.c | |
parent | 3b2944d5f1bc7b42b31293d0d19f36b237490cd6 (diff) |
VPP-203 Find the relative next node index by node names
vat# get_next_index node-name vxlan4-input next-node-name l2-input
next node index 1
Change-Id: Ib71be8a408d08d59b0ed7dfb6ada9711cf29bd69
Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
Diffstat (limited to 'vpp/vpp-api/api.c')
-rw-r--r-- | vpp/vpp-api/api.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c index f3909287..f6b1b739 100644 --- a/vpp/vpp-api/api.c +++ b/vpp/vpp-api/api.c @@ -368,7 +368,8 @@ _(CLASSIFY_TABLE_INFO,classify_table_info) \ _(CLASSIFY_SESSION_DUMP,classify_session_dump) \ _(CLASSIFY_SESSION_DETAILS,classify_session_details) \ _(IPFIX_ENABLE,ipfix_enable) \ -_(IPFIX_DUMP,ipfix_dump) +_(IPFIX_DUMP,ipfix_dump) \ +_(GET_NEXT_INDEX, get_next_index) #define QUOTE_(x) #x #define QUOTE(x) QUOTE_(x) @@ -4243,6 +4244,48 @@ static void vl_api_get_node_index_t_handler })) } +static void vl_api_get_next_index_t_handler +(vl_api_get_next_index_t * mp) +{ + vlib_main_t * vm = vlib_get_main(); + vl_api_get_next_index_reply_t * rmp; + vlib_node_t * node, * next_node; + int rv = 0; + u32 next_node_index = ~0, next_index = ~0; + uword * p; + + node = vlib_get_node_by_name (vm, mp->node_name); + + if (node == 0) { + rv = VNET_API_ERROR_NO_SUCH_NODE; + goto out; + } + + next_node = vlib_get_node_by_name (vm, mp->next_name); + + if (next_node == 0) { + rv = VNET_API_ERROR_NO_SUCH_NODE2; + goto out; + } + else + next_node_index = next_node->index; + + p = hash_get (node->next_slot_by_node, next_node_index); + + if (p == 0) { + rv = VNET_API_ERROR_NO_SUCH_ENTRY; + goto out; + } + else + next_index = p[0]; + + out: + REPLY_MACRO2(VL_API_GET_NEXT_INDEX_REPLY, + ({ + rmp->next_index = ntohl(next_index); + })); +} + static void vl_api_add_node_next_t_handler (vl_api_add_node_next_t * mp) { |