i already knew about fpioctl, but the ioctl example uses some macros to get the correct code, but i dont understand how <br><br>theres a python equivalent code that works, but i cant decypher this :<br><br>(Python code)<br>
<br><pre>TUNSETIFF = 0x400454ca<br>IFF_TUN = 0x0001<br>IFF_TAP = 0x0002<br><br>TUNMODE = IFF_TUN<br></pre><pre>f = os.open("/dev/net/tun", os.O_RDWR)<br>ifs = ioctl(f, TUNSETIFF, struct.pack("16sH", "toto%d", TUNMODE))<br>
ifname = ifs[:16].strip("\x00")<br></pre>becomes (Pascal Code);<br><br>TUNSETIFF := $400454ca;<br>IFF_TUN := $0001; // TUN is a pseudo-ip device<br>IFF_TAP := $0002; // TAP is a pseudo-ethernet device<br><br>F := TFileStream.Create('/dev/net/tun', fmOpenReadWrite);<br>
IFS := fpioctl(F.Handle, TUNSETIFF, ???);<br>IFNAME := ????<br><br>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...<br>