]> git.proxmox.com Git - mirror_frr.git/blame - lib/yang_wrappers.h
Merge pull request #13278 from FRRouting/mergify/bp/stable/8.5/pr-13269
[mirror_frr.git] / lib / yang_wrappers.h
CommitLineData
1c2facd1
RW
1/*
2 * Copyright (C) 2018 NetDEF, Inc.
3 * Renato Westphal
4 *
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)
8 * any later version.
9 *
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
13 * more details.
14 *
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
18 */
19
20#ifndef _FRR_NORTHBOUND_WRAPPERS_H_
21#define _FRR_NORTHBOUND_WRAPPERS_H_
22
23#include "prefix.h"
24
17e38209
RW
25#ifdef __cplusplus
26extern "C" {
27#endif
28
1c2facd1
RW
29/* bool */
30extern bool yang_str2bool(const char *value);
31extern struct yang_data *yang_data_new_bool(const char *xpath, bool value);
32extern bool yang_dnode_get_bool(const struct lyd_node *dnode,
0f9de11a
DL
33 const char *xpath_fmt, ...) PRINTFRR(2, 3);
34extern bool yang_get_default_bool(const char *xpath_fmt, ...) PRINTFRR(1, 2);
1c2facd1
RW
35
36/* dec64 */
37extern double yang_str2dec64(const char *xpath, const char *value);
38extern struct yang_data *yang_data_new_dec64(const char *xpath, double value);
39extern double yang_dnode_get_dec64(const struct lyd_node *dnode,
0f9de11a
DL
40 const char *xpath_fmt, ...) PRINTFRR(2, 3);
41extern double yang_get_default_dec64(const char *xpath_fmt, ...) PRINTFRR(1, 2);
1c2facd1
RW
42
43/* enum */
44extern int yang_str2enum(const char *xpath, const char *value);
45extern struct yang_data *yang_data_new_enum(const char *xpath, int value);
46extern int yang_dnode_get_enum(const struct lyd_node *dnode,
0f9de11a
DL
47 const char *xpath_fmt, ...) PRINTFRR(2, 3);
48extern int yang_get_default_enum(const char *xpath_fmt, ...) PRINTFRR(1, 2);
1c2facd1
RW
49
50/* int8 */
51extern int8_t yang_str2int8(const char *value);
52extern struct yang_data *yang_data_new_int8(const char *xpath, int8_t value);
53extern int8_t yang_dnode_get_int8(const struct lyd_node *dnode,
0f9de11a
DL
54 const char *xpath_fmt, ...) PRINTFRR(2, 3);
55extern int8_t yang_get_default_int8(const char *xpath_fmt, ...) PRINTFRR(1, 2);
1c2facd1
RW
56
57/* int16 */
58extern int16_t yang_str2int16(const char *value);
59extern struct yang_data *yang_data_new_int16(const char *xpath, int16_t value);
60extern int16_t yang_dnode_get_int16(const struct lyd_node *dnode,
0f9de11a
DL
61 const char *xpath_fmt, ...) PRINTFRR(2, 3);
62extern int16_t yang_get_default_int16(const char *xpath_fmt, ...)
63 PRINTFRR(1, 2);
1c2facd1
RW
64
65/* int32 */
66extern int32_t yang_str2int32(const char *value);
67extern struct yang_data *yang_data_new_int32(const char *xpath, int32_t value);
68extern int32_t yang_dnode_get_int32(const struct lyd_node *dnode,
0f9de11a
DL
69 const char *xpath_fmt, ...) PRINTFRR(2, 3);
70extern int32_t yang_get_default_int32(const char *xpath_fmt, ...)
71 PRINTFRR(1, 2);
1c2facd1
RW
72
73/* int64 */
74extern int64_t yang_str2int64(const char *value);
75extern struct yang_data *yang_data_new_int64(const char *xpath, int64_t value);
76extern int64_t yang_dnode_get_int64(const struct lyd_node *dnode,
0f9de11a
DL
77 const char *xpath_fmt, ...) PRINTFRR(2, 3);
78extern int64_t yang_get_default_int64(const char *xpath_fmt, ...)
79 PRINTFRR(1, 2);
1c2facd1
RW
80
81/* uint8 */
82extern uint8_t yang_str2uint8(const char *value);
83extern struct yang_data *yang_data_new_uint8(const char *xpath, uint8_t value);
84extern uint8_t yang_dnode_get_uint8(const struct lyd_node *dnode,
0f9de11a
DL
85 const char *xpath_fmt, ...) PRINTFRR(2, 3);
86extern uint8_t yang_get_default_uint8(const char *xpath_fmt, ...)
87 PRINTFRR(1, 2);
1c2facd1
RW
88
89/* uint16 */
90extern uint16_t yang_str2uint16(const char *value);
91extern struct yang_data *yang_data_new_uint16(const char *xpath,
92 uint16_t value);
93extern uint16_t yang_dnode_get_uint16(const struct lyd_node *dnode,
0f9de11a
DL
94 const char *xpath_fmt, ...)
95 PRINTFRR(2, 3);
96extern uint16_t yang_get_default_uint16(const char *xpath_fmt, ...)
97 PRINTFRR(1, 2);
1c2facd1
RW
98
99/* uint32 */
100extern uint32_t yang_str2uint32(const char *value);
101extern struct yang_data *yang_data_new_uint32(const char *xpath,
102 uint32_t value);
103extern uint32_t yang_dnode_get_uint32(const struct lyd_node *dnode,
0f9de11a
DL
104 const char *xpath_fmt, ...)
105 PRINTFRR(2, 3);
106extern uint32_t yang_get_default_uint32(const char *xpath_fmt, ...)
107 PRINTFRR(1, 2);
1c2facd1
RW
108
109/* uint64 */
110extern uint64_t yang_str2uint64(const char *value);
111extern struct yang_data *yang_data_new_uint64(const char *xpath,
112 uint64_t value);
113extern uint64_t yang_dnode_get_uint64(const struct lyd_node *dnode,
0f9de11a
DL
114 const char *xpath_fmt, ...)
115 PRINTFRR(2, 3);
116extern uint64_t yang_get_default_uint64(const char *xpath_fmt, ...)
117 PRINTFRR(1, 2);
1c2facd1
RW
118
119/* string */
120extern struct yang_data *yang_data_new_string(const char *xpath,
121 const char *value);
122extern const char *yang_dnode_get_string(const struct lyd_node *dnode,
0f9de11a
DL
123 const char *xpath_fmt, ...)
124 PRINTFRR(2, 3);
1c2facd1
RW
125extern void yang_dnode_get_string_buf(char *buf, size_t size,
126 const struct lyd_node *dnode,
0f9de11a
DL
127 const char *xpath_fmt, ...)
128 PRINTFRR(4, 5);
129extern const char *yang_get_default_string(const char *xpath_fmt, ...)
130 PRINTFRR(1, 2);
1c2facd1 131extern void yang_get_default_string_buf(char *buf, size_t size,
0f9de11a
DL
132 const char *xpath_fmt, ...)
133 PRINTFRR(3, 4);
1c2facd1 134
ac313345 135/* binary */
136extern struct yang_data *yang_data_new_binary(const char *xpath,
137 const char *value, size_t len);
138extern size_t yang_dnode_get_binary_buf(char *buf, size_t size,
139 const struct lyd_node *dnode,
0f9de11a
DL
140 const char *xpath_fmt, ...)
141 PRINTFRR(4, 5);
ac313345 142
b71df689
CS
143/* empty */
144extern struct yang_data *yang_data_new_empty(const char *xpath);
47cd2234 145extern bool yang_dnode_get_empty(const struct lyd_node *dnode,
0f9de11a 146 const char *xpath_fmt, ...) PRINTFRR(2, 3);
b71df689 147
eed84494
RW
148/* ip prefix */
149extern void yang_str2prefix(const char *value, union prefixptr prefix);
150extern struct yang_data *yang_data_new_prefix(const char *xpath,
151 union prefixconstptr prefix);
46fcb2df 152extern void yang_dnode_get_prefix(struct prefix *prefix,
eed84494 153 const struct lyd_node *dnode,
0f9de11a 154 const char *xpath_fmt, ...) PRINTFRR(3, 4);
eed84494 155extern void yang_get_default_prefix(union prefixptr var, const char *xpath_fmt,
0f9de11a 156 ...) PRINTFRR(2, 3);
eed84494 157
1c2facd1
RW
158/* ipv4 */
159extern void yang_str2ipv4(const char *value, struct in_addr *addr);
160extern struct yang_data *yang_data_new_ipv4(const char *xpath,
161 const struct in_addr *addr);
162extern void yang_dnode_get_ipv4(struct in_addr *addr,
163 const struct lyd_node *dnode,
0f9de11a 164 const char *xpath_fmt, ...) PRINTFRR(3, 4);
1c2facd1 165extern void yang_get_default_ipv4(struct in_addr *var, const char *xpath_fmt,
0f9de11a 166 ...) PRINTFRR(2, 3);
1c2facd1
RW
167
168/* ipv4p */
169extern void yang_str2ipv4p(const char *value, union prefixptr prefix);
170extern struct yang_data *yang_data_new_ipv4p(const char *xpath,
70065793 171 union prefixconstptr prefix);
1c2facd1
RW
172extern void yang_dnode_get_ipv4p(union prefixptr prefix,
173 const struct lyd_node *dnode,
0f9de11a 174 const char *xpath_fmt, ...) PRINTFRR(3, 4);
1c2facd1 175extern void yang_get_default_ipv4p(union prefixptr var, const char *xpath_fmt,
0f9de11a 176 ...) PRINTFRR(2, 3);
1c2facd1
RW
177
178/* ipv6 */
179extern void yang_str2ipv6(const char *value, struct in6_addr *addr);
180extern struct yang_data *yang_data_new_ipv6(const char *xpath,
181 const struct in6_addr *addr);
182extern void yang_dnode_get_ipv6(struct in6_addr *addr,
183 const struct lyd_node *dnode,
0f9de11a 184 const char *xpath_fmt, ...) PRINTFRR(3, 4);
1c2facd1 185extern void yang_get_default_ipv6(struct in6_addr *var, const char *xpath_fmt,
0f9de11a 186 ...) PRINTFRR(2, 3);
1c2facd1
RW
187
188/* ipv6p */
189extern void yang_str2ipv6p(const char *value, union prefixptr prefix);
190extern struct yang_data *yang_data_new_ipv6p(const char *xpath,
70065793 191 union prefixconstptr prefix);
1c2facd1
RW
192extern void yang_dnode_get_ipv6p(union prefixptr prefix,
193 const struct lyd_node *dnode,
0f9de11a 194 const char *xpath_fmt, ...) PRINTFRR(3, 4);
1c2facd1 195extern void yang_get_default_ipv6p(union prefixptr var, const char *xpath_fmt,
0f9de11a 196 ...) PRINTFRR(2, 3);
1c2facd1 197
b0584ad3
QY
198/* ip */
199extern void yang_str2ip(const char *value, struct ipaddr *addr);
200extern struct yang_data *yang_data_new_ip(const char *xpath,
201 const struct ipaddr *addr);
202extern void yang_dnode_get_ip(struct ipaddr *addr, const struct lyd_node *dnode,
0f9de11a
DL
203 const char *xpath_fmt, ...) PRINTFRR(3, 4);
204extern void yang_get_default_ip(struct ipaddr *var, const char *xpath_fmt, ...)
205 PRINTFRR(2, 3);
b0584ad3 206
dd9ef518
CS
207/* mac */
208extern struct yang_data *yang_data_new_mac(const char *xpath,
209 const struct ethaddr *mac);
210extern void yang_str2mac(const char *value, struct ethaddr *mac);
211
8d0c8ff5
CS
212/*data-and-time */
213extern struct yang_data *yang_data_new_date_and_time(const char *xpath,
214 time_t time);
215
216/* nexthop enum2str */
cad46cfd
CS
217extern const char *yang_nexthop_type2str(uint32_t ntype);
218
755100ac 219const char *yang_afi_safi_value2identity(afi_t afi, safi_t safi);
220void yang_afi_safi_identity2value(const char *key, afi_t *afi, safi_t *safi);
221
17e38209
RW
222#ifdef __cplusplus
223}
224#endif
225
1c2facd1 226#endif /* _FRR_NORTHBOUND_WRAPPERS_H_ */