Dump routes (VPP-500)
[vpp.git] / vnet / vnet / fib / fib_types.h
index 4ebd68d..83123a5 100644 (file)
@@ -1,4 +1,4 @@
-/*
+ /*
  * Copyright (c) 2016 Cisco and/or its affiliates.
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,45 +58,20 @@ typedef enum fib_protocol_t_ {
  */
 #define FIB_PROTOCOL_NONE (FIB_PROTOCOL_MAX+1)
 
-/**
- * Link Type. This maps directly into the ethertype.
- */
-typedef enum fib_link_t_ {
-#if CLIB_DEBUG > 0
-    FIB_LINK_IP4 = 1,
-#else
-    FIB_LINK_IP4 = 0,
-#endif
-    FIB_LINK_IP6,
-    FIB_LINK_MPLS,
-}  __attribute__ ((packed)) fib_link_t;
-
-/**
- * Definition outside of enum so it does not need to be included in non-defaulted
- * switch statements
- */
-#define FIB_LINK_NUM (FIB_LINK_MPLS+1)
-
-#define FIB_LINKS {            \
-    [FIB_LINK_IP4] = "ipv4",   \
-    [FIB_LINK_IP6] = "ipv6",   \
-    [FIB_LINK_MPLS] = "mpls",   \
-}
-
-#define FOR_EACH_FIB_LINK(_item)  \
-    for (_item = FIB_LINK_IP4;   \
-        _item <= FIB_LINK_MPLS;  \
+#define FOR_EACH_FIB_PROTOCOL(_item)    \
+    for (_item = FIB_PROTOCOL_IP4;      \
+        _item <= FIB_PROTOCOL_MPLS;    \
         _item++)
 
-#define FOR_EACH_FIB_IP_LINK(_item)  \
-    for (_item = FIB_LINK_IP4;      \
-        _item <= FIB_LINK_IP6;      \
+#define FOR_EACH_FIB_IP_PROTOCOL(_item)    \
+    for (_item = FIB_PROTOCOL_IP4;         \
+        _item <= FIB_PROTOCOL_IP6;        \
         _item++)
 
 /**
  * @brief Convert from a protocol to a link type
  */
-fib_link_t fib_proto_to_link (fib_protocol_t proto);
+vnet_link_t fib_proto_to_link (fib_protocol_t proto);
 
 /**
  * FIB output chain type. When a child object requests a forwarding contribution
@@ -124,31 +99,44 @@ typedef enum fib_forward_chain_type_t_ {
      * option is converted into one of the other three internally.
      */
     FIB_FORW_CHAIN_TYPE_MPLS_EOS,
+    /**
+     * Contribute an object that is to be used to forward Ethernet packets.
+     * This is last in the list since it is not valid for many FIB objects,
+     * and thus their array of per-chain-type DPOs can be sized smaller.
+     */
+    FIB_FORW_CHAIN_TYPE_ETHERNET,
 }  __attribute__ ((packed)) fib_forward_chain_type_t;
 
 #define FIB_FORW_CHAINS {                                      \
+    [FIB_FORW_CHAIN_TYPE_ETHERNET]      = "ethernet",          \
     [FIB_FORW_CHAIN_TYPE_UNICAST_IP4]   = "unicast-ip4",       \
     [FIB_FORW_CHAIN_TYPE_UNICAST_IP6]   = "unicast-ip6",       \
     [FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS]  = "mpls-neos",         \
     [FIB_FORW_CHAIN_TYPE_MPLS_EOS]      = "mpls-eos",          \
 }
 
-#define FIB_FORW_CHAIN_NUM (FIB_FORW_CHAIN_TYPE_MPLS_EOS+1)
+#define FIB_FORW_CHAIN_NUM (FIB_FORW_CHAIN_TYPE_MPLS_ETHERNET+1)
+#define FIB_FORW_CHAIN_MPLS_NUM (FIB_FORW_CHAIN_TYPE_MPLS_EOS+1)
 
 #define FOR_EACH_FIB_FORW_CHAIN(_item)                   \
-    for (_item = FIB_FORW_CHAIN_TYPE_UNICAST_IP4;        \
+    for (_item = FIB_FORW_CHAIN_TYPE_UNICAST_IP4;        \
+        _item <= FIB_FORW_CHAIN_TYPE_ETHERNET;           \
+        _item++)
+
+#define FOR_EACH_FIB_FORW_MPLS_CHAIN(_item)              \
+    for (_item = FIB_FORW_CHAIN_TYPE_UNICAST_IP4;        \
         _item <= FIB_FORW_CHAIN_TYPE_MPLS_EOS;           \
         _item++)
 
 /**
  * @brief Convert from a chain type to the adjacencies link type
  */
-extern fib_link_t fib_forw_chain_type_to_link_type(fib_forward_chain_type_t fct);
+extern vnet_link_t fib_forw_chain_type_to_link_type(fib_forward_chain_type_t fct);
 
 /**
  * @brief Convert from a payload-protocol to a chain type.
  */
-extern fib_forward_chain_type_t fib_proto_to_forw_chain_type(fib_protocol_t proto);
+extern fib_forward_chain_type_t fib_forw_chain_type_from_dpo_proto(dpo_proto_t proto);
 
 /**
  * @brief Convert from a chain type to the DPO proto it will install
@@ -196,8 +184,8 @@ typedef struct fib_prefix_t_ {
     };
 } fib_prefix_t;
 
-_Static_assert(STRUCT_OFFSET_OF(fib_prefix_t, fp_addr) == 4,
-              "FIB Prefix's address is 4 byte aligned.");
+STATIC_ASSERT(STRUCT_OFFSET_OF(fib_prefix_t, fp_addr) == 4,
+             "FIB Prefix's address is 4 byte aligned.");
 
 /**
  * \brief Compare two prefixes for equality
@@ -256,7 +244,7 @@ typedef enum fib_special_type_t_ {
         _item <= FIB_SPEICAL_TYPE_LAST; _item++)
 
 extern u8 * format_fib_protocol(u8 * s, va_list ap);
-extern u8 * format_fib_link(u8 *s, va_list ap);
+extern u8 * format_vnet_link(u8 *s, va_list ap);
 
 /**
  * Path flags from the control plane
@@ -328,4 +316,13 @@ typedef struct fib_route_path_t_ {
     mpls_label_t frp_label;
 } fib_route_path_t;
 
+/**
+ * @brief 
+ * A representation of a fib path for fib_path_encode to convey the information to the caller
+ */
+typedef struct fib_route_path_encode_t_ {
+    fib_route_path_t rpath;
+    dpo_id_t dpo;
+} fib_route_path_encode_t;
+
 #endif