xorp

IoIpManager Class Reference

A class that manages raw IP I/O. More...

#include <io_ip_manager.hh>

Inheritance diagram for IoIpManager:
IoIpManagerReceiver InstanceWatcher

List of all members.

Public Types

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

Public Member Functions

 IoIpManager (FeaNode &fea_node, const IfTree &iftree)
 Constructor for IoIpManager.
virtual ~IoIpManager ()
 Virtual destructor.
int send (const string &if_name, const string &vif_name, const IPvX &src_address, const IPvX &dst_address, uint8_t ip_protocol, int32_t ip_ttl, int32_t ip_tos, bool ip_router_alert, bool ip_internet_control, const vector< uint8_t > &ext_headers_type, const vector< vector< uint8_t > > &ext_headers_payload, const vector< uint8_t > &payload, string &error_msg)
 Send a raw IP packet.
int register_receiver (int family, const string &receiver_name, const string &if_name, const string &vif_name, uint8_t ip_protocol, bool enable_multicast_loopback, string &error_msg)
 Register to receive IP packets.
int unregister_receiver (int family, const string &receiver_name, const string &if_name, const string &vif_name, uint8_t ip_protocol, string &error_msg)
 Unregister to receive IP packets.
int join_multicast_group (const string &receiver_name, const string &if_name, const string &vif_name, uint8_t ip_protocol, const IPvX &group_address, string &error_msg)
 Join an IP multicast group.
int leave_multicast_group (const string &receiver_name, const string &if_name, const string &vif_name, uint8_t ip_protocol, const IPvX &group_address, string &error_msg)
 Leave an IP multicast group.
int leave_all_multicast_groups (const string &if_name, const string &vif_name, string &error_msg)
 Leave all multicast groups on this vif.
int register_system_multicast_upcall_receiver (int family, uint8_t ip_protocol, IoIpManager::UpcallReceiverCb receiver_cb, XorpFd &mcast_receiver_fd, string &error_msg)
 Register to receive multicast forwarding related upcalls from the system.
int unregister_system_multicast_upcall_receiver (int family, uint8_t ip_protocol, string &error_msg)
 Unregister to receive multicast forwarding related upcalls from the system.
void recv_event (const string &receiver_name, const struct IPvXHeaderInfo &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_ip_manager_receiver (IoIpManagerReceiver *v)
 Set the instance that is responsible for sending IP 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.

Private Types

typedef map< uint8_t, IoIpComm * > CommTable
typedef multimap< string,
IoIpComm::InputFilter * > 
FilterBag

Private Member Functions

CommTable & comm_table_by_family (int family)
 Get the CommTable for an address family.
FilterBag & filters_by_family (int family)
 Get the FilterBag for an address family.
void erase_filters_by_receiver_name (int family, 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.

Private Attributes

FeaNode_fea_node
EventLoop_eventloop
const IfTree_iftree
CommTable _comm_table4
CommTable _comm_table6
FilterBag _filters4
FilterBag _filters6
IoIpManagerReceiver_io_ip_manager_receiver
list< FeaDataPlaneManager * > _fea_data_plane_managers

Detailed Description

A class that manages raw IP I/O.

The IoIpManager has two containers: a container for IP protocol handlers (IoIpComm) 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 (IoIpComm) is created if necessary, then the relevent filter is created and associated with the IoIpComm.


Member Function Documentation

IoIpManager::CommTable & IoIpManager::comm_table_by_family ( int  family) [private]

Get the CommTable for an address family.

Parameters:
familythe address family.
Returns:
a reference to the CommTable for the address family.
void IoIpManager::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 IoIpManager::erase_filters_by_receiver_name ( int  family,
const string &  receiver_name 
) [private]

Erase filters for a given receiver name.

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

Get the list of registered data plane managers.

Returns:
the list of registered data plane managers.
IoIpManager::FilterBag & IoIpManager::filters_by_family ( int  family) [private]

Get the FilterBag for an address family.

Parameters:
familythe address family.
Returns:
a reference to the FilterBag for the address family.
bool IoIpManager::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& IoIpManager::iftree ( ) const [inline]

Get a reference to the interface tree.

Returns:
a reference to the interface tree (IfTree).
void IoIpManager::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 IoIpManager::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 IoIpManager::join_multicast_group ( const string &  receiver_name,
const string &  if_name,
const string &  vif_name,
uint8_t  ip_protocol,
const IPvX group_address,
string &  error_msg 
)

Join an IP 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.
ip_protocolthe IP protocol number that the receiver is interested in. It must be between 0 and 255. A protocol number of 0 is used to specify all protocols.
group_addressthe multicast group address to join.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int IoIpManager::leave_multicast_group ( const string &  receiver_name,
const string &  if_name,
const string &  vif_name,
uint8_t  ip_protocol,
const IPvX group_address,
string &  error_msg 
)

Leave an IP 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.
ip_protocolthe IP protocol number that the receiver is not interested in anymore. It must be between 0 and 255. A protocol number of 0 is used to specify all protocols.
group_addressthe multicast group address to leave.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
void IoIpManager::recv_event ( const string &  receiver_name,
const struct IPvXHeaderInfo header,
const vector< uint8_t > &  payload 
) [virtual]

Data received event.

Parameters:
receiver_namethe name of the receiver to send the IP packet to.
headerthe IP header information.
payloadthe payload, everything after the IP header and options.

Implements IoIpManagerReceiver.

int IoIpManager::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 IoIpManager::register_receiver ( int  family,
const string &  receiver_name,
const string &  if_name,
const string &  vif_name,
uint8_t  ip_protocol,
bool  enable_multicast_loopback,
string &  error_msg 
)

Register to receive IP packets.

Parameters:
familythe address family (AF_INET or AF_INET6 for IPv4 and IPv6 respectively).
receiver_namethe name of the receiver.
if_namethe interface through which packets should be accepted.
vif_namethe vif through which packets should be accepted.
ip_protocolthe IP protocol number that the receiver is interested in. It must be between 0 and 255. A protocol number of 0 is used to specify all protocols.
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 IoIpManager::register_system_multicast_upcall_receiver ( int  family,
uint8_t  ip_protocol,
IoIpManager::UpcallReceiverCb  receiver_cb,
XorpFd mcast_receiver_fd,
string &  error_msg 
)

Register to receive multicast forwarding related upcalls from the system.

Parameters:
familythe address family (AF_INET or AF_INET6 for IPv4 and IPv6 respectively).
ip_protocolthe IP protocol number that the receiver is interested in. It must be between 0 and 255. A protocol number of 0 is used to specify all protocols.
receiver_cbthe receiver callback to be invoked when an upcall is received.
receiver_fdthe return-by-reference file descriptor for the socket that receives the upcalls.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int IoIpManager::send ( const string &  if_name,
const string &  vif_name,
const IPvX src_address,
const IPvX dst_address,
uint8_t  ip_protocol,
int32_t  ip_ttl,
int32_t  ip_tos,
bool  ip_router_alert,
bool  ip_internet_control,
const vector< uint8_t > &  ext_headers_type,
const vector< vector< uint8_t > > &  ext_headers_payload,
const vector< uint8_t > &  payload,
string &  error_msg 
)

Send a raw IP packet.

Parameters:
if_namethe interface to send the packet on. It is essential for multicast. In the unicast case this field may be empty.
vif_namethe vif to send the packet on. It is essential for multicast. In the unicast case this field may be empty.
src_addressthe IP source address.
dst_addressthe IP destination address.
ip_protocolthe IP protocol number. It must be between 1 and 255.
ip_ttlthe IP TTL (hop-limit). If it has a negative value, the TTL will be set internally before transmission.
ip_tosthe Type Of Service (IP traffic class for IPv6). If it has a negative value, the TOS will be set internally before transmission.
ip_router_alertif true, then add the IP Router Alert option to the IP packet.
ip_internet_controlif true, then this is IP control traffic.
ext_headers_typea vector of integers with the types of the optional IPv6 extention headers.
ext_headers_payloada vector of payload data, one for each optional IPv6 extention header. The number of entries must match ext_headers_type.
payloadthe payload, everything after the IP header and options.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int IoIpManager::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 IoIpManager::unregister_receiver ( int  family,
const string &  receiver_name,
const string &  if_name,
const string &  vif_name,
uint8_t  ip_protocol,
string &  error_msg 
)

Unregister to receive IP packets.

Parameters:
familythe address family (AF_INET or AF_INET6 for IPv4 and IPv6 respectively).
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.
ip_protocolthe IP Protocol number that the receiver is not interested in anymore. It must be between 0 and 255. A protocol number of 0 is used to specify all protocols.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int IoIpManager::unregister_system_multicast_upcall_receiver ( int  family,
uint8_t  ip_protocol,
string &  error_msg 
)

Unregister to receive multicast forwarding related upcalls from the system.

Parameters:
familythe address family (AF_INET or AF_INET6 for IPv4 and IPv6 respectively).
ip_protocolthe IP Protocol number that the receiver is not interested in anymore. It must be between 0 and 255. A protocol number of 0 is used to specify all protocols.
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