TEST_F(EthernetIITest, SerializeSmallEthernetWithPadding) { EthernetII eth(smallip_packet, sizeof(smallip_packet)); ASSERT_TRUE(eth.inner_pdu() != NULL); PDU::serialization_type serialized = eth.serialize(); EXPECT_EQ(serialized.size(), sizeof(smallip_packet)); EXPECT_TRUE(std::equal(serialized.begin(), serialized.end(), smallip_packet)); }
TEST_F(EthernetIITest, Serialize) { EthernetII eth(dst_addr, src_addr); eth.payload_type(p_type); PDU::serialization_type serialized = eth.serialize(); ASSERT_EQ(serialized.size(), sizeof(expected_packet)); EXPECT_TRUE(std::equal(serialized.begin(), serialized.end(), expected_packet)); }
TEST_F(DHCPTest, Serialize) { DHCP dhcp1(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = dhcp1.serialize(); ASSERT_EQ(buffer.size(), sizeof(expected_packet)); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); DHCP dhcp2(&buffer[0], (uint32_t)buffer.size()); test_equals(dhcp1, dhcp2); }
TEST_F(Dot11BeaconTest, PCAPLoad1) { const uint8_t buffer[] = { 128, 0, 0, 0, 255, 255, 255, 255, 255, 255, 244, 236, 56, 254, 77, 146, 244, 236, 56, 254, 77, 146, 224, 234, 128, 209, 212, 206, 44, 0, 0, 0, 100, 0, 49, 4, 0, 7, 83, 101, 103, 117, 110, 100, 111, 1, 8, 130, 132, 139, 150, 12, 18, 24, 36, 3, 1, 1, 5, 4, 0, 1, 0, 0, 7, 6, 85, 83, 32, 1, 13, 20, 42, 1, 0, 48, 20, 1, 0, 0, 15, 172, 4, 1, 0, 0, 15, 172, 4, 1, 0, 0, 15, 172, 2, 0, 0, 50, 4, 48, 72, 96, 108, 221, 24, 0, 80, 242, 2, 1, 1, 3, 0, 3, 164, 0, 0, 39, 164, 0, 0, 66, 67, 94, 0, 98, 50, 47, 0, 221, 9, 0, 3, 127, 1, 1, 0, 0, 255, 127 }; typedef byte_array country_container; Dot11Beacon dot11(buffer, sizeof(buffer)); float rates[] = { 1.0f, 2.0f, 5.5f, 11.0f, 6.0f, 9.0f, 12.0f, 18.0f}, ext_rates[] = { 24.0f, 36.0f, 48.0f, 54.0f }; Dot11Beacon::rates_type rates_parsed = dot11.supported_rates(); Dot11Beacon::rates_type ext_rates_parsed = dot11.extended_supported_rates(); Dot11Beacon::tim_type tim(0, 1, 0, byte_array(1)), tim_parsed = dot11.tim(); Dot11Beacon::country_params country("US ", country_container(1, 1), country_container(1, 13), country_container(1, 20)), country_parsed = dot11.country(); EXPECT_EQ(dot11.ssid(), "Segundo"); ASSERT_EQ(rates_parsed.size(), sizeof(rates) / sizeof(float)); EXPECT_TRUE(std::equal(rates_parsed.begin(), rates_parsed.end(), rates)); ASSERT_EQ(ext_rates_parsed.size(), sizeof(ext_rates) / sizeof(float)); EXPECT_TRUE(std::equal(ext_rates_parsed.begin(), ext_rates_parsed.end(), ext_rates)); EXPECT_EQ(1, dot11.ds_parameter_set()); EXPECT_EQ(tim.dtim_count, tim_parsed.dtim_count); EXPECT_EQ(tim.dtim_period, tim_parsed.dtim_period); EXPECT_EQ(tim.bitmap_control, tim_parsed.bitmap_control); EXPECT_EQ(tim.partial_virtual_bitmap, tim_parsed.partial_virtual_bitmap); EXPECT_EQ(country.country, country_parsed.country); EXPECT_EQ(country.first_channel, country_parsed.first_channel); EXPECT_EQ(country.number_channels, country_parsed.number_channels); EXPECT_EQ(country.max_transmit_power, country_parsed.max_transmit_power); EXPECT_EQ(dot11.erp_information(), 0); PDU::serialization_type serialized = dot11.serialize(); ASSERT_EQ(sizeof(buffer), serialized.size()); EXPECT_TRUE(std::equal(serialized.begin(), serialized.end(), buffer)); }
TEST_F(TCPTest, Serialize) { TCP tcp1(expected_packet, sizeof(expected_packet)); PDU::serialization_type buffer = tcp1.serialize(); ASSERT_EQ(buffer.size(), sizeof(expected_packet)); EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), expected_packet)); }
TEST_F(Dot11PSPollTest, Serialize) { Dot11PSPoll 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)); }