41 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 47 #define vl_api_version(n,v) static u32 api_version=(v); 51 #define REPLY_MSG_ID_BASE sm->msg_id_base 56 #define foreach_sample_plugin_api_msg \ 57 _(SAMPLE_MACSWAP_ENABLE_DISABLE, sample_macswap_enable_disable) 62 .description =
"Sample of VPP Plugin",
83 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
88 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
91 sw_if_index, enable_disable, 0, 0);
102 u32 sw_if_index = ~0;
103 int enable_disable = 1;
117 if (sw_if_index == ~0)
126 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
128 (0,
"Invalid interface, only works on physical ports");
131 case VNET_API_ERROR_UNIMPLEMENTED:
146 .path =
"sample macswap",
148 "sample macswap <interface-name> [disable]",
158 vl_api_sample_macswap_enable_disable_reply_t * rmp;
165 REPLY_MACRO(VL_API_SAMPLE_MACSWAP_ENABLE_DISABLE_REPLY);
176 vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ 178 vl_api_##n##_t_handler, \ 180 vl_api_##n##_t_endian, \ 181 vl_api_##n##_t_print, \ 182 sizeof(vl_api_##n##_t), 1); 189 #define vl_msg_name_crc_list 191 #undef vl_msg_name_crc_list 196 #define _(id,n,crc) \ 197 vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + sm->msg_id_base); 198 foreach_vl_msg_name_crc_sample;
213 name =
format (0,
"sample_%08x%c", api_version, 0);
236 .arc_name =
"device-input",
237 .node_name =
"sample",
sample_main_t sample_main
u16 vl_msg_api_get_msg_ids(const char *name, int n)
vnet_main_t * vnet_get_main(void)
vnet_interface_main_t interface_main
static void vl_api_sample_macswap_enable_disable_t_handler(vl_api_sample_macswap_enable_disable_t *mp)
Plugin API message handler.
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
unformat_function_t unformat_vnet_sw_interface
#define SAMPLE_PLUGIN_BUILD_VER
#define VLIB_INIT_FUNCTION(x)
#define clib_error_return(e, args...)
API main structure, used by both vpp and binary API clients.
int sample_macswap_enable_disable(sample_main_t *sm, u32 sw_if_index, int enable_disable)
Enable/disable the macswap plugin.
#define vec_free(V)
Free vector's memory (no header).
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
#define VLIB_CLI_COMMAND(x,...)
static void setup_message_id_table(sample_main_t *sm, api_main_t *am)
static clib_error_t * sample_init(vlib_main_t *vm)
Initialize the sample plugin.
#define VNET_FEATURES(...)
static clib_error_t * sample_plugin_api_hookup(vlib_main_t *vm)
Set up the API message handling tables.
vnet_sw_interface_t * sw_interfaces
VNET_FEATURE_INIT(sample, static)
Hook the sample plugin into the VPP graph hierarchy.
vnet_sw_interface_type_t type
static clib_error_t * macswap_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
#define foreach_sample_plugin_api_msg