diff options
-rw-r--r-- | sharpd/sharp_vty.c | 27 | ||||
-rw-r--r-- | sharpd/sharp_zebra.c | 31 | ||||
-rw-r--r-- | sharpd/sharp_zebra.h | 4 |
3 files changed, 62 insertions, 0 deletions
diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index 873d36a99..77d0d02e7 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -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); diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index 1be6ec197..0bf5c037c 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -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) diff --git a/sharpd/sharp_zebra.h b/sharpd/sharp_zebra.h index ca7900b8c..7c714b52d 100644 --- a/sharpd/sharp_zebra.h +++ b/sharpd/sharp_zebra.h @@ -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 |