summaryrefslogtreecommitdiff
path: root/Kernel/Net/Routing.h
blob: 5ec2e706c97f301f25851089ef5518bb7369eba6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <Kernel/Locking/MutexProtected.h>
#include <Kernel/Net/NetworkAdapter.h>
#include <Kernel/Thread.h>

namespace Kernel {

struct RoutingDecision {
    RefPtr<NetworkAdapter> adapter;
    MACAddress next_hop;

    bool is_zero() const;
};

enum class UpdateArp {
    Set,
    Delete,
};

void update_arp_table(IPv4Address const&, MACAddress const&, UpdateArp update);
RoutingDecision route_to(IPv4Address const& target, IPv4Address const& source, RefPtr<NetworkAdapter> const through = nullptr);

MutexProtected<HashMap<IPv4Address, MACAddress>>& arp_table();

}