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