Giter Club home page Giter Club logo

pecl-tuntap's Introduction

pecl-tuntap

TUN/TAP ioctls for PHP. Enables PHP-Applications to create and manage TUN/TAP-Interfaces on Linux.

Building

This module may be build using the normal PECL-Way:

phpize
./configure --enable-tuntap
make && make install

Usage

Create a new TUN/TAP-Device

$fd = tuntap_new ([string $Name [, int $Flags = 0]]);

Returns a new file-stream that may be used with file-stream-functions like fread(), etc.

  • $Name may be the desired name of the new device, if NULL a name is choosen by the kernel.
  • $Flags may be any OR'ed combination of TUN/TAP-Flags (see Constants)

Both parameters are optional.

Retrive the name of a TUN/TAP-Device

$name = tuntap_name (resource $fd);

Returns the name of the TUN/TAP-Device as string.

  • $fd shall be the file-resource returned by a previous tuntap_new()-Call.

Set the owner of a TUN/TAP-Device

tuntap_owner (resource $fd [, mixed $User = NULL [, mixed $Group = NULL]]);

Returns a boolean indicating success or failure.

  • $fd shall be the file-resource returned by a previous tuntap_new()-Call.
  • $User may be NULL, a string containing a Username or an integer containing a User-ID.
  • $Group may be just like $User but for groups.

Set persistence of a TUN/TAP-Device

tuntap_persist (resource $fd [, bool $Persist = true]);

Returns a boolean indicating success or failure.

  • $fd shall be the file-resource returned by a previous tuntap_new()-Call.
  • $Persist Enable or disable persistence (default: Enable)

Constants

  • TUNTAP_DEVICE_TUN Creates a TUN-Device
  • TUNTAP_DEVICE_TAP Creates a TAP-Device
  • TUNTAP_DEVICE_EXCL Don't remember what this should be, maybe something like exclusive

Example

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.

License

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.

pecl-tuntap's People

Contributors

bitbaendiger avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.