Exemple #1
0
        public void ReceiveFrame(EthernetFrame frame)
        {
            // TODO: non blocking
            if (stream == null)
            {
                return;
            }
            var handle = GCHandle.Alloc(frame.Bytes, GCHandleType.Pinned);

            try
            {
                var result = LibC.WriteData(stream.Handle, handle.AddrOfPinnedObject(), frame.Bytes.Length);
                if (result == 0)
                {
                    this.Log(LogLevel.Error,
                             "Error while writing to TUN interface: {0}.", result);
                }
            }
            finally
            {
                handle.Free();
            }
        }