42 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 48 #define vl_api_version(n,v) static u32 api_version=(v); 52 #define REPLY_MSG_ID_BASE sm->msg_id_base 57 #define foreach_sample_plugin_api_msg \ 58 _(SAMPLE_MACSWAP_ENABLE_DISABLE, sample_macswap_enable_disable) 63 .description =
"Sample of VPP Plugin",
82 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
87 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
90 sw_if_index, enable_disable, 0, 0);
101 u32 sw_if_index = ~0;
102 int enable_disable = 1;
116 if (sw_if_index == ~0)
125 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
127 (0,
"Invalid interface, only works on physical ports");
130 case VNET_API_ERROR_UNIMPLEMENTED:
145 .path =
"sample macswap",
147 "sample macswap <interface-name> [disable]",
157 vl_api_sample_macswap_enable_disable_reply_t * rmp;
164 REPLY_MACRO(VL_API_SAMPLE_MACSWAP_ENABLE_DISABLE_REPLY);
175 vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ 177 vl_api_##n##_t_handler, \ 179 vl_api_##n##_t_endian, \ 180 vl_api_##n##_t_print, \ 181 sizeof(vl_api_##n##_t), 1); 188 #define vl_msg_name_crc_list 190 #undef vl_msg_name_crc_list 195 #define _(id,n,crc) \ 196 vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + sm->msg_id_base); 197 foreach_vl_msg_name_crc_sample;
212 name =
format (0,
"sample_%08x%c", api_version, 0);
235 .arc_name =
"device-input",
236 .node_name =
"sample",
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...)
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