xorp

VrrpTarget Class Reference

The VRRP XORP process. More...

#include <vrrp_target.hh>

Inheritance diagram for VrrpTarget:
XrlVrrpTargetBase IfMgrHintObserver

List of all members.

Public Member Functions

 VrrpTarget (XrlRouter &rtr)
bool running () const
 Check whether VRRP is running.
void tree_complete ()
 Called when the rtrmgr configuration is first received.
void updates_made ()
 Called when the rtrmgr configuration changed.
void send (const string &ifname, const string &vifname, const Mac &src, const Mac &dst, uint32_t ether, const PAYLOAD &payload)
 Transmit a L2 packet.
void join_mcast (const string &ifname, const string &vifname)
 Join the VRRP multicast group.
void leave_mcast (const string &ifname, const string &vifname)
 Leave the VRRP multicast group.
void start_arps (const string &ifname, const string &vifname)
 Start the reception of ARP packets on an interface.
void stop_arps (const string &ifname, const string &vifname)
 Stop the reception of ARPs.
void add_mac (const string &ifname, const Mac &mac)
 Add a MAC address to the router.
void delete_mac (const string &ifname, const Mac &mac)
 Delete MAC address from the router.
void add_ip (const string &ifname, const IPv4 &ip, uint32_t prefix)
void delete_ip (const string &ifname, const IPv4 &ip)
EventLoopeventloop ()

Static Public Attributes

static const string vrrp_target_name = "vrrp"
static const string fea_target_name = "fea"

Protected Member Functions

XrlCmdError common_0_1_get_target_name (string &name)
 Pure-virtual function that needs to be implemented to:
XrlCmdError common_0_1_get_version (string &version)
 Pure-virtual function that needs to be implemented to:
XrlCmdError common_0_1_get_status (uint32_t &status, string &reason)
 Pure-virtual function that needs to be implemented to:
XrlCmdError common_0_1_shutdown ()
 Pure-virtual function that needs to be implemented to:
XrlCmdError common_0_1_startup ()
 Pure-virtual function that needs to be implemented to:
XrlCmdError vrrp_0_1_add_vrid (const string &ifname, const string &vifname, const uint32_t &vrid)
 Pure-virtual function that needs to be implemented to:
XrlCmdError vrrp_0_1_delete_vrid (const string &ifname, const string &vifname, const uint32_t &vrid)
 Pure-virtual function that needs to be implemented to:
XrlCmdError vrrp_0_1_set_priority (const string &ifname, const string &vifname, const uint32_t &vrid, const uint32_t &priority)
 Pure-virtual function that needs to be implemented to:
XrlCmdError vrrp_0_1_set_interval (const string &ifname, const string &vifname, const uint32_t &vrid, const uint32_t &interval)
 Pure-virtual function that needs to be implemented to:
XrlCmdError vrrp_0_1_set_preempt (const string &ifname, const string &vifname, const uint32_t &vrid, const bool &preempt)
 Pure-virtual function that needs to be implemented to:
XrlCmdError vrrp_0_1_set_disable (const string &ifname, const string &vifname, const uint32_t &vrid, const bool &disable)
 Pure-virtual function that needs to be implemented to:
XrlCmdError vrrp_0_1_add_ip (const string &ifname, const string &vifname, const uint32_t &vrid, const IPv4 &ip)
 Pure-virtual function that needs to be implemented to:
XrlCmdError vrrp_0_1_set_prefix (const string &ifname, const string &vifname, const uint32_t &vrid, const IPv4 &ip, const uint32_t &prefix_len)
XrlCmdError vrrp_0_1_delete_ip (const string &ifname, const string &vifname, const uint32_t &vrid, const IPv4 &ip)
 Pure-virtual function that needs to be implemented to:
XrlCmdError vrrp_0_1_get_vrid_info (const string &ifname, const string &vifname, const uint32_t &vrid, string &state, IPv4 &master)
 Pure-virtual function that needs to be implemented to:
XrlCmdError vrrp_0_1_get_vrids (const string &ifname, const string &vifname, XrlAtomList &vrids)
 Pure-virtual function that needs to be implemented to:
XrlCmdError vrrp_0_1_get_ifs (XrlAtomList &ifs)
 Pure-virtual function that needs to be implemented to:
XrlCmdError vrrp_0_1_get_vifs (const string &ifname, XrlAtomList &vifs)
 Pure-virtual function that needs to be implemented to:
XrlCmdError raw_packet4_client_0_1_recv (const string &if_name, const string &vif_name, const IPv4 &src_address, const IPv4 &dst_address, const uint32_t &ip_protocol, const int32_t &ip_ttl, const int32_t &ip_tos, const bool &ip_router_alert, const bool &ip_internet_control, const vector< uint8_t > &payload)
 Pure-virtual function that needs to be implemented to:
XrlCmdError raw_link_client_0_1_recv (const string &if_name, const string &vif_name, const Mac &src_address, const Mac &dst_address, const uint32_t &ether_type, const vector< uint8_t > &payload)
 Pure-virtual function that needs to be implemented to:

Private Types

typedef map< string, VrrpVif * > VIFS
typedef map< string, VIFS * > IFS

Private Member Functions

void shutdown ()
 Terminate the VRRP process.
void start ()
 Start VRRP.
void check_interfaces ()
 Check whether rtrmgr configuration changes affect VRRP.
void check_vif (VrrpVif &vif)
 Check whether configuration changes affect a specific interface.
void add_vrid (const string &ifn, const string &vifn, uint32_t id)
 Add a VRRP instance.
void delete_vrid (const string &ifn, const string &vifn, uint32_t id)
 Delete a VRRP instance.
Vrrpfind_vrid (const string &ifn, const string &vifn, uint32_t id)
 Get a reference to a VRRP instance.
Vrrpfind_vrid_ptr (const string &ifn, const string &vifn, uint32_t id)
 Get a pointer to a VRRP instance.
VrrpViffind_vif (const string &ifn, const string &vifn, bool add=false)
 Get a pointer to a network interface.
void xrl_cb (const XrlError &xrl_error)
 The callback for all XRL operations.

Private Attributes

XrlRouter_rtr
bool _running
IFS _ifs
IfMgrXrlMirror _ifmgr
bool _ifmgr_setup
XrlRawLinkV0p1Client _rawlink
XrlRawPacket4V0p1Client _rawipv4
XrlIfmgrV0p1Client _fea
int _xrls_pending

Detailed Description

The VRRP XORP process.

This class manages all VRRP instances and provides a link between XRLs and the VRRP state machine.


Constructor & Destructor Documentation

VrrpTarget::VrrpTarget ( XrlRouter rtr)
Parameters:
rtrthe XRL router to use.

Member Function Documentation

void VrrpTarget::add_mac ( const string &  ifname,
const Mac mac 
)

Add a MAC address to the router.

Parameters:
ifnamethe interface on which to add the MAC.
macthe MAC address.
void VrrpTarget::add_vrid ( const string &  ifn,
const string &  vifn,
uint32_t  id 
) [private]

Add a VRRP instance.

Parameters:
ifninterface to run on.
vifnvif to run on.
idthe VRRP router id.
void VrrpTarget::check_vif ( VrrpVif vif) [private]

Check whether configuration changes affect a specific interface.

Parameters:
vifthe interface to check.
XrlCmdError VrrpTarget::common_0_1_get_status ( uint32_t &  status,
string &  reason 
) [protected, virtual]

Pure-virtual function that needs to be implemented to:

Get status of Xrl Target

Implements XrlVrrpTargetBase.

XrlCmdError VrrpTarget::common_0_1_get_target_name ( string &  name) [protected, virtual]

Pure-virtual function that needs to be implemented to:

Get name of Xrl Target

Implements XrlVrrpTargetBase.

XrlCmdError VrrpTarget::common_0_1_get_version ( string &  version) [protected, virtual]

Pure-virtual function that needs to be implemented to:

Get version string from Xrl Target

Implements XrlVrrpTargetBase.

XrlCmdError VrrpTarget::common_0_1_shutdown ( ) [protected, virtual]

Pure-virtual function that needs to be implemented to:

Request clean shutdown of Xrl Target

Implements XrlVrrpTargetBase.

XrlCmdError VrrpTarget::common_0_1_startup ( ) [protected, virtual]

Pure-virtual function that needs to be implemented to:

Request a startup of Xrl Target

Implements XrlVrrpTargetBase.

void VrrpTarget::delete_mac ( const string &  ifname,
const Mac mac 
)

Delete MAC address from the router.

Parameters:
ifnamethe interface on which the MAC should be deleted.
macthe MAC to remove.
void VrrpTarget::delete_vrid ( const string &  ifn,
const string &  vifn,
uint32_t  id 
) [private]

Delete a VRRP instance.

Parameters:
ifnthe interface on which the instance is running.
vifnthe vif on which it's running.
idthe VRRP router id.
EventLoop & VrrpTarget::eventloop ( )
Returns:
an instance of the eventloop.
VrrpVif * VrrpTarget::find_vif ( const string &  ifn,
const string &  vifn,
bool  add = false 
) [private]

Get a pointer to a network interface.

Null is returned if none is found and add is false. If none is found and add is true, the interface is created and a pointer to it is returned.

Returns:
the interface, or null if it is not found and add is false.
Parameters:
ifnthe physical interface name.
vifnthe logical interface name.
addwhether the interface should be added if it is not found.
Vrrp & VrrpTarget::find_vrid ( const string &  ifn,
const string &  vifn,
uint32_t  id 
) [private]

Get a reference to a VRRP instance.

An exception is thrown if the instance does not exist.

Returns:
the VRRP instance.
Parameters:
ifnthe interface on which it is running.
vifnthe vif on which it is running.
idthe VRRP id.
Vrrp * VrrpTarget::find_vrid_ptr ( const string &  ifn,
const string &  vifn,
uint32_t  id 
) [private]

Get a pointer to a VRRP instance.

Null is return if it does not exist.

Returns:
the VRRP instance or null if it is not present.
Parameters:
ifnthe interface on which the instance is running.
vifnthe vif on which it is running.
idthe VRRP id.
void VrrpTarget::join_mcast ( const string &  ifname,
const string &  vifname 
)

Join the VRRP multicast group.

Parameters:
ifnamethe interface on which to join.
vifnamethe vif on which to join.
void VrrpTarget::leave_mcast ( const string &  ifname,
const string &  vifname 
)

Leave the VRRP multicast group.

Parameters:
ifnamethe interface on which to join.
vifnamethe vif on which to join.
XrlCmdError VrrpTarget::raw_link_client_0_1_recv ( const string &  if_name,
const string &  vif_name,
const Mac src_address,
const Mac dst_address,
const uint32_t &  ether_type,
const vector< uint8_t > &  payload 
) [protected, virtual]

Pure-virtual function that needs to be implemented to:

Receive a raw link-level packet on an interface.

Parameters:
if_namethe interface name the packet arrived on.
vif_namethe vif name the packet arrived on.
src_addressthe MAC source address.
dst_addressthe MAC destination address.
ether_typethe EtherType protocol number 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 for IEEE 802.2 LLC frames.
payloadthe payload, everything after the MAC header.

Implements XrlVrrpTargetBase.

XrlCmdError VrrpTarget::raw_packet4_client_0_1_recv ( const string &  if_name,
const string &  vif_name,
const IPv4 src_address,
const IPv4 dst_address,
const uint32_t &  ip_protocol,
const int32_t &  ip_ttl,
const int32_t &  ip_tos,
const bool &  ip_router_alert,
const bool &  ip_internet_control,
const vector< uint8_t > &  payload 
) [protected, virtual]

Pure-virtual function that needs to be implemented to:

Receive an IPv4 packet from a raw socket.

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_protocolthe IP protocol number.
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.
payloadthe payload, everything after the IP header and options.

Implements XrlVrrpTargetBase.

bool VrrpTarget::running ( ) const

Check whether VRRP is running.

Returns:
whether the VRRP protocol is running.
void VrrpTarget::send ( const string &  ifname,
const string &  vifname,
const Mac src,
const Mac dst,
uint32_t  ether,
const PAYLOAD &  payload 
)

Transmit a L2 packet.

Parameters:
ifnamethe physical interface on which to transmit.
vifnamethe logical interface on which to transmit.
srcthe source MAC address.
dstthe destination MAC address.
etherthe 802.3 ethernet type.
payloadthe data to follow the MAC header.
void VrrpTarget::start_arps ( const string &  ifname,
const string &  vifname 
)

Start the reception of ARP packets on an interface.

Parameters:
ifnamethe interface on which to receive ARPs.
vifnamethe vif on which to get ARPs.
void VrrpTarget::stop_arps ( const string &  ifname,
const string &  vifname 
)

Stop the reception of ARPs.

Parameters:
ifnamethe interface on which to stop reception.
vifnamethe vif on which to stop reception.
XrlCmdError VrrpTarget::vrrp_0_1_add_ip ( const string &  ifname,
const string &  vifname,
const uint32_t &  vrid,
const IPv4 ip 
) [protected, virtual]

Pure-virtual function that needs to be implemented to:

Add an IP to the virtual router.

Parameters:
ifnamethe interface on which VRRP is running.
vifnamethe vif on which VRRP is running.
vridthe VRRP router ID.
ipthe IP address to add.

Implements XrlVrrpTargetBase.

XrlCmdError VrrpTarget::vrrp_0_1_add_vrid ( const string &  ifname,
const string &  vifname,
const uint32_t &  vrid 
) [protected, virtual]

Pure-virtual function that needs to be implemented to:

Create a VRRP instance.

Parameters:
ifnamethe interface name.
vifnamethe vif name.
vridthe VRRP router ID.

Implements XrlVrrpTargetBase.

XrlCmdError VrrpTarget::vrrp_0_1_delete_ip ( const string &  ifname,
const string &  vifname,
const uint32_t &  vrid,
const IPv4 ip 
) [protected, virtual]

Pure-virtual function that needs to be implemented to:

Remove an IP from the virtual router.

Parameters:
ifnamethe interface on which VRRP is running.
vifnamethe vif on which VRRP is running.
vridthe VRRP router ID.
ipthe IP address to remove.

Implements XrlVrrpTargetBase.

XrlCmdError VrrpTarget::vrrp_0_1_delete_vrid ( const string &  ifname,
const string &  vifname,
const uint32_t &  vrid 
) [protected, virtual]

Pure-virtual function that needs to be implemented to:

Remove a VRRP instance.

Parameters:
ifnamethe interface name.
vifnamethe vif name.
vridthe VRRP router ID.

Implements XrlVrrpTargetBase.

XrlCmdError VrrpTarget::vrrp_0_1_get_ifs ( XrlAtomList ifs) [protected, virtual]

Pure-virtual function that needs to be implemented to:

Get the physical interfaces on which VRRP is running.

Parameters:
ifsa list of interface names (strings).

Implements XrlVrrpTargetBase.

XrlCmdError VrrpTarget::vrrp_0_1_get_vifs ( const string &  ifname,
XrlAtomList vifs 
) [protected, virtual]

Pure-virtual function that needs to be implemented to:

For a given physical interface, get the virtual interfaces on which VRRP is running.

Parameters:
ifnamethe physical interface name.
vifsa list of virtual interface names (strings).

Implements XrlVrrpTargetBase.

XrlCmdError VrrpTarget::vrrp_0_1_get_vrid_info ( const string &  ifname,
const string &  vifname,
const uint32_t &  vrid,
string &  state,
IPv4 master 
) [protected, virtual]

Pure-virtual function that needs to be implemented to:

Get state information from a particular VRRP instance.

Parameters:
ifnamethe interface on which the VRRP instance is running.
vifnamethe vif on which the instance is running.
vridthe virtual router ID of the VRRP instance.
statethe state of the router (initialize, master, backup).
masterthe IP address of the master. Only valid when running.

Implements XrlVrrpTargetBase.

XrlCmdError VrrpTarget::vrrp_0_1_get_vrids ( const string &  ifname,
const string &  vifname,
XrlAtomList vrids 
) [protected, virtual]

Pure-virtual function that needs to be implemented to:

Get the virtual router IDs of all the VRRP instances running on a network interface.

Parameters:
ifnamethe physical interface name.
vifnamethe logical interface name.
vridsa list of VRRP router IDs (integers).

Implements XrlVrrpTargetBase.

XrlCmdError VrrpTarget::vrrp_0_1_set_disable ( const string &  ifname,
const string &  vifname,
const uint32_t &  vrid,
const bool &  disable 
) [protected, virtual]

Pure-virtual function that needs to be implemented to:

Start or stop a VRRP instance.

Parameters:
ifnamethe interface on which VRRP is running.
vifnamethe vif on which VRRP is running.
vridthe VRRP router ID.
disableif true, stop VRRP. Start it otherwise.

Implements XrlVrrpTargetBase.

XrlCmdError VrrpTarget::vrrp_0_1_set_interval ( const string &  ifname,
const string &  vifname,
const uint32_t &  vrid,
const uint32_t &  interval 
) [protected, virtual]

Pure-virtual function that needs to be implemented to:

Set the advertisement interval.

Parameters:
ifnamethe interface on which VRRP is running.
vifnamethe vif on which VRRP is running.
vridthe VRRP router ID.
intervalthe new advertisement interval.

Implements XrlVrrpTargetBase.

XrlCmdError VrrpTarget::vrrp_0_1_set_preempt ( const string &  ifname,
const string &  vifname,
const uint32_t &  vrid,
const bool &  preempt 
) [protected, virtual]

Pure-virtual function that needs to be implemented to:

Set whether a high priority backup router should preempt a low priority router that is acting as a master.

Parameters:
ifnamethe interface on which VRRP is running.
vifnamethe vif on which VRRP is running.
vridthe VRRP router ID.
preempttrue if preemption should occur.

Implements XrlVrrpTargetBase.

XrlCmdError VrrpTarget::vrrp_0_1_set_priority ( const string &  ifname,
const string &  vifname,
const uint32_t &  vrid,
const uint32_t &  priority 
) [protected, virtual]

Pure-virtual function that needs to be implemented to:

Set the router's priority.

Parameters:
ifnamethe interface on which VRRP is running.
vifnamethe vif on which VRRP is running.
vridthe VRRP router ID.
prioritythe new priority value.

Implements XrlVrrpTargetBase.

void VrrpTarget::xrl_cb ( const XrlError xrl_error) [private]

The callback for all XRL operations.

Parameters:
xrl_errorthe error (if any) of the operation.

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