fib: fib api updates
[vpp.git] / src / vnet / fib / fib_types.api
1 /* Hey Emacs use -*- mode: C -*- */
2 /*
3  * Copyright (c) 2018 Cisco and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 option version = "2.0.0";
18 import "vnet/ip/ip_types.api";
19
20 /** \brief MPLS label
21 */
22 typedef fib_mpls_label
23 {
24   u8 is_uniform;
25   u32 label;
26   u8 ttl;
27   u8 exp;
28 };
29
30 /** brief A path's nexthop protocol
31  */
32 enum fib_path_nh_proto
33 {
34   FIB_API_PATH_NH_PROTO_IP4 = 0,
35   FIB_API_PATH_NH_PROTO_IP6,
36   FIB_API_PATH_NH_PROTO_MPLS,
37   FIB_API_PATH_NH_PROTO_ETHERNET,
38   FIB_API_PATH_NH_PROTO_BIER,
39 };
40
41 /** \brief Flags for the path
42  */
43 enum fib_path_flags
44 {
45   FIB_API_PATH_FLAG_NONE = 0,
46   /* the path must resolve via an attached route */
47   FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED,
48   /* the path must resolve via a host route */
49   FIB_API_PATH_FLAG_RESOLVE_VIA_HOST,
50 };
51
52 /* \brief A description of the 'next-hop' for a path
53  *  this can be something that needs resolving like an IP address
54  *  (into an adjacency or another FIB entry) or the index of another
55  *  VPP object that was previously created (i.e. a UDP encap object)
56  */
57 typedef fib_path_nh
58 {
59   /* proto = IP[46] */
60   vl_api_address_union_t address;
61   /* proto = MPLS */
62   u32 via_label;
63   /* proto = ANY, determined by path type */
64   u32 obj_id;
65   /* path-type = CLASSIFY */
66   u32 classify_table_index;
67 };
68
69 enum fib_path_type
70 {
71   /* Normal Paths */
72   FIB_API_PATH_TYPE_NORMAL = 0,
73   /* local/for-us/receive = packet sent to VPP's L4 stack */
74   FIB_API_PATH_TYPE_LOCAL,
75   /* packet is dropped */
76   FIB_API_PATH_TYPE_DROP,
77   /* Packet is UDP encapped  - set obj_id in fib_path_nh_id */
78   FIB_API_PATH_TYPE_UDP_ENCAP,
79   /* Packet is BIER encapped  - set obj_id in fib_path_nh_id */
80   FIB_API_PATH_TYPE_BIER_IMP,
81   /* packet will generated ICMP unreach to sender */
82   FIB_API_PATH_TYPE_ICMP_UNREACH,
83   /* packet will generated ICMP prohibt to sender */
84   FIB_API_PATH_TYPE_ICMP_PROHIBIT,
85   /* perform a lookup based on the packet's source address */
86   FIB_API_PATH_TYPE_SOURCE_LOOKUP,
87   /* Distributed Virtual router, packet is forwarded with the original
88      L2 header unchanged */
89   FIB_API_PATH_TYPE_DVR,
90   /* packet's RX interface is changed */
91   FIB_API_PATH_TYPE_INTERFACE_RX,
92   /* packet will be sent to a classify table */
93   FIB_API_PATH_TYPE_CLASSIFY,
94 };
95
96 /** \brief FIB path
97     @param sw_if_index - index of the interface
98     @param table_id - The table ID in which to find the next-hop address
99                       (for recursive routes, i.e. when the interface is
100                        not given)
101     @param weight - The weight, for UCMP
102     @param preference - The preference of the path. lowest preference
103                         is prefered
104     @param rpf-id - For paths that pop to multicast, this the the
105                     RPF ID the packet will be given (0 and ~0 => unset)
106     @param type - the path type
107     @param flags - path flags
108     @param proto - protocol that describes the next-hop address
109     @param nh - the next-hop/net resolving object
110     @param n_labels - the number of labels present in the stack
111     @param label_stack - a stack of MPLS labels
112 */
113 typedef fib_path
114 {
115   u32 sw_if_index;
116   u32 table_id;
117   u32 rpf_id;
118   u8 weight;
119   u8 preference;
120
121   vl_api_fib_path_type_t type;
122   vl_api_fib_path_flags_t flags;
123   vl_api_fib_path_nh_proto_t proto;
124   vl_api_fib_path_nh_t nh;
125   u8 n_labels;
126   vl_api_fib_mpls_label_t label_stack[16];
127 };