[fpc-pascal] TUN/TAP
Jorge Aldo G. de F. Junior
jagfj80 at gmail.com
Mon Oct 5 00:42:00 CEST 2009
i already knew about fpioctl, but the ioctl example uses some macros to get
the correct code, but i dont understand how
theres a python equivalent code that works, but i cant decypher this :
(Python code)
TUNSETIFF = 0x400454ca
IFF_TUN = 0x0001
IFF_TAP = 0x0002
TUNMODE = IFF_TUN
f = os.open("/dev/net/tun", os.O_RDWR)
ifs = ioctl(f, TUNSETIFF, struct.pack("16sH", "toto%d", TUNMODE))
ifname = ifs[:16].strip("\x00")
becomes (Pascal Code);
TUNSETIFF := $400454ca;
IFF_TUN := $0001; // TUN is a pseudo-ip device
IFF_TAP := $0002; // TAP is a pseudo-ethernet device
F := TFileStream.Create('/dev/net/tun', fmOpenReadWrite);
IFS := fpioctl(F.Handle, TUNSETIFF, ???);
IFNAME := ????
This makes the handle behave as a virtual network interface (allowing packet
injection/reception from userland) and returns the correct interface name so
as to allow passing it to scripts, ifconfig etc...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20091004/89d5868a/attachment.html>
More information about the fpc-pascal
mailing list