本文整理汇总了C++中IP::id方法的典型用法代码示例。如果您正苦于以下问题:C++ IP::id方法的具体用法?C++ IP::id怎么用?C++ IP::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IP
的用法示例。
在下文中一共展示了IP::id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_equals
void IPTest::test_equals(const IP &ip1, const IP &ip2) {
EXPECT_EQ(ip1.dst_addr(), ip2.dst_addr());
EXPECT_EQ(ip1.src_addr(), ip2.src_addr());
EXPECT_EQ(ip1.id(), ip2.id());
EXPECT_EQ(ip1.frag_off(), ip2.frag_off());
EXPECT_EQ(ip1.tos(), ip2.tos());
EXPECT_EQ(ip1.ttl(), ip2.ttl());
EXPECT_EQ(ip1.version(), ip2.version());
EXPECT_EQ((bool)ip1.inner_pdu(), (bool)ip2.inner_pdu());
}
示例2:
TEST_F(IPTest, DefaultConstructor) {
IP ip;
EXPECT_EQ(ip.dst_addr(), "0.0.0.0");
EXPECT_EQ(ip.src_addr(), "0.0.0.0");
EXPECT_EQ(ip.version(), 4);
EXPECT_EQ(ip.id(), 1);
EXPECT_EQ(ip.pdu_type(), PDU::IP);
}
示例3: sniff_callback
bool sniff_callback(PDU &pdu) {
const IP &ip = pdu.rfind_pdu<IP>();
ttl_map::const_iterator iter;
// Fetch the IP PDU attached to the ICMP response
const IP inner_ip = pdu.rfind_pdu<RawPDU>().to<IP>();
// Critical section
{
std::lock_guard<std::mutex> _(lock);
iter = ttls.find(inner_ip.id());
}
// It's an actual response
if(iter != ttls.end()) {
// Store it
results[inner_ip.id()] = ip.src_addr();
}
return running;
}
示例4: send_packets
void send_packets(PacketSender &sender) {
// ICMPs are icmp-requests by default
IP ip = IP(addr, iface.addresses().ip_addr) / ICMP();
// We'll find at most 10 hops.
for(auto i = 1; i <= 10; ++i) {
// Set this "unique" id
ip.id(i);
// Set the time-to-live option
ip.ttl(i);
// Critical section
{
std::lock_guard<std::mutex> _(lock);
ttls[i] = i;
}
sender.send(ip);
// Give him a little time
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
running = false;
sender.send(ip);
}