X-Git-Url: https://gerrit.fd.io/r/gitweb?p=vpp.git;a=blobdiff_plain;f=src%2Fplugins%2Flb%2Flb_test.c;h=7176be8c8d8193e9b763262235cc5ee1aa80560d;hp=3da7eb04ffb17845957ca62e6efbd52ff4360647;hb=ae0724034;hpb=10bbfce0264249354f14243fbc166ee0beb41366 diff --git a/src/plugins/lb/lb_test.c b/src/plugins/lb/lb_test.c index 3da7eb04ffb..7176be8c8d8 100644 --- a/src/plugins/lb/lb_test.c +++ b/src/plugins/lb/lb_test.c @@ -23,6 +23,10 @@ #define __plugin_msg_base lb_test_main.msg_id_base #include +#include +#include +#include + //TODO: Move that to vat/plugin_api.c ////////////////////////// uword unformat_ip46_address (unformat_input_t * input, va_list * args) @@ -62,37 +66,6 @@ uword unformat_ip46_prefix (unformat_input_t * input, va_list * args) } ///////////////////////// -#define vl_msg_id(n,h) n, -typedef enum { -#include - /* We'll want to know how many messages IDs we need... */ - VL_MSG_FIRST_AVAILABLE, -} vl_msg_id_t; -#undef vl_msg_id - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* declare message handlers for each api */ - -#define vl_endianfun /* define message structures */ -#include -#undef vl_endianfun - -/* instantiate all the print functions we know about */ -#define vl_print(handle, ...) -#define vl_printfun -#include -#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 - typedef struct { /* API message ID base */ u16 msg_id_base; @@ -101,38 +74,6 @@ typedef struct { lb_test_main_t lb_test_main; -#define foreach_standard_reply_retval_handler \ -_(lb_conf_reply) \ -_(lb_add_del_vip_reply) \ -_(lb_add_del_as_reply) - -#define _(n) \ - static void vl_api_##n##_t_handler \ - (vl_api_##n##_t * mp) \ - { \ - vat_main_t * vam = lb_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 _ - -/* - * Table of message reply handlers, must include boilerplate handlers - * we just generated - */ -#define foreach_vpe_api_reply_msg \ - _(LB_CONF_REPLY, lb_conf_reply) \ - _(LB_ADD_DEL_VIP_REPLY, lb_add_del_vip_reply) \ - _(LB_ADD_DEL_AS_REPLY, lb_add_del_as_reply) \ - _(LB_VIP_DETAILS, lb_vip_details) \ - _(LB_AS_DETAILS, lb_as_details) - static int api_lb_conf (vat_main_t * vam) { unformat_input_t *line_input = vam->input; @@ -336,6 +277,41 @@ static int api_lb_add_del_as (vat_main_t * vam) return ret; } +static int api_lb_flush_vip (vat_main_t * vam) +{ + + unformat_input_t *line_input = vam->input; + vl_api_lb_flush_vip_t *mp; + int ret; + ip46_address_t vip_prefix; + u8 vip_plen; + + if (!unformat(line_input, "%U", unformat_ip46_prefix, + &vip_prefix, &vip_plen, IP46_TYPE_ANY)) + { + errmsg ("lb_add_del_as: invalid vip prefix\n"); + return -99; + } + + M(LB_FLUSH_VIP, mp); + clib_memcpy (mp->pfx.address.un.ip6, &vip_prefix.ip6, sizeof (vip_prefix.ip6)); + mp->pfx.len = vip_plen; + S(mp); + W (ret); + return ret; +} +static int api_lb_add_del_intf_nat4 (vat_main_t * vam) +{ + // Not yet implemented + return -99; +} + +static int api_lb_add_del_intf_nat6 (vat_main_t * vam) +{ + // Not yet implemented + return -99; +} + static void vl_api_lb_vip_details_t_handler (vl_api_lb_vip_details_t * mp) { @@ -467,49 +443,4 @@ static int api_lb_as_dump (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 \ -_(lb_conf, "[ip4-src-address ] [ip6-src-address ] " \ - "[buckets ] [timeout ]") \ -_(lb_add_del_vip, " " \ - "[protocol (tcp|udp) port ] " \ - "[encap (gre6|gre4|l3dsr|nat4|nat6)] " \ - "[dscp ] " \ - "[type (nodeport|clusterip) target_port ] " \ - "[new_len ] [del]") \ -_(lb_add_del_as, " [protocol (tcp|udp) port ] " \ - "[
] [del] [flush]") \ -_(lb_vip_dump, "") \ -_(lb_as_dump, " [protocol (tcp|udp) port ]") - -static void -lb_api_hookup (vat_main_t *vam) -{ - lb_test_main_t * lbtm = &lb_test_main; - /* Hook up handlers for replies from the data plane plug-in */ -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + lbtm->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 _ -} - -VAT_PLUGIN_REGISTER(lb); +#include