资源简介
官网上的最新版。但是不知道为什么没有4.1.3的,要是用Winpcap开发必备~
代码片段和文件信息
#ifdef _MSC_VER
/*
* we do not want the warnings about the old deprecated and unsecure CRT functions
* since these examples can be compiled under *nix as well
*/
#define _CRT_SECURE_NO_WARNINGS
#endif
#include “pcap.h“
/* prototype of the packet handler */
void packet_handler(u_char *param const struct pcap_pkthdr *header const u_char *pkt_data);
int main()
{
pcap_if_t *alldevs;
pcap_if_t *d;
int inum;
int i=0;
pcap_t *adhandle;
char errbuf[PCAP_ERRBUF_SIZE];
/* Retrieve the device list */
if(pcap_findalldevs(&alldevs errbuf) == -1)
{
fprintf(stderr“Error in pcap_findalldevs: %s\n“ errbuf);
exit(1);
}
/* Print the list */
for(d=alldevs; d; d=d->next)
{
printf(“%d. %s“ ++i d->name);
if (d->description)
printf(“ (%s)\n“ d->description);
else
printf(“ (No description available)\n“);
}
if(i==0)
{
printf(“\nNo interfaces found! Make sure WinPcap is installed.\n“);
return -1;
}
printf(“Enter the interface number (1-%d):“i);
scanf(“%d“ &inum);
if(inum < 1 || inum > i)
{
printf(“\nInterface number out of range.\n“);
/* Free the device list */
pcap_freealldevs(alldevs);
return -1;
}
/* Jump to the selected adapter */
for(d=alldevs i=0; i< inum-1 ;d=d->next i++);
/* Open the device */
/* Open the adapter */
if ((adhandle= pcap_open_live(d->name // name of the device
65536 // portion of the packet to capture.
// 65536 grants that the whole packet will be captured on all the MACs.
1 // promiscuous mode (nonzero means promiscuous)
1000 // read timeout
errbuf // error buffer
)) == NULL)
{
fprintf(stderr“\nUnable to open the adapter. %s is not supported by WinPcap\n“ d->name);
/* Free the device list */
pcap_freealldevs(alldevs);
return -1;
}
printf(“\nlistening on %s...\n“ d->description);
/* At this point we don‘t need any more the device list. Free it */
pcap_freealldevs(alldevs);
/* start the capture */
pcap_loop(adhandle 0 packet_handler NULL);
pcap_close(adhandle);
return 0;
}
/* Callback function invoked by libpcap for every incoming packet */
void packet_handler(u_char *param const struct pcap_pkthdr *header const u_char *pkt_data)
{
struct tm *ltime;
char timestr[16];
time_t local_tv_sec;
/*
* unused parameters
*/
(VOID)(param);
(VOID)(pkt_data);
/* convert the timestamp to readable format */
local_tv_sec = header->ts.tv_sec;
ltime=localtime(&local_tv_sec);
strftime( timestr sizeof timestr “%H:%M:%S“ ltime);
printf(“%s%.6d len:%d\n“ timestr header->ts.tv_usec header->len);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2010-06-25 10:10 WpdPack\
目录 0 2010-06-25 10:10 WpdPack\docs\
目录 0 2010-06-25 10:10 WpdPack\docs\html\
文件 8696 2010-06-25 10:10 WpdPack\docs\html\annotated.html
文件 6851 2010-06-25 10:10 WpdPack\docs\html\classes.html
文件 3717 2010-06-25 10:10 WpdPack\docs\html\daemon_8h.html
文件 7432 2010-06-25 10:10 WpdPack\docs\html\daemon_8h_source.html
文件 2717 2010-06-25 10:10 WpdPack\docs\html\deprecated.html
文件 1281 2010-06-25 10:10 WpdPack\docs\html\doxygen.png
文件 1458 2010-06-25 10:10 WpdPack\docs\html\doxygen__groups_8txt.html
文件 6353 2002-04-10 04:45 WpdPack\docs\html\dump.gif
文件 2777 2002-04-10 04:45 WpdPack\docs\html\encoding.gif
文件 3209 2010-06-25 10:10 WpdPack\docs\html\fileconf_8h.html
文件 5784 2010-06-25 10:10 WpdPack\docs\html\fileconf_8h_source.html
文件 3754 2010-06-25 10:10 WpdPack\docs\html\files.html
文件 174 2010-06-25 10:10 WpdPack\docs\html\ftv2blank.png
文件 255 2010-06-25 10:10 WpdPack\docs\html\ftv2doc.png
文件 259 2010-06-25 10:10 WpdPack\docs\html\ftv2folderclosed.png
文件 261 2010-06-25 10:10 WpdPack\docs\html\ftv2folderopen.png
文件 233 2010-06-25 10:10 WpdPack\docs\html\ftv2lastnode.png
文件 358 2010-06-25 10:10 WpdPack\docs\html\ftv2li
文件 160 2010-06-25 10:10 WpdPack\docs\html\ftv2mlastnode.png
文件 194 2010-06-25 10:10 WpdPack\docs\html\ftv2mnode.png
文件 235 2010-06-25 10:10 WpdPack\docs\html\ftv2node.png
文件 165 2010-06-25 10:10 WpdPack\docs\html\ftv2plastnode.png
文件 200 2010-06-25 10:10 WpdPack\docs\html\ftv2pnode.png
文件 229 2010-06-25 10:10 WpdPack\docs\html\ftv2vertline.png
文件 41059 2010-06-25 10:10 WpdPack\docs\html\funcs_2pcap_8h.html
文件 36291 2010-06-25 10:10 WpdPack\docs\html\funcs_2pcap_8h_source.html
文件 26027 2010-06-25 10:10 WpdPack\docs\html\functions.html
文件 25948 2010-06-25 10:10 WpdPack\docs\html\functions_vars.html
............此处省略319个文件信息
- 上一篇:开明标点挤压
- 下一篇:Interop.Shell32.dll
相关资源
- 整理的ModbusProtocol SDK开发包
- 海康摄像头+web3.0开发包SDK的demo
- artnet 开发包
- WinPcap+中文技术文档
- 精伦电子开发包最新开发包带网页插
- 中控指纹仪驱动和开发包
- 精伦IDR210 IDR200 2016年最新4.1通用二次
- focas2开发包
- 研腾身份证 浏览器扫描 最新开发包
- 武汉精伦身份证阅读器的二次开发包
- WinPcap4.1.1官网正式版
- 神思ss628 100 驱动及开发包
- 海康Web3.0控件开发包32位+demo
- MediaTek-AP-MT7628DAN+MT7612E硬件开发包
- 海康威视控件开发包.zip
- 解析抓包软件中tcp包装的数据并转换
- 神思SS628(100)型PB开发包+E语言测试
- WinPcap 中文技术文档(开发手册)
- HD900开发包.rar
- struts开发包
- 人脸识别SDK免费,可商用,有演示、
- 组态王6.55驱动开发包
- 网络流量统计基于Winpcap接口
- 组态王驱动开发包3.0.0.7中文
- WpdPack包
- 基于winpcap的网络数据采集器的实现
- web3.0开发包.zip
- KRF-35开发包
- QGIS2.8.9二次开发包及其桌面程序
- 超高频RFID读写器开发包
评论
共有 条评论