17const string DHCP4_SPACE = 
"dhcp4";
 
   18const string DHCP6_SPACE = 
"dhcp6";
 
   28    if (!subnets || subnets->empty()) {
 
   38    for (
ElementPtr const& subnet : subnets->listValue()) {
 
 
   49                                       const string& subsel) {
 
   50    if (!networks || networks->empty()) {
 
   60    for (
size_t i = 0; i < networks->size(); ++i) {
 
   64            if (!subnets->empty()) {
 
   72                network->remove(subsel);
 
 
   82    if (!subnets || subnets->empty()) {
 
   87    for (
size_t i = 0; i < subnets->size(); ++i) {
 
 
   96                                      const string& subsel) {
 
   97    if (!networks || networks->empty()) {
 
  102    for (
ElementPtr const& network : networks->listValue()) {
 
  104        if (!subnets || subnets->empty()) {
 
  108        for (
size_t i = 0; i < subnets->size(); ++i) {
 
 
  117    if (!pools || pools->empty()) {
 
  124    for (
size_t i = 0; i < pools->size(); ++i) {
 
 
  132    if (!subnets || subnets->empty()) {
 
  137    for (
ElementPtr const& subnet : subnets->listValue()) {
 
 
  144                                             const string& subsel) {
 
  145    if (!networks || networks->empty()) {
 
  150    for (
ElementPtr const& network : networks->listValue()) {
 
 
  159    if (!defs || defs->empty()) {
 
  166    for (
size_t i = 0; i < defs->size(); ++i) {
 
 
  179    if (!options || options->empty()) {
 
  186    for (
size_t i = 0; i < options->size(); ++i) {
 
  191        if (classes && classes->empty()) {
 
  192            option->remove(
"client-classes");
 
 
  201    if (!classes || classes->empty()) {
 
  207    for (
size_t i = 0; i < classes->size(); ++i) {
 
  210        if (space == DHCP4_SPACE) {
 
  213                if (!options->empty()) {
 
  218                    cclass->remove(
"option-def");
 
  226            if (!options->empty()) {
 
  231                cclass->remove(
"option-data");
 
 
  240    if (!pools || pools->empty()) {
 
  245    for (
size_t i = 0; i < pools->size(); ++i) {
 
  249            if (!options->empty()) {
 
  252                pool->remove(
"option-data");
 
 
  261    if (!hosts || hosts->empty()) {
 
  266    for (
size_t i = 0; i < hosts->size(); ++i) {
 
  270            if (!options->empty()) {
 
  273                host->remove(
"option-data");
 
 
  283    if (!subnets || subnets->empty()) {
 
  288    for (
size_t i = 0; i < subnets->size(); ++i) {
 
  294            if (!options->empty()) {
 
  297                subnet->remove(
"option-data");
 
  304            if (!pools->empty()) {
 
  307                subnet->remove(
"pools");
 
  312        if (space == DHCP6_SPACE) {
 
  315                if (!pd_pools->empty()) {
 
  318                    subnet->remove(
"pd-pools");
 
  326            if (!hosts->empty()) {
 
  329                subnet->remove(
"reservations");
 
 
  339    if (!networks || networks->empty()) {
 
  345    for (
size_t i = 0; i < networks->size(); ++i) {
 
  346        ElementPtr network = networks->getNonConst(i);
 
  351            if (!options->empty()) {
 
  354                network->remove(
"option-data");
 
  357        string subnet = 
"subnet";
 
  358        if (space == DHCP4_SPACE) {
 
  367            if (!subnets->empty()) {
 
  370                network->remove(subnet);
 
 
  378    if (!pools || pools->empty()) {
 
  383    for (
size_t i = 0; i < pools->size(); ++i) {
 
  386        if (require && require->empty()) {
 
  387            pool->remove(
"require-client-classes");
 
  389        require = pool->get(
"evaluate-additional-classes");
 
  390        if (require && require->empty()) {
 
  391            pool->remove(
"evaluate-additional-classes");
 
  394        if (classes && classes->empty()) {
 
  395            pool->remove(
"client-class");
 
  397        classes = pool->get(
"client-classes");
 
  398        if (classes && classes->empty()) {
 
  399            pool->remove(
"client-classes");
 
 
  406    if (!subnets || subnets->empty()) {
 
  411    for (
size_t i = 0; i < subnets->size(); ++i) {
 
  416        if (require && require->empty()) {
 
  417            subnet->remove(
"require-client-classes");
 
  419        require = subnet->get(
"evaluate-additional-classes");
 
  420        if (require && require->empty()) {
 
  421            subnet->remove(
"evaluate-additional-classes");
 
  424        if (classes && classes->empty()) {
 
  425            subnet->remove(
"client-class");
 
  427        classes = subnet->get(
"client-classes");
 
  428        if (classes && classes->empty()) {
 
  429            subnet->remove(
"client-classes");
 
 
  436                                               const string& subsel) {
 
  437    if (!networks || networks->empty()) {
 
  442    for (
size_t i = 0; i < networks->size(); ++i) {
 
  443        ElementPtr network = networks->getNonConst(i);
 
  446        if (require && require->empty()) {
 
  447            network->remove(
"require-client-classes");
 
  449        require = network->get(
"evaluate-additional-classes");
 
  450        if (require && require->empty()) {
 
  451            network->remove(
"evaluate-additional-classes");
 
  454        if (classes && classes->empty()) {
 
  455            network->remove(
"client-class");
 
  457        classes = network->get(
"client-classes");
 
  458        if (classes && classes->empty()) {
 
  459            network->remove(
"client-classes");
 
 
  467    if (!hosts || hosts->empty()) {
 
  472    for (
size_t i = 0; i < hosts->size(); ++i) {
 
 
  481    if (!subnets || subnets->empty()) {
 
  486    for (
ElementPtr const& subnet : subnets->listValue()) {
 
 
  493                                  const string& space) {
 
  494    if (!networks || networks->empty()) {
 
  499    for (
ElementPtr const& network : networks->listValue()) {
 
  500        if (space == DHCP4_SPACE) {
 
 
  510    if (!subnets || subnets->empty()) {
 
  515    for (
size_t i = 0; i < subnets->size(); ++i) {
 
 
  523                                   const string& subsel) {
 
  524    if (!networks || networks->empty()) {
 
  529    for (
size_t i = 0; i < networks->size(); ++i) {
 
  530        ElementPtr network = networks->getNonConst(i);
 
 
  544    dhcp->remove(
"hosts-database");
 
  546    list->add(
copy(database, 0));
 
  547    dhcp->set(
"hosts-databases", list);
 
 
  553    if (!options || !options->empty()) {
 
  557    dhcp->remove(
"relay-supplied-options");
 
 
  562                          const string& space) {
 
  566    bool have_ids = 
true;
 
  570        if (!subnets->empty()) {
 
  575            dhcp->remove(subsel);
 
  580        if (!networks->empty()) {
 
  585            dhcp->remove(
"shared-networks");
 
  599        if (!defs->empty()) {
 
  602            dhcp->remove(
"option-def");
 
  607        if (!options->empty()) {
 
  610            dhcp->remove(
"option-data");
 
  615        if (!classes->empty()) {
 
  618            dhcp->remove(
"client-classes");
 
  623        if (!hosts->empty()) {
 
  627            dhcp->remove(
"reservations");
 
  647    if (space == DHCP6_SPACE) {
 
 
  660    if (
config->contains(
"Logging")) {
 
  668    preProcess(mutable_dhcp, 
"subnet4", DHCP4_SPACE);
 
  669    config->set(
"Dhcp4", mutable_dhcp);
 
 
  680    if (
config->contains(
"Logging")) {
 
  688    preProcess(mutable_dhcp, 
"subnet6", DHCP6_SPACE);
 
  689    config->set(
"Dhcp6", mutable_dhcp);
 
 
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
static void subnetsAssignID(isc::data::ConstElementPtr subnets, isc::dhcp::SubnetIDSet &set, isc::dhcp::SubnetID &next)
Assigns subnet-id to every subnet in a subnet list.
static void sanitizeOptionSharedNetworks(isc::data::ConstElementPtr networks, const std::string &space, const OptionCodes &codes)
Set missing option codes to a shared network list.
static void sharedNetworksAssignID(isc::data::ConstElementPtr networks, isc::dhcp::SubnetIDSet &set, isc::dhcp::SubnetID &next, const std::string &subsel)
Assigns subnet-id to every subnet in a shared network list.
static void sanitizeEmptyListPools(isc::data::ConstElementPtr pools)
Process empty lists in a pool list.
static void sanitizeEmptyListSharedNetworks(isc::data::ConstElementPtr networks, const std::string &subsel)
Process empty lists in a shared-network list.
static void sanitizeRelaySubnets(isc::data::ConstElementPtr subnets)
Sanitizes relay information in subnets in a subnet list.
static void sanitizeHostSubnets(isc::data::ConstElementPtr subnets)
Process host reservations in a subnet list.
static bool subnetsCollectID(isc::data::ConstElementPtr subnets, isc::dhcp::SubnetIDSet &set)
Collects subnet-ids on all subnets.
static void preProcess4(isc::data::ElementPtr config)
Pre process a DHCPv4 configuration.
static void sanitizeOptionPools(isc::data::ConstElementPtr pools, const std::string &space, const OptionCodes &codes)
Set missing option codes to a pool list.
static void preProcess(isc::data::ElementPtr dhcp, const std::string &subsel, const std::string &space)
Pre process a configuration.
static void sanitizePoolsInSubnets(isc::data::ConstElementPtr subnets)
Sanitizes all pools in a subnets list.
static void sanitizeDatabase(isc::data::ElementPtr dhcp)
Update (hosts) database.
static void sanitizeOptionHosts(isc::data::ConstElementPtr hosts, const std::string &space, const OptionCodes &codes)
Set missing option codes to a host reservation list.
static void sanitizeHostList(isc::data::ConstElementPtr hosts)
Process host reservation list.
static void SanitizeHostsInSharedNetworks(isc::data::ConstElementPtr networks, const std::string &space)
Process host reservations in a shared network list.
static void sanitizeOptionDefList(isc::data::ConstElementPtr defs, const std::string &space, OptionCodes &codes)
Collect option definitions from an option definition list.
static void sanitizeEmptyListSubnets(isc::data::ConstElementPtr subnets)
Process empty lists in a subnet list.
static void sanitizeOptionSubnets(isc::data::ConstElementPtr subnets, const std::string &space, const OptionCodes &codes)
Set missing option codes to a subnet list.
static void sanitizePools(isc::data::ConstElementPtr pools)
Sanitizes all pools in a pools list.
static void sanitizePoolsInSharedNetworks(isc::data::ConstElementPtr networks, const std::string &subsel)
Sanitizes all pools in all subnets in a shared network list.
static void sanitizeOptionClasses(isc::data::ConstElementPtr classes, const std::string &space, OptionCodes &codes)
Collect option definitions from a client class list and set missing option codes.
static void preProcess6(isc::data::ElementPtr config)
Pre process a DHCPv6 configuration.
static void sanitizeRelaySuppliedOptions(isc::data::ElementPtr dhcp)
Update relay supplied options.
static void sanitizeOptionDataList(isc::data::ConstElementPtr options, const std::string &space, const OptionCodes &codes)
Set missing option codes to an option data list.
static void sanitizeRelayInSharedNetworks(isc::data::ConstElementPtr networks, const std::string &subsel)
Sanitizes relay information in a shared network list.
static bool sharedNetworksCollectID(isc::data::ConstElementPtr networks, isc::dhcp::SubnetIDSet &set, const std::string &subsel)
Collects subnet-ids in all subnets in all shared network list.
static void quoteIdentifier(isc::data::ElementPtr host)
Quote when needed a host identifier.
static void setCode(isc::data::ElementPtr option, const OptionCodes &codes)
Set code from name and definitions.
static void initCodes(OptionCodes &codes, const std::string &space)
Initialize code map.
static void setSpace(isc::data::ElementPtr option, const std::string &space)
Set space.
static void checkType(isc::data::ConstElementPtr option)
Checks if type is specified in option definition.
static void collect(isc::data::ConstElementPtr option, OptionCodes &codes)
Collect definition.
static void checkCode(isc::data::ConstElementPtr option)
Check if code is specified in option defintion.
static void canonizePool(isc::data::ElementPtr pool)
Canonize pool.
static void assignID(isc::data::ElementPtr subnet, isc::dhcp::SubnetIDSet &set, isc::dhcp::SubnetID &next)
Assign subnet ID.
static bool collectID(isc::data::ConstElementPtr subnet, isc::dhcp::SubnetIDSet &set)
Collect a subnet ID.
static void updateRelay(isc::data::ElementPtr subnet)
Update relay.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
std::set< dhcp::SubnetID > SubnetIDSet
Ordered list aka set of subnetIDs.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
std::unordered_map< std::string, uint16_t > OptionCodes
Map for DHCP option definitions handling code and an index built from space and name.
Defines the logger used by the top-level component of kea-lfc.