Hello all,

I have a thread that calls a pcap loop function which is then called from a class to add items to a table.

Thread class:

Qt Code:
  1. void PcapThread::startCaptureOnInterface()
  2. {
  3. int r;
  4.  
  5. while(captureOn){
  6. struct pcap_pkthdr *header;
  7. const u_char *pkt_data;
  8.  
  9. r = pcap_next_ex(descr,&header,&pkt_data);
  10.  
  11. emit addToWidget(header,pkt_data);
  12.  
  13. }
To copy to clipboard, switch view to plain text mode 

PacketTable class:

Qt Code:
  1. void PacketTable::addToWidget(struct pcap_pkthdr* pkthdr, const u_char* packet)
To copy to clipboard, switch view to plain text mode 

so far this method adds items to a table such as source IP, destination IP, packet length etc but there is no storage.

However i would like to store this in a data structure by using const u_char *packet as this is how the packet headers are declared:

Qt Code:
  1. struct ether_header *ethernet = (struct ether_header*)packet;
  2. struct iphdr *ip = (struct iphdr*)(packet + sizeof(struct ether_header));
  3. struct tcphdr *tcp = (struct tcphdr*)(packet + sizeof(struct ether_header) + sizeof(struct iphdr));
  4. payload = (u_char *)(packet + sizeof(struct ether_header) + sizeof(struct iphdr) + sizeof(struct tcphdr));
To copy to clipboard, switch view to plain text mode 

Im not sure how to go about this as i would to declare methods in a seperate class then iterate and call the methods to get data out.

Darshan