/* * netsniff-ng - the packet sniffing beast * Copyright 2009, 2010 Daniel Borkmann. * Subject to the GPL, version 2. */ #include #include #include #include #include #include #include #include #include #include "xmalloc.h" #include "die.h" #include "ring.h" #include "built_in.h" void mmap_ring_generic(int sock, struct ring *ring) { ring->mm_space = mmap(NULL, ring->mm_len, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_LOCKED | MAP_POPULATE, sock, 0); if (ring->mm_space == MAP_FAILED) panic("Cannot mmap {TX,RX}_RING!\n"); } void alloc_ring_frames_generic(struct ring *ring, int num, size_t size) { int i; size_t len = num * sizeof(*ring->frames); ring->frames = xmalloc_aligned(len, CO_CACHE_LINE_SIZE); fmemset(ring->frames, 0, len); for (i = 0; i < num; ++i) { ring->frames[i].iov_len = size; ring->frames[i].iov_base = ring->mm_space + (i * size); } } void bind_ring_generic(int sock, struct ring *ring, int ifindex) { int ret; /* The {TX,RX}_RING registers itself to the networking stack with * dev_add_pack(), so we have one single RX_RING for all devs * otherwise you'll get the packet twice. */ fmemset(&ring->s_ll, 0, sizeof(ring->s_ll)); ring->s_ll.sll_family = AF_PACKET; ring->s_ll.sll_protocol = htons(ETH_P_ALL); ring->s_ll.sll_ifindex = ifindex; ring->s_ll.sll_hatype = 0; ring->s_ll.sll_halen = 0; ring->s_ll.sll_pkttype = 0; ret = bind(sock, (struct sockaddr *) &ring->s_ll, sizeof(ring->s_ll)); if (ret < 0) panic("Cannot bind {TX,RX}_RING!\n"); } /cgit.cgi/linux/net-next.git/refs/?id=aacaaa4c8e1cd3b813a3b77c9855e53d96381f40'>refslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2016-02-05 12:51:07 +0000
committerMark Brown <broonie@kernel.org>2016-02-05 12:51:07 +0000
commitaacaaa4c8e1cd3b813a3b77c9855e53d96381f40 (patch)
tree656fb73fa195f877a5e09f37ea60c145b67c56ef
parent3245d460a1eb55b5c3ca31dde7b5c5ac71546edf (diff)
parent320549a22484952d88d4e0320218765b16cd2174 (diff)
Merge branch 'fix/mmio' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap into regmap-mmio