-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[browser] no sockets #124347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[browser] no sockets #124347
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/libraries/Common/src/System/Net/SocketAddressPal.Browser.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Buffers.Binary; | ||
| using System.Net.Sockets; | ||
|
|
||
| namespace System.Net | ||
| { | ||
| internal static class SocketAddressPal | ||
| { | ||
| public const int IPv6AddressSize = 28; | ||
| public const int IPv4AddressSize = 16; | ||
| public const int UdsAddressSize = 110; | ||
| public const int MaxAddressSize = 128; | ||
|
|
||
| public static AddressFamily GetAddressFamily(ReadOnlySpan<byte> buffer) | ||
| { | ||
| return (AddressFamily)BinaryPrimitives.ReadUInt16LittleEndian(buffer); | ||
| } | ||
|
|
||
| public static void SetAddressFamily(Span<byte> buffer, AddressFamily family) | ||
| { | ||
| if ((int)(family) > ushort.MaxValue) | ||
| { | ||
| // For legacy values family maps directly to Winsock value. | ||
| // Other values will need mapping if/when supported. | ||
| throw new PlatformNotSupportedException(); | ||
| } | ||
|
|
||
| BinaryPrimitives.WriteUInt16LittleEndian(buffer, (ushort)family); | ||
| } | ||
|
|
||
| public static ushort GetPort(ReadOnlySpan<byte> buffer) | ||
| => BinaryPrimitives.ReadUInt16BigEndian(buffer.Slice(2)); | ||
|
|
||
| public static void SetPort(Span<byte> buffer, ushort port) | ||
| => BinaryPrimitives.WriteUInt16BigEndian(buffer.Slice(2), port); | ||
|
|
||
| public static uint GetIPv4Address(ReadOnlySpan<byte> buffer) | ||
| => BinaryPrimitives.ReadUInt32LittleEndian(buffer.Slice(4)); | ||
|
|
||
| public static void GetIPv6Address(ReadOnlySpan<byte> buffer, Span<byte> address, out uint scope) | ||
| { | ||
| buffer.Slice(8, address.Length).CopyTo(address); | ||
| scope = BinaryPrimitives.ReadUInt32LittleEndian(buffer.Slice(24)); | ||
| } | ||
|
|
||
| public static void SetIPv4Address(Span<byte> buffer, uint address) | ||
| { | ||
| BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4), address); | ||
| } | ||
|
|
||
| public static void SetIPv6Address(Span<byte> buffer, Span<byte> address, uint scope) | ||
| { | ||
| // No handling for Flow Information | ||
| BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(4), 0); | ||
|
|
||
| // Scope serialization | ||
| BinaryPrimitives.WriteUInt32LittleEndian(buffer.Slice(24), scope); | ||
|
|
||
| // Address serialization | ||
| address.CopyTo(buffer.Slice(8)); | ||
| } | ||
|
|
||
| public static void Clear(Span<byte> buffer) | ||
| { | ||
| AddressFamily family = GetAddressFamily(buffer); | ||
| buffer.Clear(); | ||
| SetAddressFamily(buffer, family); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/native/libs/System.Native/pal_interfaceaddresses_browser.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| // Stub implementations of interface address functions for browser target. | ||
|
|
||
| #include "pal_config.h" | ||
| #include "pal_interfaceaddresses.h" | ||
| #include "pal_utilities.h" | ||
|
|
||
| #include <errno.h> | ||
| #include <string.h> | ||
| #include <stdlib.h> | ||
|
|
||
| int32_t SystemNative_EnumerateInterfaceAddresses( | ||
| void* context, IPv4AddressFound onIpv4Found, IPv6AddressFound onIpv6Found, LinkLayerAddressFound onLinkLayerFound) | ||
| { | ||
| (void)context; | ||
| (void)onIpv4Found; | ||
| (void)onIpv6Found; | ||
| (void)onLinkLayerFound; | ||
| // Return success but don't enumerate any interfaces | ||
| return 0; | ||
| } | ||
|
|
||
| int32_t SystemNative_GetNetworkInterfaces(int32_t* interfaceCount, NetworkInterfaceInfo** interfaces, int32_t* addressCount, IpAddressInfo** addressList) | ||
| { | ||
| if (interfaceCount == NULL || interfaces == NULL || addressCount == NULL || addressList == NULL) | ||
| { | ||
| errno = EFAULT; | ||
| return -1; | ||
| } | ||
|
|
||
| // Return empty lists | ||
| *interfaceCount = 0; | ||
| *interfaces = NULL; | ||
| *addressCount = 0; | ||
| *addressList = NULL; | ||
| return 0; | ||
| } | ||
|
|
||
| int32_t SystemNative_EnumerateGatewayAddressesForInterface(void* context, uint32_t interfaceIndex, GatewayAddressFound onGatewayFound) | ||
| { | ||
| (void)context; | ||
| (void)interfaceIndex; | ||
| (void)onGatewayFound; | ||
| // Return success but don't enumerate any gateways | ||
| return 0; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.