diff mbox

[PATCHv6] test: add libpcap example

Message ID 1395026059-18045-1-git-send-email-vincent.hsu@linaro.org
State Accepted, archived
Headers show

Commit Message

Vincent Hsu March 17, 2014, 3:14 a.m. UTC
Signed-off-by: Vincent Hsu <vincent.hsu@linaro.org>
---
 .gitignore                      |  3 ++
 platform/linux-generic/Makefile |  1 +
 test/libpcap/Makefile           | 92 +++++++++++++++++++++++++++++++++++++++++
 test/libpcap/README             | 47 +++++++++++++++++++++
 4 files changed, 143 insertions(+)
 create mode 100644 test/libpcap/Makefile
 create mode 100644 test/libpcap/README

Comments

Mike Holmes March 17, 2014, 1:20 p.m. UTC | #1
Vincent, if this patch makes it into ODP, we should make a bug to track
removing the need for note 1 and 2.
Possibly the new Ubuntu 14.04 LTS release will fix this on April 17th.


On 16 March 2014 23:14, Vincent Hsu <vincent.hsu@linaro.org> wrote:

> Signed-off-by: Vincent Hsu <vincent.hsu@linaro.org>
> ---
>  .gitignore                      |  3 ++
>  platform/linux-generic/Makefile |  1 +
>  test/libpcap/Makefile           | 92
> +++++++++++++++++++++++++++++++++++++++++
>  test/libpcap/README             | 47 +++++++++++++++++++++
>  4 files changed, 143 insertions(+)
>  create mode 100644 test/libpcap/Makefile
>  create mode 100644 test/libpcap/README
>
> diff --git a/.gitignore b/.gitignore
> index 53454a5..ae6eb64 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -14,3 +14,6 @@ test/packet_netmap/odp_packet
>  test/api_test/odp_atomic
>  test/api_test/odp_shm
>  test/api_test/odp_ring
> +test/libpcap/libpcap
> +test/libpcap/tcpdump
> +test/libpcap/wireshark
> diff --git a/platform/linux-generic/Makefile
> b/platform/linux-generic/Makefile
> index c35eb07..2a09dbe 100644
> --- a/platform/linux-generic/Makefile
> +++ b/platform/linux-generic/Makefile
> @@ -35,6 +35,7 @@ DOC_DIR  = ./doc
>  EXTRA_CFLAGS  += -I$(ODP_ROOT)/include
>  EXTRA_CFLAGS  += -I./include
>  EXTRA_CFLAGS  += -I./include/api
> +EXTRA_CFLAGS  += -fPIC
>
>  ifeq ($(ODP_HAVE_NETMAP),yes)
>  EXTRA_CFLAGS  += -DODP_HAVE_NETMAP
> diff --git a/test/libpcap/Makefile b/test/libpcap/Makefile
> new file mode 100644
> index 0000000..4438dbe
> --- /dev/null
> +++ b/test/libpcap/Makefile
> @@ -0,0 +1,92 @@
> +# Copyright (c) 2013, Linaro Limited
> +# All rights reserved.
> +#
> +# SPDX-License-Identifier:     BSD-3-Clause
> +
> +LIBPCAP_REPO=http://git.linaro.org/git/people/vincent.hsu/libpcap.git
> +LIBPCAP_DIR=libpcap
> +TCPDUMP_REPO=https://github.com/the-tcpdump-group/tcpdump.git
> +TCPDUMP_DIR=tcpdump
> +WIRESHARK_REPO=https://code.wireshark.org/review/p/wireshark.git
> +WIRESHARK_DIR=wireshark
> +LIBPCAP_VERSION=af25cf38dd258f3f1fb5b9b4b731248f022cc732
> +TCPDUMP_VERSION=tcpdump-4.2.1
> +WIRESHARK_VERSION=wireshark-1.8.9
> +
> +.PHONY: all
> +all: libpcap tcpdump
> +
> +.PHONY: update
> +update: get_libpcap get_tcpdump
> +
> +.PHONY: install
> +install: install_libpcap install_tcpdump
> +
> +.PHONY: clean
> +clean: clean_libpcap clean_tcpdump
> +
> +.PHONY: libpcap
> +libpcap: get_libpcap
> +       cd $(LIBPCAP_DIR) \
> +       && git checkout $(LIBPCAP_VERSION) \
> +       && ./configure --with-odp=../../.. --libdir=/usr/lib
> +       $(MAKE) -C $(LIBPCAP_DIR)
> +
> +.PHONY: get_libpcap
> +get_libpcap:
> +       if [ ! -d $(LIBPCAP_DIR) ]; then git clone $(LIBPCAP_REPO); \
> +       else cd $(LIBPCAP_DIR); git fetch --all; fi
> +
> +.PHONY: install_libpcap
> +install_libpcap:
> +       $(MAKE) -C $(LIBPCAP_DIR) install
> +       if [ -d $(LIBPCAP_DIR) ]; then $(MAKE) -C $(LIBPCAP_DIR) install;
> fi
> +
> +.PHONY: clean_libpcap
> +clean_libpcap:
> +       $(MAKE) -C $(LIBPCAP_DIR) clean
> +       if [ -d $(LIBPCAP_DIR) ]; then $(MAKE) -C $(LIBPCAP_DIR)
> distclean; fi
> +
> +.PHONY: tcpdump
> +tcpdump: get_tcpdump libpcap
> +       cd $(TCPDUMP_DIR) \
> +       && git checkout $(TCPDUMP_VERSION) \
> +       && ./configure
> +       $(MAKE) -C $(TCPDUMP_DIR)
> +
> +.PHONY: get_tcpdump
> +get_tcpdump:
> +       if [ ! -d $(TCPDUMP_DIR) ]; then git clone $(TCPDUMP_REPO); \
> +       else cd $(TCPDUMP_DIR); git fetch --all; fi
> +
> +.PHONY: install_tcpdump
> +install_tcpdump:
> +       $(MAKE) -C $(TCPDUMP_DIR) install
> +       if [ -d $(TCPDUMP_DIR) ]; then $(MAKE) -C $(TCPDUMP_DIR) install;
> fi
> +
> +.PHONY: clean_tcpdump
> +clean_tcpdump:
> +       $(MAKE) -C $(TCPDUMP_DIR) clean
> +       if [ -d $(TCPDUMP_DIR) ]; then $(MAKE) -C $(TCPDUMP_DIR)
> distclean; fi
> +
> +.PHONY: wireshark
> +wireshark: get_wireshark libpcap
> +       cd $(WIRESHARK_DIR) \
> +       && git checkout $(WIRESHARK_VERSION) \
> +       && ./autogen.sh && ./configure
> +       $(MAKE) -C $(WIRESHARK_DIR)
> +
> +.PHONY: get_wireshark
> +get_wireshark:
> +       if [ ! -d $(WIRESHARK_DIR) ]; then git clone $(WIRESHARK_REPO); \
> +       else cd $(WIRESHARK_DIR); git fetch --all; fi
> +
> +.PHONY: install_wireshark
> +install_wireshark:
> +       $(MAKE) -C $(WIRESHARK_DIR) install
> +       if [ -d $(WIRESHARK_DIR) ]; then $(MAKE) -C $(WIRESHARK_DIR)
> install; fi
> +
> +.PHONY: clean_wireshark
> +clean_wireshark:
> +       $(MAKE) -C $(WIRESHARK_DIR) clean
> +       if [ -d $(WIRESHARK_DIR) ]; then $(MAKE) -C $(WIRESHARK_DIR)
> distclean; fi
> diff --git a/test/libpcap/README b/test/libpcap/README
> new file mode 100644
> index 0000000..2b6b86a
> --- /dev/null
> +++ b/test/libpcap/README
> @@ -0,0 +1,47 @@
> +ODP libpcap example
> +
> +This document explains how to test the libpcap which integrate the ODP.
> +
> +(a) Compiling the libpcap
> +
> +Must have ODP libs before compiling this example. Make sure those files
> exist:
> +    - <odp_root>/build/include/
> +    - <odp_root>/build/lib/libodp.a
> +
> +build libpcap at <odp_root>/test/libpcap/:
> +$> make
> +
> +or add ODP_HAVE_NETMAP=yes to enable the netmap support:
> +$> make ODP_HAVE_NETMAP=yes
> +
> +install to system:
> +$> sudo make install
> +
> +(b) Testing
> +
> +test it through tcpdump:
> +$> sudo ./tcpdump -ni odp:eth0
> +
> +test it through wireshark:
> +$> sudo ./wireshark -i odp:eth0
> +
> +test the tcpdump bridge:
> +$> sudo ./tcpdump -ni b:eth0,eth1
> +
> +test it through tcpdump with netmap pktio:
> +$> sudo ./tcpdump -ni netmap:eth0
> +
> +test the tcpdump bridge with netmap pktio:
> +$> sudo ./tcpdump -ni netmapb:eth0,eth1
> +
> +(c) Note
> +
> +1. Currenly system default tcpdump can't successfully do mlock which is
> needed
> +   in ODP. So this example will use self-build tcpdump instead.
> +
> +2. Same reason as tcpdump, you can use self-build wireshark if you got
> mlock
> +   related error.
> +   $> sudo apt-get install autoconf bison flex libtool libgtk2.0-dev
> libpcap-dev
> +      libc-ares-dev libsmi2-dev libgnutls-dev libgcrypt11-dev libkrb5-dev
> +      libcap2-bin libgeoip-dev libortp-dev libportaudio-dev wireshark-dev
> +   $> make wireshark
> --
> 1.8.5
>
> --
> You received this message because you are subscribed to the Google Groups
> "LNG ODP Sub-team - lng-odp@linaro.org" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to lng-odp+unsubscribe@linaro.org.
> To post to this group, send email to lng-odp@linaro.org.
> Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/.
> To view this discussion on the web visit
> https://groups.google.com/a/linaro.org/d/msgid/lng-odp/1395026059-18045-1-git-send-email-vincent.hsu%40linaro.org
> .
> For more options, visit https://groups.google.com/a/linaro.org/d/optout.
>
Maxim Uvarov March 19, 2014, 9:45 a.m. UTC | #2
is there any objection to include this patch?

Maxim.

On 03/17/2014 05:20 PM, Mike Holmes wrote:
> Vincent, if this patch makes it into ODP, we should make a bug to 
> track removing the need for note 1 and 2.
> Possibly the new Ubuntu 14.04 LTS release will fix this on April 17th.
>
>
> On 16 March 2014 23:14, Vincent Hsu <vincent.hsu@linaro.org 
> <mailto:vincent.hsu@linaro.org>> wrote:
>
>     Signed-off-by: Vincent Hsu <vincent.hsu@linaro.org
>     <mailto:vincent.hsu@linaro.org>>
>     ---
>      .gitignore                      |  3 ++
>      platform/linux-generic/Makefile |  1 +
>      test/libpcap/Makefile           | 92
>     +++++++++++++++++++++++++++++++++++++++++
>      test/libpcap/README             | 47 +++++++++++++++++++++
>      4 files changed, 143 insertions(+)
>      create mode 100644 test/libpcap/Makefile
>      create mode 100644 test/libpcap/README
>
>     diff --git a/.gitignore b/.gitignore
>     index 53454a5..ae6eb64 100644
>     --- a/.gitignore
>     +++ b/.gitignore
>     @@ -14,3 +14,6 @@ test/packet_netmap/odp_packet
>      test/api_test/odp_atomic
>      test/api_test/odp_shm
>      test/api_test/odp_ring
>     +test/libpcap/libpcap
>     +test/libpcap/tcpdump
>     +test/libpcap/wireshark
>     diff --git a/platform/linux-generic/Makefile
>     b/platform/linux-generic/Makefile
>     index c35eb07..2a09dbe 100644
>     --- a/platform/linux-generic/Makefile
>     +++ b/platform/linux-generic/Makefile
>     @@ -35,6 +35,7 @@ DOC_DIR  = ./doc
>      EXTRA_CFLAGS  += -I$(ODP_ROOT)/include
>      EXTRA_CFLAGS  += -I./include
>      EXTRA_CFLAGS  += -I./include/api
>     +EXTRA_CFLAGS  += -fPIC
>
>      ifeq ($(ODP_HAVE_NETMAP),yes)
>      EXTRA_CFLAGS  += -DODP_HAVE_NETMAP
>     diff --git a/test/libpcap/Makefile b/test/libpcap/Makefile
>     new file mode 100644
>     index 0000000..4438dbe
>     --- /dev/null
>     +++ b/test/libpcap/Makefile
>     @@ -0,0 +1,92 @@
>     +# Copyright (c) 2013, Linaro Limited
>     +# All rights reserved.
>     +#
>     +# SPDX-License-Identifier:     BSD-3-Clause
>     +
>     +LIBPCAP_REPO=http://git.linaro.org/git/people/vincent.hsu/libpcap.git
>     +LIBPCAP_DIR=libpcap
>     <http://git.linaro.org/git/people/vincent.hsu/libpcap.git%0A+LIBPCAP_DIR=libpcap>
>     +TCPDUMP_REPO=https://github.com/the-tcpdump-group/tcpdump.git
>     +TCPDUMP_DIR=tcpdump
>     <https://github.com/the-tcpdump-group/tcpdump.git%0A+TCPDUMP_DIR=tcpdump>
>     +WIRESHARK_REPO=https://code.wireshark.org/review/p/wireshark.git
>     +WIRESHARK_DIR=wireshark
>     <https://code.wireshark.org/review/p/wireshark.git%0A+WIRESHARK_DIR=wireshark>
>     +LIBPCAP_VERSION=af25cf38dd258f3f1fb5b9b4b731248f022cc732
>     +TCPDUMP_VERSION=tcpdump-4.2.1
>     +WIRESHARK_VERSION=wireshark-1.8.9
>     +
>     +.PHONY: all
>     +all: libpcap tcpdump
>     +
>     +.PHONY: update
>     +update: get_libpcap get_tcpdump
>     +
>     +.PHONY: install
>     +install: install_libpcap install_tcpdump
>     +
>     +.PHONY: clean
>     +clean: clean_libpcap clean_tcpdump
>     +
>     +.PHONY: libpcap
>     +libpcap: get_libpcap
>     +       cd $(LIBPCAP_DIR) \
>     +       && git checkout $(LIBPCAP_VERSION) \
>     +       && ./configure --with-odp=../../.. --libdir=/usr/lib
>     +       $(MAKE) -C $(LIBPCAP_DIR)
>     +
>     +.PHONY: get_libpcap
>     +get_libpcap:
>     +       if [ ! -d $(LIBPCAP_DIR) ]; then git clone $(LIBPCAP_REPO); \
>     +       else cd $(LIBPCAP_DIR); git fetch --all; fi
>     +
>     +.PHONY: install_libpcap
>     +install_libpcap:
>     +       $(MAKE) -C $(LIBPCAP_DIR) install
>     +       if [ -d $(LIBPCAP_DIR) ]; then $(MAKE) -C $(LIBPCAP_DIR)
>     install; fi
>     +
>     +.PHONY: clean_libpcap
>     +clean_libpcap:
>     +       $(MAKE) -C $(LIBPCAP_DIR) clean
>     +       if [ -d $(LIBPCAP_DIR) ]; then $(MAKE) -C $(LIBPCAP_DIR)
>     distclean; fi
>     +
>     +.PHONY: tcpdump
>     +tcpdump: get_tcpdump libpcap
>     +       cd $(TCPDUMP_DIR) \
>     +       && git checkout $(TCPDUMP_VERSION) \
>     +       && ./configure
>     +       $(MAKE) -C $(TCPDUMP_DIR)
>     +
>     +.PHONY: get_tcpdump
>     +get_tcpdump:
>     +       if [ ! -d $(TCPDUMP_DIR) ]; then git clone $(TCPDUMP_REPO); \
>     +       else cd $(TCPDUMP_DIR); git fetch --all; fi
>     +
>     +.PHONY: install_tcpdump
>     +install_tcpdump:
>     +       $(MAKE) -C $(TCPDUMP_DIR) install
>     +       if [ -d $(TCPDUMP_DIR) ]; then $(MAKE) -C $(TCPDUMP_DIR)
>     install; fi
>     +
>     +.PHONY: clean_tcpdump
>     +clean_tcpdump:
>     +       $(MAKE) -C $(TCPDUMP_DIR) clean
>     +       if [ -d $(TCPDUMP_DIR) ]; then $(MAKE) -C $(TCPDUMP_DIR)
>     distclean; fi
>     +
>     +.PHONY: wireshark
>     +wireshark: get_wireshark libpcap
>     +       cd $(WIRESHARK_DIR) \
>     +       && git checkout $(WIRESHARK_VERSION) \
>     +       && ./autogen.sh && ./configure
>     +       $(MAKE) -C $(WIRESHARK_DIR)
>     +
>     +.PHONY: get_wireshark
>     +get_wireshark:
>     +       if [ ! -d $(WIRESHARK_DIR) ]; then git clone
>     $(WIRESHARK_REPO); \
>     +       else cd $(WIRESHARK_DIR); git fetch --all; fi
>     +
>     +.PHONY: install_wireshark
>     +install_wireshark:
>     +       $(MAKE) -C $(WIRESHARK_DIR) install
>     +       if [ -d $(WIRESHARK_DIR) ]; then $(MAKE) -C
>     $(WIRESHARK_DIR) install; fi
>     +
>     +.PHONY: clean_wireshark
>     +clean_wireshark:
>     +       $(MAKE) -C $(WIRESHARK_DIR) clean
>     +       if [ -d $(WIRESHARK_DIR) ]; then $(MAKE) -C
>     $(WIRESHARK_DIR) distclean; fi
>     diff --git a/test/libpcap/README b/test/libpcap/README
>     new file mode 100644
>     index 0000000..2b6b86a
>     --- /dev/null
>     +++ b/test/libpcap/README
>     @@ -0,0 +1,47 @@
>     +ODP libpcap example
>     +
>     +This document explains how to test the libpcap which integrate
>     the ODP.
>     +
>     +(a) Compiling the libpcap
>     +
>     +Must have ODP libs before compiling this example. Make sure those
>     files exist:
>     +    - <odp_root>/build/include/
>     +    - <odp_root>/build/lib/libodp.a
>     +
>     +build libpcap at <odp_root>/test/libpcap/:
>     +$> make
>     +
>     +or add ODP_HAVE_NETMAP=yes to enable the netmap support:
>     +$> make ODP_HAVE_NETMAP=yes
>     +
>     +install to system:
>     +$> sudo make install
>     +
>     +(b) Testing
>     +
>     +test it through tcpdump:
>     +$> sudo ./tcpdump -ni odp:eth0
>     +
>     +test it through wireshark:
>     +$> sudo ./wireshark -i odp:eth0
>     +
>     +test the tcpdump bridge:
>     +$> sudo ./tcpdump -ni b:eth0,eth1
>     +
>     +test it through tcpdump with netmap pktio:
>     +$> sudo ./tcpdump -ni netmap:eth0
>     +
>     +test the tcpdump bridge with netmap pktio:
>     +$> sudo ./tcpdump -ni netmapb:eth0,eth1
>     +
>     +(c) Note
>     +
>     +1. Currenly system default tcpdump can't successfully do mlock
>     which is needed
>     +   in ODP. So this example will use self-build tcpdump instead.
>     +
>     +2. Same reason as tcpdump, you can use self-build wireshark if
>     you got mlock
>     +   related error.
>     +   $> sudo apt-get install autoconf bison flex libtool
>     libgtk2.0-dev libpcap-dev
>     +      libc-ares-dev libsmi2-dev libgnutls-dev libgcrypt11-dev
>     libkrb5-dev
>     +      libcap2-bin libgeoip-dev libortp-dev libportaudio-dev
>     wireshark-dev
>     +   $> make wireshark
>     --
>     1.8.5
>
>     --
>     You received this message because you are subscribed to the Google
>     Groups "LNG ODP Sub-team - lng-odp@linaro.org
>     <mailto:lng-odp@linaro.org>" group.
>     To unsubscribe from this group and stop receiving emails from it,
>     send an email to lng-odp+unsubscribe@linaro.org
>     <mailto:lng-odp%2Bunsubscribe@linaro.org>.
>     To post to this group, send email to lng-odp@linaro.org
>     <mailto:lng-odp@linaro.org>.
>     Visit this group at
>     http://groups.google.com/a/linaro.org/group/lng-odp/.
>     To view this discussion on the web visit
>     https://groups.google.com/a/linaro.org/d/msgid/lng-odp/1395026059-18045-1-git-send-email-vincent.hsu%40linaro.org.
>     For more options, visit
>     https://groups.google.com/a/linaro.org/d/optout.
>
>
> -- 
> You received this message because you are subscribed to the Google 
> Groups "LNG ODP Sub-team - lng-odp@linaro.org" group.
> To unsubscribe from this group and stop receiving emails from it, send 
> an email to lng-odp+unsubscribe@linaro.org 
> <mailto:lng-odp+unsubscribe@linaro.org>.
> To post to this group, send email to lng-odp@linaro.org 
> <mailto:lng-odp@linaro.org>.
> Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/.
> To view this discussion on the web visit 
> https://groups.google.com/a/linaro.org/d/msgid/lng-odp/CADz3at39i-W2%3Dws4Y0h_8%2B0xNLrkH06riaaZLhnDBvQU6QJ1%2Bw%40mail.gmail.com 
> <https://groups.google.com/a/linaro.org/d/msgid/lng-odp/CADz3at39i-W2%3Dws4Y0h_8%2B0xNLrkH06riaaZLhnDBvQU6QJ1%2Bw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/a/linaro.org/d/optout.
Maxim Uvarov March 21, 2014, 12:34 p.m. UTC | #3
Merged, thanks!

Maxim.
diff mbox

Patch

diff --git a/.gitignore b/.gitignore
index 53454a5..ae6eb64 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,6 @@  test/packet_netmap/odp_packet
 test/api_test/odp_atomic
 test/api_test/odp_shm
 test/api_test/odp_ring
+test/libpcap/libpcap
+test/libpcap/tcpdump
+test/libpcap/wireshark
diff --git a/platform/linux-generic/Makefile b/platform/linux-generic/Makefile
index c35eb07..2a09dbe 100644
--- a/platform/linux-generic/Makefile
+++ b/platform/linux-generic/Makefile
@@ -35,6 +35,7 @@  DOC_DIR  = ./doc
 EXTRA_CFLAGS  += -I$(ODP_ROOT)/include
 EXTRA_CFLAGS  += -I./include
 EXTRA_CFLAGS  += -I./include/api
+EXTRA_CFLAGS  += -fPIC
 
 ifeq ($(ODP_HAVE_NETMAP),yes)
 EXTRA_CFLAGS  += -DODP_HAVE_NETMAP
diff --git a/test/libpcap/Makefile b/test/libpcap/Makefile
new file mode 100644
index 0000000..4438dbe
--- /dev/null
+++ b/test/libpcap/Makefile
@@ -0,0 +1,92 @@ 
+# Copyright (c) 2013, Linaro Limited
+# All rights reserved.
+#
+# SPDX-License-Identifier:     BSD-3-Clause
+
+LIBPCAP_REPO=http://git.linaro.org/git/people/vincent.hsu/libpcap.git
+LIBPCAP_DIR=libpcap
+TCPDUMP_REPO=https://github.com/the-tcpdump-group/tcpdump.git
+TCPDUMP_DIR=tcpdump
+WIRESHARK_REPO=https://code.wireshark.org/review/p/wireshark.git
+WIRESHARK_DIR=wireshark
+LIBPCAP_VERSION=af25cf38dd258f3f1fb5b9b4b731248f022cc732
+TCPDUMP_VERSION=tcpdump-4.2.1
+WIRESHARK_VERSION=wireshark-1.8.9
+
+.PHONY: all
+all: libpcap tcpdump
+
+.PHONY: update
+update: get_libpcap get_tcpdump
+
+.PHONY: install
+install: install_libpcap install_tcpdump
+
+.PHONY: clean
+clean: clean_libpcap clean_tcpdump
+
+.PHONY: libpcap
+libpcap: get_libpcap
+	cd $(LIBPCAP_DIR) \
+	&& git checkout $(LIBPCAP_VERSION) \
+	&& ./configure --with-odp=../../.. --libdir=/usr/lib
+	$(MAKE) -C $(LIBPCAP_DIR)
+
+.PHONY: get_libpcap
+get_libpcap:
+	if [ ! -d $(LIBPCAP_DIR) ]; then git clone $(LIBPCAP_REPO); \
+	else cd $(LIBPCAP_DIR); git fetch --all; fi
+
+.PHONY: install_libpcap
+install_libpcap:
+	$(MAKE) -C $(LIBPCAP_DIR) install
+	if [ -d $(LIBPCAP_DIR) ]; then $(MAKE) -C $(LIBPCAP_DIR) install; fi
+
+.PHONY: clean_libpcap
+clean_libpcap:
+	$(MAKE) -C $(LIBPCAP_DIR) clean
+	if [ -d $(LIBPCAP_DIR) ]; then $(MAKE) -C $(LIBPCAP_DIR) distclean; fi
+
+.PHONY: tcpdump
+tcpdump: get_tcpdump libpcap
+	cd $(TCPDUMP_DIR) \
+	&& git checkout $(TCPDUMP_VERSION) \
+	&& ./configure
+	$(MAKE) -C $(TCPDUMP_DIR)
+
+.PHONY: get_tcpdump
+get_tcpdump:
+	if [ ! -d $(TCPDUMP_DIR) ]; then git clone $(TCPDUMP_REPO); \
+	else cd $(TCPDUMP_DIR); git fetch --all; fi
+
+.PHONY: install_tcpdump
+install_tcpdump:
+	$(MAKE) -C $(TCPDUMP_DIR) install
+	if [ -d $(TCPDUMP_DIR) ]; then $(MAKE) -C $(TCPDUMP_DIR) install; fi
+
+.PHONY: clean_tcpdump
+clean_tcpdump:
+	$(MAKE) -C $(TCPDUMP_DIR) clean
+	if [ -d $(TCPDUMP_DIR) ]; then $(MAKE) -C $(TCPDUMP_DIR) distclean; fi
+
+.PHONY: wireshark
+wireshark: get_wireshark libpcap
+	cd $(WIRESHARK_DIR) \
+	&& git checkout $(WIRESHARK_VERSION) \
+	&& ./autogen.sh && ./configure
+	$(MAKE) -C $(WIRESHARK_DIR)
+
+.PHONY: get_wireshark
+get_wireshark:
+	if [ ! -d $(WIRESHARK_DIR) ]; then git clone $(WIRESHARK_REPO); \
+	else cd $(WIRESHARK_DIR); git fetch --all; fi
+
+.PHONY: install_wireshark
+install_wireshark:
+	$(MAKE) -C $(WIRESHARK_DIR) install
+	if [ -d $(WIRESHARK_DIR) ]; then $(MAKE) -C $(WIRESHARK_DIR) install; fi
+
+.PHONY: clean_wireshark
+clean_wireshark:
+	$(MAKE) -C $(WIRESHARK_DIR) clean
+	if [ -d $(WIRESHARK_DIR) ]; then $(MAKE) -C $(WIRESHARK_DIR) distclean; fi
diff --git a/test/libpcap/README b/test/libpcap/README
new file mode 100644
index 0000000..2b6b86a
--- /dev/null
+++ b/test/libpcap/README
@@ -0,0 +1,47 @@ 
+ODP libpcap example
+
+This document explains how to test the libpcap which integrate the ODP.
+
+(a) Compiling the libpcap
+
+Must have ODP libs before compiling this example. Make sure those files exist:
+    - <odp_root>/build/include/
+    - <odp_root>/build/lib/libodp.a
+
+build libpcap at <odp_root>/test/libpcap/:
+$> make
+
+or add ODP_HAVE_NETMAP=yes to enable the netmap support:
+$> make ODP_HAVE_NETMAP=yes
+
+install to system:
+$> sudo make install
+
+(b) Testing
+
+test it through tcpdump:
+$> sudo ./tcpdump -ni odp:eth0
+
+test it through wireshark:
+$> sudo ./wireshark -i odp:eth0
+
+test the tcpdump bridge:
+$> sudo ./tcpdump -ni b:eth0,eth1
+
+test it through tcpdump with netmap pktio:
+$> sudo ./tcpdump -ni netmap:eth0
+
+test the tcpdump bridge with netmap pktio:
+$> sudo ./tcpdump -ni netmapb:eth0,eth1
+
+(c) Note
+
+1. Currenly system default tcpdump can't successfully do mlock which is needed
+   in ODP. So this example will use self-build tcpdump instead.
+
+2. Same reason as tcpdump, you can use self-build wireshark if you got mlock
+   related error.
+   $> sudo apt-get install autoconf bison flex libtool libgtk2.0-dev libpcap-dev
+      libc-ares-dev libsmi2-dev libgnutls-dev libgcrypt11-dev libkrb5-dev
+      libcap2-bin libgeoip-dev libortp-dev libportaudio-dev wireshark-dev
+   $> make wireshark