Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Learning] How to use Libpcap library in Qt
QtWS25 Last Chance

[Learning] How to use Libpcap library in Qt

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 5.7k Views
  • 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 Offline
    J Offline
    jafarabadi.qt
    wrote on last edited by
    #1

    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
    1
    • J Offline
      J Offline
      jafarabadi.qt
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nasimChildOfDesert
        wrote on last edited by
        #3

        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
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved