mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Use endian independent way of setting IP fragment offset and flags
This commit is contained in:
@@ -329,7 +329,7 @@ namespace Tins {
|
||||
* \return The IP flags field
|
||||
*/
|
||||
Flags flags() const {
|
||||
return static_cast<Flags>((_ip.frag_off & 0xe0) >> 5);
|
||||
return static_cast<Flags>(Endian::be_to_host(_ip.frag_off) >> 13);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -179,11 +179,13 @@ void IP::frag_off(uint16_t new_frag_off) {
|
||||
}
|
||||
|
||||
void IP::fragment_offset(small_uint<13> new_frag_off) {
|
||||
_ip.frag_off = (_ip.frag_off & 0xe0) | Endian::host_to_be<uint16_t>(new_frag_off);
|
||||
uint16_t value = (Endian::be_to_host(_ip.frag_off) & 0xe000) | new_frag_off;
|
||||
_ip.frag_off = Endian::host_to_be(value);
|
||||
}
|
||||
|
||||
void IP::flags(Flags new_flags) {
|
||||
_ip.frag_off = (_ip.frag_off & 0xff1f) | (new_flags << 5);
|
||||
uint16_t value = (Endian::be_to_host(_ip.frag_off) & 0x1fff) | (new_flags << 13);
|
||||
_ip.frag_off = Endian::host_to_be(value);
|
||||
}
|
||||
|
||||
void IP::ttl(uint8_t new_ttl) {
|
||||
|
||||
@@ -112,7 +112,8 @@ IPv4Reassembler::packet_status IPv4Reassembler::process(PDU &pdu) {
|
||||
return FRAGMENTED;
|
||||
}
|
||||
ip->inner_pdu(pdu);
|
||||
ip->frag_off(0);
|
||||
ip->fragment_offset(0);
|
||||
ip->flags(static_cast<IP::Flags>(0));
|
||||
return REASSEMBLED;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user