summaryrefslogtreecommitdiffstats
path: root/lib/zclient.c
diff options
context:
space:
mode:
authorCarmine Scarpitta <cscarpit@cisco.com>2024-03-23 15:49:43 +0100
committerCarmine Scarpitta <cscarpit@cisco.com>2024-06-13 14:54:16 +0200
commitded79d7013f00a61b19e029a5104b453f696253a (patch)
tree59e9ba9923a6e9de0f2c84dc8cf1e0dfca731d97 /lib/zclient.c
parentzebra: Add support for SRv6 SIDs (diff)
downloadfrr-ded79d7013f00a61b19e029a5104b453f696253a.tar.xz
frr-ded79d7013f00a61b19e029a5104b453f696253a.zip
lib: Add ZAPI operation get SRv6 locator
Add a new ZAPI operation, ZEBRA_SRV6_MANAGER_GET_LOCATOR, which allows a daemon to request information about a specific locator from the SRv6 SID Manager. Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
Diffstat (limited to 'lib/zclient.c')
-rw-r--r--lib/zclient.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/zclient.c b/lib/zclient.c
index 1aab7b48b..90ec02415 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -3268,6 +3268,47 @@ int srv6_manager_release_locator_chunk(struct zclient *zclient,
return zclient_send_message(zclient);
}
+/**
+ * Function to request a SRv6 locator in an asynchronous way
+ *
+ * @param zclient The zclient used to connect to SRv6 Manager (zebra)
+ * @param locator_name Name of SRv6 locator
+ * @return 0 on success, -1 otherwise
+ */
+int srv6_manager_get_locator(struct zclient *zclient, const char *locator_name)
+{
+ struct stream *s;
+ size_t len;
+
+ if (!locator_name)
+ return -1;
+
+ if (zclient->sock < 0) {
+ flog_err(EC_LIB_ZAPI_SOCKET, "%s: invalid zclient socket",
+ __func__);
+ return -1;
+ }
+
+ if (zclient_debug)
+ zlog_debug("Getting SRv6 Locator %s", locator_name);
+
+ len = strlen(locator_name);
+
+ /* Send request */
+ s = zclient->obuf;
+ stream_reset(s);
+ zclient_create_header(s, ZEBRA_SRV6_MANAGER_GET_LOCATOR, VRF_DEFAULT);
+
+ /* Locator name */
+ stream_putw(s, len);
+ stream_put(s, locator_name, len);
+
+ /* Put length at the first point of the stream. */
+ stream_putw_at(s, 0, stream_get_endp(s));
+
+ return zclient_send_message(zclient);
+}
+
/*
* Asynchronous label chunk request
*