summaryrefslogtreecommitdiff
path: root/yang/libyang_plugins
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2019-08-07 12:24:43 -0300
committerRenato Westphal <renato@opensourcerouting.org>2019-09-18 13:38:28 -0300
commiteed84494b4e434cb3846383771f3482269e48466 (patch)
tree85a3123bbf4042ea5f9e6f4e7b91b7bcd26ac95e /yang/libyang_plugins
parent0a0d4f9e2e8bdf9d378c1c07a60e11f8a1bb7cec (diff)
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/libyang_plugins')
-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 a293c3a883..48cdceccf4 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 */
};