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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user