X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Facl%2Facl_test.c;h=a35f050fcba77d77890ee4fbbaf3ae6f78c3c5f6;hb=492a5d0bd;hp=991d877f7af36b3bbae632905e7323e06a6a8ad4;hpb=15dff7234270b5f4ad724d3a69d3ed73db2a966b;p=vpp.git diff --git a/src/plugins/acl/acl_test.c b/src/plugins/acl/acl_test.c index 991d877f7af..a35f050fcba 100644 --- a/src/plugins/acl/acl_test.c +++ b/src/plugins/acl/acl_test.c @@ -31,28 +31,14 @@ uword unformat_sw_if_index (unformat_input_t * input, va_list * args); /* Declare message IDs */ -#include - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* define message structures */ -#define vl_endianfun -#include -#undef vl_endianfun - -/* instantiate all the print functions we know about */ +#include +#include #define vl_print(handle, ...) -#define vl_printfun -#include -#undef vl_printfun - -/* Get the API version number. */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include -#undef vl_api_version +#include +#undef vl_print +#define vl_endianfun /* define message structures */ +#include +#undef vl_endianfun typedef struct { /* API message ID base */ @@ -62,35 +48,11 @@ typedef struct { acl_test_main_t acl_test_main; -#define foreach_standard_reply_retval_handler \ -_(acl_del_reply) \ -_(acl_interface_add_del_reply) \ -_(macip_acl_interface_add_del_reply) \ -_(acl_interface_set_acl_list_reply) \ -_(acl_interface_set_etype_whitelist_reply) \ -_(macip_acl_del_reply) - #define foreach_reply_retval_aclindex_handler \ _(acl_add_replace_reply) \ _(macip_acl_add_reply) \ _(macip_acl_add_replace_reply) -#define _(n) \ - static void vl_api_##n##_t_handler \ - (vl_api_##n##_t * mp) \ - { \ - vat_main_t * vam = acl_test_main.vat_main; \ - i32 retval = ntohl(mp->retval); \ - if (vam->async_mode) { \ - vam->async_errors += (retval < 0); \ - } else { \ - vam->retval = retval; \ - vam->result_ready = 1; \ - } \ - } -foreach_standard_reply_retval_handler; -#undef _ - #define _(n) \ static void vl_api_##n##_t_handler \ (vl_api_##n##_t * mp) \ @@ -155,6 +117,13 @@ static void vl_api_acl_interface_list_details_t_handler vam->result_ready = 1; } +static void vl_api_macip_acl_interface_list_details_t_handler +(vl_api_macip_acl_interface_list_details_t * mp) +{ + // NOT YET IMPLEMENTED +} + + static void vl_api_acl_interface_etype_whitelist_details_t_handler (vl_api_acl_interface_etype_whitelist_details_t * mp) { @@ -175,7 +144,14 @@ static void vl_api_acl_interface_etype_whitelist_details_t_handler vam->result_ready = 1; } - +static void vl_api_acl_plugin_get_conn_table_max_entries_reply_t_handler + (vl_api_acl_plugin_get_conn_table_max_entries_reply_t * mp) + { + vat_main_t * vam = acl_test_main.vat_main; + clib_warning("\nConn table max entries: %d", + __bswap_64(mp->conn_table_max_entries) ); + vam->result_ready = 1; + } static inline u8 * vl_api_acl_rule_t_pretty_format (u8 *out, vl_api_acl_rule_t * a) @@ -281,29 +257,6 @@ static void vl_api_acl_plugin_control_ping_reply_t_handler } } - -/* - * Table of message reply handlers, must include boilerplate handlers - * we just generated - */ -#define foreach_vpe_api_reply_msg \ -_(ACL_ADD_REPLACE_REPLY, acl_add_replace_reply) \ -_(ACL_DEL_REPLY, acl_del_reply) \ -_(ACL_INTERFACE_ADD_DEL_REPLY, acl_interface_add_del_reply) \ -_(ACL_INTERFACE_SET_ACL_LIST_REPLY, acl_interface_set_acl_list_reply) \ -_(ACL_INTERFACE_SET_ETYPE_WHITELIST_REPLY, acl_interface_set_etype_whitelist_reply) \ -_(ACL_INTERFACE_ETYPE_WHITELIST_DETAILS, acl_interface_etype_whitelist_details) \ -_(ACL_INTERFACE_LIST_DETAILS, acl_interface_list_details) \ -_(ACL_DETAILS, acl_details) \ -_(MACIP_ACL_ADD_REPLY, macip_acl_add_reply) \ -_(MACIP_ACL_ADD_REPLACE_REPLY, macip_acl_add_replace_reply) \ -_(MACIP_ACL_DEL_REPLY, macip_acl_del_reply) \ -_(MACIP_ACL_DETAILS, macip_acl_details) \ -_(MACIP_ACL_INTERFACE_ADD_DEL_REPLY, macip_acl_interface_add_del_reply) \ -_(MACIP_ACL_INTERFACE_GET_REPLY, macip_acl_interface_get_reply) \ -_(ACL_PLUGIN_CONTROL_PING_REPLY, acl_plugin_control_ping_reply) \ -_(ACL_PLUGIN_GET_VERSION_REPLY, acl_plugin_get_version_reply) - static int api_acl_plugin_get_version (vat_main_t * vam) { acl_test_main_t * sm = &acl_test_main; @@ -313,7 +266,7 @@ static int api_acl_plugin_get_version (vat_main_t * vam) vam->result_ready = 0; mp = vl_msg_api_alloc_as_if_client(msg_size); - memset (mp, 0, msg_size); + clib_memset (mp, 0, msg_size); mp->_vl_msg_id = ntohs (VL_API_ACL_PLUGIN_GET_VERSION + sm->msg_id_base); mp->client_index = vam->my_client_index; @@ -334,7 +287,7 @@ static int api_macip_acl_interface_get (vat_main_t * vam) vam->result_ready = 0; mp = vl_msg_api_alloc_as_if_client(msg_size); - memset (mp, 0, msg_size); + clib_memset (mp, 0, msg_size); mp->_vl_msg_id = ntohs (VL_API_MACIP_ACL_INTERFACE_GET + sm->msg_id_base); mp->client_index = vam->my_client_index; @@ -357,6 +310,16 @@ static int api_macip_acl_interface_get (vat_main_t * vam) } while (0) +/* NOT YET IMPLEMENTED */ +static int api_acl_plugin_control_ping (vat_main_t * vam) +{ + return 0; +} +static int api_macip_acl_interface_list_dump (vat_main_t * vam) +{ + return 0; +} + static int api_acl_add_replace (vat_main_t * vam) { acl_test_main_t * sm = &acl_test_main; @@ -519,7 +482,7 @@ static int api_acl_add_replace (vat_main_t * vam) msg_size += n_rules*sizeof(rules[0]); mp = vl_msg_api_alloc_as_if_client(msg_size); - memset (mp, 0, msg_size); + clib_memset (mp, 0, msg_size); mp->_vl_msg_id = ntohs (VL_API_ACL_ADD_REPLACE + sm->msg_id_base); mp->client_index = vam->my_client_index; if ((n_rules > 0) && rules) @@ -545,6 +508,57 @@ static int api_acl_add_replace (vat_main_t * vam) return ret; } +static int api_acl_plugin_get_conn_table_max_entries (vat_main_t * vam) +{ + acl_test_main_t * sm = &acl_test_main; + vl_api_acl_plugin_get_conn_table_max_entries_t * mp; + u32 msg_size = sizeof(*mp); + int ret; + + vam->result_ready = 0; + mp = vl_msg_api_alloc_as_if_client(msg_size); + memset (mp, 0, msg_size); + mp->_vl_msg_id = ntohs (VL_API_ACL_PLUGIN_GET_CONN_TABLE_MAX_ENTRIES + sm->msg_id_base); + mp->client_index = vam->my_client_index; + + /* send it... */ + S(mp); + + /* Wait for a reply... */ + W (ret); + return ret; +} + +static int api_acl_stats_intf_counters_enable (vat_main_t * vam) +{ + acl_test_main_t * sm = &acl_test_main; + unformat_input_t * i = vam->input; + vl_api_acl_stats_intf_counters_enable_t * mp; + u32 msg_size = sizeof(*mp); + int ret; + + vam->result_ready = 0; + mp = vl_msg_api_alloc_as_if_client(msg_size); + memset (mp, 0, msg_size); + mp->_vl_msg_id = ntohs (VL_API_ACL_STATS_INTF_COUNTERS_ENABLE + sm->msg_id_base); + mp->client_index = vam->my_client_index; + mp->enable = 1; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { + if (unformat (i, "disable")) + mp->enable = 0; + else + break; + } + + /* send it... */ + S(mp); + + /* Wait for a reply... */ + W (ret); + return ret; +} + /* * Read the series of ACL entries from file in the following format: @@ -652,7 +666,6 @@ api_acl_add_replace_from_file (vat_main_t * vam) rules[rule_idx].proto = proto; } - rules[rule_idx].is_permit = is_permit; if (append_default_permit) { rule_idx++; @@ -693,7 +706,7 @@ api_acl_add_replace_from_file (vat_main_t * vam) msg_size += n_rules*sizeof(rules[0]); mp = vl_msg_api_alloc_as_if_client(msg_size); - memset (mp, 0, msg_size); + clib_memset (mp, 0, msg_size); mp->_vl_msg_id = ntohs (VL_API_ACL_ADD_REPLACE + sm->msg_id_base); mp->client_index = vam->my_client_index; if (n_rules > 0) @@ -1257,7 +1270,7 @@ static int api_macip_acl_add (vat_main_t * vam) msg_size += n_rules*sizeof(rules[0]); mp = vl_msg_api_alloc_as_if_client(msg_size); - memset (mp, 0, msg_size); + clib_memset (mp, 0, msg_size); mp->_vl_msg_id = ntohs (VL_API_MACIP_ACL_ADD + sm->msg_id_base); mp->client_index = vam->my_client_index; if ((n_rules > 0) && rules) @@ -1409,7 +1422,7 @@ static int api_macip_acl_add_replace (vat_main_t * vam) msg_size += n_rules*sizeof(rules[0]); mp = vl_msg_api_alloc_as_if_client(msg_size); - memset (mp, 0, msg_size); + clib_memset (mp, 0, msg_size); mp->_vl_msg_id = ntohs (VL_API_MACIP_ACL_ADD_REPLACE + sm->msg_id_base); mp->client_index = vam->my_client_index; if ((n_rules > 0) && rules) @@ -1436,70 +1449,12 @@ static int api_macip_acl_add_replace (vat_main_t * vam) return ret; } -/* - * List of messages that the api test plugin sends, - * and that the data plane plugin processes - */ -#define foreach_vpe_api_msg \ -_(acl_plugin_get_version, "") \ -_(acl_add_replace, " [ [src IP/plen] [dst IP/plen] [sport X-Y] [dport X-Y] [proto P] [tcpflags FL MASK], ... , ...") \ -_(acl_add_replace_from_file, "filename [permit] [append-default-permit]") \ -_(acl_del, "") \ -_(acl_dump, "[]") \ -_(acl_interface_add_del, " | sw_if_index [add|del] [input|output] acl ") \ -_(acl_interface_set_acl_list, " | sw_if_index input [acl-idx list] output [acl-idx list]") \ -_(acl_interface_set_etype_whitelist, " | sw_if_index input [ethertype list] output [ethertype list]") \ -_(acl_interface_etype_whitelist_dump, "[ | sw_if_index ]") \ -_(acl_interface_list_dump, "[ | sw_if_index ]") \ -_(macip_acl_add, "...") \ -_(macip_acl_add_replace, " [ [count ] [src] ip mac mask , ... , ...") \ -_(macip_acl_del, "")\ -_(macip_acl_dump, "[]") \ -_(macip_acl_interface_add_del, " | sw_if_index [add|del] acl ") \ -_(macip_acl_interface_get, "") - - -static -void acl_vat_api_hookup (vat_main_t *vam) +#define VL_API_LOCAL_SETUP_MESSAGE_ID_TABLE local_setup_message_id_table +static void local_setup_message_id_table (vat_main_t * vam) { - acl_test_main_t * sm = &acl_test_main; - /* Hook up handlers for replies from the data plane plug-in */ -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ - #n, \ - vl_api_##n##_t_handler, \ - vl_noop_handler, \ - vl_api_##n##_t_endian, \ - vl_api_##n##_t_print, \ - sizeof(vl_api_##n##_t), 1); - foreach_vpe_api_reply_msg; -#undef _ - - /* API messages we can send */ -#define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n); - foreach_vpe_api_msg; -#undef _ - - /* Help strings */ -#define _(n,h) hash_set_mem (vam->help_by_name, #n, h); - foreach_vpe_api_msg; -#undef _ + hash_set_mem (vam->function_by_name, "acl_add_replace_from_file", api_acl_add_replace_from_file); + hash_set_mem (vam->help_by_name, "acl_add_replace_from_file", + "filename [permit] [append-default-permit]"); } -clib_error_t * vat_plugin_register (vat_main_t *vam) -{ - acl_test_main_t * sm = &acl_test_main; - u8 * name; - - sm->vat_main = vam; - - name = format (0, "acl_%08x%c", api_version, 0); - sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); - - if (sm->msg_id_base != (u16) ~0) - acl_vat_api_hookup (vam); - - vec_free(name); - - return 0; -} +#include