xorp

IoLink Class Reference

A base class for I/O link raw communication. More...

#include <io_link.hh>

Inheritance diagram for IoLink:
IoLinkDummy IoLinkPcap

List of all members.

Public Member Functions

 IoLink (FeaDataPlaneManager &fea_data_plane_manager, const IfTree &iftree, const string &if_name, const string &vif_name, uint16_t ether_type, const string &filter_program)
 Constructor for link-level access for a given interface and vif.
virtual ~IoLink ()
 Virtual destructor.
IoLinkManagerio_link_manager ()
 Get the IoLinkManager instance.
FeaDataPlaneManagerfea_data_plane_manager ()
 Get the FeaDataPlaneManager instance.
virtual bool is_running () const
 Test whether this instance is running.
EventLoopeventloop ()
 Get the event loop.
const IfTreeiftree () const
 Get the interface tree.
virtual const string & if_name () const
 Get the interface name.
virtual const string & vif_name () const
 Get the vif name.
virtual uint16_t ether_type () const
 Get the EtherType protocol number.
const string & filter_program () const
 Get the optional filter program.
IoLinkReceiverio_link_receiver ()
 Get the registered receiver.
virtual void register_io_link_receiver (IoLinkReceiver *io_link_receiver)
 Register the I/O Link raw packets receiver.
virtual void unregister_io_link_receiver ()
 Unregister the I/O Link raw packets receiver.
virtual int start (string &error_msg)=0
 Start operation.
virtual int stop (string &error_msg)=0
 Stop operation.
virtual int join_multicast_group (const Mac &group, string &error_msg)=0
 Join a multicast group on an interface.
virtual int leave_multicast_group (const Mac &group, string &error_msg)=0
 Leave a multicast group on an interface.
virtual int send_packet (const Mac &src_address, const Mac &dst_address, uint16_t ether_type, const vector< uint8_t > &payload, string &error_msg)=0
 Send a link-level packet.
bool is_log_trace () const
 Test if trace log is enabled.
void set_log_trace (bool is_enabled)
 Enable/disable trace log.

Protected Member Functions

virtual void recv_packet (const Mac &src_address, const Mac &dst_address, uint16_t ether_type, const vector< uint8_t > &payload)
 Received a link-level packet.
void recv_ethernet_packet (const uint8_t *packet, size_t packet_size)
 Receved an Ethernet packet.
int prepare_ethernet_packet (const Mac &src_address, const Mac &dst_address, uint16_t ether_type, const vector< uint8_t > &payload, vector< uint8_t > &packet, string &error_msg)
 Prepare an Ethernet packet for transmission.

Protected Attributes

bool _is_running

Static Protected Attributes

static const uint32_t L2_MAX_PACKET_SIZE = (64*1024)
static const uint16_t ETHERNET_HEADER_SIZE = 14
static const uint16_t ETHERNET_LENGTH_TYPE_THRESHOLD = 1536
static const uint16_t ETHERNET_MIN_FRAME_SIZE = 60

Private Attributes

IoLinkManager_io_link_manager
FeaDataPlaneManager_fea_data_plane_manager
EventLoop_eventloop
const IfTree_iftree
const string _if_name
const string _vif_name
const uint16_t _ether_type
const string _filter_program
IoLinkReceiver_io_link_receiver
bool _is_log_trace

Detailed Description

A base class for I/O link raw communication.

Each protocol 'registers' for I/O per interface and vif and gets assigned one object (per interface and vif) of this class.


Constructor & Destructor Documentation

IoLink::IoLink ( FeaDataPlaneManager fea_data_plane_manager,
const IfTree iftree,
const string &  if_name,
const string &  vif_name,
uint16_t  ether_type,
const string &  filter_program 
)

Constructor for link-level access for a given interface and vif.

Parameters:
fea_data_plane_managerthe corresponding data plane manager (FeaDataPlaneManager).
iftreethe interface tree to use.
if_namethe interface name.
vif_namethe vif name.
ether_typethe EtherType protocol number. If it is 0 then it is unused.
filter_programthe optional filter program to be applied on the received packets.

Member Function Documentation

virtual uint16_t IoLink::ether_type ( ) const [inline, virtual]

Get the EtherType protocol number.

Returns:
the EtherType protocol number. If it is 0 then it is unused.
EventLoop& IoLink::eventloop ( ) [inline]

Get the event loop.

Returns:
the event loop.
FeaDataPlaneManager& IoLink::fea_data_plane_manager ( ) [inline]

Get the FeaDataPlaneManager instance.

Returns:
the FeaDataPlaneManager instance.
const string& IoLink::filter_program ( ) const [inline]

Get the optional filter program.

Returns:
the optional filter program to be applied on the received packets.
virtual const string& IoLink::if_name ( ) const [inline, virtual]

Get the interface name.

Returns:
the interface name.
const IfTree& IoLink::iftree ( ) const [inline]

Get the interface tree.

Returns:
the interface tree.
IoLinkManager& IoLink::io_link_manager ( ) [inline]

Get the IoLinkManager instance.

Returns:
the IoLinkManager instance.
IoLinkReceiver* IoLink::io_link_receiver ( ) [inline]

Get the registered receiver.

Returns:
the registered receiver.
bool IoLink::is_log_trace ( ) const [inline]

Test if trace log is enabled.

This method is used to test whether to output trace log debug messges.

Returns:
true if trace log is enabled, otherwise false.
virtual bool IoLink::is_running ( ) const [inline, virtual]

Test whether this instance is running.

Returns:
true if the instance is running, otherwise false.
virtual int IoLink::join_multicast_group ( const Mac group,
string &  error_msg 
) [pure virtual]

Join a multicast group on an interface.

Parameters:
groupthe multicast group to join.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.

Implemented in IoLinkDummy, and IoLinkPcap.

virtual int IoLink::leave_multicast_group ( const Mac group,
string &  error_msg 
) [pure virtual]

Leave a multicast group on an interface.

Parameters:
groupthe multicast group to leave.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.

Implemented in IoLinkDummy, and IoLinkPcap.

int IoLink::prepare_ethernet_packet ( const Mac src_address,
const Mac dst_address,
uint16_t  ether_type,
const vector< uint8_t > &  payload,
vector< uint8_t > &  packet,
string &  error_msg 
) [protected]

Prepare an Ethernet packet for transmission.

Parameters:
src_addressthe MAC source address.
dst_addressthe MAC destination address.
ether_typethe EtherType protocol number.
payloadthe payload, everything after the MAC header.
packetthe return-by-reference packet prepared for transmission.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
void IoLink::recv_ethernet_packet ( const uint8_t *  packet,
size_t  packet_size 
) [protected]

Receved an Ethernet packet.

Parameters:
packetthe packet.
packet_sizethe size of the packet.
void IoLink::recv_packet ( const Mac src_address,
const Mac dst_address,
uint16_t  ether_type,
const vector< uint8_t > &  payload 
) [protected, virtual]

Received a link-level packet.

Parameters:
src_addressthe MAC source address.
dst_addressthe MAC destination address.
ether_typethe EtherType protocol number.
packetthe payload, everything after the MAC header.
void IoLink::register_io_link_receiver ( IoLinkReceiver io_link_receiver) [virtual]

Register the I/O Link raw packets receiver.

Parameters:
io_link_receiverthe receiver to register.
virtual int IoLink::send_packet ( const Mac src_address,
const Mac dst_address,
uint16_t  ether_type,
const vector< uint8_t > &  payload,
string &  error_msg 
) [pure virtual]

Send a link-level packet.

Parameters:
src_addressthe MAC source address.
dst_addressthe MAC destination address.
ether_typethe EtherType protocol number.
payloadthe payload, everything after the MAC header.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.

Implemented in IoLinkDummy, and IoLinkPcap.

void IoLink::set_log_trace ( bool  is_enabled) [inline]

Enable/disable trace log.

This method is used to enable/disable trace log debug messages output.

Parameters:
is_enabledif true, trace log is enabled, otherwise is disabled.
virtual int IoLink::start ( string &  error_msg) [pure virtual]

Start operation.

Parameters:
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.

Implemented in IoLinkDummy, and IoLinkPcap.

virtual int IoLink::stop ( string &  error_msg) [pure virtual]

Stop operation.

Parameters:
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.

Implemented in IoLinkDummy, and IoLinkPcap.

virtual const string& IoLink::vif_name ( ) const [inline, virtual]

Get the vif name.

Returns:
the vif name.

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations