mirror of
https://github.com/mfontanini/libtins
synced 2026-01-29 04:54:28 +01:00
Added constructor from buffer test for Dot11BlockAckRequest.
This commit is contained in:
@@ -2874,7 +2874,7 @@ namespace Tins {
|
||||
/**
|
||||
* \brief Getter for the control ta additional fields size.
|
||||
*/
|
||||
uint32_t controlta_size() const { return sizeof(_taddr) + sizeof(ieee80211_header); }
|
||||
uint32_t controlta_size() const { return _taddr.size() + sizeof(ieee80211_header); }
|
||||
|
||||
uint32_t write_ext_header(uint8_t *buffer, uint32_t total_sz);
|
||||
private:
|
||||
@@ -3258,8 +3258,8 @@ namespace Tins {
|
||||
private:
|
||||
TINS_BEGIN_PACK
|
||||
struct BarControl {
|
||||
uint16_t reserved:12,
|
||||
tid:4;
|
||||
uint16_t tid:4,
|
||||
reserved:12;
|
||||
} TINS_END_PACK;
|
||||
|
||||
TINS_BEGIN_PACK
|
||||
|
||||
@@ -1464,7 +1464,9 @@ Dot11Ack::Dot11Ack(const address_type &dst_addr, PDU* child)
|
||||
subtype(ACK);
|
||||
}
|
||||
|
||||
Dot11Ack::Dot11Ack(const uint8_t *buffer, uint32_t total_sz) : Dot11Control(buffer, total_sz) {
|
||||
Dot11Ack::Dot11Ack(const uint8_t *buffer, uint32_t total_sz)
|
||||
: Dot11Control(buffer, total_sz)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -1477,7 +1479,9 @@ Dot11BlockAckRequest::Dot11BlockAckRequest(const address_type &dst_addr,
|
||||
init_block_ack();
|
||||
}
|
||||
|
||||
Dot11BlockAckRequest::Dot11BlockAckRequest(const uint8_t *buffer, uint32_t total_sz) : Dot11ControlTA(buffer, total_sz) {
|
||||
Dot11BlockAckRequest::Dot11BlockAckRequest(const uint8_t *buffer, uint32_t total_sz)
|
||||
: Dot11ControlTA(buffer, total_sz)
|
||||
{
|
||||
uint32_t padding = controlta_size();
|
||||
buffer += padding;
|
||||
total_sz -= padding;
|
||||
|
||||
@@ -5,10 +5,6 @@
|
||||
#include "dot11.h"
|
||||
#include "tests/dot11.h"
|
||||
|
||||
/* PLZ PLZ I need some BLOCK ACK REQUEST packet dump,
|
||||
* in order to check the constructor from buffer.
|
||||
*/
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace Tins;
|
||||
@@ -20,23 +16,24 @@ public:
|
||||
static const address_type empty_addr, hwaddr;
|
||||
static const uint8_t expected_packet[];
|
||||
};
|
||||
/*const uint8_t Dot11BlockAckRequestTest::expected_packet[] = {
|
||||
'\x00', '\x00', ' ', '\x00', 'o', 'H', '\x00', '\x00', 's', 'H', '\xbf', '4', '\x00', '\x00', '\x00', '\x00', '\x10', '\x02', 'l', '\t', '\xdf', '\x00', '\xdc', '\xe0', '\x01', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\xfb', '\x00', '\xcf', '\x01', '\x00', '!', 'k', '\x02', '\xe5', '\x99', '\x00', '\x1c', '\xa0', '\xa8', '\r', 'U', '\x04', '\x00', '\xcf', '!', '\xc7', '\xf3', '\x00', ';'
|
||||
};*/
|
||||
|
||||
const uint8_t Dot11BlockAckRequestTest::expected_packet[] = {
|
||||
132, 0, 176, 1, 0, 33, 107, 2, 154, 230, 0, 28, 223, 215, 13, 85, 4,
|
||||
0, 176, 33
|
||||
};
|
||||
|
||||
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) {
|
||||
EXPECT_EQ(dot11.type(), Dot11::CONTROL);
|
||||
EXPECT_EQ(dot11.subtype(), Dot11::BLOCK_ACK_REQ);
|
||||
EXPECT_EQ(dot11.fragment_number(), 6);
|
||||
EXPECT_EQ(dot11.start_sequence(), 0x294);
|
||||
EXPECT_EQ(dot11.bar_control(), 0x92f);
|
||||
EXPECT_EQ(dot11.bar_control(), 4);
|
||||
EXPECT_EQ(dot11.start_sequence(), 539);
|
||||
EXPECT_EQ(dot11.fragment_number(), 0);
|
||||
}
|
||||
|
||||
TEST_F(Dot11BlockAckRequestTest, Constructor) {
|
||||
@@ -48,10 +45,10 @@ TEST_F(Dot11BlockAckRequestTest, Constructor) {
|
||||
EXPECT_EQ(dot11.bar_control(), 0);
|
||||
}
|
||||
|
||||
/*TEST_F(Dot11BlockAckRequestTest, ConstructorFromBuffer) {
|
||||
TEST_F(Dot11BlockAckRequestTest, ConstructorFromBuffer) {
|
||||
Dot11BlockAckRequest dot11(expected_packet, sizeof(expected_packet));
|
||||
test_equals_expected(dot11);
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
TEST_F(Dot11BlockAckRequestTest, CopyConstructor) {
|
||||
@@ -82,17 +79,17 @@ TEST_F(Dot11BlockAckRequestTest, ClonePDU) {
|
||||
test_equals(dot1, *dot2);
|
||||
}
|
||||
|
||||
/*TEST_F(Dot11BlockAckRequestTest, FromBytes) {
|
||||
TEST_F(Dot11BlockAckRequestTest, FromBytes) {
|
||||
std::auto_ptr<PDU> dot11(Dot11::from_bytes(expected_packet, sizeof(expected_packet)));
|
||||
ASSERT_TRUE(dot11.get());
|
||||
const Dot11BlockAckRequest *inner = dot11->find_inner_pdu<Dot11BlockAckRequest>();
|
||||
const Dot11BlockAckRequest *inner = dot11->find_pdu<Dot11BlockAckRequest>();
|
||||
ASSERT_TRUE(inner);
|
||||
test_equals_expected(*inner);
|
||||
}*/
|
||||
}
|
||||
|
||||
/*TEST_F(Dot11BlockAckRequestTest, Serialize) {
|
||||
TEST_F(Dot11BlockAckRequestTest, Serialize) {
|
||||
Dot11BlockAckRequest pdu(expected_packet, sizeof(expected_packet));
|
||||
PDU::serialization_type buffer = pdu.serialize();
|
||||
ASSERT_EQ(sizeof(expected_packet), buffer.size());
|
||||
EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet));
|
||||
}*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user