[英]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.h
被libnet.h
或pcap.h
- 似乎不再是這種情況,您必須自己包含netinet/tcp.h
struct tcphdr
以用於struct tcphdr
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.