diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-09-19 21:40:06 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-09-19 21:42:59 +0200 |
commit | 8cfb85936815a9de0fbfeeed1484f7f58ce8ea6d (patch) | |
tree | d1123e9b66a70eb1e593f8124198544f45ca01cd /Kernel/Net/NetworkAdapter.cpp | |
parent | 482d5295f1a490b76e3e888cdca9b393a26dda73 (diff) | |
download | serenity-8cfb85936815a9de0fbfeeed1484f7f58ce8ea6d.zip |
IPv4: Support overriding the default TTL (64)
Made getsockopt() and setsockopt() virtual so we can handle them in the
various Socket subclasses. The subclasses map kinda nicely to "levels".
This will allow us to implement things like "traceroute", although..
I spent some time trying to do that, but then hit a wall when it turned
out that the user-mode networking in QEMU doesn't preserve TTL in the
ICMP packets passing through.
Diffstat (limited to 'Kernel/Net/NetworkAdapter.cpp')
-rw-r--r-- | Kernel/Net/NetworkAdapter.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Kernel/Net/NetworkAdapter.cpp b/Kernel/Net/NetworkAdapter.cpp index 39cac3363c..9cba392b71 100644 --- a/Kernel/Net/NetworkAdapter.cpp +++ b/Kernel/Net/NetworkAdapter.cpp @@ -58,7 +58,7 @@ void NetworkAdapter::send(const MACAddress& destination, const ARPPacket& packet send_raw((const u8*)eth, size_in_bytes); } -void NetworkAdapter::send_ipv4(const MACAddress& destination_mac, const IPv4Address& destination_ipv4, IPv4Protocol protocol, const u8* payload, size_t payload_size) +void NetworkAdapter::send_ipv4(const MACAddress& destination_mac, const IPv4Address& destination_ipv4, IPv4Protocol protocol, const u8* payload, size_t payload_size, u8 ttl) { size_t size_in_bytes = sizeof(EthernetFrameHeader) + sizeof(IPv4Packet) + payload_size; auto buffer = ByteBuffer::create_zeroed(size_in_bytes); @@ -74,7 +74,7 @@ void NetworkAdapter::send_ipv4(const MACAddress& destination_mac, const IPv4Addr ipv4.set_protocol((u8)protocol); ipv4.set_length(sizeof(IPv4Packet) + payload_size); ipv4.set_ident(1); - ipv4.set_ttl(64); + ipv4.set_ttl(ttl); ipv4.set_checksum(ipv4.compute_checksum()); m_packets_out++; m_bytes_out += size_in_bytes; |