mirror of
https://github.com/mfontanini/libtins
synced 2026-01-28 12:44:25 +01:00
Add ICMP extensions to ICMP PDU
The length field is still not being set
This commit is contained in:
@@ -14,7 +14,7 @@ using namespace Tins;
|
||||
class ICMPTest : public testing::Test {
|
||||
public:
|
||||
static const uint8_t expected_packets[][8];
|
||||
static const uint8_t ts_request[], ts_reply[];
|
||||
static const uint8_t ts_request[], ts_reply[], packet_with_extensions[];
|
||||
static const uint32_t expected_packet_count;
|
||||
|
||||
void test_equals(const ICMP &icmp1, const ICMP &icmp2);
|
||||
@@ -35,6 +35,16 @@ const uint8_t ICMPTest::ts_reply[] = {
|
||||
14, 0, 172, 45, 0, 0, 0, 0, 0, 0, 0, 0, 4, 144, 30, 89, 4, 144, 30, 89, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
const uint8_t ICMPTest::packet_with_extensions[] = {
|
||||
11, 0, 205, 4, 0, 0, 0, 0, 69, 0, 0, 40, 165, 76, 0, 0, 1, 17, 247, 111, 12, 4, 4, 4, 12,
|
||||
1, 1, 1, 165, 75, 130, 155, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 197, 95, 0,
|
||||
8, 1, 1, 24, 150, 1, 1
|
||||
};
|
||||
|
||||
|
||||
|
||||
TEST_F(ICMPTest, DefaultConstructor) {
|
||||
ICMP icmp;
|
||||
@@ -289,10 +299,9 @@ TEST_F(ICMPTest, ConstructorFromBuffer) {
|
||||
}
|
||||
|
||||
TEST_F(ICMPTest, ExtensionsParsingWithoutALengthField) {
|
||||
const uint8_t packet[] = { 11, 0, 205, 4, 0, 0, 0, 0, 69, 0, 0, 40, 165, 76, 0, 0, 1, 17, 247, 111, 12, 4, 4, 4, 12, 1, 1, 1, 165, 75, 130, 155, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 197, 95, 0, 8, 1, 1, 24, 150, 1, 1 };
|
||||
const uint8_t encapsulated[] = { 69, 0, 0, 40, 165, 76, 0, 0, 1, 17, 247, 111, 12, 4, 4, 4, 12, 1, 1, 1, 165, 75, 130, 155, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
const uint8_t ext[] = { 0, 8, 1, 1, 24, 150, 1, 1 };
|
||||
ICMP icmp(packet, sizeof(packet));
|
||||
ICMP icmp(packet_with_extensions, sizeof(packet_with_extensions));
|
||||
ICMPExtensionsStructure extensions = icmp.extensions();
|
||||
ASSERT_EQ(1, extensions.extensions().size());
|
||||
EXPECT_EQ(
|
||||
@@ -305,4 +314,11 @@ TEST_F(ICMPTest, ExtensionsParsingWithoutALengthField) {
|
||||
RawPDU::payload_type(encapsulated, encapsulated + sizeof(encapsulated)),
|
||||
raw->payload()
|
||||
);
|
||||
|
||||
PDU::serialization_type buffer = icmp.serialize();
|
||||
EXPECT_EQ(sizeof(packet_with_extensions), buffer.size());
|
||||
EXPECT_EQ(
|
||||
buffer,
|
||||
PDU::serialization_type(packet_with_extensions, packet_with_extensions + sizeof(packet_with_extensions))
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user