sharpd: send opaque message registrations

For testing, add cli to sharpd to send opaque message
registration and un-registration messages.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
This commit is contained in:
Mark Stapp 2020-04-19 13:41:57 -04:00
parent 5bebe26d4e
commit 939b2339b4
3 changed files with 62 additions and 0 deletions

View File

@ -561,6 +561,32 @@ DEFPY (send_opaque,
return CMD_SUCCESS;
}
DEFPY (send_opaque_reg,
send_opaque_reg_cmd,
"sharp send opaque <reg$reg | unreg> \
" FRR_IP_REDIST_STR_ZEBRA "$proto_str \
[{instance (0-1000) | session (1-1000)}] type (1-1000)",
"Sharp Routing Protocol\n"
"Send messages for testing\n"
"Send opaque messages\n"
"Send opaque registration\n"
"Send opaque unregistration\n"
FRR_IP_REDIST_HELP_STR_ZEBRA
"Daemon instance\n"
"Daemon instance\n"
"Session ID\n"
"Session ID\n"
"Opaque sub-type code\n"
"Opaque sub-type code\n")
{
int proto;
proto = proto_redistnum(AFI_IP, proto_str);
sharp_opaque_reg_send((reg != NULL), proto, instance, session, type);
return CMD_SUCCESS;
}
void sharp_vty_init(void)
{
install_element(ENABLE_NODE, &install_routes_data_dump_cmd);
@ -574,6 +600,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_reg_cmd);
install_element(VIEW_NODE, &show_debugging_sharpd_cmd);

View File

@ -509,6 +509,37 @@ void sharp_opaque_send(uint32_t type, uint32_t count)
}
/*
* Send OPAQUE registration messages, using subtype 'type'.
*/
void sharp_opaque_reg_send(bool is_reg, uint32_t proto, uint32_t instance,
uint32_t session_id, uint32_t type)
{
struct stream *s;
s = zclient->obuf;
stream_reset(s);
if (is_reg)
zclient_create_header(s, ZEBRA_OPAQUE_REGISTER, VRF_DEFAULT);
else
zclient_create_header(s, ZEBRA_OPAQUE_UNREGISTER, VRF_DEFAULT);
/* Send sub-type */
stream_putl(s, type);
/* Add zclient info */
stream_putc(s, proto);
stream_putw(s, instance);
stream_putl(s, session_id);
/* Put length at the first point of the stream. */
stream_putw_at(s, 0, stream_get_endp(s));
(void)zclient_send_message(zclient);
}
extern struct zebra_privs_t sharp_privs;
void sharp_zebra_init(void)

View File

@ -44,8 +44,12 @@ 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);
/* Send OPAQUE registration messages, using subtype 'type'. */
void sharp_opaque_reg_send(bool is_reg, uint32_t proto, uint32_t instance,
uint32_t session_id, uint32_t type);
#endif