1 // SPDX-License-Identifier: Apache-2.0
2 // Copyright(c) 2023 Cisco Systems, Inc.
5 #include <npt66/npt66.h>
7 #include <npt66/npt66.api_enum.h>
8 #include <npt66/npt66.api_types.h>
9 #include <vlibmemory/api.h>
10 #include <vnet/ip/ip.h>
11 #include <vnet/ip/ip_types_api.h>
12 #include <vpp/app/version.h>
14 npt66_main_t npt66_main;
17 * This file contains the API handlers for the pnat.api
20 #define REPLY_MSG_ID_BASE npt66_main.msg_id_base
21 #include <vlibapi/api_helper_macros.h>
24 vl_api_npt66_binding_add_del_t_handler (vl_api_npt66_binding_add_del_t *mp)
26 vl_api_npt66_binding_add_del_reply_t *rmp;
28 clib_warning ("Interface index: %d", mp->sw_if_index);
29 VALIDATE_SW_IF_INDEX_END (mp);
31 rv = npt66_binding_add_del (
32 mp->sw_if_index, (ip6_address_t *) &mp->internal.address, mp->internal.len,
33 (ip6_address_t *) &mp->external.address, mp->external.len, mp->is_add);
36 REPLY_MACRO_END (VL_API_NPT66_BINDING_ADD_DEL_REPLY);
40 #include <vnet/format_fns.h>
41 #include <npt66/npt66.api.c>
43 /* Set up the API message handling tables */
45 npt66_plugin_api_hookup (vlib_main_t *vm)
47 npt66_main_t *nm = &npt66_main;
49 nm->msg_id_base = setup_message_id_table ();
54 * Register the plugin and hook up the API
56 #include <vnet/plugin/plugin.h>
57 VLIB_PLUGIN_REGISTER () = {
58 .version = VPP_BUILD_VER,
59 .description = "NPTv6",
60 .default_disabled = 1,
64 npt66_init (vlib_main_t *vm)
66 npt66_main_t *nm = &npt66_main;
67 memset (nm, 0, sizeof (*nm));
69 return npt66_plugin_api_hookup (vm);
72 VLIB_INIT_FUNCTION (npt66_init);