summaryrefslogtreecommitdiff
path: root/lib/yang_wrappers.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/yang_wrappers.c')
-rw-r--r--lib/yang_wrappers.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/yang_wrappers.c b/lib/yang_wrappers.c
index 2b502d635b..7d94a2f744 100644
--- a/lib/yang_wrappers.c
+++ b/lib/yang_wrappers.c
@@ -23,6 +23,7 @@
#include "lib_errors.h"
#include "northbound.h"
#include "printfrr.h"
+#include "nexthop.h"
static const char *yang_get_default_value(const char *xpath)
{
@@ -783,6 +784,14 @@ void yang_get_default_string_buf(char *buf, size_t size, const char *xpath_fmt,
}
/*
+ * Primitive type: empty.
+ */
+struct yang_data *yang_data_new_empty(const char *xpath)
+{
+ return yang_data_new(xpath, NULL);
+}
+
+/*
* Derived type: IP prefix.
*/
void yang_str2prefix(const char *value, union prefixptr prefix)
@@ -1114,3 +1123,44 @@ void yang_get_default_ip(struct ipaddr *var, const char *xpath_fmt, ...)
value = yang_get_default_value(xpath);
yang_str2ip(value, var);
}
+
+struct yang_data *yang_data_new_mac(const char *xpath,
+ const struct ethaddr *mac)
+{
+ char value_str[ETHER_ADDR_STRLEN];
+
+ prefix_mac2str(mac, value_str, sizeof(value_str));
+ return yang_data_new(xpath, value_str);
+}
+
+void yang_str2mac(const char *value, struct ethaddr *mac)
+{
+ (void)prefix_str2mac(value, mac);
+}
+
+const char *yang_nexthop_type2str(uint32_t ntype)
+{
+ switch (ntype) {
+ case NEXTHOP_TYPE_IFINDEX:
+ return "ifindex";
+ break;
+ case NEXTHOP_TYPE_IPV4:
+ return "ip4";
+ break;
+ case NEXTHOP_TYPE_IPV4_IFINDEX:
+ return "ip4-ifindex";
+ break;
+ case NEXTHOP_TYPE_IPV6:
+ return "ip6";
+ break;
+ case NEXTHOP_TYPE_IPV6_IFINDEX:
+ return "ip6-ifindex";
+ break;
+ case NEXTHOP_TYPE_BLACKHOLE:
+ return "blackhole";
+ break;
+ default:
+ return "unknown";
+ break;
+ }
+}