资源简介
WinPcap3.0版(驱动程序+开发包+帮助文档),它是一款用于Windows的开源库,用于网络抓包应用程序的开发。
代码片段和文件信息
/*
* Copyright (c) 1999 - 2002
* Politecnico di Torino. All rights reserved.
*
* Redistribution and use in source and binary forms with or without
* modification are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ‘‘This product includes software developed by the Politecnico
* di Torino and its contributors.‘‘ Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ‘‘AS IS‘‘ AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#include “pcap.h“
#ifndef WIN32
#include
#include
#else
#include
#endif
void ifprint(pcap_if_t *d);
char *iptos(u_long in);
int main()
{
pcap_if_t *alldevs;
pcap_if_t *d;
char errbuf[PCAP_ERRBUF_SIZE+1];
/* Retrieve the interfaces list */
if (pcap_findalldevs(&alldevs errbuf) == -1)
{
fprintf(stderr“Error in pcap_findalldevs: %s\n“errbuf);
exit(1);
}
/* Scan the list printing every entry */
for(d=alldevs;d;d=d->next)
{
ifprint(d);
}
return 1;
}
/* Print all the available information on the given interface */
void ifprint(pcap_if_t *d)
{
pcap_addr_t *a;
/* Name */
printf(“%s\n“d->name);
/* Description */
if (d->description)
printf(“\tDescription: %s\n“d->description);
/* Loopback Address*/
printf(“\tLoopback: %s\n“(d->flags & PCAP_IF_LOOPBACK)?“yes“:“no“);
/* IP addresses */
for(a=d->addresses;a;a=a->next) {
printf(“\tAddress Family: #%d\n“a->addr->sa_family);
switch(a->addr->sa_family)
{
case AF_INET:
printf(“\tAddress Family Name: AF_INET\n“);
if (a->addr)
printf(“\tAddress: %s\n“iptos(((struct sockaddr_in *)a->addr)->sin_addr.s_addr));
if (a->netmask)
printf(“\tNetmask: %s\n“iptos(((struct sockaddr_in *)a->netmask)->sin_addr.s_addr));
if (a->broadaddr)
printf(“\tBroadcast Address: %s\n“iptos(((struct sockaddr_in *)a->broadaddr)->sin_addr.s_addr));
if (a->dstaddr)
printf(“\tDestination Address: %s\n“iptos(((struct sockaddr_in *)a->dstaddr)->sin_addr.s_addr));
break;
default:
printf(“\tAddress Family Name: Unknown\n“);
break;
}
}
printf(“\n“);
}
/* From tcptraceroute convert a numeric IP address to a str
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 440405 2012-05-10 21:59 WinPcap3.0\winpcap_3_0_beta.exe
文件 5633 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\annotated.html
文件 4650 2002-04-10 12:45 WinPcap3.0\wpdpack\docs\html\arch.gif
文件 6407 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\bpf__dump_8c-source.html
文件 4189 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\bpf__dump_8c.html
文件 17834 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\bpf__image_8c-source.html
文件 4304 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\bpf__image_8c.html
文件 958 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\compile_8txt.html
文件 1875 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\doc-st
文件 2378 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\doxygen.gif
文件 6353 2002-04-10 12:45 WinPcap3.0\wpdpack\docs\html\dump.gif
文件 32888 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\dump_8c-source.html
文件 6826 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\dump_8c.html
文件 2777 2002-04-10 12:45 WinPcap3.0\wpdpack\docs\html\encoding.gif
文件 10904 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\etherent_8c-source.html
文件 6084 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\etherent_8c.html
文件 25815 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\fad-win32_8c-source.html
文件 8565 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\fad-win32_8c.html
文件 5329 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\files.html
文件 135 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\ftv2blank.gif
文件 144 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\ftv2doc.gif
文件 135 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\ftv2folderclosed.gif
文件 154 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\ftv2folderopen.gif
文件 142 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\ftv2lastnode.gif
文件 234 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\ftv2li
文件 125 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\ftv2mlastnode.gif
文件 129 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\ftv2mnode.gif
文件 147 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\ftv2node.gif
文件 130 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\ftv2plastnode.gif
文件 133 2002-08-08 12:43 WinPcap3.0\wpdpack\docs\html\ftv2pnode.gif
............此处省略282个文件信息
评论
共有 条评论