ifaces_config_parser.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this
  5. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
  6. #ifndef IFACES_CONFIG_PARSER_H
  7. #define IFACES_CONFIG_PARSER_H
  8. #include <cc/data.h>
  9. #include <cc/simple_parser.h>
  10. #include <dhcpsrv/cfg_iface.h>
  11. #include <dhcpsrv/parsers/dhcp_parsers.h>
  12. namespace isc {
  13. namespace dhcp {
  14. /// @brief Parser for the configuration of interfaces.
  15. ///
  16. /// This parser parses the "interfaces-config" parameter which holds the
  17. /// full configuration of the DHCP server with respect to the use of
  18. /// interfaces, DHCP traffic sockets and alike.
  19. ///
  20. /// This parser is used in both DHCPv4 and DHCPv6. Derived parsers
  21. /// are not needed.
  22. class IfacesConfigParser : public isc::data::SimpleParser {
  23. public:
  24. /// @brief Constructor
  25. ///
  26. /// @param protocol AF_INET for DHCPv4 and AF_INET6 for DHCPv6.
  27. explicit IfacesConfigParser(const uint16_t protocol);
  28. /// @brief Parses content of the "interfaces-config".
  29. ///
  30. /// @param config parsed structures will be stored here
  31. /// @param values pointer to the content of parsed values
  32. ///
  33. /// @throw DhcpConfigError if the interface names and/or addresses
  34. /// are invalid.
  35. void parse(const CfgIfacePtr& config, const isc::data::ConstElementPtr& values);
  36. private:
  37. /// @brief parses interfaces-list structure
  38. ///
  39. /// This method goes through all the interfaces-specified in
  40. /// 'interfaces-list' and enabled them in the specified configuration
  41. /// structure
  42. ///
  43. /// @param cfg_iface parsed interfaces will be specified here
  44. /// @param ifaces_list interfaces-list to be parsed
  45. /// @throw DhcpConfigError if the interface names are invalid.
  46. void parseInterfacesList(const CfgIfacePtr& cfg_iface,
  47. isc::data::ConstElementPtr ifaces_list);
  48. /// @brief AF_INET for DHCPv4 and AF_INET6 for DHCPv6.
  49. int protocol_;
  50. };
  51. }
  52. } // end of namespace isc
  53. #endif // IFACES_CONFIG_PARSER_H