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 | |
Adrian Pistol | ae48ffb | 2023-05-14 00:00:41 +0200 | [diff] [blame] | 26 | struct mpls_main_t; |
| 27 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 28 | /** |
| 29 | * @brief Definition of a callback for receiving MPLS interface state change |
| 30 | * notifications |
| 31 | */ |
Adrian Pistol | ae48ffb | 2023-05-14 00:00:41 +0200 | [diff] [blame] | 32 | typedef void (mpls_interface_state_change_function_t) (struct mpls_main_t *mm, |
| 33 | uword opaque, |
| 34 | u32 sw_if_index, |
| 35 | u32 is_enable); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 36 | |
Adrian Pistol | ae48ffb | 2023-05-14 00:00:41 +0200 | [diff] [blame] | 37 | typedef struct mpls_main_t |
Neale Ranns | 2297af0 | 2017-09-12 09:45:04 -0700 | [diff] [blame] | 38 | { |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 39 | /* MPLS FIB index for each software interface */ |
| 40 | u32 *fib_index_by_sw_if_index; |
| 41 | |
| 42 | /** A pool of all the MPLS FIBs */ |
| 43 | struct fib_table_t_ *fibs; |
| 44 | |
Neale Ranns | a3af337 | 2017-03-28 03:49:52 -0700 | [diff] [blame] | 45 | /** A pool of all the MPLS FIBs */ |
| 46 | struct mpls_fib_t_ *mpls_fibs; |
| 47 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 48 | /** A hash table to lookup the mpls_fib by table ID */ |
| 49 | uword *fib_index_by_table_id; |
| 50 | |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 51 | /* Feature arc indices */ |
| 52 | u8 input_feature_arc_index; |
| 53 | u8 output_feature_arc_index; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 54 | |
| 55 | /* IP4 enabled count by software interface */ |
Neale Ranns | 2297af0 | 2017-09-12 09:45:04 -0700 | [diff] [blame] | 56 | u8 *mpls_enabled_by_sw_if_index; |
Filip Tehlar | 17fcd98 | 2019-03-05 04:32:11 -0800 | [diff] [blame] | 57 | |
| 58 | u32 mpls_lookup_node_index; |
Filip Tehlar | da5088c | 2021-06-22 22:01:19 +0000 | [diff] [blame] | 59 | u16 msg_id_base; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 60 | } mpls_main_t; |
| 61 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 62 | extern mpls_main_t mpls_main; |
| 63 | |
Neale Ranns | 2297af0 | 2017-09-12 09:45:04 -0700 | [diff] [blame] | 64 | extern clib_error_t *mpls_feature_init (vlib_main_t * vm); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 65 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 66 | format_function_t format_mpls_eos_bit; |
| 67 | format_function_t format_mpls_unicast_header_net_byte_order; |
| 68 | format_function_t format_mpls_unicast_label; |
| 69 | format_function_t format_mpls_header; |
| 70 | |
Jean-Mickael Guerin | 8941ec2 | 2016-03-04 14:14:21 +0100 | [diff] [blame] | 71 | extern vlib_node_registration_t mpls_input_node; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 72 | extern vlib_node_registration_t mpls_output_node; |
| 73 | extern vlib_node_registration_t mpls_midchain_node; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 74 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 75 | /* Parse mpls protocol as 0xXXXX or protocol name. |
| 76 | In either host or network byte order. */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 77 | unformat_function_t unformat_mpls_label_net_byte_order; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 78 | unformat_function_t unformat_mpls_unicast_label; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 79 | |
| 80 | /* Parse mpls header. */ |
| 81 | unformat_function_t unformat_mpls_header; |
| 82 | unformat_function_t unformat_pg_mpls_header; |
| 83 | |
Adrian Pistol | ae48ffb | 2023-05-14 00:00:41 +0200 | [diff] [blame] | 84 | u8 mpls_sw_interface_is_enabled (u32 sw_if_index); |
| 85 | |
| 86 | void mpls_interface_state_change_add_callback ( |
| 87 | mpls_interface_state_change_function_t *function, uword opaque); |
| 88 | |
Nathan Skrzypczak | 275bd79 | 2021-09-17 17:29:14 +0200 | [diff] [blame] | 89 | int mpls_sw_interface_enable_disable (mpls_main_t *mm, u32 sw_if_index, |
| 90 | u8 is_enable); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 91 | |
Neale Ranns | 2297af0 | 2017-09-12 09:45:04 -0700 | [diff] [blame] | 92 | int mpls_dest_cmp (void *a1, void *a2); |
marek zavodsky | 2c21a9a | 2016-06-21 05:35:16 +0200 | [diff] [blame] | 93 | |
Neale Ranns | 2297af0 | 2017-09-12 09:45:04 -0700 | [diff] [blame] | 94 | int mpls_fib_index_cmp (void *a1, void *a2); |
marek zavodsky | 2c21a9a | 2016-06-21 05:35:16 +0200 | [diff] [blame] | 95 | |
Neale Ranns | 2297af0 | 2017-09-12 09:45:04 -0700 | [diff] [blame] | 96 | int mpls_label_cmp (void *a1, void *a2); |
marek zavodsky | 2c21a9a | 2016-06-21 05:35:16 +0200 | [diff] [blame] | 97 | |
Neale Ranns | 2297af0 | 2017-09-12 09:45:04 -0700 | [diff] [blame] | 98 | void mpls_table_create (u32 table_id, u8 is_api, const u8 * name); |
| 99 | void mpls_table_delete (u32 table_id, u8 is_api); |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 100 | |
Neale Ranns | 1357f3b | 2016-10-16 12:01:42 -0700 | [diff] [blame] | 101 | #endif /* included_vnet_mpls_h */ |
Neale Ranns | 2297af0 | 2017-09-12 09:45:04 -0700 | [diff] [blame] | 102 | |
| 103 | /* |
| 104 | * fd.io coding-style-patch-verification: ON |
| 105 | * |
| 106 | * Local Variables: |
| 107 | * eval: (c-set-style "gnu") |
| 108 | * End: |
| 109 | */ |