xorp

Vrrp Class Reference

VRRP protocol implementation. More...

#include <vrrp.hh>

List of all members.

Public Member Functions

 Vrrp (VrrpVif &vif, EventLoop &e, uint32_t vrid)
void set_priority (uint32_t priority)
 Set the priority of the router.
void set_interval (uint32_t interval)
 Set the advertisement interval.
void set_preempt (bool preempt)
 Set whether a high priority backup router should preempt backup routers with lower priority acting as masters.
void set_disable (bool disable)
 Stop or start this VRRP instance.
void add_ip (const IPv4 &ip)
 Add an IP to the virtual router.
void set_prefix (const IPv4 &ip, uint32_t prefix)
void delete_ip (const IPv4 &ip)
 Delete an IP from the virtual router.
bool running () const
 Check whether this instance is running.
uint32_t priority () const
 Obtain the priority of this router.
void start ()
 Start VRRP processing.
void stop ()
 Stop the protocol.
void recv (const IPv4 &from, const VrrpHeader &vh)
 Check whether the router owns all IPs configured for the virtual router.
void get_info (string &state, IPv4 &master) const
 Obtain an instance to the ARP daemon.

Static Public Attributes

static const Mac mcast_mac = Mac("01:00:5E:00:00:12")

Private Types

enum  State { INITIALIZE = 0, MASTER, BACKUP }
enum  { PRIORITY_LEAVE = 0, PRIORITY_OWN = 255 }
typedef set< IPv4IPS

Private Member Functions

void setup_intervals ()
 Calculate advertisement intervals based on protocol parameters.
void setup_timers (bool skew=false)
 Setup timers based on intervals.
void cancel_timers ()
 Stop all timers.
void send_arps ()
 Send gratuitous ARPs for all the IP addresses of this virtual router.
void send_arp (const IPv4 &ip)
 Send a gratitious ARP for a specific IP.
void send_advertisement (uint32_t priority)
 Send an advertisement with given priority.
void send_advertisement ()
 Send a VRRP advertisement.
void become_master ()
 Become the master router.
void become_backup ()
 Become a backup router.
bool master_down_expiry ()
 This is called when this router thinks the master router is dead.
bool adver_expiry ()
 This is called when the next advertisement should be sent.
void recv_adver_master (const IPv4 &from, uint32_t priority)
 Called when receiving an advertisement in the master state.
void recv_adver_backup (uint32_t priority)
 Called when an advertisement is received in the backup state.
void prepare_advertisement (uint32_t priority)
 Create the advertisement packet.
void recv_advertisement (const IPv4 &from, uint32_t priority)
 Notification of advertisement reception.
bool check_ips (const VrrpHeader &vh)
 Check whether the IPs in the VRRP packet match those configured.

Private Attributes

IPv4 _last_adv
VrrpVif_vif
uint32_t _vrid
uint32_t _priority
uint32_t _interval
double _skew_time
double _master_down_interval
bool _preempt
set< IPv4_ips
map< uint32_t, uint32_t > _prefixes
State _state
XorpTimer _master_down_timer
XorpTimer _adver_timer
bool _disable
VrrpPacket _adv_packet
Mac _source_mac

Detailed Description

VRRP protocol implementation.

This class implements the state machine of the VRRP protocol. It receive events and responds to them.


Constructor & Destructor Documentation

Vrrp::Vrrp ( VrrpVif vif,
EventLoop e,
uint32_t  vrid 
)
Parameters:
vifthe VRRP interface on which this instance is running.
eeventloop.
vridthe VRRP id of this instance.

Member Function Documentation

void Vrrp::add_ip ( const IPv4 ip)

Add an IP to the virtual router.

Parameters:
ipIP address to add to the virtual router.
bool Vrrp::adver_expiry ( ) [private]

This is called when the next advertisement should be sent.

Returns:
whether to renew the timer.
bool Vrrp::check_ips ( const VrrpHeader vh) [private]

Check whether the IPs in the VRRP packet match those configured.

Returns:
true on exact matches.
Parameters:
vhthe VRRP header.
void Vrrp::delete_ip ( const IPv4 ip)

Delete an IP from the virtual router.

Parameters:
ipIP address to remove from the virtual router.
void Vrrp::get_info ( string &  state,
IPv4 master 
) const

Obtain an instance to the ARP daemon.

Returns:
an instance of the ARP daemon. Returns information about the state of the protocol.
Parameters:
statethe state of the router (output parameter).
masterthe IP address of the master (output parameter).
bool Vrrp::master_down_expiry ( ) [private]

This is called when this router thinks the master router is dead.

That is, when the timer waiting for an advertisement expires.

Returns:
whether to reschedule the timer.
void Vrrp::prepare_advertisement ( uint32_t  priority) [private]

Create the advertisement packet.

Parameters:
prioritythe priority to be announced in the advertisement.
uint32_t Vrrp::priority ( ) const

Obtain the priority of this router.

Returns:
priority of router.
void Vrrp::recv ( const IPv4 from,
const VrrpHeader vh 
)

Check whether the router owns all IPs configured for the virtual router.

This must be called after updating IP addresses. Must be called when a VRRP packet is received.

Parameters:
fromIP address sending the packet.
vhthe VRRP packet received, starting from the VRRP header.
void Vrrp::recv_adver_backup ( uint32_t  priority) [private]

Called when an advertisement is received in the backup state.

Parameters:
prioritythe priority within the VRRP advertisement.
void Vrrp::recv_adver_master ( const IPv4 from,
uint32_t  priority 
) [private]

Called when receiving an advertisement in the master state.

Parameters:
fromthe IP that sent the advertisement.
prioritythe priority in the VRRP advertisement.
void Vrrp::recv_advertisement ( const IPv4 from,
uint32_t  priority 
) [private]

Notification of advertisement reception.

Parameters:
fromIP address of sender.
prioritythe priority in the VRRP header.
bool Vrrp::running ( ) const

Check whether this instance is running.

Returns:
whether this VRRP instance is running.
void Vrrp::send_advertisement ( uint32_t  priority) [private]

Send an advertisement with given priority.

Parameters:
priorityof the advertisement.
void Vrrp::send_advertisement ( ) [private]

Send a VRRP advertisement.

The parameters are taken from member variables.

void Vrrp::send_arp ( const IPv4 ip) [private]

Send a gratitious ARP for a specific IP.

Parameters:
ipthe IP address to send the ARP for.
void Vrrp::set_disable ( bool  disable)

Stop or start this VRRP instance.

Parameters:
disablestop this VRRP instance.
void Vrrp::set_interval ( uint32_t  interval)

Set the advertisement interval.

Parameters:
intervalthe interval for sending advertisements.
void Vrrp::set_preempt ( bool  preempt)

Set whether a high priority backup router should preempt backup routers with lower priority acting as masters.

Parameters:
preemptwhether a high priority backup should preempt a low one.
void Vrrp::set_priority ( uint32_t  priority)

Set the priority of the router.

Parameters:
prioritythe priority of this router.
void Vrrp::setup_intervals ( ) [private]

Calculate advertisement intervals based on protocol parameters.

This is called when any of these parameters (e.g., whether the router owns the IPs) change.

void Vrrp::setup_timers ( bool  skew = false) [private]

Setup timers based on intervals.

Must be called when intervals change.

Parameters:
skewwhether the skew time should be added when setting the timer.

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