summaryrefslogtreecommitdiffhomepage
path: root/windows/nsis-plugins/src/driverlogic/context.h
blob: 53d2ddeedcac6a3ac0af8f7505cba1de890c838f (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
#pragma once

#include <set>
#include <string>

class Context
{
public:

	struct VirtualNic
	{
		std::wstring node;
		std::wstring name;
		std::wstring alias;

		bool operator<(const VirtualNic &rhs) const
		{
			return _wcsicmp(node.c_str(), rhs.node.c_str()) < 0;
		}
	};

	enum class BaselineStatus
	{
		NO_INTERFACES_PRESENT,
		SOME_INTERFACES_PRESENT,
		MULLVAD_INTERFACE_PRESENT
	};

	//
	// Invoke with the output from "tapinstall hwids tap0901"
	//
	BaselineStatus establishBaseline(const std::wstring &textBlock);

	//
	// Invoke with the output from "tapinstall hwids tap0901"
	//
	void recordCurrentState(const std::wstring &textBlock);

	//
	// Identify a single new interface
	//
	VirtualNic getNewAdapter();

private:

	static std::set<VirtualNic> ParseVirtualNics(const std::wstring &textBlock);
	static std::wstring GetNicAlias(const std::wstring &name);

	std::set<VirtualNic> m_baseline;
	std::set<VirtualNic> m_currentState;
};