您好,我在从 WinPcap 驱动程序获取网卡地址信息时遇到问题。我注意到,每当为特定 NIC 启用 IPv6 时,它的地址信息就会变为 0.0.0.0。我怎样才能解决这个问题?
pcap_addr* address = GetDeviceAddress(1);
cout<<"IP address "<<iptos(((struct sockaddr_in *)address->addr)->sin_addr.s_addr)<<endl;
/////////////
pcap_addr* GetDeviceAddress(int index)//Gets the name of a device using the zero based index of its location in the list
{
int i=0;
if(pcap_findalldevs_ex(PCAP_SRC_IF_STRING,NULL,&AllDevices,errbuf) != -1)
for(Iterator=AllDevices;Iterator!=NULL;Iterator=Iterator->next)
{
if(i==index)
{
return Iterator->addresses;
}
i++;
}
return NULL;
}