fancylf
驱动牛犊
驱动牛犊
  • 注册日期2007-07-29
  • 最后登录2016-06-21
  • 粉丝1
  • 关注0
  • 积分61分
  • 威望501点
  • 贡献值0点
  • 好评度23点
  • 原创分0分
  • 专家分0分
  • 社区居民
阅读:3200回复:2

求救啊,各位大侠 ,怎样用winpcap截获并分析TCP数据包

楼主#
更多 发布于:2007-10-28 16:30
在winpcap的文档里面之哟截获和分析UDP包的例子,不知道怎样截获和分析TCP包呢?问题的重点是在截获到TCP后,
怎样定位到TCP包的头部呢?在处理UDP包的时候,winpcap 在packet_handler()中用了这定位到UDP包
/* retireve the position of the ip header */
ih = (ip_header *) (pkt_data +
14); //length of ethernet header

/* retireve the position of the udp header */
ip_len = (ih- >ver_ihl & 0xf) * 4;
uh = (udp_header *) ((u_char*)ih + ip_len);

/* convert from network byte order to host byte order */
sport = ntohs( uh- >sport );
dport = ntohs( uh- >dport );
,不知道在TCP的情况如何,请各位大侠指教,不胜感激
游客

返回顶部