2 * Copyright (C) 2018 NetDEF, Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <libyang/user_types.h>
26 static int ipv4_address_store_clb(const char *type_name
, const char *value_str
,
27 lyd_val
*value
, char **err_msg
)
29 value
->ptr
= malloc(sizeof(struct in_addr
));
33 if (inet_pton(AF_INET
, value_str
, value
->ptr
) != 1) {
41 static int ipv6_address_store_clb(const char *type_name
, const char *value_str
,
42 lyd_val
*value
, char **err_msg
)
44 value
->ptr
= malloc(INET6_ADDRSTRLEN
);
48 if (inet_pton(AF_INET6
, value_str
, value
->ptr
) != 1) {
56 static int ipv4_prefix_store_clb(const char *type_name
, const char *value_str
,
57 lyd_val
*value
, char **err_msg
)
59 value
->ptr
= malloc(sizeof(struct prefix_ipv4
));
63 if (str2prefix_ipv4(value_str
, value
->ptr
) == 0) {
71 static int ipv6_prefix_store_clb(const char *type_name
, const char *value_str
,
72 lyd_val
*value
, char **err_msg
)
74 value
->ptr
= malloc(sizeof(struct prefix_ipv6
));
78 if (str2prefix_ipv6(value_str
, value
->ptr
) == 0) {
86 struct lytype_plugin_list frr_user_types
[] = {
87 {"ietf-inet-types", "2013-07-15", "ipv4-address",
88 ipv4_address_store_clb
, free
},
89 {"ietf-inet-types", "2013-07-15", "ipv4-address-no-zone",
90 ipv4_address_store_clb
, free
},
91 {"ietf-inet-types", "2013-07-15", "ipv6-address",
92 ipv6_address_store_clb
, free
},
93 {"ietf-inet-types", "2013-07-15", "ipv6-address-no-zone",
94 ipv6_address_store_clb
, free
},
95 {"ietf-inet-types", "2013-07-15", "ipv4-prefix", ipv4_prefix_store_clb
,
97 {"ietf-inet-types", "2013-07-15", "ipv6-prefix", ipv6_prefix_store_clb
,
99 {NULL
, NULL
, NULL
, NULL
, NULL
} /* terminating item */