| 1 | /*++ |
| 2 | |
| 3 | Copyright (c) Microsoft. All rights reserved. |
| 4 | |
| 5 | Module Name: |
| 6 | |
| 7 | ContainerPortMapping.h |
| 8 | |
| 9 | Abstract: |
| 10 | |
| 11 | This file contains the definition of the WinRT wrapper for the WSLC SDK ContainerPortMapping class. |
| 12 | |
| 13 | --*/ |
| 14 | |
| 15 | #pragma once |
| 16 | #include "Microsoft.WSL.Containers.ContainerPortMapping.g.h" |
| 17 | #include "Helpers.h" |
| 18 | #include <winrt/Windows.Networking.h> |
| 19 | |
| 20 | namespace winrt::Microsoft::WSL::Containers::implementation { |
| 21 | struct ContainerPortMapping : ContainerPortMappingT<ContainerPortMapping> |
| 22 | { |
| 23 | ContainerPortMapping() = default; |
| 24 | |
| 25 | ContainerPortMapping(uint16_t windowsPort, uint16_t containerPort, winrt::Microsoft::WSL::Containers::PortProtocol const& protocol); |
| 26 | uint16_t WindowsPort(); |
| 27 | void WindowsPort(uint16_t value); |
| 28 | uint16_t ContainerPort(); |
| 29 | void ContainerPort(uint16_t value); |
| 30 | winrt::Microsoft::WSL::Containers::PortProtocol Protocol(); |
| 31 | void Protocol(winrt::Microsoft::WSL::Containers::PortProtocol const& value); |
| 32 | winrt::Windows::Networking::HostName WindowsAddress(); |
| 33 | void WindowsAddress(winrt::Windows::Networking::HostName const& value); |
| 34 | |
| 35 | WslcContainerPortMapping ToStruct(); |
| 36 | |
| 37 | private: |
| 38 | uint16_t m_windowsPort{}; |
| 39 | uint16_t m_containerPort{}; |
| 40 | winrt::Microsoft::WSL::Containers::PortProtocol m_protocol{winrt::Microsoft::WSL::Containers::PortProtocol::TCP}; |
| 41 | winrt::Windows::Networking::HostName m_windowsAddress{nullptr}; |
| 42 | |
| 43 | std::unique_ptr<WslcContainerPortMapping> m_containerPortMapping; |
| 44 | std::optional<sockaddr_storage> m_windowsAddressStorage; |
| 45 | }; |
| 46 | } // namespace winrt::Microsoft::WSL::Containers::implementation |
| 47 | |
| 48 | namespace winrt::Microsoft::WSL::Containers::factory_implementation { |
| 49 | struct ContainerPortMapping : ContainerPortMappingT<ContainerPortMapping, implementation::ContainerPortMapping> |
| 50 | { |
| 51 | }; |
| 52 | } // namespace winrt::Microsoft::WSL::Containers::factory_implementation |
| 53 | |
| 54 | DEFINE_TYPE_HELPERS(ContainerPortMapping); |