本文整理汇总了C++中QueryData::emplace_back方法的典型用法代码示例。如果您正苦于以下问题:C++ QueryData::emplace_back方法的具体用法?C++ QueryData::emplace_back怎么用?C++ QueryData::emplace_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryData
的用法示例。
在下文中一共展示了QueryData::emplace_back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: genIpv6FromIntf
void genIpv6FromIntf(const std::string& iface, QueryData& results) {
Row r;
int ifaceHlim = 0;
int ifaceRtadv = 0;
int fd = socket(AF_INET6, SOCK_DGRAM, 0);
if (fd >= 0) {
struct in6_ndireq nd;
memcpy(nd.ifname, iface.c_str(), sizeof(nd.ifname));
if (ioctl(fd, SIOCGIFINFO_IN6, &nd) >= 0) {
ifaceHlim = nd.ndi.chlim;
ifaceRtadv = nd.ndi.flags & ND6_IFF_ACCEPT_RTADV;
} else {
VLOG(1) << "Error getting information from intf: " << iface;
}
close(fd);
} else {
VLOG(1) << "Cannot open inet6 socket";
}
r["interface"] = iface;
r["hop_limit"] =
INTEGER(ifaceHlim ? ifaceHlim : getSysIpv6Config("hop_limit"));
r["rtadv_accept"] =
INTEGER(getSysIpv6Config("rtadv_accept") > 0 && ifaceRtadv);
// FreeBSD does not support some of the configurations at the interface level
for (const auto& attr : {"forwarding_enabled", "redirect_accept"}) {
r[attr] = INTEGER(getSysIpv6Config(attr));
}
results.emplace_back(std::move(r));
}
示例2: genInterfaceAddress
void genInterfaceAddress(const std::string& name,
const IP_ADAPTER_UNICAST_ADDRESS* ipaddr,
QueryData& results) {
Row r;
r["interface"] = name;
switch (ipaddr->SuffixOrigin) {
case IpSuffixOriginManual:
r["type"] = "manual";
break;
case IpSuffixOriginDhcp:
r["type"] = "dhcp";
break;
case IpSuffixOriginLinkLayerAddress:
case IpSuffixOriginRandom:
r["type"] = "auto";
break;
default:
r["type"] = "unknown";
}
if (ipaddr->Address.lpSockaddr->sa_family == AF_INET) {
ULONG mask;
ConvertLengthToIpv4Mask(ipaddr->OnLinkPrefixLength, &mask);
in_addr maskAddr;
maskAddr.s_addr = mask;
char addrBuff[INET_ADDRSTRLEN] = {0};
inet_ntop(AF_INET, &maskAddr, addrBuff, INET_ADDRSTRLEN);
r["mask"] = addrBuff;
inet_ntop(
AF_INET,
&reinterpret_cast<sockaddr_in*>(ipaddr->Address.lpSockaddr)->sin_addr,
addrBuff,
INET_ADDRSTRLEN);
r["address"] = addrBuff;
} else if (ipaddr->Address.lpSockaddr->sa_family == AF_INET6) {
in6_addr netmask;
memset(&netmask, 0x0, sizeof(netmask));
for (long i = ipaddr->OnLinkPrefixLength, j = 0; i > 0; i -= 8, ++j) {
netmask.s6_addr[j] = i >= 8 ? 0xff : (ULONG)((0xffU << (8 - i)));
}
char addrBuff[INET6_ADDRSTRLEN] = {0};
inet_ntop(AF_INET6, &netmask, addrBuff, INET6_ADDRSTRLEN);
r["mask"] = addrBuff;
inet_ntop(
AF_INET6,
&reinterpret_cast<sockaddr_in6*>(ipaddr->Address.lpSockaddr)->sin6_addr,
addrBuff,
INET6_ADDRSTRLEN);
r["address"] = addrBuff;
}
results.emplace_back(r);
}