diff options
| author | Chirag Shah <chirag@cumulusnetworks.com> | 2020-07-15 13:36:47 -0700 | 
|---|---|---|
| committer | Chirag Shah <chirag@cumulusnetworks.com> | 2020-08-11 17:06:23 -0700 | 
| commit | 47cd22344168ccefb2bb9483c452cc33fd714899 (patch) | |
| tree | 15969c0dd76b431e82032bc4dd812eda6eb38240 /lib/yang_wrappers.c | |
| parent | c64e4ca2a7821d0f20b4ca4c19bc1c9e31468b7d (diff) | |
lib: yang wrapper for getting empty type
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
Diffstat (limited to 'lib/yang_wrappers.c')
| -rw-r--r-- | lib/yang_wrappers.c | 23 | 
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/yang_wrappers.c b/lib/yang_wrappers.c index 4f743096ee..4c658c1bfb 100644 --- a/lib/yang_wrappers.c +++ b/lib/yang_wrappers.c @@ -792,6 +792,29 @@ struct yang_data *yang_data_new_empty(const char *xpath)  	return yang_data_new(xpath, NULL);  } +bool yang_dnode_get_empty(const struct lyd_node *dnode, const char *xpath_fmt, +			  ...) +{ +	va_list ap; +	char xpath[XPATH_MAXLEN]; +	const struct lyd_node_leaf_list *dleaf; + +	assert(dnode); + +	va_start(ap, xpath_fmt); +	vsnprintf(xpath, sizeof(xpath), xpath_fmt, ap); +	va_end(ap); + +	dnode = yang_dnode_get(dnode, xpath); +	if (dnode) { +		dleaf = (const struct lyd_node_leaf_list *)dnode; +		if (dleaf->value_type == LY_TYPE_EMPTY) +			return true; +	} + +	return false; +} +  /*   * Derived type: IP prefix.   */  | 
