FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
pcap_funcs.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
16
#ifndef included_vppinfra_pcap_funcs_h
17
#define included_vppinfra_pcap_funcs_h
18
19
/** Write out data to output file. */
20
clib_error_t
*
pcap_close
(
pcap_main_t
* pm);
21
clib_error_t
*
pcap_write
(
pcap_main_t
* pm);
22
23
/** Read data from file. */
24
clib_error_t
*
pcap_read
(
pcap_main_t
* pm);
25
26
/** Close the file created by pcap_write function. */
27
clib_error_t
*
pcap_close
(
pcap_main_t
* pm);
28
29
/**
30
* @brief Add packet
31
*
32
* @param *pm - pcap_main_t
33
* @param time_now - f64
34
* @param n_bytes_in_trace - u32
35
* @param n_bytes_in_packet - u32
36
*
37
* @return Packet Data
38
*
39
*/
40
static
inline
void
*
41
pcap_add_packet
(
pcap_main_t
* pm,
42
f64
time_now,
u32
n_bytes_in_trace,
u32
n_bytes_in_packet)
43
{
44
pcap_packet_header_t
*
h
;
45
u8
*d;
46
47
vec_add2
(pm->
pcap_data
, d, sizeof (
h
[0]) + n_bytes_in_trace);
48
h
= (
void
*) (d);
49
h
->time_in_sec = time_now;
50
h
->time_in_usec = 1e6 * (time_now -
h
->time_in_sec);
51
h
->n_packet_bytes_stored_in_file = n_bytes_in_trace;
52
h
->n_bytes_in_packet = n_bytes_in_packet;
53
pm->
n_packets_captured
++;
54
return
h
->data;
55
}
56
57
#endif
/* included_vppinfra_pcap_funcs_h */
58
59
/*
60
* fd.io coding-style-patch-verification: ON
61
*
62
* Local Variables:
63
* eval: (c-set-style "gnu")
64
* End:
65
*/
pcap_add_packet
static void * pcap_add_packet(pcap_main_t *pm, f64 time_now, u32 n_bytes_in_trace, u32 n_bytes_in_packet)
Add packet.
Definition:
pcap_funcs.h:41
pcap_packet_header_t
Packet header.
Definition:
pcap.h:143
pcap_close
clib_error_t * pcap_close(pcap_main_t *pm)
Write out data to output file.
Definition:
pcap.c:74
pcap_main_t
PCAP main state data structure.
Definition:
pcap.h:155
h
h
Definition:
flowhash_template.h:372
vec_add2
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition:
vec.h:644
f64
double f64
Definition:
types.h:142
pcap_main_t::pcap_data
u8 * pcap_data
Vector of pcap data.
Definition:
pcap.h:183
u32
unsigned int u32
Definition:
types.h:88
u8
unsigned char u8
Definition:
types.h:56
clib_error_t
Definition:
clib_error.h:21
pcap_write
clib_error_t * pcap_write(pcap_main_t *pm)
Write PCAP file.
Definition:
pcap.c:89
pcap_main_t::n_packets_captured
u32 n_packets_captured
Number of packets currently captured.
Definition:
pcap.h:170
pcap_read
clib_error_t * pcap_read(pcap_main_t *pm)
Read data from file.
Definition:
pcap.c:176
src
vppinfra
pcap_funcs.h
Generated on Sat Jan 8 2022 10:37:15 for FD.io VPP by
1.8.17