xorp

IoLinkPcap Class Reference

A base class for I/O link raw pcap(3)-based communication. More...

#include <io_link_pcap.hh>

Inheritance diagram for IoLinkPcap:
IoLink

List of all members.

Public Member Functions

 IoLinkPcap (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 ~IoLinkPcap ()
 Virtual destructor.
int start (string &error_msg)
 Start operation.
int stop (string &error_msg)
 Stop operation.
int join_multicast_group (const Mac &group, string &error_msg)
 Join a multicast group on an interface.
int leave_multicast_group (const Mac &group, string &error_msg)
 Leave a multicast group on an interface.
int send_packet (const Mac &src_address, const Mac &dst_address, uint16_t ether_type, const vector< uint8_t > &payload, string &error_msg)
 Send a link-level packet.

Private Member Functions

int open_pcap_access (string &error_msg)
 Open the pcap access.
int close_pcap_access (string &error_msg)
 Close the pcap access.
int join_leave_multicast_group (bool is_join, const Mac &group, string &error_msg)
 Join or leave a multicast group on an interface.
void ioevent_read_cb (XorpFd fd, IoEventType type)
 Callback that is called when there data to read from the system.
void recv_data ()
 Read data from the system, and then call the appropriate module to process it.
int reopen_pcap_access (string &error_msg)
 Reopen the pcap access.

Private Attributes

XorpFd _packet_fd
pcap_t * _pcap
int _datalink_type
char * _pcap_errbuf
int _multicast_sock
XorpTask _recv_data_task

Detailed Description

A base class for I/O link raw pcap(3)-based communication.

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


Constructor & Destructor Documentation

IoLinkPcap::IoLinkPcap ( 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. The program uses tcpdump(1) style expression.

Member Function Documentation

int IoLinkPcap::close_pcap_access ( string &  error_msg) [private]

Close the pcap access.

Parameters:
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
void IoLinkPcap::ioevent_read_cb ( XorpFd  fd,
IoEventType  type 
) [private]

Callback that is called when there data to read from the system.

This is called as a IoEventCb callback.

Parameters:
fdfile descriptor that with event caused this method to be called.
typethe event type.
int IoLinkPcap::join_leave_multicast_group ( bool  is_join,
const Mac group,
string &  error_msg 
) [private]

Join or leave a multicast group on an interface.

Parameters:
is_joinif true, then join the group, otherwise leave.
groupthe multicast group to join/leave.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int IoLinkPcap::join_multicast_group ( const Mac group,
string &  error_msg 
) [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.

Implements IoLink.

int IoLinkPcap::leave_multicast_group ( const Mac group,
string &  error_msg 
) [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.

Implements IoLink.

int IoLinkPcap::open_pcap_access ( string &  error_msg) [private]

Open the pcap access.

Parameters:
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int IoLinkPcap::reopen_pcap_access ( string &  error_msg) [private]

Reopen the pcap access.

Parameters:
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int IoLinkPcap::send_packet ( const Mac src_address,
const Mac dst_address,
uint16_t  ether_type,
const vector< uint8_t > &  payload,
string &  error_msg 
) [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.

Implements IoLink.

int IoLinkPcap::start ( string &  error_msg) [virtual]

Start operation.

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

Implements IoLink.

int IoLinkPcap::stop ( string &  error_msg) [virtual]

Stop operation.

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

Implements IoLink.


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