我想使用Cygwin在Windows 7中編譯此項目(https://github.com/alfchen/QoETrafficAnalyzer)。在Linux中我沒有問題,但我需要在Windows中使用它。我按照以下步驟安裝winpcap:help installing libpcap on cygwin。但是,我仍然有問題。我知道這個項目使用arpa/inet.h,在windows下你必須使用winsock2.h,但是改變它並不能解決任何問題。現在我有以下錯誤。我希望有一個人可以幫助我。使用Cygwin編譯項目時出現錯誤
$ make
g++ -c tcpflowstat.cpp -Wno-deprecated -I include/ -o tcpflowstat.o
tcpflowstat.cpp: En la función miembro static ‘static int TCPFlowStat::isNewFlow(std::string, std::string, tcphdr*)’:
tcpflowstat.cpp:33:17: error: ‘struct tcphdr’ has no member named ‘syn’
if (tcphdr->syn==1 && tcphdr->ack!=1) return 1;
^
tcpflowstat.cpp:33:35: error: ‘struct tcphdr’ has no member named ‘ack’
if (tcphdr->syn==1 && tcphdr->ack!=1) return 1;
^
tcpflowstat.cpp: En la función miembro ‘int TCPFlowStat::isMyPacket(std::string, std::string, tcphdr*)’:
tcpflowstat.cpp:39:31: error: ‘struct tcphdr’ has no member named ‘source’
&& cltport==tcphdr->source && svrport==tcphdr->dest) \
^
tcpflowstat.cpp:39:58: error: ‘struct tcphdr’ has no member named ‘dest’
&& cltport==tcphdr->source && svrport==tcphdr->dest) \
^
tcpflowstat.cpp:42:31: error: ‘struct tcphdr’ has no member named ‘dest’
&& cltport==tcphdr->dest && svrport==tcphdr->source)) return 0;
^
tcpflowstat.cpp:42:56: error: ‘struct tcphdr’ has no member named ‘source’
&& cltport==tcphdr->dest && svrport==tcphdr->source)) return 0;
^
tcpflowstat.cpp:43:59: error: ‘struct tcphdr’ has no member named ‘source’
int pktdir=getPacketDirection(ip_src, ip_dst, tcphdr->source, tcphdr->dest);
^
tcpflowstat.cpp:43:75: error: ‘struct tcphdr’ has no member named ‘dest’
int pktdir=getPacketDirection(ip_src, ip_dst, tcphdr->source, tcphdr->dest);
^
tcpflowstat.cpp: En la función miembro ‘void TCPFlowStat::addPacket(std::string, std::string, int, tcphdr*, double, int, bool)’:
tcpflowstat.cpp:109:59: error: ‘struct tcphdr’ has no member named ‘source’
int pktdir=getPacketDirection(ip_src, ip_dst, tcphdr->source, tcphdr->dest);
^
tcpflowstat.cpp:109:75: error: ‘struct tcphdr’ has no member named ‘dest’
int pktdir=getPacketDirection(ip_src, ip_dst, tcphdr->source, tcphdr->dest);
^
tcpflowstat.cpp:110:41: error: ‘struct tcphdr’ has no member named ‘doff’
int tcpdatalen=ippayloadlen-tcphdr->doff*4;
^
tcpflowstat.cpp:174:25: error: ‘struct tcphdr’ has no member named ‘syn’
if (tcphdr->syn==1 && tcphdr->ack!=1){
^
tcpflowstat.cpp:174:43: error: ‘struct tcphdr’ has no member named ‘ack’
if (tcphdr->syn==1 && tcphdr->ack!=1){
^
tcpflowstat.cpp:178:33: error: ‘struct tcphdr’ has no member named ‘source’
cltport=tcphdr->source;
^
tcpflowstat.cpp:179:33: error: ‘struct tcphdr’ has no member named ‘dest’
svrport=tcphdr->dest;
^
tcpflowstat.cpp:180:32: error: ‘struct tcphdr’ has no member named ‘seq’
cltseq=tcphdr->seq;
^
tcpflowstat.cpp:181:35: error: ‘struct tcphdr’ has no member named ‘seq’
svrackseq=tcphdr->seq+1; cltinitseq=tcphdr->seq+1;
^
tcpflowstat.cpp:181:61: error: ‘struct tcphdr’ has no member named ‘seq’
svrackseq=tcphdr->seq+1; cltinitseq=tcphdr->seq+1;
^
tcpflowstat.cpp:192:25: error: ‘struct tcphdr’ has no member named ‘syn’
if (tcphdr->syn==1 && tcphdr->ack==1 && tcphdr->ack_seq==svrackseq){
^
tcpflowstat.cpp:192:43: error: ‘struct tcphdr’ has no member named ‘ack’
if (tcphdr->syn==1 && tcphdr->ack==1 && tcphdr->ack_seq==svrackseq){
^
tcpflowstat.cpp:192:61: error: ‘struct tcphdr’ has no member named ‘ack_seq’
if (tcphdr->syn==1 && tcphdr->ack==1 && tcphdr->ack_seq==svrackseq){
^
tcpflowstat.cpp:195:32: error: ‘struct tcphdr’ has no member named ‘seq’
svrseq=tcphdr->seq;
^
tcpflowstat.cpp:196:35: error: ‘struct tcphdr’ has no member named ‘seq’
cltackseq=tcphdr->seq+1; svrinitseq=tcphdr->seq+1;
^
tcpflowstat.cpp:196:61: error: ‘struct tcphdr’ has no member named ‘seq’
cltackseq=tcphdr->seq+1; svrinitseq=tcphdr->seq+1;
^
tcpflowstat.cpp:197:32: error: ‘struct tcphdr’ has no member named ‘ack_seq’
cltseq=tcphdr->ack_seq;
^
tcpflowstat.cpp:202:30: error: ‘struct tcphdr’ has no member named ‘syn’
else if (tcphdr->syn==1 && tcphdr->ack!=1 && pktdir==PKTSENDER_SVR){
^
tcpflowstat.cpp:202:48: error: ‘struct tcphdr’ has no member named ‘ack’
else if (tcphdr->syn==1 && tcphdr->ack!=1 && pktdir==PKTSENDER_SVR){
^
tcpflowstat.cpp:205:32: error: ‘struct tcphdr’ has no member named ‘seq’
svrseq=tcphdr->seq;
^
tcpflowstat.cpp:206:35: error: ‘struct tcphdr’ has no member named ‘seq’
cltackseq=tcphdr->seq+1; svrinitseq=tcphdr->seq+1;
^
tcpflowstat.cpp:206:61: error: ‘struct tcphdr’ has no member named ‘seq’
cltackseq=tcphdr->seq+1; svrinitseq=tcphdr->seq+1;
^
tcpflowstat.cpp:211:30: error: ‘struct tcphdr’ has no member named ‘fin’
else if (tcphdr->fin==1 || tcphdr->rst==1){
^
tcpflowstat.cpp:211:48: error: ‘struct tcphdr’ has no member named ‘rst’
else if (tcphdr->fin==1 || tcphdr->rst==1){
^
tcpflowstat.cpp:220:25: error: ‘struct tcphdr’ has no member named ‘syn’
if (tcphdr->syn!=1 &&tcphdr->ack==1 && tcphdr->seq==cltseq && tcphdr->ack_seq==cltackseq){
^
tcpflowstat.cpp:220:42: error: ‘struct tcphdr’ has no member named ‘ack’
if (tcphdr->syn!=1 &&tcphdr->ack==1 && tcphdr->seq==cltseq && tcphdr->ack_seq==cltackseq){
^
tcpflowstat.cpp:220:60: error: ‘struct tcphdr’ has no member named ‘seq’
if (tcphdr->syn!=1 &&tcphdr->ack==1 && tcphdr->seq==cltseq && tcphdr->ack_seq==cltackseq){
^
tcpflowstat.cpp:220:83: error: ‘struct tcphdr’ has no member named ‘ack_seq’
if (tcphdr->syn!=1 &&tcphdr->ack==1 && tcphdr->seq==cltseq && tcphdr->ack_seq==cltackseq){
^
tcpflowstat.cpp:231:67: error: ‘struct tcphdr’ has no member named ‘source’
pktdir=getPacketDirection(ip_src, ip_dst, tcphdr->source, tcphdr->dest);
^
tcpflowstat.cpp:231:83: error: ‘struct tcphdr’ has no member named ‘dest’
pktdir=getPacketDirection(ip_src, ip_dst, tcphdr->source, tcphdr->dest);
^
tcpflowstat.cpp:234:36: error: ‘struct tcphdr’ has no member named ‘seq’
cltseq=tcphdr->seq+tcpdatalen;
^
tcpflowstat.cpp:235:39: error: ‘struct tcphdr’ has no member named ‘ack_seq’
cltackseq=tcphdr->ack_seq;
^
tcpflowstat.cpp:236:36: error: ‘struct tcphdr’ has no member named ‘ack_seq’
svrseq=tcphdr->ack_seq;
^
tcpflowstat.cpp:239:36: error: ‘struct tcphdr’ has no member named ‘seq’
svrseq=tcphdr->seq+tcpdatalen;
^
tcpflowstat.cpp:240:39: error: ‘struct tcphdr’ has no member named ‘ack_seq’
svrackseq=tcphdr->ack_seq;
^
tcpflowstat.cpp:241:36: error: ‘struct tcphdr’ has no member named ‘ack_seq’
cltseq=tcphdr->ack_seq;
^
tcpflowstat.cpp:248:25: error: ‘struct tcphdr’ has no member named ‘syn’
if (tcphdr->syn==1 && tcphdr->ack==1 && simulsyn==1){
^
tcpflowstat.cpp:248:43: error: ‘struct tcphdr’ has no member named ‘ack’
if (tcphdr->syn==1 && tcphdr->ack==1 && simulsyn==1){
^
tcpflowstat.cpp:250:54: error: ‘struct tcphdr’ has no member named ‘seq’
if (pktdir==PKTSENDER_CLT && tcphdr->seq==cltseq && tcphdr->ack_seq==cltackseq){
^
tcpflowstat.cpp:250:77: error: ‘struct tcphdr’ has no member named ‘ack_seq’
if (pktdir==PKTSENDER_CLT && tcphdr->seq==cltseq && tcphdr->ack_seq==cltackseq){
^
tcpflowstat.cpp:257:54: error: ‘struct tcphdr’ has no member named ‘seq’
if (pktdir==PKTSENDER_SVR && tcphdr->seq==svrseq && tcphdr->ack_seq==svrackseq){
^
tcpflowstat.cpp:257:77: error: ‘struct tcphdr’ has no member named ‘ack_seq’
if (pktdir==PKTSENDER_SVR && tcphdr->seq==svrseq && tcphdr->ack_seq==svrackseq){
^
tcpflowstat.cpp:277:25: error: ‘struct tcphdr’ has no member named ‘syn’
if (tcphdr->syn!=1) {
^
tcpflowstat.cpp:280:33: error: ‘struct tcphdr’ has no member named ‘seq’
if (tcphdr->seq > cltseq){
^
tcpflowstat.cpp:284:33: error: ‘struct tcphdr’ has no member named ‘seq’
if (tcphdr->seq < cltseq){
^
tcpflowstat.cpp:286:50: error: ‘struct tcphdr’ has no member named ‘seq’
int retxb=cltseq-tcphdr->seq;
^
tcpflowstat.cpp:296:33: error: ‘struct tcphdr’ has no member named ‘seq’
if (tcphdr->seq+tcpdatalen > cltseq) {
^
tcpflowstat.cpp:297:40: error: ‘struct tcphdr’ has no member named ‘seq’
cltseq=tcphdr->seq+tcpdatalen;
^
tcpflowstat.cpp:300:33: error: ‘struct tcphdr’ has no member named ‘ack_seq’
if (tcphdr->ack_seq >= cltackseq) {
^
tcpflowstat.cpp:301:43: error: ‘struct tcphdr’ has no member named ‘ack_seq’
cltackseq=tcphdr->ack_seq;
^
tcpflowstat.cpp:309:33: error: ‘struct tcphdr’ has no member named ‘seq’
if (tcphdr->seq > svrseq){
^
tcpflowstat.cpp:313:33: error: ‘struct tcphdr’ has no member named ‘seq’
if (tcphdr->seq < svrseq) {
^
tcpflowstat.cpp:314:50: error: ‘struct tcphdr’ has no member named ‘seq’
int retxb=svrseq-tcphdr->seq;
^
tcpflowstat.cpp:325:33: error: ‘struct tcphdr’ has no member named ‘seq’
if (tcphdr->seq+tcpdatalen > svrseq) {
^
tcpflowstat.cpp:326:40: error: ‘struct tcphdr’ has no member named ‘seq’
svrseq=tcphdr->seq+tcpdatalen;
^
tcpflowstat.cpp:330:33: error: ‘struct tcphdr’ has no member named ‘ack_seq’
if (tcphdr->ack_seq >= svrackseq) {
^
tcpflowstat.cpp:331:43: error: ‘struct tcphdr’ has no member named ‘ack_seq’
svrackseq=tcphdr->ack_seq;
^
tcpflowstat.cpp:337:29: error: ‘struct tcphdr’ has no member named ‘fin’
if (tcphdr->fin==1 || tcphdr->rst==1){
^
tcpflowstat.cpp:337:47: error: ‘struct tcphdr’ has no member named ‘rst’
if (tcphdr->fin==1 || tcphdr->rst==1){
^
make: *** [Makefile:25: tcpflowstat.o] Error 1
「struct tcphdr」包含哪些字段?一些操作系統定義了一個其他使用'#define'的位域。 – Jonas
@Jonas:實際上,我沒有找到結構定義的文件。它應該在頭文件中? –
我不熟悉windows,所以我不知道要包含哪個頭。您可以在http://www.binarytides.com/raw-sockets-packets-with-winpcap/ – Jonas