X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fioam%2Flib-vxlan-gpe%2Fvxlan_gpe_test.c;h=dad39f20c32bdf6478d8d21fb490c985cdb409df;hb=61717cc38;hp=ee25a874918e42095c32f9454c4c897e266cad18;hpb=7bc770ceb62ede18414b7bb5788692e32477e373;p=vpp.git diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c index ee25a874918..dad39f20c32 100644 --- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c +++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_test.c @@ -21,36 +21,18 @@ #include #include #include -#include + #include +#include +#include -#define __plugin_msg_base vxlan_gpe_test_main.msg_id_base +#define __plugin_msg_base ioam_vxlan_gpe_test_main.msg_id_base #include /* Declare message IDs */ -#include - -/* 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 -#undef vl_printfun +#include +#include -/* Get the API version number. */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include -#undef vl_api_version #include #include @@ -59,56 +41,20 @@ typedef struct /* API message ID base */ u16 msg_id_base; vat_main_t *vat_main; -} vxlan_gpe_test_main_t; - -vxlan_gpe_test_main_t vxlan_gpe_test_main; - -#define foreach_standard_reply_retval_handler \ -_(vxlan_gpe_ioam_enable_reply) \ -_(vxlan_gpe_ioam_disable_reply) \ -_(vxlan_gpe_ioam_vni_enable_reply) \ -_(vxlan_gpe_ioam_vni_disable_reply) \ -_(vxlan_gpe_ioam_transit_enable_reply) \ -_(vxlan_gpe_ioam_transit_disable_reply) - -#define _(n) \ - static void vl_api_##n##_t_handler \ - (vl_api_##n##_t * mp) \ - { \ - vat_main_t * vam = vxlan_gpe_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 _ +} ioam_vxlan_gpe_test_main_t; -/* - * Table of message reply handlers, must include boilerplate handlers - * we just generated - */ -#define foreach_vpe_api_reply_msg \ -_(VXLAN_GPE_IOAM_ENABLE_REPLY, vxlan_gpe_ioam_enable_reply) \ -_(VXLAN_GPE_IOAM_DISABLE_REPLY, vxlan_gpe_ioam_disable_reply) \ -_(VXLAN_GPE_IOAM_VNI_ENABLE_REPLY, vxlan_gpe_ioam_vni_enable_reply) \ -_(VXLAN_GPE_IOAM_VNI_DISABLE_REPLY, vxlan_gpe_ioam_vni_disable_reply) \ -_(VXLAN_GPE_IOAM_TRANSIT_ENABLE_REPLY, vxlan_gpe_ioam_transit_enable_reply) \ -_(VXLAN_GPE_IOAM_TRANSIT_DISABLE_REPLY, vxlan_gpe_ioam_transit_disable_reply) \ +ioam_vxlan_gpe_test_main_t ioam_vxlan_gpe_test_main; static int api_vxlan_gpe_ioam_enable (vat_main_t * vam) { unformat_input_t *input = vam->input; vl_api_vxlan_gpe_ioam_enable_t *mp; - f64 timeout; u32 id = 0; int has_trace_option = 0; int has_pow_option = 0; int has_ppc_option = 0; + int ret; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { @@ -133,9 +79,8 @@ api_vxlan_gpe_ioam_enable (vat_main_t * vam) S (mp); - W; - - return (0); + W (ret); + return ret; } @@ -143,12 +88,12 @@ static int api_vxlan_gpe_ioam_disable (vat_main_t * vam) { vl_api_vxlan_gpe_ioam_disable_t *mp; - f64 timeout; + int ret; M (VXLAN_GPE_IOAM_DISABLE, mp); S (mp); - W; - return 0; + W (ret); + return ret; } static int @@ -156,42 +101,25 @@ api_vxlan_gpe_ioam_vni_enable (vat_main_t * vam) { unformat_input_t *line_input = vam->input; vl_api_vxlan_gpe_ioam_vni_enable_t *mp; - ip4_address_t local4, remote4; - ip6_address_t local6, remote6; - u8 ipv4_set = 0, ipv6_set = 0; + ip46_address_t local, remote; u8 local_set = 0; u8 remote_set = 0; u32 vni; u8 vni_set = 0; - f64 timeout; + int ret; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { - if (unformat (line_input, "local %U", unformat_ip4_address, &local4)) + if (unformat (line_input, "local %U", unformat_ip46_address, &local)) { local_set = 1; - ipv4_set = 1; } else if (unformat (line_input, "remote %U", - unformat_ip4_address, &remote4)) + unformat_ip46_address, &remote)) { remote_set = 1; - ipv4_set = 1; } - else if (unformat (line_input, "local %U", - unformat_ip6_address, &local6)) - { - local_set = 1; - ipv6_set = 1; - } - else if (unformat (line_input, "remote %U", - unformat_ip6_address, &remote6)) - { - remote_set = 1; - ipv6_set = 1; - } - else if (unformat (line_input, "vni %d", &vni)) vni_set = 1; else @@ -211,7 +139,7 @@ api_vxlan_gpe_ioam_vni_enable (vat_main_t * vam) errmsg ("tunnel remote address not specified\n"); return -99; } - if (ipv4_set && ipv6_set) + if (ip46_address_is_ip4 (&local) != ip46_address_is_ip4 (&remote)) { errmsg ("both IPv4 and IPv6 addresses specified"); return -99; @@ -225,25 +153,18 @@ api_vxlan_gpe_ioam_vni_enable (vat_main_t * vam) M (VXLAN_GPE_IOAM_VNI_ENABLE, mp); - - if (ipv6_set) - { - clib_memcpy (&mp->local, &local6, sizeof (local6)); - clib_memcpy (&mp->remote, &remote6, sizeof (remote6)); - } - else - { - clib_memcpy (&mp->local, &local4, sizeof (local4)); - clib_memcpy (&mp->remote, &remote4, sizeof (remote4)); - } + ip_address_encode (&local, + ip46_address_is_ip4 (&local) ? IP46_TYPE_IP4 : + IP46_TYPE_IP6, &mp->local); + ip_address_encode (&local, + ip46_address_is_ip4 (&remote) ? IP46_TYPE_IP4 : + IP46_TYPE_IP6, &mp->remote); mp->vni = ntohl (vni); - mp->is_ipv6 = ipv6_set; S (mp); - W; - - return (0); + W (ret); + return ret; } static int @@ -251,42 +172,25 @@ api_vxlan_gpe_ioam_vni_disable (vat_main_t * vam) { unformat_input_t *line_input = vam->input; vl_api_vxlan_gpe_ioam_vni_disable_t *mp; - ip4_address_t local4, remote4; - ip6_address_t local6, remote6; - u8 ipv4_set = 0, ipv6_set = 0; + ip46_address_t local, remote; u8 local_set = 0; u8 remote_set = 0; u32 vni; u8 vni_set = 0; - f64 timeout; + int ret; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { - if (unformat (line_input, "local %U", unformat_ip4_address, &local4)) + if (unformat (line_input, "local %U", unformat_ip46_address, &local)) { local_set = 1; - ipv4_set = 1; } else if (unformat (line_input, "remote %U", - unformat_ip4_address, &remote4)) + unformat_ip46_address, &remote)) { remote_set = 1; - ipv4_set = 1; - } - else if (unformat (line_input, "local %U", - unformat_ip6_address, &local6)) - { - local_set = 1; - ipv6_set = 1; } - else if (unformat (line_input, "remote %U", - unformat_ip6_address, &remote6)) - { - remote_set = 1; - ipv6_set = 1; - } - else if (unformat (line_input, "vni %d", &vni)) vni_set = 1; else @@ -306,7 +210,7 @@ api_vxlan_gpe_ioam_vni_disable (vat_main_t * vam) errmsg ("tunnel remote address not specified\n"); return -99; } - if (ipv4_set && ipv6_set) + if (ip46_address_is_ip4 (&local) != ip46_address_is_ip4 (&remote)) { errmsg ("both IPv4 and IPv6 addresses specified"); return -99; @@ -320,25 +224,18 @@ api_vxlan_gpe_ioam_vni_disable (vat_main_t * vam) M (VXLAN_GPE_IOAM_VNI_DISABLE, mp); - - if (ipv6_set) - { - clib_memcpy (&mp->local, &local6, sizeof (local6)); - clib_memcpy (&mp->remote, &remote6, sizeof (remote6)); - } - else - { - clib_memcpy (&mp->local, &local4, sizeof (local4)); - clib_memcpy (&mp->remote, &remote4, sizeof (remote4)); - } + ip_address_encode (&local, + ip46_address_is_ip4 (&local) ? IP46_TYPE_IP4 : + IP46_TYPE_IP6, &mp->local); + ip_address_encode (&local, + ip46_address_is_ip4 (&remote) ? IP46_TYPE_IP4 : + IP46_TYPE_IP6, &mp->remote); mp->vni = ntohl (vni); - mp->is_ipv6 = ipv6_set; S (mp); - W; - - return 0; + W (ret); + return ret; } static int @@ -346,28 +243,18 @@ api_vxlan_gpe_ioam_transit_enable (vat_main_t * vam) { unformat_input_t *line_input = vam->input; vl_api_vxlan_gpe_ioam_transit_enable_t *mp; - ip4_address_t local4; - ip6_address_t local6; - u8 ipv4_set = 0, ipv6_set = 0; + ip46_address_t local; u8 local_set = 0; u32 outer_fib_index = 0; - f64 timeout; + int ret; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { - if (unformat (line_input, "dst-ip %U", unformat_ip4_address, &local4)) + if (unformat (line_input, "dst-ip %U", unformat_ip46_address, &local)) { local_set = 1; - ipv4_set = 1; } - else if (unformat (line_input, "dst-ip %U", - unformat_ip6_address, &local6)) - { - local_set = 1; - ipv6_set = 1; - } - else if (unformat (line_input, "outer-fib-index %d", &outer_fib_index)) ; else @@ -382,33 +269,21 @@ api_vxlan_gpe_ioam_transit_enable (vat_main_t * vam) errmsg ("destination address not specified\n"); return -99; } - if (ipv4_set && ipv6_set) - { - errmsg ("both IPv4 and IPv6 addresses specified"); - return -99; - } - M (VXLAN_GPE_IOAM_TRANSIT_ENABLE, mp); - if (ipv6_set) + if (!ip46_address_is_ip4 (&local)) { errmsg ("IPv6 currently unsupported"); return -1; } - else - { - clib_memcpy (&mp->dst_addr, &local4, sizeof (local4)); - } - + ip_address_encode (&local, IP46_TYPE_IP4, &mp->dst_addr); mp->outer_fib_index = htonl (outer_fib_index); - mp->is_ipv6 = ipv6_set; S (mp); - W; - - return (0); + W (ret); + return ret; } static int @@ -416,28 +291,18 @@ api_vxlan_gpe_ioam_transit_disable (vat_main_t * vam) { unformat_input_t *line_input = vam->input; vl_api_vxlan_gpe_ioam_transit_disable_t *mp; - ip4_address_t local4; - ip6_address_t local6; - u8 ipv4_set = 0, ipv6_set = 0; + ip46_address_t local; u8 local_set = 0; u32 outer_fib_index = 0; - f64 timeout; + int ret; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { - if (unformat (line_input, "dst-ip %U", unformat_ip4_address, &local4)) - { - local_set = 1; - ipv4_set = 1; - } - else if (unformat (line_input, "dst-ip %U", - unformat_ip6_address, &local6)) + if (unformat (line_input, "dst-ip %U", unformat_ip46_address, &local)) { local_set = 1; - ipv6_set = 1; } - else if (unformat (line_input, "outer-fib-index %d", &outer_fib_index)) ; else @@ -452,98 +317,26 @@ api_vxlan_gpe_ioam_transit_disable (vat_main_t * vam) errmsg ("destination address not specified\n"); return -99; } - if (ipv4_set && ipv6_set) - { - errmsg ("both IPv4 and IPv6 addresses specified"); - return -99; - } - M (VXLAN_GPE_IOAM_TRANSIT_DISABLE, mp); - if (ipv6_set) + if (!ip46_address_is_ip4 (&local)) { return -1; } - else - { - clib_memcpy (&mp->dst_addr, &local4, sizeof (local4)); - } + ip_address_encode (&local, IP46_TYPE_IP4, &mp->dst_addr); mp->outer_fib_index = htonl (outer_fib_index); - mp->is_ipv6 = ipv6_set; S (mp); - W; - - - return (0); -} - -/* - * List of messages that the api test plugin sends, - * and that the data plane plugin processes - */ -#define foreach_vpe_api_msg \ -_(vxlan_gpe_ioam_enable, ""\ - "[trace] [pow] [ppc ]") \ -_(vxlan_gpe_ioam_disable, "") \ -_(vxlan_gpe_ioam_vni_enable, ""\ - "local remote vni ") \ -_(vxlan_gpe_ioam_vni_disable, ""\ - "local remote vni ") \ -_(vxlan_gpe_ioam_transit_enable, ""\ - "dst-ip [outer-fib-index ]") \ -_(vxlan_gpe_ioam_transit_disable, ""\ - "dst-ip [outer-fib-index ]") \ - - -static void -vxlan_gpe_vat_api_hookup (vat_main_t * vam) -{ - vxlan_gpe_test_main_t *sm = &vxlan_gpe_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 _ + W (ret); + return ret; } -clib_error_t * -vat_plugin_register (vat_main_t * vam) -{ - vxlan_gpe_test_main_t *sm = &vxlan_gpe_test_main; - u8 *name; - - sm->vat_main = vam; - - name = format (0, "ioam_vxlan_gpe_%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) - vxlan_gpe_vat_api_hookup (vam); - - vec_free (name); - - return 0; -} +/* Override generated plugin register symbol */ +#define vat_plugin_register vxlan_gpe_vat_plugin_register +#include /* * fd.io coding-style-patch-verification: ON