2012-11-05 3 views
0

이 프로그램은 http 흐름 등을 감지 할 수 있습니다 .... 하지만 XMPP 흐름을 무시합니다. 왜 그런지 몰라? (나는이 포트 문제가 생각,하지만 난 그것을 해결해야하는 위치 모르겠어요)libnids는 xmpp 패킷을 캡처하지 않았습니다

아래는 MAIN.CPP에서 관련 부분은 다음과 같습니다

#include <sys/types.h> 
#include <sys/socket.h> 
#include <netinet/in.h> 
#include <netinet/in_systm.h> 
#include <arpa/inet.h> 
#include <string.h> 
#include <stdio.h> 
#include "nids.h" 
#include <cstdlib> 
#include <unistd.h> 

#define int_ntoa(x) inet_ntoa(*((struct in_addr *)&x)) 

// struct tuple4 contains addresses and port numbers of the TCP connections 
// the following auxiliary function produces a string looking like 
// 10.0.0.1,1024,10.0.0.2,23 
char * 
adres (struct tuple4 addr) 
{ 
    static char buf[256]; 
    strcpy (buf, int_ntoa (addr.saddr)); 
    sprintf (buf + strlen (buf), ",%i,", addr.source); 
    strcat (buf, int_ntoa (addr.daddr)); 
    sprintf (buf + strlen (buf), ",%i", addr.dest); 
    return buf; 
} 

void 
tcp_callback (struct tcp_stream *a_tcp, void ** this_time_not_needed) 
{ 

    printf("packet captured !\n"); 

} 

int 
main() 
{ 
    // here we can alter libnids params, for instance: 
    // nids_params.n_hosts=256; 
     struct nids_chksum_ctl nochksumchk; 
     nochksumchk.netaddr = 0; 
    nochksumchk.mask = 0; 
    nochksumchk.action = NIDS_DONT_CHKSUM; 
    //char fileName[] = "/home/test.pcap"; 
     //nids_params.filename =fileName;  
    nids_register_chksum_ctl(&nochksumchk, 1); 

     char myDevice [] = "eth0"; 
     nids_params.device =myDevice; 

    if (!nids_init()) 
    { 
    fprintf(stderr,"%s\n",nids_errbuf); 
    exit(1); 
    } 
    nids_register_tcp ((void*)tcp_callback); 
    nids_run(); 
    return 0; 
} 
+0

나는 장치 이름 정확도를 테스트 했으므로 내 문제의 출처는 sth입니다. –

답변

0

내 PCAP 파일이 어떤 문제에 대한이있다 tcp 연결에서 동기화.

위의 libnids 스 니펫 코드가 맞습니다!

관련 문제