public static unsafe IPPacketInformation GetIPPacketInformation(Interop.Winsock.ControlDataIPv6 *controlBuffer) { IPAddress address = controlBuffer->length != UIntPtr.Zero ? new IPAddress(new Span <byte>(controlBuffer->address, Interop.Winsock.IPv6AddressLength)) : IPAddress.IPv6None; return(new IPPacketInformation(address, (int)controlBuffer->index)); }
public static unsafe IPPacketInformation GetIPPacketInformation(Interop.Winsock.ControlDataIPv6 *controlBuffer) { IPAddress address = IPAddress.IPv6None; if (controlBuffer->length != UIntPtr.Zero) { var addressArray = new byte[Interop.Winsock.IPv6AddressLength]; Marshal.Copy((IntPtr)(controlBuffer->address), addressArray, 0, Interop.Winsock.IPv6AddressLength); address = new IPAddress(addressArray); } return(new IPPacketInformation(address, (int)controlBuffer->index)); }
public static unsafe IPPacketInformation GetIPPacketInformation(Interop.Winsock.ControlDataIPv6 *controlBuffer) { if (controlBuffer->length == (UIntPtr)sizeof(Interop.Winsock.ControlData)) { // IPv4 client connectiong to dual mode socket. return(GetIPPacketInformation((Interop.Winsock.ControlData *)controlBuffer)); } IPAddress address = controlBuffer->length != UIntPtr.Zero ? new IPAddress(new ReadOnlySpan <byte>(controlBuffer->address, Interop.Winsock.IPv6AddressLength)) : IPAddress.IPv6None; return(new IPPacketInformation(address, (int)controlBuffer->index)); }