summaryrefslogtreecommitdiffstats
path: root/mgmtd/mgmt_testc.c
diff options
context:
space:
mode:
Diffstat (limited to 'mgmtd/mgmt_testc.c')
-rw-r--r--mgmtd/mgmt_testc.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/mgmtd/mgmt_testc.c b/mgmtd/mgmt_testc.c
index 7e3ded8..8bb07ed 100644
--- a/mgmtd/mgmt_testc.c
+++ b/mgmtd/mgmt_testc.c
@@ -18,6 +18,7 @@
/* ---------------- */
static void async_notification(struct nb_cb_notify_args *args);
+static int rpc_callback(struct nb_cb_rpc_args *args);
static void sigusr1(void);
static void sigint(void);
@@ -87,6 +88,10 @@ static const struct frr_yang_module_info frr_ripd_info = {
.cbs.notify = async_notification,
},
{
+ .xpath = "/frr-ripd:clear-rip-route",
+ .cbs.rpc = rpc_callback,
+ },
+ {
.xpath = NULL,
}
}
@@ -113,6 +118,7 @@ FRR_DAEMON_INFO(mgmtd_testc, MGMTD_TESTC,
/* clang-format on */
const char **__notif_xpaths;
+const char **__rpc_xpaths;
struct mgmt_be_client_cbs __client_cbs = {};
struct event *event_timeout;
@@ -133,8 +139,11 @@ static void sigusr1(void)
static void quit(int exit_code)
{
EVENT_OFF(event_timeout);
- frr_fini();
darr_free(__client_cbs.notif_xpaths);
+ darr_free(__client_cbs.rpc_xpaths);
+
+ frr_fini();
+
exit(exit_code);
}
@@ -150,6 +159,12 @@ static void timeout(struct event *event)
quit(1);
}
+static void success(struct event *event)
+{
+ zlog_notice("Success, exiting");
+ quit(0);
+}
+
static void async_notification(struct nb_cb_notify_args *args)
{
zlog_notice("Received YANG notification");
@@ -161,6 +176,23 @@ static void async_notification(struct nb_cb_notify_args *args)
quit(0);
}
+static int rpc_callback(struct nb_cb_rpc_args *args)
+{
+ const char *vrf = NULL;
+
+ zlog_notice("Received YANG RPC");
+
+ if (yang_dnode_exists(args->input, "vrf"))
+ vrf = yang_dnode_get_string(args->input, "vrf");
+
+ printf("{\"frr-ripd:clear-rip-route\": {\"vrf\": \"%s\"}}\n", vrf);
+
+ event_cancel(&event_timeout);
+ event_add_timer(master, success, NULL, 1, NULL);
+
+ return 0;
+}
+
int main(int argc, char **argv)
{
int f_listen = 0;
@@ -215,6 +247,10 @@ int main(int argc, char **argv)
__client_cbs.nnotif_xpaths = darr_len(__notif_xpaths);
}
+ darr_push(__rpc_xpaths, "/frr-ripd:clear-rip-route");
+ __client_cbs.rpc_xpaths = __rpc_xpaths;
+ __client_cbs.nrpc_xpaths = darr_len(__rpc_xpaths);
+
mgmt_be_client = mgmt_be_client_create("mgmtd-testc", &__client_cbs, 0,
master);