i coding in c , using libpcap library. want see fields of pcap_t structure, have error :
error: dereferencing pointer incomplete type
minimal code following :
#include<stdio.h> #include<pcap/pcap.h> int main() { char errbuf[pcap_errbuf_size]; pcap_t *handle; handle=pcap_open_live("eth0", 65535, 1, 1, errbuf); printf("handle%d\n", handle->fd); pcap_close(handle); }
compilation done :
gcc test.c -lpcap
according http://www.opensource.apple.com/source/libpcap/libpcap-9/libpcap/pcap-int.h, pcap_t structure have field. libpcap included, not understand @ all.
thanks !
conclusion : olaf seems right : have error because not able access pcap_t structure. antti haapala said, pcap_t struct not defined in pcap/pcap.h in file.
i did manage wanted anyway, without access fields of structure.
problem solved, !
the -int in pcap-int.h
stands internal. you're not including header in code.
notice pcap.h
not include header, neither contain full declaration of struct pcap
; instead using forward declaration in typedef:
typedef struct pcap pcap_t;
just try:
#include <stdio.h> #include <pcap/pcap-int.h> #include <pcap/pcap.h> int main() { char errbuf[pcap_errbuf_size]; pcap_t *handle; handle=pcap_open_live("eth0", 65535, 1, 1, errbuf); printf("handle%d\n", handle->fd); pcap_close(handle); }
alas seems internal header not installed in linux nor on mac. extra-ugly hack can try copying pcap-int.h
link.
Comments
Post a Comment