tcpdump交叉编译和使用

 

1. 下载源码

http://www.tcpdump.org/

libpcap-1.7.4

tcpdump-4.7.4

2. 编译

 

<pre name="code" class="plain">#!/bin/sh

INSTALL_DIR=$(echo `pwd`/install)
#export LDFLAGS="-L${PREFIX_PATH}/lib -L${PREFIX_PATH}/usr/lib -ldl -lm"
#export CC=$GCC
#export CPPFLAGS="-I${PREFIX_PATH}/usr/include -I${PREFIX_PATH}/include"
#export CXXFLAGS="-I${PREFIX_PATH}/usr/include -I${PREFIX_PATH}/include"
#export CFLAGS="-I${PREFIX_PATH}/usr/include -I${PREFIX_PATH}/include"
#export CXX=$CPP
#export PATH=$PATH:${GCC_PATH}
export AR=mips-linux-ar
export CC=mips-linux-gcc
export CXX=mips-linux-g++
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$INSTALL_DIR

function make_libpcap()
{
        app=libpcap-1.7.4
        #rm -rf $app
        #tar vfx $app.tar.gz
        cd $app                                                                                                                                                                                                       

        ./configure --prefix=`pwd`/../install --host=mips-linux --with-pcap=linux

        if [ x"$?" != x"0" ];then
                echo "$app configure failed"
                exit 1
        fi  

        make
        if [ x"$?" != x"0" ]; then 
                echo "$app make failed"
                exit 1
        fi  

        make install
        if [ x"$?" != x"0" ]; then 
                echo "$app make install failed"
                exit 1
        fi  

        cd -
}

function make_tcpdump()
{
        app=tcpdump-4.7.4
        #rm -rf $app
        #tar vfx $app.tar.gz
        cd $app

        ./configure --prefix=`pwd`/../install --host=mips-linux 

        if [ x"$?" != x"0" ];then
                echo "$app configure failed"
                exit 1
        fi

        make
        if [ x"$?" != x"0" ]; then 
                echo "$app make failed"
                exit 1
        fi

        make install
        if [ x"$?" != x"0" ]; then 
                echo "$app make install failed"
                exit 1
        fi

        cd -
}

sudo apt-get install byacc
sudo apt-get install flex
make_libpcap
make_tcpdump
 

 

 

 

3. 运行

tcpdump -i wlan1 -w tcpdump.pcap

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值