Line data Source code
1 : // SPDX-License-Identifier: Apache-2.0 2 : // Copyright(c) 2023 Cisco Systems, Inc. 3 : 4 : #include <stdbool.h> 5 : #include <npt66/npt66.h> 6 : #include <vnet/vnet.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> 13 : 14 : npt66_main_t npt66_main; 15 : 16 : /* 17 : * This file contains the API handlers for the pnat.api 18 : */ 19 : 20 : #define REPLY_MSG_ID_BASE npt66_main.msg_id_base 21 : #include <vlibapi/api_helper_macros.h> 22 : 23 : static void 24 16 : vl_api_npt66_binding_add_del_t_handler (vl_api_npt66_binding_add_del_t *mp) 25 : { 26 : vl_api_npt66_binding_add_del_reply_t *rmp; 27 : int rv; 28 16 : clib_warning ("Interface index: %d", mp->sw_if_index); 29 16 : VALIDATE_SW_IF_INDEX_END (mp); 30 : 31 16 : rv = npt66_binding_add_del ( 32 16 : mp->sw_if_index, (ip6_address_t *) &mp->internal.address, mp->internal.len, 33 16 : (ip6_address_t *) &mp->external.address, mp->external.len, mp->is_add); 34 : 35 16 : bad_sw_if_index: 36 16 : REPLY_MACRO_END (VL_API_NPT66_BINDING_ADD_DEL_REPLY); 37 : } 38 : 39 : /* API definitions */ 40 : #include <vnet/format_fns.h> 41 : #include <npt66/npt66.api.c> 42 : 43 : /* Set up the API message handling tables */ 44 : clib_error_t * 45 1 : npt66_plugin_api_hookup (vlib_main_t *vm) 46 : { 47 1 : npt66_main_t *nm = &npt66_main; 48 : 49 1 : nm->msg_id_base = setup_message_id_table (); 50 1 : return 0; 51 : } 52 : 53 : /* 54 : * Register the plugin and hook up the API 55 : */ 56 : #include <vnet/plugin/plugin.h> 57 : VLIB_PLUGIN_REGISTER () = { 58 : .version = VPP_BUILD_VER, 59 : .description = "NPTv6", 60 : .default_disabled = 1, 61 : }; 62 : 63 : clib_error_t * 64 1 : npt66_init (vlib_main_t *vm) 65 : { 66 1 : npt66_main_t *nm = &npt66_main; 67 1 : memset (nm, 0, sizeof (*nm)); 68 : 69 1 : return npt66_plugin_api_hookup (vm); 70 : } 71 : 72 2 : VLIB_INIT_FUNCTION (npt66_init);