diff options
author | Mark Stapp <mjs@voltanet.io> | 2020-06-08 22:38:36 +0200 |
---|---|---|
committer | Mark Stapp <mjs@voltanet.io> | 2020-06-10 21:05:25 +0200 |
commit | c8b27f2ad98f71842e506b8ccff403971769d8cb (patch) | |
tree | d94ecb6922ff738e8e975b9f894f157566a93484 /sharpd | |
parent | lib,sharpd: add a SHARP_STR alias (diff) | |
download | frr-c8b27f2ad98f71842e506b8ccff403971769d8cb.tar.xz frr-c8b27f2ad98f71842e506b8ccff403971769d8cb.zip |
sharpd,zebra: unicast support for zapi messages
Distinguish between unicast and broadcast opaque messages
in zebra handler code. Add cli and internal api changes to
have sharpd send unicast opaque messages. Add opaque cli
commands to the sharp user doc.
Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'sharpd')
-rw-r--r-- | sharpd/sharp_vty.c | 30 | ||||
-rw-r--r-- | sharpd/sharp_zebra.c | 16 | ||||
-rw-r--r-- | sharpd/sharp_zebra.h | 3 |
3 files changed, 43 insertions, 6 deletions
diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index bad59d172..72e9c22f1 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -557,7 +557,34 @@ DEFPY (send_opaque, "Type code to send\n" "Number of messages to send\n") { - sharp_opaque_send(type, count); + sharp_opaque_send(type, 0, 0, 0, count); + return CMD_SUCCESS; +} + +DEFPY (send_opaque_unicast, + send_opaque_unicast_cmd, + "sharp send opaque unicast type (1-255) \ + " FRR_IP_REDIST_STR_ZEBRA "$proto_str \ + [{instance (0-1000) | session (1-1000)}] (1-1000)$count", + SHARP_STR + "Send messages for testing\n" + "Send opaque messages\n" + "Send unicast messages\n" + "Type code to send\n" + "Type code to send\n" + FRR_IP_REDIST_HELP_STR_ZEBRA + "Daemon instance\n" + "Daemon instance\n" + "Session ID\n" + "Session ID\n" + "Number of messages to send\n") +{ + uint32_t proto; + + proto = proto_redistnum(AFI_IP, proto_str); + + sharp_opaque_send(type, proto, instance, session, count); + return CMD_SUCCESS; } @@ -600,6 +627,7 @@ void sharp_vty_init(void) install_element(ENABLE_NODE, &sharp_remove_lsp_prefix_v4_cmd); install_element(ENABLE_NODE, &logpump_cmd); 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(VIEW_NODE, &show_debugging_sharpd_cmd); diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index d94e272dd..6ebc04b9e 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -491,7 +491,8 @@ static int sharp_opaque_handler(ZAPI_CALLBACK_ARGS) if (zclient_opaque_decode(s, &info) != 0) return -1; - zlog_debug("%s: received opaque type %u", __func__, info.type); + zlog_debug("%s: [%d] received opaque type %u", __func__, + zclient->session_id, info.type); return 0; } @@ -499,7 +500,8 @@ static int sharp_opaque_handler(ZAPI_CALLBACK_ARGS) /* * Send OPAQUE messages, using subtype 'type'. */ -void sharp_opaque_send(uint32_t type, uint32_t count) +void sharp_opaque_send(uint32_t type, uint32_t proto, uint32_t instance, + uint32_t session_id, uint32_t count) { uint8_t buf[32]; int ret; @@ -513,9 +515,15 @@ void sharp_opaque_send(uint32_t type, uint32_t count) buf[i] = 255; } - /* Send some messages */ + /* Send some messages - broadcast and unicast are supported */ for (i = 0; i < count; i++) { - ret = zclient_send_opaque(zclient, type, buf, sizeof(buf)); + if (proto == 0) + ret = zclient_send_opaque(zclient, type, buf, + sizeof(buf)); + else + ret = zclient_send_opaque_unicast(zclient, type, proto, + instance, session_id, + buf, sizeof(buf)); if (ret < 0) { zlog_debug("%s: send_opaque() failed => %d", __func__, ret); diff --git a/sharpd/sharp_zebra.h b/sharpd/sharp_zebra.h index 7c714b52d..7604f4b0a 100644 --- a/sharpd/sharp_zebra.h +++ b/sharpd/sharp_zebra.h @@ -46,7 +46,8 @@ int sharp_install_lsps_helper(bool install_p, const struct prefix *p, const struct nexthop_group *backup_nhg); /* Send OPAQUE messages, using subtype 'type'. */ -void sharp_opaque_send(uint32_t type, uint32_t count); +void sharp_opaque_send(uint32_t type, uint32_t proto, uint32_t instance, + uint32_t session_id, uint32_t count); /* Send OPAQUE registration messages, using subtype 'type'. */ void sharp_opaque_reg_send(bool is_reg, uint32_t proto, uint32_t instance, |