1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Fix more build issues on appveyor

This commit is contained in:
Matias Fontanini
2017-05-08 21:51:27 -07:00
parent bd0db1354e
commit b0d66a01d2
5 changed files with 12 additions and 6 deletions

View File

@@ -106,7 +106,7 @@ uint32_t EthernetII::trailer_size() const {
int32_t padding = 60 - sizeof(header_); // EthernetII min size is 60, padding is sometimes needed
if (inner_pdu()) {
padding -= inner_pdu()->size();
padding = std::max(0, padding);
padding = padding > 0 ? padding : 0;
}
return padding;
}

View File

@@ -40,7 +40,6 @@
#include "utils/checksum_utils.h"
using std::memset;
using std::max;
using Tins::Memory::InputMemoryStream;
using Tins::Memory::OutputMemoryStream;
@@ -148,7 +147,8 @@ uint32_t ICMP::trailer_size() const {
// If the next pdu size is lower than 128 bytes, then padding = 128 - pdu size
// If the next pdu size is greater than 128 bytes,
// then padding = pdu size padded to next 32 bit boundary - pdu size
const uint32_t upper_bound = max(get_adjusted_inner_pdu_size(), 128U);
const uint32_t adjusted_size = get_adjusted_inner_pdu_size();
const uint32_t upper_bound = adjusted_size > 128U ? adjusted_size : 128U;
output += upper_bound - inner_pdu()->size();
}
}
@@ -228,8 +228,9 @@ void ICMP::write_serialization(uint8_t* buffer, uint32_t total_sz) {
if (length_value) {
// If we have extensions, we'll have at least 128 bytes.
// Otherwise, just use the length
length_value = has_extensions() ? max(length_value, 128U)
: length_value;
if (has_extensions()) {
length_value = length_value > 128U ? length_value : 128U;
}
}
else {
length_value = 0;

View File

@@ -156,7 +156,9 @@ IPv4Address IPv4Address::operator&(const IPv4Address& mask) const {
} // Tins
#ifdef TINS_IS_CXX11
// Hash
size_t std::hash<Tins::IPv4Address>::operator()(const Tins::IPv4Address& addr) const {
return std::hash<uint32_t>()(addr);
}
#endif // TINS_IS_CXX11

View File

@@ -153,7 +153,9 @@ IPv6Address operator&(const IPv6Address& lhs, const IPv6Address& rhs) {
} // Tins
#ifdef TINS_IS_CXX11
// Hash
size_t std::hash<Tins::IPv6Address>::operator()(const Tins::IPv6Address& addr) const {
return std::hash<string>()(addr.to_string());
}
#endif // TINS_IS_CXX11

View File

@@ -57,6 +57,7 @@
#include <fstream>
#include <stdexcept>
#include "network_interface.h"
#include "exceptions.h"
using std::vector;
using std::string;
@@ -319,7 +320,7 @@ vector<Route6Entry> route6_entries() {
entry.metric = row->Metric;
output.push_back(entry);
}
catch (invalid_interface&) {
catch (const invalid_interface&) {
}
}