diff options
-rw-r--r-- | sharpd/sharp_vty.c | 19 | ||||
-rw-r--r-- | sharpd/sharp_zebra.c | 34 | ||||
-rw-r--r-- | sharpd/sharp_zebra.h | 7 |
3 files changed, 59 insertions, 1 deletions
diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index ca2212cd8..3a2a7aa40 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -865,6 +865,24 @@ DEFPY (send_opaque_reg, return CMD_SUCCESS; } +/* Opaque notifications - register or unregister */ +DEFPY (send_opaque_notif_reg, + send_opaque_notif_reg_cmd, + "sharp send opaque notify <reg$reg | unreg> type (1-1000)", + SHARP_STR + "Send messages for testing\n" + "Send opaque messages\n" + "Opaque notification messages\n" + "Send notify registration\n" + "Send notify unregistration\n" + "Opaque sub-type code\n" + "Opaque sub-type code\n") +{ + sharp_zebra_opaque_notif_reg((reg != NULL), type); + + return CMD_SUCCESS; +} + DEFPY (neigh_discover, neigh_discover_cmd, "sharp neigh discover [vrf NAME$vrf_name] <A.B.C.D$dst4|X:X::X:X$dst6> IFNAME$ifname", @@ -1406,6 +1424,7 @@ void sharp_vty_init(void) 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(ENABLE_NODE, &send_opaque_notif_reg_cmd); install_element(ENABLE_NODE, &neigh_discover_cmd); install_element(ENABLE_NODE, &import_te_cmd); diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index 91fb7f03b..df18118b0 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -805,6 +805,28 @@ static int sharp_opaque_handler(ZAPI_CALLBACK_ARGS) return 0; } +/* Handler for opaque notification messages */ +static int sharp_opq_notify_handler(ZAPI_CALLBACK_ARGS) +{ + struct stream *s; + struct zapi_opaque_notif_info info; + + s = zclient->ibuf; + + if (zclient_opaque_notif_decode(s, &info) != 0) + return -1; + + if (info.reg) + zlog_debug("%s: received opaque notification REG, type %u => %d/%d/%d", + __func__, info.msg_type, info.proto, info.instance, + info.session_id); + else + zlog_debug("%s: received opaque notification UNREG, type %u", + __func__, info.msg_type); + + return 0; +} + /* * Send OPAQUE messages, using subtype 'type'. */ @@ -841,6 +863,17 @@ void sharp_opaque_send(uint32_t type, uint32_t proto, uint32_t instance, } /* + * Register/unregister for opaque notifications from zebra about 'type'. + */ +void sharp_zebra_opaque_notif_reg(bool is_reg, uint32_t type) +{ + if (is_reg) + zclient_opaque_request_notify(zclient, type); + else + zclient_opaque_drop_notify(zclient, type); +} + +/* * Send OPAQUE registration messages, using subtype 'type'. */ void sharp_opaque_reg_send(bool is_reg, uint32_t proto, uint32_t instance, @@ -1036,6 +1069,7 @@ static zclient_handler *const sharp_handlers[] = { [ZEBRA_REDISTRIBUTE_ROUTE_ADD] = sharp_redistribute_route, [ZEBRA_REDISTRIBUTE_ROUTE_DEL] = sharp_redistribute_route, [ZEBRA_OPAQUE_MESSAGE] = sharp_opaque_handler, + [ZEBRA_OPAQUE_NOTIFY] = sharp_opq_notify_handler, [ZEBRA_SRV6_MANAGER_GET_LOCATOR_CHUNK] = sharp_zebra_process_srv6_locator_chunk, }; diff --git a/sharpd/sharp_zebra.h b/sharpd/sharp_zebra.h index cf8689799..025b4d8f8 100644 --- a/sharpd/sharp_zebra.h +++ b/sharpd/sharp_zebra.h @@ -39,10 +39,15 @@ int sharp_install_lsps_helper(bool install_p, bool update_p, 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'. */ +/* Send OPAQUE registration or notification registration messages, + * for opaque subtype 'type'. + */ void sharp_opaque_reg_send(bool is_reg, uint32_t proto, uint32_t instance, uint32_t session_id, uint32_t type); +/* Register/unregister for opaque notifications from zebra about 'type'. */ +void sharp_zebra_opaque_notif_reg(bool is_reg, uint32_t type); + extern void sharp_zebra_send_arp(const struct interface *ifp, const struct prefix *p); |