diff --git a/PInvoke/Ws2_32/WinSock2.WSA.cs b/PInvoke/Ws2_32/WinSock2.WSA.cs
index 078b843f..5fef90df 100644
--- a/PInvoke/Ws2_32/WinSock2.WSA.cs
+++ b/PInvoke/Ws2_32/WinSock2.WSA.cs
@@ -10157,261 +10157,6 @@ namespace Vanara.PInvoke
public SOCKET[] fd_array;
}
- /// The SOCKET_ADDRESS_LIST structure defines a variable-sized list of transport addresses.
- ///
- ///
- /// A WSK application passes a buffer to the WskControlSocket function when the WSK application queries the current list of local
- /// transport addresses that match a socket's address family. If the call to the WskControlSocket function succeeds, the
- /// buffer contains a SOCKET_ADDRESS_LIST structure followed by the SOCKADDR structures for each of the local transport addresses
- /// that match the socket's address family. The WSK subsystem fills in the Address array and sets the iAddressCount
- /// member to the number of entries in the array. The lpSockaddr pointers in each of the SOCKET_ADDRESS structures in the
- /// array point to the specific SOCKADDR structure type that corresponds to the address family that the WSK application specified
- /// when it created the socket.
- ///
- /// For more information about querying the current list of local transport addresses, see SIO_ADDRESS_LIST_QUERY.
- ///
- // https://docs.microsoft.com/en-us/windows/win32/api/ws2def/ns-ws2def-socket_address_list typedef struct _SOCKET_ADDRESS_LIST { INT
- // iAddressCount; SOCKET_ADDRESS Address[1]; } SOCKET_ADDRESS_LIST, *PSOCKET_ADDRESS_LIST, *LPSOCKET_ADDRESS_LIST;
- [PInvokeData("ws2def.h", MSDNShortId = "b005200b-b0c2-4f19-8765-cd26fbfc0cff")]
- [VanaraMarshaler(typeof(SafeAnysizeStructMarshaler), nameof(iAddressCount))]
- [StructLayout(LayoutKind.Sequential)]
- public struct SOCKET_ADDRESS_LIST
- {
- /// The number of transport addresses in the list.
- public int iAddressCount;
-
- /// A variable-sized array of SOCKET_ADDRESS structures. The SOCKET_ADDRESS structure is defined as follows:
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
- public SOCKET_ADDRESS[] Address;
- }
-
- ///
- /// The WSAMSG structure is used with the WSARecvMsg and WSASendMsg functions to store address and optional control
- /// information about connected and unconnected sockets as well as an array of buffers used to store message data.
- ///
- ///
- ///
- /// In the Microsoft Windows Software Development Kit (SDK), the version of this structure for use on Windows Vistais defined with
- /// the data type for the dwBufferCount and dwFlags members as a ULONG. When compiling an application if the
- /// target platform is Windows Vista and later ( NTDDI_VERSION >= NTDDI_LONGHORN, _WIN32_WINNT >= 0x0600, or WINVER
- /// >= 0x0600), the data type for the dwBufferCount and dwFlags members is a ULONG.
- ///
- ///
- /// Windows Server 2003 and Windows XP: When compiling an application, the data type for the dwBufferCount and
- /// dwFlags members is a DWORD.
- ///
- ///
- /// On the Windows SDK released for Windows Vista and later, the WSAMSG structure is defined in the Ws2def.h header file.
- /// Note that the Ws2def.h header file is automatically included in Winsock2.h, and should never be used directly
- ///
- ///
- /// If the datagram or control data is truncated during the transmission, the function being used in association with the
- /// WSAMSG structure returns SOCKET_ERROR and a call to the WSAGetLastError function returns WSAEMSGSIZE. It is up to the
- /// application to determine what was truncated by checking for MSG_TRUNC and/or MSG_CTRUNC flags.
- ///
- /// Use of the Control Member
- ///
- /// The following table summarizes the various uses of control data available for use in the Control member for IPv4 and IPv6.
- ///
- ///
- ///
- /// Protocol
- /// cmsg_level
- /// cmsg_type
- /// Description
- ///
- /// -
- /// IPv4
- /// IPPROTO_IP
- /// IP_ORIGINAL_ARRIVAL_IF
- ///
- /// Receives the original IPv4 arrival interface where the packet was received for datagram sockets. This control data is used by
- /// firewalls when a Teredo, 6to4, or ISATAP tunnel is used for IPv4 NAT traversal. The cmsg_data[] member in the WSAMSG structure
- /// is a ULONG that contains the IF_INDEX defined in the Ifdef.h header file. For more information, see the IPPROTO_IP Socket
- /// Options for the IP_ORIGINAL_ARRIVAL_IF socket option. Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP:
- /// The IP_ORIGINAL_ARRIVAL_IF cmsg_type is not supported.
- ///
- ///
- /// -
- /// IPv4
- /// IPPROTO_IP
- /// IP_PKTINFO
- /// Specifies/receives packet information for an IPv4 socket. For more information, see the IP_PKTINFO socket option.
- ///
- /// -
- /// IPv6
- /// IPPROTO_IPV6
- /// IPV6_DSTOPTS
- /// Specifies/receives destination options.
- ///
- /// -
- /// IPv6
- /// IPPROTO_IPV6
- /// IPV6_HOPLIMIT
- /// Specifies/receives hop limit. For more information, see the IPPROTO_IPV6 Socket Options for the IPV6_HOPLIMIT socket option.
- ///
- /// -
- /// IPv6
- /// IPPROTO_IPV6
- /// IPV6_HOPOPTS
- /// Specifies/receives hop-by-hop options.
- ///
- /// -
- /// IPv6
- /// IPPROTO_IPV6
- /// IPV6_NEXTHOP
- /// Specifies next-hop address.
- ///
- /// -
- /// IPv6
- /// IPPROTO_IPV6
- /// IPV6_PKTINFO
- /// Specifies/receives packet information for an IPv6 socket. For more information, see the IPV6_PKTINFO socket option.
- ///
- /// -
- /// IPv6
- /// IPPROTO_IPV6
- /// IPV6_RTHDR
- /// Specifies/receives routing header.
- ///
- ///
- ///
- /// Control data is made up of one or more control data objects, each beginning with a WSACMSGHDR structure, defined as the following.
- ///
- ///
- /// Note The transport, not the application, fills out the header information in the WSACMSGHDR structure. The
- /// application simply sets the needed socket options and provides the adequate buffer size.
- ///
- /// The members of the WSACMSGHDR structure are as follows:
- ///
- ///
- /// Term
- /// Description
- ///
- /// -
- /// cmsg_len
- ///
- /// The number of bytes of data starting from the beginning of the WSACMSGHDR to the end of data (excluding padding bytes that may
- /// follow data).
- ///
- ///
- /// -
- /// cmsg_level
- /// The protocol that originated the control information.
- ///
- /// -
- /// cmsg_type
- /// The protocol-specific type of control information.
- ///
- ///
- /// The following macros are used to navigate the data objects:
- ///
- /// Returns a pointer to the first control data object. Returns a NULL pointer if there is no control data in the
- /// WSAMSG structure, such as when the Control member is a NULL pointer.
- ///
- ///
- /// Returns a pointer to the next control data object, or NULL if there are no more data objects. If the pcmsg parameter is
- /// NULL, a pointer to the first control data object is returned.
- ///
- ///
- /// Returns a pointer to the first byte of data (referred to as the cmsg_data member, though it is not defined in the structure).
- ///
- ///
- /// Returns the total size of a control data object, given the amount of data. Used to allocate the correct amount of buffer space.
- /// Includes alignment padding.
- ///
- /// Returns the value in cmsg_len given the amount of data. Includes alignment padding.
- ///
- // https://docs.microsoft.com/en-us/windows/win32/api/ws2def/ns-ws2def-wsamsg typedef struct _WSAMSG { LPSOCKADDR name; INT namelen;
- // LPWSABUF lpBuffers; #if ... ULONG dwBufferCount; #else DWORD dwBufferCount; #endif WSABUF Control; #if ... ULONG dwFlags; #else
- // DWORD dwFlags; #endif } WSAMSG, *PWSAMSG, *LPWSAMSG;
- [PInvokeData("ws2def.h", MSDNShortId = "105a6e2c-1edf-4ec0-a1c2-ac0bcafeda30")]
- [StructLayout(LayoutKind.Sequential)]
- public struct WSAMSG
- {
- ///
- /// Type: LPSOCKADDR
- ///
- /// A pointer to a SOCKET_ADDRESS structure that stores information about the remote address. Used only with unconnected sockets.
- ///
- ///
- public IntPtr name;
-
- ///
- /// Type: INT
- ///
- /// The length, in bytes, of the SOCKET_ADDRESS structure pointed to in the pAddr member. Used only with unconnected sockets.
- ///
- ///
- public int namelen;
-
- ///
- /// Type: LPWSABUF
- ///
- /// An array of WSABUF structures used to receive the message data. The capability of the lpBuffers member to contain
- /// multiple buffers enables the use of scatter/gather I/O.
- ///
- ///
- public IntPtr lpBuffers;
-
- ///
- /// Type: DWORD
- /// The number of buffers pointed to in the lpBuffers member.
- ///
- public uint dwBufferCount;
-
- ///
- /// Type: WSABUF
- /// A structure of WSABUF type used to specify optional control data. See Remarks.
- ///
- public WSABUF Control;
-
- ///
- /// Type: DWORD
- ///
- /// One or more control flags, specified as the logical OR of values. The possible values for dwFlags member on
- /// input are defined in the Winsock2.h header file. The possible values for dwFlags member on output are defined in the
- /// Ws2def.h header file which is automatically included by the Winsock2.h header file.
- ///
- ///
- ///
- /// Flags on input
- /// Meaning
- ///
- /// -
- /// MSG_PEEK
- ///
- /// Peek at the incoming data. The data is copied into the buffer, but is not removed from the input queue. This flag is valid
- /// only for non-overlapped sockets.
- ///
- ///
- ///
- ///
- ///
- /// Flag returned
- /// Meaning
- ///
- /// -
- /// MSG_BCAST
- /// The datagram was received as a link-layer broadcast or with a destination IP address that is a broadcast address.
- ///
- /// -
- /// MSG_MCAST
- /// The datagram was received with a destination IP address that is a multicast address.
- ///
- /// -
- /// MSG_TRUNC
- /// The datagram was truncated. More data was present than the process allocated room for.
- ///
- /// -
- /// MSG_CTRUNC
- /// The control (ancillary) data was truncated. More control data was present than the process allocated room for.
- ///
- ///
- ///
- public MsgFlags dwFlags;
- }
-
/// The WSANETWORKEVENTS structure is used to store a socket's internal information about network events.
// https://docs.microsoft.com/en-us/windows/win32/api/winsock2/ns-winsock2-wsanetworkevents typedef struct _WSANETWORKEVENTS { long
// lNetworkEvents; int iErrorCode[FD_MAX_EVENTS]; } WSANETWORKEVENTS, *LPWSANETWORKEVENTS;
diff --git a/PInvoke/Ws2_32/WinSock2.cs b/PInvoke/Ws2_32/WinSock2.cs
index 5f8648dd..0bfc0e43 100644
--- a/PInvoke/Ws2_32/WinSock2.cs
+++ b/PInvoke/Ws2_32/WinSock2.cs
@@ -1354,294 +1354,6 @@ namespace Vanara.PInvoke
public WSABUF ProviderSpecific;
}
- /// The SOCKADDR_IN structure specifies a transport address and port for the AF_INET address family.
- ///
- /// All of the data in the SOCKADDR_IN structure, except for the address family, must be specified in network-byte-order (big-endian).
- ///
- // https://docs.microsoft.com/en-us/windows/win32/api/ws2def/ns-ws2def-sockaddr_in typedef struct sockaddr_in { #if ... short
- // sin_family; #else ADDRESS_FAMILY sin_family; #endif USHORT sin_port; IN_ADDR sin_addr; CHAR sin_zero[8]; } SOCKADDR_IN, *PSOCKADDR_IN;
- [PInvokeData("ws2def.h", MSDNShortId = "96379562-403f-451c-ac7a-f0eec34bfe5e")]
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct SOCKADDR_IN
- {
- /// The address family for the transport address. This member should always be set to AF_INET.
- public ADDRESS_FAMILY sin_family;
-
- /// A transport protocol port number.
- public ushort sin_port;
-
- /// An IN_ADDR structure that contains an IPv4 transport address.
- public IN_ADDR sin_addr;
-
- /// Reserved for system use. A WSK application should set the contents of this array to zero.
- public ulong sin_zero;
-
- /// Initializes a new instance of the struct.
- /// An IN_ADDR structure that contains an IPv4 transport address.
- /// A transport protocol port number.
- public SOCKADDR_IN(IN_ADDR addr, ushort port = 0)
- {
- sin_family = ADDRESS_FAMILY.AF_INET;
- sin_port = port;
- sin_addr = addr;
- sin_zero = 0;
- }
-
- /// Performs an implicit conversion from to .
- /// The addr.
- /// The resulting instance from the conversion.
- public static implicit operator SOCKADDR_IN(IN_ADDR addr) => new SOCKADDR_IN(addr);
-
- /// Converts to string.
- /// A that represents this instance.
- public override string ToString() => $"{sin_addr}:{sin_port}";
- }
-
- /// The SOCKADDR_IN6 structure specifies a transport address and port for the AF_INET6 address family.
- ///
- ///
- /// All of the data in the SOCKADDR_IN6 structure, except for the address family, must be specified in network-byte-order (big-endian).
- ///
- ///
- /// The size of the SOCKADDR_IN6 structure is too large to fit in the memory space that is provided by a SOCKADDR structure. For a
- /// structure that is guaranteed to be large enough to contain a transport address for all possible address families, see SOCKADDR_STORAGEa>.
- ///
- ///
- // https://docs.microsoft.com/en-us/windows/win32/api/ws2ipdef/ns-ws2ipdef-sockaddr_in6_lh typedef struct sockaddr_in6 {
- // ADDRESS_FAMILY sin6_family; USHORT sin6_port; ULONG sin6_flowinfo; IN6_ADDR sin6_addr; union { ULONG sin6_scope_id; SCOPE_ID
- // sin6_scope_struct; }; } SOCKADDR_IN6_LH, *PSOCKADDR_IN6_LH, *LPSOCKADDR_IN6_LH;
- [PInvokeData("ws2ipdef.h", MSDNShortId = "ef2955d2-5dc1-420b-a9e0-32a584059d5a")]
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct SOCKADDR_IN6
- {
- /// The address family for the transport address. This member should always be set to AF_INET6.
- public ADDRESS_FAMILY sin6_family;
-
- /// A transport protocol port number.
- public ushort sin6_port;
-
- /// The IPv6 flow information.
- public uint sin6_flowinfo;
-
- /// An IN6_ADDR structure that contains an IPv6 transport address.
- public IN6_ADDR sin6_addr;
-
- /// A ULONG representation of the IPv6 scope identifier that is defined in the sin6_scope_struct member.
- public uint sin6_scope_id;
-
- /// Initializes a new instance of the struct.
- /// A byte array that contains an IPv6 transport address.
- ///
- /// A ULONG representation of the IPv6 scope identifier that is defined in the sin6_scope_struct member.
- ///
- /// A transport protocol port number.
- public SOCKADDR_IN6(byte[] addr, uint scope_id, ushort port = 0) : this(new IN6_ADDR(addr), scope_id, port)
- {
- }
-
- /// Initializes a new instance of the struct.
- /// An IN6_ADDR structure that contains an IPv6 transport address.
- ///
- /// A ULONG representation of the IPv6 scope identifier that is defined in the sin6_scope_struct member.
- ///
- /// A transport protocol port number.
- public SOCKADDR_IN6(IN6_ADDR addr, uint scope_id, ushort port = 0)
- {
- sin6_family = ADDRESS_FAMILY.AF_INET6;
- sin6_port = port;
- sin6_flowinfo = 0;
- sin6_addr = addr;
- sin6_scope_id = scope_id;
- }
-
- /// Performs an implicit conversion from to .
- /// The address.
- /// The resulting instance from the conversion.
- public static implicit operator SOCKADDR_IN6(IN6_ADDR addr) => new SOCKADDR_IN6(addr, 0);
-
- ///
- public override string ToString() => $"{sin6_addr}" + (sin6_scope_id == 0 ? "" : "%" + sin6_scope_id.ToString()) + $":{sin6_port}";
- }
-
- ///
- /// The SOCKADDR_IN6_PAIR structure contains pointers to a pair of IP addresses that represent a source and destination
- /// address pair.
- ///
- ///
- /// The SOCKADDR_IN6_PAIR structure is defined on Windows Vista and later.
- ///
- /// Any IPv4 addresses in the SOCKADDR_IN6_PAIR structure must be represented in the IPv4-mapped IPv6 address format which
- /// enables an IPv6 only application to communicate with an IPv4 node. For more information on the IPv4-mapped IPv6 address format,
- /// see Dual-Stack Sockets.
- ///
- /// The SOCKADDR_IN6_PAIR structure is used by the CreateSortedAddressPairs function.
- /// Note that the Ws2ipdef.h header file is automatically included in Ws2tcpip.h header file, and should never be used directly.
- ///
- // https://docs.microsoft.com/en-us/windows/desktop/api/ws2ipdef/ns-ws2ipdef-_sockaddr_in6_pair typedef struct _sockaddr_in6_pair {
- // PSOCKADDR_IN6 SourceAddress; PSOCKADDR_IN6 DestinationAddress; } SOCKADDR_IN6_PAIR, *PSOCKADDR_IN6_PAIR;
- [PInvokeData("ws2ipdef.h", MSDNShortId = "0265f8e0-8b35-4d9d-bf22-e98e9ff36a17")]
- [StructLayout(LayoutKind.Sequential)]
- public struct SOCKADDR_IN6_PAIR
- {
- /// The source address
- private IntPtr _SourceAddress;
-
- /// The destination address
- private IntPtr _DestinationAddress;
-
- ///
- /// A pointer to an IP source address represented as a SOCKADDR_IN6 structure. The address family is in host byte order and the
- /// IPv6 address, port, flow information, and zone ID are in network byte order.
- ///
- /// The source address.
- public SOCKADDR_IN6 SourceAddress => _SourceAddress.ToStructure();
-
- ///
- /// A pointer to an IP source address represented as a SOCKADDR_IN6 structure. The address family is in host byte order and the
- /// IPv6 address, port, flow information, and zone ID are in network byte order.
- ///
- /// The destination address.
- public SOCKADDR_IN6 DestinationAddress => _DestinationAddress.ToStructure();
-
- /// Performs an implicit conversion from to .
- /// The unmanaged value.
- /// The resulting instance from the conversion.
- public static implicit operator SOCKADDR_IN6_PAIR_NATIVE(SOCKADDR_IN6_PAIR unmgd) =>
- new SOCKADDR_IN6_PAIR_NATIVE { SourceAddress = unmgd.SourceAddress, DestinationAddress = unmgd.DestinationAddress };
-
- /// Converts to string.
- /// A that represents this instance.
- ///
- public override string ToString() => $"{SourceAddress} : {DestinationAddress}";
- }
-
- ///
- /// The SOCKADDR_IN6_PAIR structure contains pointers to a pair of IP addresses that represent a source and destination
- /// address pair.
- ///
- ///
- /// The SOCKADDR_IN6_PAIR structure is defined on Windows Vista and later.
- ///
- /// Any IPv4 addresses in the SOCKADDR_IN6_PAIR structure must be represented in the IPv4-mapped IPv6 address format which
- /// enables an IPv6 only application to communicate with an IPv4 node. For more information on the IPv4-mapped IPv6 address format,
- /// see Dual-Stack Sockets.
- ///
- /// The SOCKADDR_IN6_PAIR structure is used by the CreateSortedAddressPairs function.
- /// Note that the Ws2ipdef.h header file is automatically included in Ws2tcpip.h header file, and should never be used directly.
- ///
- // https://docs.microsoft.com/en-us/windows/desktop/api/ws2ipdef/ns-ws2ipdef-_sockaddr_in6_pair typedef struct _sockaddr_in6_pair {
- // PSOCKADDR_IN6 SourceAddress; PSOCKADDR_IN6 DestinationAddress; } SOCKADDR_IN6_PAIR, *PSOCKADDR_IN6_PAIR;
- [PInvokeData("ws2ipdef.h", MSDNShortId = "0265f8e0-8b35-4d9d-bf22-e98e9ff36a17")]
- [StructLayout(LayoutKind.Sequential)]
- public struct SOCKADDR_IN6_PAIR_NATIVE
- {
- ///
- /// A pointer to an IP source address represented as a SOCKADDR_IN6 structure. The address family is in host byte order and the
- /// IPv6 address, port, flow information, and zone ID are in network byte order.
- ///
- public SOCKADDR_IN6 SourceAddress;
-
- ///
- /// A pointer to an IP source address represented as a SOCKADDR_IN6 structure. The address family is in host byte order and the
- /// IPv6 address, port, flow information, and zone ID are in network byte order.
- ///
- public SOCKADDR_IN6 DestinationAddress;
-
- /// Converts to string.
- /// A that represents this instance.
- ///
- public override string ToString() => $"{SourceAddress} : {DestinationAddress}";
- }
-
- /// The SOCKADDR_INET union contains an IPv4, an IPv6 address, or an address family.
- ///
- /// The SOCKADDR_INET union is defined on Windows Vista and later.
- ///
- /// The SOCKADDR_INET union is a convenience structure for accessing an IPv4 address, an IPv6 address, or the IP address
- /// family without having to cast the sockaddr structure.
- ///
- /// The SOCKADDR_INET union is the data type of the Prefix member in the IP_ADDRESS_PREFIX structure
- /// Note that the Ws2ipdef.h header file is automatically included in Ws2tcpip.h header file, and should never be used directly.
- ///
- // https://docs.microsoft.com/en-us/windows/win32/api/ws2ipdef/ns-ws2ipdef-sockaddr_inet typedef union _SOCKADDR_INET { SOCKADDR_IN
- // Ipv4; SOCKADDR_IN6 Ipv6; ADDRESS_FAMILY si_family; } SOCKADDR_INET, *PSOCKADDR_INET;
- [PInvokeData("ws2ipdef.h", MSDNShortId = "7278dcb4-65c6-4aea-a474-cb7fae4d7672")]
- [StructLayout(LayoutKind.Explicit)]
- public struct SOCKADDR_INET : IEquatable, IEquatable, IEquatable
- {
- ///
- /// An IPv4 address represented as a SOCKADDR_IN structure containing the address family and the IPv4 address. The address
- /// family is in host byte order and the IPv4 address is in network byte order.
- ///
- /// On the Windows SDK released for Windows Vista and later, the organization of header files has changed and the SOCKADDR_IN
- /// structure is defined in the Ws2def.h header file. Note that the Ws2def.h header file is automatically included in
- /// Winsock2.h, and should never be used directly.
- ///
- ///
- [FieldOffset(0)]
- public SOCKADDR_IN Ipv4;
-
- ///
- /// An IPv6 address represented as a SOCKADDR_IN6 structure containing the address family and the IPv6 address. The address
- /// family is in host byte order and the IPv6 address is in network byte order.
- ///
- /// On the Windows SDK released for Windows Vista and later, the organization of header files has changed and the SOCKADDR_IN6
- /// structure is defined in the Ws2def.h header file. Note that the Ws2def.h header file is automatically included in
- /// Winsock2.h, and should never be used directly.
- ///
- ///
- [FieldOffset(0)]
- public SOCKADDR_IN6 Ipv6;
-
- ///
- /// The address family.
- ///
- /// Possible values for the address family are listed in the Ws2def.h header file. Note that the values for the AF_ address
- /// family and PF_ protocol family constants are identical (for example, AF_INET and PF_INET), so either constant can be
- /// used.The Ws2def.h header file is automatically included in Winsock2.h, and should never be used directly.
- ///
- ///
- [FieldOffset(0)]
- public ADDRESS_FAMILY si_family;
-
- /// Specifies whether this instance is equal to the specified object.
- /// The object to test for equality.
- /// if is equal to this instance.
- public bool Equals(SOCKADDR_INET other) => (si_family == ADDRESS_FAMILY.AF_INET && Ipv4.Equals(other.Ipv4)) || (si_family == ADDRESS_FAMILY.AF_INET6 && Ipv6.Equals(other.Ipv6));
-
- /// Specifies whether this instance is equal to the specified object.
- /// The object to test for equality.
- /// if is equal to this instance.
- public bool Equals(SOCKADDR_IN other) => si_family == ADDRESS_FAMILY.AF_INET && Ipv4.Equals(other);
-
- /// Specifies whether this instance is equal to the specified object.
- /// The object to test for equality.
- /// if is equal to this instance.
- public bool Equals(SOCKADDR_IN6 other) => si_family == ADDRESS_FAMILY.AF_INET6 && Ipv6.Equals(other);
-
- /// Performs an implicit conversion from to .
- /// The address.
- /// The resulting instance from the conversion.
- public static implicit operator SOCKADDR_INET(SOCKADDR_IN address) => new SOCKADDR_INET { Ipv4 = address };
-
- /// Performs an implicit conversion from to .
- /// The address.
- /// The resulting instance from the conversion.
- public static implicit operator SOCKADDR_INET(SOCKADDR_IN6 address) => new SOCKADDR_INET { Ipv6 = address };
-
- /// Converts to string.
- /// A that represents this instance.
- public override string ToString()
- {
- var sb = new System.Text.StringBuilder($"{si_family}");
- if (si_family == ADDRESS_FAMILY.AF_INET)
- sb.Append(":").Append(Ipv4);
- else if (si_family == ADDRESS_FAMILY.AF_INET6)
- sb.Append(":").Append(Ipv6);
- return sb.ToString();
- }
- }
-
/// Provides a handle to a socket.
///
[PInvokeData("winsock2.h")]
@@ -1711,41 +1423,6 @@ namespace Vanara.PInvoke
public override string ToString() => handle.ToString();
}
- /// The SOCKET_ADDRESS structure stores protocol-specific address information.
- ///
- ///
- /// The SOCKADDR structure pointed to by the lpSockaddr member varies depending on the protocol or address family selected.
- /// For example, the sockaddr_in6 structure is used for an IPv6 socket address while the sockaddr_in4 structure is
- /// used for an IPv4 socket address. The address family is the first member of all of the SOCKADDR structures. The address
- /// family is used to determine which structure is used.
- ///
- ///
- /// On the Microsoft Windows Software Development Kit (SDK) released for Windows Vista and later, the organization of header files
- /// has changed and the SOCKET_ADDRESS structure is defined in the Ws2def.h header file. Note that the Ws2def.h header file
- /// is automatically included in Winsock2.h, and should never be used directly.
- ///
- ///
- // https://docs.microsoft.com/en-us/windows/win32/api/ws2def/ns-ws2def-socket_address typedef struct _SOCKET_ADDRESS { LPSOCKADDR
- // lpSockaddr; INT iSockaddrLength; } SOCKET_ADDRESS, *PSOCKET_ADDRESS, *LPSOCKET_ADDRESS;
- [PInvokeData("ws2def.h", MSDNShortId = "37fbcb96-a859-4eca-8928-8051f95407b9")]
- [StructLayout(LayoutKind.Sequential)]
- public struct SOCKET_ADDRESS
- {
- /// A pointer to a socket address represented as a SOCKADDR structure.
- public IntPtr lpSockAddr;
-
- /// The length, in bytes, of the socket address.
- public int iSockaddrLength;
-
- /// Gets the from this instance.
- /// The value pointed to by this instance.
- public SOCKADDR_INET GetSOCKADDR() => lpSockAddr.ToStructure();
-
- /// Converts to string.
- /// A that represents this instance.
- public override string ToString() => GetSOCKADDR().ToString();
- }
-
///
/// The timeval structure is used to specify a time interval. It is associated with the Berkeley Software Distribution (BSD)
/// Time.h header file.
@@ -1785,20 +1462,6 @@ namespace Vanara.PInvoke
}
}
- /// The WSABUF structure enables the creation or manipulation of a data buffer used by some Winsock functions.
- // https://docs.microsoft.com/en-us/windows/desktop/api/ws2def/ns-ws2def-_wsabuf typedef struct _WSABUF { ULONG len; CHAR *buf; }
- // WSABUF, *LPWSABUF;
- [PInvokeData("ws2def.h", MSDNShortId = "a012c3ba-67fd-4fcf-84d1-85e9d495c29c")]
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
- public struct WSABUF
- {
- /// The length of the buffer, in bytes.
- public uint len;
-
- /// A pointer to the buffer.
- public IntPtr buf;
- }
-
/// The WSADATA structure contains information about the Windows Sockets implementation.
///
///
diff --git a/PInvoke/Ws2_32/ws2ipdef.cs b/PInvoke/Ws2_32/ws2ipdef.cs
index db19655f..6c3db4f2 100644
--- a/PInvoke/Ws2_32/ws2ipdef.cs
+++ b/PInvoke/Ws2_32/ws2ipdef.cs
@@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
+using Vanara.Extensions;
using Vanara.InteropServices;
namespace Vanara.PInvoke
@@ -284,5 +285,250 @@ namespace Vanara.PInvoke
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
public IN_ADDR[] imsf_slist;
}
+
+ /// The SOCKADDR_IN6 structure specifies a transport address and port for the AF_INET6 address family.
+ ///
+ ///
+ /// All of the data in the SOCKADDR_IN6 structure, except for the address family, must be specified in network-byte-order (big-endian).
+ ///
+ ///
+ /// The size of the SOCKADDR_IN6 structure is too large to fit in the memory space that is provided by a SOCKADDR structure. For a
+ /// structure that is guaranteed to be large enough to contain a transport address for all possible address families, see SOCKADDR_STORAGEa>.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/ws2ipdef/ns-ws2ipdef-sockaddr_in6_lh typedef struct sockaddr_in6 {
+ // ADDRESS_FAMILY sin6_family; USHORT sin6_port; ULONG sin6_flowinfo; IN6_ADDR sin6_addr; union { ULONG sin6_scope_id; SCOPE_ID
+ // sin6_scope_struct; }; } SOCKADDR_IN6_LH, *PSOCKADDR_IN6_LH, *LPSOCKADDR_IN6_LH;
+ [PInvokeData("ws2ipdef.h", MSDNShortId = "ef2955d2-5dc1-420b-a9e0-32a584059d5a")]
+ [StructLayout(LayoutKind.Sequential, Pack = 2)]
+ public struct SOCKADDR_IN6
+ {
+ /// The address family for the transport address. This member should always be set to AF_INET6.
+ public ADDRESS_FAMILY sin6_family;
+
+ /// A transport protocol port number.
+ public ushort sin6_port;
+
+ /// The IPv6 flow information.
+ public uint sin6_flowinfo;
+
+ /// An IN6_ADDR structure that contains an IPv6 transport address.
+ public IN6_ADDR sin6_addr;
+
+ /// A ULONG representation of the IPv6 scope identifier that is defined in the sin6_scope_struct member.
+ public uint sin6_scope_id;
+
+ /// Initializes a new instance of the struct.
+ /// A byte array that contains an IPv6 transport address.
+ ///
+ /// A ULONG representation of the IPv6 scope identifier that is defined in the sin6_scope_struct member.
+ ///
+ /// A transport protocol port number.
+ public SOCKADDR_IN6(byte[] addr, uint scope_id, ushort port = 0) : this(new IN6_ADDR(addr), scope_id, port)
+ {
+ }
+
+ /// Initializes a new instance of the struct.
+ /// An IN6_ADDR structure that contains an IPv6 transport address.
+ ///
+ /// A ULONG representation of the IPv6 scope identifier that is defined in the sin6_scope_struct member.
+ ///
+ /// A transport protocol port number.
+ public SOCKADDR_IN6(IN6_ADDR addr, uint scope_id, ushort port = 0)
+ {
+ sin6_family = ADDRESS_FAMILY.AF_INET6;
+ sin6_port = port;
+ sin6_flowinfo = 0;
+ sin6_addr = addr;
+ sin6_scope_id = scope_id;
+ }
+
+ /// Performs an implicit conversion from to .
+ /// The address.
+ /// The resulting instance from the conversion.
+ public static implicit operator SOCKADDR_IN6(IN6_ADDR addr) => new SOCKADDR_IN6(addr, 0);
+
+ ///
+ public override string ToString() => $"{sin6_addr}" + (sin6_scope_id == 0 ? "" : "%" + sin6_scope_id.ToString()) + $":{sin6_port}";
+ }
+
+ ///
+ /// The SOCKADDR_IN6_PAIR structure contains pointers to a pair of IP addresses that represent a source and destination
+ /// address pair.
+ ///
+ ///
+ /// The SOCKADDR_IN6_PAIR structure is defined on Windows Vista and later.
+ ///
+ /// Any IPv4 addresses in the SOCKADDR_IN6_PAIR structure must be represented in the IPv4-mapped IPv6 address format which
+ /// enables an IPv6 only application to communicate with an IPv4 node. For more information on the IPv4-mapped IPv6 address format,
+ /// see Dual-Stack Sockets.
+ ///
+ /// The SOCKADDR_IN6_PAIR structure is used by the CreateSortedAddressPairs function.
+ /// Note that the Ws2ipdef.h header file is automatically included in Ws2tcpip.h header file, and should never be used directly.
+ ///
+ // https://docs.microsoft.com/en-us/windows/desktop/api/ws2ipdef/ns-ws2ipdef-_sockaddr_in6_pair typedef struct _sockaddr_in6_pair {
+ // PSOCKADDR_IN6 SourceAddress; PSOCKADDR_IN6 DestinationAddress; } SOCKADDR_IN6_PAIR, *PSOCKADDR_IN6_PAIR;
+ [PInvokeData("ws2ipdef.h", MSDNShortId = "0265f8e0-8b35-4d9d-bf22-e98e9ff36a17")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct SOCKADDR_IN6_PAIR
+ {
+ /// The source address
+ private IntPtr _SourceAddress;
+
+ /// The destination address
+ private IntPtr _DestinationAddress;
+
+ ///
+ /// A pointer to an IP source address represented as a SOCKADDR_IN6 structure. The address family is in host byte order and the
+ /// IPv6 address, port, flow information, and zone ID are in network byte order.
+ ///
+ /// The source address.
+ public SOCKADDR_IN6 SourceAddress => _SourceAddress.ToStructure();
+
+ ///
+ /// A pointer to an IP source address represented as a SOCKADDR_IN6 structure. The address family is in host byte order and the
+ /// IPv6 address, port, flow information, and zone ID are in network byte order.
+ ///
+ /// The destination address.
+ public SOCKADDR_IN6 DestinationAddress => _DestinationAddress.ToStructure();
+
+ /// Performs an implicit conversion from to .
+ /// The unmanaged value.
+ /// The resulting instance from the conversion.
+ public static implicit operator SOCKADDR_IN6_PAIR_NATIVE(SOCKADDR_IN6_PAIR unmgd) =>
+ new SOCKADDR_IN6_PAIR_NATIVE { SourceAddress = unmgd.SourceAddress, DestinationAddress = unmgd.DestinationAddress };
+
+ /// Converts to string.
+ /// A that represents this instance.
+ ///
+ public override string ToString() => $"{SourceAddress} : {DestinationAddress}";
+ }
+
+ ///
+ /// The SOCKADDR_IN6_PAIR structure contains pointers to a pair of IP addresses that represent a source and destination
+ /// address pair.
+ ///
+ ///
+ /// The SOCKADDR_IN6_PAIR structure is defined on Windows Vista and later.
+ ///
+ /// Any IPv4 addresses in the SOCKADDR_IN6_PAIR structure must be represented in the IPv4-mapped IPv6 address format which
+ /// enables an IPv6 only application to communicate with an IPv4 node. For more information on the IPv4-mapped IPv6 address format,
+ /// see Dual-Stack Sockets.
+ ///
+ /// The SOCKADDR_IN6_PAIR structure is used by the CreateSortedAddressPairs function.
+ /// Note that the Ws2ipdef.h header file is automatically included in Ws2tcpip.h header file, and should never be used directly.
+ ///
+ // https://docs.microsoft.com/en-us/windows/desktop/api/ws2ipdef/ns-ws2ipdef-_sockaddr_in6_pair typedef struct _sockaddr_in6_pair {
+ // PSOCKADDR_IN6 SourceAddress; PSOCKADDR_IN6 DestinationAddress; } SOCKADDR_IN6_PAIR, *PSOCKADDR_IN6_PAIR;
+ [PInvokeData("ws2ipdef.h", MSDNShortId = "0265f8e0-8b35-4d9d-bf22-e98e9ff36a17")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct SOCKADDR_IN6_PAIR_NATIVE
+ {
+ ///
+ /// A pointer to an IP source address represented as a SOCKADDR_IN6 structure. The address family is in host byte order and the
+ /// IPv6 address, port, flow information, and zone ID are in network byte order.
+ ///
+ public SOCKADDR_IN6 SourceAddress;
+
+ ///
+ /// A pointer to an IP source address represented as a SOCKADDR_IN6 structure. The address family is in host byte order and the
+ /// IPv6 address, port, flow information, and zone ID are in network byte order.
+ ///
+ public SOCKADDR_IN6 DestinationAddress;
+
+ /// Converts to string.
+ /// A that represents this instance.
+ ///
+ public override string ToString() => $"{SourceAddress} : {DestinationAddress}";
+ }
+
+ /// The SOCKADDR_INET union contains an IPv4, an IPv6 address, or an address family.
+ ///
+ /// The SOCKADDR_INET union is defined on Windows Vista and later.
+ ///
+ /// The SOCKADDR_INET union is a convenience structure for accessing an IPv4 address, an IPv6 address, or the IP address
+ /// family without having to cast the sockaddr structure.
+ ///
+ /// The SOCKADDR_INET union is the data type of the Prefix member in the IP_ADDRESS_PREFIX structure
+ /// Note that the Ws2ipdef.h header file is automatically included in Ws2tcpip.h header file, and should never be used directly.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/ws2ipdef/ns-ws2ipdef-sockaddr_inet typedef union _SOCKADDR_INET { SOCKADDR_IN
+ // Ipv4; SOCKADDR_IN6 Ipv6; ADDRESS_FAMILY si_family; } SOCKADDR_INET, *PSOCKADDR_INET;
+ [PInvokeData("ws2ipdef.h", MSDNShortId = "7278dcb4-65c6-4aea-a474-cb7fae4d7672")]
+ [StructLayout(LayoutKind.Explicit)]
+ public struct SOCKADDR_INET : IEquatable, IEquatable, IEquatable
+ {
+ ///
+ /// An IPv4 address represented as a SOCKADDR_IN structure containing the address family and the IPv4 address. The address
+ /// family is in host byte order and the IPv4 address is in network byte order.
+ ///
+ /// On the Windows SDK released for Windows Vista and later, the organization of header files has changed and the SOCKADDR_IN
+ /// structure is defined in the Ws2def.h header file. Note that the Ws2def.h header file is automatically included in
+ /// Winsock2.h, and should never be used directly.
+ ///
+ ///
+ [FieldOffset(0)]
+ public SOCKADDR_IN Ipv4;
+
+ ///
+ /// An IPv6 address represented as a SOCKADDR_IN6 structure containing the address family and the IPv6 address. The address
+ /// family is in host byte order and the IPv6 address is in network byte order.
+ ///
+ /// On the Windows SDK released for Windows Vista and later, the organization of header files has changed and the SOCKADDR_IN6
+ /// structure is defined in the Ws2def.h header file. Note that the Ws2def.h header file is automatically included in
+ /// Winsock2.h, and should never be used directly.
+ ///
+ ///
+ [FieldOffset(0)]
+ public SOCKADDR_IN6 Ipv6;
+
+ ///
+ /// The address family.
+ ///
+ /// Possible values for the address family are listed in the Ws2def.h header file. Note that the values for the AF_ address
+ /// family and PF_ protocol family constants are identical (for example, AF_INET and PF_INET), so either constant can be
+ /// used.The Ws2def.h header file is automatically included in Winsock2.h, and should never be used directly.
+ ///
+ ///
+ [FieldOffset(0)]
+ public ADDRESS_FAMILY si_family;
+
+ /// Specifies whether this instance is equal to the specified object.
+ /// The object to test for equality.
+ /// if is equal to this instance.
+ public bool Equals(SOCKADDR_INET other) => (si_family == ADDRESS_FAMILY.AF_INET && Ipv4.Equals(other.Ipv4)) || (si_family == ADDRESS_FAMILY.AF_INET6 && Ipv6.Equals(other.Ipv6));
+
+ /// Specifies whether this instance is equal to the specified object.
+ /// The object to test for equality.
+ /// if is equal to this instance.
+ public bool Equals(SOCKADDR_IN other) => si_family == ADDRESS_FAMILY.AF_INET && Ipv4.Equals(other);
+
+ /// Specifies whether this instance is equal to the specified object.
+ /// The object to test for equality.
+ /// if is equal to this instance.
+ public bool Equals(SOCKADDR_IN6 other) => si_family == ADDRESS_FAMILY.AF_INET6 && Ipv6.Equals(other);
+
+ /// Performs an implicit conversion from to .
+ /// The address.
+ /// The resulting instance from the conversion.
+ public static implicit operator SOCKADDR_INET(SOCKADDR_IN address) => new SOCKADDR_INET { Ipv4 = address };
+
+ /// Performs an implicit conversion from to .
+ /// The address.
+ /// The resulting instance from the conversion.
+ public static implicit operator SOCKADDR_INET(SOCKADDR_IN6 address) => new SOCKADDR_INET { Ipv6 = address };
+
+ /// Converts to string.
+ /// A that represents this instance.
+ public override string ToString()
+ {
+ var sb = new System.Text.StringBuilder($"{si_family}");
+ if (si_family == ADDRESS_FAMILY.AF_INET)
+ sb.Append(":").Append(Ipv4);
+ else if (si_family == ADDRESS_FAMILY.AF_INET6)
+ sb.Append(":").Append(Ipv6);
+ return sb.ToString();
+ }
+ }
}
}
\ No newline at end of file