diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc index 352fe8fc41..fca462ec94 100644 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@ -3075,6 +3075,18 @@ AllocEngine::ClientContext4::currentHost() const { return (ConstHostPtr()); } +ConstHostPtr +AllocEngine::ClientContext4::globalHost() const { + if (subnet_ && subnet_->getHostReservationMode() == Network::HR_GLOBAL) { + auto host = hosts_.find(SUBNET_ID_GLOBAL); + if (host != hosts_.cend()) { + return (host->second); + } + } + + return (ConstHostPtr()); +} + DdnsParamsPtr AllocEngine::ClientContext4::getDdnsParams() { // We already have it, return it. diff --git a/src/lib/dhcpsrv/alloc_engine.h b/src/lib/dhcpsrv/alloc_engine.h index cdce92a2f9..d18d64fcc2 100644 --- a/src/lib/dhcpsrv/alloc_engine.h +++ b/src/lib/dhcpsrv/alloc_engine.h @@ -1409,6 +1409,16 @@ public: /// @return Pointer to the host object. ConstHostPtr currentHost() const; + /// @brief Returns global host reservation if there is one + /// + /// If the current subnet's reservation mode is global and + /// there is a global host (i.e. reservation belonging to + /// the global subnet), return it. Otherwise return an + /// empty pointer. + /// + /// @return Pointer to the host object. + ConstHostPtr globalHost() const; + /// @brief Default constructor. ClientContext4();