afi-safi identity handling should be in the common place.
Signed-off-by: VishalDhingra <vdhingra@vmware.com>
break;
}
}
+
+
+const char *yang_afi_safi_value2identity(afi_t afi, safi_t safi)
+{
+ if (afi == AFI_IP && safi == SAFI_UNICAST)
+ return "frr-routing:ipv4-unicast";
+ if (afi == AFI_IP6 && safi == SAFI_UNICAST)
+ return "frr-routing:ipv6-unicast";
+ if (afi == AFI_IP && safi == SAFI_MULTICAST)
+ return "frr-routing:ipv4-multicast";
+ if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
+ return "frr-routing:ipv6-multicast";
+
+ return NULL;
+}
+
+void yang_afi_safi_identity2value(const char *key, afi_t *afi, safi_t *safi)
+{
+ if (strmatch(key, "frr-routing:ipv4-unicast")) {
+ *afi = AFI_IP;
+ *safi = SAFI_UNICAST;
+ } else if (strmatch(key, "frr-routing:ipv6-unicast")) {
+ *afi = AFI_IP6;
+ *safi = SAFI_UNICAST;
+ } else if (strmatch(key, "frr-routing:ipv4-multicast")) {
+ *afi = AFI_IP;
+ *safi = SAFI_MULTICAST;
+ } else if (strmatch(key, "frr-routing:ipv6-multicast")) {
+ *afi = AFI_IP6;
+ *safi = SAFI_MULTICAST;
+ } else {
+ *afi = AFI_UNSPEC;
+ *safi = SAFI_UNSPEC;
+ }
+}
/* nexthop enum2str */
extern const char *yang_nexthop_type2str(uint32_t ntype);
+const char *yang_afi_safi_value2identity(afi_t afi, safi_t safi);
+void yang_afi_safi_identity2value(const char *key, afi_t *afi, safi_t *safi);
+
#ifdef __cplusplus
}
#endif
"This identity represents an IPv6 address family.";
}
+ identity afi-safi-type {
+ description
+ "Base identity type (AFI,SAFI) tuples for RIB";
+ }
+
+ identity ipv4-unicast {
+ base afi-safi-type;
+ description
+ "This identity represents the IPv4 unicast address family.";
+ }
+
+ identity ipv6-unicast {
+ base afi-safi-type;
+ description
+ "This identity represents the IPv6 unicast address family.";
+ }
+
+ identity ipv4-multicast {
+ base afi-safi-type;
+ description
+ "This identity represents the IPv4 multicast address family.";
+ }
+
+ identity ipv6-multicast {
+ base afi-safi-type;
+ description
+ "This identity represents the IPv6 multicast address family.";
+ }
+
identity control-plane-protocol {
description
"Base identity from which control-plane protocol identities are
"Initial revision.";
}
- identity afi-safi-type {
- description
- "Base identity type (AFI,SAFI) tuples for RIB";
- }
-
- identity ipv4-unicast {
- base afi-safi-type;
- description
- "This identity represents the IPv4 unicast address family.";
- }
-
- identity ipv6-unicast {
- base afi-safi-type;
- description
- "This identity represents the IPv6 unicast address family.";
- }
-
- identity ipv4-multicast {
- base afi-safi-type;
- description
- "This identity represents the IPv4 multicast address family.";
- }
-
- identity ipv6-multicast {
- base afi-safi-type;
- description
- "This identity represents the IPv6 multicast address family.";
- }
-
typedef unix-timestamp {
type uint32;
units "seconds";
key "afi-safi-name table-id";
leaf afi-safi-name {
type identityref {
- base afi-safi-type;
+ base frr-rt:afi-safi-type;
}
description
"AFI, SAFI name.";
#include "vrf.h"
#include "libfrr.h"
#include "routemap.h"
+#include "routing_nb.h"
#include "zebra/zebra_router.h"
#include "zebra/zebra_errors.h"
&frr_route_map_info,
&frr_zebra_info,
&frr_vrf_info,
+ &frr_routing_info,
};
FRR_DAEMON_INFO(
#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",
extern const struct frr_yang_module_info frr_zebra_info;
-/* helper functions */
-const char *zebra_afi_safi_value2identity(afi_t afi, safi_t safi);
-void zebra_afi_safi_identity2value(const char *key, afi_t *afi, safi_t *safi);
-
/* prototypes */
int get_route_information_rpc(struct nb_cb_rpc_args *args);
int get_v6_mroute_info_rpc(struct nb_cb_rpc_args *args);
table_id = zvrf->table_id;
afi_safi_name = yang_dnode_get_string(args->dnode, "./afi-safi-name");
- zebra_afi_safi_identity2value(afi_safi_name, &afi, &safi);
+ yang_afi_safi_identity2value(afi_safi_name, &afi, &safi);
zrt = zebra_router_find_zrt(zvrf, table_id, afi, safi);
args->keys->num = 2;
- snprintfrr(args->keys->key[0], sizeof(args->keys->key[0]), "%s:%s",
- "frr-zebra",
- zebra_afi_safi_value2identity(zrt->afi, zrt->safi));
+ snprintfrr(args->keys->key[0], sizeof(args->keys->key[0]), "%s",
+ yang_afi_safi_value2identity(zrt->afi, zrt->safi));
snprintfrr(args->keys->key[1], sizeof(args->keys->key[1]), "%u",
zrt->tableid);
zvrf = zebra_vrf_lookup_by_id(vrf->vrf_id);
- zebra_afi_safi_identity2value(args->keys->key[0], &afi, &safi);
+ yang_afi_safi_identity2value(args->keys->key[0], &afi, &safi);
table_id = yang_str2uint32(args->keys->key[1]);
/* table_id 0 assume vrf's table_id. */
if (!table_id)