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 #include <ioam/analyse/ioam_analyse.h>
17 #include <ioam/export-common/ioam_export.h>
18 #include <ioam/analyse/ip6/ip6_ioam_analyse.h>
19 #include <ioam/analyse/ioam_summary_export.h>
20 #include <vnet/ip/ip.h>
21 #include <ioam/ipfixcollector/ipfixcollector.h>
23 extern ioam_export_main_t ioam_export_main;
25 ioam_analyse_enable_disable (vlib_main_t * vm,
26 int is_add, int is_export, int remote_listen)
28 ipfix_client_add_del_t ipfix_reg;
31 ipfix_reg.client_name = format (0, "ip6-hbh-analyse-remote");
32 ipfix_reg.client_node = analyse_node_remote.index;
33 ipfix_reg.ipfix_setid = IPFIX_IOAM_EXPORT_ID;
37 rv = ioam_flow_create (!is_add);
44 ip6_ioam_analyse_register_handlers ();
48 ipfix_collector_reg_setid (vm, &ipfix_reg);
52 ioam_export_set_next_node (&ioam_export_main,
53 (u8 *) "ip6-hbh-analyse-local");
58 ip6_ioam_analyse_unregister_handlers ();
62 ipfix_collector_reg_setid (vm, &ipfix_reg);
65 ioam_export_reset_next_node (&ioam_export_main);
69 vec_free (ipfix_reg.client_name);
74 set_ioam_analyse_command_fn (vlib_main_t * vm, unformat_input_t * input,
75 vlib_cli_command_t * cmd)
79 int remote_listen = 0;
81 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
83 if (unformat (input, "export-ipfix-collector"))
85 else if (unformat (input, "disable"))
87 else if (unformat (input, "listen-ipfix"))
93 return (ioam_analyse_enable_disable (vm, is_add, is_export, remote_listen));
97 VLIB_CLI_COMMAND (set_ioam_analyse_command, static) = {
98 .path = "set ioam analyse",
99 .short_help = "set ioam analyse [export-ipfix-collector] [disable] [listen-ipfix]",
100 .function = set_ioam_analyse_command_fn,
104 static clib_error_t *
105 show_ioam_analyse_cmd_fn (vlib_main_t * vm, unformat_input_t * input,
106 vlib_cli_command_t * cmd)
108 ip6_ioam_analyser_main_t *am = &ioam_analyser_main;
109 ioam_analyser_data_t *record = NULL;
113 vec_reset_length (s);
114 s = format (0, "iOAM Analyse Information: \n");
115 vec_foreach_index (i, am->aggregated_data)
117 record = am->aggregated_data + i;
121 s = format (s, "Flow Number: %u\n", i);
122 s = print_analyse_flow (s, record);
123 s = format (s, "\n");
125 vlib_cli_output (vm, "%v", s);
133 VLIB_CLI_COMMAND (ip6_show_ioam_ipfix_cmd, static) = {
134 .path = "show ioam analyse ",
135 .short_help = "show ioam analyser information",
136 .function = show_ioam_analyse_cmd_fn,
140 static clib_error_t *
141 ioam_analyse_init (vlib_main_t * vm)
143 ip6_ioam_analyser_main_t *am = &ioam_analyser_main;
146 vec_validate_aligned (am->aggregated_data, 50, CLIB_CACHE_LINE_BYTES);
147 vec_foreach_index (i, am->aggregated_data)
149 ioam_analyse_init_data (am->aggregated_data + i);
155 VLIB_INIT_FUNCTION (ioam_analyse_init);
158 * fd.io coding-style-patch-verification: ON
161 * eval: (c-set-style "gnu")