 |
Kea
1.5.0
|
Go to the documentation of this file.
24 #include <boost/noncopyable.hpp>
25 #include <boost/shared_ptr.hpp>
69 typedef std::function<void(
const bool,
const std::string&,
const bool)>
PostSyncCallback;
328 template<
typename QueryPtrType>
329 bool inScopeInternal(QueryPtrType& query);
447 template<
typename QueryPtrType>
519 const std::string& server_name,
520 const unsigned int max_period,
533 const std::string& server_name,
610 const std::string& server_name,
611 const unsigned int max_period,
614 const bool dhcp_disabled =
false);
643 const std::string& server_name,
644 const unsigned int max_period,
647 const bool dhcp_disabled);
672 const unsigned int max_period);
689 int synchronize(std::string& status_message,
const std::string& server_name,
690 const unsigned int max_period);
boost::shared_ptr< NetworkState > NetworkStatePtr
Pointer to the NetworkState object.
bool inScope(dhcp::Pkt4Ptr &query4)
Checks if the DHCPv4 query should be processed by this server.
static const int HA_SYNCING_SUCCEEDED_EVT
Lease database synchroniation succeeded.
static const int HA_SYNCING_FAILED_EVT
Lease database synchronization failed.
std::function< void(const bool, const std::string &)> PostRequestCallback
Callback invoked when request was sent and a response received or an error occurred.
virtual void defineEvents()
Defines events used by the HA service.
std::map< boost::shared_ptr< dhcp::Pkt >, int > pending_requests_
Map holding a number of scheduled requests for a given packet.
static const int HA_HEARTBEAT_COMPLETE_EVT
Finished heartbeat commannd.
void syncingStateHandler()
Handler for "syncing" state.
http::HttpClient client_
HTTP client instance used to send lease updates.
void waitingStateHandler()
Handler for "waiting" state.
void verboseTransition(const unsigned state)
Transitions to a desired state and logs it.
void readyStateHandler()
Handler for "ready" state.
void asyncSyncLeases()
Asynchronously reads leases from a peer and updates local lease database.
void localDisableDHCPService()
Disables local DHCP service.
void localEnableDHCPService()
Enables local DHCP service.
void adjustNetworkState()
Enables or disables network state depending on the served scopes.
int synchronize(std::string &status_message, const std::string &server_name, const unsigned int max_period)
Synchronizes lease database with a partner.
CommunicationStatePtr communication_state_
Holds communication state with a peer.
std::function< void(const bool, const std::string &, const bool)> PostSyncCallback
Callback invoked when lease database synchronization is complete.
boost::shared_ptr< HttpResponse > HttpResponsePtr
Pointer to the HttpResponse object.
bool shouldPartnerDown() const
Indicates if the server should transition to the partner down state.
boost::shared_ptr< ParkingLotHandle > ParkingLotHandlePtr
Pointer to the parking lot handle.
void startHeartbeat()
Unconditionally starts one heartbeat to a peer.
Defines the logger used by the top-level component of kea-dhcp-ddns.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
void asyncSendLeaseUpdate(const QueryPtrType &query, const HAConfig::PeerConfigPtr &config, const data::ConstElementPtr &command, const hooks::ParkingLotHandlePtr &parking_lot)
Asynchronously sends lease update to the peer.
size_t asyncSendLeaseUpdates(const dhcp::Pkt4Ptr &query, const dhcp::Lease4CollectionPtr &leases, const dhcp::Lease4CollectionPtr &deleted_leases, const hooks::ParkingLotHandlePtr &parking_lot)
Schedules asynchronous IPv4 leases updates.
DHCP query filtering class.
data::ConstElementPtr processHeartbeat()
Processes ha-heartbeat command and returns a response.
boost::shared_ptr< Lease6Collection > Lease6CollectionPtr
A shared pointer to the collection of IPv6 leases.
void scheduleHeartbeat()
Schedules asynchronous heartbeat to a peer if it is not scheduled.
void backupStateHandler()
Handler for the "backup" state.
void asyncEnableDHCPService(http::HttpClient &http_client, const std::string &server_name, PostRequestCallback post_request_action)
Schedules asynchronous "dhcp-enable" command to the specified server.
data::ConstElementPtr processSynchronize(const std::string &server_name, const unsigned int max_period)
Processes ha-sync command and returns a response.
asiolink::IOServicePtr io_service_
Pointer to the IO service object shared between this hooks library and the DHCP server.
High availability service.
boost::shared_ptr< Lease > LeasePtr
Pointer to the lease object.
void serveDefaultScopes()
Instructs the HA service to serve default scopes.
HAServerType
Lists possible server types for which HA service is created.
boost::shared_ptr< Lease4Collection > Lease4CollectionPtr
A shared pointer to the collection of IPv4 leases.
boost::shared_ptr< HAService > HAServicePtr
Pointer to the HAService class.
bool unpause()
Unpauses the HA state machine with logging.
void conditionalLogPausedState() const
Logs if the server is paused in the current state.
data::ConstElementPtr verifyAsyncResponse(const http::HttpResponsePtr &response)
Checks if the response is valid or contains an error.
static const int HA_LEASE_UPDATES_COMPLETE_EVT
Finished lease updates commands.
HAServerType server_type_
DHCP server type.
static const int SM_DERIVED_EVENT_MIN
Value at which custom events in a derived class should begin.
QueryFilter query_filter_
Selects queries to be processed/dropped.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
bool shouldSendLeaseUpdates(const HAConfig::PeerConfigPtr &peer_config) const
Checks if the lease updates should be sent as result of leases allocation or release.
HAServerType getServerType() const
Returns HA server type used in object construction.
boost::shared_ptr< HAConfig > HAConfigPtr
Pointer to the High Availability configuration structure.
boost::shared_ptr< CommunicationState > CommunicationStatePtr
Type of the pointer to the CommunicationState object.
boost::shared_ptr< PeerConfig > PeerConfigPtr
Pointer to the server's configuration.
dhcp::NetworkStatePtr network_state_
Pointer to the state of the DHCP service (enabled/disabled).
void asyncSendHeartbeat()
Starts asynchronous heartbeat to a peer.
virtual void verifyEvents()
Verifies events used by the HA service.
data::ConstElementPtr processContinue()
Processes ha-continue command and returns a response.
data::ConstElementPtr processScopes(const std::vector< std::string > &scopes)
Processes ha-scopes command and returns a response.
HAService(const asiolink::IOServicePtr &io_service, const dhcp::NetworkStatePtr &network_state, const HAConfigPtr &config, const HAServerType &server_type=HAServerType::DHCPv4)
Constructor.
void asyncDisableDHCPService(http::HttpClient &http_client, const std::string &server_name, const unsigned int max_period, PostRequestCallback post_request_action)
Schedules asynchronous "dhcp-disable" command to the specified server.
boost::shared_ptr< const Element > ConstElementPtr
void partnerDownStateHandler()
Handler for "partner-down" state.
void asyncSyncLeasesInternal(http::HttpClient &http_client, const std::string &server_name, const unsigned int max_period, const dhcp::LeasePtr &last_lease, PostSyncCallback post_sync_action, const bool dhcp_disabled)
Implements fetching one page of leases during synchronization.
bool shouldTerminate() const
Indicates if the server should transition to the terminated state as a result of high clock skew.
virtual void defineStates()
Defines states of the HA service.
void normalStateHandler()
Handler for the "hot-standby" and "load-balancing" states.
Implements a finite state machine.
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
void terminatedStateHandler()
Handler for "terminated" state.
HAConfigPtr config_
Pointer to the HA hooks library configuration.