public override EndPoint Create(SocketAddress socketAddress)
 {
     if (socketAddress.Family != this.AddressFamily)
     {
         throw new ArgumentException(SR.GetString("net_InvalidAddressFamily", new object[] { socketAddress.Family.ToString(), base.GetType().FullName, this.AddressFamily.ToString() }), "socketAddress");
     }
     if (socketAddress.Size < 8)
     {
         throw new ArgumentException(SR.GetString("net_InvalidSocketAddressSize", new object[] { socketAddress.GetType().FullName, base.GetType().FullName }), "socketAddress");
     }
     if (this.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6)
     {
         byte[] address = new byte[0x10];
         for (int i = 0; i < address.Length; i++)
         {
             address[i] = socketAddress[i + 8];
         }
         int num2 = ((socketAddress[2] << 8) & 0xff00) | socketAddress[3];
         long scopeid = (((socketAddress[0x1b] << 0x18) + (socketAddress[0x1a] << 0x10)) + (socketAddress[0x19] << 8)) + socketAddress[0x18];
         return new IPEndPoint(new IPAddress(address, scopeid), num2);
     }
     int port = ((socketAddress[2] << 8) & 0xff00) | socketAddress[3];
     return new IPEndPoint(((((socketAddress[4] & 0xff) | ((socketAddress[5] << 8) & 0xff00)) | ((socketAddress[6] << 0x10) & 0xff0000)) | (socketAddress[7] << 0x18)) & ((long) 0xffffffffL), port);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates an endpoint from a socket address.
 /// </summary>
 ///
 /// <returns>
 /// An <see cref="T:System.Net.EndPoint"/> instance using the specified socket address.
 /// </returns>
 /// <param name="socketAddress">The <see cref="T:System.Net.SocketAddress"/> to use for the endpoint. </param><exception cref="T:System.ArgumentException">The AddressFamily of <paramref name="socketAddress"/> is not equal to the AddressFamily of the current instance.-or- <paramref name="socketAddress"/>.Size &lt; 8. </exception><PermissionSet><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence"/></PermissionSet>
 public override EndPoint Create(SocketAddress socketAddress)
 {
     if (socketAddress.Family != this.AddressFamily)
     {
         throw new ArgumentException(SR.GetString("net_InvalidAddressFamily", (object)((object)socketAddress.Family).ToString(), (object)this.GetType().FullName, (object)((object)this.AddressFamily).ToString()), "socketAddress");
     }
     else
     {
         if (socketAddress.Size >= 8)
         {
             return((EndPoint)socketAddress.GetIPEndPoint());
         }
         throw new ArgumentException(SR.GetString("net_InvalidSocketAddressSize", (object)socketAddress.GetType().FullName, (object)this.GetType().FullName), "socketAddress");
     }
 }
Ejemplo n.º 3
0
        /// <include file='doc\IPEndPoint.uex' path='docs/doc[@for="IPEndPoint.Create"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public override EndPoint Create(SocketAddress socketAddress)
        {
            //
            // validate SocketAddress
            //
            if (socketAddress.Family != this.AddressFamily)
            {
                throw new ArgumentException(SR.GetString(SR.net_InvalidAddressFamily, socketAddress.Family.ToString(), this.GetType().FullName, this.AddressFamily.ToString()));
            }
            if (socketAddress.Size < 8)
            {
                throw new ArgumentException(SR.GetString(SR.net_InvalidSocketAddressSize, socketAddress.GetType().FullName, this.GetType().FullName));
            }
            //
            // strip out of SocketAddress information on the EndPoint
            //
            int port =
                ((int)socketAddress[2] << 8) |
                ((int)socketAddress[3]);

            long address = (long)(
                ((int)socketAddress[4]) |
                ((int)socketAddress[5] << 8) |
                ((int)socketAddress[6] << 16) |
                ((int)socketAddress[7] << 24)
                ) & 0x00000000FFFFFFFF;

            IPEndPoint created = new IPEndPoint(address, port);

            GlobalLog.Print("IPEndPoint::Create: " + this.ToString() + " -> " + created.ToString());

            //
            // return it
            //
            return(created);
        }
Ejemplo n.º 4
0
        public override EndPoint Create(SocketAddress socketAddress)
        {
            // Validate SocketAddress
            if (socketAddress.Family != this.AddressFamily)
            {
                throw new ArgumentException(SR.Format(SR.net_InvalidAddressFamily, socketAddress.Family.ToString(), this.GetType().FullName, this.AddressFamily.ToString()), nameof(socketAddress));
            }
            if (socketAddress.Size < 8)
            {
                throw new ArgumentException(SR.Format(SR.net_InvalidSocketAddressSize, socketAddress.GetType().FullName, this.GetType().FullName), nameof(socketAddress));
            }

            return(socketAddress.GetIPEndPoint());
        }
Ejemplo n.º 5
0
        public override EndPoint Create(SocketAddress socketAddress)
        {
            // Validate SocketAddress
            if (socketAddress.Family != this.AddressFamily)
            {
                throw new ArgumentException(SR.Format(SR.net_InvalidAddressFamily, socketAddress.Family.ToString(), this.GetType().FullName, this.AddressFamily.ToString()), "socketAddress");
            }
            if (socketAddress.Size < 8)
            {
                throw new ArgumentException(SR.Format(SR.net_InvalidSocketAddressSize, socketAddress.GetType().FullName, this.GetType().FullName), "socketAddress");
            }

            return socketAddress.GetIPEndPoint();
        }
Ejemplo n.º 6
0
        /// <include file='doc\IPEndPoint.uex' path='docs/doc[@for="IPEndPoint.Create"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public override EndPoint Create(SocketAddress socketAddress)
        {
            //
            // validate SocketAddress
            //
            if (socketAddress.Family != this.AddressFamily)
            {
                throw new ArgumentException(SR.GetString(SR.net_InvalidAddressFamily, socketAddress.Family.ToString(), this.GetType().FullName, this.AddressFamily.ToString()));
            }
            if (socketAddress.Size < 8)
            {
                throw new ArgumentException(SR.GetString(SR.net_InvalidSocketAddressSize, socketAddress.GetType().FullName, this.GetType().FullName));
            }

            if (this.AddressFamily == AddressFamily.InterNetworkV6)
            {
                //
                // IPv6 Changes: Extract the IPv6 Address information from the socket address
                //
                byte[] addr = new byte[16];
                for (int i = 0; i < 16; i++)
                {
                    addr[i] = socketAddress[i + 8];
                }
                //
                // Port
                //
                int port = (int)((socketAddress[2] << 8 & 0xFF00) | (socketAddress[3]));
                //
                // Scope
                //
                long scope = (long)((socketAddress[27] << 24) +
                                    (socketAddress[26] << 16) +
                                    (socketAddress[25] << 8) +
                                    (socketAddress[24]));

                IPEndPoint created = new IPEndPoint(new IPAddress(addr, scope), port);

                GlobalLog.Print("IPEndPoint::Create IPv6: " + this.ToString() + " -> " + created.ToString());

                return(created);
            }
            else
            {
                //
                // strip out of SocketAddress information on the EndPoint
                //
                int port = (int)(
                    (socketAddress[2] << 8 & 0xFF00) |
                    (socketAddress[3])
                    );

                long address = (long)(
                    (socketAddress[4] & 0x000000FF) |
                    (socketAddress[5] << 8 & 0x0000FF00) |
                    (socketAddress[6] << 16 & 0x00FF0000) |
                    (socketAddress[7] << 24)
                    ) & 0x00000000FFFFFFFF;

                IPEndPoint created = new IPEndPoint(address, port);

                GlobalLog.Print("IPEndPoint::Create: " + this.ToString() + " -> " + created.ToString());

                //
                // return it
                //
                return(created);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Creates an endpoint from a socket address.
 /// </summary>
 /// 
 /// <returns>
 /// An <see cref="T:System.Net.EndPoint"/> instance using the specified socket address.
 /// </returns>
 /// <param name="socketAddress">The <see cref="T:System.Net.SocketAddress"/> to use for the endpoint. </param><exception cref="T:System.ArgumentException">The AddressFamily of <paramref name="socketAddress"/> is not equal to the AddressFamily of the current instance.-or- <paramref name="socketAddress"/>.Size &lt; 8. </exception><PermissionSet><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence"/></PermissionSet>
 public override EndPoint Create(SocketAddress socketAddress)
 {
     if (socketAddress.Family != this.AddressFamily)
       {
     throw new ArgumentException(SR.GetString("net_InvalidAddressFamily", (object) ((object) socketAddress.Family).ToString(), (object) this.GetType().FullName, (object) ((object) this.AddressFamily).ToString()), "socketAddress");
       }
       else
       {
     if (socketAddress.Size >= 8)
       return (EndPoint) socketAddress.GetIPEndPoint();
     throw new ArgumentException(SR.GetString("net_InvalidSocketAddressSize", (object) socketAddress.GetType().FullName, (object) this.GetType().FullName), "socketAddress");
       }
 }
Ejemplo n.º 8
0
        /// <include file='doc\IPEndPoint.uex' path='docs/doc[@for="IPEndPoint.Create"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public override EndPoint Create(SocketAddress socketAddress) {
            //
            // validate SocketAddress
            //
            if (socketAddress.Family != this.AddressFamily) {
                throw new ArgumentException(SR.GetString(SR.net_InvalidAddressFamily, socketAddress.Family.ToString(), this.GetType().FullName, this.AddressFamily.ToString()));
            }
            if (socketAddress.Size<8) {
                throw new ArgumentException(SR.GetString(SR.net_InvalidSocketAddressSize, socketAddress.GetType().FullName, this.GetType().FullName));
            }
            //
            // strip out of SocketAddress information on the EndPoint
            //
            int port = 
                    ((int)socketAddress[2]<<8) |
                    ((int)socketAddress[3]);

            long address = (long)(
                    ((int)socketAddress[4]    ) |
                    ((int)socketAddress[5]<<8 ) |
                    ((int)socketAddress[6]<<16) |
                    ((int)socketAddress[7]<<24)
                    ) & 0x00000000FFFFFFFF;

            IPEndPoint created = new IPEndPoint(address, port);

            GlobalLog.Print("IPEndPoint::Create: " + this.ToString() + " -> " + created.ToString() );

            //
            // return it
            //
            return created;
        }
Ejemplo n.º 9
0
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public override EndPoint Create(SocketAddress socketAddress) {
            //
            // validate SocketAddress
            //
            if (socketAddress.Family != this.AddressFamily) {
                throw new ArgumentException(SR.GetString(SR.net_InvalidAddressFamily, socketAddress.Family.ToString(), this.GetType().FullName, this.AddressFamily.ToString()), "socketAddress");
            }
            if (socketAddress.Size<8) {
                throw new ArgumentException(SR.GetString(SR.net_InvalidSocketAddressSize, socketAddress.GetType().FullName, this.GetType().FullName), "socketAddress");
            }

            if ( this.AddressFamily == AddressFamily.InterNetworkV6 ) {
                //
                // IPv6 Changes: Extract the IPv6 Address information from the socket address
                //
                byte[] addr = new byte[IPAddress.IPv6AddressBytes];
                for (int i = 0; i < addr.Length; i++)
                {
                    addr[i] = socketAddress[i + 8];
                }
                //
                // Port
                //
                int port = (int)((socketAddress[2]<<8 & 0xFF00) | (socketAddress[3]));
                //
                // Scope
                //
                long scope = (long)((socketAddress[27] << 24) +
                                    (socketAddress[26] << 16) +
                                    (socketAddress[25] << 8 ) +
                                    (socketAddress[24]));

                IPEndPoint created = new IPEndPoint(new IPAddress(addr,scope),port);

                GlobalLog.Print("IPEndPoint::Create IPv6: " + this.ToString() + " -> " + created.ToString() );

                return created;
            }
            else
            {

                //
                // strip out of SocketAddress information on the EndPoint
                //
                int port = (int)(
                        (socketAddress[2]<<8 & 0xFF00) |
                        (socketAddress[3])
                        );
    
                long address = (long)(
                        (socketAddress[4]     & 0x000000FF) |
                        (socketAddress[5]<<8  & 0x0000FF00) |
                        (socketAddress[6]<<16 & 0x00FF0000) |
                        (socketAddress[7]<<24)
                        ) & 0x00000000FFFFFFFF;
    
                IPEndPoint created = new IPEndPoint(address, port);
    
                GlobalLog.Print("IPEndPoint::Create: " + this.ToString() + " -> " + created.ToString() );
    
                //
                // return it
                //
                return created;
            }
        }
        public override EndPoint Create(SocketAddress socketAddress)
        {
            if (socketAddress.Family != this.AddressFamily)
            {
                throw new ArgumentException(SR.GetString("net_InvalidAddressFamily", new object[] { socketAddress.Family.ToString(), base.GetType().FullName, this.AddressFamily.ToString() }), "socketAddress");
            }
            if (socketAddress.Size < 8)
            {
                throw new ArgumentException(SR.GetString("net_InvalidSocketAddressSize", new object[] { socketAddress.GetType().FullName, base.GetType().FullName }), "socketAddress");
            }
            if (this.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6)
            {
                byte[] address = new byte[0x10];
                for (int i = 0; i < address.Length; i++)
                {
                    address[i] = socketAddress[i + 8];
                }
                int  num2    = ((socketAddress[2] << 8) & 0xff00) | socketAddress[3];
                long scopeid = (((socketAddress[0x1b] << 0x18) + (socketAddress[0x1a] << 0x10)) + (socketAddress[0x19] << 8)) + socketAddress[0x18];
                return(new IPEndPoint(new IPAddress(address, scopeid), num2));
            }
            int port = ((socketAddress[2] << 8) & 0xff00) | socketAddress[3];

            return(new IPEndPoint(((((socketAddress[4] & 0xff) | ((socketAddress[5] << 8) & 0xff00)) | ((socketAddress[6] << 0x10) & 0xff0000)) | (socketAddress[7] << 0x18)) & ((long)0xffffffffL), port));
        }