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;
51 typedef vlib_frame_t *(vnet_flow_data_callback_t) (struct flow_report_main *,
53 vlib_frame_t *, u32 *,
56 typedef u8 *(vnet_flow_rewrite_callback_t) (struct flow_report_main *,
60 ipfix_report_element_t * elts,
61 u32 n_elts, u32 * stream_index);
63 u8 *vnet_flow_rewrite_generic_callback (struct flow_report_main *,
67 ipfix_report_element_t * elts,
68 u32 n_elts, u32 * stream_index);
83 } flow_report_stream_t;
85 typedef struct flow_report
87 /* ipfix rewrite, set by callback */
91 f64 last_template_sent;
94 /* Bitmap of fields to send */
95 uword *fields_to_send;
100 /* build-the-template-packet rewrite callback */
101 vnet_flow_rewrite_callback_t *rewrite_callback;
102 ipfix_report_element_t *report_elements;
103 u32 n_report_elements;
106 /* Send-flow-data callback */
107 vnet_flow_data_callback_t *flow_data_callback;
110 typedef struct flow_report_main
112 flow_report_t *reports;
113 flow_report_stream_t *streams;
115 /* ipfix collector ip address, port, our ip address, fib index */
116 ip4_address_t ipfix_collector;
118 ip4_address_t src_address;
124 /* time interval in seconds after which to resend templates */
125 u32 template_interval;
127 /* UDP checksum calculation enable flag */
130 /* time scale transform. Joy. */
134 /* convenience variables */
135 vlib_main_t *vlib_main;
136 vnet_main_t *vnet_main;
137 } flow_report_main_t;
139 extern flow_report_main_t flow_report_main;
141 extern vlib_node_registration_t flow_report_process_node;
143 int vnet_flow_report_enable_disable (u32 sw_if_index, u32 table_index,
147 vnet_flow_data_callback_t *flow_data_callback;
148 vnet_flow_rewrite_callback_t *rewrite_callback;
149 ipfix_report_element_t *report_elements;
150 u32 n_report_elements;
156 } vnet_flow_report_add_del_args_t;
158 int vnet_flow_report_add_del (flow_report_main_t * frm,
159 vnet_flow_report_add_del_args_t * a,
162 clib_error_t *flow_report_add_del_error_to_clib_error (int error);
164 void vnet_flow_reports_reset (flow_report_main_t * frm);
166 void vnet_stream_reset (flow_report_main_t * frm, u32 stream_index);
168 int vnet_stream_change (flow_report_main_t * frm,
169 u32 old_domain_id, u16 old_src_port,
170 u32 new_domain_id, u16 new_src_port);
172 #endif /* __included_vnet_flow_report_h__ */
175 * fd.io coding-style-patch-verification: ON
178 * eval: (c-set-style "gnu")