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/ip4_packet.h>
24 #include <vnet/ip/ip6_packet.h>
25 #include <vnet/udp/udp_packet.h>
27 #include <vppinfra/error.h>
28 #include <vppinfra/hash.h>
29 #include <vppinfra/cache.h>
31 #include <vnet/ipfix-export/ipfix_packet.h>
33 /* ipfix field definitions for a particular report */
38 } ipfix_report_element_t;
40 /* Used to build the rewrite */
45 ipfix_template_packet_t ipfix;
46 } ip4_ipfix_template_packet_t;
48 struct flow_report_main;
50 struct ipfix_exporter;
52 typedef vlib_frame_t *(vnet_flow_data_callback_t) (
53 struct flow_report_main *frm, struct ipfix_exporter *exp,
54 struct flow_report *, vlib_frame_t *, u32 *, u32);
56 typedef u8 *(vnet_flow_rewrite_callback_t) (struct ipfix_exporter *exp,
58 ip4_address_t *, ip4_address_t *,
59 u16, ipfix_report_element_t *elts,
60 u32 n_elts, u32 *stream_index);
62 u8 *vnet_flow_rewrite_generic_callback (struct ipfix_exporter *exp,
63 struct flow_report *, ip4_address_t *,
65 ipfix_report_element_t *elts,
66 u32 n_elts, u32 *stream_index);
81 } flow_report_stream_t;
83 typedef struct flow_report
85 /* ipfix rewrite, set by callback */
89 f64 last_template_sent;
92 /* Bitmap of fields to send */
93 uword *fields_to_send;
98 /* build-the-template-packet rewrite callback */
99 vnet_flow_rewrite_callback_t *rewrite_callback;
100 ipfix_report_element_t *report_elements;
101 u32 n_report_elements;
104 /* Send-flow-data callback */
105 vnet_flow_data_callback_t *flow_data_callback;
109 * The maximum number of ipfix exporters we can have at once
111 #define IPFIX_EXPORTERS_MAX 5
114 * We support multiple exporters. Each one has its own configured
115 * destination, and its own set of reports and streams.
117 typedef struct ipfix_exporter
119 flow_report_t *reports;
120 flow_report_stream_t *streams;
122 /* ipfix collector ip address, port, our ip address, fib index */
123 ip4_address_t ipfix_collector;
125 ip4_address_t src_address;
131 /* time interval in seconds after which to resend templates */
132 u32 template_interval;
134 /* UDP checksum calculation enable flag */
138 typedef struct flow_report_main
141 * A pool of the exporters. Entry 0 is always there for backwards
142 * compatability reasons. Entries 1 and above have to be created by
145 ipfix_exporter_t *exporters;
147 /* time scale transform. Joy. */
151 /* convenience variables */
152 vlib_main_t *vlib_main;
153 vnet_main_t *vnet_main;
156 } flow_report_main_t;
158 extern flow_report_main_t flow_report_main;
160 extern vlib_node_registration_t flow_report_process_node;
164 vnet_flow_data_callback_t *flow_data_callback;
165 vnet_flow_rewrite_callback_t *rewrite_callback;
166 ipfix_report_element_t *report_elements;
167 u32 n_report_elements;
173 } vnet_flow_report_add_del_args_t;
175 int vnet_flow_report_add_del (ipfix_exporter_t *exp,
176 vnet_flow_report_add_del_args_t *a,
179 clib_error_t *flow_report_add_del_error_to_clib_error (int error);
181 void vnet_flow_reports_reset (ipfix_exporter_t *exp);
183 void vnet_stream_reset (ipfix_exporter_t *exp, u32 stream_index);
185 int vnet_stream_change (ipfix_exporter_t *exp, u32 old_domain_id,
186 u16 old_src_port, u32 new_domain_id, u16 new_src_port);
188 #endif /* __included_vnet_flow_report_h__ */
191 * fd.io coding-style-patch-verification: ON
194 * eval: (c-set-style "gnu")