sharpd: send new OPAQUE messages

Add a simple cli to exercise the new OPAQUE messages.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
This commit is contained in:
Mark Stapp 2020-04-15 16:31:57 -04:00
parent 79b3664a67
commit 2ac6c90d18
3 changed files with 47 additions and 0 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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