2 * Copyright (c) 2016 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #ifndef __MFIB_TYPES_H__
17 #define __MFIB_TYPES_H__
19 #include <vnet/fib/fib_types.h>
22 * Aggregrate type for a prefix
24 typedef struct mfib_prefix_t_ {
33 fib_protocol_t fp_proto;
36 * Pad to keep the address 4 byte aligned
41 * The address type is not deriveable from the fp_addr member.
42 * If it's v4, then the first 3 u32s of the address will be 0.
43 * v6 addresses (even v4 mapped ones) have at least 2 u32s assigned
44 * to non-zero values. true. but when it's all zero, one cannot decide.
46 ip46_address_t fp_grp_addr;
47 ip46_address_t fp_src_addr;
50 typedef enum mfib_entry_attribute_t_
52 MFIB_ENTRY_ATTRIBUTE_FIRST = 0,
54 * The control planes needs packets mathing this entry to generate
57 MFIB_ENTRY_SIGNAL = MFIB_ENTRY_ATTRIBUTE_FIRST,
59 * Drop all traffic to this route
63 * The control plane needs to be informed of coneected sources
67 * Accept packets from any incpoming interface
68 * Use with extreme caution
70 MFIB_ENTRY_ACCEPT_ALL_ITF,
71 MFIB_ENTRY_INHERIT_ACCEPT,
72 MFIB_ENTRY_ATTRIBUTE_LAST = MFIB_ENTRY_INHERIT_ACCEPT,
73 } mfib_entry_attribute_t;
75 #define FOR_EACH_MFIB_ATTRIBUTE(_item) \
76 for (_item = MFIB_ENTRY_ATTRIBUTE_FIRST; \
77 _item <= MFIB_ENTRY_ATTRIBUTE_LAST; \
80 #define MFIB_ENTRY_NAMES_SHORT { \
81 [MFIB_ENTRY_SIGNAL] = "S", \
82 [MFIB_ENTRY_CONNECTED] = "C", \
83 [MFIB_ENTRY_DROP] = "D", \
84 [MFIB_ENTRY_ACCEPT_ALL_ITF] = "AA", \
85 [MFIB_ENTRY_INHERIT_ACCEPT] = "IA", \
88 #define MFIB_ENTRY_NAMES_LONG { \
89 [MFIB_ENTRY_SIGNAL] = "Signal", \
90 [MFIB_ENTRY_CONNECTED] = "Connected", \
91 [MFIB_ENTRY_DROP] = "Drop", \
92 [MFIB_ENTRY_ACCEPT_ALL_ITF] = "Accept-all-itf", \
93 [MFIB_ENTRY_INHERIT_ACCEPT] = "Inherit-Accept", \
96 typedef enum mfib_entry_flags_t_
99 MFIB_ENTRY_FLAG_SIGNAL = (1 << MFIB_ENTRY_SIGNAL),
100 MFIB_ENTRY_FLAG_DROP = (1 << MFIB_ENTRY_DROP),
101 MFIB_ENTRY_FLAG_CONNECTED = (1 << MFIB_ENTRY_CONNECTED),
102 MFIB_ENTRY_FLAG_INHERIT_ACCEPT = (1 << MFIB_ENTRY_INHERIT_ACCEPT),
103 MFIB_ENTRY_FLAG_ACCEPT_ALL_ITF = (1 << MFIB_ENTRY_ACCEPT_ALL_ITF),
104 } mfib_entry_flags_t;
106 typedef enum mfib_itf_attribute_t_
108 MFIB_ITF_ATTRIBUTE_FIRST,
109 MFIB_ITF_NEGATE_SIGNAL = MFIB_ITF_ATTRIBUTE_FIRST,
112 MFIB_ITF_SIGNAL_PRESENT,
113 MFIB_ITF_DONT_PRESERVE,
114 MFIB_ITF_ATTRIBUTE_LAST = MFIB_ITF_DONT_PRESERVE,
115 } mfib_itf_attribute_t;
117 #define FOR_EACH_MFIB_ITF_ATTRIBUTE(_item) \
118 for (_item = MFIB_ITF_ATTRIBUTE_FIRST; \
119 _item <= MFIB_ITF_ATTRIBUTE_LAST; \
122 #define MFIB_ITF_NAMES_SHORT { \
123 [MFIB_ITF_NEGATE_SIGNAL] = "NS", \
124 [MFIB_ITF_ACCEPT] = "A", \
125 [MFIB_ITF_FORWARD] = "F", \
126 [MFIB_ITF_SIGNAL_PRESENT] = "SP", \
127 [MFIB_ITF_DONT_PRESERVE] = "DP", \
130 #define MFIB_ITF_NAMES_LONG { \
131 [MFIB_ITF_NEGATE_SIGNAL] = "Negate-Signal", \
132 [MFIB_ITF_ACCEPT] = "Accept", \
133 [MFIB_ITF_FORWARD] = "Forward", \
134 [MFIB_ITF_SIGNAL_PRESENT] = "Signal-Present", \
135 [MFIB_ITF_DONT_PRESERVE] = "Don't-Preserve", \
138 typedef enum mfib_itf_flags_t_
141 MFIB_ITF_FLAG_NEGATE_SIGNAL = (1 << MFIB_ITF_NEGATE_SIGNAL),
142 MFIB_ITF_FLAG_ACCEPT = (1 << MFIB_ITF_ACCEPT),
143 MFIB_ITF_FLAG_FORWARD = (1 << MFIB_ITF_FORWARD),
144 MFIB_ITF_FLAG_SIGNAL_PRESENT = (1 << MFIB_ITF_SIGNAL_PRESENT),
145 MFIB_ITF_FLAG_DONT_PRESERVE = (1 << MFIB_ITF_DONT_PRESERVE),
149 * Possible [control plane] sources of MFIB entries
151 typedef enum mfib_source_t_
158 MFIB_SOURCE_DEFAULT_ROUTE,
161 #define MFIB_SOURCE_NAMES { \
162 [MFIB_SOURCE_SPECIAL] = "Special", \
163 [MFIB_SOURCE_API] = "API", \
164 [MFIB_SOURCE_CLI] = "CLI", \
165 [MFIB_SOURCE_DHCP] = "DHCP", \
166 [MFIB_SOURCE_VXLAN] = "VXLAN", \
167 [MFIB_SOURCE_DEFAULT_ROUTE] = "Default Route", \
171 * \brief Compare two prefixes for equality
173 extern int mfib_prefix_cmp(const mfib_prefix_t *p1,
174 const mfib_prefix_t *p2);
176 extern u8 * format_mfib_prefix(u8 * s, va_list * args);
178 extern u8 *format_mfib_entry_flags(u8 * s, va_list * args);
179 extern u8 *format_mfib_itf_flags(u8 * s, va_list * args);
180 extern uword unformat_mfib_itf_flags(unformat_input_t * input,
182 extern uword unformat_mfib_entry_flags(unformat_input_t * input,