mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-18 10:46:25 +00:00
net: fix header_length field in Ipv4_packet
Replace size_t by uint8_t in accessors for the IPv4 header fields 'version' and 'header_length' - uint8_t is the smallest integral type for 4 bit of information. Note, as the _internet header length_ field is defined to reflect the number of 32-bit words the header occupies, we also stick to the specification with our accessor. Issue #1915
This commit is contained in:
parent
abed38e8ac
commit
bed870ead4
@ -66,8 +66,8 @@ class Net::Ipv4_packet
|
||||
** IPv4 header fields **
|
||||
************************/
|
||||
|
||||
unsigned _version : 4;
|
||||
unsigned _header_length : 4;
|
||||
unsigned _version : 4;
|
||||
Genode::uint8_t _diff_service;
|
||||
Genode::uint16_t _total_length;
|
||||
Genode::uint16_t _identification;
|
||||
@ -131,9 +131,11 @@ class Net::Ipv4_packet
|
||||
** IPv4 field read-accessors **
|
||||
*******************************/
|
||||
|
||||
Genode::size_t version() { return _version; }
|
||||
Genode::size_t header_length() { return _header_length / 4; }
|
||||
Genode::uint8_t precedence() { return _diff_service & PRECEDENCE; }
|
||||
Genode::uint8_t version() { return _version; }
|
||||
|
||||
/* returns the number of 32-bit words the header occupies */
|
||||
Genode::uint8_t header_length() { return _header_length; }
|
||||
Genode::uint8_t precedence() { return _diff_service & PRECEDENCE; }
|
||||
|
||||
bool low_delay() { return _diff_service & DELAY; }
|
||||
bool high_throughput() { return _diff_service & THROUGHPUT; }
|
||||
@ -150,7 +152,7 @@ class Net::Ipv4_packet
|
||||
Genode::uint8_t time_to_live() { return _time_to_live; }
|
||||
Genode::uint8_t protocol() { return _protocol; }
|
||||
|
||||
Genode::uint16_t checksum() { return host_to_big_endian(_header_checksum); }
|
||||
Genode::uint16_t checksum() { return host_to_big_endian(_header_checksum); }
|
||||
|
||||
Ipv4_address dst() { return Ipv4_address(&_dst_addr); }
|
||||
Ipv4_address src() { return Ipv4_address(&_src_addr); }
|
||||
|
Loading…
Reference in New Issue
Block a user