- Tutorials
- API Examples
- User Guide
- Ch 1 - The Basics
- Ch 2 - libpcap
- 2.1 - The Main libpcap API Overview
- 2.2 - Getting a List of Interfaces
- 2.3 - Opening a Network Interface for Capture
- 2.4 - Opening offline capture
- 2.5 - Setting a packet filter
- 2.6 - Reading one packet at a time
- 2.7 - Reading multiple packets with dispatch loops
- 2.8 - Dumping captured packet to an offline file
- 2.9 - Transmitting packets
- 2.10 - Close Pcap and PcapDumper handles
- Ch 3 - Packet Decoding
- Ch 4 - Internals
- Ch 5 - Protocols
- Ch 6 - Native API
Compiling on Red Hat Enterprise version, requires few extra step in order to install the neccessary build environment.
In addtion Red Hat Enterprise Linux version 4 uses fairely old version of libpcap (version 0.8.3) which is below standard requirements of jNetPcap installations. However in order to provide support on these still common platforms in production environments, RHEL installations have a lower requirement for libpcap. Libpcap versions below 0.9.7 do not provide support for 2 functions: pcap_injet and pcap_sendpacket. These functions are ommitted from jNetPcap API. When using jNetPcap API, you can check if these 2 functions are supported with methods: Pcap.isPacketInjectSupported() and Pcap.isPacketSendSupported().
The following packages and their dependencies need to be installed for a build environment neccessary to compile jNetPcap software:
redhat> uname -a
Linux localhost.localdomain 2.6.9-89.ELsmp #1 SMP Mon Apr 20 10:34:33 EDT 2009 i686 i686 i386 GNU/Linuxredhat> rpm -q libpcap jdk gcc-c++ ant ant-nodeps subversion junit rpm-devel
libpcap-0.8.3-12.el4_6.1
jdk-1.6.0_02-fcs
gcc-c++-3.4.6-11
ant-1.6.5-4jpp
ant-nodeps-1.6.5-4jpp
subversion-1.1.4-2.ent
junit-3.8.2-4jpp
rpm-devel-4.3.3-32_nonptlSome of these packages are not easy to aquire for red-hat platforms. The rpms can be either downloaded manually or using an installer such as yum.
Installing Sun's java JDK
You have to download the linux distribution manually from http://java.sun.com. The self extracting and installing package is very easy to install.
If there is already a java environment installed you need to setup alternatives to Sun's JDK.
alternatives --install /usr/bin/java java /usr/java/latest/bin/java 1
alternatives --install /usr/bin/javah javah /usr/java/latest/bin/javah 1
alternatives --config java (make sure JDK is selected is primary)
alternatives --config javah (make sure JDK is selected is primary)
setenv JAVA_HOME /usr/java/latestNote: you can specify a specific version of JDK if more then one is installed to alternatives in the /usr/java directory.
Installing using up2date
Some of the above packages can be installed from local RHEL CD or from one of the RHN channels.
- up2date subversion
- up2date gcc-c++
- up2date libpcap
- up2date rpm-devel
Installing YUM on red-hat EL version 4
The remaing packages are easiest to install from jpackage.org yum repository.
You can skip this step if you already have yum installed and configured. Otherwise we have to download yum package and its prerequisites manually.
cd /tmp mkdir yum cd yum wget http://dag.wieers.com/rpm/packages/yum/yum-2.4.2-0.4.el4.rf.noarch.rpm wget http://dag.wieers.com/rpm/packages/python-elementtree/python-elementtree... wget http://dag.wieers.com/rpm/packages/sqlite/sqlite-2.8.17-1.el4.rf.i386.rpm wget http://dag.wieers.com/rpm/packages/python-urlgrabber/python-urlgrabber-2... rpm -iv python-elementtree-1.2.6-7.el4.rf.i386.rpm rpm -iv sqlite-2.8.17-1.el4.rf.i386.rpm rpm -iv python-sqlite-1.0.1-1.2.el4.rf.i386.rpm rpm -iv python-urlgrabber-2.9.7-1.2.el4.rf.noarch.rpm rpm -iv yum-2.4.2-0.4.el4.rf.noarch.rpm
Next we need to configure yum for jpackage.org repository which contains all the required java-noarch type packages. You would replace or append to (if you already have a working yum configuration) the /etc/yum.conf configuration file with the following:
/etc/yum.conf
[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=redhat-release
tolerant=1
exactarch=1
# Be sure to enable the distro specific repository for your distro below:
# - jpackage-fc for Fedora Core
# - jpackage-rhel for Red Hat Enterprise Linux and derivatives
[jpackage-generic]
name=JPackage (free), generic
mirrorlist=http://www.jpackage.org/mirrorlist.php?dist=generic&type=free&release=1.7
failovermethod=priority
gpgcheck=1
gpgkey=http://www.jpackage.org/jpackage.asc
enabled=1
[jpackage-fc]
name=JPackage (free) for Fedora Core $releasever
mirrorlist=http://www.jpackage.org/mirrorlist.php?dist=fedora-$releasever&type=free&release=1.7
failovermethod=priority
gpgcheck=1
gpgkey=http://www.jpackage.org/jpackage.asc
enabled=0
[jpackage-rhel]
name=JPackage (free) for Red Hat Enterprise Linux $releasever
mirrorlist=http://www.jpackage.org/mirrorlist.php?dist=redhat-el-$releasever&type=free&release=1.7
failovermethod=priority
gpgcheck=1
gpgkey=http://www.jpackage.org/jpackage.asc
enabled=0
[jpackage-generic-nonfree]
name=JPackage (non-free), generic
mirrorlist=http://www.jpackage.org/jpackage_generic_nonfree_1.7.txt
failovermethod=priority
gpgcheck=1
gpgkey=http://www.jpackage.org/jpackage.asc
enabled=0Now we are ready to install various no-arch type packages needed by jNetPcap.
Installing remaining packages using yum
This would be quiet easy step now if it weren't for a gatcha. The ant package distributed with jpackage.org (usually have jpp somewhere in the name) has a bug (yes this is a reported bug by many) that has a prerequisite requirement for sun-devel. This requirement comes from installation on a SULinux and is not applicable for red hat linuxes, since no such package exists anywhere. Therefore what you need to do is install ant package prerequisites first using yum. The manually download the ant package and install it using rpm and force it to not do dependency check.
Here are ant dependencies:
package: ant.noarch 1.6.5-4jpp
dependency: jaxp_parser_impl
provider: classpathx-jaxp.noarch 1.0-0.1.beta1.10jpp
provider: crimson.noarch 1.1.3-17jpp
provider: xerces-j2.noarch 2.9.0-2jpp
dependency: config(ant) = 1.6.5-4jpp
provider: ant.noarch 1.6.5-4jpp
dependency: xml-commons-apis
provider: xml-commons-jaxp-1.2-apis.noarch 1.3.03-11jpp
provider: xml-commons-jaxp-1.3-apis.noarch 1.3.03-11jpp
provider: xml-commons-jaxp-1.1-apis.noarch 1.3.03-11jpp
dependency: jpackage-utils >= 1.6
provider: jpackage-utils.noarch 1.7.5-1jpp
dependency: java-devel
Unsatisfied dependencyNotice that java-devl is an unsatisfied dependency. This is a report bug with the packaging. It apparently had been removed as a requirement and then put back. So we have to install the dependencies first in a separate step:
yum install classpathx-jaxp
yum install crimson
yum install xerces-j2
yum install xml-commons-jaxp
yum install jpackage-utilsNext we manually download the ant rpm from jpackage.org repository and install it using rpm:
wget http://mirrors.dotsrc.org/jpackage/1.7/generic/free/RPMS/ant-1.6.5-4jpp.... -iv --nodepends ant-1.6.5-4jpp.noarch.rpmAfter ANT has been installed, you need to check and make sure that Sun's JDK hadn't been removed during this entire process. If it has, you need to re-install it.
Now we install the remaining packages:
yum install ant-nodeps
yum install ant-junitCheckout source code and compile
After the environment is setup, you should now be able to checkout the source code and perform builds.
- Checkout source code
- As root run jUnit testcases:
su
ant clean test
exit -
ant -Dos=rhel4 clean package-rpm
Installing packages manually (not recommended)
It is possible to install the remaining packages manually. It is however much easier using yum (see installing using yum section).
To install manually you have to download manually all the require packages to your local system and then install using rpm command.
You can install all the packages from jpackage repository which contains most of the java based packages for various OSes. The web URL to the respository is
http://mirrors.dotsrc.org/jpackage/1.7/generic/free/repodata/repoview/The packages are organized alphabetically and you can click on the first letter of the package from a menu at the top of the page. All of the above specified packages need to be download and installed using rpm command. It is however not easy manually to figure out what all the inter-dependencies are, but its not impossible.
Below is an attempt to list some of the dependencies by these various packages. Note that some of the dependencies can go to deeper level, but atleast here are the top-level dependencies:
ant package
<code>
package: ant.noarch 1.6.5-4jpp
dependency: jaxp_parser_impl
provider: classpathx-jaxp.noarch 1.0-0.1.beta1.10jpp
provider: crimson.noarch 1.1.3-17jpp
provider: xerces-j2.noarch 2.9.0-2jpp
dependency: config(ant) = 1.6.5-4jpp
provider: ant.noarch 1.6.5-4jpp
dependency: xml-commons-apis
provider: xml-commons-jaxp-1.2-apis.noarch 1.3.03-11jpp
provider: xml-commons-jaxp-1.3-apis.noarch 1.3.03-11jpp
provider: xml-commons-jaxp-1.1-apis.noarch 1.3.03-11jpp
dependency: jpackage-utils >= 1.6
provider: jpackage-utils.noarch 1.7.5-1jpp
dependency: java-devel
Unsatisfied dependencyant-nodeps package
package: ant-nodeps.noarch 1.6.5-4jpp
dependency: ant = 1.6.5-4jpp
provider: ant.noarch 1.6.5-4jpp
junit package
No dependencies for this package
ant-junit package
package: ant-junit.noarch 1.6.5-4jpp
dependency: ant = 1.6.5-4jpp
provider: ant.noarch 1.6.5-4jpp
dependency: junit
provider: junit.noarch 3.8.2-4jppAnd here are the second level dependencies for all the dependencies of the ant package:
package: xerces-j2.noarch 2.9.0-2jpp
dependency: xml-commons-jaxp-1.3-apis >= 1.3
provider: xml-commons-jaxp-1.3-apis.noarch 1.3.03-11jpp
dependency: jaxp_parser_impl
provider: classpathx-jaxp.noarch 1.0-0.1.beta1.10jpp
provider: crimson.noarch 1.1.3-17jpp
provider: xerces-j2.noarch 2.9.0-2jpp
dependency: jpackage-utils >= 1.7.2
provider: jpackage-utils.noarch 1.7.5-1jpp
dependency: /bin/sh
Unsatisfied dependency
dependency: /usr/sbin/update-alternatives
Unsatisfied dependency
dependency: xml-commons-resolver11
provider: xml-commons-resolver11.noarch 1.3.03-11jpp
package: crimson.noarch 1.1.3-17jpp
dependency: /usr/sbin/update-alternatives
Unsatisfied dependency
dependency: xml-commons-apis
provider: xml-commons-jaxp-1.2-apis.noarch 1.3.03-11jpp
provider: xml-commons-jaxp-1.3-apis.noarch 1.3.03-11jpp
provider: xml-commons-jaxp-1.1-apis.noarch 1.3.03-11jpp
dependency: jpackage-utils >= 1.6
provider: jpackage-utils.noarch 1.7.5-1jpp
dependency: /bin/sh
Unsatisfied dependency
package: classpathx-jaxp.noarch 1.0-0.1.beta1.10jpp
dependency: /usr/sbin/update-alternatives
Unsatisfied dependency
dependency: xml-commons-apis
provider: xml-commons-jaxp-1.2-apis.noarch 1.3.03-11jpp
provider: xml-commons-jaxp-1.3-apis.noarch 1.3.03-11jpp
provider: xml-commons-jaxp-1.1-apis.noarch 1.3.03-11jpp
dependency: /bin/sh
Unsatisfied dependency
package: jpackage-utils.noarch 1.7.5-1jpp
dependency: /bin/sed
Unsatisfied dependency
dependency: /bin/egrep
Unsatisfied dependency
dependency: /usr/bin/perl
Unsatisfied dependency
dependency: /bin/sh
Unsatisfied dependencyLike I said, trying to resolve all of these dependencies can get quiet difficult rather quickly. None the less I have provided as much data as I can to help your resolve these dependencies manually.