[Winpcap-users] Re: question

Gianluca Varenni gianluca.varenni at cacetech.com
Wed Apr 16 22:01:28 GMT 2008

Do the samples in the wpdpack read the file you created? I'm referring to the readfile/readfile_ex.

The small amount of code that you posted seems ok to me, so either the file is corrupted or there is some error in the code that you didn't post.

Have a nice day

  ----- Original Message ----- 
  From: Golnaz Honarpisheh 
  To: gianluca.varenni at cacetech.com 
  Cc: winpcap-users at winpcap.org 
  Sent: Wednesday, April 16, 2008 10:23 AM
  Subject: question

  I have a problem in Winpcap programming. I want to write a program to open the Scapture.pcap file which I already have it from wireshark and is save file on my computer and i want to read it and print the packets for me for later processing. This is the code i have written but pcap_next_ex doesnt work,please guide me.Thanks

  #include "pcap.h"
  #include <stdio.h>
  #include <stdlib.h>
  #include <iostream>
  using namespace std;
  #define LINE_LEN 16
  void find_device(pcap_if_t **all_devices);
   main(int argc, char **argv) {
          int res,i=0;
    struct pcap{};
          char errbuf[PCAP_ERRBUF_SIZE];    /* Error string */
          pcap_t *indesc,*outdesc;
    struct pcap_pkthdr header; /* The header that pcap gives us */
    struct pcap_pkthdr pcap_header;
    const u_char *packet;  /* The actual packet */
    pcap_t *handle;   /* Session handle */
          char error[PCAP_ERRBUF_SIZE];
          FILE *capfile;
          char *capture_file;
    char *pkt_data;
          int caplen;
          int nb=0;

           pcap_t *pcap_open_offline(char *scapturefile,char *errbuf);
    /* Grab a packet*/
          int code  = pcap_next_ex(handle,&header,&packet);
          if (code < 0)
                  cout << "Error in pcap_next_ex\n";
          /* Print its length*/ 
          cout << "Jacked a packet with length of " << header->len << " bytes\n"; 


  Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20080416/a28731d2/attachment.htm

More information about the Winpcap-users mailing list