mirror of
https://github.com/mfontanini/libtins
synced 2026-01-29 21:14:28 +01:00
Code cleanup and use same syntax on the entire project
Initial code cleanup More code cleanup Cleanup more code Cleanup Dot11 code Fix OSX build issue Cleanup examples Fix ref and pointer declaration syntax Fix braces
This commit is contained in:
@@ -12,12 +12,12 @@ using namespace Tins;
|
||||
|
||||
class AddressRangeTest : public testing::Test {
|
||||
public:
|
||||
void contain_tests24(const IPv4Range &range);
|
||||
void contain_tests24(const IPv6Range &range);
|
||||
void contain_tests26(const IPv4Range &range);
|
||||
void contain_tests24(const IPv4Range& range);
|
||||
void contain_tests24(const IPv6Range& range);
|
||||
void contain_tests26(const IPv4Range& range);
|
||||
};
|
||||
|
||||
void AddressRangeTest::contain_tests24(const IPv4Range &range) {
|
||||
void AddressRangeTest::contain_tests24(const IPv4Range& range) {
|
||||
EXPECT_TRUE(range.contains("192.168.0.0"));
|
||||
EXPECT_TRUE(range.contains("192.168.0.1"));
|
||||
EXPECT_TRUE(range.contains("192.168.0.254"));
|
||||
@@ -26,14 +26,14 @@ void AddressRangeTest::contain_tests24(const IPv4Range &range) {
|
||||
EXPECT_FALSE(range.contains("192.168.1.1"));
|
||||
}
|
||||
|
||||
void AddressRangeTest::contain_tests26(const IPv4Range &range) {
|
||||
void AddressRangeTest::contain_tests26(const IPv4Range& range) {
|
||||
EXPECT_TRUE(range.contains("192.168.254.192"));
|
||||
EXPECT_TRUE(range.contains("192.168.254.255"));
|
||||
EXPECT_FALSE(range.contains("192.168.254.0"));
|
||||
EXPECT_FALSE(range.contains("192.168.254.191"));
|
||||
}
|
||||
|
||||
void AddressRangeTest::contain_tests24(const IPv6Range &range) {
|
||||
void AddressRangeTest::contain_tests24(const IPv6Range& range) {
|
||||
EXPECT_TRUE(range.contains("dead::1"));
|
||||
EXPECT_TRUE(range.contains("dead::1fee"));
|
||||
EXPECT_TRUE(range.contains("dead::ffee"));
|
||||
|
||||
@@ -49,10 +49,10 @@ public:
|
||||
static const PDU::PDUType pdu_flag;
|
||||
|
||||
DummyPDU(const uint8_t* data, uint32_t sz) : buffer(data, data + sz) { }
|
||||
DummyPDU *clone() const { return new DummyPDU<n>(*this); }
|
||||
DummyPDU* clone() const { return new DummyPDU<n>(*this); }
|
||||
uint32_t header_size() const { return (uint32_t)buffer.size(); }
|
||||
PDUType pdu_type() const { return pdu_flag; }
|
||||
void write_serialization(uint8_t *data, uint32_t, const PDU *)
|
||||
void write_serialization(uint8_t* data, uint32_t, const PDU *)
|
||||
{
|
||||
std::copy(buffer.begin(), buffer.end(), data);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
static const uint8_t expected_packet[];
|
||||
static const IPv4Address addr1, addr2;
|
||||
|
||||
void test_equals(const ARP &arp1, const ARP &arp2);
|
||||
void test_equals(const ARP& arp1, const ARP& arp2);
|
||||
};
|
||||
|
||||
const address_type ARPTest::empty_addr;
|
||||
@@ -34,7 +34,7 @@ const uint8_t ARPTest::expected_packet[] = {
|
||||
};
|
||||
const IPv4Address ARPTest::addr1(0x1234), ARPTest::addr2(0xa3f1);
|
||||
|
||||
void ARPTest::test_equals(const ARP &arp1, const ARP &arp2) {
|
||||
void ARPTest::test_equals(const ARP& arp1, const ARP& arp2) {
|
||||
EXPECT_EQ(arp1.opcode(), arp2.opcode());
|
||||
ASSERT_EQ(arp1.hw_addr_length(), arp2.hw_addr_length());
|
||||
EXPECT_EQ(arp1.hw_addr_format(), arp2.hw_addr_format());
|
||||
@@ -69,7 +69,7 @@ TEST_F(ARPTest, CopyAssignmentOperator) {
|
||||
}
|
||||
|
||||
TEST_F(ARPTest, NestedCopy) {
|
||||
ARP *nested_arp = new ARP(addr1, addr2, hw_addr1, hw_addr2);
|
||||
ARP* nested_arp = new ARP(addr1, addr2, hw_addr1, hw_addr2);
|
||||
ARP arp1(addr1, addr2, hw_addr1, hw_addr2);
|
||||
arp1.inner_pdu(nested_arp);
|
||||
ARP arp2(arp1);
|
||||
|
||||
@@ -20,8 +20,8 @@ public:
|
||||
static const uint8_t sname[], file[];
|
||||
static const IPv4Address addr;
|
||||
|
||||
void test_equals(const DHCP &dhcp1, const DHCP &dhcp2);
|
||||
void test_option(const DHCP &dhcp, DHCP::OptionTypes opt, uint32_t len = 0, uint8_t *value = 0);
|
||||
void test_equals(const DHCP& dhcp1, const DHCP& dhcp2);
|
||||
void test_option(const DHCP& dhcp, DHCP::OptionTypes opt, uint32_t len = 0, uint8_t* value = 0);
|
||||
};
|
||||
|
||||
const BootP::chaddr_type DHCPTest::chaddr("16:ab:54:12:fa:ca:56:7f:1b:65:11:fa:da:ab:19:18");
|
||||
@@ -167,8 +167,8 @@ TEST_F(DHCPTest, File) {
|
||||
EXPECT_TRUE(memcmp(dhcp.file(), file, 128) == 0);
|
||||
}
|
||||
|
||||
void DHCPTest::test_option(const DHCP &dhcp, DHCP::OptionTypes opt, uint32_t len, uint8_t *value) {
|
||||
const DHCP::option *option = dhcp.search_option(opt);
|
||||
void DHCPTest::test_option(const DHCP& dhcp, DHCP::OptionTypes opt, uint32_t len, uint8_t* value) {
|
||||
const DHCP::option* option = dhcp.search_option(opt);
|
||||
ASSERT_TRUE(option != 0);
|
||||
EXPECT_EQ(option->option(), opt);
|
||||
ASSERT_EQ(option->data_size(), len);
|
||||
@@ -244,7 +244,7 @@ TEST_F(DHCPTest, BroadcastOption) {
|
||||
EXPECT_EQ(ip, dhcp.broadcast());
|
||||
}
|
||||
|
||||
void DHCPTest::test_equals(const DHCP &dhcp1, const DHCP &dhcp2) {
|
||||
void DHCPTest::test_equals(const DHCP& dhcp1, const DHCP& dhcp2) {
|
||||
EXPECT_EQ(dhcp1.opcode(), dhcp2.opcode());
|
||||
EXPECT_EQ(dhcp1.htype(), dhcp2.htype());
|
||||
ASSERT_EQ(dhcp1.hlen(), dhcp2.hlen());
|
||||
|
||||
@@ -10,7 +10,7 @@ class DHCPv6Test : public testing::Test {
|
||||
public:
|
||||
static const uint8_t expected_packet[];
|
||||
|
||||
void test_equals(const DHCPv6 &dhcp1, const DHCPv6 &dhcp2);
|
||||
void test_equals(const DHCPv6& dhcp1, const DHCPv6& dhcp2);
|
||||
};
|
||||
|
||||
const uint8_t DHCPv6Test::expected_packet[] = {
|
||||
|
||||
@@ -15,9 +15,9 @@ public:
|
||||
static const uint8_t expected_packet[], dns_response1[],
|
||||
dns_packet1[];
|
||||
|
||||
void test_equals(const DNS &dns1, const DNS &dns2);
|
||||
void test_equals(const DNS::Query &q1, const DNS::Query &q2);
|
||||
void test_equals(const DNS::Resource &q1, const DNS::Resource &q2);
|
||||
void test_equals(const DNS& dns1, const DNS& dns2);
|
||||
void test_equals(const DNS::Query& q1, const DNS::Query& q2);
|
||||
void test_equals(const DNS::Resource& q1, const DNS::Resource& q2);
|
||||
};
|
||||
|
||||
const uint8_t DNSTest::expected_packet[] = {
|
||||
@@ -45,7 +45,7 @@ const uint8_t DNSTest::dns_packet1[] = {
|
||||
|
||||
|
||||
|
||||
void DNSTest::test_equals(const DNS &dns1, const DNS &dns2) {
|
||||
void DNSTest::test_equals(const DNS& dns1, const DNS& dns2) {
|
||||
EXPECT_EQ(dns1.id(), dns2.id());
|
||||
EXPECT_EQ(dns1.type(), dns2.type());
|
||||
EXPECT_EQ(dns1.opcode(), dns2.opcode());
|
||||
@@ -66,13 +66,13 @@ void DNSTest::test_equals(const DNS &dns1, const DNS &dns2) {
|
||||
EXPECT_EQ(dns1.inner_pdu() != NULL, dns2.inner_pdu() != NULL);
|
||||
}
|
||||
|
||||
void DNSTest::test_equals(const DNS::Query &q1, const DNS::Query &q2) {
|
||||
void DNSTest::test_equals(const DNS::Query& q1, const DNS::Query& q2) {
|
||||
EXPECT_EQ(q1.dname(), q2.dname());
|
||||
EXPECT_EQ(q1.type(), q2.type());
|
||||
EXPECT_EQ(q1.query_class(), q2.query_class());
|
||||
}
|
||||
|
||||
void DNSTest::test_equals(const DNS::Resource &q1, const DNS::Resource &q2) {
|
||||
void DNSTest::test_equals(const DNS::Resource& q1, const DNS::Resource& q2) {
|
||||
EXPECT_EQ(q1.dname(), q2.dname());
|
||||
EXPECT_EQ(q1.data(), q2.data());
|
||||
EXPECT_EQ(q1.type(), q2.type());
|
||||
@@ -179,7 +179,7 @@ TEST_F(DNSTest, CopyAssignmentOperator) {
|
||||
}
|
||||
|
||||
TEST_F(DNSTest, NestedCopy) {
|
||||
DNS *nested = new DNS(expected_packet, sizeof(expected_packet));
|
||||
DNS* nested = new DNS(expected_packet, sizeof(expected_packet));
|
||||
DNS dns1(expected_packet, sizeof(expected_packet));
|
||||
dns1.inner_pdu(nested);
|
||||
DNS dns2(dns1);
|
||||
@@ -307,7 +307,7 @@ TEST_F(DNSTest, Answers) {
|
||||
TEST_F(DNSTest, Authority) {
|
||||
DNS dns;
|
||||
|
||||
const char *domain = "carlos.example.com";
|
||||
const char* domain = "carlos.example.com";
|
||||
dns.add_authority(
|
||||
DNS::Resource("www.example.com", domain, DNS::CNAME, DNS::IN, 0x762)
|
||||
);
|
||||
@@ -331,7 +331,7 @@ TEST_F(DNSTest, Authority) {
|
||||
TEST_F(DNSTest, Additional) {
|
||||
DNS dns;
|
||||
|
||||
const char *domain = "carlos.example.com";
|
||||
const char* domain = "carlos.example.com";
|
||||
dns.add_additional(
|
||||
DNS::Resource("www.example.com", domain, DNS::CNAME, DNS::IN, 0x762)
|
||||
);
|
||||
@@ -395,7 +395,7 @@ TEST_F(DNSTest, ItAintGonnaCorrupt) {
|
||||
EXPECT_EQ(dns.questions_count(), 1);
|
||||
EXPECT_EQ(dns.answers_count(), 5);
|
||||
|
||||
const char *domain = "carlos.example.com";
|
||||
const char* domain = "carlos.example.com";
|
||||
dns.add_additional(
|
||||
DNS::Resource("www.example.com", domain, DNS::CNAME, DNS::IN, 0x762)
|
||||
);
|
||||
|
||||
@@ -22,14 +22,14 @@ const uint8_t Dot11AckTest::expected_packet[] = {
|
||||
213, 1, 79, 35, 0, 1, 2, 3, 4, 5
|
||||
};
|
||||
|
||||
void test_equals(const Dot11Ack &dot1, const Dot11Ack &dot2) {
|
||||
void test_equals(const Dot11Ack& dot1, const Dot11Ack& dot2) {
|
||||
test_equals(
|
||||
static_cast<const Dot11&>(dot1),
|
||||
static_cast<const Dot11&>(dot2)
|
||||
);
|
||||
}
|
||||
|
||||
void test_equals_expected(const Dot11Ack &dot11) {
|
||||
void test_equals_expected(const Dot11Ack& dot11) {
|
||||
EXPECT_EQ(dot11.protocol(), 1);
|
||||
EXPECT_EQ(dot11.type(), Dot11::CONTROL);
|
||||
EXPECT_EQ(dot11.subtype(), Dot11::ACK);
|
||||
@@ -89,7 +89,7 @@ TEST_F(Dot11AckTest, ClonePDU) {
|
||||
TEST_F(Dot11AckTest, FromBytes) {
|
||||
Internals::smart_ptr<PDU>::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
|
||||
ASSERT_TRUE(dot11.get() != NULL);
|
||||
const Dot11Ack *inner = dot11->find_pdu<Dot11Ack>();
|
||||
const Dot11Ack* inner = dot11->find_pdu<Dot11Ack>();
|
||||
ASSERT_TRUE(inner != NULL);
|
||||
test_equals_expected(*inner);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ const uint8_t Dot11AssocRequestTest::expected_packet[] = {
|
||||
0, 0, 21, 32, 243, 146
|
||||
};
|
||||
|
||||
void test_equals(const Dot11AssocRequest &dot1, const Dot11AssocRequest &dot2) {
|
||||
void test_equals(const Dot11AssocRequest& dot1, const Dot11AssocRequest& dot2) {
|
||||
test_equals(dot1.capabilities(), dot2.capabilities());
|
||||
EXPECT_EQ(dot1.listen_interval(), dot2.listen_interval());
|
||||
test_equals(
|
||||
@@ -32,7 +32,7 @@ void test_equals(const Dot11AssocRequest &dot1, const Dot11AssocRequest &dot2) {
|
||||
);
|
||||
}
|
||||
|
||||
void test_equals_expected(const Dot11AssocRequest &dot11) {
|
||||
void test_equals_expected(const Dot11AssocRequest& dot11) {
|
||||
test_equals_expected(static_cast<const Dot11ManagementFrame&>(dot11));
|
||||
EXPECT_EQ(dot11.listen_interval(), 0x92f3);
|
||||
EXPECT_EQ(dot11.subtype(), Dot11::ASSOC_REQ);
|
||||
@@ -78,7 +78,7 @@ TEST_F(Dot11AssocRequestTest, ClonePDU) {
|
||||
TEST_F(Dot11AssocRequestTest, FromBytes) {
|
||||
Internals::smart_ptr<PDU>::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
|
||||
ASSERT_TRUE(dot11.get() != NULL);
|
||||
const Dot11AssocRequest *inner = dot11->find_pdu<Dot11AssocRequest>();
|
||||
const Dot11AssocRequest* inner = dot11->find_pdu<Dot11AssocRequest>();
|
||||
ASSERT_TRUE(inner != NULL);
|
||||
test_equals_expected(*inner);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ const uint8_t Dot11AssocResponseTest::expected_packet[] = {
|
||||
0, 0, 21, 32, 243, 146, 58, 242
|
||||
};
|
||||
|
||||
void test_equals(const Dot11AssocResponse &dot1, const Dot11AssocResponse &dot2) {
|
||||
void test_equals(const Dot11AssocResponse& dot1, const Dot11AssocResponse& dot2) {
|
||||
test_equals(dot1.capabilities(), dot2.capabilities());
|
||||
EXPECT_EQ(dot1.status_code(), dot2.status_code());
|
||||
EXPECT_EQ(dot1.aid(), dot2.aid());
|
||||
@@ -32,7 +32,7 @@ void test_equals(const Dot11AssocResponse &dot1, const Dot11AssocResponse &dot2)
|
||||
);
|
||||
}
|
||||
|
||||
void test_equals_expected(const Dot11AssocResponse &dot11) {
|
||||
void test_equals_expected(const Dot11AssocResponse& dot11) {
|
||||
test_equals_expected(static_cast<const Dot11ManagementFrame&>(dot11));
|
||||
EXPECT_EQ(dot11.status_code(), 0x92f3);
|
||||
EXPECT_EQ(dot11.aid(), 0xf23a);
|
||||
@@ -86,7 +86,7 @@ TEST_F(Dot11AssocResponseTest, ClonePDU) {
|
||||
TEST_F(Dot11AssocResponseTest, FromBytes) {
|
||||
Internals::smart_ptr<PDU>::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
|
||||
ASSERT_TRUE(dot11.get() != NULL);
|
||||
const Dot11AssocResponse *inner = dot11->find_pdu<Dot11AssocResponse>();
|
||||
const Dot11AssocResponse* inner = dot11->find_pdu<Dot11AssocResponse>();
|
||||
ASSERT_TRUE(inner != NULL);
|
||||
test_equals_expected(*inner);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ const uint8_t Dot11AuthenticationTest::expected_packet[] = {
|
||||
7, 0, 0, 162, 40, 58, 242, 243, 146
|
||||
};
|
||||
|
||||
void test_equals(const Dot11Authentication &dot1, const Dot11Authentication &dot2) {
|
||||
void test_equals(const Dot11Authentication& dot1, const Dot11Authentication& dot2) {
|
||||
EXPECT_EQ(dot1.status_code(), dot2.status_code());
|
||||
EXPECT_EQ(dot1.auth_seq_number(), dot2.auth_seq_number());
|
||||
EXPECT_EQ(dot1.auth_algorithm(), dot2.auth_algorithm());
|
||||
@@ -32,7 +32,7 @@ void test_equals(const Dot11Authentication &dot1, const Dot11Authentication &dot
|
||||
);
|
||||
}
|
||||
|
||||
void test_equals_expected(const Dot11Authentication &dot11) {
|
||||
void test_equals_expected(const Dot11Authentication& dot11) {
|
||||
test_equals_expected(static_cast<const Dot11ManagementFrame&>(dot11));
|
||||
EXPECT_EQ(dot11.status_code(), 0x92f3);
|
||||
EXPECT_EQ(dot11.auth_seq_number(), 0xf23a);
|
||||
@@ -94,7 +94,7 @@ TEST_F(Dot11AuthenticationTest, ClonePDU) {
|
||||
TEST_F(Dot11AuthenticationTest, FromBytes) {
|
||||
Internals::smart_ptr<PDU>::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
|
||||
ASSERT_TRUE(dot11.get() != NULL);
|
||||
const Dot11Authentication *inner = dot11->find_pdu<Dot11Authentication>();
|
||||
const Dot11Authentication* inner = dot11->find_pdu<Dot11Authentication>();
|
||||
ASSERT_TRUE(inner != NULL);
|
||||
test_equals_expected(*inner);
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ const uint8_t Dot11BeaconTest::expected_packet[] = {
|
||||
7, 0, 0, 250, 1, 147, 40, 65, 35, 173, 31, 250, 20, 149, 32
|
||||
};
|
||||
|
||||
void test_equals_expected(const Dot11Beacon &dot11) {
|
||||
void test_equals_expected(const Dot11Beacon& dot11) {
|
||||
EXPECT_EQ(dot11.subtype(), 8);
|
||||
EXPECT_EQ(dot11.timestamp(), 0x1fad2341289301faULL);
|
||||
EXPECT_EQ(dot11.interval(), 0x14fa);
|
||||
|
||||
const Dot11Beacon::capability_information &info = dot11.capabilities();
|
||||
const Dot11Beacon::capability_information& info = dot11.capabilities();
|
||||
EXPECT_EQ(info.ess(), true);
|
||||
EXPECT_EQ(info.ibss(), false);
|
||||
EXPECT_EQ(info.cf_poll(), true);
|
||||
@@ -111,7 +111,7 @@ TEST_F(Dot11BeaconTest, SeqNum) {
|
||||
TEST_F(Dot11BeaconTest, FromBytes) {
|
||||
Internals::smart_ptr<PDU>::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
|
||||
ASSERT_TRUE(dot11.get() != NULL);
|
||||
const Dot11Beacon *beacon = dot11->find_pdu<Dot11Beacon>();
|
||||
const Dot11Beacon* beacon = dot11->find_pdu<Dot11Beacon>();
|
||||
ASSERT_TRUE(beacon != NULL);
|
||||
test_equals_expected(*beacon);
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@ const uint8_t Dot11BlockAckRequestTest::expected_packet[] = {
|
||||
0, 176, 33
|
||||
};
|
||||
|
||||
void test_equals(const Dot11BlockAckRequest &dot1, const Dot11BlockAckRequest &dot2) {
|
||||
void test_equals(const Dot11BlockAckRequest& dot1, const Dot11BlockAckRequest& dot2) {
|
||||
EXPECT_EQ(dot1.fragment_number(), dot2.fragment_number());
|
||||
EXPECT_EQ(dot1.start_sequence(), dot2.start_sequence());
|
||||
EXPECT_EQ(dot1.bar_control(), dot2.bar_control());
|
||||
}
|
||||
|
||||
void test_equals_expected(const Dot11BlockAckRequest &dot11) {
|
||||
void test_equals_expected(const Dot11BlockAckRequest& dot11) {
|
||||
EXPECT_EQ(dot11.type(), Dot11::CONTROL);
|
||||
EXPECT_EQ(dot11.subtype(), Dot11::BLOCK_ACK_REQ);
|
||||
EXPECT_EQ(dot11.bar_control(), 4);
|
||||
@@ -82,7 +82,7 @@ TEST_F(Dot11BlockAckRequestTest, ClonePDU) {
|
||||
TEST_F(Dot11BlockAckRequestTest, FromBytes) {
|
||||
Internals::smart_ptr<PDU>::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
|
||||
ASSERT_TRUE(dot11.get() != NULL);
|
||||
const Dot11BlockAckRequest *inner = dot11->find_pdu<Dot11BlockAckRequest>();
|
||||
const Dot11BlockAckRequest* inner = dot11->find_pdu<Dot11BlockAckRequest>();
|
||||
ASSERT_TRUE(inner != NULL);
|
||||
test_equals_expected(*inner);
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ const uint8_t Dot11CFEndTest::expected_packet[] = {
|
||||
229, 1, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6
|
||||
};
|
||||
|
||||
void test_equals(const Dot11CFEnd &dot1, const Dot11CFEnd &dot2) {
|
||||
void test_equals(const Dot11CFEnd& dot1, const Dot11CFEnd& dot2) {
|
||||
test_equals(
|
||||
static_cast<const Dot11ControlTA&>(dot1),
|
||||
static_cast<const Dot11ControlTA&>(dot2)
|
||||
);
|
||||
}
|
||||
|
||||
void test_equals_expected(const Dot11CFEnd &dot11) {
|
||||
void test_equals_expected(const Dot11CFEnd& dot11) {
|
||||
test_equals_expected(static_cast<const Dot11ControlTA&>(dot11));
|
||||
EXPECT_EQ(dot11.subtype(), Dot11::CF_END);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ TEST_F(Dot11CFEndTest, ClonePDU) {
|
||||
TEST_F(Dot11CFEndTest, FromBytes) {
|
||||
Internals::smart_ptr<PDU>::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
|
||||
ASSERT_TRUE(dot11.get() != NULL);
|
||||
const Dot11CFEnd *inner = dot11->find_pdu<Dot11CFEnd>();
|
||||
const Dot11CFEnd* inner = dot11->find_pdu<Dot11CFEnd>();
|
||||
ASSERT_TRUE(inner != NULL);
|
||||
test_equals_expected(*inner);
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ const uint8_t Dot11EndCFAckTest::expected_packet[] = {
|
||||
245, 1, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6
|
||||
};
|
||||
|
||||
void test_equals(const Dot11EndCFAck &dot1, const Dot11EndCFAck &dot2) {
|
||||
void test_equals(const Dot11EndCFAck& dot1, const Dot11EndCFAck& dot2) {
|
||||
test_equals(
|
||||
static_cast<const Dot11ControlTA&>(dot1),
|
||||
static_cast<const Dot11ControlTA&>(dot2)
|
||||
);
|
||||
}
|
||||
|
||||
void test_equals_expected(const Dot11EndCFAck &dot11) {
|
||||
void test_equals_expected(const Dot11EndCFAck& dot11) {
|
||||
test_equals_expected(static_cast<const Dot11ControlTA&>(dot11));
|
||||
EXPECT_EQ(dot11.subtype(), Dot11::CF_END_ACK);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ TEST_F(Dot11EndCFAckTest, ClonePDU) {
|
||||
TEST_F(Dot11EndCFAckTest, FromBytes) {
|
||||
Internals::smart_ptr<PDU>::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
|
||||
ASSERT_TRUE(dot11.get() != NULL);
|
||||
const Dot11EndCFAck *inner = dot11->find_pdu<Dot11EndCFAck>();
|
||||
const Dot11EndCFAck* inner = dot11->find_pdu<Dot11EndCFAck>();
|
||||
ASSERT_TRUE(inner != NULL);
|
||||
test_equals_expected(*inner);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ TEST_F(Dot11DataTest, ClonePDU) {
|
||||
TEST_F(Dot11DataTest, FromBytes) {
|
||||
Internals::smart_ptr<PDU>::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
|
||||
ASSERT_TRUE(dot11.get() != NULL);
|
||||
const Dot11Data *inner = dot11->find_pdu<Dot11Data>();
|
||||
const Dot11Data* inner = dot11->find_pdu<Dot11Data>();
|
||||
ASSERT_TRUE(inner != NULL);
|
||||
test_equals_expected(*inner);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ const uint8_t Dot11DeauthenticationTest::expected_packet[] = {
|
||||
7, 0, 0, 243, 146
|
||||
};
|
||||
|
||||
void test_equals(const Dot11Deauthentication &dot1, const Dot11Deauthentication &dot2) {
|
||||
void test_equals(const Dot11Deauthentication& dot1, const Dot11Deauthentication& dot2) {
|
||||
EXPECT_EQ(dot1.reason_code(), dot2.reason_code());
|
||||
test_equals(
|
||||
static_cast<const Dot11ManagementFrame&>(dot1),
|
||||
@@ -30,7 +30,7 @@ void test_equals(const Dot11Deauthentication &dot1, const Dot11Deauthentication
|
||||
);
|
||||
}
|
||||
|
||||
void test_equals_expected(const Dot11Deauthentication &dot11) {
|
||||
void test_equals_expected(const Dot11Deauthentication& dot11) {
|
||||
test_equals_expected(static_cast<const Dot11ManagementFrame&>(dot11));
|
||||
EXPECT_EQ(dot11.reason_code(), 0x92f3);
|
||||
EXPECT_EQ(dot11.subtype(), Dot11::DEAUTH);
|
||||
@@ -76,7 +76,7 @@ TEST_F(Dot11DeauthenticationTest, ClonePDU) {
|
||||
TEST_F(Dot11DeauthenticationTest, FromBytes) {
|
||||
Internals::smart_ptr<PDU>::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
|
||||
ASSERT_TRUE(dot11.get() != NULL);
|
||||
const Dot11Deauthentication *inner = dot11->find_pdu<Dot11Deauthentication>();
|
||||
const Dot11Deauthentication* inner = dot11->find_pdu<Dot11Deauthentication>();
|
||||
ASSERT_TRUE(inner != NULL);
|
||||
test_equals_expected(*inner);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ const uint8_t Dot11DisassocTest::expected_packet[] = {
|
||||
7, 0, 0, 18, 35
|
||||
};
|
||||
|
||||
void test_equals(const Dot11Disassoc &dot1, const Dot11Disassoc &dot2) {
|
||||
void test_equals(const Dot11Disassoc& dot1, const Dot11Disassoc& dot2) {
|
||||
EXPECT_EQ(dot1.reason_code(), dot2.reason_code());
|
||||
test_equals(
|
||||
static_cast<const Dot11ManagementFrame&>(dot1),
|
||||
@@ -31,7 +31,7 @@ void test_equals(const Dot11Disassoc &dot1, const Dot11Disassoc &dot2) {
|
||||
);
|
||||
}
|
||||
|
||||
void test_equals_expected(const Dot11Disassoc &dot11) {
|
||||
void test_equals_expected(const Dot11Disassoc& dot11) {
|
||||
test_equals_expected(static_cast<const Dot11ManagementFrame&>(dot11));
|
||||
EXPECT_EQ(dot11.reason_code(), 0x2312);
|
||||
EXPECT_EQ(dot11.subtype(), Dot11::DISASSOC);
|
||||
@@ -77,7 +77,7 @@ TEST_F(Dot11DisassocTest, ClonePDU) {
|
||||
TEST_F(Dot11DisassocTest, FromBytes) {
|
||||
Internals::smart_ptr<PDU>::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
|
||||
ASSERT_TRUE(dot11.get() != NULL);
|
||||
const Dot11Disassoc *inner = dot11->find_pdu<Dot11Disassoc>();
|
||||
const Dot11Disassoc* inner = dot11->find_pdu<Dot11Disassoc>();
|
||||
ASSERT_TRUE(inner != NULL);
|
||||
test_equals_expected(*inner);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ TEST_F(Dot11Test, Addr1) {
|
||||
TEST_F(Dot11Test, AddTaggedOption) {
|
||||
Dot11 dot11;
|
||||
dot11.add_option(Dot11::option(Dot11::SSID, hwaddr.begin(), hwaddr.end()));
|
||||
const Dot11::option *option = dot11.search_option(Dot11::SSID);
|
||||
const Dot11::option* option = dot11.search_option(Dot11::SSID);
|
||||
ASSERT_TRUE(option != NULL);
|
||||
EXPECT_EQ(option->data_size(), hwaddr.size());
|
||||
EXPECT_EQ(option->option(), Dot11::SSID);
|
||||
|
||||
@@ -22,14 +22,14 @@ const uint8_t Dot11ProbeRequestTest::expected_packet[] = {
|
||||
0, 0
|
||||
};
|
||||
|
||||
void test_equals(const Dot11ProbeRequest &dot1, const Dot11ProbeRequest &dot2) {
|
||||
void test_equals(const Dot11ProbeRequest& dot1, const Dot11ProbeRequest& dot2) {
|
||||
test_equals(
|
||||
static_cast<const Dot11ManagementFrame&>(dot1),
|
||||
static_cast<const Dot11ManagementFrame&>(dot2)
|
||||
);
|
||||
}
|
||||
|
||||
void test_equals_expected(const Dot11ProbeRequest &dot11) {
|
||||
void test_equals_expected(const Dot11ProbeRequest& dot11) {
|
||||
test_equals_expected(static_cast<const Dot11ManagementFrame&>(dot11));
|
||||
EXPECT_EQ(dot11.subtype(), Dot11::PROBE_REQ);
|
||||
}
|
||||
@@ -67,7 +67,7 @@ TEST_F(Dot11ProbeRequestTest, ClonePDU) {
|
||||
TEST_F(Dot11ProbeRequestTest, FromBytes) {
|
||||
Internals::smart_ptr<PDU>::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
|
||||
ASSERT_TRUE(dot11.get() != NULL);
|
||||
const Dot11ProbeRequest *inner = dot11->find_pdu<Dot11ProbeRequest>();
|
||||
const Dot11ProbeRequest* inner = dot11->find_pdu<Dot11ProbeRequest>();
|
||||
ASSERT_TRUE(inner != NULL);
|
||||
test_equals_expected(*inner);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ const uint8_t Dot11ProbeResponseTest::expected_packet[] = {
|
||||
0, 0, 145, 138, 131, 39, 223, 152, 166, 23, 141, 146, 0, 0
|
||||
};
|
||||
|
||||
void test_equals(const Dot11ProbeResponse &dot1, const Dot11ProbeResponse &dot2) {
|
||||
void test_equals(const Dot11ProbeResponse& dot1, const Dot11ProbeResponse& dot2) {
|
||||
EXPECT_EQ(dot1.interval(), dot2.interval());
|
||||
EXPECT_EQ(dot1.timestamp(), dot2.timestamp());
|
||||
test_equals(
|
||||
@@ -31,7 +31,7 @@ void test_equals(const Dot11ProbeResponse &dot1, const Dot11ProbeResponse &dot2)
|
||||
);
|
||||
}
|
||||
|
||||
void test_equals_expected(const Dot11ProbeResponse &dot11) {
|
||||
void test_equals_expected(const Dot11ProbeResponse& dot11) {
|
||||
test_equals_expected(static_cast<const Dot11ManagementFrame&>(dot11));
|
||||
EXPECT_EQ(dot11.timestamp(), 0x17a698df27838a91ULL);
|
||||
EXPECT_EQ(dot11.interval(), 0x928d);
|
||||
@@ -85,7 +85,7 @@ TEST_F(Dot11ProbeResponseTest, ClonePDU) {
|
||||
TEST_F(Dot11ProbeResponseTest, FromBytes) {
|
||||
Internals::smart_ptr<PDU>::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
|
||||
ASSERT_TRUE(dot11.get() != NULL);
|
||||
const Dot11ProbeResponse *inner = dot11->find_pdu<Dot11ProbeResponse>();
|
||||
const Dot11ProbeResponse* inner = dot11->find_pdu<Dot11ProbeResponse>();
|
||||
ASSERT_TRUE(inner != NULL);
|
||||
test_equals_expected(*inner);
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ const uint8_t Dot11PSPollTest::expected_packet[] = {
|
||||
165, 1, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6
|
||||
};
|
||||
|
||||
void test_equals(const Dot11PSPoll &dot1, const Dot11PSPoll &dot2) {
|
||||
void test_equals(const Dot11PSPoll& dot1, const Dot11PSPoll& dot2) {
|
||||
test_equals(
|
||||
static_cast<const Dot11ControlTA&>(dot1),
|
||||
static_cast<const Dot11ControlTA&>(dot2)
|
||||
);
|
||||
}
|
||||
|
||||
void test_equals_expected(const Dot11PSPoll &dot11) {
|
||||
void test_equals_expected(const Dot11PSPoll& dot11) {
|
||||
test_equals_expected(static_cast<const Dot11ControlTA&>(dot11));
|
||||
EXPECT_EQ(dot11.subtype(), Dot11::PS);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ TEST_F(Dot11PSPollTest, ClonePDU) {
|
||||
TEST_F(Dot11PSPollTest, FromBytes) {
|
||||
Internals::smart_ptr<PDU>::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
|
||||
ASSERT_TRUE(dot11.get() != NULL);
|
||||
const Dot11PSPoll *inner = dot11->find_pdu<Dot11PSPoll>();
|
||||
const Dot11PSPoll* inner = dot11->find_pdu<Dot11PSPoll>();
|
||||
ASSERT_TRUE(inner != NULL);
|
||||
test_equals_expected(*inner);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ const uint8_t Dot11ReAssocRequestTest::expected_packet[] = {
|
||||
0, 0, 21, 32, 243, 146, 3, 4, 5, 6, 7, 8
|
||||
};
|
||||
|
||||
void test_equals(const Dot11ReAssocRequest &dot1, const Dot11ReAssocRequest &dot2) {
|
||||
void test_equals(const Dot11ReAssocRequest& dot1, const Dot11ReAssocRequest& dot2) {
|
||||
test_equals(dot1.capabilities(), dot2.capabilities());
|
||||
EXPECT_EQ(dot1.listen_interval(), dot2.listen_interval());
|
||||
EXPECT_EQ(dot1.current_ap(), dot2.current_ap());
|
||||
@@ -32,7 +32,7 @@ void test_equals(const Dot11ReAssocRequest &dot1, const Dot11ReAssocRequest &dot
|
||||
);
|
||||
}
|
||||
|
||||
void test_equals_expected(const Dot11ReAssocRequest &dot11) {
|
||||
void test_equals_expected(const Dot11ReAssocRequest& dot11) {
|
||||
test_equals_expected(static_cast<const Dot11ManagementFrame&>(dot11));
|
||||
EXPECT_EQ(dot11.listen_interval(), 0x92f3);
|
||||
EXPECT_EQ(dot11.subtype(), Dot11::REASSOC_REQ);
|
||||
@@ -85,7 +85,7 @@ TEST_F(Dot11ReAssocRequestTest, ClonePDU) {
|
||||
TEST_F(Dot11ReAssocRequestTest, FromBytes) {
|
||||
Internals::smart_ptr<PDU>::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
|
||||
ASSERT_TRUE(dot11.get() != NULL);
|
||||
const Dot11ReAssocRequest *inner = dot11->find_pdu<Dot11ReAssocRequest>();
|
||||
const Dot11ReAssocRequest* inner = dot11->find_pdu<Dot11ReAssocRequest>();
|
||||
ASSERT_TRUE(inner != NULL);
|
||||
test_equals_expected(*inner);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ const uint8_t Dot11ReAssocResponseTest::expected_packet[] = {
|
||||
0, 0, 21, 32, 243, 146, 58, 242
|
||||
};
|
||||
|
||||
void test_equals(const Dot11ReAssocResponse &dot1, const Dot11ReAssocResponse &dot2) {
|
||||
void test_equals(const Dot11ReAssocResponse& dot1, const Dot11ReAssocResponse& dot2) {
|
||||
test_equals(dot1.capabilities(), dot2.capabilities());
|
||||
EXPECT_EQ(dot1.status_code(), dot2.status_code());
|
||||
EXPECT_EQ(dot1.aid(), dot2.aid());
|
||||
@@ -32,7 +32,7 @@ void test_equals(const Dot11ReAssocResponse &dot1, const Dot11ReAssocResponse &d
|
||||
);
|
||||
}
|
||||
|
||||
void test_equals_expected(const Dot11ReAssocResponse &dot11) {
|
||||
void test_equals_expected(const Dot11ReAssocResponse& dot11) {
|
||||
test_equals_expected(static_cast<const Dot11ManagementFrame&>(dot11));
|
||||
EXPECT_EQ(dot11.status_code(), 0x92f3);
|
||||
EXPECT_EQ(dot11.aid(), 0xf23a);
|
||||
@@ -74,7 +74,7 @@ TEST_F(Dot11ReAssocResponseTest, ClonePDU) {
|
||||
TEST_F(Dot11ReAssocResponseTest, FromBytes) {
|
||||
Internals::smart_ptr<PDU>::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
|
||||
ASSERT_TRUE(dot11.get() != NULL);
|
||||
const Dot11ReAssocResponse *inner = dot11->find_pdu<Dot11ReAssocResponse>();
|
||||
const Dot11ReAssocResponse* inner = dot11->find_pdu<Dot11ReAssocResponse>();
|
||||
ASSERT_TRUE(inner != NULL);
|
||||
test_equals_expected(*inner);
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ const uint8_t Dot11RTSTest::expected_packet[] = {
|
||||
181, 1, 79, 35, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6
|
||||
};
|
||||
|
||||
void test_equals(const Dot11RTS &dot1, const Dot11RTS &dot2) {
|
||||
void test_equals(const Dot11RTS& dot1, const Dot11RTS& dot2) {
|
||||
test_equals(
|
||||
static_cast<const Dot11ControlTA&>(dot1),
|
||||
static_cast<const Dot11ControlTA&>(dot2)
|
||||
);
|
||||
}
|
||||
|
||||
void test_equals_expected(const Dot11RTS &dot11) {
|
||||
void test_equals_expected(const Dot11RTS& dot11) {
|
||||
test_equals_expected(static_cast<const Dot11ControlTA&>(dot11));
|
||||
EXPECT_EQ(dot11.subtype(), Dot11::RTS);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ TEST_F(Dot11RTSTest, ClonePDU) {
|
||||
TEST_F(Dot11RTSTest, FromBytes) {
|
||||
Internals::smart_ptr<PDU>::type dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
|
||||
ASSERT_TRUE(dot11.get() != NULL);
|
||||
const Dot11RTS *inner = dot11->find_pdu<Dot11RTS>();
|
||||
const Dot11RTS* inner = dot11->find_pdu<Dot11RTS>();
|
||||
ASSERT_TRUE(inner != NULL);
|
||||
test_equals_expected(*inner);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class Dot1QTest : public testing::Test {
|
||||
public:
|
||||
static const uint8_t expected_packet[];
|
||||
|
||||
void test_equals(const Dot1Q &pdu1, const Dot1Q &pdu2);
|
||||
void test_equals(const Dot1Q& pdu1, const Dot1Q& pdu2);
|
||||
};
|
||||
|
||||
const uint8_t Dot1QTest::expected_packet[] = {
|
||||
@@ -34,14 +34,14 @@ TEST_F(Dot1QTest, DefaultConstructor) {
|
||||
|
||||
TEST_F(Dot1QTest, ConstructorFromBuffer) {
|
||||
EthernetII eth(expected_packet, sizeof(expected_packet));
|
||||
const Dot1Q *dot1 = eth.find_pdu<Dot1Q>();
|
||||
const Dot1Q* dot1 = eth.find_pdu<Dot1Q>();
|
||||
ASSERT_TRUE(dot1 != NULL);
|
||||
EXPECT_EQ(0x806, dot1->payload_type());
|
||||
EXPECT_EQ(5, dot1->priority());
|
||||
EXPECT_EQ(1, dot1->cfi());
|
||||
EXPECT_EQ(123, dot1->id());
|
||||
|
||||
const ARP *arp = dot1->find_pdu<ARP>();
|
||||
const ARP* arp = dot1->find_pdu<ARP>();
|
||||
ASSERT_TRUE(arp != NULL);
|
||||
// just to check it the offset's OK
|
||||
EXPECT_EQ(ARP::hwaddress_type("00:19:06:ea:b8:c1"), arp->sender_hw_addr());
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
static address_type empty_addr;
|
||||
static const uint16_t p_type;
|
||||
|
||||
void test_equals(const EthernetII ð1, const EthernetII ð2);
|
||||
void test_equals(const EthernetII& eth1, const EthernetII& eth2);
|
||||
};
|
||||
|
||||
const uint8_t EthernetIITest::expected_packet[] = {
|
||||
@@ -53,7 +53,7 @@ address_type EthernetIITest::empty_addr;
|
||||
|
||||
const uint16_t EthernetIITest::p_type = 0xd0ab;
|
||||
|
||||
void EthernetIITest::test_equals(const EthernetII ð1, const EthernetII ð2) {
|
||||
void EthernetIITest::test_equals(const EthernetII& eth1, const EthernetII& eth2) {
|
||||
EXPECT_EQ(eth1.dst_addr(), eth2.dst_addr());
|
||||
EXPECT_EQ(eth1.src_addr(), eth2.src_addr());
|
||||
EXPECT_EQ(eth1.payload_type(), eth2.payload_type());
|
||||
@@ -83,7 +83,7 @@ TEST_F(EthernetIITest, CopyAssignmentOperator) {
|
||||
}
|
||||
|
||||
TEST_F(EthernetIITest, NestedCopy) {
|
||||
EthernetII *nested = new EthernetII(expected_packet, sizeof(expected_packet));
|
||||
EthernetII* nested = new EthernetII(expected_packet, sizeof(expected_packet));
|
||||
EthernetII eth1(expected_packet, sizeof(expected_packet));
|
||||
eth1.inner_pdu(nested);
|
||||
EthernetII eth2(eth1);
|
||||
|
||||
@@ -12,11 +12,11 @@ using namespace Tins;
|
||||
class HWAddressTest : public testing::Test {
|
||||
public:
|
||||
static const std::string address;
|
||||
static const uint8_t *byte_address, *empty_addr;
|
||||
static const uint8_t* byte_address, *empty_addr;
|
||||
};
|
||||
|
||||
const std::string HWAddressTest::address = "00:de:ad:be:ef:00";
|
||||
const uint8_t *HWAddressTest::byte_address = (const uint8_t*)"\x00\xde\xad\xbe\xef\x00",
|
||||
const uint8_t* HWAddressTest::byte_address = (const uint8_t*)"\x00\xde\xad\xbe\xef\x00",
|
||||
*HWAddressTest::empty_addr = (const uint8_t*)"\x00\x00\x00\x00\x00\x00";
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
packet_with_extensions_and_length[];
|
||||
static const uint32_t expected_packet_count;
|
||||
|
||||
void test_equals(const ICMP &icmp1, const ICMP &icmp2);
|
||||
void test_equals(const ICMP& icmp1, const ICMP& icmp2);
|
||||
};
|
||||
|
||||
const uint8_t ICMPTest::expected_packets[][8] = {
|
||||
@@ -78,7 +78,7 @@ TEST_F(ICMPTest, CopyAssignmentOperator) {
|
||||
}
|
||||
|
||||
TEST_F(ICMPTest, NestedCopy) {
|
||||
ICMP *nested = new ICMP(expected_packets[0], sizeof(expected_packets[0]));
|
||||
ICMP* nested = new ICMP(expected_packets[0], sizeof(expected_packets[0]));
|
||||
ICMP icmp1(expected_packets[0], sizeof(expected_packets[0]));
|
||||
icmp1.inner_pdu(nested);
|
||||
ICMP icmp2(icmp1);
|
||||
@@ -256,7 +256,7 @@ TEST_F(ICMPTest, SetRedirect) {
|
||||
EXPECT_EQ(IPv4Address("1.2.3.4"), icmp.gateway());
|
||||
}
|
||||
|
||||
void ICMPTest::test_equals(const ICMP &icmp1, const ICMP &icmp2) {
|
||||
void ICMPTest::test_equals(const ICMP& icmp1, const ICMP& icmp2) {
|
||||
EXPECT_EQ(icmp1.type(), icmp2.type());
|
||||
EXPECT_EQ(icmp1.code(), icmp2.code());
|
||||
EXPECT_EQ(icmp1.gateway(), icmp2.gateway());
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
static const uint8_t packet_with_extensions_and_length[];
|
||||
static const uint8_t mld2_icmpv6_layer[];
|
||||
|
||||
void test_equals(const ICMPv6 &icmp1, const ICMPv6 &icmp2);
|
||||
void test_equals(const ICMPv6& icmp1, const ICMPv6& icmp2);
|
||||
};
|
||||
|
||||
const uint8_t ICMPv6Test::expected_packet[] = {
|
||||
@@ -114,7 +114,7 @@ TEST_F(ICMPv6Test, ConstructorFromBuffer2) {
|
||||
EXPECT_EQ(icmp.router_lifetime(), 1800);
|
||||
EXPECT_EQ(icmp.reachable_time(), 30000U);
|
||||
EXPECT_EQ(icmp.retransmit_timer(), 1000U);
|
||||
const ICMPv6::option *opt = icmp.search_option(ICMPv6::SOURCE_ADDRESS);
|
||||
const ICMPv6::option* opt = icmp.search_option(ICMPv6::SOURCE_ADDRESS);
|
||||
ASSERT_TRUE(opt != NULL);
|
||||
EXPECT_EQ(opt->data_size(), 6U);
|
||||
EXPECT_EQ(HWAddress<6>(opt->data_ptr()), "00:60:97:07:69:ea");
|
||||
@@ -281,7 +281,7 @@ TEST_F(ICMPv6Test, PrefixInformation) {
|
||||
EXPECT_EQ(result.L, info.L);
|
||||
EXPECT_EQ(result.valid_lifetime, info.valid_lifetime);
|
||||
EXPECT_EQ(result.preferred_lifetime, info.preferred_lifetime);
|
||||
EXPECT_EQ(IPv6Address(result.prefix), IPv6Address(result.prefix));
|
||||
EXPECT_EQ(IPv6Address(info.prefix), IPv6Address(result.prefix));
|
||||
EXPECT_EQ(IPv6Address(result.prefix), "827d:adae::1");
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ TEST_F(ICMPv6Test, NewAdvertisementInterval) {
|
||||
TEST_F(ICMPv6Test, NewHomeAgentInformation) {
|
||||
ICMPv6 icmp;
|
||||
ICMPv6::new_ha_info_type data;
|
||||
data.push_back(0);
|
||||
data.push_back(0xfeed);
|
||||
data.push_back(0x92fa);
|
||||
data.push_back(0xaab3);
|
||||
icmp.new_home_agent_info(data);
|
||||
@@ -426,6 +426,7 @@ TEST_F(ICMPv6Test, MAP) {
|
||||
EXPECT_EQ(output.dist, data.dist);
|
||||
EXPECT_EQ(output.pref, data.pref);
|
||||
EXPECT_EQ(output.r, data.r);
|
||||
EXPECT_EQ(output.valid_lifetime, data.valid_lifetime);
|
||||
EXPECT_EQ(output.address, data.address);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
static const uint8_t expected_packet[], fragmented_packet[],
|
||||
fragmented_ether_ip_packet[], tot_len_zero_packet[];
|
||||
|
||||
void test_equals(const IP &ip1, const IP &ip2);
|
||||
void test_equals(const IP& ip1, const IP& ip2);
|
||||
void test_overwrite_source_address(IP& ip);
|
||||
};
|
||||
|
||||
@@ -475,7 +475,7 @@ TEST_F(IPTest, CopyAssignmentOperator) {
|
||||
}
|
||||
|
||||
TEST_F(IPTest, NestedCopy) {
|
||||
IP *nested = new IP(expected_packet, sizeof(expected_packet));
|
||||
IP* nested = new IP(expected_packet, sizeof(expected_packet));
|
||||
IP ip1;
|
||||
ip1.inner_pdu(nested);
|
||||
IP ip2(ip1);
|
||||
@@ -625,13 +625,13 @@ TEST_F(IPTest, AddOption) {
|
||||
const uint8_t data[] = { 0x15, 0x17, 0x94, 0x66, 0xff };
|
||||
IP::option_identifier id(IP::SEC, IP::CONTROL, 1);
|
||||
ip.add_option(IP::option(id, data, data + sizeof(data)));
|
||||
const IP::option *opt = ip.search_option(id);
|
||||
const IP::option* opt = ip.search_option(id);
|
||||
ASSERT_TRUE(opt != NULL);
|
||||
ASSERT_EQ(opt->data_size(), sizeof(data));
|
||||
EXPECT_TRUE(memcmp(opt->data_ptr(), data, sizeof(data)) == 0);
|
||||
}
|
||||
|
||||
void IPTest::test_equals(const IP &ip1, const IP &ip2) {
|
||||
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());
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
static const uint8_t packets[][1514];
|
||||
static const size_t packet_sizes[], orderings[][11];
|
||||
|
||||
void test_packets(const std::vector<std::pair<const uint8_t*, size_t> > &vt);
|
||||
void test_packets(const std::vector<std::pair<const uint8_t*, size_t> >& vt);
|
||||
};
|
||||
|
||||
const uint8_t IPv4ReassemblerTest::packets[][1514] = {
|
||||
@@ -42,7 +42,7 @@ const size_t IPv4ReassemblerTest::orderings[][11] = {
|
||||
{ 1, 9, 8, 5, 4, 2, 0, 7, 6, 3, 10 }
|
||||
};
|
||||
|
||||
void IPv4ReassemblerTest::test_packets(const std::vector<std::pair<const uint8_t*, size_t> > &vt) {
|
||||
void IPv4ReassemblerTest::test_packets(const std::vector<std::pair<const uint8_t*, size_t> >& vt) {
|
||||
IPv4Reassembler reassembler;
|
||||
for(size_t i = 0; i < vt.size(); ++i) {
|
||||
EthernetII eth(vt[i].first, (uint32_t)vt[i].second);
|
||||
@@ -51,7 +51,7 @@ void IPv4ReassemblerTest::test_packets(const std::vector<std::pair<const uint8_t
|
||||
if(status == IPv4Reassembler::REASSEMBLED) {
|
||||
ASSERT_EQ(static_cast<size_t>(vt.size() - 1), i);
|
||||
ASSERT_TRUE(eth.find_pdu<UDP>() != NULL);
|
||||
RawPDU *raw = eth.find_pdu<RawPDU>();
|
||||
RawPDU* raw = eth.find_pdu<RawPDU>();
|
||||
ASSERT_TRUE(raw != NULL);
|
||||
ASSERT_EQ(15000ULL, raw->payload().size());
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ TEST_F(IPSecAHTest, EthPacket) {
|
||||
|
||||
TEST_F(IPSecAHTest, ConstructorFromBuffer) {
|
||||
IPSecAH ipsec(expected_packet, sizeof(expected_packet));
|
||||
const char *icv_ptr = "\x27\xcf\xc0\xa5\xe4\x3d\x69\xb3\x72\x8e\xc5\xb0";
|
||||
const char* icv_ptr = "\x27\xcf\xc0\xa5\xe4\x3d\x69\xb3\x72\x8e\xc5\xb0";
|
||||
EXPECT_EQ(0x32, ipsec.next_header());
|
||||
EXPECT_EQ(4, ipsec.length());
|
||||
EXPECT_EQ(0x8179b705U, ipsec.spi());
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
static const uint8_t expected_packet1[], expected_packet2[],
|
||||
hop_by_hop_options[];
|
||||
|
||||
void test_equals(IPv6 &ip1, IPv6 &ip2);
|
||||
void test_equals(IPv6& ip1, IPv6& ip2);
|
||||
};
|
||||
|
||||
const uint8_t IPv6Test::expected_packet1[] = {
|
||||
@@ -55,7 +55,7 @@ const uint8_t IPv6Test::hop_by_hop_options[] = {
|
||||
222, 173, 190, 239, 190, 173, 254, 237
|
||||
};
|
||||
|
||||
void IPv6Test::test_equals(IPv6 &ip1, IPv6 &ip2) {
|
||||
void IPv6Test::test_equals(IPv6& ip1, IPv6& ip2) {
|
||||
EXPECT_EQ(ip1.version(), ip2.version());
|
||||
EXPECT_EQ(ip1.traffic_class(), ip2.traffic_class());
|
||||
EXPECT_EQ(ip1.flow_label(), ip2.flow_label());
|
||||
@@ -67,7 +67,7 @@ void IPv6Test::test_equals(IPv6 &ip1, IPv6 &ip2) {
|
||||
|
||||
EXPECT_EQ(ip1.search_header(IPv6::HOP_BY_HOP) != NULL,
|
||||
ip2.search_header(IPv6::HOP_BY_HOP) != NULL);
|
||||
const IPv6::ext_header *header1 = ip1.search_header(IPv6::HOP_BY_HOP),
|
||||
const IPv6::ext_header* header1 = ip1.search_header(IPv6::HOP_BY_HOP),
|
||||
*header2 = ip2.search_header(IPv6::HOP_BY_HOP);
|
||||
if(header1 && header2) {
|
||||
EXPECT_EQ(header1->data_size(), header2->data_size());
|
||||
@@ -75,7 +75,7 @@ void IPv6Test::test_equals(IPv6 &ip1, IPv6 &ip2) {
|
||||
|
||||
EXPECT_EQ(ip1.inner_pdu() != NULL, ip2.inner_pdu() != NULL);
|
||||
|
||||
const ICMPv6 *icmp1 = ip1.find_pdu<ICMPv6>(), *icmp2 = ip2.find_pdu<ICMPv6>();
|
||||
const ICMPv6* icmp1 = ip1.find_pdu<ICMPv6>(), *icmp2 = ip2.find_pdu<ICMPv6>();
|
||||
ASSERT_EQ(icmp1 != NULL, icmp2 != NULL);
|
||||
|
||||
if(icmp1 && icmp2) {
|
||||
@@ -106,7 +106,7 @@ TEST_F(IPv6Test, ConstructorFromBuffer) {
|
||||
EXPECT_EQ(ipv6.dst_addr(), "::1");
|
||||
EXPECT_EQ(ipv6.src_addr(), "::1");
|
||||
ASSERT_TRUE(ipv6.inner_pdu() != NULL);
|
||||
TCP *tcp = ipv6.find_pdu<TCP>();
|
||||
TCP* tcp = ipv6.find_pdu<TCP>();
|
||||
ASSERT_TRUE(tcp != NULL);
|
||||
EXPECT_EQ(tcp->sport(), 50828);
|
||||
EXPECT_EQ(tcp->dport(), 80);
|
||||
@@ -124,14 +124,14 @@ TEST_F(IPv6Test, ConstructorFromBuffer2) {
|
||||
EXPECT_EQ(ipv6.dst_addr(), "ff02::16");
|
||||
EXPECT_EQ(ipv6.src_addr(), "fe80::2d0:9ff:fee3:e8de");
|
||||
|
||||
ICMPv6 *pdu = ipv6.find_pdu<ICMPv6>();
|
||||
ICMPv6* pdu = ipv6.find_pdu<ICMPv6>();
|
||||
ASSERT_TRUE(pdu != NULL);
|
||||
EXPECT_EQ(pdu->type(), 143);
|
||||
EXPECT_EQ(pdu->code(), 0);
|
||||
EXPECT_EQ(pdu->checksum(), 0x74fe);
|
||||
EXPECT_EQ(pdu->checksum(), 0x74fe);
|
||||
|
||||
const IPv6::ext_header *header = ipv6.search_header(IPv6::HOP_BY_HOP);
|
||||
const IPv6::ext_header* header = ipv6.search_header(IPv6::HOP_BY_HOP);
|
||||
ASSERT_TRUE(header != NULL);
|
||||
EXPECT_EQ(header->data_size(), 6U);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace Tins;
|
||||
|
||||
const uint8_t empty_addr[IPv6Address::address_size] = { 0 };
|
||||
|
||||
void test_to_string(const std::string &str) {
|
||||
void test_to_string(const std::string& str) {
|
||||
EXPECT_EQ(str, IPv6Address(str).to_string());
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
static const uint8_t from_buffer_info[];
|
||||
static const uint8_t from_buffer_super[];
|
||||
|
||||
//void test_equals(const IP &ip1, const IP &ip2);
|
||||
//void test_equals(const IP& ip1, const IP& ip2);
|
||||
};
|
||||
|
||||
const uint8_t LLCTest::from_buffer_info[] = {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int argc, char* argv[]) {
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
@@ -104,8 +104,8 @@ TEST_F(MatchesResponseTest, DHCP) {
|
||||
};
|
||||
|
||||
EthernetII discover(dhcp_discover, sizeof(dhcp_discover));
|
||||
UDP *udp = discover.find_pdu<UDP>();
|
||||
const RawPDU *raw = discover.find_pdu<RawPDU>();
|
||||
UDP* udp = discover.find_pdu<UDP>();
|
||||
const RawPDU* raw = discover.find_pdu<RawPDU>();
|
||||
ASSERT_TRUE(udp != NULL);
|
||||
ASSERT_TRUE(raw != NULL);
|
||||
|
||||
@@ -221,8 +221,8 @@ TEST_F(MatchesResponseTest, DHCPv6) {
|
||||
};
|
||||
|
||||
EthernetII pkt(request, sizeof(request));
|
||||
UDP *udp = pkt.find_pdu<UDP>();
|
||||
const RawPDU *raw = pkt.find_pdu<RawPDU>();
|
||||
UDP* udp = pkt.find_pdu<UDP>();
|
||||
const RawPDU* raw = pkt.find_pdu<RawPDU>();
|
||||
ASSERT_TRUE(udp != NULL);
|
||||
ASSERT_TRUE(raw != NULL);
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ TEST_F(PDUTest, FindPDU) {
|
||||
EXPECT_TRUE(ip.find_pdu<TCP>() != NULL);
|
||||
EXPECT_TRUE(ip.find_pdu<RawPDU>() != NULL);
|
||||
EXPECT_FALSE(ip.find_pdu<UDP>() != NULL);
|
||||
TCP &t1 = ip.rfind_pdu<TCP>();
|
||||
const TCP &t2 = ip.rfind_pdu<TCP>();
|
||||
TCP& t1 = ip.rfind_pdu<TCP>();
|
||||
const TCP& t2 = ip.rfind_pdu<TCP>();
|
||||
(void)t1;
|
||||
(void)t2;
|
||||
EXPECT_THROW(ip.rfind_pdu<UDP>(), pdu_not_found);
|
||||
@@ -33,12 +33,12 @@ TEST_F(PDUTest, OperatorConcat) {
|
||||
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>();
|
||||
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>();
|
||||
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()));
|
||||
@@ -47,10 +47,10 @@ TEST_F(PDUTest, OperatorConcat) {
|
||||
TEST_F(PDUTest, OperatorConcatOnPointers) {
|
||||
std::string raw_payload = "Test";
|
||||
IP ip = IP("192.168.0.1") / TCP(22, 52);
|
||||
TCP *tcp = ip.find_pdu<TCP>();
|
||||
TCP* tcp = ip.find_pdu<TCP>();
|
||||
ASSERT_TRUE(tcp != NULL);
|
||||
tcp /= RawPDU(raw_payload);
|
||||
RawPDU *raw = ip.find_pdu<RawPDU>();
|
||||
RawPDU* raw = ip.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()));
|
||||
@@ -59,19 +59,19 @@ TEST_F(PDUTest, OperatorConcatOnPointers) {
|
||||
TEST_F(PDUTest, OperatorConcatOnPacket) {
|
||||
std::string raw_payload = "Test";
|
||||
Packet packet = IP("192.168.0.1") / TCP(22, 52);
|
||||
TCP *tcp = packet.pdu()->find_pdu<TCP>();
|
||||
TCP* tcp = packet.pdu()->find_pdu<TCP>();
|
||||
ASSERT_TRUE(tcp != NULL);
|
||||
tcp /= RawPDU(raw_payload);
|
||||
RawPDU *raw = packet.pdu()->find_pdu<RawPDU>();
|
||||
RawPDU* raw = packet.pdu()->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()));
|
||||
}
|
||||
|
||||
TEST_F(PDUTest, TinsCast) {
|
||||
PDU *null_pdu = 0;
|
||||
PDU* null_pdu = 0;
|
||||
TCP tcp;
|
||||
PDU *pdu = &tcp;
|
||||
PDU* pdu = &tcp;
|
||||
EXPECT_EQ(tins_cast<TCP*>(pdu), &tcp);
|
||||
EXPECT_EQ(tins_cast<const TCP*>(pdu), &tcp);
|
||||
EXPECT_EQ(tins_cast<TCP*>(null_pdu), null_pdu);
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
static const uint8_t eapol_over_snap[];
|
||||
static const uint8_t broken_eapol[];
|
||||
|
||||
void test_equals(const RSNEAPOL &eapol1, const RSNEAPOL &eapol2);
|
||||
void test_equals(const RSNEAPOL& eapol1, const RSNEAPOL& eapol2);
|
||||
};
|
||||
|
||||
uint8_t empty_iv[RSNEAPOL::key_iv_size] = { 0 };
|
||||
@@ -79,7 +79,7 @@ const uint8_t RSNEAPOLTest::broken_eapol[] = {
|
||||
179, 86
|
||||
};
|
||||
|
||||
void RSNEAPOLTest::test_equals(const RSNEAPOL &eapol1, const RSNEAPOL &eapol2) {
|
||||
void RSNEAPOLTest::test_equals(const RSNEAPOL& eapol1, const RSNEAPOL& eapol2) {
|
||||
EXPECT_EQ(eapol1.version(), eapol2.version());
|
||||
EXPECT_EQ(eapol1.packet_type(), eapol2.packet_type());
|
||||
EXPECT_EQ(eapol1.type(), eapol2.type());
|
||||
|
||||
@@ -14,7 +14,7 @@ class SLLTest : public testing::Test {
|
||||
public:
|
||||
static const uint8_t expected_packet[];
|
||||
|
||||
void test_equals(const SLL &sll1, const SLL &sll2);
|
||||
void test_equals(const SLL& sll1, const SLL& sll2);
|
||||
};
|
||||
|
||||
const uint8_t SLLTest::expected_packet[] = {
|
||||
|
||||
@@ -12,7 +12,7 @@ class SNAPTest : public testing::Test {
|
||||
public:
|
||||
static const uint8_t expected_packet[];
|
||||
|
||||
void test_equals(const SNAP &snap1, const SNAP &snap2);
|
||||
void test_equals(const SNAP& snap1, const SNAP& snap2);
|
||||
};
|
||||
|
||||
const uint8_t SNAPTest::expected_packet[] = {
|
||||
@@ -87,7 +87,7 @@ TEST_F(SNAPTest, ClonePDU) {
|
||||
snap1.eth_type(0xfab1);
|
||||
snap1.org_code(0xfab1c3);
|
||||
snap1.control(0x1);
|
||||
SNAP *snap2 = static_cast<SNAP*>(snap1.clone());
|
||||
SNAP* snap2 = static_cast<SNAP*>(snap1.clone());
|
||||
ASSERT_TRUE(snap2 != NULL);
|
||||
test_equals(snap1, *snap2);
|
||||
|
||||
@@ -108,7 +108,7 @@ TEST_F(SNAPTest, ConstructorFromBuffer) {
|
||||
test_equals(snap1, snap2);
|
||||
}
|
||||
|
||||
void SNAPTest::test_equals(const SNAP &snap1, const SNAP &snap2) {
|
||||
void SNAPTest::test_equals(const SNAP& snap1, const SNAP& snap2) {
|
||||
EXPECT_EQ(snap1.dsap(), snap2.dsap());
|
||||
EXPECT_EQ(snap1.ssap(), snap2.ssap());
|
||||
EXPECT_EQ(snap1.control(), snap2.control());
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace Tins;
|
||||
class STPTest : public testing::Test {
|
||||
public:
|
||||
static const uint8_t expected_packet[];
|
||||
static void test_equals(const STP::bpdu_id_type &lhs, const STP::bpdu_id_type &rhs);
|
||||
static void test_equals(const STP::bpdu_id_type& lhs, const STP::bpdu_id_type& rhs);
|
||||
};
|
||||
|
||||
const uint8_t STPTest::expected_packet[] = {
|
||||
@@ -21,7 +21,7 @@ const uint8_t STPTest::expected_packet[] = {
|
||||
0
|
||||
};
|
||||
|
||||
void STPTest::test_equals(const STP::bpdu_id_type &lhs, const STP::bpdu_id_type &rhs) {
|
||||
void STPTest::test_equals(const STP::bpdu_id_type& lhs, const STP::bpdu_id_type& rhs) {
|
||||
EXPECT_EQ(lhs.priority, rhs.priority);
|
||||
EXPECT_EQ(lhs.ext_id, rhs.ext_id);
|
||||
EXPECT_EQ(lhs.id, rhs.id);
|
||||
@@ -78,8 +78,8 @@ TEST_F(STPTest, ChainedPDUs) {
|
||||
0, 0, 144, 76, 8, 23, 181, 128, 1, 0, 0, 20, 0, 2, 0, 0, 0
|
||||
};
|
||||
Dot3 pkt(input, sizeof(input));
|
||||
STP *stp = pkt.find_pdu<STP>();
|
||||
LLC *llc = pkt.find_pdu<LLC>();
|
||||
STP* stp = pkt.find_pdu<STP>();
|
||||
LLC* llc = pkt.find_pdu<LLC>();
|
||||
ASSERT_TRUE(stp != NULL);
|
||||
ASSERT_TRUE(llc != NULL);
|
||||
EXPECT_EQ(0x8001, stp->port_id());
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
static const uint8_t expected_packet[], checksum_packet[],
|
||||
partial_packet[];
|
||||
|
||||
void test_equals(const TCP &tcp1, const TCP &tcp2);
|
||||
void test_equals(const TCP& tcp1, const TCP& tcp2);
|
||||
};
|
||||
|
||||
const uint8_t TCPTest::expected_packet[] = {
|
||||
@@ -47,7 +47,7 @@ TEST_F(TCPTest, DefaultConstructor) {
|
||||
|
||||
TEST_F(TCPTest, ChecksumCheck) {
|
||||
EthernetII pkt1(checksum_packet, sizeof(checksum_packet));
|
||||
const TCP &tcp1 = pkt1.rfind_pdu<TCP>();
|
||||
const TCP& tcp1 = pkt1.rfind_pdu<TCP>();
|
||||
uint16_t checksum = tcp1.checksum();
|
||||
|
||||
PDU::serialization_type buffer = pkt1.serialize();
|
||||
@@ -60,7 +60,7 @@ TEST_F(TCPTest, ChecksumCheck) {
|
||||
);
|
||||
|
||||
EthernetII pkt2(&buffer[0], (uint32_t)buffer.size());
|
||||
const TCP &tcp2 = pkt2.rfind_pdu<TCP>();
|
||||
const TCP& tcp2 = pkt2.rfind_pdu<TCP>();
|
||||
EXPECT_EQ(checksum, tcp2.checksum());
|
||||
EXPECT_EQ(tcp1.checksum(), tcp2.checksum());
|
||||
|
||||
@@ -79,7 +79,7 @@ TEST_F(TCPTest, CopyAssignmentOperator) {
|
||||
}
|
||||
|
||||
TEST_F(TCPTest, NestedCopy) {
|
||||
TCP *nested_tcp = new TCP(0x6d1f, 0x78f2);
|
||||
TCP* nested_tcp = new TCP(0x6d1f, 0x78f2);
|
||||
TCP tcp1(0x6d1f, 0x78f2);
|
||||
tcp1.inner_pdu(nested_tcp);
|
||||
TCP tcp2(tcp1);
|
||||
@@ -200,7 +200,7 @@ TEST_F(TCPTest, Timestamp) {
|
||||
EXPECT_EQ(tcp.timestamp(), data);
|
||||
}
|
||||
|
||||
void TCPTest::test_equals(const TCP &tcp1, const TCP &tcp2) {
|
||||
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());
|
||||
|
||||
@@ -75,7 +75,7 @@ TEST_F(UDPTest, DefaultConstructor) {
|
||||
|
||||
TEST_F(UDPTest, ChecksumCheck) {
|
||||
EthernetII pkt1(checksum_packet, sizeof(checksum_packet));
|
||||
const UDP &udp1 = pkt1.rfind_pdu<UDP>();
|
||||
const UDP& udp1 = pkt1.rfind_pdu<UDP>();
|
||||
uint16_t checksum = udp1.checksum();
|
||||
PDU::serialization_type buffer = pkt1.serialize();
|
||||
EXPECT_EQ(
|
||||
@@ -87,7 +87,7 @@ TEST_F(UDPTest, ChecksumCheck) {
|
||||
);
|
||||
|
||||
EthernetII pkt2(&buffer[0], (uint32_t)buffer.size());
|
||||
const UDP &udp2 = pkt2.rfind_pdu<UDP>();
|
||||
const UDP& udp2 = pkt2.rfind_pdu<UDP>();
|
||||
EXPECT_EQ(checksum, udp2.checksum());
|
||||
EXPECT_EQ(udp1.checksum(), udp2.checksum());
|
||||
}
|
||||
@@ -171,7 +171,7 @@ TEST_F(UDPTest, ClonePDU) {
|
||||
udp1.sport(sport);
|
||||
udp1.length(length);
|
||||
|
||||
UDP *udp2 = udp1.clone();
|
||||
UDP* udp2 = udp1.clone();
|
||||
ASSERT_TRUE(udp2 != NULL);
|
||||
EXPECT_EQ(udp2->sport(), sport);
|
||||
EXPECT_EQ(udp2->dport(), dport);
|
||||
|
||||
@@ -35,7 +35,7 @@ TEST_F(WEPDecryptTest, Decrypt1) {
|
||||
|
||||
ASSERT_TRUE(decrypter.decrypt(dot11));
|
||||
|
||||
ARP *arp = dot11.find_pdu<ARP>();
|
||||
ARP* arp = dot11.find_pdu<ARP>();
|
||||
ASSERT_TRUE(arp != NULL);
|
||||
EXPECT_EQ(arp->sender_hw_addr(), "00:0e:a6:6b:fb:69");
|
||||
EXPECT_EQ(arp->target_hw_addr(), "00:00:00:00:00:00");
|
||||
|
||||
@@ -19,11 +19,11 @@ public:
|
||||
static const uint8_t tkip_packets[7][211];
|
||||
static const size_t ccmp_packets_size[], tkip_packets_size[];
|
||||
|
||||
void check_ccmp_packet5(const PDU &pdu);
|
||||
void check_ccmp_packet6(const PDU &pdu);
|
||||
void check_ccmp_packet5(const PDU& pdu);
|
||||
void check_ccmp_packet6(const PDU& pdu);
|
||||
|
||||
void check_tkip_packet5(const PDU &pdu);
|
||||
void check_tkip_packet6(const PDU &pdu);
|
||||
void check_tkip_packet5(const PDU& pdu);
|
||||
void check_tkip_packet6(const PDU& pdu);
|
||||
};
|
||||
|
||||
// packet taken from aircrack's site.
|
||||
@@ -63,30 +63,30 @@ const size_t WPA2DecryptTest::tkip_packets_size[] = {
|
||||
108, 149, 171, 211, 149, 134, 134
|
||||
};
|
||||
|
||||
void WPA2DecryptTest::check_ccmp_packet5(const PDU &pdu) {
|
||||
const UDP *udp = pdu.find_pdu<UDP>();
|
||||
void WPA2DecryptTest::check_ccmp_packet5(const PDU& pdu) {
|
||||
const UDP* udp = pdu.find_pdu<UDP>();
|
||||
ASSERT_TRUE(udp);
|
||||
EXPECT_EQ(udp->sport(), 68);
|
||||
EXPECT_EQ(udp->dport(), 67);
|
||||
}
|
||||
|
||||
void WPA2DecryptTest::check_ccmp_packet6(const PDU &pdu) {
|
||||
const UDP *udp = pdu.find_pdu<UDP>();
|
||||
void WPA2DecryptTest::check_ccmp_packet6(const PDU& pdu) {
|
||||
const UDP* udp = pdu.find_pdu<UDP>();
|
||||
ASSERT_TRUE(udp);
|
||||
EXPECT_EQ(udp->sport(), 67);
|
||||
EXPECT_EQ(udp->dport(), 68);
|
||||
}
|
||||
|
||||
void WPA2DecryptTest::check_tkip_packet5(const PDU &pdu) {
|
||||
const TCP *tcp = pdu.find_pdu<TCP>();
|
||||
void WPA2DecryptTest::check_tkip_packet5(const PDU& pdu) {
|
||||
const TCP* tcp = pdu.find_pdu<TCP>();
|
||||
ASSERT_TRUE(tcp);
|
||||
EXPECT_EQ(tcp->sport(), 44934);
|
||||
EXPECT_EQ(tcp->dport(), 80);
|
||||
EXPECT_EQ(tcp->window(), 1215);
|
||||
}
|
||||
|
||||
void WPA2DecryptTest::check_tkip_packet6(const PDU &pdu) {
|
||||
const TCP *tcp = pdu.find_pdu<TCP>();
|
||||
void WPA2DecryptTest::check_tkip_packet6(const PDU& pdu) {
|
||||
const TCP* tcp = pdu.find_pdu<TCP>();
|
||||
ASSERT_TRUE(tcp);
|
||||
EXPECT_EQ(tcp->sport(), 44934);
|
||||
EXPECT_EQ(tcp->dport(), 80);
|
||||
|
||||
Reference in New Issue
Block a user