我正在尝试使用Cygwin在Windows 7中编译此项目(https://github.com/alfchen/QoETrafficAnalyzer)。在Linux中我没有问题,但我在Windows中需要它。我按照此处包含的步骤安装了winpcap:help installing libpcap on cygwin。但是,我还有问题。我知道该项目使用arpa / inet.h并且在windows下你必须使用winsock2.h,但改变它并没有解决任何问题。现在我有以下错误。我希望有人可以帮助我。
$ 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
答案 0 :(得分:0)
在cygwin上,结构在struct tcphdr {
u_int16_t th_sport; /* source port */
u_int16_t th_dport; /* destination port */
tcp_seq th_seq; /* sequence number */
tcp_seq th_ack; /* acknowledgement number */
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int th_x2:4, /* (unused) */
th_off:4; /* data offset */
#endif
#if __BYTE_ORDER == __BIG_ENDIAN
unsigned int th_off:4, /* data offset */
th_x2:4; /* (unused) */
#endif
u_int8_t th_flags;
#define TH_FIN 0x01
#define TH_SYN 0x02
#define TH_RST 0x04
#define TH_PUSH 0x08
#define TH_ACK 0x10
#define TH_URG 0x20
#define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG)
u_int16_t th_win; /* window */
u_int16_t th_sum; /* checksum */
u_int16_t th_urp; /* urgent pointer */
};
上定义
其内容是:
from_json
请注意,大部分cygwin内部都来自BSD,而不是来自Linux 在这种情况下,两个结构不匹配。