senf::TapSocketProtocol Class Reference
[Protocol Implementations (Concrete Protocol Classes)]

SocketProcol for the tap pseudo-device. More...

#include <senf/Socket/Protocols/Raw/TunTapSocketHandle.hh>

Inheritance diagram for senf::TapSocketProtocol:
Inheritance graph
[legend]

List of all members.


Detailed Description

SocketProcol for the tap pseudo-device.
Socket Handle typedefs:
TapSocketHandle
Policy Interface:
ClientSocketHandle::read() ...
The TapSocketProtocol provides access to the Linux tap device.

The tap device is a virtual ethernet network device. The tap driver was designed as low level kernel support for ethernet tunneling. Userland application can write Ethernet frames to the socket and kernel will receive this frames from the tap interface. In the same time every frame that kernel writes to the tap interface can be read by userland application from the socket.

This class is utilized as the protocol class of the ProtocolClientSocketHandle via the Socket Handle typedef above.

See also:
Kernel documentation for the TUN/TAP device driver.

Definition at line 77 of file TunTapSocketHandle.hh.


Related Functions

(Note that these are not member functions.)

typedef
ProtocolClientSocketHandle
< TapSocketProtocol
TapSocketHandle
  SocketHandle of TapSocketProtocol.

Abstract Interface Implementation

unsigned  available () const
  Return (maximum) number of bytes available for reading < without < blocking.
bool  eof () const
  returns always false.
unsigned int  ifaceIndex () const
  returns the index of the correspondent tap interface
std::string  ifaceName () const
  returns the actual name of the correspondent tap interface

Constructors

void  init_client () const
  Open tap socket and create new tap interface.
void  init_client (std::string const &interface_name, bool NO_PI=true) const
  Open tap socket and create new tap interface.

Member Function Documentation

unsigned senf::TapSocketProtocol::
available ()

Return (maximum) number of bytes available for reading < without < blocking.

This member will check in a (very, sigh) protocol dependent way, how many bytes may be read from a socket in a single (non-blocking) read operation. If the socket does not support reading (viz. NotReadablePolicy is set), this member should always return 0.

Depending on the protocol, it may not be possible to return a good value. In this case, an upper bound may be returned (e.g.: When reading from a socket which returns ethernet frames, returning 1500 from available() is ok). However, this should only be done as a last resort. Also beware, that this number should not be too large since the socket layer will always need to allocate that number of bytes for the data to be read.

Implements senf::SocketProtocol.

Definition at line 66 of file TunTapSocketHandle.cc.

bool senf::TapSocketProtocol::
eof ()

returns always false.

Implements senf::SocketProtocol.

Definition at line 93 of file TunTapSocketHandle.cc.

unsigned int senf::TapSocketProtocol::
ifaceIndex ()

returns the index of the correspondent tap interface

Definition at line 99 of file TunTapSocketHandle.cc.

std::string senf::TapSocketProtocol::
ifaceName ()

returns the actual name of the correspondent tap interface

Definition at line 105 of file TunTapSocketHandle.cc.

void senf::TapSocketProtocol::
init_client ( std::string const &  interface_name,
bool  NO_PI = true )

Open tap socket and create new tap interface.

Opens the tun/tap socket and create a new tap interface with the given name. Note that the created interface can have a different name as specified. Use ifaceName() to get the actual name.

The new interface is down and has to be set up separately. After closing the socket, the tap interface and all corresponding routes will be deleted automatically.

Parameters:
[in]  interface_name  name of the new tap interface.
[in]  NO_PI  if set to false each packet has a additional 4 bytes header (flags, proto)
Note:
This member is implicitly called from the ProtocolClientSocketHandle::ProtocolClientSocketHandle() constructor

Definition at line 48 of file TunTapSocketHandle.cc.

void senf::TapSocketProtocol::
init_client ()

Open tap socket and create new tap interface.

Opens the tun/tap socket and create a new tap interface Use ifaceName() to get the actual name of the newly created interface.

The new interface is down and has to be set up separately. After closing the socket, the tap interface and all corresponding routes will be deleted automatically.

Note:
This member is implicitly called from the ProtocolClientSocketHandle::ProtocolClientSocketHandle() constructor

Definition at line 42 of file TunTapSocketHandle.cc.


The documentation for this class was generated from the following files: