@@ -35,7 +35,7 @@ if (options.As(&optionsStaging10) == S_OK)
3535{
3636 // Configure port ranges for WebRTC UDP traffic to work within enterprise firewalls
3737 // Set UDP port range (example: 50000-55000 for enterprise environments)
38- const UINT32 udpMin = 50000, udpMax = 55000;
38+ const INT32 udpMin = 50000, udpMax = 55000;
3939
4040 CHECK_FAILURE (optionsStaging10->SetAllowedPortRange(
4141 COREWEBVIEW2_TRANSPORT_PROTOCOL_UDP, udpMin, udpMax));
@@ -80,52 +80,56 @@ OnCreateEnvironmentCompleted(environment);
8080# API Details
8181### C++
8282```
83- /// Specifies the transport protocol type for port configuration.
83+ /// Specifies the network protocol type for port configuration.
8484[v1_enum]
85- typedef enum COREWEBVIEW2_TRANSPORT_PROTOCOL {
86- /// Transmission Control Protocol - reliable, connection-oriented protocol.
87- COREWEBVIEW2_TRANSPORT_PROTOCOL_TCP,
85+ typedef enum COREWEBVIEW2_NETWORK_PROTOCOL {
8886 /// User Datagram Protocol - fast, connectionless protocol.
89- COREWEBVIEW2_TRANSPORT_PROTOCOL_UDP ,
90- } COREWEBVIEW2_TRANSPORT_PROTOCOL ;
87+ COREWEBVIEW2_NETWORK_PROTOCOL_UDP ,
88+ } COREWEBVIEW2_NETWORK_PROTOCOL ;
9189
9290/// Additional options used to create WebView2 Environment to manage port range configuration.
9391[uuid(eaf22436-27a1-5e3d-a4e3-84d7e7a69a1a), object, pointer_default(unique)]
9492interface ICoreWebView2StagingEnvironmentOptions10 : IUnknown {
9593 /// Sets the allowed port range for the specified transport protocol.
96- /// This allows WebView2 to work within enterprise firewall constraints
97- /// by restricting transport communication to the specified port range.
98- /// Currently only WebRTC UDP port restriction is supported.
99- /// minPort and maxPort must be in the range 1025-65535 (inclusive).
100- /// Calls with invalid ranges fail with E_INVALIDARG.
101- /// minPort must be less than or equal to maxPort.
102- /// If minPort equals maxPort, it represents a single port.
103- /// If (0,0) is passed as (minPort, maxPort), API will treat this as default
104- /// value and no restrictions on ports will be applied.
94+ /// This API enables WebView2 to operate within enterprise network or firewall
95+ /// restrictions by limiting network communication to a defined port range.
10596 ///
106- /// `protocol` The transport protocol (TCP or UDP) for which to set the port range.
107- /// `minPort` The minimum port number in the allowed range (inclusive).
108- /// `maxPort` The maximum port number in the allowed range (inclusive).
97+ /// Currently, only WebRTC UDP Port Range restriction is supported.
98+ ///
99+ /// `minPort` and `maxPort` must be within the range 1025–65535 (inclusive),
100+ /// and `minPort` must be less than or equal to `maxPort`.
101+ /// If `minPort` equals `maxPort`, the range represents a single port.
102+ ///
103+ /// Passing `(0, 0)` resets to the default behavior, meaning no restrictions
104+ /// are applied and the system assigns ports from the full ephemeral range.
105+ ///
106+ /// Calls with invalid ranges fail with `E_INVALIDARG`.
107+ ///
108+ /// `protocol` The transport protocol (currently only UDP is supported).
109+ /// `minPort` The minimum allowed port number (inclusive).
110+ /// `maxPort` The maximum allowed port number (inclusive).
109111 ///
110112 HRESULT SetAllowedPortRange(
111- [in] COREWEBVIEW2_TRANSPORT_PROTOCOL protocol,
112- [in] UINT32 minPort,
113- [in] UINT32 maxPort
113+ [in] COREWEBVIEW2_NETWORK_PROTOCOL protocol,
114+ [in] INT32 minPort,
115+ [in] INT32 maxPort
114116 );
115117
116- /// Gets the allowed port range for the specified transport protocol.
117- /// Returns the current port range configuration that was set via
118- /// SetAllowedPortRange. Default value is (0,0) which means no restrictions applied
119- /// and ports are allocated randomly between system's ephemeral range 1025-65535 (inclusive).
118+ /// Retrieves the allowed port range for the specified transport protocol.
119+ /// Returns the currently configured port range previously set via
120+ /// `SetAllowedPortRange`.
121+ ///
122+ /// By default, `(0, 0)` is returned, which indicates no restrictions are applied
123+ /// and ports are allocated from the system’s ephemeral range (1025–65535 inclusive).
120124 ///
121- /// `protocol` The transport protocol (TCP or UDP) for which to get the port range .
122- /// `minPort` Receives the minimum port number in the allowed range .
123- /// `maxPort` Receives the maximum port number in the allowed range .
125+ /// `protocol` The transport protocol (currently only UDP is supported) .
126+ /// `minPort` Receives the minimum allowed port number (inclusive) .
127+ /// `maxPort` Receives the maximum allowed port number (inclusive) .
124128 ///
125129 HRESULT GetAllowedPortRange(
126- [in] COREWEBVIEW2_TRANSPORT_PROTOCOL protocol,
127- [out] UINT32 * minPort,
128- [out] UINT32 * maxPort
130+ [in] COREWEBVIEW2_NETWORK_PROTOCOL protocol,
131+ [out] INT32 * minPort,
132+ [out] INT32 * maxPort
129133 );
130134
131135
@@ -138,17 +142,16 @@ namespace Microsoft.Web.WebView2.Core
138142{
139143 enum CoreWebView2NetworkProtocol
140144 {
141- Tcp = 0 ,
142- Udp = 1 ,
145+ Udp = 0 ,
143146 };
144147
145148 runtimeclass CoreWebView2EnvironmentOptions
146149 {
147150 [interface_name (" Microsoft.Web.WebView2.Core.ICoreWebView2StagingEnvironmentOptions10" )]
148151 {
149152 // ICoreWebView2StagingEnvironmentOptions10 members
150- void SetAllowedPortRange(CoreWebView2NetworkProtocol protocol, UInt32 minPort, UInt32 maxPort);
151- void GetAllowedPortRange(CoreWebView2NetworkProtocol protocol, out UInt32 minPort, out UInt32 maxPort);
153+ void SetAllowedPortRange(CoreWebView2NetworkProtocol protocol, Int32 minPort, Int32 maxPort);
154+ void GetAllowedPortRange(CoreWebView2NetworkProtocol protocol, out Int32 minPort, out Int32 maxPort);
152155 }
153156 }
154157}
0 commit comments