Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [Learning] How to use Libpcap library in Qt

    General and Desktop
    2
    3
    4827
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jafarabadi.qt last edited by

      h1. How to use Libpcap library in Qt

      h2. Getting Start

      Note that I do this in Ubuntu operating system, in Windows you can use from Winpcap library.

      • Step 1: Install libpcap using below command:
        @sudo apt-get install libpcap-dev@

      • Step 2: Run Qt Creator as super user (my Qt path: /opt/Qt5.3.1/Tools/QtCreator/bin)
        @cd /opt/Qt5.3.1/Tools/QtCreator/bin
        sudo -b ./qtcreator@

      • Step 3: Add library to project: first open [your_project_name].pro file in Qt Creator and add this line:
        @LIBS += -lpcap@

      • Step 4: (Example) Print your device(s) name:
        @#include <QDebug>
        #include <pcap.h>@
        @pcap_if *alldevs;
        pcap_if_t *d;
        char errbuf[PCAP_ERRBUF_SIZE+1];

      if (pcap_findalldevs(&alldevs,errbuf)!=-1)
      {
      QStringList retval;
      for(d=alldevs;d;d=d->next)
      qDebug()<<QString(d->name);
      }

      //more: http://www.programming-pcap.aldabaknocking.com/@

      • Step 5: Enjoy :) [Written by Ali Jafarabdi :: Qt is an awesome programming language.]
      1 Reply Last reply Reply Quote 1
      • J
        jafarabadi.qt last edited by

        as soon as posible i post new thread with Qt libraries which this thread is referred in it ;)

        1 Reply Last reply Reply Quote 0
        • N
          nasimChildOfDesert last edited by

          hi thanks for your topic, i have some more question about pcab , can u tell me how can i run this type of program in qt , in ubunto as administrator , and how to learn more??

          1 Reply Last reply Reply Quote 0
          • First post
            Last post