2020-01-18 05:38:21 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2019-04-02 10:46:44 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
2021-08-21 18:31:15 -03:00
|
|
|
#include <Kernel/Locking/MutexProtected.h>
|
2019-04-02 14:54:38 -03:00
|
|
|
#include <Kernel/Net/NetworkAdapter.h>
|
2020-11-29 20:05:27 -03:00
|
|
|
#include <Kernel/Thread.h>
|
2019-04-02 10:46:44 -03:00
|
|
|
|
2020-02-15 21:27:42 -03:00
|
|
|
namespace Kernel {
|
|
|
|
|
|
2020-03-21 21:12:45 -03:00
|
|
|
struct RoutingDecision {
|
2020-02-07 20:19:46 -03:00
|
|
|
RefPtr<NetworkAdapter> adapter;
|
2019-08-28 22:18:32 -03:00
|
|
|
MACAddress next_hop;
|
2019-08-28 22:18:38 -03:00
|
|
|
|
|
|
|
|
bool is_zero() const;
|
2019-08-28 08:58:01 -03:00
|
|
|
};
|
|
|
|
|
|
2021-07-24 20:37:54 -03:00
|
|
|
enum class UpdateArp {
|
|
|
|
|
Set,
|
|
|
|
|
Delete,
|
|
|
|
|
};
|
|
|
|
|
|
2021-09-03 11:33:07 -03:00
|
|
|
void update_arp_table(IPv4Address const&, MACAddress const&, UpdateArp update);
|
|
|
|
|
RoutingDecision route_to(IPv4Address const& target, IPv4Address const& source, RefPtr<NetworkAdapter> const through = nullptr);
|
2019-08-28 08:58:01 -03:00
|
|
|
|
2021-08-21 18:31:15 -03:00
|
|
|
MutexProtected<HashMap<IPv4Address, MACAddress>>& arp_table();
|
2020-02-15 21:27:42 -03:00
|
|
|
|
|
|
|
|
}
|