1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-29 13:04:28 +01:00

Fixed some compilation errors/warnings and bugs when using Big Endian architectures.

This commit is contained in:
Matias Fontanini
2013-09-24 00:34:14 -03:00
parent 9cbac6b044
commit c4e6a7c0d6
24 changed files with 217 additions and 183 deletions

View File

@@ -105,7 +105,7 @@ TEST_F(DHCPTest, HOps) {
TEST_F(DHCPTest, Xid) {
DHCP dhcp;
dhcp.xid(0x71bd167c);
EXPECT_EQ(dhcp.xid(), 0x71bd167c);
EXPECT_EQ(dhcp.xid(), 0x71bd167cU);
}
TEST_F(DHCPTest, Secs) {
@@ -284,7 +284,7 @@ TEST_F(DHCPTest, ConstructorFromBuffer) {
EXPECT_EQ(dhcp1.htype(), 1);
ASSERT_EQ(dhcp1.hlen(), (const size_t)EthernetII::address_type::address_size);
EXPECT_EQ(dhcp1.hops(), 0x1f);
EXPECT_EQ(dhcp1.xid(), 0x3fab23de);
EXPECT_EQ(dhcp1.xid(), 0x3fab23deU);
EXPECT_EQ(dhcp1.secs(), 0x9f1a);
EXPECT_EQ(dhcp1.padding(), 0);
EXPECT_EQ(dhcp1.ciaddr(), IPv4Address("192.168.0.102"));

View File

@@ -23,13 +23,13 @@ TEST_F(DHCPv6Test, DefaultConstructor) {
DHCPv6 dhcp;
EXPECT_EQ(0, (int)dhcp.msg_type());
EXPECT_EQ(0, dhcp.hop_count());
EXPECT_EQ(0, dhcp.transaction_id());
EXPECT_EQ(0U, dhcp.transaction_id());
}
TEST_F(DHCPv6Test, ConstructorFromBuffer) {
DHCPv6 dhcp(expected_packet, sizeof(expected_packet));
EXPECT_EQ(DHCPv6::SOLICIT, dhcp.msg_type());
EXPECT_EQ(0xe828b9, dhcp.transaction_id());
EXPECT_EQ(0xe828b9U, dhcp.transaction_id());
EXPECT_TRUE(dhcp.search_option(DHCPv6::CLIENTID));
EXPECT_TRUE(dhcp.search_option(DHCPv6::IA_NA));
EXPECT_TRUE(dhcp.search_option(DHCPv6::ELAPSED_TIME));
@@ -62,7 +62,7 @@ TEST_F(DHCPv6Test, HopCount) {
TEST_F(DHCPv6Test, TransactionId) {
DHCPv6 dhcp;
dhcp.transaction_id(0x8af2ad);
EXPECT_EQ(0x8af2ad, dhcp.transaction_id());
EXPECT_EQ(0x8af2adU, dhcp.transaction_id());
}
// Options
@@ -160,7 +160,7 @@ TEST_F(DHCPv6Test, Authentication) {
data.protocol = 0x92;
data.algorithm = 0x8f;
data.rdm = 0xa1;
data.replay_detection = 0x78ad6d5290398df7;
data.replay_detection = 0x78ad6d5290398df7ULL;
data.auth_info.push_back(0);
data.auth_info.push_back(1);
data.auth_info.push_back(2);

View File

@@ -76,11 +76,11 @@ TEST_F(DNSTest, ConstructorFromBuffer) {
EXPECT_EQ(dns.answers_count(), 1);
std::list<DNS::Query> queries = dns.queries();
ASSERT_EQ(queries.size(), 1);
ASSERT_EQ(queries.size(), 1U);
test_equals(queries.front(), DNS::Query("www.example.com", DNS::A, DNS::IN));
std::list<DNS::Resource> answers = dns.answers();
ASSERT_EQ(answers.size(), 1);
ASSERT_EQ(answers.size(), 1U);
test_equals(answers.front(), DNS::Resource("www.example.com", "192.168.0.1", DNS::A, DNS::IN, 0x1234));
}
@@ -212,13 +212,13 @@ TEST_F(DNSTest, Answers) {
EXPECT_TRUE(it->dname() == "www.example.com" || it->dname() == "www.example2.com");
if(it->dname() == "www.example.com") {
EXPECT_EQ(it->type(), DNS::A);
EXPECT_EQ(it->ttl(), 0x762);
EXPECT_EQ(it->ttl(), 0x762U);
EXPECT_EQ(it->data(), "127.0.0.1");
EXPECT_EQ(it->query_class(), DNS::IN);
}
else if(it->dname() == "www.example2.com") {
EXPECT_EQ(it->type(), DNS::MX);
EXPECT_EQ(it->ttl(), 0x762);
EXPECT_EQ(it->ttl(), 0x762U);
EXPECT_EQ(it->data(), "mail.example.com");
EXPECT_EQ(it->query_class(), DNS::IN);
}
@@ -235,7 +235,7 @@ TEST_F(DNSTest, AnswersWithSameName) {
EXPECT_TRUE(it->data() == "127.0.0.1" || it->data() == "127.0.0.2");
EXPECT_EQ(it->dname(), "www.example.com");
EXPECT_EQ(it->type(), DNS::A);
EXPECT_EQ(it->ttl(), 0x762);
EXPECT_EQ(it->ttl(), 0x762U);
EXPECT_EQ(it->query_class(), DNS::IN);
}
}
@@ -250,7 +250,7 @@ TEST_F(DNSTest, AnswersV6) {
for(DNS::resources_type::const_iterator it = resources.begin(); it != resources.end(); ++it) {
EXPECT_EQ(it->dname(), "www.example.com");
EXPECT_EQ(it->type(), DNS::AAAA);
EXPECT_EQ(it->ttl(), 0x762);
EXPECT_EQ(it->ttl(), 0x762U);
EXPECT_EQ(it->data(), "f9a8:239::1:1");
EXPECT_EQ(it->query_class(), DNS::IN);
}

View File

@@ -26,7 +26,7 @@ const uint8_t Dot11BeaconTest::expected_packet[] = {
void test_equals_expected(const Dot11Beacon &dot11) {
EXPECT_EQ(dot11.subtype(), 8);
EXPECT_EQ(dot11.timestamp(), 0x1fad2341289301faLL);
EXPECT_EQ(dot11.timestamp(), 0x1fad2341289301faULL);
EXPECT_EQ(dot11.interval(), 0x14fa);
const Dot11Beacon::capability_information &info = dot11.capabilities();
@@ -68,7 +68,7 @@ TEST_F(Dot11BeaconTest, DefaultConstructor) {
test_equals_empty(dot11.capabilities());
EXPECT_EQ(dot11.interval(), 0);
EXPECT_EQ(dot11.timestamp(), 0);
EXPECT_EQ(dot11.timestamp(), 0U);
EXPECT_EQ(dot11.subtype(), Dot11::BEACON);
}
@@ -116,7 +116,7 @@ TEST_F(Dot11BeaconTest, FromBytes) {
TEST_F(Dot11BeaconTest, Timestamp) {
Dot11Beacon dot11;
dot11.timestamp(0x1fad2341289301faLL);
EXPECT_EQ(dot11.timestamp(), 0x1fad2341289301faLL);
EXPECT_EQ(dot11.timestamp(), 0x1fad2341289301faULL);
}
TEST_F(Dot11BeaconTest, Interval) {

View File

@@ -139,6 +139,8 @@ TEST_F(Dot11DataTest, Serialize) {
TEST_F(Dot11DataTest, Source_Dest_BSSID_Address1) {
Dot11Data data(from_to_ds10, sizeof(from_to_ds10));
EXPECT_EQ(1, data.from_ds());
EXPECT_EQ(0, data.to_ds());
EXPECT_EQ(data.src_addr(), "00:18:f8:f5:c2:c6");
EXPECT_EQ(data.dst_addr(), "00:25:9c:74:95:92");
EXPECT_EQ(data.bssid_addr(), "00:18:f8:f5:c2:c6");
@@ -146,13 +148,17 @@ TEST_F(Dot11DataTest, Source_Dest_BSSID_Address1) {
TEST_F(Dot11DataTest, Source_Dest_BSSID_Address2) {
Dot11Data data(from_to_ds01, sizeof(from_to_ds01));
EXPECT_EQ(0, data.from_ds());
EXPECT_EQ(1, data.to_ds());
EXPECT_EQ(data.src_addr(), "00:25:9c:74:95:92");
EXPECT_EQ(data.dst_addr(), "00:18:f8:f5:c2:c6");
EXPECT_EQ(data.bssid_addr(), "00:18:f8:f5:c2:c6");
}
TEST_F(Dot11DataTest, Source_Dest_BSSID_Address3) {
Dot11Data data(from_to_ds01, sizeof(from_to_ds00));
Dot11Data data(from_to_ds00, sizeof(from_to_ds00));
EXPECT_EQ(0, data.from_ds());
EXPECT_EQ(0, data.to_ds());
EXPECT_EQ(data.src_addr(), "00:25:9c:74:95:92");
EXPECT_EQ(data.dst_addr(), "00:18:f8:f5:c2:c6");
EXPECT_EQ(data.bssid_addr(), "00:18:f8:f5:c2:c6");

View File

@@ -30,7 +30,7 @@ void test_equals(const Dot11ProbeResponse &dot1, const Dot11ProbeResponse &dot2)
void test_equals_expected(const Dot11ProbeResponse &dot11) {
test_equals_expected(static_cast<const Dot11ManagementFrame&>(dot11));
EXPECT_EQ(dot11.timestamp(), 0x17a698df27838a91LL);
EXPECT_EQ(dot11.timestamp(), 0x17a698df27838a91ULL);
EXPECT_EQ(dot11.interval(), 0x928d);
EXPECT_EQ(dot11.subtype(), Dot11::PROBE_RESP);
}
@@ -38,7 +38,7 @@ void test_equals_expected(const Dot11ProbeResponse &dot11) {
TEST_F(Dot11ProbeResponseTest, Constructor) {
Dot11ProbeResponse dot11;
test_equals_empty(static_cast<const Dot11ManagementFrame&>(dot11));
EXPECT_EQ(dot11.timestamp(), 0);
EXPECT_EQ(dot11.timestamp(), 0U);
EXPECT_EQ(dot11.interval(), 0);
EXPECT_EQ(dot11.subtype(), Dot11::PROBE_RESP);
}
@@ -70,7 +70,7 @@ TEST_F(Dot11ProbeResponseTest, Interval) {
TEST_F(Dot11ProbeResponseTest, Timestamp) {
Dot11ProbeResponse dot11;
dot11.timestamp(0x92af8a72df928a7cLL);
EXPECT_EQ(dot11.timestamp(), 0x92af8a72df928a7cLL);
EXPECT_EQ(dot11.timestamp(), 0x92af8a72df928a7cULL);
}
TEST_F(Dot11ProbeResponseTest, ClonePDU) {

View File

@@ -90,7 +90,7 @@ TEST_F(ICMPTest, Checksum) {
TEST_F(ICMPTest, Gateway) {
ICMP icmp;
icmp.gateway(0x31fdb5cd);
EXPECT_EQ(icmp.gateway(), 0x31fdb5cd);
EXPECT_EQ(icmp.gateway(), 0x31fdb5cdU);
}
TEST_F(ICMPTest, MTU) {
@@ -176,7 +176,7 @@ TEST_F(ICMPTest, SetRedirect) {
icmp.set_redirect(0x3d, 0xf1dc);
EXPECT_EQ(icmp.type(), ICMP::REDIRECT);
EXPECT_EQ(icmp.code(), 0x3d);
EXPECT_EQ(icmp.gateway(), 0xf1dc);
EXPECT_EQ(icmp.gateway(), 0xf1dcU);
}
void ICMPTest::test_equals(const ICMP &icmp1, const ICMP &icmp2) {

View File

@@ -70,20 +70,20 @@ TEST_F(ICMPv6Test, ConstructorFromBuffer2) {
EXPECT_EQ(icmp.other(), 0);
EXPECT_EQ(icmp.router_pref(), 0);
EXPECT_EQ(icmp.router_lifetime(), 1800);
EXPECT_EQ(icmp.reachable_time(), 30000);
EXPECT_EQ(icmp.retransmit_timer(), 1000);
EXPECT_EQ(icmp.reachable_time(), 30000U);
EXPECT_EQ(icmp.retransmit_timer(), 1000U);
const ICMPv6::option *opt = icmp.search_option(ICMPv6::SOURCE_ADDRESS);
ASSERT_TRUE(opt);
EXPECT_EQ(opt->data_size(), 6);
EXPECT_EQ(opt->data_size(), 6U);
EXPECT_EQ(HWAddress<6>(opt->data_ptr()), "00:60:97:07:69:ea");
opt = icmp.search_option(ICMPv6::MTU);
ASSERT_TRUE(opt);
EXPECT_EQ(opt->data_size(), 6);
EXPECT_EQ(opt->data_size(), 6U);
opt = icmp.search_option(ICMPv6::PREFIX_INFO);
ASSERT_TRUE(opt);
EXPECT_EQ(opt->data_size(), 30);
EXPECT_EQ(opt->data_size(), 30U);
}
TEST_F(ICMPv6Test, Type) {
@@ -216,7 +216,7 @@ TEST_F(ICMPv6Test, RedirectHeader) {
TEST_F(ICMPv6Test, MTU) {
ICMPv6 icmp;
icmp.mtu(0x9a8df7);
EXPECT_EQ(icmp.mtu(), 0x9a8df7);
EXPECT_EQ(icmp.mtu(), 0x9a8df7U);
}
TEST_F(ICMPv6Test, ShortcutLimit) {
@@ -228,7 +228,7 @@ TEST_F(ICMPv6Test, ShortcutLimit) {
TEST_F(ICMPv6Test, NewAdvertisementInterval) {
ICMPv6 icmp;
icmp.new_advert_interval(0x9a8df7);
EXPECT_EQ(icmp.new_advert_interval(), 0x9a8df7);
EXPECT_EQ(icmp.new_advert_interval(), 0x9a8df7U);
}
TEST_F(ICMPv6Test, NewHomeAgentInformation) {
@@ -277,8 +277,8 @@ TEST_F(ICMPv6Test, RSASignature) {
TEST_F(ICMPv6Test, Timestamp) {
ICMPv6 icmp;
icmp.timestamp(0x2837d6aaa231L);
EXPECT_EQ(icmp.timestamp(), 0x2837d6aaa231L);
icmp.timestamp(0x2837d6aaa231ULL);
EXPECT_EQ(icmp.timestamp(), 0x2837d6aaa231ULL);
}
TEST_F(ICMPv6Test, Nonce) {
@@ -431,6 +431,6 @@ TEST_F(ICMPv6Test, SpoofedOptions) {
ICMPv6::option(ICMPv6::NAACK, 250, a, a + sizeof(a))
);
// probably we'd expect it to crash if it's not working, valgrind plx
EXPECT_EQ(3, pdu.options().size());
EXPECT_EQ(3U, pdu.options().size());
EXPECT_EQ(pdu.serialize().size(), pdu.size());
}

View File

@@ -27,8 +27,8 @@ const uint8_t IPTest::expected_packet[] = {
TEST_F(IPTest, DefaultConstructor) {
IP ip;
EXPECT_EQ(ip.dst_addr(), 0);
EXPECT_EQ(ip.src_addr(), 0);
EXPECT_EQ(ip.dst_addr(), "0.0.0.0");
EXPECT_EQ(ip.src_addr(), "0.0.0.0");
EXPECT_EQ(ip.version(), 4);
EXPECT_EQ(ip.id(), 1);
EXPECT_EQ(ip.pdu_type(), PDU::IP);
@@ -144,7 +144,7 @@ TEST_F(IPTest, SecOption) {
EXPECT_EQ(found.security, 0x746a);
EXPECT_EQ(found.compartments, 26539);
EXPECT_EQ(found.handling_restrictions, 0x77ab);
EXPECT_EQ(found.transmission_control, 0x68656c);
EXPECT_EQ(found.transmission_control, 0x68656cU);
}
TEST_F(IPTest, LSRROption) {
@@ -224,7 +224,7 @@ TEST_F(IPTest, ConstructorFromBuffer) {
EXPECT_EQ(sec.security, 0x746a);
EXPECT_EQ(sec.compartments, 26539);
EXPECT_EQ(sec.handling_restrictions, 0x77ab);
EXPECT_EQ(sec.transmission_control, 0x68656c);
EXPECT_EQ(sec.transmission_control, 0x68656cU);
}
TEST_F(IPTest, Serialize) {
@@ -261,6 +261,6 @@ TEST_F(IPTest, SpoofedOptions) {
IP::option(IP::NOOP, 250, a, a + sizeof(a))
);
// probably we'd expect it to crash if it's not working, valgrind plx
EXPECT_EQ(3, pdu.options().size());
EXPECT_EQ(3U, pdu.options().size());
EXPECT_EQ(pdu.serialize().size(), pdu.size());
}

View File

@@ -65,7 +65,7 @@ TEST_F(IPv6Test, Constructor) {
IPv6 ipv6("::1:2:3", "f0aa:beef::1");
EXPECT_EQ(ipv6.version(), 6);
EXPECT_EQ(ipv6.traffic_class(), 0);
EXPECT_EQ(ipv6.flow_label(), 0);
EXPECT_EQ(ipv6.flow_label(), 0U);
EXPECT_EQ(ipv6.payload_length(), 0);
EXPECT_EQ(ipv6.next_header(), 0);
EXPECT_EQ(ipv6.hop_limit(), 0);
@@ -77,7 +77,7 @@ TEST_F(IPv6Test, ConstructorFromBuffer) {
IPv6 ipv6(expected_packet1, sizeof(expected_packet1));
EXPECT_EQ(ipv6.version(), 6);
EXPECT_EQ(ipv6.traffic_class(), 0x9a);
EXPECT_EQ(ipv6.flow_label(), 0x82734);
EXPECT_EQ(ipv6.flow_label(), 0x82734U);
EXPECT_EQ(ipv6.payload_length(), 40);
EXPECT_EQ(ipv6.next_header(), 6);
EXPECT_EQ(ipv6.hop_limit(), 64);
@@ -95,7 +95,7 @@ TEST_F(IPv6Test, ConstructorFromBuffer2) {
IPv6 ipv6(expected_packet2, sizeof(expected_packet2));
EXPECT_EQ(ipv6.version(), 6);
EXPECT_EQ(ipv6.traffic_class(), 0);
EXPECT_EQ(ipv6.flow_label(), 0);
EXPECT_EQ(ipv6.flow_label(), 0U);
EXPECT_EQ(ipv6.payload_length(), 36);
EXPECT_EQ(ipv6.next_header(), IPv6::HOP_BY_HOP);
EXPECT_EQ(ipv6.hop_limit(), 1);
@@ -111,7 +111,7 @@ TEST_F(IPv6Test, ConstructorFromBuffer2) {
const IPv6::ext_header *header = ipv6.search_header(IPv6::HOP_BY_HOP);
ASSERT_TRUE(header);
EXPECT_EQ(header->data_size(), 6);
EXPECT_EQ(header->data_size(), 6U);
}
TEST_F(IPv6Test, Serialize) {
@@ -138,13 +138,13 @@ TEST_F(IPv6Test, TrafficClass) {
TEST_F(IPv6Test, FlowLabel) {
IPv6 ipv6;
ipv6.flow_label(0x918d7);
EXPECT_EQ(ipv6.flow_label(), 0x918d7);
EXPECT_EQ(ipv6.flow_label(), 0x918d7U);
}
TEST_F(IPv6Test, PayloadLength) {
IPv6 ipv6;
ipv6.payload_length(0xaf71);
EXPECT_EQ(ipv6.payload_length(), 0xaf71);
EXPECT_EQ(ipv6.payload_length(), 0xaf71U);
}
TEST_F(IPv6Test, NextHeader) {

View File

@@ -33,7 +33,7 @@ TEST_F(LLCTest, DefaultConstructor) {
EXPECT_EQ(llc.ssap(), 0);
EXPECT_EQ(llc.dsap(), 0);
EXPECT_EQ(llc.type(), LLC::INFORMATION);
EXPECT_EQ(llc.header_size(), 4);
EXPECT_EQ(llc.header_size(), 4U);
EXPECT_EQ(llc.pdu_type(), PDU::LLC);
}
@@ -42,7 +42,7 @@ TEST_F(LLCTest, ParamsConstructor) {
EXPECT_EQ(0xAD, llc.dsap());
EXPECT_EQ(0x16, llc.ssap());
EXPECT_EQ(LLC::INFORMATION, llc.type());
EXPECT_EQ(4, llc.header_size());
EXPECT_EQ(4U, llc.header_size());
EXPECT_EQ(PDU::LLC, llc.pdu_type());
}
@@ -91,11 +91,11 @@ TEST_F(LLCTest, Type) {
TEST_F(LLCTest, HeadSize) {
LLC llc;
llc.type(LLC::INFORMATION);
EXPECT_EQ(llc.header_size(), 4);
EXPECT_EQ(llc.header_size(), 4U);
llc.type(LLC::SUPERVISORY);
EXPECT_EQ(llc.header_size(), 4);
EXPECT_EQ(llc.header_size(), 4U);
llc.type(LLC::UNNUMBERED);
EXPECT_EQ(llc.header_size(), 3);
EXPECT_EQ(llc.header_size(), 3U);
}
TEST_F(LLCTest, SendSeqNumber) {
@@ -176,7 +176,7 @@ TEST_F(LLCTest, ModifierFunction) {
TEST_F(LLCTest, ConstructorFromBuffer) {
LLC llc(LLCTest::from_buffer_info, 4);
EXPECT_EQ(LLC::INFORMATION, llc.type());
EXPECT_EQ(4, llc.header_size());
EXPECT_EQ(4U, llc.header_size());
EXPECT_EQ(0xFE, llc.dsap());
EXPECT_EQ(0x48, llc.ssap());
EXPECT_FALSE(llc.group());
@@ -186,7 +186,7 @@ TEST_F(LLCTest, ConstructorFromBuffer) {
EXPECT_EQ(29, llc.receive_seq_number());
LLC llc_super(LLCTest::from_buffer_super, sizeof(LLCTest::from_buffer_super));
EXPECT_EQ(4, llc_super.header_size());
EXPECT_EQ(4U, llc_super.header_size());
EXPECT_EQ(0x4B, llc_super.dsap());
EXPECT_EQ(0x19, llc_super.ssap());
EXPECT_TRUE(llc_super.group());
@@ -196,7 +196,7 @@ TEST_F(LLCTest, ConstructorFromBuffer) {
EXPECT_EQ(LLC::RECEIVE_NOT_READY, llc_super.supervisory_function());
LLC llc_unnum(LLCTest::from_buffer_unnumbered, sizeof(LLCTest::from_buffer_unnumbered));
EXPECT_EQ(llc_unnum.header_size(), 3);
EXPECT_EQ(llc_unnum.header_size(), 3U);
EXPECT_EQ(llc_unnum.dsap(), 0xaa);
EXPECT_EQ(llc_unnum.ssap(), 0x17);
EXPECT_FALSE(llc_unnum.group());

View File

@@ -32,7 +32,7 @@ TEST_F(PPITest, ConstructorFromBuffer) {
EXPECT_EQ(0, pdu.version());
EXPECT_EQ(0, pdu.flags());
EXPECT_EQ(84, pdu.length());
EXPECT_EQ(105, pdu.dlt());
EXPECT_EQ(105U, pdu.dlt());
EXPECT_TRUE(pdu.find_pdu<Dot11Data>());
EXPECT_TRUE(pdu.find_pdu<UDP>());
}

View File

@@ -33,7 +33,7 @@ TEST_F(PPPoETest, ConstructorFromBuffer) {
EXPECT_EQ(0x09, pdu.code());
EXPECT_EQ(0, pdu.session_id());
EXPECT_EQ(16, pdu.payload_length());
EXPECT_EQ(3, pdu.tags().size());
EXPECT_EQ(3U, pdu.tags().size());
EXPECT_EQ("", pdu.service_name());
ASSERT_TRUE(pdu.search_tag(PPPoE::SERVICE_NAME));
@@ -186,6 +186,6 @@ TEST_F(PPPoETest, SpoofedOptions) {
PPPoE::tag(PPPoE::VENDOR_SPECIFIC, 65000, a, a + sizeof(a))
);
// probably we'd expect it to crash if it's not working, valgrind plx
EXPECT_EQ(3, pdu.tags().size());
EXPECT_EQ(3U, pdu.tags().size());
EXPECT_EQ(pdu.serialize().size(), pdu.size());
}

View File

@@ -66,8 +66,8 @@ TEST_F(RadioTapTest, DefaultConstructor) {
RadioTap radio;
EXPECT_TRUE(radio.flags() & RadioTap::FCS);
EXPECT_EQ(Utils::mhz_to_channel(radio.channel_freq()), 1);
EXPECT_EQ(radio.channel_type(), 0xa0);
EXPECT_EQ(radio.tsft(), 0);
EXPECT_EQ(radio.channel_type(), 0xa0U);
EXPECT_EQ(radio.tsft(), 0U);
EXPECT_EQ(radio.dbm_signal(), 0xce);
EXPECT_EQ(radio.antenna(), 0);
EXPECT_EQ(radio.rx_flags(), 0);
@@ -79,9 +79,17 @@ TEST_F(RadioTapTest, ConstructorFromBuffer) {
EXPECT_EQ(radio.length(), 32);
EXPECT_EQ(radio.rate(), 0xc);
EXPECT_EQ(radio.flags(), 0x10);
EXPECT_TRUE(radio.present() & RadioTap::TSTF);
EXPECT_TRUE(radio.present() & RadioTap::RATE);
EXPECT_TRUE(radio.present() & RadioTap::DBM_SIGNAL);
EXPECT_TRUE(radio.present() & RadioTap::ANTENNA);
EXPECT_TRUE(radio.present() & RadioTap::CHANNEL_PLUS);
EXPECT_TRUE(radio.flags() & RadioTap::FCS);
EXPECT_EQ(radio.channel_type(), 0x140);
EXPECT_EQ(radio.tsft(), 616089172);
EXPECT_EQ(radio.channel_freq(), 5180);
EXPECT_EQ(radio.tsft(), 616089172U);
EXPECT_EQ(radio.dbm_signal(), 0xda);
EXPECT_EQ(radio.dbm_noise(), 0xa0);
EXPECT_EQ(radio.antenna(), 2);
@@ -185,5 +193,5 @@ TEST_F(RadioTapTest, Rate) {
TEST_F(RadioTapTest, TSFT) {
RadioTap radio;
radio.tsft(0x7afb9a8d);
EXPECT_EQ(radio.tsft(), 0x7afb9a8d);
EXPECT_EQ(radio.tsft(), 0x7afb9a8dU);
}

View File

@@ -23,7 +23,7 @@ TEST_F(RC4EAPOLTest, DefaultConstructor) {
EXPECT_EQ(EAPOL::RC4, eapol.type());
EXPECT_EQ(0, eapol.length());
EXPECT_EQ(0, eapol.key_length());
EXPECT_EQ(0, eapol.replay_counter());
EXPECT_EQ(0U, eapol.replay_counter());
EXPECT_TRUE(std::equal(empty_iv, empty_iv + sizeof(empty_iv), eapol.key_iv()));
EXPECT_EQ(0, eapol.key_flag());
EXPECT_EQ(0, eapol.key_index());
@@ -64,7 +64,7 @@ TEST_F(RC4EAPOLTest, KeyLength) {
TEST_F(RC4EAPOLTest, ReplayCounter) {
RC4EAPOL eapol;
eapol.replay_counter(0x7af3d91a1fd3abLL);
EXPECT_EQ(0x7af3d91a1fd3abLL, eapol.replay_counter());
EXPECT_EQ(0x7af3d91a1fd3abULL, eapol.replay_counter());
}
TEST_F(RC4EAPOLTest, KeyIV) {

View File

@@ -79,7 +79,7 @@ TEST_F(RSNEAPOLTest, DefaultConstructor) {
EXPECT_EQ(EAPOL::RSN, eapol.type());
EXPECT_EQ(0, eapol.length());
EXPECT_EQ(0, eapol.key_length());
EXPECT_EQ(0, eapol.replay_counter());
EXPECT_EQ(0U, eapol.replay_counter());
EXPECT_TRUE(std::equal(empty_iv, empty_iv + sizeof(empty_iv), eapol.key_iv()));
EXPECT_TRUE(std::equal(empty_rsc, empty_rsc + sizeof(empty_rsc), eapol.id()));
EXPECT_TRUE(std::equal(empty_rsc, empty_rsc + sizeof(empty_rsc), eapol.rsc()));
@@ -107,7 +107,7 @@ TEST_F(RSNEAPOLTest, ConstructorFromBuffer) {
EXPECT_EQ(1, eapol.encrypted());
EXPECT_EQ(16, eapol.key_length());
EXPECT_EQ(2, eapol.replay_counter());
EXPECT_EQ(2U, eapol.replay_counter());
EXPECT_TRUE(std::equal(nonce, nonce + sizeof(nonce), eapol.nonce()));
EXPECT_TRUE(std::equal(empty_iv, empty_iv + sizeof(empty_iv), eapol.key_iv()));
EXPECT_TRUE(std::equal(rsc, rsc + sizeof(rsc), eapol.rsc()));
@@ -115,7 +115,7 @@ TEST_F(RSNEAPOLTest, ConstructorFromBuffer) {
EXPECT_TRUE(std::equal(mic, mic + sizeof(mic), eapol.mic()));
ASSERT_EQ(56, eapol.wpa_length());
RSNEAPOL::key_type key_found = eapol.key();
ASSERT_EQ(56, key_found.size());
ASSERT_EQ(56U, key_found.size());
EXPECT_TRUE(std::equal(key, key + sizeof(key), key_found.begin()));
}
@@ -159,8 +159,8 @@ TEST_F(RSNEAPOLTest, ConstructionTest) {
TEST_F(RSNEAPOLTest, ReplayCounter) {
RSNEAPOL eapol;
eapol.replay_counter(0x7af3d91a1fd3abLL);
EXPECT_EQ(0x7af3d91a1fd3abLL, eapol.replay_counter());
eapol.replay_counter(0x7af3d91a1fd3abULL);
EXPECT_EQ(0x7af3d91a1fd3abULL, eapol.replay_counter());
}
TEST_F(RSNEAPOLTest, WPALength) {

View File

@@ -25,7 +25,7 @@ TEST_F(SNAPTest, DefaultConstructor) {
EXPECT_EQ(snap.dsap(), 0xaa);
EXPECT_EQ(snap.ssap(), 0xaa);
EXPECT_EQ(snap.eth_type(), 0);
EXPECT_EQ(snap.org_code(), 0);
EXPECT_EQ(snap.org_code(), 0U);
EXPECT_EQ(snap.control(), 3);
}
@@ -51,7 +51,7 @@ TEST_F(SNAPTest, OrgCode) {
SNAP snap;
snap.org_code(0xfab1c3);
EXPECT_EQ(snap.org_code(), 0xfab1c3);
EXPECT_EQ(snap.org_code(), 0xfab1c3U);
EXPECT_EQ(snap.control(), 3);
}
@@ -60,7 +60,7 @@ TEST_F(SNAPTest, Control) {
snap.control(0xfa);
EXPECT_EQ(snap.control(), 0xfa);
EXPECT_EQ(snap.org_code(), 0);
EXPECT_EQ(snap.org_code(), 0U);
}
TEST_F(SNAPTest, EthType) {
@@ -102,7 +102,7 @@ TEST_F(SNAPTest, ConstructorFromBuffer) {
EXPECT_EQ(0xaa, snap1.dsap());
EXPECT_EQ(0xaa, snap1.ssap());
EXPECT_EQ(0x0800, snap1.eth_type());
EXPECT_EQ(1, snap1.org_code());
EXPECT_EQ(1U, snap1.org_code());
SNAP snap2(&buffer[0], buffer.size());
test_equals(snap1, snap2);

View File

@@ -33,7 +33,7 @@ TEST_F(STPTest, DefaultConstructor) {
EXPECT_EQ(0, pdu.proto_version());
EXPECT_EQ(0, pdu.bpdu_type());
EXPECT_EQ(0, pdu.bpdu_flags());
EXPECT_EQ(0, pdu.root_path_cost());
EXPECT_EQ(0U, pdu.root_path_cost());
EXPECT_EQ(0, pdu.port_id());
EXPECT_EQ(0, pdu.msg_age());
EXPECT_EQ(0, pdu.max_age());
@@ -50,7 +50,7 @@ TEST_F(STPTest, ConstructorFromBuffer) {
EXPECT_EQ(0x92, pdu.bpdu_flags());
test_equals(bpdu, pdu.root_id());
// root identifier(32768. 0, 00:90:4c:08:17:b5
EXPECT_EQ(0x928378, pdu.root_path_cost());
EXPECT_EQ(0x928378U, pdu.root_path_cost());
test_equals(bpdu, pdu.bridge_id());
// bridge identifier(32768. 0, 00:90:4c:08:17:b5
EXPECT_EQ(0x8001, pdu.port_id());
@@ -129,7 +129,7 @@ TEST_F(STPTest, BPDUFlags) {
TEST_F(STPTest, RootPathCost) {
STP pdu;
pdu.root_path_cost(0x28378462);
EXPECT_EQ(0x28378462, pdu.root_path_cost());
EXPECT_EQ(0x28378462U, pdu.root_path_cost());
}
TEST_F(STPTest, PortID) {

View File

@@ -92,13 +92,13 @@ TEST_F(TCPTest, SPort) {
TEST_F(TCPTest, Seq) {
TCP tcp;
tcp.seq(0x5fad65fb);
EXPECT_EQ(tcp.seq(), 0x5fad65fb);
EXPECT_EQ(tcp.seq(), 0x5fad65fbU);
}
TEST_F(TCPTest, AckSeq) {
TCP tcp;
tcp.ack_seq(0x5fad65fb);
EXPECT_EQ(tcp.ack_seq(), 0x5fad65fb);
EXPECT_EQ(tcp.ack_seq(), 0x5fad65fbU);
}
TEST_F(TCPTest, Window) {
@@ -204,7 +204,7 @@ TEST_F(TCPTest, ConstructorFromBuffer) {
EXPECT_EQ(tcp1.dport(), 0x4f1d);
EXPECT_EQ(tcp1.sport(), 0x7f4d);
EXPECT_EQ(tcp1.seq(), 0xf1dae546);
EXPECT_EQ(tcp1.ack_seq(), 0x5faed123);
EXPECT_EQ(tcp1.ack_seq(), 0x5faed123U);
EXPECT_EQ(tcp1.window(), 0x71da);
EXPECT_EQ(tcp1.urg_ptr(), 0x1fae);
EXPECT_EQ(tcp1.data_offset(), 0xd);
@@ -219,9 +219,9 @@ TEST_F(TCPTest, ConstructorFromBuffer) {
TCP::sack_type edges = tcp1.sack();
TCP::sack_type::const_iterator iter = edges.begin();
ASSERT_EQ(edges.size(), 2);
EXPECT_EQ(*iter++, 0x00010203);
EXPECT_EQ(*iter++, 0x04050607);
ASSERT_EQ(edges.size(), 2U);
EXPECT_EQ(*iter++, 0x00010203U);
EXPECT_EQ(*iter++, 0x04050607U);
PDU::serialization_type buffer = tcp1.serialize();
@@ -249,6 +249,6 @@ TEST_F(TCPTest, SpoofedOptions) {
TCP::option(TCP::SACK, 250, a, a + sizeof(a))
);
// probably we'd expect it to crash if it's not working, valgrind plx
EXPECT_EQ(3, pdu.options().size());
EXPECT_EQ(3U, pdu.options().size());
EXPECT_EQ(pdu.serialize().size(), pdu.size());
}

View File

@@ -70,7 +70,7 @@ TEST_F(UtilsTest, Crc32) {
uint32_t crc = Utils::crc32(data, data_len);
EXPECT_EQ(crc, 0x78840f54);
EXPECT_EQ(crc, 0x78840f54U);
}