繁体   English   中英

取消引用指向不完整类型“struct tcphdr”的指针?

[英]dereferencing pointer to incomplete type ‘struct tcphdr’?

我正在尝试从 Ubuntu 18.04 上的 NetworkSecurityTools 书中编译“示例 11-9。SYNplescan 工具的源代码”: http : //books.gigatux.nl/mirror/networksecuritytools/0596007949/networkst-CHP-11-SECT -4.html

但它说

error: dereferencing pointer to incomplete type ‘struct tcphdr’
     if (tcp->th_flags == 0x14)
            ^~

我该如何解决?

在以下变化之后,人们会发生变化,包括来来去去:

@@ -1,9 +1,12 @@
+#define _DEFAULT_SOURCE 1
 #define _BSD_SOURCE 1
 #include <stdio.h>
 #include <unistd.h>
 #include <time.h>
 #include <libnet.h>
 #include <pcap.h>
+#include <netinet/tcp.h>
+#include <netinet/ip.h>
 
 int answer = 0;            /* flag for scan timeout */
 
@@ -42,7 +45,7 @@
 int
 main (int argc, char *argv[])
 {
-  char *device = NULL;        /* device for sniffing/sending */
+  const char *device = NULL;        /* device for sniffing/sending */
   char o;            /* for option processing */
   in_addr_t ipaddr;        /* ip address to scan */
   u_int32_t myipaddr;        /* ip address of this host */

我能够编译:

gcc -Wall 1.c -lnet -lpcap

没有编译器消息。 我想一旦netinet/tcp.h libnet.hlibnet.hpcap.h - 似乎不再是这种情况,您必须自己包含netinet/tcp.h struct tcphdr以用于struct tcphdr

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM