-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStructs.cs
More file actions
96 lines (89 loc) · 2.94 KB
/
Copy pathStructs.cs
File metadata and controls
96 lines (89 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// OpenSNI - Open Source SQL Server Network Interface for macOS/Linux
// Struct definitions matching Interop.Windows.Sni in Microsoft.Data.SqlClient
using System;
using System.Runtime.InteropServices;
namespace OpenSNI;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct SniError
{
internal Provider provider;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 261)]
internal string errorMessage;
internal int nativeError;
internal uint sniError;
[MarshalAs(UnmanagedType.LPWStr)]
internal string? fileName;
[MarshalAs(UnmanagedType.LPWStr)]
internal string? function;
internal uint lineNumber;
}
[StructLayout(LayoutKind.Sequential)]
internal struct SniConsumerInfo
{
public int DefaultUserDataLength;
public nint ConsumerKey;
public nint fnReadComp;
public nint fnWriteComp;
public nint fnTrace;
public nint fnAcceptComp;
public uint dwNumProts;
public nint rgListenInfo;
public nint NodeAffinity;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct AuthProviderInfo
{
public uint flags;
[MarshalAs(UnmanagedType.Bool)]
public bool tlsFirst;
[MarshalAs(UnmanagedType.LPWStr)]
public string? certId;
[MarshalAs(UnmanagedType.Bool)]
public bool certHash;
public object? cert;
[MarshalAs(UnmanagedType.Bool)]
public bool enforceRevocation;
[MarshalAs(UnmanagedType.Bool)]
public bool ignoreSniEndpointName;
public uint tlsCompressionType;
}
// Exact match of SniClientConsumerInfo.cs from SqlClient source
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct SniClientConsumerInfo
{
public SniConsumerInfo ConsumerInfo;
[MarshalAs(UnmanagedType.LPWStr)]
public string? wszConnectionString;
[MarshalAs(UnmanagedType.LPWStr)]
public string? HostNameInCertificate;
public Prefix networkLibrary;
public byte* szSPN;
public uint cchSPN;
public byte* szInstanceName;
public uint cchInstanceName;
[MarshalAs(UnmanagedType.Bool)]
public bool fOverrideLastConnectCache;
[MarshalAs(UnmanagedType.Bool)]
public bool fSynchronousConnection;
public int timeout;
[MarshalAs(UnmanagedType.Bool)]
public bool fParallel;
public TransparentNetworkResolutionMode transparentNetworkResolution;
public int totalTimeout;
public bool isAzureSqlServerEndpoint;
public SqlConnectionIPAddressPreference ipAddressPreference;
public SniDnsCacheInfo DNSCacheInfo; // embedded, not a pointer!
}
// Exact match of SniDnsCacheInfo.cs from SqlClient source
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct SniDnsCacheInfo
{
[MarshalAs(UnmanagedType.LPWStr)]
public string? wszCachedFQDN;
[MarshalAs(UnmanagedType.LPWStr)]
public string? wszCachedTcpIPv4;
[MarshalAs(UnmanagedType.LPWStr)]
public string? wszCachedTcpIPv6;
[MarshalAs(UnmanagedType.LPWStr)]
public string? wszCachedTcpPort;
}