本文整理汇总了C++中BNetworkAddress::LinkLevelAddressLength方法的典型用法代码示例。如果您正苦于以下问题:C++ BNetworkAddress::LinkLevelAddressLength方法的具体用法?C++ BNetworkAddress::LinkLevelAddressLength怎么用?C++ BNetworkAddress::LinkLevelAddressLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BNetworkAddress
的用法示例。
在下文中一共展示了BNetworkAddress::LinkLevelAddressLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Port
bool
BNetworkAddress::operator<(const BNetworkAddress& other) const
{
if (Family() < other.Family())
return true;
if (Family() > other.Family())
return false;
int compare;
switch (fAddress.ss_family) {
default:
case AF_INET:
{
sockaddr_in& address = (sockaddr_in&)fAddress;
sockaddr_in& otherAddress = (sockaddr_in&)other.fAddress;
compare = memcmp(&address.sin_addr, &otherAddress.sin_addr,
sizeof(address.sin_addr));
break;
}
case AF_INET6:
{
sockaddr_in6& address = (sockaddr_in6&)fAddress;
sockaddr_in6& otherAddress = (sockaddr_in6&)other.fAddress;
compare = memcmp(&address.sin6_addr, &otherAddress.sin6_addr,
sizeof(address.sin6_addr));
break;
}
case AF_LINK:
if (LinkLevelAddressLength() < other.LinkLevelAddressLength())
return true;
if (LinkLevelAddressLength() > other.LinkLevelAddressLength())
return true;
// TODO: could compare index, and name, too
compare = memcmp(LinkLevelAddress(), other.LinkLevelAddress(),
LinkLevelAddressLength());
break;
}
if (compare < 0)
return true;
if (compare > 0)
return false;
return Port() < other.Port();
}