<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:10pt"><DIV>Here is my code,However i think problem is not from code because even when i make it short to open only the file i will get same error.Another thing is that evrytime i open my file in a project i have to go to project menu and settings to set manually the wincap.lib ,in this way there is no error in buil process but in run time i will get myfilename.exe error and in reports shows that message;unhandled exceptation</DIV><SPAN class=yshortcuts id=lw_1208547201_1 style="BACKGROUND: #dceeff"><FONT color=#0000ff>
<DIV><BR>#include "pcap.h"<BR>#include <stdio.h><BR>#include <stdlib.h><BR>#include <iostream><BR>using namespace std;<BR>#define LINE_LEN 16<BR>void find_device(pcap_if_t **all_devices);</DIV>
<DIV> main(int argc, char **argv) {<BR> int res,i=0;<BR> struct pcap{};<BR> char errbuf[PCAP_ERRBUF_SIZE]; /* Error string */</DIV>
<DIV> <BR> struct pcap_pkthdr *header; /* The header that pcap gives us */<BR> struct pcap_pkthdr *pcap_header;<BR> const u_char *packet; /* The actual packet */<BR> pcap_t *handle; /* Session handle */<BR> char error[PCAP_ERRBUF_SIZE];<BR> FILE *capfile;<BR> char *capture_file;<BR> char *pkt_data;<BR> int caplen;<BR> </DIV>
<DIV> pcap_t *pcap_open_offline(char *scapturefile,char *errbuf);<BR> <BR> /* Grab a packet<BR> int code = pcap_next_ex(handle,&header,&packet);<BR> if (code < 0)<BR> cout << "Error in pcap_next_ex\n";</DIV>
<DIV> /* Print its length<BR> cout << "length of packet is" << header->len << " bytes\n"; <BR> printf("%ld: \n", header->len);</DIV>
<DIV><BR> /* And close the session <BR> pcap_close(handle);<BR> return(0); */</DIV>
<DIV> /* Retrieve the packets from the file */<BR> while((res = pcap_next_ex( handle, &header, &packet)) >= 0){<BR> /* print pkt timestamp and pkt len */<BR> printf("%ld:%ld (%ld)\n", header->ts.tv_sec, header->ts.tv_usec, header->len); <BR> <BR> /* Print the packet */<BR> for (i=1; (i < header->caplen + 1 ) ; i++)<BR> {<BR> printf("%.2x ", pkt_data[i-1]);<BR> if ( (i % LINE_LEN) == 0) printf("\n");<BR>
} <BR> printf("\n\n"); <BR> } <BR> if(res == -1){<BR> printf("Error reading the packets: %s\n", pcap_geterr(handle));<BR> }<BR> <BR> return 0;</DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV></FONT></SPAN> </DIV></div><br>
<hr size=1>Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. <a href="http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ "> Try it now.</a></body></html>