本文整理汇总了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());
}
示例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());
}
示例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());
}
示例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()
);
}
示例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());
}
示例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);
}