senf::emu::InterfaceAPIBase< Medium, Direction, Transport, Base > Class Template Reference

Interface implementation base-class. More...

#include <senf/Ext/NetEmu/InterfaceAPIBase.hh>

Detailed Description

template<class Medium, class Direction, class Transport = void, class Base = void>
class senf::emu::InterfaceAPIBase< Medium, Direction, Transport, Base >

Interface implementation base-class.

InterfaceAPIBase is the helper base-class for implementing interface types. Depending on the template arguments, the class will select the correct set of base classes.

Template Parameters
TransportTransport type, interface::Hardware or interface::Emulated
MediumType of network medium, interface::Wired or interface::Wireless
DirectionSupported data directions, interface::Bidirectional (default), interface::ReceiveOnly or Interface::TransmitOnly

The real interface implementation will be some PPI network which produces received packets on an output connector or jack and will receive packets on an input connector to be sent via the network device.

For emulated interfaces, the 'hardware device' is provided by the base classes via two jacks, receiverJack for incoming packets and transmitterJack for outgoing packets. You will need to connect these jacks to your internal network.

struct MyInterfaceNet
{
ppi::connector::ActiveOutputJack<EthernetPacket> myOutput; // receive capable
ppi::connector::PassiveInputJack<EthernetPacket> myInput; // transmit capable
// Emulated interfaces only
ppi::connector::PassiveInputJack<> myReceiveInput; // receive capable
ppi::connector::ActiveOutputJack<> myTransmitOutput; // transmit capable
// modules and code to send/receive data to/from the network device (or the emulation
// layer)
};
// Adjust the InterfaceAPIBase template arguments accordingly
class MyInterface
: private MyInterfaceNet,
public senf::emu::InterfaceAPIBase<senf::emu::interface::Emulated,
senf::emu::interface::Wireless>
{
public:
// The arguments to the Base constructor depends on the 'Direction' template
// parameter:
// ReceiveOnly interfaces skip the 'input' argument
// TransmitOnly interfaces skip the 'output' argument
// Your constructor may take arguments to configure the device.
MyInterface()
: Base (myOutput, myInput)
{
// Only emulated interfaces
senf::ppi::connect(receiverJack, myReceiveInput); // receive capable
senf::ppi::connect(myTransmitOutput, transmitterJack); // transmit capable
// Only hardware wireless interfaces
// call registerFrequency and registerParameter (once or multiple times) to
// register all valid parameter and frequency combinations.
registerFrequency(minFreq, maxFreq, minBw, maxBw);
registerFrequency(freq, bw);
registerParameter(label, efficiency, minrssi);
// Only hardware wireless transmit capable interfaces
// call register TxPower (once or multiple times) to register valid
// txPower values
registerTxPower(minPower, maxPower);
registerTxPower(power);
init();
}
private:
// Abstract API implementation
// All interfaces
virtual void v_id(senf::MACAddress const & id);
virtual senf::MACAddress v_id() const;
// Only hardware interfaces
virtual void v_enable();
virtual void v_disable();
virtual bool v_enabled() const;
// Only hardware transmit capable interfaces
virtual unsigned v_mtu() const;
virtual void v_mtu(unsigned v);
// Only hardware receive capable interfaces
virtual bool v_promisc() const;
virtual void v_promisc(bool v);
virtual bool v_annotationMode() const;
virtual void v_annotationMode(bool a);
// Only hardware wireless interfaces
virtual unsigned v_frequency() const;
virtual unsigned v_bandwidth() const;
virtual void v_frequency(unsigned freq, unsigned bw);
// Only wireless transmit capable interfaces
virtual unsigned v_modulationId() const;
virtual void v_modulationId(unsigned id);
virtual int v_txPower() const;
virtual void v_txPower(int power);
// Only emulated transmit capable interfaces (optional)
virtual Packet::size_type v_emulatedPayloadSize(Packet packet);
// Only emulated wireless receive capable interfaces (optional)
virtual bool v_emulatedWirelessQuality(senf::Packet packet,
};

Definition at line 161 of file InterfaceAPIBase.hh.


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