Exemplo n.º 1
0
void TCPTest::test_equals(const TCP &tcp1, const TCP &tcp2) {
    EXPECT_EQ(tcp1.dport(), tcp2.dport());
    EXPECT_EQ(tcp2.sport(), tcp2.sport());
    EXPECT_EQ(tcp1.seq(), tcp2.seq());
    EXPECT_EQ(tcp1.ack_seq(), tcp2.ack_seq());
    EXPECT_EQ(tcp1.window(), tcp2.window());
    EXPECT_EQ(tcp1.checksum(), tcp2.checksum());
    EXPECT_EQ(tcp1.urg_ptr(), tcp2.urg_ptr());
    EXPECT_EQ(tcp1.data_offset(), tcp2.data_offset());
    EXPECT_EQ((bool)tcp1.inner_pdu(), (bool)tcp2.inner_pdu());
}
Exemplo n.º 2
0
Arquivo: pdu.cpp Projeto: Imva/libtins
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()));
}