Exemplo n.º 1
0
        private unsafe void InitIPPacketInformation()
        {
            IPAddress address = null;

            if (this.m_ControlBuffer.Length == s_ControlDataSize)
            {
                UnsafeNclNativeMethods.OSSOCK.ControlData data = (UnsafeNclNativeMethods.OSSOCK.ControlData)Marshal.PtrToStructure(this.m_Message.controlBuffer.Pointer, typeof(UnsafeNclNativeMethods.OSSOCK.ControlData));
                if (data.length != UIntPtr.Zero)
                {
                    address = new IPAddress((long)data.address);
                }
                this.m_IPPacketInformation = new IPPacketInformation((address != null) ? address : IPAddress.None, (int)data.index);
            }
            else if (this.m_ControlBuffer.Length == s_ControlDataIPv6Size)
            {
                UnsafeNclNativeMethods.OSSOCK.ControlDataIPv6 pv = (UnsafeNclNativeMethods.OSSOCK.ControlDataIPv6)Marshal.PtrToStructure(this.m_Message.controlBuffer.Pointer, typeof(UnsafeNclNativeMethods.OSSOCK.ControlDataIPv6));
                if (pv.length != UIntPtr.Zero)
                {
                    address = new IPAddress(pv.address);
                }
                this.m_IPPacketInformation = new IPPacketInformation((address != null) ? address : IPAddress.IPv6None, (int)pv.index);
            }
            else
            {
                this.m_IPPacketInformation = new IPPacketInformation();
            }
        }
        unsafe private void InitIPPacketInformation()
        {
            IPAddress address = null;

            //ipv4
            if (m_ControlBuffer.Length == s_ControlDataSize)
            {
                UnsafeNclNativeMethods.OSSOCK.ControlData controlData = (UnsafeNclNativeMethods.OSSOCK.ControlData)Marshal.PtrToStructure(m_Message->controlBuffer.Pointer, typeof(UnsafeNclNativeMethods.OSSOCK.ControlData));
                if (controlData.length != UIntPtr.Zero)
                {
                    address = new IPAddress((long)controlData.address);
                }
                m_IPPacketInformation = new IPPacketInformation(((address != null)?address:IPAddress.None), (int)controlData.index);
            }
            //ipv6
            else if (m_ControlBuffer.Length == s_ControlDataIPv6Size)
            {
                UnsafeNclNativeMethods.OSSOCK.ControlDataIPv6 controlData = (UnsafeNclNativeMethods.OSSOCK.ControlDataIPv6)Marshal.PtrToStructure(m_Message->controlBuffer.Pointer, typeof(UnsafeNclNativeMethods.OSSOCK.ControlDataIPv6));
                if (controlData.length != UIntPtr.Zero)
                {
                    address = new IPAddress(controlData.address);
                }
                m_IPPacketInformation = new IPPacketInformation(((address != null)?address:IPAddress.IPv6None), (int)controlData.index);
            }
            //other
            else
            {
                m_IPPacketInformation = new IPPacketInformation();
            }
        }