Kea: isc::ha::CommunicationState4 Class Reference

| Kea 1.5.0

Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
isc::ha::CommunicationState4 Class Reference

Holds communication state between DHCPv4 servers. More...

`#include <communication_state.h>`

Inheritance diagram for isc::ha::CommunicationState4:
[legend]

## Public Member Functions
| CommunicationState4 (const asiolink::IOServicePtr &io_service, const HAConfigPtr &config)
| Constructor. More...
virtual void | analyzeMessage (const boost::shared_ptr< dhcp::Pkt > &message)
| Checks if the DHCPv4 message appears to be unanswered. More...
virtual bool | failureDetected () const
| Checks if the partner failure has been detected based on the DHCP traffic analysis. More...
Public Member Functions inherited from isc::ha::CommunicationState
| CommunicationState (const asiolink::IOServicePtr &io_service, const HAConfigPtr &config)
| Constructor. More...
virtual | ~CommunicationState ()
| Destructor. More...
bool | clockSkewShouldTerminate () const
| Indicates whether the HA service should enter "terminated" state as a result of the clock skew exceeding maximum value. More...
bool | clockSkewShouldWarn ()
| Indicates whether the HA service should issue a warning about high clock skew between the active servers. More...
int64_t | getDurationInMillisecs () const
| Returns duration between the poke time and current time. More...
int | getPartnerState () const
| Returns last known state of the partner. More...
bool | isCommunicationInterrupted () const
| Checks if communication with the partner is interrupted. More...
bool | isHeartbeatRunning () const
| Checks if recurring heartbeat is running. More...
std::string | logFormatClockSkew () const
| Returns current clock skew value in the logger friendly format. More...
void | poke ()
| Pokes the communication state. More...
void | setPartnerState (const std::string &state)
| Sets partner state. More...
void | setPartnerTime (const std::string &time_text)
| Provide partner's notion of time so the new clock skew can be calculated. More...
void | startHeartbeat (const long interval, const boost::function< void()> &heartbeat_impl)
| Starts recurring heartbeat (public interface). More...
void | stopHeartbeat ()
| Stops recurring heartbeat. More...

## Protected Member Functions
virtual void | clearUnackedClients ()
| Removes information about clients which the partner server failed to respond to. More...
Protected Member Functions inherited from isc::ha::CommunicationState
bool | isClockSkewGreater (const long seconds) const
| Checks if the clock skew is greater than the specified number of seconds. More...
void | startHeartbeatInternal (const long interval=0, const boost::function< void()> &heartbeat_impl=0)
| Starts recurring heartbeat. More...

## Protected Attributes
std::multimap< std::vector< uint8_t >, std::vector< uint8_t > > | unacked_clients_
| Holds information about the clients which the partner server failed to respond to. More...
Protected Attributes inherited from isc::ha::CommunicationState
boost::posix_time::time_duration | clock_skew_
| Clock skew between the active servers. More...
HAConfigPtr | config_
| High availability configuration. More...
boost::function< void()> | heartbeat_impl_
| Pointer to the function providing heartbeat implementation. More...
long | interval_
| Interval specified for the heartbeat. More...
asiolink::IOServicePtr | io_service_
| Pointer to the common IO service instance. More...
boost::posix_time::ptime | last_clock_skew_warn_
| Holds a time when last warning about too high clock skew was issued. More...
int | partner_state_
| Last known state of the partner server. More...
boost::posix_time::ptime | poke_time_
| Last poke time. More...
asiolink::IntervalTimerPtr | timer_
| Interval timer triggering heartbeat commands. More...

## Detailed Description

Holds communication state between DHCPv4 servers.

This class implements DHCPv4 failure detection by monitoring the value of the "secs" field in received DHCPv4 messages as described in `CommunicationState::analyzeMessage`.

Definition at line 331 of file communication_state.h.

## Constructor & Destructor Documentation

## ◆ CommunicationState4()

isc::ha::CommunicationState4::CommunicationState4 | ( | const asiolink::IOServicePtr & | io_service,
|  | const HAConfigPtr & | config
| ) |  |

Constructor.

Parameters

  io_service | pointer to the common IO service instance.
  config | pointer to the HA configuration.

Definition at line 241 of file communication_state.cc.

## Member Function Documentation

## ◆ analyzeMessage()

void isc::ha::CommunicationState4::analyzeMessage | ( | const boost::shared_ptr< dhcp::Pkt > & | message | ) |
| virtual

Checks if the DHCPv4 message appears to be unanswered.

This method uses "secs" field value for detecting client communication failures as described in the `CommunicationState::analyzeMessage`. Some misbehaving Windows clients were reported to swap "secs" field bytes. In this case the first byte is set to non-zero byte and the second byte is set to 0. This method handles such cases and corrects bytes order before comparing against the threshold.

Parameters

  message | DHCPv4 message to be analyzed. This must be the message which belongs to the partner, i.e. the caller must filter out messages belonging to the partner prior to calling this method.

Implements isc::ha::CommunicationState.

Definition at line 247 of file communication_state.cc.

References isc::ha::CommunicationState::config_, isc::dhcp::DHO_DHCP_CLIENT_IDENTIFIER, isc_throw, and unacked_clients_.

## ◆ clearUnackedClients()

void isc::ha::CommunicationState4::clearUnackedClients | ( |  | ) |
| protectedvirtual

Removes information about clients which the partner server failed to respond to.

See `CommunicationState::analyzeMessage` for details.

Implements isc::ha::CommunicationState.

Definition at line 306 of file communication_state.cc.

References unacked_clients_.

## ◆ failureDetected()

bool isc::ha::CommunicationState4::failureDetected | ( |  | ) | const
| virtual

Checks if the partner failure has been detected based on the DHCP traffic analysis.

Returns
  true if the partner failure has been detected, false otherwise.

Implements isc::ha::CommunicationState.

Definition at line 300 of file communication_state.cc.

References isc::ha::CommunicationState::config_, and unacked_clients_.

## Member Data Documentation

## ◆ unacked_clients_

std::multimap<std::vector<uint8_t>, std::vector<uint8_t> > isc::ha::CommunicationState4::unacked_clients_
| protected

Holds information about the clients which the partner server failed to respond to.

The key of the multimap holds hardware addresses of the clients. The value of the multimap holds client identifiers of the clients. The client identifiers may be empty.

Definition at line 378 of file communication_state.h.

Referenced by analyzeMessage(), clearUnackedClients(), and failureDetected().

The documentation for this class was generated from the following files:

- communication_state.h
- communication_state.cc