#include <dhcpsrv/lease_mgr.h>
#include <dhcpsrv/lease_mgr_factory.h>
#include <dhcpsrv/subnet.h>
+#include <dhcpsrv/subnet_selector.h>
#include <dhcpsrv/utils.h>
#include <dhcpsrv/utils.h>
#include <hooks/callout_handle.h>
Subnet4Ptr subnet;
- CfgSubnets4::Selector selector;
+ SubnetSelector selector;
selector.ciaddr_ = question->getCiaddr();
selector.giaddr_ = question->getGiaddr();
selector.local_address_ = question->getLocalAddr();
namespace isc {
namespace dhcp {
-CfgSubnets4::Selector::Selector()
- : ciaddr_(ZERO_ADDRESS), giaddr_(ZERO_ADDRESS),
- local_address_(ZERO_ADDRESS), remote_address_(ZERO_ADDRESS),
- client_classes_(ClientClasses()), iface_name_(std::string()) {
-}
-
void
CfgSubnets4::add(const Subnet4Ptr& subnet) {
/// @todo: Check that this new subnet does not cross boundaries of any
}
Subnet4Ptr
-CfgSubnets4::selectSubnet(const Selector& selector) const {
+CfgSubnets4::selectSubnet(const SubnetSelector& selector) const {
// If relayed message has been received, try to match the giaddr with the
// relay address specified for a subnet. It is also possible that the relay
// address will not match with any of the relay addresses accross all
#include <asiolink/io_address.h>
#include <dhcpsrv/subnet.h>
+#include <dhcpsrv/subnet_selector.h>
#include <boost/shared_ptr.hpp>
namespace isc {
class CfgSubnets4 {
public:
- /// @brief Subnet selector used in @c CfgSubnets4::selectSubnet.
- ///
- /// This structure holds various parameters extracted from a packet sent
- /// by a DHCP client used to select the subnet for the client.
- struct Selector {
- /// @brief ciaddr from the client's message.
- asiolink::IOAddress ciaddr_;
- /// @brief giaddr from the client's message.
- asiolink::IOAddress giaddr_;
- /// @brief Address on which the message was received.
- asiolink::IOAddress local_address_;
- /// @brief Source address of the message.
- asiolink::IOAddress remote_address_;
- /// @brief Classes that the client belongs to.
- ClientClasses client_classes_;
- /// @brief Name of the interface on which the message was received.
- std::string iface_name_;
-
- /// @brief Default constructor.
- ///
- /// Sets the default values for the @c Selector.
- Selector();
- };
-
/// @brief Adds new subnet to the configuration.
///
/// @param subnet Pointer to the subnet being added.
/// @return Pointer to the selected subnet or NULL if no subnet found.
/// @throw isc::BadValue if the values in the subnet selector are invalid
/// or they are insufficient to select a subnet.
- Subnet4Ptr selectSubnet(const Selector& selector) const;
+ Subnet4Ptr selectSubnet(const SubnetSelector& selector) const;
/// @brief Returns pointer to a subnet if provided address is in its range.
///
/// This method returns a pointer to the subnet if the address passed in
/// parameter is in range with this subnet. This is mainly used for unit
- /// testing. This method is also called by the @c selectSubnet(Selector).
+ /// testing. This method is also called by the
+ /// @c selectSubnet(SubnetSelector).
///
/// @param address Address for which the subnet is searched.
/// @param client_classes Optional parameter specifying the classes that
#include <dhcpsrv/cfg_subnets4.h>
#include <dhcpsrv/subnet.h>
#include <dhcpsrv/subnet_id.h>
+#include <dhcpsrv/subnet_selector.h>
#include <gtest/gtest.h>
using namespace isc;
Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"), 26, 1, 2, 3));
// Make sure that initially the subnets don't exist.
- CfgSubnets4::Selector selector;
+ SubnetSelector selector;
selector.ciaddr_ = IOAddress("192.0.2.0");
// Set some unicast local address to simulate a Renew.
selector.local_address_ = IOAddress("10.0.0.100");
cfg.add(subnet2);
cfg.add(subnet3);
- CfgSubnets4::Selector selector;
+ SubnetSelector selector;
selector.local_address_ = IOAddress("10.0.0.10");
cfg.add(subnet2);
cfg.add(subnet3);
- CfgSubnets4::Selector selector;
+ SubnetSelector selector;
// Check that without relay-info specified, subnets are not selected
selector.giaddr_ = IOAddress("10.0.0.1");
Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"), 26, 1, 2, 3));
// Make sure that initially the subnets don't exist.
- CfgSubnets4::Selector selector;
+ SubnetSelector selector;
selector.remote_address_ = IOAddress("192.0.2.0");
// Set some unicast local address to simulate a Renew.
selector.local_address_ = IOAddress("10.0.0.100");
IfaceMgrTestConfig config(true);
CfgSubnets4 cfg;
- CfgSubnets4::Selector selector;
+ SubnetSelector selector;
// Initially, there are no subnets configured, so none of the IPv4
// addresses assigned to eth0 and eth1 can match with any subnet.