本文整理汇总了C++中IPAddress::isIPv4Mapped方法的典型用法代码示例。如果您正苦于以下问题:C++ IPAddress::isIPv4Mapped方法的具体用法?C++ IPAddress::isIPv4Mapped怎么用?C++ IPAddress::isIPv4Mapped使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPAddress
的用法示例。
在下文中一共展示了IPAddress::isIPv4Mapped方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
// public
bool operator==(const IPAddress& addr1, const IPAddress& addr2) {
if (addr1.family() == addr2.family()) {
if (addr1.isV6()) {
return (addr1.asV6() == addr2.asV6());
} else if (addr1.isV4()) {
return (addr1.asV4() == addr2.asV4());
} else {
CHECK_EQ(addr1.family(), AF_UNSPEC);
// Two default initialized AF_UNSPEC addresses should be considered equal.
// AF_UNSPEC is the only other value for which an IPAddress can be
// created, in the default constructor case.
return true;
}
}
// addr1 is v4 mapped v6 address, addr2 is v4
if (addr1.isIPv4Mapped() && addr2.isV4()) {
if (IPAddress::createIPv4(addr1) == addr2.asV4()) {
return true;
}
}
// addr2 is v4 mapped v6 address, addr1 is v4
if (addr2.isIPv4Mapped() && addr1.isV4()) {
if (IPAddress::createIPv4(addr2) == addr1.asV4()) {
return true;
}
}
// we only compare IPv4 and IPv6 addresses
return false;
}