internal static extern SocketError setsockopt(
     [In] SafeCloseSocket socketHandle,
     [In] SocketOptionLevel optionLevel,
     [In] SocketOptionName optionName,
     [In] ref IPv6MulticastRequest mreq,
     [In] int optionLength
     );
 internal static extern SocketError getsockopt(
     [In] SafeCloseSocket socketHandle,
     [In] SocketOptionLevel optionLevel,
     [In] SocketOptionName optionName,
     [Out] out IPv6MulticastRequest optionValue,
     [In, Out] ref int optionLength
     );
Esempio n. 3
0
        /// <devdoc>
        ///     <para>
        ///         IPv6 getsockopt for JOIN / LEAVE multicast group
        ///     </para>
        /// </devdoc>
        private IPv6MulticastOption getIPv6MulticastOpt(SocketOptionName optionName) {
            IPv6MulticastRequest ipmr = new IPv6MulticastRequest();

            int optlen = IPv6MulticastRequest.Size;

            // This can throw ObjectDisposedException.
            SocketError errorCode = UnsafeNclNativeMethods.OSSOCK.getsockopt(
                m_Handle,
                SocketOptionLevel.IP,
                optionName,
                out ipmr,
                ref optlen);

            GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::getIPv6MulticastOpt() UnsafeNclNativeMethods.OSSOCK.getsockopt returns errorCode:" + errorCode);

            //
            // if the native call fails we'll throw a SocketException
            //
            if (errorCode==SocketError.SocketError) {
                //
                // update our internal state after this socket error and throw
                //
                SocketException socketException = new SocketException();
                UpdateStatusAfterSocketError(socketException);
                if(s_LoggingEnabled)Logging.Exception(Logging.Sockets, this, "getIPv6MulticastOpt", socketException);
                throw socketException;
            }

            IPv6MulticastOption multicastOption = new IPv6MulticastOption(new IPAddress(ipmr.MulticastAddress),ipmr.InterfaceIndex);

            return multicastOption;
        }
Esempio n. 4
0
        /// <devdoc>
        ///     <para>
        ///         IPv6 setsockopt for JOIN / LEAVE multicast group
        ///     </para>
        /// </devdoc>
        private void setIPv6MulticastOption(SocketOptionName optionName, IPv6MulticastOption MR) {
            IPv6MulticastRequest ipmr = new IPv6MulticastRequest();

            ipmr.MulticastAddress = MR.Group.GetAddressBytes();
            ipmr.InterfaceIndex   = unchecked((int)MR.InterfaceIndex);

            GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::setIPv6MulticastOption(): optionName:" + optionName.ToString() + " MR:" + MR.ToString() + " ipmr:" + ipmr.ToString() + " IPv6MulticastRequest.Size:" + IPv6MulticastRequest.Size.ToString());

            // This can throw ObjectDisposedException.
            SocketError errorCode = UnsafeNclNativeMethods.OSSOCK.setsockopt(
                m_Handle,
                SocketOptionLevel.IPv6,
                optionName,
                ref ipmr,
                IPv6MulticastRequest.Size);

            GlobalLog.Print("Socket#" + ValidationHelper.HashString(this) + "::setIPv6MulticastOption() UnsafeNclNativeMethods.OSSOCK.setsockopt returns errorCode:" + errorCode);

            //
            // if the native call fails we'll throw a SocketException
            //
            if (errorCode==SocketError.SocketError) {
                //
                // update our internal state after this socket error and throw
                //
                SocketException socketException = new SocketException();
                UpdateStatusAfterSocketError(socketException);
                if(s_LoggingEnabled)Logging.Exception(Logging.Sockets, this, "setIPv6MulticastOption", socketException);
                throw socketException;
            }
        }
Esempio n. 5
0
 private IPv6MulticastOption getIPv6MulticastOpt(SocketOptionName optionName)
 {
     IPv6MulticastRequest optionValue = new IPv6MulticastRequest();
       int optionLength = IPv6MulticastRequest.Size;
       if (UnsafeNclNativeMethods.OSSOCK.getsockopt(this.m_Handle, SocketOptionLevel.IP, optionName, out optionValue, out optionLength) != SocketError.SocketError)
     return new IPv6MulticastOption(new IPAddress(optionValue.MulticastAddress), (long) optionValue.InterfaceIndex);
       SocketException socketException = new SocketException();
       this.UpdateStatusAfterSocketError(socketException);
       if (Socket.s_LoggingEnabled)
     Logging.Exception(Logging.Sockets, (object) this, "getIPv6MulticastOpt", (Exception) socketException);
       throw socketException;
 }
 internal static extern SocketError getsockopt([In] SafeCloseSocket socketHandle, [In] SocketOptionLevel optionLevel, [In] SocketOptionName optionName, out IPv6MulticastRequest optionValue, [In, Out] ref int optionLength);
 private void setIPv6MulticastOption(SocketOptionName optionName, IPv6MulticastOption MR)
 {
     IPv6MulticastRequest mreq = new IPv6MulticastRequest {
         MulticastAddress = MR.Group.GetAddressBytes(),
         InterfaceIndex = (int) MR.InterfaceIndex
     };
     if (UnsafeNclNativeMethods.OSSOCK.setsockopt(this.m_Handle, SocketOptionLevel.IPv6, optionName, ref mreq, IPv6MulticastRequest.Size) == SocketError.SocketError)
     {
         SocketException socketException = new SocketException();
         this.UpdateStatusAfterSocketError(socketException);
         if (s_LoggingEnabled)
         {
             Logging.Exception(Logging.Sockets, this, "setIPv6MulticastOption", socketException);
         }
         throw socketException;
     }
 }