mpls: Use the .api for the definition of error/info counters
[vpp.git] / src / vnet / mpls / mpls.h
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  */
15 #ifndef included_vnet_mpls_h
16 #define included_vnet_mpls_h
17
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>
25
26 /**
27  * @brief Definition of a callback for receiving MPLS interface state change
28  * notifications
29  */
30 typedef void (*mpls_interface_state_change_callback_t) (u32 sw_if_index,
31                                                         u32 is_enable);
32
33 typedef struct
34 {
35   /* MPLS FIB index for each software interface */
36   u32 *fib_index_by_sw_if_index;
37
38   /**  A pool of all the MPLS FIBs */
39   struct fib_table_t_ *fibs;
40
41   /**  A pool of all the MPLS FIBs */
42   struct mpls_fib_t_ *mpls_fibs;
43
44   /** A hash table to lookup the mpls_fib by table ID */
45   uword *fib_index_by_table_id;
46
47   /* Feature arc indices */
48   u8 input_feature_arc_index;
49   u8 output_feature_arc_index;
50
51   /* IP4 enabled count by software interface */
52   u8 *mpls_enabled_by_sw_if_index;
53
54   u32 mpls_lookup_node_index;
55   u16 msg_id_base;
56 } mpls_main_t;
57
58 extern mpls_main_t mpls_main;
59
60 extern clib_error_t *mpls_feature_init (vlib_main_t * vm);
61
62 format_function_t format_mpls_eos_bit;
63 format_function_t format_mpls_unicast_header_net_byte_order;
64 format_function_t format_mpls_unicast_label;
65 format_function_t format_mpls_header;
66
67 extern vlib_node_registration_t mpls_input_node;
68 extern vlib_node_registration_t mpls_output_node;
69 extern vlib_node_registration_t mpls_midchain_node;
70
71 /* Parse mpls protocol as 0xXXXX or protocol name.
72    In either host or network byte order. */
73 unformat_function_t unformat_mpls_label_net_byte_order;
74 unformat_function_t unformat_mpls_unicast_label;
75
76 /* Parse mpls header. */
77 unformat_function_t unformat_mpls_header;
78 unformat_function_t unformat_pg_mpls_header;
79
80 int mpls_sw_interface_enable_disable (mpls_main_t *mm, u32 sw_if_index,
81                                       u8 is_enable);
82
83 u8 mpls_sw_interface_is_enabled (u32 sw_if_index);
84
85 int mpls_dest_cmp (void *a1, void *a2);
86
87 int mpls_fib_index_cmp (void *a1, void *a2);
88
89 int mpls_label_cmp (void *a1, void *a2);
90
91 void mpls_table_create (u32 table_id, u8 is_api, const u8 * name);
92 void mpls_table_delete (u32 table_id, u8 is_api);
93
94 #endif /* included_vnet_mpls_h */
95
96 /*
97  * fd.io coding-style-patch-verification: ON
98  *
99  * Local Variables:
100  * eval: (c-set-style "gnu")
101  * End:
102  */