diff options
author | Mark Stapp <mjs@voltanet.io> | 2020-04-15 22:31:57 +0200 |
---|---|---|
committer | Mark Stapp <mjs@voltanet.io> | 2020-06-02 14:21:38 +0200 |
commit | 2ac6c90d1866517628c6325c411c3fae526b9225 (patch) | |
tree | b0f53c5d051dfd0c1a6454572498905daeb10ee7 /sharpd | |
parent | zebra: call zapi message handler with a batch (diff) | |
download | frr-2ac6c90d1866517628c6325c411c3fae526b9225.tar.xz frr-2ac6c90d1866517628c6325c411c3fae526b9225.zip |
sharpd: send new OPAQUE messages
Add a simple cli to exercise the new OPAQUE messages.
Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'sharpd')
-rw-r--r-- | sharpd/sharp_vty.c | 15 | ||||
-rw-r--r-- | sharpd/sharp_zebra.c | 29 | ||||
-rw-r--r-- | sharpd/sharp_zebra.h | 3 |
3 files changed, 47 insertions, 0 deletions
diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index 987588947..873d36a99 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -547,6 +547,20 @@ DEFPY (logpump, return CMD_SUCCESS; } +DEFPY (send_opaque, + send_opaque_cmd, + "sharp send opaque type (1-255) (1-1000)$count", + "Sharp Routing Protocol\n" + "Send messages for testing\n" + "Send opaque messages\n" + "Type code to send\n" + "Type code to send\n" + "Number of messages to send\n") +{ + sharp_opaque_send(type, count); + return CMD_SUCCESS; +} + void sharp_vty_init(void) { install_element(ENABLE_NODE, &install_routes_data_dump_cmd); @@ -559,6 +573,7 @@ void sharp_vty_init(void) install_element(ENABLE_NODE, &sharp_lsp_prefix_v4_cmd); 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(VIEW_NODE, &show_debugging_sharpd_cmd); diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index 079509644..1be6ec197 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -480,6 +480,35 @@ static int sharp_redistribute_route(ZAPI_CALLBACK_ARGS) return 0; } +/* + * Send OPAQUE messages, using subtype 'type'. + */ +void sharp_opaque_send(uint32_t type, uint32_t count) +{ + uint8_t buf[100]; + int ret; + uint32_t i; + + /* Prepare a small payload */ + for (i = 0; i < sizeof(buf); i++) { + if (type < 255) + buf[i] = type; + else + buf[i] = 255; + } + + /* Send some messages */ + for (i = 0; i < count; i++) { + ret = zclient_send_opaque(zclient, type, buf, sizeof(buf)); + if (ret < 0) { + zlog_debug("%s: send_opaque() failed => %d", + __func__, ret); + break; + } + } + +} + extern struct zebra_privs_t sharp_privs; void sharp_zebra_init(void) diff --git a/sharpd/sharp_zebra.h b/sharpd/sharp_zebra.h index 2b8e19dd9..ca7900b8c 100644 --- a/sharpd/sharp_zebra.h +++ b/sharpd/sharp_zebra.h @@ -44,5 +44,8 @@ int sharp_install_lsps_helper(bool install_p, const struct prefix *p, uint8_t type, int instance, uint32_t in_label, const struct nexthop_group *nhg, const struct nexthop_group *backup_nhg); +/* Send OPAQUE messages, using subtype 'type'. */ +void sharp_opaque_send(uint32_t type, uint32_t count); + #endif |