FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
pcap_classify.h
Go to the documentation of this file.
1
/*
2
* pcap_classify.h - Use the classifier to decide if a packet is captured
3
*
4
* Copyright (c) 2021 Cisco and/or its affiliates.
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at:
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*/
17
#include <
vlib/vlib.h
>
18
#include <
vnet/vnet.h
>
19
#include <
vnet/classify/vnet_classify.h
>
20
#include <
vnet/classify/trace_classify.h
>
21
22
/** @file pcap_classify.h
23
* Use the vpp classifier to decide whether to capture packets
24
*/
25
26
/** @brief vnet_is_packet_pcaped
27
* @param vlib_buffer_t *b - packet to capture
28
* @return 0 => no capture, 1 => capture
29
*/
30
31
static_always_inline
int
32
vnet_is_packet_pcaped
(
vnet_pcap_t
*pp,
vlib_buffer_t
*
b
,
u32
sw_if_index
)
33
{
34
const
u32
pcap_sw_if_index = pp->
pcap_sw_if_index
;
35
const
u32
filter_classify_table_index = pp->
filter_classify_table_index
;
36
const
vlib_error_t
pcap_error_index = pp->
pcap_error_index
;
37
38
if
(pcap_sw_if_index != 0)
39
{
40
if
(~0 ==
sw_if_index
)
41
sw_if_index
=
vnet_buffer
(
b
)->sw_if_index[
VLIB_RX
];
42
if
(pcap_sw_if_index !=
sw_if_index
)
43
return
0;
/* wrong interface, skip */
44
}
45
46
if
(pcap_error_index != (
vlib_error_t
) ~0 && pcap_error_index !=
b
->
error
)
47
return
0;
/* wrong error */
48
49
if
(filter_classify_table_index != ~0 &&
50
vnet_is_packet_traced_inline
(
b
, filter_classify_table_index,
51
0
/* full classify */
) != 1)
52
return
0;
/* not matching the filter, skip */
53
54
return
1;
/* success */
55
}
56
57
/*
58
* fd.io coding-style-patch-verification: ON
59
*
60
* Local Variables:
61
* eval: (c-set-style "gnu")
62
* End:
63
*/
vlib.h
trace_classify.h
VLIB_RX
@ VLIB_RX
Definition:
defs.h:46
vnet_pcap_t::pcap_sw_if_index
u32 pcap_sw_if_index
Definition:
vnet.h:70
vlib_buffer_t::error
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition:
buffer.h:145
vnet_buffer
#define vnet_buffer(b)
Definition:
buffer.h:437
static_always_inline
#define static_always_inline
Definition:
clib.h:112
vnet_pcap_t::filter_classify_table_index
u32 filter_classify_table_index
Definition:
vnet.h:72
vnet_pcap_t
Definition:
vnet.h:60
u32
unsigned int u32
Definition:
types.h:88
vnet_is_packet_pcaped
static_always_inline int vnet_is_packet_pcaped(vnet_pcap_t *pp, vlib_buffer_t *b, u32 sw_if_index)
vnet_is_packet_pcaped
Definition:
pcap_classify.h:32
vnet_classify.h
vnet_is_packet_traced_inline
static int vnet_is_packet_traced_inline(vlib_buffer_t *b, u32 classify_table_index, int func)
vnet_is_packet_traced
Definition:
trace_classify.h:34
b
vlib_buffer_t ** b
Definition:
nat44_ei_out2in.c:717
vlib_error_t
u16 vlib_error_t
Definition:
error.h:45
vnet.h
sw_if_index
vl_api_interface_index_t sw_if_index
Definition:
wireguard.api:34
vnet_pcap_t::pcap_error_index
vlib_error_t pcap_error_index
Definition:
vnet.h:73
vlib_buffer_t
VLIB buffer representation.
Definition:
buffer.h:111
src
vnet
classify
pcap_classify.h
Generated on Sat Jan 8 2022 10:04:44 for FD.io VPP by
1.8.17