首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >libnids未捕获xmpp数据包

libnids未捕获xmpp数据包
EN

Stack Overflow用户
提问于 2012-11-05 20:22:55
回答 1查看 200关注 0票数 0

此程序可以检测http流等。但是它忽略了XMPP流;我不知道为什么?(我猜这是一个端口问题,但我不知道应该在哪里修复它)

以下是来自main.cpp的相关部分:

代码语言:javascript
复制
#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;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-20 16:37:20

我的pcap文件有一些关于tcp连接同步的问题。

所以上面的libnids代码片段是正确的!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13232045

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档