当前位置: 首页>>代码示例>>C++>>正文


C++ IP::inner_pdu方法代码示例

本文整理汇总了C++中IP::inner_pdu方法的典型用法代码示例。如果您正苦于以下问题:C++ IP::inner_pdu方法的具体用法?C++ IP::inner_pdu怎么用?C++ IP::inner_pdu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IP的用法示例。


在下文中一共展示了IP::inner_pdu方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

IPv4Reassembler::PacketStatus IPv4Reassembler::process(PDU& pdu) {
    IP* ip = pdu.find_pdu<IP>();
    if (ip && ip->inner_pdu()) {
        // There's fragmentation
        if (ip->is_fragmented()) {
            key_type key = make_key(ip);
            // Create it or look it up, it's the same
            Internals::IPv4Stream& stream = streams_[key];
            stream.add_fragment(ip);
            if (stream.is_complete()) {
                PDU* pdu = stream.allocate_pdu();
                // Use all field values from the first fragment
                *ip = stream.first_fragment();

                // Erase this stream, since it's already assembled
                streams_.erase(key);
                // The packet is corrupt
                if (!pdu) {
                    return FRAGMENTED;
                }
                ip->inner_pdu(pdu);
                ip->fragment_offset(0);
                ip->flags(static_cast<IP::Flags>(0));
                return REASSEMBLED;
            }
            else {
                return FRAGMENTED;
            }
        }
    }
    return NOT_FRAGMENTED;
}
开发者ID:UlfWetzker,项目名称:libtins,代码行数:32,代码来源:ip_reassembler.cpp

示例2:

IPv4Reassembler::packet_status IPv4Reassembler::process(PDU &pdu) {
    IP *ip = pdu.find_pdu<IP>();
    if(ip && ip->inner_pdu()) {
        // There's fragmentation
        if(ip->is_fragmented()) {
            // Create it or look it up, it's the same
            Internals::IPv4Stream &stream = streams[make_key(ip)];
            stream.add_fragment(ip);
            if(stream.is_complete()) {
                PDU *pdu = stream.allocate_pdu();
                // The packet is corrupt
                if(!pdu)  {
                    streams.erase(make_key(ip));
                    return FRAGMENTED;
                }
                ip->inner_pdu(pdu);
                ip->frag_off(0);
                return REASSEMBLED;
            }
            else
                return FRAGMENTED;
        }
    }
    return NOT_FRAGMENTED;
}
开发者ID:Imva,项目名称:libtins,代码行数:25,代码来源:ip_reassembler.cpp

示例3: 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());
}
开发者ID:DaTrollMon,项目名称:libtins,代码行数:10,代码来源:ip.cpp

示例4: IP

TEST_F(PDUTest, OperatorConcat) {
    std::string raw_payload = "Test";
    IP ip = IP("192.168.0.1") / TCP(22, 52) / RawPDU(raw_payload); 
    EXPECT_EQ(ip.dst_addr(), "192.168.0.1"); 
    ASSERT_TRUE(ip.inner_pdu() != NULL);
    TCP *tcp = ip.find_pdu<TCP>();
    ASSERT_TRUE(tcp != NULL);
    EXPECT_EQ(tcp->dport(), 22);
    EXPECT_EQ(tcp->sport(), 52);
    ASSERT_TRUE(tcp->inner_pdu() != NULL);
    RawPDU *raw = tcp->find_pdu<RawPDU>();
    ASSERT_TRUE(raw != NULL);
    ASSERT_EQ(raw->payload_size(), raw_payload.size());
    EXPECT_TRUE(std::equal(raw_payload.begin(), raw_payload.end(), raw->payload().begin()));
}
开发者ID:Imva,项目名称:libtins,代码行数:15,代码来源:pdu.cpp

示例5: strip_rr

static void strip_rr(IP& ip, const RR& rr) {
    //cout << "Stripping RR table" << endl;
    RawPDU raw = RawPDU(&rr.payload()[0], rr.payload().size());
    ip.inner_pdu(raw);
    ip.protocol(rr.original_protocol());
}
开发者ID:benmcmorran,项目名称:aitf,代码行数:6,代码来源:main.c

示例6: create_rr

static void create_rr(IP& ip) {
    //cout << "Creating RR table" << endl;
    std::vector<uint8_t> payload = ip.serialize_inner();
    RR newRR(ip.protocol(), 5, &payload[0], payload.size());
    ip.inner_pdu(newRR);
}
开发者ID:benmcmorran,项目名称:aitf,代码行数:6,代码来源:main.c


注:本文中的IP::inner_pdu方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。