Source VRF Select
[vpp.git] / src / vnet / fib / fib_api.c
index a2f7e79..3c832eb 100644 (file)
@@ -217,7 +217,7 @@ fib_api_path_encode (const fib_route_path_encode_t * api_rpath,
         out->is_drop = true;
         break;
     case DPO_IP_NULL:
-        switch (api_rpath->dpo.dpoi_index)
+        switch (ip_null_dpo_get_action(api_rpath->dpo.dpoi_index))
         {
         case IP_NULL_ACTION_NONE:
             out->is_drop = true;
@@ -241,11 +241,10 @@ fib_api_path_encode (const fib_route_path_encode_t * api_rpath,
     out->afi = api_rpath->rpath.frp_proto;
     fib_api_path_copy_next_hop (api_rpath, out);
 
-    if (~0 == api_rpath->rpath.frp_sw_if_index &&
-        !ip46_address_is_zero(&api_rpath->rpath.frp_addr))
+    if (0 != api_rpath->rpath.frp_fib_index)
     {
         if ((DPO_PROTO_IP6 == api_rpath->rpath.frp_proto) ||
-            (DPO_PROTO_IP6 == api_rpath->rpath.frp_proto))
+            (DPO_PROTO_IP4 == api_rpath->rpath.frp_proto))
         {
             fib_table_t *fib;
 
@@ -266,3 +265,35 @@ fib_api_path_encode (const fib_route_path_encode_t * api_rpath,
         out->next_hop_id = api_rpath->rpath.frp_udp_encap_id;
     }
 }
+
+fib_protocol_t
+fib_proto_from_api_address_family (int af)
+{
+    switch (clib_net_to_host_u32 (af))
+    {
+    case ADDRESS_IP4:
+        return (FIB_PROTOCOL_IP4);
+    case ADDRESS_IP6:
+        return (FIB_PROTOCOL_IP6);
+    }
+
+    ASSERT(0);
+    return (FIB_PROTOCOL_IP4);
+}
+
+int
+fib_proto_to_api_address_family (fib_protocol_t fproto)
+{
+    switch (fproto)
+    {
+    case FIB_PROTOCOL_IP4:
+        return (clib_net_to_host_u32 (ADDRESS_IP4));
+    case FIB_PROTOCOL_IP6:
+        return (clib_net_to_host_u32 (ADDRESS_IP6));
+    default:
+        break;
+    }
+
+    ASSERT(0);
+    return (clib_net_to_host_u32 (ADDRESS_IP4));
+}