On Wed, 14 Feb 2024 09:56:22 +0100 Laurent Vivier <lvivier(a)redhat.com> wrote:Signed-off-by: Laurent Vivier <lvivier(a)redhat.com> --- Notes: v2: - introduce pcap_header(), a common helper to write packet header - use writev() rather than write() in a loop - add functions comment pcap.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++------- pcap.h | 1 + 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/pcap.c b/pcap.c index 501d52d4992b..3869a403dd0f 100644 --- a/pcap.c +++ b/pcap.c @@ -20,6 +20,7 @@ #include <sys/time.h> #include <sys/types.h> #include <sys/stat.h> +#include <sys/uio.h> #include <fcntl.h> #include <time.h> #include <errno.h> @@ -31,6 +32,7 @@ #include "util.h" #include "passt.h" #include "log.h" +#include "iov.h" #define PCAP_VERSION_MINOR 4 @@ -65,6 +67,28 @@ struct pcap_pkthdr { uint32_t len; }; +/* + * pcap_header - Write a pcap packet header to the pcap file descriptor (pcap_fd).Nit: pcap_header(). And "(pcap_fd)" doesn't seem to be a valid reference (anymore?).+ * + * @len: Length of the packet data. + * @tv: Pointer to a timeval struct containing the timestamp for the packet. + * + * Returns; -1 in case of error, otherwise, 0 to indicate success."Return: -1" ...I know, it's wrong in pcap_frame(). -- Stefano