cfg_4o6.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // Copyright (C) 2015-2016 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 CFG_4OVER6_H
  7. #define CFG_4OVER6_H
  8. #include <string>
  9. #include <asiolink/io_address.h>
  10. namespace isc {
  11. namespace dhcp {
  12. /// @brief This structure contains information about DHCP4o6 (RFC7341)
  13. ///
  14. /// DHCP4o6 is completely optional. If it is not enabled, this structure
  15. /// does not contain any information.
  16. struct Cfg4o6 {
  17. /// the default constructor.
  18. ///
  19. /// Initializes fields to their default value.
  20. Cfg4o6()
  21. :enabled_(false), subnet4o6_(std::make_pair(asiolink::IOAddress("::"), 128u)) {
  22. }
  23. /// @brief Returns whether the DHCP4o6 is enabled or not.
  24. /// @return true if enabled
  25. bool enabled() const {
  26. return (enabled_);
  27. }
  28. /// @brief Sets the DHCP4o6 enabled status.
  29. /// @param enabled specifies if the DHCP4o6 should be enabled or not
  30. void enabled(bool enabled) {
  31. enabled_ = enabled;
  32. }
  33. /// @brief Returns the DHCP4o6 interface.
  34. /// @return value of the 4o6-interface parameter.
  35. std::string getIface4o6() const {
  36. return (iface4o6_);
  37. }
  38. /// @brief Sets the 4o6-interface.
  39. /// @param iface name of the network interface the 4o6 traffic is received on
  40. void setIface4o6(const std::string& iface) {
  41. iface4o6_ = iface;
  42. enabled_ = true;
  43. }
  44. /// @brief Returns prefix/len for the IPv6 subnet.
  45. /// @return prefix/length pair
  46. std::pair<asiolink::IOAddress, uint8_t> getSubnet4o6() const {
  47. return (subnet4o6_);
  48. }
  49. /// @brief Sets the prefix/length information (content of the 4o6-subnet).
  50. /// @param subnet IOAddress that represents a prefix
  51. /// @param prefix specifies prefix length
  52. void setSubnet4o6(const asiolink::IOAddress& subnet, uint8_t prefix) {
  53. subnet4o6_ = std::make_pair(subnet, prefix);
  54. enabled_ = true;
  55. }
  56. /// @brief Returns the interface-id.
  57. /// @return the option representing interface-id (or NULL)
  58. OptionPtr getInterfaceId() const {
  59. return (interface_id_);
  60. }
  61. /// @brief Sets the interface-id
  62. /// @param opt option to be used as interface-id match
  63. void setInterfaceId(const OptionPtr& opt) {
  64. interface_id_ = opt;
  65. enabled_ = true;
  66. }
  67. private:
  68. /// Specifies if 4o6 is enabled on this subnet.
  69. bool enabled_;
  70. /// Specifies the network interface used as v4 subnet selector.
  71. std::string iface4o6_;
  72. /// Specifies the IPv6 subnet used for v4 subnet selection.
  73. std::pair<asiolink::IOAddress, uint8_t> subnet4o6_;
  74. /// Specifies the v6 interface-id used for v4 subnet selection.
  75. OptionPtr interface_id_;
  76. };
  77. } // end of isc::dhcp namespace
  78. } // end of isc namespace
  79. #endif