2017-04-07 4 views
0

Cygwin을 사용하여 Windows 7에서이 프로젝트 (https://github.com/alfchen/QoETrafficAnalyzer)를 컴파일하려고합니다. 리눅스에서는 문제가 없지만 Windows에서 필요합니다. 여기에 포함 된 단계에 따라 winpcap을 설치했습니다 : help installing libpcap on cygwin. 그러나, 나는 아직도 문제가있다. 나는이 프로젝트가 arpa/inet.h를 사용하고 있고 윈도우 아래에서 winsock2.h를 사용해야 만한다는 것을 알고 있지만 그것을 변경해도 아무 것도 해결하지 못한다. 지금은 다음과 같은 오류가 발생했습니다. 누군가가 나를 도울 수 있기를 바랍니다. 구조를 Cygwin에서에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 
+0

'struct tcphdr'에는 어떤 필드가 포함되어 있습니까? 어떤 OS는'#defined'를 사용하는 비트 필드를 정의합니다. – Jonas

+0

@Jonas : 사실, 구조체가 정의 된 파일을 찾지 못했습니다. 헤더 파일에 있어야하나요? –

+0

Windows에 익숙하지 않아 포함 할 헤더를 알 수 없습니다. http://www.binarytides.com/raw-sockets-packets-with-winpcap/ – Jonas

답변

0

/usr/include/netinet/tcp.h
그 내용에 정의되어 있습니다 :

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 */ 
}; 

하는 Cygwin에서 내부의 대부분은 BSD에서가 아니라 리눅스 에서이 경우에 찍은 것을인지 두 구조가 일치하지 않습니다.

+0

코드가/usr/include/netinet /에있는 구조체에 정의되어 있으므로 코드를 변경해 보았습니다. tcp.h하지만 작동하지 않습니다. 프로그램이 원래 리눅스 용으로 만들어 졌다면 cygwin으로 컴파일 할 수 있습니까? 내 말은, 수술 시스템 (소켓)에 매우 의존하는 것이 너무 많다는 것입니다. 제가하려고하는 것이 가능할 지 모르겠습니다. –

관련 문제