blob: cc3eeed035eb5de2f77ad82c13da0011bdf78aa6 [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
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 Ranns1357f3b2016-10-16 12:01:42 -070015#ifndef included_vnet_mpls_h
16#define included_vnet_mpls_h
Ed Warnickecb9cada2015-12-08 15:45:58 -070017
18#include <vnet/vnet.h>
Neale Ranns0bfe5d82016-08-25 15:29:12 +010019#include <vnet/mpls/packet.h>
20#include <vnet/mpls/mpls_types.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070021#include <vnet/ip/ip4_packet.h>
22#include <vnet/ethernet/ethernet.h>
Neale Ranns0bfe5d82016-08-25 15:29:12 +010023#include <vnet/fib/fib_node.h>
24#include <vnet/adj/adj.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070025
Neale Ranns2297af02017-09-12 09:45:04 -070026typedef enum
27{
Ed Warnickecb9cada2015-12-08 15:45:58 -070028#define mpls_error(n,s) MPLS_ERROR_##n,
Neale Ranns0bfe5d82016-08-25 15:29:12 +010029#include <vnet/mpls/error.def>
Ed Warnickecb9cada2015-12-08 15:45:58 -070030#undef mpls_error
31 MPLS_N_ERROR,
Neale Ranns1357f3b2016-10-16 12:01:42 -070032} mpls_error_t;
Ed Warnickecb9cada2015-12-08 15:45:58 -070033
Neale Ranns0bfe5d82016-08-25 15:29:12 +010034/**
35 * @brief Definition of a callback for receiving MPLS interface state change
36 * notifications
37 */
Neale Ranns2297af02017-09-12 09:45:04 -070038typedef void (*mpls_interface_state_change_callback_t) (u32 sw_if_index,
39 u32 is_enable);
Neale Ranns0bfe5d82016-08-25 15:29:12 +010040
Neale Ranns2297af02017-09-12 09:45:04 -070041typedef struct
42{
Neale Ranns0bfe5d82016-08-25 15:29:12 +010043 /* MPLS FIB index for each software interface */
44 u32 *fib_index_by_sw_if_index;
45
46 /** A pool of all the MPLS FIBs */
47 struct fib_table_t_ *fibs;
48
Neale Rannsa3af3372017-03-28 03:49:52 -070049 /** A pool of all the MPLS FIBs */
50 struct mpls_fib_t_ *mpls_fibs;
51
Neale Ranns0bfe5d82016-08-25 15:29:12 +010052 /** A hash table to lookup the mpls_fib by table ID */
53 uword *fib_index_by_table_id;
54
Damjan Marion8b3191e2016-11-09 19:54:20 +010055 /* Feature arc indices */
56 u8 input_feature_arc_index;
57 u8 output_feature_arc_index;
Neale Ranns0bfe5d82016-08-25 15:29:12 +010058
59 /* IP4 enabled count by software interface */
Neale Ranns2297af02017-09-12 09:45:04 -070060 u8 *mpls_enabled_by_sw_if_index;
Ed Warnickecb9cada2015-12-08 15:45:58 -070061} mpls_main_t;
62
Neale Ranns0bfe5d82016-08-25 15:29:12 +010063extern mpls_main_t mpls_main;
64
Neale Ranns2297af02017-09-12 09:45:04 -070065extern clib_error_t *mpls_feature_init (vlib_main_t * vm);
Ed Warnickecb9cada2015-12-08 15:45:58 -070066
Neale Ranns0bfe5d82016-08-25 15:29:12 +010067format_function_t format_mpls_eos_bit;
68format_function_t format_mpls_unicast_header_net_byte_order;
69format_function_t format_mpls_unicast_label;
70format_function_t format_mpls_header;
71
Jean-Mickael Guerin8941ec22016-03-04 14:14:21 +010072extern vlib_node_registration_t mpls_input_node;
Neale Ranns0bfe5d82016-08-25 15:29:12 +010073extern vlib_node_registration_t mpls_output_node;
74extern vlib_node_registration_t mpls_midchain_node;
Ed Warnickecb9cada2015-12-08 15:45:58 -070075
Ed Warnickecb9cada2015-12-08 15:45:58 -070076/* Parse mpls protocol as 0xXXXX or protocol name.
77 In either host or network byte order. */
Ed Warnickecb9cada2015-12-08 15:45:58 -070078unformat_function_t unformat_mpls_label_net_byte_order;
Neale Ranns0bfe5d82016-08-25 15:29:12 +010079unformat_function_t unformat_mpls_unicast_label;
Ed Warnickecb9cada2015-12-08 15:45:58 -070080
81/* Parse mpls header. */
82unformat_function_t unformat_mpls_header;
83unformat_function_t unformat_pg_mpls_header;
84
Neale Ranns15002542017-09-10 04:39:11 -070085int mpls_sw_interface_enable_disable (mpls_main_t * mm,
Neale Ranns2297af02017-09-12 09:45:04 -070086 u32 sw_if_index,
87 u8 is_enable, u8 is_api);
Neale Ranns0bfe5d82016-08-25 15:29:12 +010088
89u8 mpls_sw_interface_is_enabled (u32 sw_if_index);
90
Ed Warnickecb9cada2015-12-08 15:45:58 -070091int mpls_fib_reset_labels (u32 fib_id);
92
Neale Ranns2297af02017-09-12 09:45:04 -070093int mpls_dest_cmp (void *a1, void *a2);
marek zavodsky2c21a9a2016-06-21 05:35:16 +020094
Neale Ranns2297af02017-09-12 09:45:04 -070095int mpls_fib_index_cmp (void *a1, void *a2);
marek zavodsky2c21a9a2016-06-21 05:35:16 +020096
Neale Ranns2297af02017-09-12 09:45:04 -070097int mpls_label_cmp (void *a1, void *a2);
marek zavodsky2c21a9a2016-06-21 05:35:16 +020098
Neale Ranns2297af02017-09-12 09:45:04 -070099void mpls_table_create (u32 table_id, u8 is_api, const u8 * name);
100void mpls_table_delete (u32 table_id, u8 is_api);
Neale Ranns15002542017-09-10 04:39:11 -0700101
Neale Ranns1357f3b2016-10-16 12:01:42 -0700102#endif /* included_vnet_mpls_h */
Neale Ranns2297af02017-09-12 09:45:04 -0700103
104/*
105 * fd.io coding-style-patch-verification: ON
106 *
107 * Local Variables:
108 * eval: (c-set-style "gnu")
109 * End:
110 */