Unifying with other structures, this introduces m_payload for all
relevant structures, except the TCP header (which has a different
concept of payload than the rest).
This allows us to return a pointer directly instead of doing pointer
arithmetic to point to the end of the structure.
According to ARP.h, address lengths default to size of their
underlying types (IPv4Address and MACAddress respectively). We never
modify those values, and in reality, ARP never carries anything else.
Hence, those checks resolved to comparing sizeof to itself, which
probably gets optimized out of the compiler anyways.
This change removes the checks that will never fail, plus changes the
function definition to pass adapter directly, matching other handlers.
This commit introduces the first bit of IPv6 support into
SerenityOS. An IPv6 packet header structure allows NetworkTask to
recognize and log correctly shaped IPv6 packets, but nothing is done
with those yet. A new logging flag, IPV6_DEBUG, allows debugging of
IPv6 internals.
Co-Authored-By: sdomi <ja@sdomi.pl>
Up until now, the internet_checksum function lived in IPv4.h. Due to
its use in IPv6, a better place for it nowadays would be in IP.h.
Due to how it gets used in IPv6 scenarios, it makes sense to extend it
to run over multiple smaller structs instead of one big continous chunk
of memory. This change converts internet_checksum into a class with
methods "add" and "finish", which process data and return the final
result, respectively.
This commit also fixes proper hash computation for payloads that have
an odd length. Furthermore, the function was refactored to use
a ReadonlyBytes object instead of separate data and size.
Co-Authored-By: Wanda <wanda@phinode.net>
Commit ad73adef5d needlessly introduced an IPv4 directory.
If we were to keep it, sharing common headers between IPv4 and IPv6
would be much messier, and may potentially increase code duplication.
This change renames the IPv4 directory to IP to aid with later IPv6
porting efforts.