8 #include <QWaitCondition>
18 #include <sys/types.h>
19 #include <sys/socket.h>
20 #include <netinet/in.h>
21 #include <arpa/inet.h>
22 #include "ethernet_hdr.h"
31 #define SIZE_ETHERNET 14
66 Sniffer(QWaitCondition *pw, QMutex *mx,
int *ps) ;
139 void resultReady(
unsigned long index);
143 vector<ip_packet> packet_list ;
144 QWaitCondition *wait_pause ;
184 got_packet(
const struct pcap_pkthdr *header,
const u_char *packet);
void got_packet(const struct pcap_pkthdr *header, const u_char *packet)
Disects the received packet. Takes out the info needed.
Definition: sniffer.cpp:394
string format_payload(const char *payload, int len)
Formats the payload from a byte stream into a string of ascci.
Definition: sniffer.cpp:342
~Sniffer()
Destructor, does nothing.
Definition: sniffer.cpp:35
void process()
The sniffer is run as a separate thread and the function process is the main function of the thread...
Definition: sniffer.cpp:45
void print_hex_ascii_line(const u_char *payload, int len, int offset)
Prints to std output the a payload in ascii.
Definition: sniffer.cpp:157
void print_payload(const u_char *payload, int len)
Prints the payload in ascii.
Definition: sniffer.cpp:278
void setDevice(string)
Sets the device to capture packets to dev.
Definition: sniffer.cpp:561
vector< ip_packet > * getPacketList()
Returns the packet list that contains the packets that are Ethernet -> IP -> (TCP|UDP) ...
Definition: sniffer.cpp:520
void find_devices(vector< string > &)
Find the network devices in the computer, and store them in vector devs.
Definition: sniffer.cpp:533
Sniffer()
Constructor, does nothing.
Definition: sniffer.cpp:8
string format_hex_ascii_line(const char *payload, int len, int offset)
Return string with the bytes of a payload line in ascii.
Definition: sniffer.cpp:219
The Sniffer class is the one that use the pcap library to extract the packet information. It discards any packet that is not Ethernet->IP->(TCP|UDP), and pass up to the GUI the packets that are Ethernet->IP->(TCP|UDP).
Definition: sniffer.h:40