/* * netsniff-ng - the packet sniffing beast * Copyright 2009 - 2013 Daniel Borkmann. * Subject to the GPL, version 2. */ #include #include #include #include #include #include #include "pcap_io.h" #include "built_in.h" #include "die.h" #include "iosched.h" #include "ioops.h" static ssize_t pcap_rw_write(int fd, pcap_pkthdr_t *phdr, enum pcap_type type, const uint8_t *packet, size_t len) { ssize_t ret, hdrsize = pcap_get_hdr_length(phdr, type), hdrlen = 0; ret = write_or_die(fd, &phdr->raw, hdrsize); if (unlikely(ret != hdrsize)) panic("Failed to write pkt header!\n"); hdrlen = pcap_get_length(phdr, type); if (unlikely(hdrlen != (ssize_t) len)) return -EINVAL; ret = write_or_die(fd, packet, hdrlen); if (unlikely(ret != hdrlen)) panic("Failed to write pkt payload!\n"); return hdrsize + hdrlen; } static ssize_t pcap_rw_read(int fd, pcap_pkthdr_t *phdr, enum pcap_type type, uint8_t *packet, size_t len) { ssize_t ret, hdrsize = pcap_get_hdr_length(phdr, type), hdrlen = 0; ret = read_or_die(fd, &phdr->raw, hdrsize); if (unlikely(ret != hdrsize)) return -EIO; hdrlen = pcap_get_length(phdr, type); if (unlikely(hdrlen == 0 || hdrlen > (ssize_t) len)) return -EINVAL; ret = read(fd, packet, hdrlen); if (unlikely(ret != hdrlen)) return -EIO; return hdrsize + hdrlen; } static void pcap_rw_init_once(void) { set_ioprio_rt(); } static void pcap_rw_fsync(int fd) { fdatasync(fd); } const struct pcap_file_ops pcap_rw_ops = { .init_once_pcap = pcap_rw_init_once, .pull_fhdr_pcap = pcap_generic_pull_fhdr, .push_fhdr_pcap = pcap_generic_push_fhdr, .read_pcap = pcap_rw_read, .write_pcap = pcap_rw_write, .fsync_pcap = pcap_rw_fsync, }; ='/cgit.cgi/linux/net-next.git/tree/?h=nds-private-remove&id=3e5d6897176d38b54124da56183810abbd68c8bc'>treecommitdiff
diff options
context:
space:
mode:
authorNetanel Belgazal <netanel@annapurnalabs.com>2017-02-09 15:21:39 +0200
committerDavid S. Miller <davem@davemloft.net>2017-02-09 22:27:06 -0500
commit3e5d6897176d38b54124da56183810abbd68c8bc (patch)
treeb39c6b130ae03f217307f2cd3eb5e7659514a5e4
parentdd8427a78ffccbacf166a2d5d5eae55b586e1afe (diff)
net/ena: update driver version to 1.1.2
Signed-off-by: Netanel Belgazal <netanel@annapurnalabs.com> Signed-off-by: David S. Miller <davem@davemloft.net>