xorp

IoIpComm Class Reference

A class that handles raw IP I/O communication for a specific protocol. More...

#include <io_ip_manager.hh>

Inheritance diagram for IoIpComm:
NONCOPYABLE IoIpReceiver

List of all members.

Classes

class  InputFilter
 Filter class. More...
class  JoinedMulticastGroup
 Joined multicast group class. More...

Public Member Functions

 IoIpComm (IoIpManager &io_ip_manager, const IfTree &iftree, int family, uint8_t ip_protocol)
 Constructor for IoIpComm.
virtual ~IoIpComm ()
 Virtual destructor.
void allocate_io_ip_plugins ()
 Allocate the I/O IP plugins (one per data plane manager).
void deallocate_io_ip_plugins ()
 Deallocate the I/O IP plugins (one per data plane manager).
void allocate_io_ip_plugin (FeaDataPlaneManager *fea_data_plane_manager)
 Allocate an I/O IP plugin for a given data plane manager.
void deallocate_io_ip_plugin (FeaDataPlaneManager *fea_data_plane_manager)
 Deallocate the I/O IP plugin for a given data plane manager.
void start_io_ip_plugins ()
 Start all I/O IP plugins.
void stop_io_ip_plugins ()
 Stop all I/O IP plugins.
int add_filter (InputFilter *filter)
 Add a filter to list of input filters.
int remove_filter (InputFilter *filter)
 Remove filter from list of input filters.
bool no_input_filters () const
int send_packet (const string &if_name, const string &vif_name, const IPvX &src_address, const IPvX &dst_address, 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.
virtual void recv_packet (const string &if_name, const string &vif_name, const IPvX &src_address, const IPvX &dst_address, 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)
 Received a raw IP packet.
virtual void recv_system_multicast_upcall (const vector< uint8_t > &payload)
 Received a multicast forwarding related upcall from the system.
int join_multicast_group (const string &if_name, const string &vif_name, const IPvX &group_address, const string &receiver_name, string &error_msg)
 Join an IP multicast group.
int leave_multicast_group (const string &if_name, const string &vif_name, const IPvX &group_address, const string &receiver_name, 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 IP multicast groups on this interface.
uint8_t ip_protocol () const
 Get the IP protocol.
XorpFd first_valid_mcast_protocol_fd_in ()
 Get the first valid file descriptor for receiving protocol messages.

Private Types

typedef list< pair
< FeaDataPlaneManager *, IoIp * > > 
IoIpPlugins
typedef map
< JoinedMulticastGroup,
JoinedMulticastGroup
JoinedGroupsTable

Private Member Functions

 IoIpComm (const IoIpComm &)
IoIpCommoperator= (const IoIpComm &)

Private Attributes

IoIpManager_io_ip_manager
const IfTree_iftree
const int _family
const uint8_t _ip_protocol
IoIpPlugins _io_ip_plugins
list< InputFilter * > _input_filters
JoinedGroupsTable _joined_groups_table

Detailed Description

A class that handles raw IP I/O communication for a specific protocol.

It also allows arbitrary filters to receive the raw IP data for that protocol.


Constructor & Destructor Documentation

IoIpComm::IoIpComm ( IoIpManager io_ip_manager,
const IfTree iftree,
int  family,
uint8_t  ip_protocol 
)

Constructor for IoIpComm.

Parameters:
io_ip_managerthe corresponding I/O IP manager (IoIpManager).
iftreethe interface tree to use.
familythe address family (AF_INET or AF_INET6 for IPv4 and IPv6 respectively).
ip_protocolthe IP protocol number (IPPROTO_*).

Member Function Documentation

int IoIpComm::add_filter ( InputFilter filter)

Add a filter to list of input filters.

The IoIpComm class assumes that the callee will be responsible for managing the memory associated with the filter and will call remove_filter() if the filter is deleted or goes out of scope.

Parameters:
filterthe filter to add.
Returns:
XORP_OK on success, otherwise XORP_ERROR.
void IoIpComm::allocate_io_ip_plugin ( FeaDataPlaneManager fea_data_plane_manager)

Allocate an I/O IP plugin for a given data plane manager.

Parameters:
fea_data_plane_managerthe data plane manager.
void IoIpComm::deallocate_io_ip_plugin ( FeaDataPlaneManager fea_data_plane_manager)

Deallocate the I/O IP plugin for a given data plane manager.

Parameters:
fea_data_plane_managerthe data plane manager.
XorpFd IoIpComm::first_valid_mcast_protocol_fd_in ( )

Get the first valid file descriptor for receiving protocol messages.

Returns:
the first valid file descriptor for receiving protocol messages.
uint8_t IoIpComm::ip_protocol ( ) const [inline]

Get the IP protocol.

Returns:
the IP protocol.
int IoIpComm::join_multicast_group ( const string &  if_name,
const string &  vif_name,
const IPvX group_address,
const string &  receiver_name,
string &  error_msg 
)

Join an IP multicast group.

Parameters:
if_namethe interface through which packets should be accepted.
vif_namethe vif through which packets should be accepted.
group_addressthe multicast group address to join.
receiver_namethe name of the receiver.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int IoIpComm::leave_all_multicast_groups ( const string &  if_name,
const string &  vif_name,
string &  error_msg 
)

Leave all IP multicast groups on this interface.

Parameters:
if_namethe interface through which packets should not be accepted.
vif_namethe vif through which packets should not be accepted.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int IoIpComm::leave_multicast_group ( const string &  if_name,
const string &  vif_name,
const IPvX group_address,
const string &  receiver_name,
string &  error_msg 
)

Leave an IP multicast group.

Parameters:
if_namethe interface through which packets should not be accepted.
vif_namethe vif through which packets should not be accepted.
group_addressthe multicast group address to leave.
receiver_namethe name of the receiver.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
bool IoIpComm::no_input_filters ( ) const [inline]
Returns:
true if there are no filters associated with this instance.
void IoIpComm::recv_packet ( const string &  if_name,
const string &  vif_name,
const IPvX src_address,
const IPvX dst_address,
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 
) [virtual]

Received a raw IP packet.

Parameters:
if_namethe interface name the packet arrived on.
vif_namethe vif name the packet arrived on.
src_addressthe IP source address.
dst_addressthe IP destination address.
ip_ttlthe IP TTL (hop-limit). If it has a negative value, then the received value is unknown.
ip_tosThe type of service (Diffserv/ECN bits for IPv4). If it has a negative value, then the received value is unknown.
ip_router_alertif true, the IP Router Alert option was included in 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.
packetthe payload, everything after the IP header and options.

Implements IoIpReceiver.

void IoIpComm::recv_system_multicast_upcall ( const vector< uint8_t > &  payload) [virtual]

Received a multicast forwarding related upcall from the system.

Examples of such upcalls are: "nocache", "wrongiif", "wholepkt", "bw_upcall".

Parameters:
payloadthe payload data for the upcall.

Implements IoIpReceiver.

int IoIpComm::remove_filter ( InputFilter filter)

Remove filter from list of input filters.

Parameters:
filterthe filter to remove.
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int IoIpComm::send_packet ( const string &  if_name,
const string &  vif_name,
const IPvX src_address,
const IPvX dst_address,
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_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.

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