diff --git a/dmentry.c b/dmentry.c index 8c91476f..1da81d4b 100644 --- a/dmentry.c +++ b/dmentry.c @@ -296,6 +296,9 @@ int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1, case CMD_GET_SCHEMA: fault = dm_entry_get_schema(ctx); break; + case CMD_GET_INSTANCES: + fault = dm_entry_get_instances(ctx); + break; #ifdef BBF_TR064 case CMD_UPNP_GET_SUPPORTED_PARAMETERS: ctx->depth = atoi(arg1); diff --git a/libbbf_api/dmbbf.c b/libbbf_api/dmbbf.c index ab6b05c6..40046b72 100644 --- a/libbbf_api/dmbbf.c +++ b/libbbf_api/dmbbf.c @@ -1423,6 +1423,59 @@ static int mparam_get_schema_name(DMPARAM_ARGS) return 0; } +/* ************** + * get_instances + * **************/ +static int mobj_get_instances_in_obj(DMOBJECT_ARGS) +{ + if (node->matched && node->is_instanceobj) { + char *name = dmstrdup(node->current_object); + + if (name) { + name[strlen(name) - 1] = 0; + add_list_paramameter(dmctx, name, NULL, "xsd:object", NULL, 0); + } + } + + return 0; +} + +static int mparam_get_instances_in_obj(DMPARAM_ARGS) +{ + return 0; +} + +int dm_entry_get_instances(struct dmctx *dmctx) +{ + DMOBJ *root = dmctx->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; + + plen = strlen(dmctx->in_param); + if (dmctx->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; + + err = dm_browse(dmctx, &node, root, NULL, NULL); + if (dmctx->findparam == 0) + return err; + + return 0; +} + + /* ******************** * get notification * ********************/ diff --git a/libbbf_api/dmbbf.h b/libbbf_api/dmbbf.h index 470a6d68..609a2217 100644 --- a/libbbf_api/dmbbf.h +++ b/libbbf_api/dmbbf.h @@ -336,6 +336,7 @@ enum { CMD_USP_OPERATE, CMD_USP_LIST_OPERATE, CMD_GET_SCHEMA, + CMD_GET_INSTANCES, #ifdef BBF_TR064 CMD_UPNP_GET_SUPPORTED_PARAMETERS, CMD_UPNP_GET_INSTANCES, @@ -557,6 +558,7 @@ void dmentry_instance_lookup_inparam(struct dmctx *ctx); int dm_entry_get_value(struct dmctx *ctx); int dm_entry_get_name(struct dmctx *ctx); int dm_entry_get_schema(struct dmctx *ctx); +int dm_entry_get_instances(struct dmctx *dmctx); int dm_entry_get_notification(struct dmctx *ctx); int dm_entry_inform(struct dmctx *ctx); int dm_entry_add_object(struct dmctx *ctx);