pcap 사용시 compile 에러발생됩니다...
글쓴이: zhangyuan / 작성시간: 수, 2007/10/31 - 1:34오후
int main(int argc, char *argv[])
{
struct bpf_program fcode;
pcap_handler printer;
char ebuf[PCAP_ERRBUF_SIZE];
int c, i, snaplen = 1514, size, packetcnt;
bpf_u_int32 myself, localnet, netmask;
unsigned char *pcap_userdata;
struct in_addr net_addr;
filter_rule = argv[1]; /* example : "src host xxx.xxx.xxx.xxx and tcp port 80" */
signal(SIGINT,sig_int);
opterr = 0;
if(argc-1 < 1) {
usage();
exit(1);
}
if (device == NULL ) {
if ( (device = pcap_lookupdev(ebuf) ) == NULL) {
perror(ebuf);
exit(-1);
}
}
fprintf(stdout, "device = %s\n", device);
pd = pcap_open_live(device, snaplen, PROMISCUOUS, 1000, ebuf);
if(pd == NULL) {
perror(ebuf);
exit(-1);
}
fprintf(stdout, "DEBUG00.\n");
#if 0
i = pcap_snapshot(pd);
if(snaplen < i) {
perror(ebuf);
exit(-1);
}
#endif
fprintf(stdout, "DEBUG01.\n");
if(pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) {
perror(ebuf);
exit(-1);
}
setuid(getuid());
fprintf(stdout, "DEBUG02.\n");
net_addr.s_addr = localnet;
fprintf(stdout, "localnet:%s\n", inet_ntoa(net_addr));
net_addr.s_addr = netmask;
fprintf(stdout, "netmask: %s.\n", inet_ntoa(net_addr));
if(pcap_compile(pd, &fcode, filter_rule, 0, localnet) < 0) {
perror(ebuf);
exit(-1);
}
...
...
}===============
위와 같이 구성을 하고 실행을 해보면,
device = hme0
DEBUG00.
DEBUG01.
DEBUG02.
localnet:10.10.0.0
netmask: 255.255.0.0.
No such file or directory
이런 결과가 얻어지는데... 뭐가 문제인지 모르겠네요...
device는 제대로 인식한것 같은데... 무슨 파일에 불만이 있는것인지...
아시는분 답변 부탁드립니다..
환경은
SunOS proto 5.8 Generic_108528-17 sun4u sparc SUNW,Ultra-80
Forums:


댓글 달기