summaryrefslogtreecommitdiff
blob: 219db03253580171c1a1b06c1d8c4d5543fd6463 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-libs/libpcap-ringbuffer/libpcap-ringbuffer-0.9.20060417.ebuild,v 1.4 2007/06/26 02:26:28 mr_bones_ Exp $

inherit eutils toolchain-funcs linux-info multilib libtool autotools

MY_P=${PN:0:7}-${PV}

DESCRIPTION="A libpcap version which supports MMAP mode (ringbuffer) on the linux kernel 2.[46].x"
HOMEPAGE="http://public.lanl.gov/cpw/"
SRC_URI="http://public.lanl.gov/cpw/${MY_P}.tar.gz"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~x86"
IUSE="ipv6"

DEPEND="!virtual/libpcap"

PROVIDE="virtual/libpcap"

S=${WORKDIR}/${MY_P}

# Used in linux-info to check minium Kernel support
CONFIG_CHECK="PACKET_MMAP"
PACKET_MMAP_ERROR="Make sure you have PACKET_MMAP compiled in your kernel to make use of libpcap's ringbuffer feature."

src_unpack() {
	unpack ${A}

	cd "${S}"
	epatch "${FILESDIR}/${P}-makefile.patch"
	eautoreconf
}

src_compile() {
	econf $(use_enable ipv6) --enable-shared --with-pcap=linux || die "configure failed"
	emake || die "make failed"
}

src_install() {
	emake DESTDIR="${D}" install || die "make install failed"
	dodoc CREDITS CHANGES FILES README* VERSION

	dosym libpcap-0.9.3.so /usr/$(get_libdir)/libpcap.so.0.9
	dosym libpcap-0.9.3.so /usr/$(get_libdir)/libpcap.so.0

	#set PCAP_FRAMES=max
	echo "PCAP_FRAMES=32768" > "${T}/99libpcap-ringbuffer"
	doenvd "${T}/99libpcap-ringbuffer"
}

pkg_postinst() {
	echo
	elog "Use of the ringbuffer requires that the environment variable PCAP_FRAMES be set."
	elog "This has automaticaly been set to the maximal accepted value"
	elog "   PCAP_FRAMES=32768"
	elog
	elog "This will tie up at around 51 Mbytes of memory for the ring buffer alone"
	elog "when capturing packets with tools like tcpdump or snort."
	elog "You can change this environment variable by editing"
	elog "   /etc/env.d/99libpcap-ringbuffer"
	elog "and then run"
	elog "   env-update && source /etc/profile"
	elog
	elog "To continue to use libpcap-ringbuffer without the ringbuffer,  just set PCAP_FRAMES=0"
	elog "in the env.d file. Alternatively, you could run wireshark like this:"
	elog "   PCAP_FRAMES=0 wireshark"
	elog
	elog "For further details see:"
	elog "   /usr/share/doc/${PF}/README.ring.gz"
}