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

Fix invalid endian on IP fragment offset on OSX

This commit is contained in:
Matias Fontanini
2016-02-04 20:20:14 -08:00
parent 4b0976571e
commit 72e038b9bf

View File

@@ -429,10 +429,13 @@ void IP::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* pare
protocol(new_flag);
}
}
uint16_t original_frag_off = ip_.frag_off;
#if __FreeBSD__ || defined(__FreeBSD_kernel__) || __APPLE__
if (!parent) {
total_sz = Endian::host_to_be<uint16_t>(total_sz);
ip_.frag_off = Endian::be_to_host(ip_.frag_off);
}
#endif
tot_len(total_sz);
@@ -440,6 +443,9 @@ void IP::write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* pare
stream.write(ip_);
// Restore the fragment offset field in case we flipped it
ip_.frag_off = original_frag_off;
for (options_type::const_iterator it = ip_options_.begin(); it != ip_options_.end(); ++it) {
write_option(*it, stream);
}