41 #include <sys/fcntl.h> 86 memset (&fh, 0,
sizeof (fh));
87 fh.magic = 0xa1b2c3d4;
91 fh.max_packet_size_in_bytes = 1 << 16;
145 int fd, need_swap, n;
156 if (read (fd, &fh,
sizeof (fh)) !=
sizeof (fh))
163 if (fh.magic == 0xd4c3b2a1)
166 #define _(t,f) fh.f = clib_byte_swap_##t (fh.f); 171 if (fh.magic != 0xa1b2c3d4)
179 while ((n = read (fd, &ph,
sizeof (ph))) != 0)
185 #define _(t,f) ph.f = clib_byte_swap_##t (ph.f); 190 data =
vec_new (
u8, ph.n_bytes_in_packet);
191 if (read (fd, data, ph.n_packet_bytes_stored_in_file) != ph.n_packet_bytes_stored_in_file)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define foreach_pcap_packet_header
#define clib_error_return_unix(e, args...)
always_inline word unix_error_is_fatal(word error)
clib_error_t * pcap_read(pcap_main_t *pm)
clib_error_t * pcap_write(pcap_main_t *pm)
#define PCAP_MAIN_INIT_DONE
pcap_packet_type_t packet_type
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define clib_error_return(e, args...)
#define foreach_pcap_file_header