blob: 47e1d1103a2fb397906fea02a25d724b8b2b9c91 [file] [log] [blame]
Pavel Kotucekeb9e6662017-01-24 13:40:26 +01001/*
2 *------------------------------------------------------------------
3 * flow_api.c - flow api
4 *
5 * Copyright (c) 2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
18 */
19
20#include <vnet/vnet.h>
21#include <vlibmemory/api.h>
Jakub Grajciar2f71a882019-10-10 14:21:22 +020022#include <vnet/ip/ip_types_api.h>
Florin Corasb040f982020-10-20 14:59:43 -070023#include <vnet/udp/udp_local.h>
Pavel Kotucekeb9e6662017-01-24 13:40:26 +010024
25#include <vnet/interface.h>
26#include <vnet/api_errno.h>
27
28#include <vnet/fib/fib_table.h>
Ole Troana9855ef2018-05-02 12:45:10 +020029#include <vnet/ipfix-export/flow_report.h>
30#include <vnet/ipfix-export/flow_report_classify.h>
Pavel Kotucekeb9e6662017-01-24 13:40:26 +010031
Filip Tehlar53dea272021-06-21 10:57:49 +000032#include <vnet/format_fns.h>
33#include <vnet/ipfix-export/ipfix_export.api_enum.h>
34#include <vnet/ipfix-export/ipfix_export.api_types.h>
Pavel Kotucekeb9e6662017-01-24 13:40:26 +010035
Filip Tehlar53dea272021-06-21 10:57:49 +000036#define REPLY_MSG_ID_BASE frm->msg_id_base
Pavel Kotucekeb9e6662017-01-24 13:40:26 +010037#include <vlibapi/api_helper_macros.h>
38
Paul Atkinsd747dd92021-09-22 14:56:17 +010039ipfix_exporter_t *
40vnet_ipfix_exporter_lookup (ip4_address_t *ipfix_collector)
41{
42 flow_report_main_t *frm = &flow_report_main;
43 ipfix_exporter_t *exp;
44
45 pool_foreach (exp, frm->exporters)
46 {
47 if (exp->ipfix_collector.as_u32 == ipfix_collector->as_u32)
48 return exp;
49 }
50
51 return NULL;
52}
53
54/*
55 * For backwards compatibility reasons index 0 in the set of exporters
56 * is alwyas used for the exporter created via the set_ipfix_exporter
57 * API.
58 */
59#define USE_INDEX_0 true
60#define USE_ANY_INDEX false
61
Paul Atkinsa6e131e2021-09-22 14:18:45 +010062static int
63vl_api_set_ipfix_exporter_t_internal (
64 u32 client_index, vl_api_address_t *mp_collector_address,
65 u16 mp_collector_port, vl_api_address_t *mp_src_address, u32 mp_vrf_id,
Paul Atkinsd747dd92021-09-22 14:56:17 +010066 u32 mp_path_mtu, u32 mp_template_interval, bool mp_udp_checksum,
67 bool use_index_0, bool is_create)
Pavel Kotucekeb9e6662017-01-24 13:40:26 +010068{
69 vlib_main_t *vm = vlib_get_main ();
70 flow_report_main_t *frm = &flow_report_main;
Paul Atkinsd747dd92021-09-22 14:56:17 +010071 ipfix_exporter_t *exp;
Paul Vinciguerra21b83e92019-06-24 09:55:46 -040072 vl_api_registration_t *reg;
Pavel Kotucekeb9e6662017-01-24 13:40:26 +010073 ip4_address_t collector, src;
74 u16 collector_port = UDP_DST_PORT_ipfix;
75 u32 path_mtu;
76 u32 template_interval;
77 u8 udp_checksum;
78 u32 fib_id;
79 u32 fib_index = ~0;
Pavel Kotucekeb9e6662017-01-24 13:40:26 +010080
Paul Atkinsa6e131e2021-09-22 14:18:45 +010081 reg = vl_api_client_index_to_registration (client_index);
Paul Vinciguerra21b83e92019-06-24 09:55:46 -040082 if (!reg)
Paul Atkinsa6e131e2021-09-22 14:18:45 +010083 return VNET_API_ERROR_UNIMPLEMENTED;
Paul Vinciguerra21b83e92019-06-24 09:55:46 -040084
Paul Atkinsd747dd92021-09-22 14:56:17 +010085 /* Collector address is the key for the exporter lookup */
86 ip4_address_decode (mp_collector_address->un.ip4, &collector);
87
88 if (use_index_0)
89 /*
90 * In this case we update the existing exporter. There is no delete
91 * for exp[0]
92 */
93 exp = &frm->exporters[0];
94 else
95 {
96 if (is_create)
97 {
98 exp = vnet_ipfix_exporter_lookup (&collector);
99 if (!exp)
100 {
101 /* Create a new exporter instead of updating an existing one */
102 if (pool_elts (frm->exporters) >= IPFIX_EXPORTERS_MAX)
103 return VNET_API_ERROR_INVALID_VALUE;
104 pool_get (frm->exporters, exp);
105 if (!exp)
106 return VNET_API_ERROR_INVALID_VALUE;
107 }
108 }
109 else
110 {
111 /* Delete the exporter */
112 exp = vnet_ipfix_exporter_lookup (&collector);
113 if (!exp)
114 return VNET_API_ERROR_NO_SUCH_ENTRY;
115
116 pool_put (frm->exporters, exp);
117 return 0;
118 }
119 }
120
Paul Atkinsa6e131e2021-09-22 14:18:45 +0100121 if (mp_src_address->af == ADDRESS_IP6 ||
122 mp_collector_address->af == ADDRESS_IP6)
Jakub Grajciar2f71a882019-10-10 14:21:22 +0200123 {
Paul Atkinsa6e131e2021-09-22 14:18:45 +0100124 return VNET_API_ERROR_UNIMPLEMENTED;
Jakub Grajciar2f71a882019-10-10 14:21:22 +0200125 }
126
Paul Atkinsa6e131e2021-09-22 14:18:45 +0100127 collector_port = ntohs (mp_collector_port);
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100128 if (collector_port == (u16) ~ 0)
129 collector_port = UDP_DST_PORT_ipfix;
Paul Atkinsa6e131e2021-09-22 14:18:45 +0100130 ip4_address_decode (mp_src_address->un.ip4, &src);
131 fib_id = ntohl (mp_vrf_id);
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100132
133 ip4_main_t *im = &ip4_main;
134 if (fib_id == ~0)
135 {
136 fib_index = ~0;
137 }
138 else
139 {
140 uword *p = hash_get (im->fib_index_by_table_id, fib_id);
141 if (!p)
Paul Atkinsa6e131e2021-09-22 14:18:45 +0100142 return VNET_API_ERROR_NO_SUCH_FIB;
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100143 fib_index = p[0];
144 }
145
Paul Atkinsa6e131e2021-09-22 14:18:45 +0100146 path_mtu = ntohl (mp_path_mtu);
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100147 if (path_mtu == ~0)
148 path_mtu = 512; // RFC 7011 section 10.3.3.
Paul Atkinsa6e131e2021-09-22 14:18:45 +0100149 template_interval = ntohl (mp_template_interval);
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100150 if (template_interval == ~0)
151 template_interval = 20;
Paul Atkinsa6e131e2021-09-22 14:18:45 +0100152 udp_checksum = mp_udp_checksum;
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100153
Alexander Chernavin67ec7522020-10-01 08:57:59 -0400154 if (collector.as_u32 != 0 && src.as_u32 == 0)
Paul Atkinsa6e131e2021-09-22 14:18:45 +0100155 return VNET_API_ERROR_INVALID_VALUE;
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100156
157 if (path_mtu > 1450 /* vpp does not support fragmentation */ )
Paul Atkinsa6e131e2021-09-22 14:18:45 +0100158 return VNET_API_ERROR_INVALID_VALUE;
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100159
160 if (path_mtu < 68)
Paul Atkinsa6e131e2021-09-22 14:18:45 +0100161 return VNET_API_ERROR_INVALID_VALUE;
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100162
163 /* Reset report streams if we are reconfiguring IP addresses */
Paul Atkins9ec64492021-09-21 20:49:12 +0100164 if (exp->ipfix_collector.as_u32 != collector.as_u32 ||
165 exp->src_address.as_u32 != src.as_u32 ||
166 exp->collector_port != collector_port)
Paul Atkins40f9a7a2021-09-22 10:06:23 +0100167 vnet_flow_reports_reset (exp);
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100168
Paul Atkins9ec64492021-09-21 20:49:12 +0100169 exp->ipfix_collector.as_u32 = collector.as_u32;
170 exp->collector_port = collector_port;
171 exp->src_address.as_u32 = src.as_u32;
172 exp->fib_index = fib_index;
173 exp->path_mtu = path_mtu;
174 exp->template_interval = template_interval;
175 exp->udp_checksum = udp_checksum;
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100176
177 /* Turn on the flow reporting process */
178 vlib_process_signal_event (vm, flow_report_process_node.index, 1, 0);
179
Paul Atkinsa6e131e2021-09-22 14:18:45 +0100180 return 0;
181}
182
183static void
184vl_api_set_ipfix_exporter_t_handler (vl_api_set_ipfix_exporter_t *mp)
185{
186 vl_api_set_ipfix_exporter_reply_t *rmp;
187 flow_report_main_t *frm = &flow_report_main;
188 int rv = vl_api_set_ipfix_exporter_t_internal (
189 mp->client_index, &mp->collector_address, mp->collector_port,
190 &mp->src_address, mp->vrf_id, mp->path_mtu, mp->template_interval,
Paul Atkinsd747dd92021-09-22 14:56:17 +0100191 mp->udp_checksum, USE_INDEX_0, 0);
Paul Atkinsa6e131e2021-09-22 14:18:45 +0100192
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100193 REPLY_MACRO (VL_API_SET_IPFIX_EXPORTER_REPLY);
194}
195
196static void
Paul Atkinsd747dd92021-09-22 14:56:17 +0100197vl_api_ipfix_exporter_create_delete_t_handler (
198 vl_api_ipfix_exporter_create_delete_t *mp)
199{
200 vl_api_ipfix_exporter_create_delete_reply_t *rmp;
201 flow_report_main_t *frm = &flow_report_main;
202 int rv = vl_api_set_ipfix_exporter_t_internal (
203 mp->client_index, &mp->collector_address, mp->collector_port,
204 &mp->src_address, mp->vrf_id, mp->path_mtu, mp->template_interval,
205 mp->udp_checksum, USE_ANY_INDEX, mp->is_create);
206
207 REPLY_MACRO (VL_API_IPFIX_EXPORTER_CREATE_DELETE_REPLY);
208}
209
210static void
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100211vl_api_ipfix_exporter_dump_t_handler (vl_api_ipfix_exporter_dump_t * mp)
212{
213 flow_report_main_t *frm = &flow_report_main;
Paul Atkins9ec64492021-09-21 20:49:12 +0100214 ipfix_exporter_t *exp = pool_elt_at_index (flow_report_main.exporters, 0);
Florin Coras6c4dae22018-01-09 06:39:23 -0800215 vl_api_registration_t *reg;
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100216 vl_api_ipfix_exporter_details_t *rmp;
217 ip4_main_t *im = &ip4_main;
Jakub Grajciar2f71a882019-10-10 14:21:22 +0200218 ip46_address_t collector = {.as_u64[0] = 0,.as_u64[1] = 0 };
219 ip46_address_t src = {.as_u64[0] = 0,.as_u64[1] = 0 };
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100220 u32 vrf_id;
221
Florin Coras6c4dae22018-01-09 06:39:23 -0800222 reg = vl_api_client_index_to_registration (mp->client_index);
223 if (!reg)
Paul Vinciguerra21b83e92019-06-24 09:55:46 -0400224 return;
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100225
226 rmp = vl_msg_api_alloc (sizeof (*rmp));
Dave Barachb7b92992018-10-17 10:38:51 -0400227 clib_memset (rmp, 0, sizeof (*rmp));
Paul Atkins5df0b342021-09-23 10:55:25 +0100228 rmp->_vl_msg_id =
229 ntohs ((REPLY_MSG_ID_BASE) + VL_API_IPFIX_EXPORTER_DETAILS);
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100230 rmp->context = mp->context;
Jakub Grajciar2f71a882019-10-10 14:21:22 +0200231
Paul Atkins9ec64492021-09-21 20:49:12 +0100232 memcpy (&collector.ip4, &exp->ipfix_collector, sizeof (ip4_address_t));
Jakub Grajciar2f71a882019-10-10 14:21:22 +0200233 ip_address_encode (&collector, IP46_TYPE_IP4, &rmp->collector_address);
234
Paul Atkins9ec64492021-09-21 20:49:12 +0100235 rmp->collector_port = htons (exp->collector_port);
Jakub Grajciar2f71a882019-10-10 14:21:22 +0200236
Paul Atkins9ec64492021-09-21 20:49:12 +0100237 memcpy (&src.ip4, &exp->src_address, sizeof (ip4_address_t));
Jakub Grajciar2f71a882019-10-10 14:21:22 +0200238 ip_address_encode (&src, IP46_TYPE_IP4, &rmp->src_address);
239
Paul Atkins9ec64492021-09-21 20:49:12 +0100240 if (exp->fib_index == ~0)
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100241 vrf_id = ~0;
242 else
Paul Atkins9ec64492021-09-21 20:49:12 +0100243 vrf_id = im->fibs[exp->fib_index].ft_table_id;
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100244 rmp->vrf_id = htonl (vrf_id);
Paul Atkins9ec64492021-09-21 20:49:12 +0100245 rmp->path_mtu = htonl (exp->path_mtu);
246 rmp->template_interval = htonl (exp->template_interval);
247 rmp->udp_checksum = (exp->udp_checksum != 0);
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100248
Florin Coras6c4dae22018-01-09 06:39:23 -0800249 vl_api_send_msg (reg, (u8 *) rmp);
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100250}
251
252static void
253 vl_api_set_ipfix_classify_stream_t_handler
254 (vl_api_set_ipfix_classify_stream_t * mp)
255{
256 vl_api_set_ipfix_classify_stream_reply_t *rmp;
257 flow_report_classify_main_t *fcm = &flow_report_classify_main;
258 flow_report_main_t *frm = &flow_report_main;
Paul Atkins40f9a7a2021-09-22 10:06:23 +0100259 ipfix_exporter_t *exp = &frm->exporters[0];
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100260 u32 domain_id = 0;
261 u32 src_port = UDP_DST_PORT_ipfix;
262 int rv = 0;
263
264 domain_id = ntohl (mp->domain_id);
265 src_port = ntohs (mp->src_port);
266
267 if (fcm->src_port != 0 &&
268 (fcm->domain_id != domain_id || fcm->src_port != (u16) src_port))
269 {
Paul Atkins40f9a7a2021-09-22 10:06:23 +0100270 int rv = vnet_stream_change (exp, fcm->domain_id, fcm->src_port,
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100271 domain_id, (u16) src_port);
272 ASSERT (rv == 0);
273 }
274
275 fcm->domain_id = domain_id;
276 fcm->src_port = (u16) src_port;
277
278 REPLY_MACRO (VL_API_SET_IPFIX_CLASSIFY_STREAM_REPLY);
279}
280
281static void
282 vl_api_ipfix_classify_stream_dump_t_handler
283 (vl_api_ipfix_classify_stream_dump_t * mp)
284{
285 flow_report_classify_main_t *fcm = &flow_report_classify_main;
Florin Coras6c4dae22018-01-09 06:39:23 -0800286 vl_api_registration_t *reg;
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100287 vl_api_ipfix_classify_stream_details_t *rmp;
288
Florin Coras6c4dae22018-01-09 06:39:23 -0800289 reg = vl_api_client_index_to_registration (mp->client_index);
290 if (!reg)
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100291 return;
292
293 rmp = vl_msg_api_alloc (sizeof (*rmp));
Dave Barachb7b92992018-10-17 10:38:51 -0400294 clib_memset (rmp, 0, sizeof (*rmp));
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100295 rmp->_vl_msg_id = ntohs (VL_API_IPFIX_CLASSIFY_STREAM_DETAILS);
296 rmp->context = mp->context;
297 rmp->domain_id = htonl (fcm->domain_id);
298 rmp->src_port = htons (fcm->src_port);
299
Florin Coras6c4dae22018-01-09 06:39:23 -0800300 vl_api_send_msg (reg, (u8 *) rmp);
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100301}
302
303static void
304 vl_api_ipfix_classify_table_add_del_t_handler
305 (vl_api_ipfix_classify_table_add_del_t * mp)
306{
307 vl_api_ipfix_classify_table_add_del_reply_t *rmp;
Paul Vinciguerra21b83e92019-06-24 09:55:46 -0400308 vl_api_registration_t *reg;
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100309 flow_report_classify_main_t *fcm = &flow_report_classify_main;
310 flow_report_main_t *frm = &flow_report_main;
Paul Atkins40f9a7a2021-09-22 10:06:23 +0100311 ipfix_exporter_t *exp = &frm->exporters[0];
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100312 vnet_flow_report_add_del_args_t args;
313 ipfix_classify_table_t *table;
314 int is_add;
315 u32 classify_table_index;
316 u8 ip_version;
317 u8 transport_protocol;
318 int rv = 0;
319
Paul Vinciguerra21b83e92019-06-24 09:55:46 -0400320 reg = vl_api_client_index_to_registration (mp->client_index);
321 if (!reg)
322 return;
323
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100324 classify_table_index = ntohl (mp->table_id);
Alexander Chernavinf6cf57c2020-09-30 10:36:10 -0400325 ip_version = (mp->ip_version == ADDRESS_IP4) ? 4 : 6;
326 transport_protocol = mp->transport_protocol;
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100327 is_add = mp->is_add;
328
329 if (fcm->src_port == 0)
330 {
331 /* call set_ipfix_classify_stream first */
332 rv = VNET_API_ERROR_UNSPECIFIED;
333 goto out;
334 }
335
Dave Barachb7b92992018-10-17 10:38:51 -0400336 clib_memset (&args, 0, sizeof (args));
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100337
338 table = 0;
339 int i;
340 for (i = 0; i < vec_len (fcm->tables); i++)
341 if (ipfix_classify_table_index_valid (i))
342 if (fcm->tables[i].classify_table_index == classify_table_index)
343 {
344 table = &fcm->tables[i];
345 break;
346 }
347
348 if (is_add)
349 {
350 if (table)
351 {
352 rv = VNET_API_ERROR_VALUE_EXIST;
353 goto out;
354 }
355 table = ipfix_classify_add_table ();
356 table->classify_table_index = classify_table_index;
357 }
358 else
359 {
360 if (!table)
361 {
362 rv = VNET_API_ERROR_NO_SUCH_ENTRY;
363 goto out;
364 }
365 }
366
367 table->ip_version = ip_version;
368 table->transport_protocol = transport_protocol;
369
370 args.opaque.as_uword = table - fcm->tables;
371 args.rewrite_callback = ipfix_classify_template_rewrite;
372 args.flow_data_callback = ipfix_classify_send_flows;
373 args.is_add = is_add;
374 args.domain_id = fcm->domain_id;
375 args.src_port = fcm->src_port;
376
Paul Atkins40f9a7a2021-09-22 10:06:23 +0100377 rv = vnet_flow_report_add_del (exp, &args, NULL);
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100378
379 /* If deleting, or add failed */
380 if (is_add == 0 || (rv && is_add))
381 ipfix_classify_delete_table (table - fcm->tables);
382
383out:
384 REPLY_MACRO (VL_API_SET_IPFIX_CLASSIFY_STREAM_REPLY);
385}
386
387static void
388send_ipfix_classify_table_details (u32 table_index,
Florin Coras6c4dae22018-01-09 06:39:23 -0800389 vl_api_registration_t * reg, u32 context)
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100390{
391 flow_report_classify_main_t *fcm = &flow_report_classify_main;
392 vl_api_ipfix_classify_table_details_t *mp;
393
394 ipfix_classify_table_t *table = &fcm->tables[table_index];
395
396 mp = vl_msg_api_alloc (sizeof (*mp));
Dave Barachb7b92992018-10-17 10:38:51 -0400397 clib_memset (mp, 0, sizeof (*mp));
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100398 mp->_vl_msg_id = ntohs (VL_API_IPFIX_CLASSIFY_TABLE_DETAILS);
399 mp->context = context;
400 mp->table_id = htonl (table->classify_table_index);
Alexander Chernavinf6cf57c2020-09-30 10:36:10 -0400401 mp->ip_version = (table->ip_version == 4) ? ADDRESS_IP4 : ADDRESS_IP6;
402 mp->transport_protocol = table->transport_protocol;
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100403
Florin Coras6c4dae22018-01-09 06:39:23 -0800404 vl_api_send_msg (reg, (u8 *) mp);
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100405}
406
407static void
408 vl_api_ipfix_classify_table_dump_t_handler
409 (vl_api_ipfix_classify_table_dump_t * mp)
410{
411 flow_report_classify_main_t *fcm = &flow_report_classify_main;
Florin Coras6c4dae22018-01-09 06:39:23 -0800412 vl_api_registration_t *reg;
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100413 u32 i;
414
Florin Coras6c4dae22018-01-09 06:39:23 -0800415 reg = vl_api_client_index_to_registration (mp->client_index);
416 if (!reg)
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100417 return;
418
419 for (i = 0; i < vec_len (fcm->tables); i++)
420 if (ipfix_classify_table_index_valid (i))
Florin Coras6c4dae22018-01-09 06:39:23 -0800421 send_ipfix_classify_table_details (i, reg, mp->context);
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100422}
423
Paul Vinciguerra21b83e92019-06-24 09:55:46 -0400424static void
425vl_api_ipfix_flush_t_handler (vl_api_ipfix_flush_t * mp)
426{
Filip Tehlar53dea272021-06-21 10:57:49 +0000427 flow_report_main_t *frm = &flow_report_main;
Paul Vinciguerra21b83e92019-06-24 09:55:46 -0400428 vl_api_ipfix_flush_reply_t *rmp;
429 vl_api_registration_t *reg;
430 vlib_main_t *vm = vlib_get_main ();
431 int rv = 0;
432
433 reg = vl_api_client_index_to_registration (mp->client_index);
434 if (!reg)
435 return;
436
437 /* poke the flow reporting process */
438 vlib_process_signal_event (vm, flow_report_process_node.index,
439 1 /* type_opaque */ , 0 /* data */ );
440
441 REPLY_MACRO (VL_API_IPFIX_FLUSH_REPLY);
442}
443
Filip Tehlar53dea272021-06-21 10:57:49 +0000444#include <vnet/ipfix-export/ipfix_export.api.c>
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100445static clib_error_t *
446flow_api_hookup (vlib_main_t * vm)
447{
Filip Tehlar53dea272021-06-21 10:57:49 +0000448 flow_report_main_t *frm = &flow_report_main;
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100449 /*
450 * Set up the (msg_name, crc, message-id) table
451 */
Filip Tehlar53dea272021-06-21 10:57:49 +0000452 REPLY_MSG_ID_BASE = setup_message_id_table ();
Pavel Kotucekeb9e6662017-01-24 13:40:26 +0100453
454 return 0;
455}
456
457VLIB_API_INIT_FUNCTION (flow_api_hookup);
458
459/*
460 * fd.io coding-style-patch-verification: ON
461 *
462 * Local Variables:
463 * eval: (c-set-style "gnu")
464 * End:
465 */