diff --git a/src/ethmngr.c b/src/ethmngr.c index 27bd14fa504922214dba8156a82a602490442c3d..0a4e3d021c9185f1515af1af85cb08a4107d9282 100644 --- a/src/ethmngr.c +++ b/src/ethmngr.c @@ -252,22 +252,26 @@ static void ethmngr_usage(char *prog) fprintf(stderr, "\n"); fprintf(stderr, "options:\n"); fprintf(stderr, " -l <log level> As per syslog, 0 to 7\n"); + fprintf(stderr, " -d <schema dm> Display the schema data model supported by micro-service\n"); fprintf(stderr, " -h <help> To print this help menu\n"); fprintf(stderr, "\n"); } int main(int argc, char **argv) { - int ch; + int ch, dm_type = 0; int log_level = 6; // default LOG_INFO - while ((ch = getopt(argc, argv, "hl:")) != -1) { + while ((ch = getopt(argc, argv, "hdl:")) != -1) { switch (ch) { case 'l': log_level = (int)strtoul(optarg, NULL, 10); if (log_level < 0 || log_level > 7) log_level = 6; break; + case 'd': + dm_type++; + break; case 'h': ethmngr_usage(argv[0]); exit(0); @@ -276,13 +280,18 @@ int main(int argc, char **argv) } } - openlog("ethmngr", LOG_PID|LOG_CONS|LOG_NDELAY, LOG_LOCAL1); - memset(&bbfdm_ctx, 0, sizeof(struct bbfdm_context)); bbfdm_ubus_set_service_name(&bbfdm_ctx, "ethmngr"); 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("ethmngr", LOG_PID|LOG_CONS|LOG_NDELAY, LOG_LOCAL1); + if (bbfdm_ubus_regiter_init(&bbfdm_ctx)) goto out;