LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 588|回复: 1

从IP数据包中分离TCP数据时出现的问题(利用libpcap)

[复制链接]
发表于 2004-9-11 13:31:53 | 显示全部楼层 |阅读模式
编译通过不了,大家帮忙看一下

       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
发表于 2004-9-12 01:20:04 | 显示全部楼层
这个错误估计是少头文件,你找找
15 struct ip *iph;
16 struct tcphdr *tcph;
17 struct udphdr *udph;
这几个结构在哪里定义的
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表