Problem with pcap programmin

Hi
I want to capture packet with library,for the first step,I have compile this simple code,that I derived from example of tcpdump official site.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <stdio.h>
#include <pcap.h>
#define BUFFER_SIZE 100
#define BUFFER_PACKET 100

int main ()

{
	pcap_t *handle;
	char *dev="eth0";
	char Error_Buffer[BUFFER_SIZE];
	char *Filter = "port 80";
	struct bpf_program BPF_Filter;
	bpf_u_int32 net;
	bpf_u_int32 mask;
        printf("KKKKKKKK\n");
	struct pcap_pkthdr header;
	const u_char *packet;
	pcap_lookupnet(dev, &net, &mask, Error_Buffer);



	handle = pcap_open_live(dev,BUFFER_PACKET,1,0,Error_Buffer);
	pcap_compile (handle,&BPF_Filter,Filter,0,net);
	pcap_setfilter(handle,&BPF_Filter);
	packet = pcap_next(handle, &header);

	 /* Print its length */
	    printf("Jacked a packet with length of [%d]\n", header.len);

	    /* And close the session */
	    pcap_close(handle);
	    return(0);


}


I have compiled it without any problem,but when I run it,it will be run without any result.so I had to run it in gdb,after debug it, I got this error:

1
2
3
__printf (format=0x40091d "KKKKK") at printf.c:30
30      printf.c: No such file or directory.
        in printf.c

and
1
2
3
_IO_vfprintf_internal (s=0x7ffff7ba3780, format=0x40091d "KKKKK", ap=0x7fffffffe0b0) at vfprintf.c:245
245     vfprintf.c: No such file or directory.
        in vfprintf.c


and also for another function of pcap library:
1
2
3
4
5
27              pcap_lookupnet(dev, &net, &mask, Error_Buffer);
(gdb) step
pcap_lookupnet (device=0x400900 "eth0", netp=0x7fffffffe1ac, maskp=0x7fffffffe1a8, errbuf=0x7fffffffe1c0 "0\342\377\377\377\177") at ./inet.c:689
689     ./inet.c: No such file or directory.
        in ./inet.c


Unfortunately I could not find any solution for that yet.

Thanks for any help or guidance
Topic archived. No new replies allowed.