Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new <see cref="BroAddress"/> from an existing IP <paramref name="address"/>.
        /// </summary>
        /// <param name="address"><see cref="IPAddress"/> used to initialize <see cref="BroAddress"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="address"/> is <c>null</c>.</exception>
        public BroAddress(IPAddress address)
        {
            if ((object)address == null)
            {
                throw new ArgumentNullException("address");
            }

            m_address = address.ConvertToBroAddr();
        }
Ejemplo n.º 2
0
        // Determines if one bro_addr structure is equal to another
        public static unsafe bool ValueEquals(this bro_addr address1, bro_addr address2)
        {
            for (int i = 0; i < 4; i++)
            {
                if (address1.addr[i] != address2.addr[i])
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        // Get address bytes of a bro_addr structure
        public static unsafe byte[] GetAddressBytes(this bro_addr address)
        {
            byte[] addressBytes = new byte[16];

            fixed(byte *pAddressBytes = &addressBytes[0])
            {
                for (int i = 0; i < 4; i++)
                {
                    *(uint *)(pAddressBytes + i * sizeof(uint)) = address.addr[i];
                }
            }

            return(addressBytes);
        }
Ejemplo n.º 4
0
        // Converts an IPAddress to a bro_addr
        public static unsafe bro_addr ConvertToBroAddr(this IPAddress ipAddress)
        {
            bro_addr broAddress = new bro_addr();

            byte[] addressBytes = ipAddress.MapToIPv6().GetAddressBytes();

            fixed(byte *pAddressBytes = &addressBytes[0])
            {
                for (int i = 0; i < 4; i++)
                {
                    broAddress.addr[i] = *(uint *)(pAddressBytes + i * sizeof(uint));
                }
            }

            return(broAddress);
        }
Ejemplo n.º 5
0
 // Creates a new Bro IP address from an existing Bro IP address
 internal BroAddress(bro_addr sourceAddress)
 {
     m_address = sourceAddress;
 }