[fpc-pascal] TAP-Win32

Jorge Aldo G. de F. Junior jagfj80 at gmail.com
Fri May 14 13:34:08 CEST 2010


Uses
	Windows,
	Classes,
	BlckSock;

Const
	TAP_Device = '\\.\Global\{44F7688F-77FA-43DC-8D8F-9CBA23E01BB0}.tap'#00;
	TAP_Buffer = 8192;

Var
	Handle : Integer;
	Buffer : Pointer;
	Stream : THandleStream;
	Count  : Integer;
	
Begin
	Handle := CreateFileA(PChar(TAP_Device), GENERIC_READ or
GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM, 0);
	Stream := THandleStream.Create(Handle);
	Buffer := GetMem(TAP_Buffer);
	Repeat
		Count := Stream.Read(Buffer^, TAP_Buffer);
		If Count > 0 Then
			Stream.Write(Buffer^, Count);
	Until False;
	Stream.Free;
	FreeMem(Buffer, TAP_Buffer);
	CloseHandle(Handle);
End.


=========

i am able to receive packets setting up a tap device with a fixed ip
and doing ping to the gateway address...

now i need to decipher the ioctl calls...

2010/5/13 José Mejuto <joshyfun at gmail.com>:
> Hello FPC-Pascal,
>
> Friday, May 14, 2010, 12:14:31 AM, you wrote:
>
> JAGdFJ> This is the C# example i found :
> JAGdFJ> http://www.varsanofiev.com/inside/TunTest.cs
>
> Also this line is wrong IMHO:
>
> TAP_Device = '\\\\.\\Global\\{44F7688F-77FA-43DC-8D8F-9CBA23E01BB0}.tap';
>
> it should be:
>
> TAP_Device = '\\.\Global\{44F7688F-77FA-43DC-8D8F-9CBA23E01BB0}.tap';
>
> Pascal does not need the slash escape sequence.
>
> --
> Best regards,
>  José
>
> _______________________________________________
> 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