本文整理汇总了C++中BNetworkAddress::SockAddr方法的典型用法代码示例。如果您正苦于以下问题:C++ BNetworkAddress::SockAddr方法的具体用法?C++ BNetworkAddress::SockAddr怎么用?C++ BNetworkAddress::SockAddr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BNetworkAddress
的用法示例。
在下文中一共展示了BNetworkAddress::SockAddr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_ifaliasreq
status_t
BNetworkInterface::AddAddress(const BNetworkAddress& local)
{
BNetworkInterfaceAddress address;
address.SetAddress(local.SockAddr());
return do_ifaliasreq(Name(), B_SOCKET_ADD_ALIAS, address);
}
示例2: do_request
status_t
BNetworkInterface::RemoveAddress(const BNetworkAddress& address)
{
ifreq request;
memcpy(&request.ifr_addr, &address.SockAddr(), address.Length());
return do_request(address.Family(), request, Name(), B_SOCKET_REMOVE_ALIAS);
}
示例3: AddRoute
status_t
BNetworkInterface::AddDefaultRoute(const BNetworkAddress& gateway)
{
route_entry route;
memset(&route, 0, sizeof(route_entry));
route.flags = RTF_STATIC | RTF_DEFAULT | RTF_GATEWAY;
route.gateway = const_cast<sockaddr*>(&gateway.SockAddr());
return AddRoute(route);
}
示例4: closer
int32
BNetworkInterface::FindAddress(const BNetworkAddress& address)
{
int socket = ::socket(address.Family(), SOCK_DGRAM, 0);
if (socket < 0)
return -1;
FileDescriptorCloser closer(socket);
ifaliasreq request;
memset(&request, 0, sizeof(ifaliasreq));
strlcpy(request.ifra_name, Name(), IF_NAMESIZE);
request.ifra_index = -1;
memcpy(&request.ifra_addr, &address.SockAddr(), address.Length());
if (ioctl(socket, B_SOCKET_GET_ALIAS, &request, sizeof(struct ifaliasreq))
< 0) {
return -1;
}
return request.ifra_index;
}