1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +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

@@ -69,7 +69,7 @@ public:
* \return The stored version field value.
*/
uint8_t version() const {
return Endian::le_to_host(_header.version);
return _header.version;
}
/**
@@ -77,7 +77,7 @@ public:
* \return The stored flags field value.
*/
uint8_t flags() const {
return Endian::le_to_host(_header.flags);
return _header.flags;
}
/**
@@ -85,7 +85,7 @@ public:
* \return The stored length field value.
*/
uint16_t length() const {
return Endian::le_to_host(_header.length);
return _header.length;
}
/**
@@ -93,7 +93,7 @@ public:
* \return The stored Data Link Type field value.
*/
uint32_t dlt() const {
return Endian::le_to_host(_header.dlt);
return _header.dlt;
}
/**

View File

@@ -89,7 +89,8 @@ namespace Tins {
ANTENNA = 2048,
DB_SIGNAL = 4096,
DB_NOISE = 8192,
RX_FLAGS = 16382
RX_FLAGS = 16382,
CHANNEL_PLUS = 262144
};
/**
@@ -295,7 +296,7 @@ namespace Tins {
* \brief Getter for the channel+ field.
* \return The channel+ field.
*/
uint32_t channel_plus() const { return Endian::le_to_host(_channel_type); }
uint32_t channel_plus() const { return Endian::le_to_host<uint32_t>(_channel_type); }
/**
* \brief Getter for the rx flags field.
@@ -313,7 +314,8 @@ namespace Tins {
* if its corresponding bit flag is set in the present field.
*/
PresentFlags present() const {
return (PresentFlags)*(uint32_t*)(&_radio.it_len + 1);
//return (PresentFlags)*(uint32_t*)(&_radio.it_len + 1);
return (PresentFlags)Endian::le_to_host(_radio.flags_32);
}
/** \brief Check wether ptr points to a valid response for this PDU.
@@ -357,50 +359,60 @@ namespace Tins {
uint8_t it_version;
uint8_t it_pad;
uint16_t it_len;
uint32_t tsft:1,
flags:1,
rate:1,
channel:1,
fhss:1,
dbm_signal:1,
dbm_noise:1,
lock_quality:1,
tx_attenuation:1,
db_tx_attenuation:1,
dbm_tx_attenuation:1,
antenna:1,
db_signal:1,
db_noise:1,
rx_flags:1,
reserved1:3,
channel_plus:1,
reserved2:12,
ext:1;
union {
struct {
uint32_t tsft:1,
flags:1,
rate:1,
channel:1,
fhss:1,
dbm_signal:1,
dbm_noise:1,
lock_quality:1,
tx_attenuation:1,
db_tx_attenuation:1,
dbm_tx_attenuation:1,
antenna:1,
db_signal:1,
db_noise:1,
rx_flags:1,
reserved1:3,
channel_plus:1,
reserved2:12,
ext:1;
} flags;
uint32_t flags_32;
};
#else
uint8_t it_pad;
uint8_t it_version;
uint16_t it_len;
uint32_t lock_quality:1,
dbm_noise:1,
dbm_signal:1,
fhss:1,
channel:1,
rate:1,
flags:1,
tsft:1,
reserved3:1,
rx_flags:1,
db_tx_attenuation:1,
dbm_tx_attenuation:1,
antenna:1,
db_signal:1,
db_noise:1,
tx_attenuation:1,
reserved2:5,
channel_plus:1,
reserved1:2,
reserved4:7,
ext:1;
union {
struct {
uint32_t lock_quality:1,
dbm_noise:1,
dbm_signal:1,
fhss:1,
channel:1,
rate:1,
flags:1,
tsft:1,
reserved3:1,
rx_flags:1,
db_tx_attenuation:1,
dbm_tx_attenuation:1,
antenna:1,
db_signal:1,
db_noise:1,
tx_attenuation:1,
reserved2:5,
channel_plus:1,
reserved1:2,
reserved4:7,
ext:1;
} flags;
uint32_t flags_32;
};
#endif
} TINS_END_PACK;
@@ -411,8 +423,7 @@ namespace Tins {
radiotap_hdr _radio;
// present fields...
uint64_t _tsft;
uint32_t _channel_type;
uint16_t _channel_freq, _rx_flags, _signal_quality;
uint16_t _channel_type, _channel_freq, _rx_flags, _signal_quality;
uint8_t _antenna, _flags, _rate, _dbm_signal, _dbm_noise, _channel, _max_power, _db_signal;
};
}

View File

@@ -32,6 +32,7 @@
#include <cassert>
#endif
#include <stdexcept>
#include <iostream> // borrame
#include "eapol.h"
#include "rsn_information.h"
#include "exceptions.h"
@@ -56,7 +57,12 @@ EAPOL *EAPOL::from_bytes(const uint8_t *buffer, uint32_t total_sz) {
if(total_sz < sizeof(eapolhdr))
throw malformed_packet();
const eapolhdr *ptr = (const eapolhdr*)buffer;
total_sz = std::min(total_sz, (uint32_t)ptr->length);
uint32_t data_len = Endian::be_to_host<uint16_t>(ptr->length);
// at least 4 for fields always present
total_sz = std::min(
total_sz,
data_len + 4
);
switch(ptr->type) {
case RC4:
return new Tins::RC4EAPOL(buffer, total_sz);

View File

@@ -77,56 +77,57 @@ RadioTap::RadioTap(const uint8_t *buffer, uint32_t total_sz)
buffer += sizeof(_radio);
radiotap_hdr_size -= sizeof(_radio);
if(_radio.tsft)
if(_radio.flags.tsft)
read_field(buffer, radiotap_hdr_size, _tsft);
if(_radio.flags)
if(_radio.flags.flags)
read_field(buffer, radiotap_hdr_size, _flags);
if(_radio.rate)
if(_radio.flags.rate)
read_field(buffer, radiotap_hdr_size, _rate);
if(_radio.channel) {
if(_radio.flags.channel) {
if(((buffer - buffer_start) & 1) == 1) {
buffer++;
radiotap_hdr_size--;
}
read_field(buffer, radiotap_hdr_size, _channel_freq);
uint16_t dummy;
read_field(buffer, radiotap_hdr_size, dummy);
_channel_type = dummy;
read_field(buffer, radiotap_hdr_size, _channel_type);
}
if(_radio.dbm_signal)
if(_radio.flags.dbm_signal)
read_field(buffer, radiotap_hdr_size, _dbm_signal);
if(_radio.dbm_noise)
if(_radio.flags.dbm_noise)
read_field(buffer, radiotap_hdr_size, _dbm_noise);
if(_radio.lock_quality)
if(_radio.flags.lock_quality)
read_field(buffer, radiotap_hdr_size, _signal_quality);
if(_radio.antenna)
if(_radio.flags.antenna)
read_field(buffer, radiotap_hdr_size, _antenna);
if(_radio.db_signal)
if(_radio.flags.db_signal)
read_field(buffer, radiotap_hdr_size, _db_signal);
if(_radio.rx_flags) {
if(_radio.flags.rx_flags) {
if(((buffer - buffer_start) & 1) == 1) {
buffer++;
radiotap_hdr_size--;
}
read_field(buffer, radiotap_hdr_size, _rx_flags);
}
if(_radio.channel_plus) {
if(_radio.flags.channel_plus) {
uint32_t offset = ((buffer - buffer_start) % 4);
if(offset) {
offset = 4 - offset;
buffer += offset;
radiotap_hdr_size -= offset;
}
read_field(buffer, radiotap_hdr_size, _channel_type);
uint32_t dummy;
read_field(buffer, radiotap_hdr_size, dummy);
// nasty Big Endian fix
_channel_type = Endian::le_to_host<uint16_t>(Endian::host_to_le<uint32_t>(dummy));
read_field(buffer, radiotap_hdr_size, _channel_freq);
read_field(buffer, radiotap_hdr_size, _channel);
read_field(buffer, radiotap_hdr_size, _max_power);
@@ -135,7 +136,7 @@ RadioTap::RadioTap(const uint8_t *buffer, uint32_t total_sz)
total_sz -= length();
buffer += radiotap_hdr_size;
if(_radio.flags && (flags() & FCS) != 0) {
if(_radio.flags.flags && (flags() & FCS) != 0) {
check_size(total_sz, sizeof(uint32_t));
total_sz -= sizeof(uint32_t);
if((flags() & FAILED_FCS) !=0)
@@ -169,83 +170,83 @@ void RadioTap::length(uint16_t new_length) {
void RadioTap::tsft(uint64_t new_tsft) {
_tsft = Endian::host_to_le(new_tsft);
_radio.tsft = 1;
_radio.flags.tsft = 1;
}
void RadioTap::flags(FrameFlags new_flags) {
_flags = (uint8_t)new_flags;
_radio.flags = 1;
_radio.flags.flags = 1;
}
void RadioTap::rate(uint8_t new_rate) {
_rate = new_rate;
_radio.rate = 1;
_radio.flags.rate = 1;
}
void RadioTap::channel(uint16_t new_freq, uint16_t new_type) {
_channel_freq = Endian::host_to_le(new_freq);
_channel_type = Endian::host_to_le<uint32_t>(new_type);
_radio.channel = 1;
_channel_type = Endian::host_to_le(new_type);
_radio.flags.channel = 1;
}
void RadioTap::dbm_signal(uint8_t new_dbm_signal) {
_dbm_signal = new_dbm_signal;
_radio.dbm_signal = 1;
_radio.flags.dbm_signal = 1;
}
void RadioTap::dbm_noise(uint8_t new_dbm_noise) {
_dbm_noise = new_dbm_noise;
_radio.dbm_noise = 1;
_radio.flags.dbm_noise = 1;
}
void RadioTap::signal_quality(uint8_t new_signal_quality) {
_signal_quality = new_signal_quality;
_radio.lock_quality = 1;
_radio.flags.lock_quality = 1;
}
void RadioTap::antenna(uint8_t new_antenna) {
_antenna = new_antenna;
_radio.antenna = 1;
_radio.flags.antenna = 1;
}
void RadioTap::db_signal(uint8_t new_db_signal) {
_db_signal = new_db_signal;
_radio.db_signal = 1;
_radio.flags.db_signal = 1;
}
void RadioTap::rx_flags(uint16_t new_rx_flag) {
_rx_flags = Endian::host_to_le(new_rx_flag);
_radio.rx_flags = 1;
_radio.flags.rx_flags = 1;
}
uint32_t RadioTap::header_size() const {
uint32_t total_bytes = 0;
if(_radio.tsft)
if(_radio.flags.tsft)
total_bytes += sizeof(_tsft);
if(_radio.flags)
if(_radio.flags.flags)
total_bytes += sizeof(_flags);
if(_radio.rate)
if(_radio.flags.rate)
total_bytes += sizeof(_rate);
if(_radio.channel) {
if(_radio.flags.channel) {
total_bytes += (total_bytes & 1);
total_bytes += sizeof(uint16_t) * 2;
}
if(_radio.dbm_signal)
if(_radio.flags.dbm_signal)
total_bytes += sizeof(_dbm_signal);
if(_radio.dbm_noise)
if(_radio.flags.dbm_noise)
total_bytes += sizeof(_dbm_noise);
if(_radio.lock_quality) {
if(_radio.flags.lock_quality) {
total_bytes += (total_bytes & 1);
total_bytes += sizeof(_signal_quality);
}
if(_radio.antenna)
if(_radio.flags.antenna)
total_bytes += sizeof(_antenna);
if(_radio.db_signal)
if(_radio.flags.db_signal)
total_bytes += sizeof(_db_signal);
if(_radio.rx_flags) {
if(_radio.flags.rx_flags) {
total_bytes += (total_bytes & 1);
total_bytes += sizeof(_rx_flags);
}
if(_radio.channel_plus) {
if(_radio.flags.channel_plus) {
uint32_t offset = total_bytes % 4;
if(offset)
total_bytes += 4 - offset;
@@ -309,56 +310,55 @@ void RadioTap::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU
_radio.it_len = Endian::host_to_le<uint16_t>(sz);
memcpy(buffer, &_radio, sizeof(_radio));
buffer += sizeof(_radio);
if(_radio.tsft) {
if(_radio.flags.tsft) {
memcpy(buffer, &_tsft, sizeof(_tsft));
buffer += sizeof(_tsft);
}
if(_radio.flags) {
if(_radio.flags.flags) {
memcpy(buffer, &_flags, sizeof(_flags));
buffer += sizeof(_flags);
}
if(_radio.rate) {
if(_radio.flags.rate) {
memcpy(buffer, &_rate, sizeof(_rate));
buffer += sizeof(_rate);
}
if(_radio.channel) {
if(_radio.flags.channel) {
if(((buffer - buffer_start) & 1) == 1)
*(buffer++) = 0;
uint16_t dummy = _channel_type;
memcpy(buffer, &_channel_freq, sizeof(_channel_freq));
buffer += sizeof(_channel_freq);
memcpy(buffer, &dummy, sizeof(dummy));
buffer += sizeof(dummy);
memcpy(buffer, &_channel_type, sizeof(_channel_type));
buffer += sizeof(_channel_type);
}
if(_radio.dbm_signal) {
if(_radio.flags.dbm_signal) {
memcpy(buffer, &_dbm_signal, sizeof(_dbm_signal));
buffer += sizeof(_dbm_signal);
}
if(_radio.dbm_noise) {
if(_radio.flags.dbm_noise) {
memcpy(buffer, &_dbm_noise, sizeof(_dbm_noise));
buffer += sizeof(_dbm_noise);
}
if(_radio.lock_quality) {
if(_radio.flags.lock_quality) {
if(((buffer - buffer_start) & 1) == 1)
*(buffer++) = 0;
memcpy(buffer, &_signal_quality, sizeof(_signal_quality));
buffer += sizeof(_signal_quality);
}
if(_radio.antenna) {
if(_radio.flags.antenna) {
memcpy(buffer, &_antenna, sizeof(_antenna));
buffer += sizeof(_antenna);
}
if(_radio.db_signal) {
if(_radio.flags.db_signal) {
memcpy(buffer, &_db_signal, sizeof(_db_signal));
buffer += sizeof(_db_signal);
}
if(_radio.rx_flags) {
if(_radio.flags.rx_flags) {
if(((buffer - buffer_start) & 1) == 1)
*(buffer++) = 0;
memcpy(buffer, &_rx_flags, sizeof(_rx_flags));
buffer += sizeof(_rx_flags);
}
if(_radio.channel_plus) {
if(_radio.flags.channel_plus) {
uint32_t offset = ((buffer - buffer_start) % 4);
if(offset) {
offset = 4 - offset;
@@ -366,8 +366,11 @@ void RadioTap::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU
*buffer++ = 0;
}
}
memcpy(buffer, &_channel_type, sizeof(_channel_type));
buffer += sizeof(_channel_type);
uint32_t dummy = _channel_type;
// nasty Big Endian fix
dummy = Endian::le_to_host<uint32_t>(Endian::host_to_le<uint16_t>(dummy));
memcpy(buffer, &dummy, sizeof(dummy));
buffer += sizeof(dummy);
memcpy(buffer, &_channel_freq, sizeof(_channel_freq));
buffer += sizeof(_channel_freq);
memcpy(buffer, &_channel, sizeof(_channel));

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);
}