Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
| 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: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 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. |
| 14 | */ |
Neale Ranns | 1357f3b | 2016-10-16 12:01:42 -0700 | [diff] [blame] | 15 | #ifndef included_vnet_mpls_h |
| 16 | #define included_vnet_mpls_h |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 17 | |
| 18 | #include <vnet/vnet.h> |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 19 | #include <vnet/mpls/packet.h> |
| 20 | #include <vnet/mpls/mpls_types.h> |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 21 | #include <vnet/ip/ip4_packet.h> |
| 22 | #include <vnet/ethernet/ethernet.h> |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 23 | #include <vnet/fib/fib_node.h> |
| 24 | #include <vnet/adj/adj.h> |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 25 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 26 | typedef enum { |
| 27 | #define mpls_error(n,s) MPLS_ERROR_##n, |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 28 | #include <vnet/mpls/error.def> |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 29 | #undef mpls_error |
| 30 | MPLS_N_ERROR, |
Neale Ranns | 1357f3b | 2016-10-16 12:01:42 -0700 | [diff] [blame] | 31 | } mpls_error_t; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 32 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 33 | /** |
| 34 | * @brief Definition of a callback for receiving MPLS interface state change |
| 35 | * notifications |
| 36 | */ |
| 37 | typedef void (*mpls_interface_state_change_callback_t)(u32 sw_if_index, |
| 38 | u32 is_enable); |
| 39 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 40 | typedef struct { |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 41 | /* MPLS FIB index for each software interface */ |
| 42 | u32 *fib_index_by_sw_if_index; |
| 43 | |
| 44 | /** A pool of all the MPLS FIBs */ |
| 45 | struct fib_table_t_ *fibs; |
| 46 | |
Neale Ranns | a3af337 | 2017-03-28 03:49:52 -0700 | [diff] [blame] | 47 | /** A pool of all the MPLS FIBs */ |
| 48 | struct mpls_fib_t_ *mpls_fibs; |
| 49 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 50 | /** A hash table to lookup the mpls_fib by table ID */ |
| 51 | uword *fib_index_by_table_id; |
| 52 | |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 53 | /* Feature arc indices */ |
| 54 | u8 input_feature_arc_index; |
| 55 | u8 output_feature_arc_index; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 56 | |
| 57 | /* IP4 enabled count by software interface */ |
| 58 | u8 * mpls_enabled_by_sw_if_index; |
| 59 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 60 | /* convenience */ |
| 61 | vlib_main_t * vlib_main; |
| 62 | vnet_main_t * vnet_main; |
| 63 | } mpls_main_t; |
| 64 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 65 | extern mpls_main_t mpls_main; |
| 66 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 67 | extern clib_error_t * mpls_feature_init(vlib_main_t * vm); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 68 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 69 | format_function_t format_mpls_eos_bit; |
| 70 | format_function_t format_mpls_unicast_header_net_byte_order; |
| 71 | format_function_t format_mpls_unicast_label; |
| 72 | format_function_t format_mpls_header; |
| 73 | |
Jean-Mickael Guerin | 8941ec2 | 2016-03-04 14:14:21 +0100 | [diff] [blame] | 74 | extern vlib_node_registration_t mpls_input_node; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 75 | extern vlib_node_registration_t mpls_output_node; |
| 76 | extern vlib_node_registration_t mpls_midchain_node; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 77 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 78 | /* Parse mpls protocol as 0xXXXX or protocol name. |
| 79 | In either host or network byte order. */ |
| 80 | unformat_function_t unformat_mpls_protocol_host_byte_order; |
| 81 | unformat_function_t unformat_mpls_protocol_net_byte_order; |
| 82 | unformat_function_t unformat_mpls_label_net_byte_order; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 83 | unformat_function_t unformat_mpls_unicast_label; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 84 | |
| 85 | /* Parse mpls header. */ |
| 86 | unformat_function_t unformat_mpls_header; |
| 87 | unformat_function_t unformat_pg_mpls_header; |
| 88 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 89 | void mpls_sw_interface_enable_disable (mpls_main_t * mm, |
| 90 | u32 sw_if_index, |
| 91 | u8 is_enable); |
| 92 | |
| 93 | u8 mpls_sw_interface_is_enabled (u32 sw_if_index); |
| 94 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 95 | int mpls_fib_reset_labels (u32 fib_id); |
| 96 | |
marek zavodsky | 2c21a9a | 2016-06-21 05:35:16 +0200 | [diff] [blame] | 97 | int |
| 98 | mpls_dest_cmp(void * a1, void * a2); |
| 99 | |
| 100 | int |
| 101 | mpls_fib_index_cmp(void * a1, void * a2); |
| 102 | |
| 103 | int |
| 104 | mpls_label_cmp(void * a1, void * a2); |
| 105 | |
Neale Ranns | 1357f3b | 2016-10-16 12:01:42 -0700 | [diff] [blame] | 106 | #endif /* included_vnet_mpls_h */ |