43 #ifndef included_vnet_pcap_h 44 #define included_vnet_pcap_h 57 #define foreach_vnet_pcap_packet_type \ 66 #define _(f,n) PCAP_PACKET_TYPE_##f = (n), 71 #define foreach_pcap_file_header \ 77 _ (u16, major_version) \ 78 _ (u16, minor_version) \ 87 _ (u32, max_packet_size_in_bytes) \ 100 #define foreach_pcap_packet_header \ 102 _ (u32, time_in_sec) \ 104 _ (u32, time_in_usec) \ 107 _ (u32, n_packet_bytes_stored_in_file) \ 109 _ (u32, n_bytes_in_packet) 143 #define PCAP_MAIN_INIT_DONE (1 << 0) 183 f64 time_now,
u32 n_bytes_in_trace,
u32 n_bytes_in_packet)
190 h->time_in_sec = time_now;
191 h->time_in_usec = 1e6 * (time_now - h->time_in_sec);
192 h->n_packet_bytes_stored_in_file = n_bytes_in_trace;
193 h->n_bytes_in_packet = n_bytes_in_packet;
char * file_name
File name of pcap output.
int file_descriptor
File descriptor for reading/writing.
u32 n_packets_to_capture
Number of packets to capture.
static f64 vlib_time_now(vlib_main_t *vm)
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
clib_error_t * pcap_write(pcap_main_t *pm)
Write out data to output file.
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
static void * pcap_add_packet(pcap_main_t *pm, f64 time_now, u32 n_bytes_in_trace, u32 n_bytes_in_packet)
Add packet.
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
PCAP main state data structure.
clib_spinlock_t lock
spinlock to protect e.g.
#define foreach_pcap_packet_header
u32 n_pcap_data_written
Bytes written.
u16 current_length
Nbytes between current data and the end of this buffer.
u8 * pcap_data
Vector of pcap data.
static void pcap_add_buffer(pcap_main_t *pm, vlib_main_t *vm, u32 buffer_index, u32 n_bytes_in_trace)
Add buffer (vlib_buffer_t) to the trace.
#define clib_memcpy(a, b, c)
u32 next_buffer
Next buffer for this linked-list of buffers.
clib_error_t * pcap_read(pcap_main_t *pm)
Read data from file.
u32 min_packet_bytes
Min/Max Packet bytes.
u64 * timestamps
Timestamps.
pcap_packet_type_t packet_type
Packet type.
u8 ** packets_read
Packets read from file.
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
u32 n_packets_captured
Number of packets currently captured.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
#define foreach_vnet_pcap_packet_type
Packet types supported by PCAP.
#define foreach_pcap_file_header