From 0fb678699e90f2c67e861f99a3a341ab9909de36 Mon Sep 17 00:00:00 2001 From: Amin Ben Romdhane <amin.benromdhane@iopsys.eu> Date: Tue, 6 May 2025 21:03:31 +0200 Subject: [PATCH] Add support for displaying the schema data model with '-d' option --- src/main.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main.c b/src/main.c index 625523e..25b440b 100644 --- a/src/main.c +++ b/src/main.c @@ -119,11 +119,11 @@ int cleanup() int main(int argc, char **argv) { - int ch; - int log_level = 7; + int ch, dm_type = 0; + int log_level = 7; struct bbfdm_context bbfdm_ctx = {0}; - while ((ch = getopt(argc, argv, "l:q:")) != -1) { + while ((ch = getopt(argc, argv, "dl:q:")) != -1) { switch (ch) { case 'l': if (optarg) { @@ -133,6 +133,9 @@ int main(int argc, char **argv) if (log_level < 0 || log_level > 7) log_level = 7; break; + case 'd': + dm_type++; + break; case 'q': int num_of_q = get_no_of_q_per_port(argv[argc-1]); printf("%d", num_of_q); @@ -142,10 +145,15 @@ int main(int argc, char **argv) } } - memset(&bbfdm_ctx, 0, sizeof(struct bbfdm_context)); - bbfdm_ubus_set_service_name(&bbfdm_ctx, "qosmngr"); - bbfdm_ubus_set_log_level(log_level); - bbfdm_ubus_load_data_model(tDynamicObj); + memset(&bbfdm_ctx, 0, sizeof(struct bbfdm_context)); + bbfdm_ubus_set_service_name(&bbfdm_ctx, "qosmngr"); + bbfdm_ubus_set_log_level(log_level); + bbfdm_ubus_load_data_model(tDynamicObj); + + if (dm_type > 0) { + int res = bbfdm_print_data_model_schema(&bbfdm_ctx, dm_type); + exit(res); + } openlog("qosmngr", LOG_PID|LOG_CONS, LOG_LOCAL1); -- GitLab