public WinTunPort(string adapterName, Func <WinTunTransitter, TPacketReceiver> packetReceiverFactory) { _pool = new WinTunMemoryPool(1000, 2000); _deviceGuid = GetGuidForName(adapterName); _fileHandle = CreateFile($"{UsermodeDeviceSpace}{_deviceGuid}.tap", FileAccess.ReadWrite, FileShare.ReadWrite, 0, FileMode.Open, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, IntPtr.Zero); SetMediaStatus(_fileHandle); SetTapIOCtl(_fileHandle); _fileStream = new FileStream(_fileHandle, FileAccess.ReadWrite, 2000, isAsync: true); _transmitter = new WinTunTransitter(_fileStream, _pool); _packetReceiver = packetReceiverFactory(_transmitter); var ignore = ReadLoop(); }
internal WinTunTransitter(FileStream fileStream, WinTunMemoryPool pool) { _fileStream = fileStream; _pool = pool; }
public WinTunOwnedMemory(WinTunMemoryPool memoryPool, IntPtr memoryPtr, int startIndex, int length) { _pool = memoryPool; _memoryPtr = (byte *)memoryPtr.ToPointer() + startIndex; _length = length; }