编写Winpcap的第一个程序:#pragma comment(lib, "wpcap.lib")
#pragma comment(lib, "ws2_32.lib")#include <pcap.h>
#include <stdio.h>int main(void)
{
char error_content[PCAP_ERRBUF_SIZE] = {'\0'};
struct in_addr net_ip_address;
struct in_addr net_mask_addr;
char *net_interface;
char *net_ip_string;
char *net_mask_string;
u_int32_t net_ip;
u_int32_t net_mask; net_interface = pcap_lookupdev(error_content);
printf("error:%s\n", error_content);
pcap_lookupnet(net_interface, &net_ip, &net_mask, error_content);
printf("error:%s\n", error_content);
printf("net interface: %s\n", net_interface); net_ip_address.S_un.S_addr = net_ip;
net_ip_string = inet_ntoa(net_ip_address);
printf("IP: %s\n", net_ip_string); net_mask_addr.S_un.S_addr = net_mask;
net_mask_string = inet_ntoa(net_mask_addr);
printf("net mask: %s\n", net_mask_string); return 0;
}可是程序运行的结果第一次是有一个IP,担不是我的IP,可是后来怎么允许都是如下的结果了:
D:\fll文档资料\fllproject\WinPcap\Debug>WinPcap.exe
error:
error:
net interface: \
IP: 0.0.0.0
net mask: 0.0.0.0D:\fll文档资料\fllproject\WinPcap\Debug>
请问哪里有问题呢?