Exemplo n.º 1
0
        /// <summary>
        /// Creates a new <see cref="BroConnection"/> using the existing <paramref name="socket"/> handle.
        /// </summary>
        /// <param name="socket">Existing open socket to use for <see cref="BroConnection"/>.</param>
        /// <param name="flags">Connection flags for this <see cref="BroConnection"/>.</param>
        /// <exception cref="OutOfMemoryException">Failed to create Bro connection.</exception>
        public BroConnection(int socket, BroConnectionFlags flags = BroConnectionFlags.None)
            : this()
        {
            m_connectionPtr = BroApi.bro_conn_new_socket(socket, flags);

            if (m_connectionPtr.IsInvalid())
            {
                throw new OutOfMemoryException("Failed to create Bro connection.");
            }

            m_hostName = string.Format("@FD={0}", socket);
            m_flags    = flags;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new <see cref="BroConnection"/> with specified connection parameters.
        /// </summary>
        /// <param name="hostName">Host name, formatted as host:port, to connect to.</param>
        /// <param name="flags">Connection flags for this <see cref="BroConnection"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="hostName"/> is <c>null</c>.</exception>
        /// <exception cref="OutOfMemoryException">Failed to create Bro connection.</exception>
        public BroConnection(string hostName, BroConnectionFlags flags = BroConnectionFlags.None)
            : this()
        {
            if ((object)hostName == null)
            {
                throw new ArgumentNullException("hostName");
            }

            m_connectionPtr = BroApi.bro_conn_new_str(hostName, flags);

            if (m_connectionPtr.IsInvalid())
            {
                throw new OutOfMemoryException("Failed to create Bro connection.");
            }

            m_hostName = hostName;
            m_flags    = flags;
        }
Exemplo n.º 3
0
        public BroConnection(Socket socket, BroConnectionFlags flags = BroConnectionFlags.None)
            : this()
        {
            if ((object)socket == null)
            {
                throw new ArgumentNullException("socket");
            }

            m_connectionPtr = BroApi.bro_conn_new_socket(socket.Handle.ToInt32(), flags);

            if (m_connectionPtr.IsInvalid())
            {
                throw new OutOfMemoryException("Failed to create Bro connection.");
            }

            m_hostName = DeriveHostName(socket);
            m_flags    = flags;
        }