|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
40 #include <sys/fcntl.h>
102 open (pm->
file_name, O_CREAT | O_TRUNC | O_WRONLY, 0664);
117 fh.magic = 0xa1b2c3d4;
118 fh.major_version = 2;
119 fh.minor_version = 4;
121 fh.max_packet_size_in_bytes = 1 << 16;
124 if (n !=
sizeof (fh))
179 int fd, need_swap, n;
190 if (read (fd, &fh,
sizeof (fh)) !=
sizeof (fh))
198 if (fh.magic == 0xd4c3b2a1)
201 #define _(t,f) fh.f = clib_byte_swap_##t (fh.f);
206 if (fh.magic != 0xa1b2c3d4)
214 while ((n = read (fd, &
ph,
sizeof (
ph))) != 0)
223 #define _(t,f) ph.f = clib_byte_swap_##t (ph.f);
229 if (read (fd,
data,
ph.n_packet_bytes_stored_in_file) !=
230 ph.n_packet_bytes_stored_in_file)
246 timestamp_sec =
ph.time_in_sec;
247 timestamp_usec =
ph.time_in_usec;
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static void clib_spinlock_init(clib_spinlock_t *p)
#define foreach_pcap_packet_header
__clib_export clib_error_t * pcap_read(pcap_main_t *pm)
Read PCAP file.
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
u32 min_packet_bytes
Min/Max Packet bytes.
static word unix_error_is_fatal(word error)
__clib_export clib_error_t * pcap_close(pcap_main_t *pm)
Close PCAP file.
#define clib_error_return(e, args...)
pcap_packet_type_t packet_type
Packet type.
PCAP main state data structure.
u64 * timestamps
Timestamps.
pool_header_t * ph(void *p)
GDB callable function: ph - call pool_header - get pool header.
clib_spinlock_t lock
spinlock to protect e.g.
int file_descriptor
File descriptor for reading/writing.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define foreach_pcap_file_header
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
PCAP utility definitions.
u8 * pcap_data
Vector of pcap data.
u8 ** packets_read
Packets read from file.
u32 n_pcap_data_written
Bytes written.
#define clib_error_return_unix(e, args...)
__clib_export clib_error_t * pcap_write(pcap_main_t *pm)
Write PCAP file.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define PCAP_MAIN_INIT_DONE
char * file_name
File name of pcap output.
u32 n_packets_captured
Number of packets currently captured.