xorp

IoLinkManager Class Reference

A class that manages raw link-level I/O. More...

#include <io_link_manager.hh>

Inheritance diagram for IoLinkManager:
IoLinkManagerReceiver InstanceWatcher

List of all members.

Classes

class  CommTableKey

Public Types

typedef XorpCallback2< int,
const uint8_t *, size_t >
::RefPtr 
UpcallReceiverCb

Public Member Functions

 IoLinkManager (FeaNode &fea_node, const IfTree &iftree)
 Constructor for IoLinkManager.
virtual ~IoLinkManager ()
 Virtual destructor.
int send (const string &if_name, const string &vif_name, const Mac &src_address, const Mac &dst_address, uint16_t ether_type, const vector< uint8_t > &payload, string &error_msg)
 Send a raw link-level packet on an interface.
int register_receiver (const string &receiver_name, const string &if_name, const string &vif_name, uint16_t ether_type, const string &filter_program, bool enable_multicast_loopback, string &error_msg)
 Register to receive raw link-level packets.
int unregister_receiver (const string &receiver_name, const string &if_name, const string &vif_name, uint16_t ether_type, const string &filter_program, string &error_msg)
 Unregister to receive raw link-level packets.
int join_multicast_group (const string &receiver_name, const string &if_name, const string &vif_name, uint16_t ether_type, const string &filter_program, const Mac &group_address, string &error_msg)
 Join a MAC multicast group.
int leave_multicast_group (const string &receiver_name, const string &if_name, const string &vif_name, uint16_t ether_type, const string &filter_program, const Mac &group_address, string &error_msg)
 Leave a MAC multicast group.
void recv_event (const string &receiver_name, const struct MacHeaderInfo &header, const vector< uint8_t > &payload)
 Data received event.
void instance_birth (const string &instance_name)
 Inform the watcher that a component instance is alive.
void instance_death (const string &instance_name)
 Inform the watcher that a component instance is dead.
void set_io_link_manager_receiver (IoLinkManagerReceiver *v)
 Set the instance that is responsible for sending raw link-level packets to a receiver.
const IfTreeiftree () const
 Get a reference to the interface tree.
int register_data_plane_manager (FeaDataPlaneManager *fea_data_plane_manager, bool is_exclusive)
 Register FeaDataPlaneManager data plane manager.
int unregister_data_plane_manager (FeaDataPlaneManager *fea_data_plane_manager)
 Unregister FeaDataPlaneManager data plane manager.
list< FeaDataPlaneManager * > & fea_data_plane_managers ()
 Get the list of registered data plane managers.
int add_multicast_mac (const string &if_name, const Mac &mac, string &error_msg)
 Add a multicast MAC address to an interface.
int remove_multicast_mac (const string &if_name, const Mac &mac, string &error_msg)
 Remove a multicast MAC address from an interface.

Private Types

typedef map< CommTableKey,
IoLinkComm * > 
CommTable
typedef multimap< string,
IoLinkComm::InputFilter * > 
FilterBag

Private Member Functions

void erase_filters_by_receiver_name (const string &receiver_name)
 Erase filters for a given receiver name.
bool has_filter_by_receiver_name (const string &receiver_name) const
 Test whether there is a filter for a given receiver name.
void erase_filters (CommTable &comm_table, FilterBag &filters, const FilterBag::iterator &begin, const FilterBag::iterator &end)
 Erase filters for a given CommTable and FilterBag.
IoLinkCommadd_iolink_comm_txonly (const string &if_name, const string &vif_name, uint16_t ether_type)
 Add a communication handler that can be used for raw link-level transmission only.
IoLinkCommfind_iolink_comm (const string &if_name, const string &vif_name, uint16_t ether_type)
 Find the communication handler for a given interface/vif name and EtherType.
int add_remove_multicast_mac (bool add, const string &if_name, const Mac &mac, string &error_msg)
 Add/remove a multicast MAC address on an interface.

Private Attributes

FeaNode_fea_node
EventLoop_eventloop
const IfTree_iftree
CommTable _comm_table
FilterBag _filters
IoLinkManagerReceiver_io_link_manager_receiver
list< FeaDataPlaneManager * > _fea_data_plane_managers

Detailed Description

A class that manages raw link-level I/O.

The IoLinkManager has two containers: a container for link-level handlers (IoLinkComm) indexed by the protocol associated with the handler, and a container for the filters associated with each receiver_name. When a receiver registers for interest in a particular type of raw packet a handler (IoLinkComm) is created if necessary, then the relevent filter is created and associated with the IoLinkComm.


Member Function Documentation

IoLinkComm & IoLinkManager::add_iolink_comm_txonly ( const string &  if_name,
const string &  vif_name,
uint16_t  ether_type 
) [private]

Add a communication handler that can be used for raw link-level transmission only.

Parameters:
if_namethe interface name.
vif_namethe vif name.
ether_typethe EtherType protocol number.
Returns:
a reference to the transmission only communication handler.
int IoLinkManager::add_multicast_mac ( const string &  if_name,
const Mac mac,
string &  error_msg 
)

Add a multicast MAC address to an interface.

Parameters:
if_namethe interface name.
macthe MAC address to add.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int IoLinkManager::add_remove_multicast_mac ( bool  add,
const string &  if_name,
const Mac mac,
string &  error_msg 
) [private]

Add/remove a multicast MAC address on an interface.

Parameters:
addif true, then add the address, otherwise remove it.
if_namethe interface name.
macthe MAC address to add/remove.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
void IoLinkManager::erase_filters ( CommTable &  comm_table,
FilterBag &  filters,
const FilterBag::iterator &  begin,
const FilterBag::iterator &  end 
) [private]

Erase filters for a given CommTable and FilterBag.

Parameters:
comm_tablethe associated CommTable.
filtersthe associated FilterBag.
beginthe begin iterator to the FilterBag for the set of filters to erase.
endthe end iterator to the FilterBag for the set of filters to erase.
void IoLinkManager::erase_filters_by_receiver_name ( const string &  receiver_name) [private]

Erase filters for a given receiver name.

Parameters:
receiver_namethe name of the receiver.
list<FeaDataPlaneManager*>& IoLinkManager::fea_data_plane_managers ( ) [inline]

Get the list of registered data plane managers.

Returns:
the list of registered data plane managers.
IoLinkComm & IoLinkManager::find_iolink_comm ( const string &  if_name,
const string &  vif_name,
uint16_t  ether_type 
) [private]

Find the communication handler for a given interface/vif name and EtherType.

Note that if the handler is not found, a new one is created and returned.

Parameters:
if_namethe interface name.
vif_namethe vif name.
ether_typethe EtherType protocol number.
Returns:
a reference to the communication handler.
bool IoLinkManager::has_filter_by_receiver_name ( const string &  receiver_name) const [private]

Test whether there is a filter for a given receiver name.

Parameters:
receiver_namethe name of the receiver.
Returns:
true if there is a filter for the given receiver name, otherwise false.
const IfTree& IoLinkManager::iftree ( ) const [inline]

Get a reference to the interface tree.

Returns:
a reference to the interface tree (IfTree).
void IoLinkManager::instance_birth ( const string &  instance_name) [virtual]

Inform the watcher that a component instance is alive.

Parameters:
instance_namethe name of the instance that is alive.

Implements InstanceWatcher.

void IoLinkManager::instance_death ( const string &  instance_name) [virtual]

Inform the watcher that a component instance is dead.

Parameters:
instance_namethe name of the instance that is dead.

Implements InstanceWatcher.

int IoLinkManager::join_multicast_group ( const string &  receiver_name,
const string &  if_name,
const string &  vif_name,
uint16_t  ether_type,
const string &  filter_program,
const Mac group_address,
string &  error_msg 
)

Join a MAC multicast group.

Parameters:
receiver_namethe name of the receiver.
if_namethe interface through which packets should be accepted.
vif_namethe vif through which packets should be accepted.
ether_typethe EtherType protocol number or the Destination SAP that the receiver is interested in. It must be between 1536 and 65535 to specify the EtherType, or between 1 and 255 to specify the Destination SAP for IEEE 802.2 LLC frames. A protocol number of 0 is used to specify all protocols.
filter_programthe optional filter program to be applied on the received packets. The program uses tcpdump(1) style expression.
group_addressthe multicast group address to join.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int IoLinkManager::leave_multicast_group ( const string &  receiver_name,
const string &  if_name,
const string &  vif_name,
uint16_t  ether_type,
const string &  filter_program,
const Mac group_address,
string &  error_msg 
)

Leave a MAC multicast group.

Parameters:
receiver_namethe name of the receiver.
if_namethe interface through which packets should not be accepted.
vif_namethe vif through which packets should not be accepted.
ether_typethe EtherType protocol number or the Destination SAP that the receiver is not interested in anymore. It must be between 1536 and 65535 to specify the EtherType, or between 1 and 255 to specify the Destination SAP for IEEE 802.2 LLC frames. A protocol number of 0 is used to specify all protocols.
filter_programthe filter program that was applied on the received packets. The program uses tcpdump(1) style expression.
group_addressthe multicast group address to leave.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
void IoLinkManager::recv_event ( const string &  receiver_name,
const struct MacHeaderInfo header,
const vector< uint8_t > &  payload 
) [virtual]

Data received event.

Parameters:
receiver_namethe name of the receiver to send the raw link-level packet to.
headerthe MAC header information.
payloadthe payload, everything after the MAC header.

Implements IoLinkManagerReceiver.

int IoLinkManager::register_data_plane_manager ( FeaDataPlaneManager fea_data_plane_manager,
bool  is_exclusive 
)

Register FeaDataPlaneManager data plane manager.

Parameters:
fea_data_plane_managerthe data plane manager to register.
is_exclusiveif true, the manager is registered as the exclusive manager, otherwise is added to the list of managers.
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int IoLinkManager::register_receiver ( const string &  receiver_name,
const string &  if_name,
const string &  vif_name,
uint16_t  ether_type,
const string &  filter_program,
bool  enable_multicast_loopback,
string &  error_msg 
)

Register to receive raw link-level packets.

Parameters:
receiver_namethe name of the receiver.
if_namethe interface through which packets should be accepted.
vif_namethe vif through which packets should be accepted.
ether_typethe EtherType protocol number or the Destination SAP that the receiver is interested in. It must be between 1536 and 65535 to specify the EtherType, or between 1 and 255 to specify the Destination SAP for IEEE 802.2 LLC frames. A protocol number of 0 is used to specify all protocols.
filter_programthe optional filter program to be applied on the received packets. The program uses tcpdump(1) style expression.
enable_multicast_loopbackif true then enable delivering of multicast datagrams back to this host (assuming the host is a member of the same multicast group.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int IoLinkManager::remove_multicast_mac ( const string &  if_name,
const Mac mac,
string &  error_msg 
)

Remove a multicast MAC address from an interface.

Parameters:
if_namethe interface name.
macthe MAC address to remove.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int IoLinkManager::send ( const string &  if_name,
const string &  vif_name,
const Mac src_address,
const Mac dst_address,
uint16_t  ether_type,
const vector< uint8_t > &  payload,
string &  error_msg 
)

Send a raw link-level packet on an interface.

Parameters:
if_namethe interface to send the packet on.
vif_namethe vif to send the packet on.
src_addressthe MAC source address.
dst_addressthe MAC destination address.
ether_typethe EtherType protocol type or the Destination SAP. It must be between 1536 and 65535 to specify the EtherType, or between 1 and 255 to specify the Destination SAP IEEE 802.2 LLC frames.
payloadthe payload, everything after the MAC header.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int IoLinkManager::unregister_data_plane_manager ( FeaDataPlaneManager fea_data_plane_manager)

Unregister FeaDataPlaneManager data plane manager.

Parameters:
fea_data_plane_managerthe data plane manager to unregister.
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int IoLinkManager::unregister_receiver ( const string &  receiver_name,
const string &  if_name,
const string &  vif_name,
uint16_t  ether_type,
const string &  filter_program,
string &  error_msg 
)

Unregister to receive raw link-level packets.

Parameters:
receiver_namethe name of the receiver.
if_namethe interface through which packets should not be accepted.
vif_namethe vif through which packets should not be accepted.
ether_typethe EtherType protocol number or the Destination SAP that the receiver is not interested in anymore. It must be between 1536 and 65535 to specify the EtherType, or between 1 and 255 to specify the Destination SAP for IEEE 802.2 LLC frames. A protocol number of 0 is used to specify all protocols.
filter_programthe filter program that was applied on the received packets. The program uses tcpdump(1) style expression.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.

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