| 1 | // Copyright (C) Microsoft Corporation. All rights reserved. |
| 2 | |
| 3 | #pragma once |
| 4 | #include <optional> |
| 5 | #include <string> |
| 6 | #include <vector> |
| 7 | #include <wbemcli.h> |
| 8 | #include <windows.h> |
| 9 | #include "WslCoreConfig.h" |
| 10 | |
| 11 | namespace wsl::core::networking { |
| 12 | |
| 13 | enum class HyperVFirewallSupport |
| 14 | { |
| 15 | None, |
| 16 | Version1, // initially shipped with SV2 |
| 17 | Version2 // updated from Version1 and backported down to Windows 11 22H2 |
| 18 | }; |
| 19 | HyperVFirewallSupport GetHyperVFirewallSupportVersion(const FirewallConfiguration& firewallConfig) noexcept; |
| 20 | |
| 21 | std::wstring MakeLoopbackFirewallRuleId(const GUID& guid); |
| 22 | std::wstring MakeLocalSubnetFirewallRuleId(const GUID& guid); |
| 23 | |
| 24 | std::vector<FirewallRuleConfiguration> MakeDefaultFirewallRuleConfiguration(const GUID& guid); |
| 25 | FirewallRuleConfiguration MakeLoopbackFirewallRuleConfiguration(const std::wstring& ruleId); |
| 26 | FirewallRuleConfiguration MakeLocalSubnetFirewallRuleConfiguration(const std::wstring& ruleId); |
| 27 | |
| 28 | void ConfigureHyperVFirewall(const FirewallConfiguration& firewallConfig, const std::wstring& vmCreatorFriendlyName) noexcept; |
| 29 | |
| 30 | void ConfigureSharedAccessFirewallRule() noexcept; |
| 31 | |
| 32 | HRESULT AddHyperVFirewallRule(const GUID& vmCreatorId, const wsl::core::FirewallRuleConfiguration& firewallRule) noexcept; |
| 33 | HRESULT RemoveHyperVFirewallRule(const std::wstring& ruleId) noexcept; |
| 34 | |
| 35 | } // namespace wsl::core::networking |