diff options
author | Francis Dupont <fdupont@isc.org> | 2018-05-11 16:35:04 +0200 |
---|---|---|
committer | Francis Dupont <fdupont@isc.org> | 2018-05-11 16:35:04 +0200 |
commit | f8a235791a8f8dbf7deb446fd7af13ce0f777ca6 (patch) | |
tree | a9a90ebfd6d5a5f5179367da664e5f9b13bf4183 /src/lib/dhcpsrv/cfg_subnets6.cc | |
parent | [master] MySQL support for shared lease stats implemented (diff) | |
download | kea-f8a235791a8f8dbf7deb446fd7af13ce0f777ca6.tar.xz kea-f8a235791a8f8dbf7deb446fd7af13ce0f777ca6.zip |
[5617] Moved selector init to library
Diffstat (limited to 'src/lib/dhcpsrv/cfg_subnets6.cc')
-rw-r--r-- | src/lib/dhcpsrv/cfg_subnets6.cc | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/lib/dhcpsrv/cfg_subnets6.cc b/src/lib/dhcpsrv/cfg_subnets6.cc index 9db6aa4fee..0d058b3954 100644 --- a/src/lib/dhcpsrv/cfg_subnets6.cc +++ b/src/lib/dhcpsrv/cfg_subnets6.cc @@ -1,16 +1,19 @@ -// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include <config.h> +#include <dhcp/dhcp6.h> +#include <dhcp/option_custom.h> #include <dhcpsrv/cfg_subnets6.h> #include <dhcpsrv/dhcpsrv_log.h> #include <dhcpsrv/lease_mgr_factory.h> #include <dhcpsrv/subnet_id.h> #include <dhcpsrv/addr_utilities.h> #include <stats/stats_mgr.h> +#include <boost/foreach.hpp> #include <string.h> #include <sstream> @@ -66,6 +69,32 @@ CfgSubnets6::getByPrefix(const std::string& subnet_text) const { return ((subnet_it != index.cend()) ? (*subnet_it) : ConstSubnet6Ptr()); } +SubnetSelector +CfgSubnets6::initSelector(const Pkt6Ptr& query) { + // Initialize subnet selector with the values used to select the subnet. + SubnetSelector selector; + selector.iface_name_ = query->getIface(); + selector.remote_address_ = query->getRemoteAddr(); + selector.first_relay_linkaddr_ = IOAddress("::"); + selector.client_classes_ = query->classes_; + + // Initialize fields specific to relayed messages. + if (!query->relay_info_.empty()) { + BOOST_REVERSE_FOREACH(Pkt6::RelayInfo relay, query->relay_info_) { + if (!relay.linkaddr_.isV6Zero() && + !relay.linkaddr_.isV6LinkLocal()) { + selector.first_relay_linkaddr_ = relay.linkaddr_; + break; + } + } + selector.interface_id_ = + query->getAnyRelayOption(D6O_INTERFACE_ID, + Pkt6::RELAY_GET_FIRST); + } + + return (selector); +} + Subnet6Ptr CfgSubnets6::selectSubnet(const SubnetSelector& selector) const { Subnet6Ptr subnet; |