Commit graph

5 commits

Author SHA1 Message Date
sdomi
a781106a89 Kernel/Net: Introduce proper pointers for payload calls
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.
2024-10-04 12:04:17 +02:00
sdomi
a706e81d41 Kernel/Net: Remove useless checks from handle_arp
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.
2024-10-04 12:04:17 +02:00
kleines Filmröllchen
11d46a4a00 Kernel/Net: Start work on IPv6
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>
2024-10-04 12:04:17 +02:00
sdomi
2a0af461b2 Kernel/Net: Move internet_checksum to a more general file
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>
2024-10-04 12:04:17 +02:00
sdomi
17e0ba4914 Kernel/Net: Rename IPv4 directory to IP
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.
2024-10-04 12:04:17 +02:00