diff options
author | Florin Coras <fcoras@cisco.com> | 2017-11-10 09:03:54 -0800 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2017-11-10 19:50:22 +0000 |
commit | 6e8c6679883f59542d85d1de3edabc7e811108d2 (patch) | |
tree | 55beb4d9ded6a221de506cd5f5240f4c64b50a3e /src | |
parent | af8dfbf6d8d3b5430a437e98e18f95998e9559ca (diff) |
session: add app ns index to ns create api
Change-Id: I86bfe4e8b0a899cc54c9b37eeb5eec701d0baf3d
Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/vat/api_format.c | 36 | ||||
-rw-r--r-- | src/vnet/session/session.api | 14 | ||||
-rwxr-xr-x | src/vnet/session/session_api.c | 20 |
3 files changed, 66 insertions, 4 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c index c75857bc111..43957e15dcc 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -5304,7 +5304,6 @@ _(p2p_ethernet_del_reply) \ _(lldp_config_reply) \ _(sw_interface_set_lldp_reply) \ _(tcp_configure_src_addresses_reply) \ -_(app_namespace_add_del_reply) \ _(dns_enable_disable_reply) \ _(dns_name_server_add_del_reply) \ _(session_rule_add_del_reply) \ @@ -21463,6 +21462,41 @@ api_tcp_configure_src_addresses (vat_main_t * vam) return ret; } +static void vl_api_app_namespace_add_del_reply_t_handler + (vl_api_app_namespace_add_del_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + if (retval == 0) + errmsg ("app ns index %d\n", ntohl (mp->appns_index)); + vam->result_ready = 1; + } +} + +static void vl_api_app_namespace_add_del_reply_t_handler_json + (vl_api_app_namespace_add_del_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + static int api_app_namespace_add_del (vat_main_t * vam) { diff --git a/src/vnet/session/session.api b/src/vnet/session/session.api index 6ed75efb08c..358103a4f56 100644 --- a/src/vnet/session/session.api +++ b/src/vnet/session/session.api @@ -348,7 +348,7 @@ autoreply define session_enable_disable { @param namespace_id_len - length of namespace id lower @param namespace_id - namespace id */ -autoreply define app_namespace_add_del { +define app_namespace_add_del { u32 client_index; u32 context; u64 secret; @@ -359,6 +359,18 @@ autoreply define app_namespace_add_del { u8 namespace_id[64]; }; +/** \brief Reply for app namespace add/del + @param context - returned sender context, to match reply w/ request + @param retval - return code + @param appns_index - app namespace index +*/ +define app_namespace_add_del_reply +{ + u32 context; + i32 retval; + u32 appns_index; +}; + /** \brief add/del session rule @param client_index - opaque cookie to identify the sender client to vpp direction only diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c index fb74e6bbff4..7de77ddfd34 100755 --- a/src/vnet/session/session_api.c +++ b/src/vnet/session/session_api.c @@ -748,8 +748,9 @@ static void vl_api_app_namespace_add_del_t_handler (vl_api_app_namespace_add_del_t * mp) { vl_api_app_namespace_add_del_reply_t *rmp; - u8 *ns_id = 0; clib_error_t *error = 0; + u32 appns_index = 0; + u8 *ns_id = 0; int rv = 0; if (!session_manager_is_enabled ()) { @@ -779,9 +780,24 @@ vl_api_app_namespace_add_del_t_handler (vl_api_app_namespace_add_del_t * mp) rv = clib_error_get_code (error); clib_error_report (error); } + else + { + appns_index = app_namespace_index_from_id (ns_id); + if (appns_index == APP_NAMESPACE_INVALID_INDEX) + { + clib_warning ("app ns lookup failed"); + rv = VNET_API_ERROR_UNSPECIFIED; + } + } vec_free (ns_id); + + /* *INDENT-OFF* */ done: - REPLY_MACRO (VL_API_APP_NAMESPACE_ADD_DEL_REPLY); + REPLY_MACRO2 (VL_API_APP_NAMESPACE_ADD_DEL_REPLY, ({ + if (!rv) + rmp->appns_index = clib_host_to_net_u32 (appns_index); + })); + /* *INDENT-ON* */ } static void |