]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2559] Merge branch 'master' into trac2559
authorStephen Morris <stephen@isc.org>
Mon, 21 Jan 2013 20:57:57 +0000 (20:57 +0000)
committerStephen Morris <stephen@isc.org>
Mon, 21 Jan 2013 20:57:57 +0000 (20:57 +0000)
Conflicts:
src/bin/dhcp4/config_parser.cc
src/bin/dhcp6/config_parser.cc
src/bin/dhcp6/dhcp6_srv.h
src/lib/dhcpsrv/dhcpsrv_messages.mes
src/lib/dhcpsrv/tests/Makefile.am

15 files changed:
1  2 
src/bin/dhcp4/config_parser.cc
src/bin/dhcp4/dhcp4.spec
src/bin/dhcp4/dhcp4_messages.mes
src/bin/dhcp6/config_parser.cc
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/dhcp6.spec
src/bin/dhcp6/dhcp6_messages.mes
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/dhcp6_srv.h
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
src/lib/dhcpsrv/Makefile.am
src/lib/dhcpsrv/dhcp_config_parser.h
src/lib/dhcpsrv/dhcpsrv_messages.mes
src/lib/dhcpsrv/memfile_lease_mgr.cc
src/lib/dhcpsrv/tests/Makefile.am

index c067a6feff201b68e368751dcd916c162977941c,fdb4240375665f67d1eb152202360a96d7037eff..6ce23f52ceb08982b1be61ccd7fcec83b66c0d67
@@@ -18,8 -18,8 +18,9 @@@
  #include <dhcp/libdhcp++.h>
  #include <dhcp/option_definition.h>
  #include <dhcpsrv/cfgmgr.h>
 +#include <dhcpsrv/dbaccess_parser.h>
  #include <dhcpsrv/dhcp_config_parser.h>
+ #include <dhcpsrv/option_space_container.h>
  #include <util/encode/hex.h>
  #include <util/strutil.h>
  #include <boost/foreach.hpp>
@@@ -38,6 -38,20 +39,17 @@@ using namespace isc::asiolink
  
  namespace {
  
 -/// @brief auxiliary type used for storing element name and its parser
 -typedef pair<string, ConstElementPtr> ConfigPair;
 -
+ // Forward declarations of some of the parser classes.
+ // They are used to define pointer types for these classes.
+ class BooleanParser;
+ class StringParser;
+ class Uint32Parser;
+ // Pointers to various parser objects.
+ typedef boost::shared_ptr<BooleanParser> BooleanParserPtr;
+ typedef boost::shared_ptr<StringParser> StringParserPtr;
+ typedef boost::shared_ptr<Uint32Parser> Uint32ParserPtr;
  /// @brief a factory method that will create a parser for a given element name
  typedef isc::dhcp::DhcpConfigParser* ParserFactory(const std::string& config_id);
  
@@@ -1317,8 -1605,8 +1603,9 @@@ DhcpConfigParser* createGlobalDhcp4Conf
      factories["interface"] = InterfaceListConfigParser::factory;
      factories["subnet4"] = Subnets4ListConfigParser::factory;
      factories["option-data"] = OptionDataListParser::factory;
+     factories["option-def"] = OptionDefListParser::factory;
      factories["version"] = StringParser::factory;
 +    factories["lease-database"] = DbAccessParser::factory;
  
      FactoryMap::iterator f = factories.find(config_id);
      if (f == factories.end()) {
@@@ -1372,20 -1661,22 +1660,27 @@@ configureDhcp4Server(Dhcpv4Srv&, ConstE
      // rollback informs whether error occured and original data
      // have to be restored to global storages.
      bool rollback = false;
 -
 +    // config_pair holds the details of the current parser when iterating over
-     // parser.  It is declared outside the loops so in case of an error, the
-     // name of the failing parser can be retrieved in the "catch" clause.
++    // the parsers.  It is declared outside the loops so in case of an error,
++    // the name of the failing parser can be retrieved in the "catch" clause.
 +    ConfigPair config_pair;
      try {
 -        BOOST_FOREACH(ConfigPair config_pair, values_map) {
+         // Make parsers grouping.
+         const std::map<std::string, ConstElementPtr>& values_map =
+             config_set->mapValue();
++        BOOST_FOREACH(config_pair, values_map) {
+             ParserPtr parser(createGlobalDhcp4ConfigParser(config_pair.first));
++            LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, DHCP4_PARSER_CREATED)
++                      .arg(config_pair.first);
+             if (config_pair.first == "subnet4") {
+                 subnet_parser = parser;
  
-         // Iterate over all independent parsers first (all but subnet4)
-         // and try to parse the data.
-         BOOST_FOREACH(config_pair, config_set->mapValue()) {
-             if (config_pair.first != "subnet4") {
-                 ParserPtr parser(createGlobalDhcp4ConfigParser(
-                                      config_pair.first));
-                 LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, DHCP4_PARSER_CREATED1)
-                           .arg(config_pair.first);
+             } else if (config_pair.first == "option-data") {
+                 option_parser = parser;
+             } else {
+                 // Those parsers should be started before other
+                 // parsers so we can call build straight away.
                  independent_parsers.push_back(parser);
                  parser->build(config_pair.second);
                  // The commit operation here may modify the global storage
          }
  
      } catch (const isc::Exception& ex) {
 -        answer =
 -            isc::config::createAnswer(1, string("Configuration parsing failed: ") + ex.what());
 +        LOG_ERROR(dhcp4_logger, DHCP4_PARSER_CREATE_FAIL)
 +                  .arg(config_pair.first).arg(ex.what());
 +        answer = isc::config::createAnswer(1,
 +                     string("Configuration parsing failed: ") + ex.what());
          // An error occured, so make sure that we restore original data.
          rollback = true;
  
      } catch (...) {
          // for things like bad_cast in boost::lexical_cast
 -        answer =
 -            isc::config::createAnswer(1, string("Configuration parsing failed"));
 +        LOG_ERROR(dhcp4_logger, DHCP4_PARSER_CREATE_EXCEPTION)
 +                  .arg(config_pair.first);
 +        answer = isc::config::createAnswer(1,
 +                     string("Configuration parsing failed"));
          // An error occured, so make sure that we restore original data.
          rollback = true;
      }
              }
          }
          catch (const isc::Exception& ex) {
 -            answer =
 -                isc::config::createAnswer(2, string("Configuration commit failed: ") + ex.what());
 +            LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg(ex.what());
-             answer =
-                 isc::config::createAnswer(2, string("Configuration commit failed: ") + ex.what());
++            answer = isc::config::createAnswer(2,
++                         string("Configuration commit failed: ") + ex.what());
              rollback = true;
  
          } catch (...) {
              // for things like bad_cast in boost::lexical_cast
 -            answer =
 -                isc::config::createAnswer(2, string("Configuration commit failed"));
 +            LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_EXCEPTION);
-             answer =
-                 isc::config::createAnswer(2, string("Configuration commit failed"));
++            answer = isc::config::createAnswer(2,
++                         string("Configuration commit failed"));
              rollback = true;
  
          }
Simple merge
index 8c305343c948577a06b708fc0ad5f33d0990a5d1,02ad0a075a0e3fe475eb72bc954a759734db617f..7f040abba56dbc286dfc4c77b9fbf04fb670c23c
@@@ -88,41 -115,6 +115,36 @@@ This error is output if the server fail
  returned to the client into a valid packet.  The cause is most likely
  to be a programming error: please raise a bug report.
  
- % DHCP4_PARSER_CREATED1 created parser for configuration element %1
- A debug message output during a configuration update of the IPv4 DHCP
- server, notifying that the parser for the specified configuration element
- has been successfully created in the first pass through creating parsers
- % DHCP4_PARSER_CREATED2 created parser for configuration element %1
 +% DHCP4_PARSER_COMMIT_EXCEPTION parser failed to commit changes
 +On receipt of message containing details to a change of the IPv4 DHCP
 +server configuration, a set of parsers were successfully created, but one
 +of them failed to commit its changes due to a low-level system exception
 +being raised.  Additional messages may be output indicating the reason.
 +
 +% DHCP4_PARSER_COMMIT_FAIL parser failed to commit changes: %1
 +On receipt of message containing details to a change of the IPv4 DHCP
 +server configuration, a set of parsers were successfully created, but
 +one of them failed to commit its changes.  The reason for the failure
 +is given in the message.
 +
- has been successfully created in the second pass through creating parsers
++% DHCP4_PARSER_CREATED created parser for configuration element %1
 +A debug message output during a configuration update of the IPv4 DHCP
 +server, notifying that the parser for the specified configuration element
++has been successfully created.
 +
 +% DHCP4_PARSER_CREATE_FAIL failed to create parser for configuration element %1: %2
 +On receipt of message containing details to a change of its configuration,
 +the IPv4 DHCP server failed to create a parser to decode the contents of the
 +named configuration element.  The reason for the failure is given in the
 +message.
 +
 +% DHCP4_PARSER_CREATE_EXCEPTION failed to create parser for configuration element %1
 +On receipt of message containing details to a change of its configuration,
 +the IPv4 DHCP server failed to create a parser to decode the contents
 +of the named configuration element.  The message has been output in
 +response to a non-BIND 10 exception being raised.  Additional messages
 +may give further information.
 +
  % DHCP4_QUERY_DATA received packet type %1, data is <%2>
  A debug message listing the data received from the client.
  
index 1ded503f169979ec247c5d8affdb8988a56e6e8b,f2eb34c55f6221ab2542137d805e459d87e4707a..49cb73cf5380a39d6e225b40af8817268094f3b2
@@@ -18,8 -18,8 +18,9 @@@
  #include <dhcp/libdhcp++.h>
  #include <dhcp6/config_parser.h>
  #include <dhcp6/dhcp6_log.h>
+ #include <dhcp/iface_mgr.h>
  #include <dhcpsrv/cfgmgr.h>
 +#include <dhcpsrv/dbaccess_parser.h>
  #include <dhcpsrv/dhcp_config_parser.h>
  #include <dhcpsrv/pool.h>
  #include <dhcpsrv/subnet.h>
@@@ -47,6 -48,20 +49,17 @@@ using namespace isc::asiolink
  
  namespace {
  
 -/// @brief Auxiliary type used for storing an element name and its parser.
 -typedef pair<string, ConstElementPtr> ConfigPair;
 -
+ // Forward declarations of some of the parser classes.
+ // They are used to define pointer types for these classes.
+ class BooleanParser;
+ class StringParser;
+ class Uint32Parser;
+ // Pointers to various parser objects.
+ typedef boost::shared_ptr<BooleanParser> BooleanParserPtr;
+ typedef boost::shared_ptr<StringParser> StringParserPtr;
+ typedef boost::shared_ptr<Uint32Parser> Uint32ParserPtr;
  /// @brief Factory method that will create a parser for a given element name
  typedef isc::dhcp::DhcpConfigParser* ParserFactory(const std::string& config_id);
  
@@@ -1353,8 -1661,8 +1659,9 @@@ DhcpConfigParser* createGlobalDhcpConfi
      factories["interface"] = InterfaceListConfigParser::factory;
      factories["subnet6"] = Subnets6ListConfigParser::factory;
      factories["option-data"] = OptionDataListParser::factory;
+     factories["option-def"] = OptionDefListParser::factory;
      factories["version"] = StringParser::factory;
 +    factories["lease-database"] = DbAccessParser::factory;
  
      FactoryMap::iterator f = factories.find(config_id);
      if (f == factories.end()) {
@@@ -1408,19 -1717,22 +1716,28 @@@ configureDhcp6Server(Dhcpv6Srv&, ConstE
      // rollback informs whether error occured and original data
      // have to be restored to global storages.
      bool rollback = false;
-     // config_pair holds the details of the current parser when iterating over
-     // parser.  It is declared outside the loops so in case of an error, the
-     // name of the failing parser can be retrieved in the "catch" clause.
++    // config_pair holds ther details of the current parser when iterating over
++    // the parsers.  It is declared outside the loop so in case of error, the
++    // name of the failing parser can be retrieved within the "catch" clause.
 +    ConfigPair config_pair;
      try {
-         // Iterate over all independent parsers first (all but subnet6)
-         // and try to parse the data.
-         BOOST_FOREACH(config_pair, config_set->mapValue()) {
-             if (config_pair.first != "subnet6") {
-                 ParserPtr parser(createGlobalDhcpConfigParser(
-                                      config_pair.first));
-                 LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL, DHCP6_PARSER_CREATED1)
-                           .arg(config_pair.first);
+         // Make parsers grouping.
+         const std::map<std::string, ConstElementPtr>& values_map =
+             config_set->mapValue();
 -        BOOST_FOREACH(ConfigPair config_pair, values_map) {
++        BOOST_FOREACH(config_pair, values_map) {
+             ParserPtr parser(createGlobalDhcpConfigParser(config_pair.first));
++            LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL, DHCP6_PARSER_CREATED)
++                      .arg(config_pair.first);
+             if (config_pair.first == "subnet6") {
+                 subnet_parser = parser;
+             } else if (config_pair.first == "option-data") {
+                 option_parser = parser;
+             } else {
+                 // Those parsers should be started before other
+                 // parsers so we can call build straight away.
                  independent_parsers.push_back(parser);
                  parser->build(config_pair.second);
                  // The commit operation here may modify the global storage
              }
          }
          catch (const isc::Exception& ex) {
 -            answer =
 -                isc::config::createAnswer(2, string("Configuration commit failed:") 
 -                                          + ex.what());
 +            LOG_ERROR(dhcp6_logger, DHCP6_PARSER_COMMIT_FAIL).arg(ex.what());
-             answer =
-                 isc::config::createAnswer(2, string("Configuration commit failed:") 
-                                           + ex.what());
++            answer = isc::config::createAnswer(2,
++                         string("Configuration commit failed:") + ex.what());
              // An error occured, so make sure to restore the original data.
              rollback = true;
          } catch (...) {
              // for things like bad_cast in boost::lexical_cast
 -            answer =
 -                isc::config::createAnswer(2, string("Configuration commit failed"));
 +            LOG_ERROR(dhcp6_logger, DHCP6_PARSER_COMMIT_EXCEPTION);
-             answer =
-                 isc::config::createAnswer(2, string("Configuration commit failed"));
++            answer = isc::config::createAnswer(2,
++                         string("Configuration commit failed"));
              // An error occured, so make sure to restore the original data.
              rollback = true;
          }
Simple merge
Simple merge
index f80af12e3901e0390807e7bdbbfd5d8f50ba6147,c38776ca452dd31517320286cac8eccb1368ea2d..63f5231e3421821c124de0957ce16ac807b610a2
@@@ -172,46 -172,6 +172,41 @@@ This error is output if the server fail
  returned to the client into a valid packet.  The reason is most likely
  to be to a programming error: please raise a bug report.
  
- % DHCP6_PARSER_CREATED1 created parser for configuration element %1
 +% DHCP6_PARSER_COMMIT_EXCEPTION parser failed to commit changes
 +On receipt of message containing details to a change of the IPv6 DHCP
 +server configuration, a set of parsers were successfully created, but one
 +of them failed to commit its changes due to a low-level system exception
 +being raised.  Additional messages may be output indicating the reason.
 +
 +% DHCP6_PARSER_COMMIT_FAIL parser failed to commit changes: %1
 +On receipt of message containing details to a change of the IPv6 DHCP
 +server configuration, a set of parsers were successfully created, but
 +one of them failed to commit its changes.  The reason for the failure
 +is given in the message.
 +
- has been successfully created in the first pass through creating parsers
- % DHCP6_PARSER_CREATED2 created parser for configuration element %1
- A debug message output during a configuration update of the IPv6 DHCP
- server, notifying that the parser for the specified configuration element
- has been successfully created in the second pass through creating parsers
++% DHCP6_PARSER_CREATED created parser for configuration element %1
 +A debug message output during a configuration update of the IPv6 DHCP
 +server, notifying that the parser for the specified configuration element
++has been successfully created.
 +
 +% DHCP6_PARSER_CREATE_FAIL failed to create parser for configuration element %1: %2
 +On receipt of message containing details to a change of its configuration,
 +the IPv6 DHCP server failed to create a parser to decode the contents of the
 +named configuration element.  The reason for the failure is given in the
 +message.
 +
 +% DHCP6_PARSER_CREATE_EXCEPTION failed to create parser for configuration element %1
 +On receipt of message containing details to a change of its configuration,
 +the IPv6 DHCP server failed to create a parser to decode the contents
 +of the named configuration element.  The message has been output in
 +response to a non-BIND 10 exception being raised.  Additional messages
 +may give further information.
 +
 +The most likely cause of this is that the specification file for the server
 +(which details the allowable contents of the configuration) is not correct for
 +this version of BIND 10.  This former may be the result of an interrupted
 +installation of an update to BIND 10.
 +
  % DHCP6_PROCESS_IA_NA_REQUEST server is processing IA_NA option (duid=%1, iaid=%2, hint=%3)
  This is a debug message that indicates a processing of received IA_NA
  option. It may optionally contain an address that may be used by the server
index cb943ecad8abaf698dbaa12d19e2487a1f5855ed,e50950f836d1be4156bbe26c3a24ed39f50ceee3..1e0b4dae38ad0229ce1e5f4a6e8715871c736614
@@@ -69,8 -75,29 +75,23 @@@ Dhcpv6Srv::Dhcpv6Srv(uint16_t port
              IfaceMgr::instance().openSockets6(port);
          }
  
-         setServerID();
+         string duid_file = CfgMgr::instance().getDataDir() + "/" + string(SERVER_DUID_FILE);
+         if (loadServerID(duid_file)) {
+             LOG_DEBUG(dhcp6_logger, DBG_DHCP6_START, DHCP6_SERVERID_LOADED)
+                 .arg(duid_file);
+         } else {
+             generateServerID();
+             LOG_INFO(dhcp6_logger, DHCP6_SERVERID_GENERATED)
+                 .arg(duidToString(getServerID()))
+                 .arg(duid_file);
+             if (!writeServerID(duid_file)) {
+                 LOG_WARN(dhcp6_logger, DHCP6_SERVERID_WRITE_FAIL)
+                     .arg(duid_file);
+             }
+         }
  
 -        // Instantiate LeaseMgr
 -        LeaseMgrFactory::create(dbconfig);
 -        LOG_INFO(dhcp6_logger, DHCP6_DB_BACKEND_STARTED)
 -            .arg(LeaseMgrFactory::instance().getType())
 -            .arg(LeaseMgrFactory::instance().getName());
 -
          // Instantiate allocation engine
          alloc_engine_.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100));
  
Simple merge
Simple merge
Simple merge
index 0af1afb78b4ed849a9934a29b95429560c671de7,8a7610b37aa4caf05c8455ae2b3a8f5fabb9b847..bf4e1e11cab94cc342e945176f51f66d0df65ef1
@@@ -60,12 -60,11 +60,19 @@@ This is a debug message reporting that 
  returned the specified IPv6 subnet when given the address hint specified
  as the address is within the subnet.
  
 -This is a debug message reporting that the DHCP configuration manager has
 -returned the specified IPv6 subnet for a packet received over given interface.
 -This particular subnet was selected, because it was specified as being directly
 -reachable over given interface. (see 'interface' parameter in subnet6 definition).
+ % DHCPSRV_CFGMGR_SUBNET6_IFACE selected subnet %1 for packet received over interface %2
++This is a debug message reporting that the DHCP configuration manager
++has returned the specified IPv6 subnet for a packet received over
++given interface.  This particular subnet was selected, because it
++was specified as being directly reachable over given interface. (see
++'interface' parameter in subnet6 definition).
++
 +% DHCPSRV_CLOSE_DB closing currently open %1 database
 +This is a debug message, issued when the DHCP server closes the currently
 +open lease database.  It is issued at program shutdown and whenever
 +the database access parameters are changed: in the latter case, the
 +server closes the currently open database, and opens a database using
 +the new parameters.
  
  % DHCPSRV_INVALID_ACCESS invalid database access string: %1
  This is logged when an attempt has been made to parse a database access string
Simple merge
index 2f775189242a6943c7fb111731413df8a161c132,dfe3e785c5e7d4f3450c5ca7a1412de24a68ff33..00476c0ceb90497863e24f0b5c4af77580bc0f27
@@@ -30,8 -30,6 +30,7 @@@ libdhcpsrv_unittests_SOURCES  = run_uni
  libdhcpsrv_unittests_SOURCES += addr_utilities_unittest.cc
  libdhcpsrv_unittests_SOURCES += alloc_engine_unittest.cc
  libdhcpsrv_unittests_SOURCES += cfgmgr_unittest.cc
- libdhcpsrv_unittests_SOURCES += hwaddr_unittest.cc
 +libdhcpsrv_unittests_SOURCES += dbaccess_parser_unittest.cc
  libdhcpsrv_unittests_SOURCES += lease_mgr_factory_unittest.cc
  libdhcpsrv_unittests_SOURCES += lease_mgr_unittest.cc
  libdhcpsrv_unittests_SOURCES += memfile_lease_mgr_unittest.cc