diff options
| author | Chirag Shah <chirag@cumulusnetworks.com> | 2020-03-30 19:29:32 -0700 |
|---|---|---|
| committer | Santosh P K <sapk@vmware.com> | 2020-04-16 08:24:02 -0700 |
| commit | cad46cfdc96f7cfe21402308ae47dde1e6786bac (patch) | |
| tree | 1b1c5e475f3aa3a7e3c25741ad45a5d77e77dd92 | |
| parent | b71df6891c31309306ea278567a9f1815476a844 (diff) | |
lib: yang wrapper nexthop type to str
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
| -rw-r--r-- | lib/yang_wrappers.c | 28 | ||||
| -rw-r--r-- | lib/yang_wrappers.h | 2 |
2 files changed, 30 insertions, 0 deletions
diff --git a/lib/yang_wrappers.c b/lib/yang_wrappers.c index a172529e52..9434d9b9f0 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) { @@ -1136,3 +1137,30 @@ 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; + } +} diff --git a/lib/yang_wrappers.h b/lib/yang_wrappers.h index dfb42ca2ad..d853b61ae1 100644 --- a/lib/yang_wrappers.h +++ b/lib/yang_wrappers.h @@ -180,4 +180,6 @@ extern struct yang_data *yang_data_new_mac(const char *xpath, const struct ethaddr *mac); extern void yang_str2mac(const char *value, struct ethaddr *mac); +extern const char *yang_nexthop_type2str(uint32_t ntype); + #endif /* _FRR_NORTHBOUND_WRAPPERS_H_ */ |
