Porting libpcap packet capture library to arm platform under Linux

tags: linux  ubuntu  server  Telecommunication

1. Introduction

The libpcap library is installed on the x86-based Ubuntu. The predecessors have written very clearly. For details, please refer to:

as well as

If you need any dependency packages during the installation process, just apt-get install xxx related packages directly.

This article mainly introduces how to transplant libpcap library to arm platform to realize the function of grabbing network packets on arm architecture.

 

2. Start transplanting

Many porting libpcap library to arm on the Internet are all old versions such as libpcap-1.0.0, which have little reference value. This article transplants the latest version of libpcap-1.9.1, I hope it will be used for future reference.

A. Download and unzip

(1) Go to the official websitehttp://www.tcpdump.org/Download libpcap library, pay attention to download libpcap, not download tcpdump library.

(2) Unzip: tart -xvzf libpcap-1.9.1.tar.gz; then enter the libpcap-1.9.1 directory.

(3) There is no Makefile in the libpcap-1.9.1 directory. First, you need to configure it to generate a Makefile.

Enter the command: ./configure --host=arm-linux-gnueabihf --build=i686-pc-linux

In this instruction, the --build=i686-pc-linux part is for 64-bit Linux, and this parameter can be omitted.

(4) Under normal circumstances, a Makefile will be generated.

B. Modify the Makefile

(1) Open Makefile and change the value of prefix to the installation path of your cross-compiler. My installation path is:

The cross compiler installed by CC compiler (I installed arm-linux-gnueabihf-gcc):

Note: The Makefile file may have permission problems and cannot be modified, so you need to chmod 777 Makefile to change the Makefile permissions.

(2) After the Makefile is modified, make it first, and then make install.

Done appears, indicating that the installation is successful.

C. Copy of link library

If the libpacp library is successfully installed, libpcap.a and libpcap.so.1.9.1 will be generated. Copy these generated libraries to the root directory /usr/local/lib/ directory:

Because, when arm-linux-gnueabihf-gcc is compiling, it will first search for the corresponding library in the /usr/local/lib directory.

 

D. Code compilation

In your code.c directory, enter the command (if you did not write the Makefile yourself):

arm-linux-gnueabihf-gcc test.c -o test -lpcap

Can generate executable files for arm architecture:

The test is the executable file of the arm platform:

 

 

Intelligent Recommendation

Porting FFMPEG under ARM-Linux

Hello there! Here is the kite blog, Welcome to communicate with me. FFmpeg is an open source and free cross-platform video and audio streaming solution. It belongs to free software and uses the LGPL o...

Packet capture under linux

First use ifconfig to query the network card of the machine, and then modify it in the main function The enp9s0 here is what we need...

Porting Python 2.7 to ARM-LINUX embedded platform

xz -d Python-2.7.3.tar.xz tar xvf Python-2.7.3.tar Compile HOST version interpreter Compiling the embedded version of Python requires the interpreter to parse the setup.py to compile the Python module...

Using the libpcap function library to capture packets in a Linux environment

Install libpcap Reference blog: The official website to download the libpacp compression package, the official website address:Click Download the current latest version shown in the image: Unzip libpc...

Porting opencv to qt+opencv and arm under linux

Because of research, it is necessary to port opencv under Linux to use with qt, andOpencv is transplanted on the arm side. Since I encountered many problems in the process of operation, and solved the...

More Recommendation

ARM porting libcurl under linux environment

Because the board used is ZLG's imx280a, the Ubuntu I installed directly used them. System environment:VM-Ubuntu-12.04-64bit-zlg (this doesn’t matter, I installed it directly with the official Z...

SDL and extension library transplantation under arm Linux platform

Reference article:   SDL (Simple DirectMedia Layer) is a free cross-platform multimedia development kit suitable for games, game SDKs, presentation software, emulators, MPEG players and othe...

libpcap packet capture analysis project (2)

In project (1), we successfully captured the data packet and extracted the basic information in the data packet. This time we will output the various protocols used by the data packet and output the m...

libpcap packet capture analysis project (1)

First introduce the usage of libpcap library functions: Here I use two functions, pcap_open_live () and pcap_next (), you can jump through the portal to see the specific usage. The comments in the cod...

libpcap packet capture analysis project (4)

In project three, we completed the parsing of a package in the "hospital mirror stream.pcapng" file. The next thing we need to do is to write the parsed data into the file, so that the TS st...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top