From ab26cfaea675807d29db316d1c3fb2498f7f6579 Mon Sep 17 00:00:00 2001 From: vdutta Date: Mon, 14 Sep 2020 15:56:14 +0530 Subject: [PATCH] get_instances: Added next-level support in instances --- dmentry.c | 3 +++ libbbf_api/dmbbf.c | 30 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/dmentry.c b/dmentry.c index 5c21cb0b..b0d33248 100644 --- a/dmentry.c +++ b/dmentry.c @@ -298,6 +298,9 @@ int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1, fault = dm_entry_get_schema(ctx); break; case CMD_GET_INSTANCES: + if (arg1) + string_to_bool(arg1, &ctx->nextlevel); + fault = dm_entry_get_instances(ctx); break; #ifdef BBF_TR064 diff --git a/libbbf_api/dmbbf.c b/libbbf_api/dmbbf.c index 5c59f6c7..9a99143c 100644 --- a/libbbf_api/dmbbf.c +++ b/libbbf_api/dmbbf.c @@ -1425,31 +1425,31 @@ static int mparam_get_schema_name(DMPARAM_ARGS) /* ************** * get_instances * **************/ -int dm_entry_get_instances(struct dmctx *dmctx) +int dm_entry_get_instances(struct dmctx *ctx) { - DMOBJ *root = dmctx->dm_entryobj; + DMOBJ *root = ctx->dm_entryobj; DMNODE node = { .current_object = "" }; char buf[4] = { dm_delim, 0 }; size_t plen; int err; - if (dmctx->in_param[0] == 0) - dmctx->in_param = buf; + if (ctx->in_param[0] == 0) + ctx->in_param = buf; - plen = strlen(dmctx->in_param); - if (dmctx->in_param[plen - 1] != dm_delim) + plen = strlen(ctx->in_param); + if (ctx->in_param[plen - 1] != dm_delim) return FAULT_9005; - dmctx->inparam_isparam = 0; - dmctx->findparam = 0; - dmctx->stop = 0; - dmctx->checkobj = plugin_obj_match; - dmctx->checkleaf = plugin_leaf_match; - dmctx->method_obj = mobj_get_instances_in_obj; - dmctx->method_param = mparam_get_instances_in_obj; + ctx->inparam_isparam = 0; + ctx->findparam = 0; + ctx->stop = 0; + ctx->checkobj = (ctx->nextlevel) ? plugin_obj_nextlevel_match : plugin_obj_match; + ctx->checkleaf = (ctx->nextlevel) ? plugin_leaf_nextlevel_match : plugin_leaf_match; + ctx->method_obj = mobj_get_instances_in_obj; + ctx->method_param = mparam_get_instances_in_obj; - err = dm_browse(dmctx, &node, root, NULL, NULL); - if (dmctx->findparam == 0) + err = dm_browse(ctx, &node, root, NULL, NULL); + if (ctx->findparam == 0) return err; return 0;