diff options
author | Jakub Urbańczyk <xthaid@gmail.com> | 2020-08-06 13:33:47 +0200 |
---|---|---|
committer | Jakub Urbańczyk <xthaid@gmail.com> | 2020-08-12 23:20:04 +0200 |
commit | da187b7705828cb2e2bff94275bc36ca6f69999c (patch) | |
tree | 2534c487885463423175840c5537eeb5bf3f8cd0 /sharpd | |
parent | lib, zebra: add support for sending ARP requests (diff) | |
download | frr-da187b7705828cb2e2bff94275bc36ca6f69999c.tar.xz frr-da187b7705828cb2e2bff94275bc36ca6f69999c.zip |
sharpd: add a command to send ARP/NDP requests
Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
Diffstat (limited to 'sharpd')
-rw-r--r-- | sharpd/sharp_vty.c | 46 | ||||
-rw-r--r-- | sharpd/sharp_zebra.c | 5 | ||||
-rw-r--r-- | sharpd/sharp_zebra.h | 3 |
3 files changed, 54 insertions, 0 deletions
diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index 049b8475e..d390ea819 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -649,6 +649,51 @@ DEFPY (send_opaque_reg, return CMD_SUCCESS; } +DEFPY (neigh_discover, + neigh_discover_cmd, + "sharp neigh discover [vrf NAME$vrf_name] <A.B.C.D$dst4|X:X::X:X$dst6> IFNAME$ifname", + SHARP_STR + "Discover neighbours\n" + "Send an ARP/NDP request\n" + VRF_CMD_HELP_STR + "v4 Destination address\n" + "v6 Destination address\n" + "Interface name\n") +{ + struct vrf *vrf; + struct interface *ifp; + struct prefix prefix; + + memset(&prefix, 0, sizeof(prefix)); + + if (dst4.s_addr != 0) { + prefix.family = AF_INET; + prefix.prefixlen = 32; + prefix.u.prefix4 = dst4; + } else { + prefix.family = AF_INET6; + prefix.prefixlen = 128; + prefix.u.prefix6 = dst6; + } + + vrf = vrf_lookup_by_name(vrf_name ? vrf_name : VRF_DEFAULT_NAME); + if (!vrf) { + vty_out(vty, "The vrf NAME specified: %s does not exist\n", + vrf_name ? vrf_name : VRF_DEFAULT_NAME); + return CMD_WARNING; + } + + ifp = if_lookup_by_name_vrf(ifname, vrf); + if (ifp == NULL) { + vty_out(vty, "%% Can't find interface %s\n", ifname); + return CMD_WARNING; + } + + sharp_zebra_send_arp(ifp, &prefix); + + return CMD_SUCCESS; +} + void sharp_vty_init(void) { install_element(ENABLE_NODE, &install_routes_data_dump_cmd); @@ -666,6 +711,7 @@ void sharp_vty_init(void) install_element(ENABLE_NODE, &send_opaque_cmd); install_element(ENABLE_NODE, &send_opaque_unicast_cmd); install_element(ENABLE_NODE, &send_opaque_reg_cmd); + install_element(ENABLE_NODE, &neigh_discover_cmd); install_element(VIEW_NODE, &show_debugging_sharpd_cmd); diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index e0f16d71f..08f5a07b7 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -663,6 +663,11 @@ void sharp_opaque_reg_send(bool is_reg, uint32_t proto, uint32_t instance, } +void sharp_zebra_send_arp(const struct interface *ifp, const struct prefix *p) +{ + zclient_send_neigh_discovery_req(zclient, ifp, p); +} + void sharp_zebra_init(void) { struct zclient_options opt = {.receive_notify = true}; diff --git a/sharpd/sharp_zebra.h b/sharpd/sharp_zebra.h index e40585aa6..0a44fa694 100644 --- a/sharpd/sharp_zebra.h +++ b/sharpd/sharp_zebra.h @@ -58,4 +58,7 @@ void sharp_opaque_send(uint32_t type, uint32_t proto, uint32_t instance, void sharp_opaque_reg_send(bool is_reg, uint32_t proto, uint32_t instance, uint32_t session_id, uint32_t type); +extern void sharp_zebra_send_arp(const struct interface *ifp, + const struct prefix *p); + #endif |