]> git.proxmox.com Git - mirror_frr.git/blobdiff - yang/libyang_plugins/frr_user_types.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / yang / libyang_plugins / frr_user_types.c
index a293c3a88354b06dd66cb4ee4b5cc363d40154f2..70a8da39caeb1d8d213fd8a57419cb40db6a58fd 100644 (file)
@@ -1,20 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (C) 2018  NetDEF, Inc.
  *                     Renato Westphal
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
@@ -99,6 +86,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 +116,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 */
 };