[Dnsmail-cvs] dnsmail UnsafeNativeMethods.cs,1.4,1.5
Brought to you by:
ethem
From: Ethem E. <et...@us...> - 2006-08-07 08:25:17
|
Update of /cvsroot/dnsmail/dnsmail In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv22821/dnsmail Modified Files: UnsafeNativeMethods.cs Log Message: Coding art. tabs, spaces, etc... :) Index: UnsafeNativeMethods.cs =================================================================== RCS file: /cvsroot/dnsmail/dnsmail/UnsafeNativeMethods.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** UnsafeNativeMethods.cs 4 Aug 2006 12:53:36 -0000 1.4 --- UnsafeNativeMethods.cs 7 Aug 2006 08:25:14 -0000 1.5 *************** *** 10,14 **** internal sealed class STRUCTURES { ! private STRUCTURES(){} internal const UInt32 SUCCESS = 0; internal const UInt32 DNS_QUERY_STANDARD = 0; --- 10,14 ---- internal sealed class STRUCTURES { ! private STRUCTURES() { } internal const UInt32 SUCCESS = 0; internal const UInt32 DNS_QUERY_STANDARD = 0; *************** *** 37,45 **** internal IntPtr pNext; internal String pName; ! [MarshalAs(UnmanagedType.U2)]internal UInt16 wType; ! [MarshalAs(UnmanagedType.U2)]internal UInt16 wDataLength; ! [MarshalAs(UnmanagedType.U4)]internal UInt32 flags; ! [MarshalAs(UnmanagedType.U4)]internal UInt32 dwTtl; ! [MarshalAs(UnmanagedType.U4)]internal UInt32 dwReserved; internal static readonly int SIZE = Marshal.SizeOf(typeof(DNS_RECORD)); } --- 37,50 ---- internal IntPtr pNext; internal String pName; ! [MarshalAs(UnmanagedType.U2)] ! internal UInt16 wType; ! [MarshalAs(UnmanagedType.U2)] ! internal UInt16 wDataLength; ! [MarshalAs(UnmanagedType.U4)] ! internal UInt32 flags; ! [MarshalAs(UnmanagedType.U4)] ! internal UInt32 dwTtl; ! [MarshalAs(UnmanagedType.U4)] ! internal UInt32 dwReserved; internal static readonly int SIZE = Marshal.SizeOf(typeof(DNS_RECORD)); } *************** *** 53,65 **** internal struct FIXED_INFO { ! [MarshalAs(UnmanagedType.ByValTStr, SizeConst=132)]internal string HostName; ! [MarshalAs(UnmanagedType.ByValTStr, SizeConst=132)]internal string DomainName; internal IntPtr CurrentDnsServer; // pointer to IP_ADDR_STRING internal IP_ADDR_STRING DnsServerList; internal UInt32 NodeType; ! [MarshalAs(UnmanagedType.ByValTStr, SizeConst=260)]internal string ScopeId; ! internal UInt32 EnableRouting; ! internal UInt32 EnableProxy; ! internal UInt32 EnableDns; } #endregion --- 58,73 ---- internal struct FIXED_INFO { ! [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 132)] ! internal string HostName; ! [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 132)] ! internal string DomainName; internal IntPtr CurrentDnsServer; // pointer to IP_ADDR_STRING internal IP_ADDR_STRING DnsServerList; internal UInt32 NodeType; ! [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] ! internal string ScopeId; ! internal bool EnableRouting; ! internal bool EnableProxy; ! internal bool EnableDns; } #endregion *************** *** 73,87 **** { internal IntPtr Next; ! [MarshalAs(UnmanagedType.ByValTStr, SizeConst=16)]internal string IpAddress; ! [MarshalAs(UnmanagedType.ByValTStr, SizeConst=16)]internal string IpMask; ! internal UInt32 Context; } #endregion } ! [SuppressUnmanagedCodeSecurityAttribute()] internal sealed class UnsafeNativeMethods { ! private UnsafeNativeMethods(){} private const String DNS_API_DLL = "dnsapi.dll"; private const String DNS_API_QUERY = "DnsQuery_A"; --- 81,97 ---- { internal IntPtr Next; ! [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] ! internal string IpAddress; ! [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] ! internal string IpMask; ! internal uint Context; } #endregion } ! [SuppressUnmanagedCodeSecurityAttribute()] internal sealed class UnsafeNativeMethods { ! private UnsafeNativeMethods() { } private const String DNS_API_DLL = "dnsapi.dll"; private const String DNS_API_QUERY = "DnsQuery_A"; *************** *** 93,104 **** /// DnsQuery /// </summary> ! [DllImport(DNS_API_DLL,EntryPoint=DNS_API_QUERY,CharSet=CharSet.Auto,SetLastError=true)] internal static extern UInt32 DnsQuery( ! [In, MarshalAs(UnmanagedType.LPStr)] String lpstrName, ! [In, MarshalAs(UnmanagedType.U2)] UInt16 wType, ! [In, MarshalAs(UnmanagedType.U4)] UInt32 fOptions, ! [In] IntPtr aipServers, ! [In, Out] ref IntPtr ppQueryResults, ! [In, Out] IntPtr pReserved ); #endregion --- 103,114 ---- /// DnsQuery /// </summary> ! [DllImport(DNS_API_DLL, EntryPoint = DNS_API_QUERY, CharSet = CharSet.Auto, SetLastError = true)] internal static extern UInt32 DnsQuery( ! [In, MarshalAs(UnmanagedType.LPStr)] String lpstrName, ! [In, MarshalAs(UnmanagedType.U2)] UInt16 wType, ! [In, MarshalAs(UnmanagedType.U4)] UInt32 fOptions, ! [In] IntPtr aipServers, ! [In, Out] ref IntPtr ppQueryResults, ! [In, Out] IntPtr pReserved ); #endregion *************** *** 119,123 **** /// GetNetworkParams /// </summary> ! [DllImport(IP_HELP_API_DLL, CharSet=CharSet.Auto, SetLastError=true)] private static extern UInt32 GetNetworkParams( IntPtr pMemory, --- 129,133 ---- /// GetNetworkParams /// </summary> ! [DllImport(IP_HELP_API_DLL, CharSet = CharSet.Auto, SetLastError = true)] private static extern UInt32 GetNetworkParams( IntPtr pMemory, *************** *** 148,152 **** iptemp = new ArrayList(); fi = (STRUCTURES.FIXED_INFO)Marshal.PtrToStructure(pMemory, typeof(STRUCTURES.FIXED_INFO)); ! if(fi.DnsServerList.IpAddress!=null && fi.DnsServerList.IpAddress!=String.Empty) { iptemp.Add(String.Copy(fi.DnsServerList.IpAddress)); --- 158,162 ---- iptemp = new ArrayList(); fi = (STRUCTURES.FIXED_INFO)Marshal.PtrToStructure(pMemory, typeof(STRUCTURES.FIXED_INFO)); ! if (fi.DnsServerList.IpAddress != null && fi.DnsServerList.IpAddress != String.Empty) { iptemp.Add(String.Copy(fi.DnsServerList.IpAddress)); *************** *** 156,160 **** { serv = (STRUCTURES.IP_ADDR_STRING)Marshal.PtrToStructure(pAddrStr, typeof(STRUCTURES.IP_ADDR_STRING)); ! if(serv.IpAddress!=null && serv.IpAddress!=String.Empty) iptemp.Add(String.Copy(serv.IpAddress)); --- 166,170 ---- { serv = (STRUCTURES.IP_ADDR_STRING)Marshal.PtrToStructure(pAddrStr, typeof(STRUCTURES.IP_ADDR_STRING)); ! if (serv.IpAddress != null && serv.IpAddress != String.Empty) iptemp.Add(String.Copy(serv.IpAddress)); *************** *** 164,168 **** } Marshal.DestroyStructure(pMemory, typeof(STRUCTURES.FIXED_INFO)); ! if(iptemp.Count > 0) { String[] servers = (String[])iptemp.ToArray(typeof(String)); --- 174,178 ---- } Marshal.DestroyStructure(pMemory, typeof(STRUCTURES.FIXED_INFO)); ! if (iptemp.Count > 0) { String[] servers = (String[])iptemp.ToArray(typeof(String)); *************** *** 171,175 **** } else ! return new string[0]{}; //length=0 } finally --- 181,185 ---- } else ! return new string[0] { }; //length=0 } finally *************** *** 188,219 **** internal unsafe sealed class UnsafeOpenSsl { ! private UnsafeOpenSsl(){} private const String LIB_EAY = @"libeay32.dll"; private const String LIB_SSL = @"ssleay32.dll"; ! [DllImport(LIB_SSL)] internal static extern int SSL_library_init(); ! [DllImport(LIB_SSL)] internal static extern void SSL_load_error_strings(); ! [DllImport(LIB_SSL)] internal static extern IntPtr TLSv1_method(); ! [DllImport(LIB_SSL)] internal static extern IntPtr SSL_CTX_new(IntPtr method); ! [DllImport(LIB_SSL)] internal static extern void SSL_CTX_free(IntPtr ctx); ! [DllImport(LIB_SSL)] internal static extern IntPtr SSL_new(IntPtr ctx); ! [DllImport(LIB_SSL)] internal static extern void SSL_free(IntPtr ssl); ! [DllImport(LIB_SSL)] internal static extern int SSL_shutdown(IntPtr ssl); ! [DllImport(LIB_SSL)] internal static extern int SSL_set_fd(IntPtr ssl, IntPtr sockHandle); ! [DllImport(LIB_SSL)] internal static extern void SSL_set_quiet_shutdown(IntPtr ssl, int mode); ! [DllImport(LIB_SSL)] internal static extern int SSL_ctrl(IntPtr ssl, int cmd, int larg, IntPtr parg); ! [DllImport(LIB_SSL)] internal static extern int SSL_connect(IntPtr ssl); ! [DllImport(LIB_SSL)] internal static extern int SSL_read(IntPtr ssl, byte* buf, int num); ! [DllImport(LIB_SSL)] internal static extern int SSL_write(IntPtr ssl, byte* buf, int num); ! [DllImport(LIB_SSL)] internal static extern int SSL_peek(IntPtr ssl, byte* buf, int num); ! [DllImport(LIB_SSL)] internal static extern IntPtr SSL_get_peer_certificate(IntPtr ssl); ! [DllImport(LIB_SSL)] internal static extern int SSL_get_error(IntPtr ssl, int ret); ! [DllImport(LIB_EAY)] internal static extern uint SSLeay(); ! [DllImport(LIB_EAY)] internal static extern int ERR_get_error(); ! [DllImport(LIB_EAY)] internal static extern int ERR_peek_error(); ! [DllImport(LIB_EAY)] internal static extern String ERR_error_string_n(int e, System.Text.StringBuilder sb, int l); ! [DllImport(LIB_EAY)] internal static extern void X509_free(IntPtr x509); ! [DllImport(LIB_EAY)] internal static extern int i2d_X509(IntPtr cer, byte** ppOut); } }; --- 198,252 ---- internal unsafe sealed class UnsafeOpenSsl { ! private UnsafeOpenSsl() { } private const String LIB_EAY = @"libeay32.dll"; private const String LIB_SSL = @"ssleay32.dll"; ! [DllImport(LIB_SSL)] ! internal static extern int SSL_library_init(); ! [DllImport(LIB_SSL)] ! internal static extern void SSL_load_error_strings(); ! [DllImport(LIB_SSL)] ! internal static extern IntPtr TLSv1_method(); ! [DllImport(LIB_SSL)] ! internal static extern IntPtr SSL_CTX_new(IntPtr method); ! [DllImport(LIB_SSL)] ! internal static extern void SSL_CTX_free(IntPtr ctx); ! [DllImport(LIB_SSL)] ! internal static extern IntPtr SSL_new(IntPtr ctx); ! [DllImport(LIB_SSL)] ! internal static extern void SSL_free(IntPtr ssl); ! [DllImport(LIB_SSL)] ! internal static extern int SSL_shutdown(IntPtr ssl); ! [DllImport(LIB_SSL)] ! internal static extern int SSL_set_fd(IntPtr ssl, IntPtr sockHandle); ! [DllImport(LIB_SSL)] ! internal static extern void SSL_set_quiet_shutdown(IntPtr ssl, int mode); ! [DllImport(LIB_SSL)] ! internal static extern int SSL_ctrl(IntPtr ssl, int cmd, int larg, IntPtr parg); ! [DllImport(LIB_SSL)] ! internal static extern int SSL_connect(IntPtr ssl); ! [DllImport(LIB_SSL)] ! internal static extern int SSL_read(IntPtr ssl, byte* buf, int num); ! [DllImport(LIB_SSL)] ! internal static extern int SSL_write(IntPtr ssl, byte* buf, int num); ! [DllImport(LIB_SSL)] ! internal static extern int SSL_peek(IntPtr ssl, byte* buf, int num); ! [DllImport(LIB_SSL)] ! internal static extern IntPtr SSL_get_peer_certificate(IntPtr ssl); ! [DllImport(LIB_SSL)] ! internal static extern int SSL_get_error(IntPtr ssl, int ret); ! [DllImport(LIB_EAY)] ! internal static extern uint SSLeay(); ! [DllImport(LIB_EAY)] ! internal static extern int ERR_get_error(); ! [DllImport(LIB_EAY)] ! internal static extern int ERR_peek_error(); ! [DllImport(LIB_EAY)] ! internal static extern String ERR_error_string_n(int e, System.Text.StringBuilder sb, int l); ! [DllImport(LIB_EAY)] ! internal static extern void X509_free(IntPtr x509); ! [DllImport(LIB_EAY)] ! internal static extern int i2d_X509(IntPtr cer, byte** ppOut); } }; |