Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit e970eec

Browse files
dotnet-botpgavlin
authored andcommitted
Initial commit of System.Net.Primitives.
1 parent 00a304f commit e970eec

File tree

73 files changed

+15178
-24
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+15178
-24
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
6+
internal static partial class Interop
7+
{
8+
internal static partial class Crypt32
9+
{
10+
// All constants below are from wincrypt.h.
11+
12+
// Algorithm classes
13+
public const int ALG_CLASS_ANY = 0;
14+
public const int ALG_CLASS_SIGNATURE = (1 << 13);
15+
public const int ALG_CLASS_ENCRYPT = (3 << 13);
16+
public const int ALG_CLASS_HASH = (4 << 13);
17+
public const int ALG_CLASS_KEY_EXCHANGE = (5 << 13);
18+
19+
// Algorithm types
20+
public const int ALG_TYPE_RSA = (2 << 9);
21+
public const int ALG_TYPE_BLOCK = (3 << 9);
22+
public const int ALG_TYPE_STREAM = (4 << 9);
23+
public const int ALG_TYPE_DH = (5 << 9);
24+
25+
// Block ciipher sub-IDs
26+
public const int ALG_SID_DES = 1;
27+
public const int ALG_SID_3DES = 3;
28+
public const int ALG_SID_AES_128 = 14;
29+
public const int ALG_SID_AES_192 = 15;
30+
public const int ALG_SID_AES_256 = 16;
31+
public const int ALG_SID_AES = 17;
32+
33+
// RC2 sub-IDs
34+
public const int ALG_SID_RC2 = 2;
35+
36+
// Stream cipher sub-IDs
37+
public const int ALG_SID_RC4 = 1;
38+
39+
// Diffie-Hellman sub-IDs
40+
public const int ALG_SID_DH_EPHEM = 2;
41+
42+
// Hash sub-IDs
43+
public const int ALG_SID_MD5 = 3;
44+
public const int ALG_SID_SHA = 4;
45+
}
46+
}

src/Common/src/Interop/Windows/Interop.Libraries.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ internal static class Libraries
1717
internal const string Handle = "api-ms-win-core-handle-l1-1-0.dll";
1818
internal const string Heap = "api-ms-win-core-heap-obsolete-l1-1-0.dll";
1919
internal const string IO = "api-ms-win-core-io-l1-1-0.dll";
20+
internal const string IpHlpApi = "iphlpapi.dll";
2021
internal const string Kernel32 = "kernel32.dll";
2122
internal const string Kernel32_L1 = "api-ms-win-core-kernel32-legacy-l1-1-1.dll";
2223
internal const string Kernel32_L2 = "api-ms-win-core-kernel32-legacy-l1-1-0.dll";
@@ -53,6 +54,7 @@ internal static class Libraries
5354
internal const string User32 = "user32.dll";
5455
internal const string Version = "api-ms-win-core-version-l1-1-0.dll";
5556
internal const string WinHttp = "winhttp.dll";
57+
internal const string Winsock = "Ws2_32.dll";
5658
internal const string Wow64 = "api-ms-win-core-wow64-l1-1-0.dll";
5759
internal const string Zlib = "clrcompression.dll";
5860
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
internal static partial class Interop
5+
{
6+
internal static partial class IpHlpApi
7+
{
8+
public const uint ERROR_SUCCESS = 0;
9+
public const uint ERROR_INVALID_FUNCTION = 1;
10+
public const uint ERROR_NO_SUCH_DEVICE = 2;
11+
public const uint ERROR_INVALID_DATA = 13;
12+
public const uint ERROR_INVALID_PARAMETER = 87;
13+
public const uint ERROR_BUFFER_OVERFLOW = 111;
14+
public const uint ERROR_INSUFFICIENT_BUFFER = 122;
15+
public const uint ERROR_NO_DATA = 232;
16+
public const uint ERROR_IO_PENDING = 997;
17+
public const uint ERROR_NOT_FOUND = 1168;
18+
}
19+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
using System.Runtime.InteropServices;
6+
7+
internal static partial class Interop
8+
{
9+
internal static partial class IpHlpApi
10+
{
11+
public const int MAX_HOSTNAME_LEN = 128;
12+
public const int MAX_DOMAIN_NAME_LEN = 128;
13+
public const int MAX_SCOPE_ID_LEN = 256;
14+
15+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
16+
public struct FIXED_INFO
17+
{
18+
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_HOSTNAME_LEN + 4)]
19+
public string hostName;
20+
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_DOMAIN_NAME_LEN + 4)]
21+
public string domainName;
22+
public IntPtr currentDnsServer; // IpAddressList*
23+
public IP_ADDR_STRING DnsServerList;
24+
public uint nodeType;
25+
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_SCOPE_ID_LEN + 4)]
26+
public string scopeId;
27+
public bool enableRouting;
28+
public bool enableProxy;
29+
public bool enableDns;
30+
}
31+
}
32+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System.Runtime.InteropServices;
5+
6+
using Microsoft.Win32.SafeHandles;
7+
8+
internal static partial class Interop
9+
{
10+
internal static partial class IpHlpApi
11+
{
12+
[DllImport(Interop.Libraries.IpHlpApi, ExactSpelling = true)]
13+
internal extern static uint GetNetworkParams(SafeLocalAllocHandle pFixedInfo, ref uint pOutBufLen);
14+
}
15+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
using System.Runtime.InteropServices;
6+
7+
internal static partial class Interop
8+
{
9+
internal static partial class IpHlpApi
10+
{
11+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
12+
public struct IP_ADDR_STRING
13+
{
14+
public IntPtr Next; // struct _IpAddressList*
15+
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
16+
public string IpAddress;
17+
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
18+
public string IpMask;
19+
public uint Context;
20+
}
21+
}
22+
}

src/Common/src/Interop/Windows/NtDll/Interop.NtStatus.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ internal class StatusOptions
88
// Error codes from ntstatus.h
99
internal const uint STATUS_SUCCESS = 0x00000000;
1010
internal const uint STATUS_SOME_NOT_MAPPED = 0x00000107;
11+
internal const uint STATUS_INVALID_PARAMETER = 0xC000000D;
1112
internal const uint STATUS_NO_MEMORY = 0xC0000017;
1213
internal const uint STATUS_OBJECT_NAME_NOT_FOUND = 0xC0000034;
1314
internal const uint STATUS_NONE_MAPPED = 0xC0000073;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System.Runtime.InteropServices;
5+
using System.Text;
6+
7+
internal static partial class Interop
8+
{
9+
internal static partial class NtDll
10+
{
11+
[DllImport(Interop.Libraries.NtDll, ExactSpelling = true, CharSet = CharSet.Unicode)]
12+
internal extern static uint RtlIpv4AddressToStringExW(
13+
[In] byte[] address,
14+
[In] ushort port,
15+
[In, Out] StringBuilder addressString,
16+
[In, Out] ref uint addressStringLength);
17+
}
18+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System.Runtime.InteropServices;
5+
6+
internal static partial class Interop
7+
{
8+
internal static partial class NtDll
9+
{
10+
[DllImport(Interop.Libraries.NtDll, ExactSpelling = true, CharSet = CharSet.Unicode)]
11+
internal extern static uint RtlIpv4StringToAddressExW(
12+
[In] string s,
13+
[In] bool strict,
14+
[Out] byte[] address,
15+
[Out] out ushort port);
16+
}
17+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System.Runtime.InteropServices;
5+
using System.Text;
6+
7+
internal static partial class Interop
8+
{
9+
internal static partial class NtDll
10+
{
11+
[DllImport(Interop.Libraries.NtDll, ExactSpelling = true, CharSet = CharSet.Unicode)]
12+
internal extern static uint RtlIpv6AddressToStringExW(
13+
[In] byte[] address,
14+
[In] uint scopeId,
15+
[In] ushort port,
16+
[In, Out] StringBuilder addressString,
17+
[In, Out] ref uint addressStringLength);
18+
}
19+
}

0 commit comments

Comments
 (0)