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-08-21 21:31:15 +00:00
|
|
|
#include <Kernel/Locking/MutexProtected.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
|
|
|
};
|
|
|
|
|
2022-03-12 18:56:23 +00:00
|
|
|
enum class UpdateTable {
|
2021-07-24 23:37:54 +00:00
|
|
|
Set,
|
|
|
|
Delete,
|
|
|
|
};
|
|
|
|
|
2022-03-12 18:56:23 +00:00
|
|
|
void update_arp_table(IPv4Address const&, MACAddress const&, UpdateTable update);
|
2021-12-01 22:27:24 +00:00
|
|
|
|
|
|
|
enum class AllowUsingGateway {
|
|
|
|
Yes,
|
|
|
|
No,
|
|
|
|
};
|
|
|
|
|
|
|
|
RoutingDecision route_to(IPv4Address const& target, IPv4Address const& source, RefPtr<NetworkAdapter> const through = nullptr, AllowUsingGateway = AllowUsingGateway::Yes);
|
2019-08-28 11:58:01 +00:00
|
|
|
|
2022-02-03 00:07:57 +00:00
|
|
|
SpinlockProtected<HashMap<IPv4Address, MACAddress>>& arp_table();
|
2020-02-16 00:27:42 +00:00
|
|
|
|
|
|
|
}
|