2 * Copyright (c) 2015 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.
15 #ifndef included_vnet_mpls_h
16 #define included_vnet_mpls_h
18 #include <vnet/vnet.h>
19 #include <vnet/mpls/packet.h>
20 #include <vnet/mpls/mpls_types.h>
21 #include <vnet/ip/ip4_packet.h>
22 #include <vnet/ethernet/ethernet.h>
23 #include <vnet/fib/fib_node.h>
24 #include <vnet/adj/adj.h>
27 #define mpls_error(n,s) MPLS_ERROR_##n,
28 #include <vnet/mpls/error.def>
33 #define MPLS_FIB_DEFAULT_TABLE_ID 0
36 * Type exposure is to allow the DP fast/inlined access
38 #define MPLS_FIB_KEY_SIZE 21
39 #define MPLS_FIB_DB_SIZE (1 << (MPLS_FIB_KEY_SIZE-1))
41 typedef struct mpls_fib_t_
44 * A hash table of entries. 21 bit key
45 * Hash table for reduced memory footprint
50 * The load-balance indeices keyed by 21 bit label+eos bit.
51 * A flat array for maximum lookup performace.
53 index_t mf_lbs[MPLS_FIB_DB_SIZE];
57 * @brief Definition of a callback for receiving MPLS interface state change
60 typedef void (*mpls_interface_state_change_callback_t)(u32 sw_if_index,
64 /* MPLS FIB index for each software interface */
65 u32 *fib_index_by_sw_if_index;
67 /** A pool of all the MPLS FIBs */
68 struct fib_table_t_ *fibs;
70 /** A hash table to lookup the mpls_fib by table ID */
71 uword *fib_index_by_table_id;
73 /* Feature arc indices */
74 u8 input_feature_arc_index;
75 u8 output_feature_arc_index;
77 /* IP4 enabled count by software interface */
78 u8 * mpls_enabled_by_sw_if_index;
81 vlib_main_t * vlib_main;
82 vnet_main_t * vnet_main;
85 extern mpls_main_t mpls_main;
87 extern clib_error_t * mpls_feature_init(vlib_main_t * vm);
89 format_function_t format_mpls_eos_bit;
90 format_function_t format_mpls_unicast_header_net_byte_order;
91 format_function_t format_mpls_unicast_label;
92 format_function_t format_mpls_header;
94 extern vlib_node_registration_t mpls_input_node;
95 extern vlib_node_registration_t mpls_output_node;
96 extern vlib_node_registration_t mpls_midchain_node;
98 /* Parse mpls protocol as 0xXXXX or protocol name.
99 In either host or network byte order. */
100 unformat_function_t unformat_mpls_protocol_host_byte_order;
101 unformat_function_t unformat_mpls_protocol_net_byte_order;
102 unformat_function_t unformat_mpls_label_net_byte_order;
103 unformat_function_t unformat_mpls_unicast_label;
105 /* Parse mpls header. */
106 unformat_function_t unformat_mpls_header;
107 unformat_function_t unformat_pg_mpls_header;
109 void mpls_sw_interface_enable_disable (mpls_main_t * mm,
113 u8 mpls_sw_interface_is_enabled (u32 sw_if_index);
115 int mpls_fib_reset_labels (u32 fib_id);
118 mpls_dest_cmp(void * a1, void * a2);
121 mpls_fib_index_cmp(void * a1, void * a2);
124 mpls_label_cmp(void * a1, void * a2);
126 #endif /* included_vnet_mpls_h */