FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
flow_report_classify.h
Go to the documentation of this file.
1 /*
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:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15 #ifndef __included_flow_report_classify_h__
16 #define __included_flow_report_classify_h__
17 
18 #define foreach_ipfix_ip4_field \
19 _(ip->src_address.as_u32, ((u32[]){0xFFFFFFFF}), sourceIPv4Address, 4) \
20 _(ip->dst_address.as_u32, ((u32[]){0xFFFFFFFF}), destinationIPv4Address, 4) \
21 _(ip->protocol, ((u8[]){0xFF}), protocolIdentifier, 1)
22 
23 #define foreach_ipfix_ip6_field \
24 _(ip6->src_address.as_u8, \
25  ((u32[]){0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}), \
26  sourceIPv6Address, 16) \
27 _(ip6->dst_address.as_u8, \
28  ((u32[]){0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}), \
29  destinationIPv6Address, 16) \
30 _(ip6->protocol, ((u8[]){0xFF}), protocolIdentifier, 1)
31 
32 #define foreach_ipfix_tcpudp_field \
33 _(tcpudp->src_port, ((u16[]){0xFFFF}), sourceTransportPort, 2) \
34 _(tcpudp->dst_port, ((u16[]){0xFFFF}), destinationTransportPort, 2)
35 
36 #define foreach_ipfix_tcp_field \
37 _(tcpudp->src_port, ((u16[]){0xFFFF}), tcpSourcePort, 2) \
38 _(tcpudp->dst_port, ((u16[]){0xFFFF}), tcpDestinationPort, 2)
39 
40 #define foreach_ipfix_udp_field \
41 _(tcpudp->src_port, ((u16[]){0xFFFF}), udpSourcePort, 2) \
42 _(tcpudp->dst_port, ((u16[]){0xFFFF}), udpDestinationPort, 2)
43 
44 #define foreach_ipfix_transport_protocol_field \
45  switch (transport_protocol) { \
46  case 255: \
47  foreach_ipfix_tcpudp_field; \
48  break; \
49  case 6: \
50  foreach_ipfix_tcp_field; \
51  break; \
52  case 17: \
53  foreach_ipfix_udp_field; \
54  break; \
55  }
56 
57 #define foreach_ipfix_field \
58  if (ip_version == 4) { \
59  ip = (ip4_header_t *)ip_start; \
60  tcpudp = (tcpudp_header_t *)(ip+1); \
61  foreach_ipfix_ip4_field; \
62  } else { \
63  ip6 = (ip6_header_t *)ip_start; \
64  tcpudp = (tcpudp_header_t *)(ip6+1); \
65  foreach_ipfix_ip6_field; \
66  } \
67  foreach_ipfix_transport_protocol_field
68 
69 typedef struct
70 {
75 
76 typedef struct
77 {
82 
84 
87 {
89  return index < vec_len (fcm->tables) &&
90  fcm->tables[index].classify_table_index != ~0;
91 }
92 
95 {
97  u32 i;
98  for (i = 0; i < vec_len (fcm->tables); i++)
100  return &fcm->tables[i];
101  u32 index = vec_len (fcm->tables);
102  vec_validate (fcm->tables, index);
103  return &fcm->tables[index];
104 }
105 
108 {
110  ASSERT (index < vec_len (fcm->tables));
111  ASSERT (fcm->tables[index].classify_table_index != ~0);
112  fcm->tables[index].classify_table_index = ~0;
113 }
114 
116  flow_report_t * fr,
117  ip4_address_t * collector_address,
119  u16 collector_port,
120  ipfix_report_element_t * elts,
121  u32 n_elts, u32 * stream_index);
122 
124  flow_report_t * fr,
125  vlib_frame_t * f,
126  u32 * to_next, u32 node_index);
127 
128 #endif /* __included_flow_report_classify_h__ */
129 
130 /*
131  * fd.io coding-style-patch-verification: ON
132  *
133  * Local Variables:
134  * eval: (c-set-style "gnu")
135  * End:
136  */
flow_report_classify_main_t
Definition: flow_report_classify.h:76
f
vlib_frame_t * f
Definition: interface_output.c:1098
flow_report_classify_main_t::domain_id
u32 domain_id
Definition: flow_report_classify.h:78
flow_report_classify_main
flow_report_classify_main_t flow_report_classify_main
Definition: flow_report_classify.c:29
flow_report
Definition: flow_report.h:85
u16
unsigned short u16
Definition: types.h:57
ipfix_classify_send_flows
vlib_frame_t * ipfix_classify_send_flows(flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
Definition: flow_report_classify.c:161
ipfix_classify_table_t::classify_table_index
u32 classify_table_index
Definition: flow_report_classify.h:71
node_index
node node_index
Definition: interface_output.c:440
flow_report_classify_main_t::tables
ipfix_classify_table_t * tables
Definition: flow_report_classify.h:80
vlib_frame_t
Definition: node.h:372
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
ipfix_classify_table_index_valid
static_always_inline u8 ipfix_classify_table_index_valid(u32 index)
Definition: flow_report_classify.h:86
static_always_inline
#define static_always_inline
Definition: clib.h:112
ipfix_report_element_t
Definition: flow_report.h:34
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
flow_report_main
Definition: flow_report.h:110
ip4_address_t
Definition: ip4_packet.h:50
ipfix_classify_template_rewrite
u8 * ipfix_classify_template_rewrite(flow_report_main_t *frm, flow_report_t *fr, ip4_address_t *collector_address, ip4_address_t *src_address, u16 collector_port, ipfix_report_element_t *elts, u32 n_elts, u32 *stream_index)
Definition: flow_report_classify.c:32
flow_report_classify_main_t::src_port
u16 src_port
Definition: flow_report_classify.h:79
index
u32 index
Definition: flow_types.api:221
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
ipfix_classify_table_t::transport_protocol
u8 transport_protocol
Definition: flow_report_classify.h:73
u32
unsigned int u32
Definition: types.h:88
u8
unsigned char u8
Definition: types.h:56
ipfix_classify_table_t
Definition: flow_report_classify.h:69
ipfix_classify_table_t::ip_version
u8 ip_version
Definition: flow_report_classify.h:72
i
int i
Definition: flowhash_template.h:376
ipfix_classify_add_table
static_always_inline ipfix_classify_table_t * ipfix_classify_add_table(void)
Definition: flow_report_classify.h:94
src_address
vl_api_address_union_t src_address
Definition: ip_types.api:122
ipfix_classify_delete_table
static_always_inline void ipfix_classify_delete_table(u32 index)
Definition: flow_report_classify.h:107