Exemplo n.º 1
0
        /// <summary>
        ///		Create a new security option.
        /// </summary>
        /// <param name="option">
        ///		The option to parse.
        ///	</param>
        /// <exception cref="ArgumentNullException">
        ///		The option argument is null.
        ///	</exception>
        /// <exception cref="ArgumentException">
        ///		The option argument is not a security option.
        ///	</exception>
        public IpV4SecurityOption(IpV4Option option)
        {
            if (option == null)
            {
                throw new ArgumentNullException("option");
            }

            if (option.OptionType != IpV4OptionNumber.Security)
            {
                throw new ArgumentException("The option passed was not compatible with this class. This class accepts security options only", "option");
            }

            // extract the security level field
            m_level = (IpV4SecurityLevelType)BitConverter.ToUInt16(option.Data, 0);

            // extract the compartment field
            m_compartment = BitConverter.ToUInt16(option.Data, 2);

            // extract the handling restrictions field
            m_handling = BitConverter.ToUInt16(option.Data, 4);

            // extract the 24 bits of the transmission control code

            m_tcc  = (uint)(option.Data[6] << 0x10);
            m_tcc |= (uint)(option.Data[7] << 0x08);
            m_tcc |= option.Data[8];
        }
Exemplo n.º 2
0
		/// <summary>
		///		Create a new security option.
		/// </summary>
		/// <param name="option">
		///		The option to parse.
		///	</param>
		/// <exception cref="ArgumentNullException">
		///		The option argument is null.
		///	</exception>
		/// <exception cref="ArgumentException">
		///		The option argument is not a security option.
		///	</exception>
		public IpV4SecurityOption (IpV4Option option)
		{
			if (option == null)
			{
				throw new ArgumentNullException ("option");
			}
		
			if (option.OptionType != IpV4OptionNumber.Security)
			{
				throw new ArgumentException ("The option passed was not compatible with this class. This class accepts security options only", "option");
			}
			
			// extract the security level field
			m_level = (IpV4SecurityLevelType) BitConverter.ToUInt16 (option.Data, 0);
			
			// extract the compartment field
			m_compartment = BitConverter.ToUInt16 (option.Data, 2);
			
			// extract the handling restrictions field
			m_handling = BitConverter.ToUInt16 (option.Data, 4);
			
			// extract the 24 bits of the transmission control code
			
			m_tcc = (uint)(option.Data[6] << 0x10);
			m_tcc |= (uint)(option.Data[7] << 0x08);
			m_tcc |= option.Data[8];
			
		}