|
编译通过不了,大家帮忙看一下
1 #include<stdio.h>
2 #include<sys/types.h>
3 #include<sys/time.h>
4 #include<sys/socket.h>
5 #include<netinet/in.h>
6 #include<netinet/in_systm.h>
7 #include<netinet/ip.h>
8 #include<netinet/if_ether.h>
9 #include<pcap.h>
10 #define DEFAULT_SNAPLEN 68
11 #define MAXSTRINGSIZEWWW 256
12
13 void packet_print(u_char *user,const struct pcap_pkthdr *h,const u_char *p)
14 {
15 struct ip *iph;
16 struct tcphdr *tcph;
17 struct udphdr *udph;
18 u_short srcport,dstport;
19 char protocol[MAXSTRINGSIZEWWW];
20 char srcp[MAXSTRINGSIZEWWW],dstp[MAXSTRINGSIZEWWW];
21
22 if(ntohs(((struct ether_header *)p)->ether_type) == ETHERTYPE_IP){
23 iph = (struct ip *)(p + sizeof(struct ether_header));
24 if(iph->ip_p == IPPROTO_IP){
25 strcpy(protocol,"tcp");
26 tcph = (struct tcphdr *)(p + sizeof(struct ether_header) + 4 * iph->ip_hl);
27 srcport = ntohs(tcph->source);
28 dstport = ntohs(tcph->dest);
29 }else if(iph->ip_p == IPPROTO_UDP){
30 strcpy(protocol,"udp");
31 udph = (struct udphdr *)(p + sizeof(struct ether_header) + 4 * iph->ip_hl);
32 srcport = ntohs(udph->source);
33 dstport = ntohs(udph->dest);
34 }else{
35 strcpy(protocol,"---");
36 srcport = dstport = 0;
37 }
.....................
ERROR:
eth_txt.c: In function `packet_print':
eth_txt.c:27: dereferencing pointer to incomplete type
eth_txt.c:28: dereferencing pointer to incomplete type
eth_txt.c:32: dereferencing pointer to incomplete type
eth_txt.c:33: dereferencing pointer to incomplete type |
|