/**
* @brief 验证是否是虚拟网卡
* @param pIpAdapterInfo 指向网卡数据的指针
*/
BOOL IsVirtualNetCard(const PIP_ADAPTER_INFO pIpAdapterInfo)
{
//去除有特征名的虚拟网卡
if (IsInString(strlwr(pIpAdapterInfo->Description), "virtual")) return true;
//去除有MAC的虚拟网卡 vmware
if (pIpAdapterInfo->Address[0] == 0x00 && pIpAdapterInfo->Address[1] == 0x05 && pIpAdapterInfo->Address[2] == 0x69) return true;
//去除有MAC的虚拟网卡 vmware
if (pIpAdapterInfo->Address[0] == 0x00 && pIpAdapterInfo->Address[1] == 0x0C && pIpAdapterInfo->Address[2] == 0x29) return true;
//去除有MAC的虚拟网卡 vmware
if (pIpAdapterInfo->Address[0] == 0x00 && pIpAdapterInfo->Address[1] == 0x50 && pIpAdapterInfo->Address[2] == 0x56) return true;
//去除有MAC的虚拟网卡 vmware
if (pIpAdapterInfo->Address[0] == 0x00 && pIpAdapterInfo->Address[1] == 0x1C && pIpAdapterInfo->Address[2] == 0x14) return true;
//去除有MAC的虚拟网卡 parallels
if (pIpAdapterInfo->Address[0] == 0x00 && pIpAdapterInfo->Address[1] == 0x1C && pIpAdapterInfo->Address[2] == 0x42) return true;
//去除有MAC的虚拟网卡 microsoft virtual pc
if (pIpAdapterInfo->Address[0] == 0x00 && pIpAdapterInfo->Address[1] == 0x03 && pIpAdapterInfo->Address[2] == 0xFF) return true;
//去除有MAC的虚拟网卡 virtual iron
if (pIpAdapterInfo->Address[0] == 0x00 && pIpAdapterInfo->Address[1] == 0x0F && pIpAdapterInfo->Address[2] == 0x4B) return true;
//去除有MAC的虚拟网卡 Red Hat xen , Oracle vm , xen source, novell xen
if (pIpAdapterInfo->Address[0] == 0x00 && pIpAdapterInfo->Address[1] == 0x16 && pIpAdapterInfo->Address[2] == 0x3E) return true;
//去除有MAC的虚拟网卡 virtualbox
if (pIpAdapterInfo->Address[0] == 0x08 && pIpAdapterInfo->Address[1] == 0x00 && pIpAdapterInfo->Address[2] == 0x27) return true;
return false;
}
/**
* @brief 验证是否是0.0.0.0不可用IP
* @param pIpAdapterInfo 指向网卡数据的指针
*/
BOOL IsInvalidIp(const PIP_ADAPTER_INFO pIpAdapterInfo)
{
IP_ADDR_STRING *pIpAddrString = &(pIpAdapterInfo->IpAddressList);
do
{
if (!strcmp(pIpAddrString->IpAddress.String, "0.0.0.0"))
{
return false;
}
if ((pIpAddrString = pIpAddrString->Next) == NULL)
{
return true;
}
} while (pIpAddrString);
return true;
}
/**
* @brief 验证是否是内网IP
* @param pIpAdapterInfo 指向网卡数据的指针
*/
BOOL IsIntranetIP(const PIP_ADAPTER_INFO pIpAdapterInfo)
{
IP_ADDR_STRING *pIpAddrString = &(pIpAdapterInfo->IpAddressList);
do
{
if (strncmp(pIpAddrString->IpAddress.String, "10", 2) == 0 || (strncmp(pIpAddrString->IpAddress.String, "172.16", 6) > 0 && strncmp(pIpAddrString->IpAddress.String, "172.31", 6) < 0) || strncmp(pIpAddrString->IpAddress.String, "192.168", 7) == 0)
{
return true;
}
if ((pIpAddrString = pIpAddrString->Next) == NULL)
{
return false;
}
} while (pIpAddrString);
return true;
}
2. CPP文件(代码应用演示)