Пример #1
0
TEST_F(UDPTest, ChecksumCheck) {
    IP pkt1(checksum_packet, sizeof(checksum_packet)); 
    const UDP &udp1 = pkt1.rfind_pdu<UDP>();
    uint16_t checksum = udp1.checksum();
    
    IP::serialization_type buffer = pkt1.serialize();
    IP pkt2(&buffer[0], buffer.size());
    const UDP &udp2 = pkt2.rfind_pdu<UDP>();
    EXPECT_EQ(checksum, udp2.checksum());
    EXPECT_EQ(udp1.checksum(), udp2.checksum());
}
Пример #2
0
TEST_F(TCPTest, ChecksumCheck) {
    IP pkt1(checksum_packet, sizeof(checksum_packet)); 
    const TCP &tcp1 = pkt1.rfind_pdu<TCP>();
    uint16_t checksum = tcp1.checksum();
    
    IP::serialization_type buffer = pkt1.serialize();
    IP pkt2(&buffer[0], buffer.size());
    const TCP &tcp2 = pkt2.rfind_pdu<TCP>();
    EXPECT_EQ(checksum, tcp2.checksum());
    EXPECT_EQ(tcp1.checksum(), tcp2.checksum());
    
}
Пример #3
0
TEST_F(IPTest, StackedProtocols) {
    IP ip = IP() / TCP();
    IP::serialization_type buffer = ip.serialize();
    EXPECT_TRUE(IP(&buffer[0], buffer.size()).find_pdu<TCP>());
    
    ip = IP() / UDP();
    buffer = ip.serialize();
    EXPECT_TRUE(IP(&buffer[0], buffer.size()).find_pdu<UDP>());
    
    ip = IP() / ICMP();
    buffer = ip.serialize();
    EXPECT_TRUE(IP(&buffer[0], buffer.size()).find_pdu<ICMP>());
}