5 void pcap_callback_wrapper(u_char *user, const struct pcap_pkthdr *phdr,
8 wtap_handler wtap_callback = NULL;
10 FILE* wtap_file(wtap *wth)
12 if (wth->file_type == WTAP_FILE_PCAP) {
13 return pcap_file(wth->pcap);
19 int wtap_file_type(wtap *wth)
21 return wth->file_type;
24 int wtap_encapsulation(wtap *wth)
26 return wth->encapsulation;
30 int wtap_snapshot_length(wtap *wth)
32 if (wth->file_type == WTAP_FILE_PCAP)
33 return pcap_snapshot(wth->pcap);
38 void wtap_close(wtap *wth)
40 if (wth->file_type == WTAP_FILE_PCAP)
41 pcap_close(wth->pcap);
46 void wtap_loop(wtap *wth, int count, wtap_handler callback, u_char* user)
50 if (wth->file_type == WTAP_FILE_PCAP) {
51 wtap_callback = callback;
52 pcap_loop(wth->pcap, count, pcap_callback_wrapper, user);
55 while (ngsniffer_read(wth)) {
57 callback(user, &wth->phdr, buffer_start_ptr(&wth->frame_buffer));
63 void pcap_callback_wrapper(u_char *user, const struct pcap_pkthdr *phdr,
66 /* struct wtap_pkthdr whdr;
67 memcpy(&whdr, phdr, sizeof(struct wtap_pkthdr));*/
68 wtap_callback(user, (struct wtap_pkthdr*) phdr, buf);