Implements interfaces: twisted.pair.tuntap._IInputOutputSystem

An in-memory implementation of basic I/O primitives, useful in the context of unit testing as a drop-in replacement for parts of the os module.

Instance Variable permissions
Method __init__ Undocumented
Method getTunnel Get the Tunnel object associated with the given TuntapPort.
Method registerSpecialDevice Specify a class which will be used to handle I/O to a device of a particular name.
Method open No summary
Method read Try to read some bytes out of one of the in-memory buffers which may previously have been populated by write.
Method write Try to add some bytes to one of the in-memory buffers to be accessed by a later read call.
Method close Discard the in-memory buffer and other in-memory state for the given file descriptor.
Method ioctl Perform some configuration change to the in-memory state for the given file descriptor.
Method sendUDP Write an ethernet frame containing an ip datagram containing a udp datagram containing the given payload, addressed to the given address, to a tunnel device previously opened on this I/O system.
Method receiveUDP Get a socket-like object which can be used to receive a datagram sent from the given address.
Instance Variable _devices
Instance Variable _openFiles
Instance Variable _counter
_devices =
_openFiles =
permissions =
_counter =
def __init__(self): (source)
Undocumented
def getTunnel(self, port): (source)

Get the Tunnel object associated with the given TuntapPort.

ParametersportA TuntapPort previously initialized using this MemoryIOSystem.
ReturnsThe tunnel object created by a prior use of open on this object on the tunnel special device file. (type: Tunnel)
def registerSpecialDevice(self, name, cls): (source)

Specify a class which will be used to handle I/O to a device of a particular name.

ParametersnameThe filesystem path name of the device. (type: bytes)
clsA class (like Tunnel) to instantiated whenever this device is opened.
@_privileged
def open(self, name, flags, mode=None): (source)

A replacement for os.open. This initializes state in this MemoryIOSystem which will be reflected in the behavior of the other file descriptor-related methods (eg MemoryIOSystem.read, MemoryIOSystem.write, etc).

ParametersnameA string giving the name of the file to open. (type: bytes)
flagsThe flags with which to open the file. (type: int)
modeThe mode with which to open the file. (type: int)
ReturnsA file descriptor associated with the newly opened file description. (type: int)
RaisesOSErrorWith ENOSYS if the file is not a recognized special device file.
def read(self, fd, limit): (source)

Try to read some bytes out of one of the in-memory buffers which may previously have been populated by write.

See Alsoos.read
def write(self, fd, data): (source)

Try to add some bytes to one of the in-memory buffers to be accessed by a later read call.

See Alsoos.write
def close(self, fd): (source)

Discard the in-memory buffer and other in-memory state for the given file descriptor.

See Alsoos.close
@_privileged
def ioctl(self, fd, request, args): (source)

Perform some configuration change to the in-memory state for the given file descriptor.

See Alsofcntl.ioctl
def sendUDP(self, datagram, address): (source)

Write an ethernet frame containing an ip datagram containing a udp datagram containing the given payload, addressed to the given address, to a tunnel device previously opened on this I/O system.

ParametersdatagramA UDP datagram payload to send. (type: bytes)
addressThe destination to which to send the datagram. (type: tuple of (bytes, int))
ReturnsA two-tuple giving the address from which gives the address from which the datagram was sent. (type: tuple of (bytes, int))
def receiveUDP(self, fileno, host, port): (source)

Get a socket-like object which can be used to receive a datagram sent from the given address.

ParametersfilenoA file descriptor representing a tunnel device which the datagram will be received via. (type: int)
hostThe IPv4 address to which the datagram was sent. (type: bytes)
portThe UDP port number to which the datagram was sent. received. (type: int)
ReturnsA socket.socket-like object which can be used to receive the specified datagram.
API Documentation for Twisted, generated by pydoctor at 2018-10-15 19:29:43.