[fpc-pascal] TAP-Win32
Jorge Aldo G. de F. Junior
jagfj80 at gmail.com
Thu May 13 22:42:37 CEST 2010
TAP-Win32 is the win32 equivalent of linux/unix tun tap devices.
i need to:
- discover installed taps
- set device options (Dont need ip and etc, just the basic ioctls)
- read and write to device (after set up it becomes just a simple file)
i tried this :
Uses Windows, Classes;
Const
TAP_Device = '\\\\.\\Global\\{44F7688F-77FA-43DC-8D8F-9CBA23E01BB0}.tap';
Var
Handle : Integer;
Buffer : Pointer;
Stream : THandleStream;
Count : Integer;
Begin
Handle := CreateFile(PChar(TAP_Device), GENERIC_READ Or
GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM Or
FILE_FLAG_OVERLAPPED, 0);
WriteLn(Handle);
Stream := THandleStream.Create(Handle);
Buffer := GetMem(2048);
Repeat
Count := Stream.Read(Buffer^, 2048);
If Count > 0 Then
WriteLn('Got ', Count, ' bytes !');
Stream.Write(Buffer^, Count);
Until False;
Stream.Free;
FreeMem(Buffer, 2048);
CloseHandle(Handle);
End.
(translated from a C# example)
but the handle returned is always -1
(The guid is correct as returned by openvpn)
2010/5/13 Marc Weustink <marc at dommelstein.net>:
> Felipe Monteiro de Carvalho wrote:
>>
>> What does TAP stand for?
>
> see http://en.wikipedia.org/wiki/TUN/TAP for some pointers.
>
> Marc
>
>
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list