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:
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.
15 #ifndef __included_vnet_flow_report_h__
16 #define __included_vnet_flow_report_h__
18 #include <vlib/vlib.h>
19 #include <vnet/vnet.h>
20 #include <vnet/ethernet/ethernet.h>
21 #include <vnet/ethernet/packet.h>
22 #include <vnet/ip/ip_packet.h>
23 #include <vnet/ip/ip_types.h>
24 #include <vnet/ip/ip4_packet.h>
25 #include <vnet/ip/ip6_packet.h>
26 #include <vnet/udp/udp_packet.h>
28 #include <vppinfra/error.h>
29 #include <vppinfra/hash.h>
30 #include <vppinfra/cache.h>
32 #include <vnet/ipfix-export/ipfix_packet.h>
34 /* ipfix field definitions for a particular report */
39 } ipfix_report_element_t;
41 /* Used to build the rewrite */
46 ipfix_template_packet_t ipfix;
47 } ip4_ipfix_template_packet_t;
49 struct flow_report_main;
51 struct ipfix_exporter;
53 typedef vlib_frame_t *(vnet_flow_data_callback_t) (
54 struct flow_report_main *frm, struct ipfix_exporter *exp,
55 struct flow_report *, vlib_frame_t *, u32 *, u32);
57 typedef u8 *(vnet_flow_rewrite_callback_t) (struct ipfix_exporter *exp,
59 ip4_address_t *, ip4_address_t *,
60 u16, ipfix_report_element_t *elts,
61 u32 n_elts, u32 *stream_index);
63 u8 *vnet_flow_rewrite_generic_callback (struct ipfix_exporter *exp,
64 struct flow_report *, ip4_address_t *,
66 ipfix_report_element_t *elts,
67 u32 n_elts, u32 *stream_index);
82 } flow_report_stream_t;
84 typedef struct flow_report
86 /* ipfix rewrite, set by callback */
90 f64 last_template_sent;
93 /* Bitmap of fields to send */
94 uword *fields_to_send;
99 /* build-the-template-packet rewrite callback */
100 vnet_flow_rewrite_callback_t *rewrite_callback;
101 ipfix_report_element_t *report_elements;
102 u32 n_report_elements;
105 /* Send-flow-data callback */
106 vnet_flow_data_callback_t *flow_data_callback;
110 * The maximum number of ipfix exporters we can have at once
112 #define IPFIX_EXPORTERS_MAX 5
115 * We support multiple exporters. Each one has its own configured
116 * destination, and its own set of reports and streams.
118 typedef struct ipfix_exporter
120 flow_report_t *reports;
121 flow_report_stream_t *streams;
123 /* ipfix collector ip address, port, our ip address, fib index */
124 ip4_address_t ipfix_collector;
126 ip4_address_t src_address;
132 /* time interval in seconds after which to resend templates */
133 u32 template_interval;
135 /* UDP checksum calculation enable flag */
139 typedef struct flow_report_main
142 * A pool of the exporters. Entry 0 is always there for backwards
143 * compatability reasons. Entries 1 and above have to be created by
146 ipfix_exporter_t *exporters;
148 /* time scale transform. Joy. */
152 /* convenience variables */
153 vlib_main_t *vlib_main;
154 vnet_main_t *vnet_main;
157 } flow_report_main_t;
159 extern flow_report_main_t flow_report_main;
161 extern vlib_node_registration_t flow_report_process_node;
165 vnet_flow_data_callback_t *flow_data_callback;
166 vnet_flow_rewrite_callback_t *rewrite_callback;
167 ipfix_report_element_t *report_elements;
168 u32 n_report_elements;
174 } vnet_flow_report_add_del_args_t;
176 int vnet_flow_report_add_del (ipfix_exporter_t *exp,
177 vnet_flow_report_add_del_args_t *a,
180 clib_error_t *flow_report_add_del_error_to_clib_error (int error);
182 void vnet_flow_reports_reset (ipfix_exporter_t *exp);
184 void vnet_stream_reset (ipfix_exporter_t *exp, u32 stream_index);
186 int vnet_stream_change (ipfix_exporter_t *exp, u32 old_domain_id,
187 u16 old_src_port, u32 new_domain_id, u16 new_src_port);
190 * Search all the exporters for one that has a matching destination address.
192 ipfix_exporter_t *vnet_ipfix_exporter_lookup (ip4_address_t *ipfix_collector);
194 #endif /* __included_vnet_flow_report_h__ */
197 * fd.io coding-style-patch-verification: ON
200 * eval: (c-set-style "gnu")