diff options
author | Matus Fabian <matfabia@cisco.com> | 2018-10-02 03:22:18 -0700 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2018-10-02 12:32:15 +0000 |
commit | 2d3c7b9c4555ea4467253b0590c9aa1a6c644b4d (patch) | |
tree | bd48ef5082982c8c30c29ccf8a852bc80c6e36e4 /src/vnet/bfd/bfd_api.c | |
parent | a9a0b2ce2daabc5479aa7722e3ec7023f8c6c0d5 (diff) |
BFD: add get echo source API (VPP-1367)
Change-Id: I45f540128e038ddb17ba96ce30965e8f7c732067
Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src/vnet/bfd/bfd_api.c')
-rw-r--r-- | src/vnet/bfd/bfd_api.c | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/src/vnet/bfd/bfd_api.c b/src/vnet/bfd/bfd_api.c index 33a7c1d8bf6..fcd66950114 100644 --- a/src/vnet/bfd/bfd_api.c +++ b/src/vnet/bfd/bfd_api.c @@ -60,7 +60,8 @@ _ (BFD_UDP_AUTH_ACTIVATE, bfd_udp_auth_activate) \ _ (BFD_UDP_AUTH_DEACTIVATE, bfd_udp_auth_deactivate) \ _ (BFD_UDP_SET_ECHO_SOURCE, bfd_udp_set_echo_source) \ - _ (BFD_UDP_DEL_ECHO_SOURCE, bfd_udp_del_echo_source) + _ (BFD_UDP_DEL_ECHO_SOURCE, bfd_udp_del_echo_source) \ + _ (BFD_UDP_GET_ECHO_SOURCE, bfd_udp_get_echo_source) pub_sub_handler (bfd_events, BFD_EVENTS); @@ -359,6 +360,59 @@ vl_api_bfd_udp_del_echo_source_t_handler (vl_api_bfd_udp_del_echo_source_t * REPLY_MACRO (VL_API_BFD_UDP_DEL_ECHO_SOURCE_REPLY); } +static void +vl_api_bfd_udp_get_echo_source_t_handler (vl_api_bfd_udp_get_echo_source_t * + mp) +{ + vl_api_bfd_udp_get_echo_source_reply_t *rmp; + int rv = 0; + int is_set; + u32 sw_if_index; + int have_usable_ip4; + ip4_address_t ip4; + int have_usable_ip6; + ip6_address_t ip6; + + bfd_udp_get_echo_source (&is_set, &sw_if_index, &have_usable_ip4, &ip4, + &have_usable_ip6, &ip6); + + /* *INDENT-OFF* */ + REPLY_MACRO2 (VL_API_BFD_UDP_GET_ECHO_SOURCE_REPLY, + ({ + rmp->sw_if_index = ntohl (sw_if_index); + if (is_set) + { + rmp->is_set = 1; + rmp->sw_if_index = clib_host_to_net_u32 (sw_if_index); + if (have_usable_ip4) + { + rmp->have_usable_ip4 = 1; + clib_memcpy (rmp->ip4_addr, &ip4, sizeof (ip4)); + } + else + { + rmp->have_usable_ip4 = 0; + } + if (have_usable_ip6) + { + rmp->have_usable_ip6 = 1; + clib_memcpy (rmp->ip6_addr, &ip6, sizeof (ip6)); + } + else + { + rmp->have_usable_ip6 = 0; + } + } + else + { + rmp->is_set = 0; + rmp->have_usable_ip4 = 0; + rmp->have_usable_ip6 = 0; + } + })) + /* *INDENT-ON* */ +} + /* * bfd_api_hookup * Add vpe's API message handlers to the table. |