summaryrefslogtreecommitdiffstats
path: root/yang
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2019-08-07 17:24:43 +0200
committerRenato Westphal <renato@opensourcerouting.org>2019-09-18 18:38:28 +0200
commiteed84494b4e434cb3846383771f3482269e48466 (patch)
tree85a3123bbf4042ea5f9e6f4e7b91b7bcd26ac95e /yang
parentMerge pull request #5006 from manuhalo/fix_ftn_uninstall (diff)
downloadfrr-eed84494b4e434cb3846383771f3482269e48466.tar.xz
frr-eed84494b4e434cb3846383771f3482269e48466.zip
lib: add yang wrappers for IP prefixes
We had wrappers for IPv4 and IPv6 prefixes, but not for IP (version agnostic) prefixes. This commit addresses this issue. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'yang')
-rw-r--r--yang/libyang_plugins/frr_user_types.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/yang/libyang_plugins/frr_user_types.c b/yang/libyang_plugins/frr_user_types.c
index a293c3a88..48cdceccf 100644
--- a/yang/libyang_plugins/frr_user_types.c
+++ b/yang/libyang_plugins/frr_user_types.c
@@ -99,6 +99,21 @@ static int ipv6_prefix_store_clb(const char *type_name, const char *value_str,
return 0;
}
+static int ip_prefix_store_clb(const char *type_name, const char *value_str,
+ lyd_val *value, char **err_msg)
+{
+ value->ptr = malloc(sizeof(struct prefix));
+ if (!value->ptr)
+ return 1;
+
+ if (str2prefix(value_str, value->ptr) == 0) {
+ free(value->ptr);
+ return 1;
+ }
+
+ return 0;
+}
+
struct lytype_plugin_list frr_user_types[] = {
{"ietf-inet-types", "2013-07-15", "ipv4-address",
ipv4_address_store_clb, free},
@@ -114,5 +129,7 @@ struct lytype_plugin_list frr_user_types[] = {
free},
{"ietf-inet-types", "2013-07-15", "ipv6-prefix", ipv6_prefix_store_clb,
free},
+ {"ietf-inet-types", "2013-07-15", "ip-prefix", ip_prefix_store_clb,
+ free},
{NULL, NULL, NULL, NULL, NULL} /* terminating item */
};