GetIPPacketInformation() private static method

private static GetIPPacketInformation ( System.Net.Interop messageHeader, bool isIPv4, bool isIPv6 ) : IPPacketInformation
messageHeader System.Net.Interop
isIPv4 bool
isIPv6 bool
return IPPacketInformation
コード例 #1
0
 private unsafe void InitIPPacketInformation()
 {
     if (_controlBuffer.Length == s_controlDataSize)
     {
         // IPv4
         _ipPacketInformation = SocketPal.GetIPPacketInformation((Interop.Winsock.ControlData *)_message->controlBuffer.Pointer);
     }
     else if (_controlBuffer.Length == s_controlDataIPv6Size)
     {
         // IPv6
         _ipPacketInformation = SocketPal.GetIPPacketInformation((Interop.Winsock.ControlDataIPv6 *)_message->controlBuffer.Pointer);
     }
     else
     {
         // Other
         _ipPacketInformation = new IPPacketInformation();
     }
 }
コード例 #2
0
        private unsafe void InitIPPacketInformation()
        {
            int?controlBufferLength = _controlBuffer?.Length;

            if (controlBufferLength == sizeof(Interop.Winsock.ControlData))
            {
                // IPv4
                _ipPacketInformation = SocketPal.GetIPPacketInformation((Interop.Winsock.ControlData *)_message->controlBuffer.Pointer);
            }
            else if (controlBufferLength == sizeof(Interop.Winsock.ControlDataIPv6))
            {
                // IPv6
                _ipPacketInformation = SocketPal.GetIPPacketInformation((Interop.Winsock.ControlDataIPv6 *)_message->controlBuffer.Pointer);
            }
            else
            {
                // Other
                _ipPacketInformation = default;
            }
        }