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


C++ EthernetII::serialize方法代码示例

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


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

示例1: serialized

// Make sure that a big payload is not considered ICMP extensions
TEST_F(IPv6Test, BigEncapsulatedPacketIsNotConsideredToHaveExtensions) {
    IPv6 encapsulated = IPv6(TINS_DEFAULT_TEST_IP) / UDP(99, 12) / RawPDU(std::string(250, 'A'));
    EthernetII pkt = EthernetII() / IPv6() / ICMPv6(ICMPv6::TIME_EXCEEDED) / encapsulated;

    PDU::serialization_type buffer = pkt.serialize();
    EthernetII serialized(&buffer[0], buffer.size());
    ASSERT_EQ(encapsulated.size(), serialized.rfind_pdu<RawPDU>().payload().size());
    ASSERT_TRUE(serialized.rfind_pdu<ICMPv6>().extensions().extensions().empty());
}
开发者ID:simple555a,项目名称:libtins,代码行数:10,代码来源:ipv6.cpp

示例2: RawPDU

TEST_F(EthernetIITest, SerializePreservesGivenPayloadType) {
    EthernetII eth;
    uint32_t payload_size = 100;
    uint8_t payload[100] = {0};
    eth /= RawPDU(payload, payload_size);
    eth.payload_type(p_type);
    eth.serialize();
    EXPECT_EQ(p_type, eth.payload_type());
}
开发者ID:CityOfSolitude,项目名称:libtins,代码行数:9,代码来源:ethernetII.cpp

示例3: EthernetII

TEST_F(Dot1QTest, SerializeCraftedPacket)
{
    EthernetII pkt = EthernetII() / Dot1Q(10) / IP("192.168.1.2") / TCP(23, 45) / RawPDU("asdasdasd");
    PDU::serialization_type buffer = pkt.serialize();
    EXPECT_EQ(buffer[12], 0x81);
    EXPECT_EQ(buffer[13], 0x00);
    EthernetII pkt2(&buffer[0], buffer.size());
    const Dot1Q &q1 = pkt2.rfind_pdu<Dot1Q>();
    EXPECT_EQ(10, q1.id());
}
开发者ID:UlfWetzker,项目名称:libtins,代码行数:10,代码来源:dot1q_test.cpp

示例4: pdu

TEST_F(PPPoETest, StackedOnEthernetSerializationWithTags) {
    PPPoE pdu(expected_packet, sizeof(expected_packet));
    EthernetII eth = EthernetII() / pdu;
    PDU::serialization_type buffer = eth.serialize();
    EthernetII eth2(&buffer[0], (uint32_t)buffer.size());
    PPPoE* unserialized = eth2.find_pdu<PPPoE>();
    ASSERT_TRUE(unserialized != NULL);
    EXPECT_EQ(
        PPPoE::serialization_type(expected_packet, expected_packet + sizeof(expected_packet)),
        unserialized->serialize()
    );

}
开发者ID:prasad24582,项目名称:libtins,代码行数:13,代码来源:pppoe.cpp

示例5: extension

// Use a large buffer. This wil set the length field
TEST_F(IPv6Test, SerializePacketHavingICMPExtensionsWithLengthAndLotsOfPayload) {
    IPv6 encapsulated = IPv6(TINS_DEFAULT_TEST_IP) / UDP(99, 12) / RawPDU(std::string(250, 'A'));
    EthernetII pkt = EthernetII() / IPv6() / ICMPv6(ICMPv6::TIME_EXCEEDED) / encapsulated;
    const uint8_t payload[] = { 24, 150, 1, 1 }; 
    ICMPExtension extension(1, 1);
    ICMPExtension::payload_type ext_payload(payload, payload + sizeof(payload));
    extension.payload(ext_payload);
    pkt.rfind_pdu<ICMPv6>().extensions().add_extension(extension);

    PDU::serialization_type buffer = pkt.serialize();
    EthernetII serialized(&buffer[0], buffer.size());
    ASSERT_EQ(1, serialized.rfind_pdu<ICMPv6>().extensions().extensions().size());
    EXPECT_EQ(ext_payload, serialized.rfind_pdu<ICMPv6>().extensions().extensions().begin()->payload());
}
开发者ID:simple555a,项目名称:libtins,代码行数:15,代码来源:ipv6.cpp

示例6: EthernetII

TEST_F(PPPoETest, StackedOnEthernet) {
    EthernetII eth = EthernetII() / PPPoE();
    PDU::serialization_type buffer = eth.serialize();
    EthernetII eth2(&buffer[0], (uint32_t)buffer.size());
    ASSERT_TRUE(eth2.find_pdu<PPPoE>() != NULL);
}
开发者ID:prasad24582,项目名称:libtins,代码行数:6,代码来源:pppoe.cpp


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