blob: 9c0b19d62fc7ed1c64284e05b9858f1a06aeff25 (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#pragma once
#include <set>
#include <string>
#include <optional>
class Context
{
public:
Context()
{
}
struct NetworkAdapter
{
std::wstring guid;
std::wstring name;
std::wstring alias;
std::wstring deviceInstanceId;
NetworkAdapter(std::wstring guid, std::wstring name, std::wstring alias, std::wstring deviceInstanceId)
: guid(guid)
, name(name)
, alias(alias)
, deviceInstanceId(deviceInstanceId)
{
}
bool operator<(const NetworkAdapter &rhs) const
{
return _wcsicmp(deviceInstanceId.c_str(), rhs.deviceInstanceId.c_str()) < 0;
}
};
enum class BaselineStatus
{
NO_TAP_ADAPTERS_PRESENT,
SOME_TAP_ADAPTERS_PRESENT,
MULLVAD_ADAPTER_PRESENT
};
BaselineStatus establishBaseline();
void recordCurrentState();
//
// Restore TAP aliases to baseline state
//
void rollbackTapAliases();
//
// Identify a single new TAP adapter
//
NetworkAdapter getNewAdapter();
enum class DeletionResult
{
NO_REMAINING_TAP_ADAPTERS,
SOME_REMAINING_TAP_ADAPTERS
};
static DeletionResult DeleteMullvadAdapter();
private:
static std::optional<NetworkAdapter> FindMullvadAdapter(const std::set<NetworkAdapter> &tapAdapters);
std::set<NetworkAdapter> m_baseline;
std::set<NetworkAdapter> m_currentState;
};
|