help using pcap library to sniff packets
i am using pcap sample codes to create my own sniffer. i downloaded their sample sniffer and its working on windows but not on linux. i am using gcc compiler on both machines, and i have only pcap.h included.
the error is : dereferencing pointer to incomplete type. the netmask is causing the error. the netmask is the mask of the first address of the interface.u_int netmask=netmask((struct sockaddr_in*)d->addresses->netmask))->sin_addr.S_开发者_如何学JAVAun.S_addr;
any solutions?
The compiler indicating that it doesn't have the definition of struct sockaddr_in
in scope, so it can't look inside such a structure. On Linux that struct is defined in this header, which you will need to include:
#include <netinet/in.h>
精彩评论