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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef PLUGINS_IOAM_PLUGIN_IOAM_ANALYSE_IP6_IOAM_ANALYSE_NODE_H_
17 #define PLUGINS_IOAM_PLUGIN_IOAM_ANALYSE_IP6_IOAM_ANALYSE_NODE_H_
19 #include <ioam/analyse/ioam_analyse.h>
20 #include <vnet/ip/ip6_hop_by_hop.h>
21 #include <ioam/encap/ip6_ioam_trace.h>
23 /** @brief IP6-iOAM analyser main structure.
28 /** Array of function pointer to analyse each hop-by-hop option. */
29 int (*analyse_hbh_handler[MAX_IP6_HBH_OPTION]) (u32 flow_id,
30 ip6_hop_by_hop_option_t *
33 /** This contains the aggregated data from the time VPP started analysing. */
34 ioam_analyser_data_t *aggregated_data;
36 } ip6_ioam_analyser_main_t;
38 extern ip6_ioam_analyser_main_t ioam_analyser_main;
40 extern vlib_node_registration_t analyse_node_local;
41 extern vlib_node_registration_t analyse_node_remote;
43 void ip6_ioam_analyse_register_handlers (void);
45 void ip6_ioam_analyse_unregister_handlers (void);
47 clib_error_t *ip6_ioam_analyse_init (vlib_main_t * vm);
49 inline static ioam_analyser_data_t *
50 ioam_analyse_get_data_from_flow_id (u32 flow_id)
52 if (flow_id >= vec_len (ioam_analyser_main.aggregated_data))
55 if (ioam_analyser_main.aggregated_data[flow_id].is_free)
56 ioam_analyser_main.aggregated_data[flow_id].is_free = 0;
58 return (ioam_analyser_main.aggregated_data + flow_id);
62 ip6_ioam_find_hbh_option (ip6_hop_by_hop_header_t * hbh0, u8 option)
64 ip6_hop_by_hop_option_t *opt0, *limit0;
67 opt0 = (ip6_hop_by_hop_option_t *) (hbh0 + 1);
69 (ip6_hop_by_hop_option_t *) ((u8 *) hbh0 + ((hbh0->length + 1) << 3));
75 return ((void *) opt0);
79 opt0 = (ip6_hop_by_hop_option_t *) ((u8 *) opt0) + 1;
82 opt0 = (ip6_hop_by_hop_option_t *)
83 (((u8 *) opt0) + opt0->length + sizeof (ip6_hop_by_hop_option_t));
90 ip6_ioam_analyse_compare_path_delay (ip6_hop_by_hop_header_t * hbh0,
91 ip6_hop_by_hop_header_t * hbh1,
94 ioam_trace_option_t *trace0 = NULL, *trace1 = NULL;
98 ip6_ioam_find_hbh_option (hbh0, HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST);
100 ip6_ioam_find_hbh_option (hbh1, HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST);
102 if (PREDICT_FALSE ((trace0 == NULL) && (trace1 == NULL)))
105 if (PREDICT_FALSE (trace1 == NULL))
108 if (PREDICT_FALSE (trace0 == NULL))
111 delay0 = ip6_ioam_analyse_calc_delay (&trace0->trace_hdr,
112 trace0->hdr.length - 2, oneway);
113 delay1 = ip6_ioam_analyse_calc_delay (&trace1->trace_hdr,
114 trace1->hdr.length - 2, oneway);
116 return (delay0 - delay1);
119 #endif /* PLUGINS_IOAM_PLUGIN_IOAM_ANALYSE_IP6_IOAM_ANALYSE_NODE_H_ */
122 * fd.io coding-style-patch-verification: ON
125 * eval: (c-set-style "gnu")