diff options
| author | Chirag Shah <chirag@cumulusnetworks.com> | 2020-05-12 14:09:57 -0700 |
|---|---|---|
| committer | Chirag Shah <chirag@cumulusnetworks.com> | 2020-05-12 14:31:37 -0700 |
| commit | 77f4028e503aa76ea5a06f2393b7607b6bcf5da9 (patch) | |
| tree | 55ac4325f06818d64aecdaa1b3b2b3b1f3390dfd /zebra/zebra_nb.c | |
| parent | db856683559935952edaf90079fa0e45cb4cefe6 (diff) | |
zebra: afi-safi identity to value apis
Helper APIs to convert afi-safi identity to values.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
Diffstat (limited to 'zebra/zebra_nb.c')
| -rw-r--r-- | zebra/zebra_nb.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/zebra/zebra_nb.c b/zebra/zebra_nb.c index aad60aac6a..25b8b44ec9 100644 --- a/zebra/zebra_nb.c +++ b/zebra/zebra_nb.c @@ -22,6 +22,40 @@ #include "libfrr.h" #include "zebra_nb.h" +const char *zebra_afi_safi_value2identity(afi_t afi, safi_t safi) +{ + if (afi == AFI_IP && safi == SAFI_UNICAST) + return "ipv4-unicast"; + if (afi == AFI_IP6 && safi == SAFI_UNICAST) + return "ipv6-unicast"; + if (afi == AFI_IP && safi == SAFI_MULTICAST) + return "ipv4-multicast"; + if (afi == AFI_IP6 && safi == SAFI_MULTICAST) + return "ipv6-multicast"; + + return " "; +} + +void zebra_afi_safi_identity2value(const char *key, afi_t *afi, safi_t *safi) +{ + if (strmatch(key, "frr-zebra:ipv4-unicast")) { + *afi = AFI_IP; + *safi = SAFI_UNICAST; + } else if (strmatch(key, "frr-zebra:ipv6-unicast")) { + *afi = AFI_IP6; + *safi = SAFI_UNICAST; + } else if (strmatch(key, "frr-zebra:ipv4-multicast")) { + *afi = AFI_IP; + *safi = SAFI_MULTICAST; + } else if (strmatch(key, "frr-zebra:ipv6-multicast")) { + *afi = AFI_IP6; + *safi = SAFI_MULTICAST; + } else { + *afi = AFI_UNSPEC; + *safi = SAFI_UNSPEC; + } +} + /* clang-format off */ const struct frr_yang_module_info frr_zebra_info = { .name = "frr-zebra", |
