mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
LLC now working with tests! IEEE802_3 also working \(without tests\)
This commit is contained in:
@@ -123,10 +123,10 @@ namespace Tins {
|
||||
void dsap(uint8_t new_dsap);
|
||||
|
||||
/**
|
||||
* \brief Setter for the command bit.
|
||||
* \brief Setter for the response bit.
|
||||
* \param value The value to be set.
|
||||
*/
|
||||
void command(bool value);
|
||||
void response(bool value);
|
||||
|
||||
/**
|
||||
* \brief Setter for the ssap field.
|
||||
@@ -200,10 +200,10 @@ namespace Tins {
|
||||
inline uint8_t dsap() {return _header.dsap; }
|
||||
|
||||
/**
|
||||
* \brief Getter for the command bit.
|
||||
* \return Wheter the command bit is set or not.
|
||||
* \brief Getter for the response bit.
|
||||
* \return Whether the response bit is set or not.
|
||||
*/
|
||||
inline bool command() {return _header.ssap & 0x01; }
|
||||
inline bool response() {return (_header.ssap & 0x01); }
|
||||
|
||||
/**
|
||||
* \brief Getter for the ssap field.
|
||||
|
||||
@@ -59,6 +59,7 @@ LLC::LLC(const uint8_t *buffer, uint32_t total_sz) : PDU(0xff) {
|
||||
std::memcpy(&_header, buffer, sizeof(_header));
|
||||
buffer += sizeof(_header);
|
||||
total_sz -= sizeof(_header);
|
||||
information_field_length = 0;
|
||||
if ((buffer[0] & 0x03) == LLC::UNNUMBERED) {
|
||||
type(LLC::UNNUMBERED);
|
||||
std::memcpy(&control_field.unnumbered, buffer, sizeof(un_control_field));
|
||||
@@ -69,7 +70,7 @@ LLC::LLC(const uint8_t *buffer, uint32_t total_sz) : PDU(0xff) {
|
||||
else {
|
||||
type((Format)(buffer[0] & 0x03));
|
||||
control_field_length = 2;
|
||||
std::memcpy(&control_field.info, buffer, sizeof(un_control_field));
|
||||
std::memcpy(&control_field.info, buffer, sizeof(info_control_field));
|
||||
buffer += 2;
|
||||
total_sz -= 2;
|
||||
}
|
||||
@@ -99,7 +100,7 @@ void LLC::dsap(uint8_t new_dsap) {
|
||||
_header.dsap = new_dsap;
|
||||
}
|
||||
|
||||
void LLC::command(bool value) {
|
||||
void LLC::response(bool value) {
|
||||
if (value) {
|
||||
_header.ssap |= 0x01;
|
||||
}
|
||||
|
||||
@@ -35,11 +35,11 @@ TEST_F(LLCTest, DefaultConstructor) {
|
||||
|
||||
TEST_F(LLCTest, ParamsConstructor) {
|
||||
LLC llc(0xAD, 0x16);
|
||||
EXPECT_EQ(llc.dsap(), 0xAD);
|
||||
EXPECT_EQ(llc.ssap(), 0x16);
|
||||
EXPECT_EQ(llc.type(), LLC::INFORMATION);
|
||||
EXPECT_EQ(llc.header_size(), 4);
|
||||
EXPECT_EQ(llc.pdu_type(), PDU::LLC);
|
||||
EXPECT_EQ(0xAD, llc.dsap());
|
||||
EXPECT_EQ(0x16, llc.ssap());
|
||||
EXPECT_EQ(LLC::INFORMATION, llc.type());
|
||||
EXPECT_EQ(4, llc.header_size());
|
||||
EXPECT_EQ(PDU::LLC, llc.pdu_type());
|
||||
}
|
||||
|
||||
TEST_F(LLCTest, Group) {
|
||||
@@ -58,12 +58,12 @@ TEST_F(LLCTest, Dsap) {
|
||||
EXPECT_EQ(llc.dsap(), 0x01);
|
||||
}
|
||||
|
||||
TEST_F(LLCTest, Command) {
|
||||
TEST_F(LLCTest, Response) {
|
||||
LLC llc;
|
||||
llc.command(true);
|
||||
EXPECT_TRUE(llc.command());
|
||||
llc.command(false);
|
||||
EXPECT_FALSE(llc.command());
|
||||
llc.response(true);
|
||||
EXPECT_TRUE(llc.response());
|
||||
llc.response(false);
|
||||
EXPECT_FALSE(llc.response());
|
||||
}
|
||||
|
||||
TEST_F(LLCTest, Ssap) {
|
||||
@@ -112,12 +112,12 @@ TEST_F(LLCTest, ReceiveSeqNumber) {
|
||||
llc.type(LLC::INFORMATION);
|
||||
llc.receive_seq_number(18);
|
||||
EXPECT_EQ(18, llc.receive_seq_number());
|
||||
llc.send_seq_number(127);
|
||||
llc.receive_seq_number(127);
|
||||
EXPECT_EQ(127, llc.receive_seq_number());
|
||||
llc.type(LLC::SUPERVISORY);
|
||||
llc.receive_seq_number(19);
|
||||
EXPECT_EQ(19, llc.receive_seq_number());
|
||||
llc.send_seq_number(127);
|
||||
llc.receive_seq_number(127);
|
||||
EXPECT_EQ(127, llc.receive_seq_number());
|
||||
llc.type(LLC::UNNUMBERED);
|
||||
EXPECT_EQ(0, llc.receive_seq_number());
|
||||
@@ -171,32 +171,32 @@ TEST_F(LLCTest, ModifierFunction) {
|
||||
|
||||
TEST_F(LLCTest, ConstructorFromBuffer) {
|
||||
LLC llc(LLCTest::from_buffer_info, 4);
|
||||
EXPECT_EQ(llc.type(), LLC::INFORMATION);
|
||||
EXPECT_EQ(llc.header_size(), 4);
|
||||
EXPECT_EQ(llc.dsap(), 0xFE);
|
||||
EXPECT_EQ(llc.ssap(), 0x48);
|
||||
EXPECT_EQ(LLC::INFORMATION, llc.type());
|
||||
EXPECT_EQ(4, llc.header_size());
|
||||
EXPECT_EQ(0xFE, llc.dsap());
|
||||
EXPECT_EQ(0x48, llc.ssap());
|
||||
EXPECT_FALSE(llc.group());
|
||||
EXPECT_TRUE(llc.command());
|
||||
EXPECT_FALSE(llc.response());
|
||||
EXPECT_TRUE(llc.poll_final());
|
||||
EXPECT_EQ(llc.send_seq_number(), 30);
|
||||
EXPECT_EQ(llc.receive_seq_number(), 29);
|
||||
EXPECT_EQ(30, llc.send_seq_number());
|
||||
EXPECT_EQ(29, llc.receive_seq_number());
|
||||
|
||||
LLC llc_super(LLCTest::from_buffer_super, 4);
|
||||
EXPECT_EQ(llc_super.header_size(), 4);
|
||||
EXPECT_EQ(llc_super.dsap(), 0x4B);
|
||||
EXPECT_EQ(llc_super.ssap(), 0x19);
|
||||
LLC llc_super(4, LLCTest::from_buffer_super);
|
||||
EXPECT_EQ(4, llc_super.header_size());
|
||||
EXPECT_EQ(0x4B, llc_super.dsap());
|
||||
EXPECT_EQ(0x19, llc_super.ssap());
|
||||
EXPECT_TRUE(llc_super.group());
|
||||
EXPECT_FALSE(llc_super.command());
|
||||
EXPECT_TRUE(llc_super.response());
|
||||
EXPECT_FALSE(llc_super.poll_final());
|
||||
EXPECT_EQ(llc_super.receive_seq_number(), 29);
|
||||
EXPECT_EQ(llc_super.supervisory_function(), LLC::RECEIVE_NOT_READY);
|
||||
EXPECT_EQ(29, llc_super.receive_seq_number());
|
||||
EXPECT_EQ(LLC::RECEIVE_NOT_READY, llc_super.supervisory_function());
|
||||
|
||||
LLC llc_unnum(LLCTest::from_buffer_unnumbered, 3);
|
||||
EXPECT_EQ(llc_unnum.header_size(), 3);
|
||||
EXPECT_EQ(llc_unnum.dsap(), 0xaa);
|
||||
EXPECT_EQ(llc_unnum.ssap(), 0x17);
|
||||
EXPECT_FALSE(llc_unnum.group());
|
||||
EXPECT_FALSE(llc_unnum.command());
|
||||
EXPECT_TRUE(llc_unnum.response());
|
||||
EXPECT_FALSE(llc_unnum.poll_final());
|
||||
EXPECT_EQ(llc_unnum.modifier_function(), LLC::SABME);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user