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

Removed the useless PDU::flag member. Added a PDU concatenation operator.

This commit is contained in:
Matias Fontanini
2012-10-07 18:51:06 -03:00
parent da60d99f98
commit 153bcecc35
24 changed files with 169 additions and 89 deletions

View File

@@ -3,6 +3,9 @@
#include <string>
#include <stdint.h>
#include "ip.h"
#include "tcp.h"
#include "udp.h"
#include "icmp.h"
#include "ip_address.h"
#include "utils.h"
@@ -238,3 +241,17 @@ TEST_F(IPTest, Serialize) {
ASSERT_EQ(buffer.size(), sizeof(expected_packet));
EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet));
}
TEST_F(IPTest, StackedProtocols) {
IP ip = IP() / TCP();
IP::serialization_type buffer = ip.serialize();
EXPECT_TRUE(IP(&buffer[0], buffer.size()).find_pdu<TCP>());
ip = IP() / UDP();
buffer = ip.serialize();
EXPECT_TRUE(IP(&buffer[0], buffer.size()).find_pdu<UDP>());
ip = IP() / ICMP();
buffer = ip.serialize();
EXPECT_TRUE(IP(&buffer[0], buffer.size()).find_pdu<ICMP>());
}