From eed84494b4e434cb3846383771f3482269e48466 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Wed, 7 Aug 2019 12:24:43 -0300 Subject: 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 --- yang/libyang_plugins/frr_user_types.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'yang') 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 */ }; -- cgit v1.2.3