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",
81 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
86 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
89 sw_if_index, enable_disable, 0, 0);
100 u32 sw_if_index = ~0;
101 int enable_disable = 1;
115 if (sw_if_index == ~0)
124 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
126 (0,
"Invalid interface, only works on physical ports");
129 case VNET_API_ERROR_UNIMPLEMENTED:
144 .path =
"sample macswap",
146 "sample macswap <interface-name> [disable]",
156 vl_api_sample_macswap_enable_disable_reply_t * rmp;
163 REPLY_MACRO(VL_API_SAMPLE_MACSWAP_ENABLE_DISABLE_REPLY);
174 vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ 176 vl_api_##n##_t_handler, \ 178 vl_api_##n##_t_endian, \ 179 vl_api_##n##_t_print, \ 180 sizeof(vl_api_##n##_t), 1); 187 #define vl_msg_name_crc_list 189 #undef vl_msg_name_crc_list 194 #define _(id,n,crc) \ 195 vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + sm->msg_id_base); 196 foreach_vl_msg_name_crc_sample;
211 name =
format (0,
"sample_%08x%c", api_version, 0);
234 .arc_name =
"device-input",
235 .node_name =
"sample",
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...)
sample_main_t sample_main
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
u16 vl_msg_api_get_msg_ids(const char *name, int n)