Installation of Pcap

Source: Internet
Author: User

Pcap, the packet Capture library, grabs the package library and provides a high-level interface to the capture system. All packets on the network, even those sent to other hosts, can be captured through this mechanism. It also supports saving captured packets as local files and reading information from local files.

There are a few more details to refer to: http://baike.baidu.com/view/6584893.htm

  Some introductions of Libpcap, http://baike.baidu.com/view/1319961.htm

And this is libpcap download information http://www.tcpdump.org/release/

There are some steps or installation errors that can be referred to here: http://blog.csdn.net/cfjtaishan/article/details/7096085

To summarize:

1, install the GCC compiler (if installed, you can avoid)

  2, Libpcap has some dependent packages, so you have to install the GNU M4,bison and flex in turn before installing Libpacap:sudo apt-get install flex and sudo apt-get Install Bison )

3, the download of these several installation package extracted to the same directory, the terminal under the root identity in turn into the above 4 folders. Perform the following command to compile the installation, respectively:
      ./configure
Make
Make install

  4, test code (turn from: http://hi.baidu.com/amauri3389/item/0982a400359cb9d51ef04668)

      

#include <stdio.h>Int main () {char *dev,errbuf[    1024pcap_lookupdev (ERRBUF); if (Dev==null) {fprintf (stderr,  "coundn ' t find default device:%s \n ",errbuf); return 2 "device:%s \n" ,dev); return 0    

Compile: gcc-o test Test.c-lpcap (may appear

                  HERE.C: In the function ' main ':
Here.c:12:5: Warning: Assigning integers to pointers, not type conversions [enabled by default]

Message, leave it, and proceed to the next step.)

Execution: When executing, the password is also entered as root, sudo su
    The./test executes the generated executable file test.

Next comes the problem that I have encountered:

Tip: Error while loading shared Libraries:libpcap.so.1:cannot open Shared object file:no such file or DIRECTORY

Workaround: Open the file ld.so.conf in the/etc directory and add two lines
          /usr/local/lib
/usr/lib

then execute the commands from the new load configuration under the terminal: ldconfig

OK, then compile and run test.c successfully output the result:
       Device:eth0
If not executed as root, the output will be:
        Couldn ' t find default Device:no suitable device found

Attached: Some bison reference and study materials: Http://zh.wikipedia.org/wiki/GNU_bison

Http://wenku.baidu.com/view/6501c928bd64783e09122ba1.html

Installation of Pcap

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.