예제 #1
0
        // Creates a new Bro packet from libpcap packet header information and packet data.
        internal BroPacket(timeval timestamp, uint captureLength, byte[] packetData, string tag = null)
        {
            if ((object)packetData == null)
            {
                throw new ArgumentNullException("packetData");
            }

            pcap_pkthdr header = new pcap_pkthdr();

            header.ts     = timestamp;
            header.caplen = captureLength;
            header.len    = (uint)packetData.Length;

            m_packetPtr = BroApi.bro_packet_new(ref header, packetData, tag);

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