| 1 | // Copyright (C) Microsoft Corporation. All rights reserved. |
| 2 | |
| 3 | #pragma once |
| 4 | |
| 5 | #include <computenetwork.h> |
| 6 | |
| 7 | namespace wsl::windows::common::stringify { |
| 8 | |
| 9 | constexpr auto ToString(NL_NETWORK_CONNECTIVITY_LEVEL_HINT level) noexcept |
| 10 | { |
| 11 | switch (level) |
| 12 | { |
| 13 | case NetworkConnectivityLevelHintNone:; |
| 14 | return "None"; |
| 15 | case NetworkConnectivityLevelHintLocalAccess: |
| 16 | return "LocalAccess"; |
| 17 | case NetworkConnectivityLevelHintInternetAccess: |
| 18 | return "InternetAccess"; |
| 19 | case NetworkConnectivityLevelHintConstrainedInternetAccess: |
| 20 | return "ConstrainedInternetAccess"; |
| 21 | case NetworkConnectivityLevelHintHidden: |
| 22 | return "Hidden"; |
| 23 | default: |
| 24 | return "Unknown"; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | constexpr auto ToString(NL_NETWORK_CONNECTIVITY_COST_HINT cost) noexcept |
| 29 | { |
| 30 | switch (cost) |
| 31 | { |
| 32 | case NetworkConnectivityCostHintUnrestricted: |
| 33 | return "Unrestricted"; |
| 34 | case NetworkConnectivityCostHintFixed: |
| 35 | return "Fixed"; |
| 36 | case NetworkConnectivityCostHintVariable: |
| 37 | return "Variable"; |
| 38 | default: |
| 39 | return "Unknown"; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | constexpr auto ToString(ABI::Windows::Networking::Connectivity::NetworkConnectivityLevel connectivityLevel) noexcept |
| 44 | { |
| 45 | using ABI::Windows::Networking::Connectivity::NetworkConnectivityLevel; |
| 46 | |
| 47 | switch (connectivityLevel) |
| 48 | { |
| 49 | case NetworkConnectivityLevel::NetworkConnectivityLevel_ConstrainedInternetAccess: |
| 50 | return "ConstrainedInternetAccess"; |
| 51 | case NetworkConnectivityLevel::NetworkConnectivityLevel_InternetAccess: |
| 52 | return "InternetAccess"; |
| 53 | case NetworkConnectivityLevel::NetworkConnectivityLevel_LocalAccess: |
| 54 | return "LocalAccess"; |
| 55 | case NetworkConnectivityLevel::NetworkConnectivityLevel_None: |
| 56 | return "None"; |
| 57 | default: |
| 58 | return "<unknown NetworkConnectivityLevel>"; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | constexpr auto HcnNotificationsToString(DWORD notification) noexcept |
| 63 | { |
| 64 | switch (notification) |
| 65 | { |
| 66 | case HcnNotificationNetworkPreCreate: |
| 67 | return "HcnNotificationNetworkPreCreate"; |
| 68 | case HcnNotificationNetworkCreate: |
| 69 | return "HcnNotificationNetworkCreate"; |
| 70 | case HcnNotificationNetworkPreDelete: |
| 71 | return "HcnNotificationNetworkPreDelete"; |
| 72 | case HcnNotificationNetworkDelete: |
| 73 | return "HcnNotificationNetworkDelete"; |
| 74 | case HcnNotificationNamespaceCreate: |
| 75 | return "HcnNotificationNamespaceCreate"; |
| 76 | case HcnNotificationNamespaceDelete: |
| 77 | return "HcnNotificationNamespaceDelete"; |
| 78 | /// Notifications for HCN_SERVICE handles |
| 79 | case 0x00000007: |
| 80 | return "HcnNotificationGuestNetworkServiceCreate"; |
| 81 | case 0x00000008: |
| 82 | return "HcnNotificationGuestNetworkServiceDelete"; |
| 83 | /// Notifications for HCN_NETWORK handles |
| 84 | case 0x00000009: |
| 85 | return "HcnNotificationNetworkEndpointAttached"; |
| 86 | case 0x00000010: |
| 87 | return "HcnNotificationNetworkEndpointDetached"; |
| 88 | /// Notifications for HCN_GUESTNETWORKSERVICE handles |
| 89 | case 0x00000011: |
| 90 | return "HcnNotificationGuestNetworkServiceStateChanged"; |
| 91 | case 0x00000012: |
| 92 | return "HcnNotificationGuestNetworkServiceInterfaceStateChanged"; |
| 93 | case HcnNotificationServiceDisconnect: |
| 94 | return "HcnNotificationServiceDisconnect"; |
| 95 | default: |
| 96 | return "<unknown>"; |
| 97 | } |
| 98 | } |
| 99 | } // namespace wsl::windows::common::stringify |