* Limited support of RFC 7895 YANG Module Library to list modules:
* That is, limited support of: ietf-yang-library.yang * For example: `<module><name>example</name><revision/></module><module><name>ietf-restconf-monitoring</name><revision>2017-01-26</revision></module>...` * Comply to RFC 8040 3.5.3.1 rule: api-identifier = [module-name ":"] identifier * The "module-name" was a no-op before. * This means that there was no difference between eg: GET /restconf/data/ietf-yang-library:modules-state and GET /restconf/data/XXXX:modules-state
This commit is contained in:
parent
0631be19cb
commit
74fc0800ae
18 changed files with 921 additions and 120 deletions
|
|
@ -620,33 +620,51 @@ yang_find_schemanode(yang_node *yn,
|
|||
*/
|
||||
yang_stmt *
|
||||
yang_find_topnode(yang_spec *ysp,
|
||||
char *argument,
|
||||
char *nodeid,
|
||||
yang_class class)
|
||||
{
|
||||
yang_stmt *ys = NULL;
|
||||
yang_stmt *yc = NULL;
|
||||
yang_stmt *ymod = NULL; /* module */
|
||||
yang_stmt *yres = NULL; /* result */
|
||||
char *prefix = NULL;
|
||||
char *id = NULL;
|
||||
int i;
|
||||
|
||||
for (i=0; i<ysp->yp_len; i++){
|
||||
ys = ysp->yp_stmt[i];
|
||||
switch (class){
|
||||
case YC_NONE:
|
||||
if ((yc = yang_find((yang_node*)ys, 0, argument)) != NULL)
|
||||
return yc;
|
||||
break;
|
||||
case YC_DATANODE:
|
||||
if ((yc = yang_find_datanode((yang_node*)ys, argument)) != NULL)
|
||||
return yc;
|
||||
break;
|
||||
case YC_SCHEMANODE:
|
||||
if ((yc = yang_find_schemanode((yang_node*)ys, argument)) != NULL)
|
||||
return yc;
|
||||
break;
|
||||
case YC_DATADEFINITION:
|
||||
break; /* nyi */
|
||||
if (yang_nodeid_split(nodeid, &prefix, &id) < 0)
|
||||
goto done;
|
||||
if (prefix){
|
||||
if ((ymod = yang_find((yang_node*)ysp, Y_MODULE, prefix)) != NULL){
|
||||
if ((yres = yang_find((yang_node*)ymod, 0, id)) != NULL)
|
||||
goto ok;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
else /* No prefix given - loop through and find first */
|
||||
for (i=0; i<ysp->yp_len; i++){
|
||||
ymod = ysp->yp_stmt[i];
|
||||
switch (class){
|
||||
case YC_NONE:
|
||||
if ((yres = yang_find((yang_node*)ymod, 0, id)) != NULL)
|
||||
goto ok;
|
||||
break;
|
||||
case YC_DATANODE:
|
||||
if ((yres = yang_find_datanode((yang_node*)ymod, id)) != NULL)
|
||||
goto ok;
|
||||
break;
|
||||
case YC_SCHEMANODE:
|
||||
if ((yres = yang_find_schemanode((yang_node*)ymod, id)) != NULL)
|
||||
goto ok;
|
||||
break;
|
||||
case YC_DATADEFINITION:
|
||||
break; /* nyi */
|
||||
}
|
||||
}
|
||||
ok:
|
||||
done:
|
||||
if (prefix)
|
||||
free(prefix);
|
||||
if (id)
|
||||
free(id);
|
||||
return yres;
|
||||
}
|
||||
|
||||
/*! Given a yang statement, find the prefix associated to this module
|
||||
|
|
@ -822,7 +840,6 @@ yarg_prefix(yang_stmt *ys)
|
|||
return prefix;
|
||||
}
|
||||
|
||||
|
||||
/*! Split yang node identifier into prefix and identifer.
|
||||
* @param[in] node-id
|
||||
* @param[out] prefix Malloced string. May be NULL.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue