From patchwork Mon Mar 17 03:14:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Hsu X-Patchwork-Id: 26338 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5332D202E6 for ; Mon, 17 Mar 2014 03:17:33 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id g12sf21087494oah.7 for ; Sun, 16 Mar 2014 20:17:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:to:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe:content-type; bh=BgyTJtdvU9z5gDDLVSwd8v1q+/f/S5Y/sKuMwMYnKJ8=; b=hVFzNkCkTI+XefDajU6WOzqZc9lMqJ+PTX+hCz8mq7U/FyNJdTgpPjPPExo9dI2N0i iY76/yEcsYYTqDwyiVwkc0WVlz69nV5eKGT9nRn2xGFNjs7B6PPZBH73BrTYzCgAQ9ll GM1NW0Xs3HPs2lGXNZu8Kw0uK3WkujeHfwaZGuBYWmsYZSspg3NkDitnFkzLVynBpHKy 6xcFON3OqgOdVAqtvhHbD5tRAB88F+hNIRzHimwM014kq0BAHFjl1UiGHXJkwa3Sjqj5 w8DWTBr5tcEExML/T3xIm/S2YU50JYpHRCRv/hg4vh4Q0BLDArijMuMMrxifl/SfEycE CVlQ== X-Gm-Message-State: ALoCoQkpZVl0Jdv8A1d4yy2ugSPWtcnDUsu+JMO6l78V+1g4iCSHo0uID8cAxWvRPkinwTd0LaUT X-Received: by 10.182.98.230 with SMTP id el6mr8511599obb.10.1395026252738; Sun, 16 Mar 2014 20:17:32 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: lng-odp@linaro.org Received: by 10.50.66.208 with SMTP id h16ls792469igt.8.gmail; Sun, 16 Mar 2014 20:17:32 -0700 (PDT) X-Received: by 10.66.65.204 with SMTP id z12mr23335117pas.60.1395026252334; Sun, 16 Mar 2014 20:17:32 -0700 (PDT) Received: from mail-pb0-f46.google.com (mail-pb0-f46.google.com [209.85.160.46]) by mx.google.com with ESMTPS id zm8si8857285pac.235.2014.03.16.20.17.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 16 Mar 2014 20:17:32 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.46 is neither permitted nor denied by best guess record for domain of vincent.hsu@linaro.org) client-ip=209.85.160.46; Received: by mail-pb0-f46.google.com with SMTP id rq2so5118855pbb.33 for ; Sun, 16 Mar 2014 20:17:32 -0700 (PDT) X-Received: by 10.66.181.70 with SMTP id du6mr23031288pac.23.1395026251908; Sun, 16 Mar 2014 20:17:31 -0700 (PDT) Received: from team1.fj ([124.219.7.128]) by mx.google.com with ESMTPSA id fn2sm64754105pab.38.2014.03.16.20.17.30 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 16 Mar 2014 20:17:31 -0700 (PDT) From: Vincent Hsu To: lng-odp@linaro.org Subject: [lng-odp] [PATCHv6] test: add libpcap example Date: Mon, 17 Mar 2014 11:14:19 +0800 Message-Id: <1395026059-18045-1-git-send-email-vincent.hsu@linaro.org> X-Mailer: git-send-email 1.8.5 X-Original-Sender: vincent.hsu@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.46 is neither permitted nor denied by best guess record for domain of vincent.hsu@linaro.org) smtp.mail=vincent.hsu@linaro.org Precedence: list Mailing-list: list lng-odp@linaro.org; contact lng-odp+owners@linaro.org List-ID: X-Google-Group-Id: 474323889996 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Signed-off-by: Vincent Hsu --- .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: + - /build/include/ + - /build/lib/libodp.a + +build libpcap at /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