VPP-632 : InBand OAM Analyser
[vpp.git] / src / plugins / ioam / analyse / ip6 / ip6_ioam_analyse.h
1 /*
2  * Copyright (c) 2017 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
16 #ifndef PLUGINS_IOAM_PLUGIN_IOAM_ANALYSE_IP6_IOAM_ANALYSE_NODE_H_
17 #define PLUGINS_IOAM_PLUGIN_IOAM_ANALYSE_IP6_IOAM_ANALYSE_NODE_H_
18
19 #include <ioam/analyse/ioam_analyse.h>
20 #include <vnet/ip/ip6_hop_by_hop.h>
21
22 /** @brief IP6-iOAM analyser main structure.
23     @note cache aligned.
24 */
25 typedef struct
26 {
27   /** Array of function pointer to analyse each hop-by-hop option. */
28   int (*analyse_hbh_handler[MAX_IP6_HBH_OPTION]) (u32 flow_id,
29                                                   ip6_hop_by_hop_option_t *
30                                                   opt, u16 len);
31
32   /** This contains the aggregated data from the time VPP started analysing. */
33   ioam_analyser_data_t *aggregated_data;
34
35 } ip6_ioam_analyser_main_t;
36
37 extern ip6_ioam_analyser_main_t ioam_analyser_main;
38
39 extern vlib_node_registration_t analyse_node_local;
40 extern vlib_node_registration_t analyse_node_remote;
41
42 void ip6_ioam_analyse_register_handlers (void);
43
44 void ip6_ioam_analyse_unregister_handlers (void);
45
46 clib_error_t *ip6_ioam_analyse_init (vlib_main_t * vm);
47
48 inline static ioam_analyser_data_t *
49 ioam_analyse_get_data_from_flow_id (u32 flow_id)
50 {
51   if (flow_id >= vec_len (ioam_analyser_main.aggregated_data))
52     return NULL;
53
54   if (ioam_analyser_main.aggregated_data[flow_id].is_free)
55     ioam_analyser_main.aggregated_data[flow_id].is_free = 0;
56
57   return (ioam_analyser_main.aggregated_data + flow_id);
58 }
59
60 #endif /* PLUGINS_IOAM_PLUGIN_IOAM_ANALYSE_IP6_IOAM_ANALYSE_NODE_H_ */
61
62 /*
63  * fd.io coding-style-patch-verification: ON
64  *
65  * Local Variables:
66  * eval: (c-set-style "gnu")
67  * End:
68  */