TUN/TAP ioctls for PHP. Enables PHP-Applications to create and manage TUN/TAP-Interfaces on Linux.
This module may be build using the normal PECL-Way:
phpize
./configure --enable-tuntap
make && make install
$fd = tuntap_new ([string $Name [, int $Flags = 0]]);
Returns a new file-stream that may be used with file-stream-functions like
fread(), etc.
$Namemay be the desired name of the new device, ifNULLa name is choosen by the kernel.$Flagsmay be any OR'ed combination of TUN/TAP-Flags (see Constants)
Both parameters are optional.
$name = tuntap_name (resource $fd);
Returns the name of the TUN/TAP-Device as string.
$fdshall be the file-resource returned by a previoustuntap_new()-Call.
tuntap_owner (resource $fd [, mixed $User = NULL [, mixed $Group = NULL]]);
Returns a boolean indicating success or failure.
$fdshall be the file-resource returned by a previoustuntap_new()-Call.$Usermay be NULL, a string containing a Username or an integer containing a User-ID.$Groupmay be just like$Userbut for groups.
tuntap_persist (resource $fd [, bool $Persist = true]);
Returns a boolean indicating success or failure.
$fdshall be the file-resource returned by a previoustuntap_new()-Call.$PersistEnable or disable persistence (default: Enable)
TUNTAP_DEVICE_TUNCreates a TUN-DeviceTUNTAP_DEVICE_TAPCreates a TAP-DeviceTUNTAP_DEVICE_NO_PIDo not provide packet informationTUNTAP_DEVICE_EXCLDon't remember what this should be, maybe something like exclusive
Please see the provided tuntap.php (including the lib/-Folder) for an example.
The script creates a TAP-Interface, assigns the local IP-Adress 10.10.10.1/24
using iproute2 and emulates a virutal peer at 10.10.10.2 that may be pinged
using external tools.
Copyright (C) 2016-17 Bernd Holzmüller
Licensed under the PHP license 3.01. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.