1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-27 12:14:26 +01:00

Added small_uint class.

This commit is contained in:
Matias Fontanini
2012-09-02 18:24:59 -03:00
parent fbd6ef397b
commit 958edcc74a
28 changed files with 326 additions and 361 deletions

View File

@@ -90,7 +90,7 @@ TEST_F(Dot11AckTest, ClonePDU) {
TEST_F(Dot11AckTest, FromBytes) {
std::auto_ptr<PDU> dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
ASSERT_TRUE(dot11.get());
const Dot11Ack *inner = dot11->find_inner_pdu<Dot11Ack>();
const Dot11Ack *inner = dot11->find_pdu<Dot11Ack>();
ASSERT_TRUE(inner);
test_equals_expected(*inner);
}

View File

@@ -80,7 +80,7 @@ TEST_F(Dot11AssocRequestTest, ClonePDU) {
TEST_F(Dot11AssocRequestTest, FromBytes) {
std::auto_ptr<PDU> dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
ASSERT_TRUE(dot11.get());
const Dot11AssocRequest *inner = dot11->find_inner_pdu<Dot11AssocRequest>();
const Dot11AssocRequest *inner = dot11->find_pdu<Dot11AssocRequest>();
ASSERT_TRUE(inner);
test_equals_expected(*inner);
}

View File

@@ -89,7 +89,7 @@ TEST_F(Dot11AssocResponseTest, FromBytes) {
std::auto_ptr<PDU> dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
ASSERT_TRUE(dot11.get());
std::cout << (int)dot11->pdu_type() << std::endl;
const Dot11AssocResponse *inner = dot11->find_inner_pdu<Dot11AssocResponse>();
const Dot11AssocResponse *inner = dot11->find_pdu<Dot11AssocResponse>();
ASSERT_TRUE(inner);
test_equals_expected(*inner);
}

View File

@@ -96,7 +96,7 @@ TEST_F(Dot11AuthenticationTest, ClonePDU) {
TEST_F(Dot11AuthenticationTest, FromBytes) {
std::auto_ptr<PDU> dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
ASSERT_TRUE(dot11.get());
const Dot11Authentication *inner = dot11->find_inner_pdu<Dot11Authentication>();
const Dot11Authentication *inner = dot11->find_pdu<Dot11Authentication>();
ASSERT_TRUE(inner);
test_equals_expected(*inner);
}

View File

@@ -99,7 +99,7 @@ TEST_F(Dot11BeaconTest, CopyAssignmentOperator) {
TEST_F(Dot11BeaconTest, FromBytes) {
std::auto_ptr<PDU> dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
ASSERT_TRUE(dot11.get());
const Dot11Beacon *beacon = dot11->find_inner_pdu<Dot11Beacon>();
const Dot11Beacon *beacon = dot11->find_pdu<Dot11Beacon>();
ASSERT_TRUE(beacon);
test_equals_expected(*beacon);
}
@@ -355,6 +355,24 @@ TEST_F(Dot11BeaconTest, ChallengeText) {
EXPECT_EQ(dot11.challenge_text(), "libtins ftw");
}
TEST_F(Dot11BeaconTest, RSNInformationTest) {
Dot11Beacon dot11;
RSNInformation rsn_info, found;
rsn_info.add_pairwise_cypher(RSNInformation::WEP_40);
rsn_info.add_akm_cypher(RSNInformation::PSK);
rsn_info.group_suite(RSNInformation::CCMP);
rsn_info.version(0x7283);
rsn_info.capabilities(0x18ad);
dot11.rsn_information(rsn_info);
found = dot11.rsn_information();
EXPECT_EQ(rsn_info.version(), found.version());
EXPECT_EQ(rsn_info.capabilities(), found.capabilities());
EXPECT_EQ(rsn_info.group_suite(), found.group_suite());
EXPECT_EQ(rsn_info.pairwise_cyphers(), found.pairwise_cyphers());
EXPECT_EQ(rsn_info.akm_cyphers(), found.akm_cyphers());
}
TEST_F(Dot11BeaconTest, PCAPLoad1) {
const uint8_t buffer[] = {

View File

@@ -67,7 +67,7 @@ TEST_F(Dot11CFEndTest, ClonePDU) {
TEST_F(Dot11CFEndTest, FromBytes) {
std::auto_ptr<PDU> dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
ASSERT_TRUE(dot11.get());
const Dot11CFEnd *inner = dot11->find_inner_pdu<Dot11CFEnd>();
const Dot11CFEnd *inner = dot11->find_pdu<Dot11CFEnd>();
ASSERT_TRUE(inner);
test_equals_expected(*inner);
}

View File

@@ -67,7 +67,7 @@ TEST_F(Dot11EndCFAckTest, ClonePDU) {
TEST_F(Dot11EndCFAckTest, FromBytes) {
std::auto_ptr<PDU> dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
ASSERT_TRUE(dot11.get());
const Dot11EndCFAck *inner = dot11->find_inner_pdu<Dot11EndCFAck>();
const Dot11EndCFAck *inner = dot11->find_pdu<Dot11EndCFAck>();
ASSERT_TRUE(inner);
test_equals_expected(*inner);
}

View File

@@ -56,7 +56,7 @@ TEST_F(Dot11DataTest, ClonePDU) {
TEST_F(Dot11DataTest, FromBytes) {
std::auto_ptr<PDU> dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
ASSERT_TRUE(dot11.get());
const Dot11Data *inner = dot11->find_inner_pdu<Dot11Data>();
const Dot11Data *inner = dot11->find_pdu<Dot11Data>();
ASSERT_TRUE(inner);
test_equals_expected(*inner);
}

View File

@@ -78,7 +78,7 @@ TEST_F(Dot11DeauthenticationTest, ClonePDU) {
TEST_F(Dot11DeauthenticationTest, FromBytes) {
std::auto_ptr<PDU> dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
ASSERT_TRUE(dot11.get());
const Dot11Deauthentication *inner = dot11->find_inner_pdu<Dot11Deauthentication>();
const Dot11Deauthentication *inner = dot11->find_pdu<Dot11Deauthentication>();
ASSERT_TRUE(inner);
test_equals_expected(*inner);
}

View File

@@ -78,7 +78,7 @@ TEST_F(Dot11DisassocTest, ClonePDU) {
TEST_F(Dot11DisassocTest, FromBytes) {
std::auto_ptr<PDU> dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
ASSERT_TRUE(dot11.get());
const Dot11Disassoc *inner = dot11->find_inner_pdu<Dot11Disassoc>();
const Dot11Disassoc *inner = dot11->find_pdu<Dot11Disassoc>();
ASSERT_TRUE(inner);
test_equals_expected(*inner);
}

View File

@@ -68,7 +68,7 @@ TEST_F(Dot11ProbeRequestTest, ClonePDU) {
TEST_F(Dot11ProbeRequestTest, FromBytes) {
std::auto_ptr<PDU> dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
ASSERT_TRUE(dot11.get());
const Dot11ProbeRequest *inner = dot11->find_inner_pdu<Dot11ProbeRequest>();
const Dot11ProbeRequest *inner = dot11->find_pdu<Dot11ProbeRequest>();
ASSERT_TRUE(inner);
test_equals_expected(*inner);
}

View File

@@ -88,7 +88,7 @@ TEST_F(Dot11ProbeResponseTest, ClonePDU) {
TEST_F(Dot11ProbeResponseTest, FromBytes) {
std::auto_ptr<PDU> dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
ASSERT_TRUE(dot11.get());
const Dot11ProbeResponse *inner = dot11->find_inner_pdu<Dot11ProbeResponse>();
const Dot11ProbeResponse *inner = dot11->find_pdu<Dot11ProbeResponse>();
ASSERT_TRUE(inner);
test_equals_expected(*inner);
}

View File

@@ -67,7 +67,7 @@ TEST_F(Dot11PSPollTest, ClonePDU) {
TEST_F(Dot11PSPollTest, FromBytes) {
std::auto_ptr<PDU> dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
ASSERT_TRUE(dot11.get());
const Dot11PSPoll *inner = dot11->find_inner_pdu<Dot11PSPoll>();
const Dot11PSPoll *inner = dot11->find_pdu<Dot11PSPoll>();
ASSERT_TRUE(inner);
test_equals_expected(*inner);
}

View File

@@ -87,7 +87,7 @@ TEST_F(Dot11ReAssocRequestTest, ClonePDU) {
TEST_F(Dot11ReAssocRequestTest, FromBytes) {
std::auto_ptr<PDU> dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
ASSERT_TRUE(dot11.get());
const Dot11ReAssocRequest *inner = dot11->find_inner_pdu<Dot11ReAssocRequest>();
const Dot11ReAssocRequest *inner = dot11->find_pdu<Dot11ReAssocRequest>();
ASSERT_TRUE(inner);
test_equals_expected(*inner);
}

View File

@@ -76,7 +76,7 @@ TEST_F(Dot11ReAssocResponseTest, ClonePDU) {
TEST_F(Dot11ReAssocResponseTest, FromBytes) {
std::auto_ptr<PDU> dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
ASSERT_TRUE(dot11.get());
const Dot11ReAssocResponse *inner = dot11->find_inner_pdu<Dot11ReAssocResponse>();
const Dot11ReAssocResponse *inner = dot11->find_pdu<Dot11ReAssocResponse>();
ASSERT_TRUE(inner);
test_equals_expected(*inner);
}

View File

@@ -67,7 +67,7 @@ TEST_F(Dot11RTSTest, ClonePDU) {
TEST_F(Dot11RTSTest, FromBytes) {
std::auto_ptr<PDU> dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
ASSERT_TRUE(dot11.get());
const Dot11RTS *inner = dot11->find_inner_pdu<Dot11RTS>();
const Dot11RTS *inner = dot11->find_pdu<Dot11RTS>();
ASSERT_TRUE(inner);
test_equals_expected(*inner);
}