config_parser.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #include <cc/data.h>
  15. #include <exceptions/exceptions.h>
  16. #include <dhcpsrv/dhcp_parsers.h>
  17. #include <stdint.h>
  18. #include <string>
  19. #ifndef DHCP4_CONFIG_PARSER_H
  20. #define DHCP4_CONFIG_PARSER_H
  21. /// @todo: This header file and its .cc counterpart are very similar between
  22. /// DHCPv4 and DHCPv6. They should be merged. A ticket #2355.
  23. namespace isc {
  24. namespace dhcp {
  25. class Dhcpv4Srv;
  26. /// @brief Configure DHCPv4 server (@c Dhcpv4Srv) with a set of configuration
  27. /// values.
  28. ///
  29. /// This function parses configuration information stored in @c config_set
  30. /// and configures the @c server by applying the configuration to it.
  31. /// It provides the strong exception guarantee as long as the underlying
  32. /// derived class implementations of @c DhcpConfigParser meet the assumption,
  33. /// that is, it ensures that either configuration is fully applied or the
  34. /// state of the server is intact.
  35. ///
  36. /// If a syntax or semantics level error happens during the configuration
  37. /// (such as malformed configuration or invalid configuration parameter),
  38. /// this function returns appropriate error code.
  39. ///
  40. /// This function is called every time a new configuration is received. The
  41. /// extra parameter is a reference to DHCPv4 server component. It is currently
  42. /// not used and CfgMgr::instance() is accessed instead.
  43. ///
  44. /// This method does not throw. It catches all exceptions and returns them as
  45. /// reconfiguration statuses. It may return the following response codes:
  46. /// 0 - configuration successful
  47. /// 1 - malformed configuration (parsing failed)
  48. /// 2 - commit failed (parsing was successful, but failed to store the
  49. /// values in to server's configuration)
  50. ///
  51. /// @param config_set a new configuration (JSON) for DHCPv4 server
  52. /// @return answer that contains result of reconfiguration
  53. isc::data::ConstElementPtr
  54. configureDhcp4Server(Dhcpv4Srv&,
  55. isc::data::ConstElementPtr config_set);
  56. /// @brief Returns the global context
  57. ///
  58. /// @return a reference to the global context
  59. ParserContextPtr& globalContext();
  60. }; // end of isc::dhcp namespace
  61. }; // end of isc namespace
  62. #endif // DHCP4_CONFIG_PARSER_H