summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat66/nat66_api.c
diff options
context:
space:
mode:
authorFilip Varga <fivarga@cisco.com>2021-03-23 12:57:58 +0100
committerOle Tr�an <otroan@employees.org>2021-03-31 11:46:05 +0000
commited2ee5e57b0f65ac4a94aac84cb6c27468878ea4 (patch)
tree60ce5bb4f17bf57c12146c20db66cd19fdb233a4 /src/plugins/nat/nat66/nat66_api.c
parent7554aef84a8a406c9dae73a7445e8b97920a83b3 (diff)
nat: NAT66 plugin enable&disable calls update
Type: improvement Adding support for enable&disable calls (dynamic plugin configuration). API (nat66_plugin_enable_disable) and CLI (nat66 plugin enable/nat66 plugin disable) with support for outside_vrf id configuration. Change-Id: I5637ff1621d6662adc3b7c6f7f8176d84a4b492b Signed-off-by: Filip Varga <fivarga@cisco.com>
Diffstat (limited to 'src/plugins/nat/nat66/nat66_api.c')
-rw-r--r--src/plugins/nat/nat66/nat66_api.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/plugins/nat/nat66/nat66_api.c b/src/plugins/nat/nat66/nat66_api.c
index 2a2b3cc07ad..470c1fe48fa 100644
--- a/src/plugins/nat/nat66/nat66_api.c
+++ b/src/plugins/nat/nat66/nat66_api.c
@@ -23,9 +23,23 @@
#define REPLY_MSG_ID_BASE nm->msg_id_base
#include <vlibapi/api_helper_macros.h>
-/*************/
-/*** NAT66 ***/
-/*************/
+static void
+vl_api_nat66_plugin_enable_disable_t_handler (
+ vl_api_nat66_plugin_enable_disable_t *mp)
+{
+ nat66_main_t *nm = &nat66_main;
+ vl_api_nat66_plugin_enable_disable_reply_t *rmp;
+ int rv = 0;
+
+ if (mp->enable)
+ {
+ rv = nat66_plugin_enable (ntohl (mp->outside_vrf));
+ }
+ else
+ rv = nat66_plugin_disable ();
+
+ REPLY_MACRO (VL_API_NAT66_PLUGIN_ENABLE_DISABLE_REPLY);
+}
static void
vl_api_nat66_add_del_interface_t_handler (vl_api_nat66_add_del_interface_t *
@@ -96,6 +110,10 @@ static void
vl_api_nat66_interface_dump_t_handler (vl_api_nat66_interface_dump_t * mp)
{
vl_api_registration_t *rp;
+ nat66_main_t *nm = &nat66_main;
+
+ if (PREDICT_FALSE (!nm->enabled))
+ return;
rp = vl_api_client_index_to_registration (mp->client_index);
if (rp == 0)
@@ -145,6 +163,10 @@ vl_api_nat66_static_mapping_dump_t_handler (vl_api_nat66_static_mapping_dump_t
* mp)
{
vl_api_registration_t *rp;
+ nat66_main_t *nm = &nat66_main;
+
+ if (PREDICT_FALSE (!nm->enabled))
+ return;
rp = vl_api_client_index_to_registration (mp->client_index);
if (rp == 0)
@@ -167,8 +189,6 @@ clib_error_t *
nat66_plugin_api_hookup (vlib_main_t * vm)
{
nat66_main_t *nm = &nat66_main;
-
nm->msg_id_base = setup_message_id_table ();
-
return 0;
}