mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 18:35:09 +00:00
Kernel: Record MAC addresses for incoming IPv4 packets
This way we don't have to do ARP just to send packets back to an address which just sent us a packet.
This commit is contained in:
parent
fb2ad94195
commit
c03cbf83ab
1 changed files with 9 additions and 0 deletions
|
@ -183,6 +183,15 @@ void handle_ipv4(const EthernetFrameHeader& eth, size_t frame_size, const Time&
|
||||||
|
|
||||||
dbgln_if(IPV4_DEBUG, "handle_ipv4: source={}, destination={}", packet.source(), packet.destination());
|
dbgln_if(IPV4_DEBUG, "handle_ipv4: source={}, destination={}", packet.source(), packet.destination());
|
||||||
|
|
||||||
|
NetworkAdapter::for_each([&](auto& adapter) {
|
||||||
|
if (adapter.link_up()) {
|
||||||
|
auto my_net = adapter.ipv4_address().to_u32() & adapter.ipv4_netmask().to_u32();
|
||||||
|
auto their_net = packet.source().to_u32() & adapter.ipv4_netmask().to_u32();
|
||||||
|
if (my_net == their_net)
|
||||||
|
update_arp_table(packet.source(), eth.source());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
switch ((IPv4Protocol)packet.protocol()) {
|
switch ((IPv4Protocol)packet.protocol()) {
|
||||||
case IPv4Protocol::ICMP:
|
case IPv4Protocol::ICMP:
|
||||||
return handle_icmp(eth, packet, packet_timestamp);
|
return handle_icmp(eth, packet, packet_timestamp);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue