diff options
author | Marcin Siodelski <marcin@isc.org> | 2016-06-30 13:32:32 +0200 |
---|---|---|
committer | Marcin Siodelski <marcin@isc.org> | 2016-07-08 07:50:19 +0200 |
commit | 1f3ac9ac2b6cb19826adbfb6b9fb64828cf5efba (patch) | |
tree | 3d0df6a3826080b25a5223c53c60b3710002af82 /src/lib/dhcp | |
parent | [4497] Added .gitignores to non-recursively built directories. (diff) | |
download | kea-1f3ac9ac2b6cb19826adbfb6b9fb64828cf5efba.tar.xz kea-1f3ac9ac2b6cb19826adbfb6b9fb64828cf5efba.zip |
[4497] Documented Option::clone() in all option classes.
Also udated copyright dates where applicable.
Diffstat (limited to 'src/lib/dhcp')
29 files changed, 80 insertions, 28 deletions
diff --git a/src/lib/dhcp/option.cc b/src/lib/dhcp/option.cc index d3bf8ad408..82e3593cfb 100644 --- a/src/lib/dhcp/option.cc +++ b/src/lib/dhcp/option.cc @@ -74,8 +74,7 @@ Option::operator=(const Option& rhs) { OptionPtr Option::clone() const { - OptionPtr option(new Option(*this)); - return (option); + return (cloneInternal<Option>()); } void @@ -214,6 +213,8 @@ Option::getOptionsCopy(OptionCollection& options_copy) const { local_options.insert(std::make_pair(it->second->getType(), copy)); } + // All options copied successfully, so assign them to the output + // parameter. options_copy.swap(local_options); } diff --git a/src/lib/dhcp/option.h b/src/lib/dhcp/option.h index b5e385c5c6..fdc9fe9173 100644 --- a/src/lib/dhcp/option.h +++ b/src/lib/dhcp/option.h @@ -144,10 +144,31 @@ public: Option(Universe u, uint16_t type, OptionBufferConstIter first, OptionBufferConstIter last); - Option(const Option& option); + /// @brief Copy constructor. + /// + /// This constructor makes a deep copy of the option and all of the + /// suboptions. It calls @ref getOptionsCopy to deep copy suboptions. + /// + /// @param source Option to be copied. + Option(const Option& source); + /// @brief Assignment operator. + /// + /// The assignment operator performs a deep copy of the option and + /// its suboptions. It calls @ref getOptionsCopy to deep copy + /// suboptions. + /// + /// @param rhs Option to be assigned. Option& operator=(const Option& rhs); + /// @brief Copies this option and returns a pointer to the copy. + /// + /// This function must be overriden in the derived classes to make + /// a copy of the derived type. The simplest way to do it is by + /// calling @ref copyInternal function with an appropriate template + /// parmater. + /// + /// @return Pointer to the copy of the option. virtual OptionPtr clone() const; /// @brief returns option universe (V4 or V6) @@ -263,6 +284,11 @@ public: return (options_); } + /// @brief Performs deep copy of suboptions. + /// + /// This method calls @ref clone method to deep copy each option. + /// + /// @param [out] options_copy Container where copied options are stored. void getOptionsCopy(OptionCollection& options_copy) const; /// Attempts to delete first suboption of requested type @@ -372,6 +398,15 @@ public: protected: + /// @brief Copies this option and returns a pointer to the copy. + /// + /// The deep copy of the option is performed by calling copy + /// constructor of the option of a given type. Derived classes call + /// this method in the implementations of @ref clone methods to + /// create a copy of the option of their type. + /// + /// @tparam OptionType Type of the option of which a clone should + /// be created. template<typename OptionType> OptionPtr cloneInternal() const { boost::shared_ptr<OptionType> diff --git a/src/lib/dhcp/option4_addrlst.cc b/src/lib/dhcp/option4_addrlst.cc index 61bdc4f2f6..478eb997f1 100644 --- a/src/lib/dhcp/option4_addrlst.cc +++ b/src/lib/dhcp/option4_addrlst.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/lib/dhcp/option4_addrlst.h b/src/lib/dhcp/option4_addrlst.h index e1448ce29d..24ff1288c3 100644 --- a/src/lib/dhcp/option4_addrlst.h +++ b/src/lib/dhcp/option4_addrlst.h @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -80,6 +80,7 @@ public: Option4AddrLst(uint8_t type, OptionBufferConstIter first, OptionBufferConstIter last); + /// @brief Copies this option and returns a pointer to the copy. virtual OptionPtr clone() const; /// @brief Writes option in a wire-format to a buffer. diff --git a/src/lib/dhcp/option4_client_fqdn.cc b/src/lib/dhcp/option4_client_fqdn.cc index e5057076a7..1984e8b7e3 100644 --- a/src/lib/dhcp/option4_client_fqdn.cc +++ b/src/lib/dhcp/option4_client_fqdn.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/lib/dhcp/option4_client_fqdn.h b/src/lib/dhcp/option4_client_fqdn.h index 5656112e69..43767a64bc 100644 --- a/src/lib/dhcp/option4_client_fqdn.h +++ b/src/lib/dhcp/option4_client_fqdn.h @@ -219,6 +219,7 @@ public: /// @brief Copy constructor Option4ClientFqdn(const Option4ClientFqdn& source); + /// @brief Copies this option and returns a pointer to the copy. virtual OptionPtr clone() const; /// @brief Destructor diff --git a/src/lib/dhcp/option6_addrlst.cc b/src/lib/dhcp/option6_addrlst.cc index ab505c4da7..ba4cc0de39 100644 --- a/src/lib/dhcp/option6_addrlst.cc +++ b/src/lib/dhcp/option6_addrlst.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/lib/dhcp/option6_addrlst.h b/src/lib/dhcp/option6_addrlst.h index 217b76ffa0..67f3b6108d 100644 --- a/src/lib/dhcp/option6_addrlst.h +++ b/src/lib/dhcp/option6_addrlst.h @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/lib/dhcp/option6_client_fqdn.cc b/src/lib/dhcp/option6_client_fqdn.cc index 700146a98c..e1c7c565c7 100644 --- a/src/lib/dhcp/option6_client_fqdn.cc +++ b/src/lib/dhcp/option6_client_fqdn.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/lib/dhcp/option6_client_fqdn.h b/src/lib/dhcp/option6_client_fqdn.h index 35c55d1520..58adfbd52e 100644 --- a/src/lib/dhcp/option6_client_fqdn.h +++ b/src/lib/dhcp/option6_client_fqdn.h @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -140,6 +140,7 @@ public: /// @brief Copy constructor Option6ClientFqdn(const Option6ClientFqdn& source); + /// @brief Copies this option and returns a pointer to the copy. virtual OptionPtr clone() const; /// @brief Destructor diff --git a/src/lib/dhcp/option6_ia.cc b/src/lib/dhcp/option6_ia.cc index 887ec1e645..1c11062b8c 100644 --- a/src/lib/dhcp/option6_ia.cc +++ b/src/lib/dhcp/option6_ia.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/lib/dhcp/option6_ia.h b/src/lib/dhcp/option6_ia.h index b29c77727f..232d15d6fc 100644 --- a/src/lib/dhcp/option6_ia.h +++ b/src/lib/dhcp/option6_ia.h @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -39,6 +39,7 @@ public: Option6IA(uint16_t type, OptionBuffer::const_iterator begin, OptionBuffer::const_iterator end); + /// @brief Copies this option and returns a pointer to the copy. virtual OptionPtr clone() const; /// Writes option in wire-format to buf, returns pointer to first unused diff --git a/src/lib/dhcp/option6_iaaddr.cc b/src/lib/dhcp/option6_iaaddr.cc index 477be9e603..a392450ddc 100644 --- a/src/lib/dhcp/option6_iaaddr.cc +++ b/src/lib/dhcp/option6_iaaddr.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/lib/dhcp/option6_iaaddr.h b/src/lib/dhcp/option6_iaaddr.h index 4709269965..8d3cda060f 100644 --- a/src/lib/dhcp/option6_iaaddr.h +++ b/src/lib/dhcp/option6_iaaddr.h @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -46,6 +46,7 @@ public: Option6IAAddr(uint32_t type, OptionBuffer::const_iterator begin, OptionBuffer::const_iterator end); + /// @brief Copies this option and returns a pointer to the copy. virtual OptionPtr clone() const; /// @brief Writes option in wire-format. diff --git a/src/lib/dhcp/option6_iaprefix.cc b/src/lib/dhcp/option6_iaprefix.cc index 95dacd6127..e8e9cc82fb 100644 --- a/src/lib/dhcp/option6_iaprefix.cc +++ b/src/lib/dhcp/option6_iaprefix.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/lib/dhcp/option6_iaprefix.h b/src/lib/dhcp/option6_iaprefix.h index c9be8ee681..e3a9b57ef5 100644 --- a/src/lib/dhcp/option6_iaprefix.h +++ b/src/lib/dhcp/option6_iaprefix.h @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -74,6 +74,7 @@ public: Option6IAPrefix(uint32_t type, OptionBuffer::const_iterator begin, OptionBuffer::const_iterator end); + /// @brief Copies this option and returns a pointer to the copy. virtual OptionPtr clone() const; /// @brief Writes option in wire-format. diff --git a/src/lib/dhcp/option6_status_code.cc b/src/lib/dhcp/option6_status_code.cc index f0de03bab4..58a56ebc7b 100644 --- a/src/lib/dhcp/option6_status_code.cc +++ b/src/lib/dhcp/option6_status_code.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/lib/dhcp/option6_status_code.h b/src/lib/dhcp/option6_status_code.h index 3b012186f0..148de7ee36 100644 --- a/src/lib/dhcp/option6_status_code.h +++ b/src/lib/dhcp/option6_status_code.h @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -37,6 +37,7 @@ public: /// @param end Iterator to end of option data (first byte after option end). Option6StatusCode(OptionBufferConstIter begin, OptionBufferConstIter end); + /// @brief Copies this option and returns a pointer to the copy. virtual OptionPtr clone() const; /// @brief Writes option in wire-format. diff --git a/src/lib/dhcp/option_custom.cc b/src/lib/dhcp/option_custom.cc index e868083429..d966bb9b38 100644 --- a/src/lib/dhcp/option_custom.cc +++ b/src/lib/dhcp/option_custom.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/lib/dhcp/option_custom.h b/src/lib/dhcp/option_custom.h index 28eb35dc48..ae8009f9c1 100644 --- a/src/lib/dhcp/option_custom.h +++ b/src/lib/dhcp/option_custom.h @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -79,6 +79,7 @@ public: OptionCustom(const OptionDefinition& def, Universe u, OptionBufferConstIter first, OptionBufferConstIter last); + /// @brief Copies this option and returns a pointer to the copy. virtual OptionPtr clone() const; /// @brief Create new buffer and set its value as an IP address. diff --git a/src/lib/dhcp/option_int.h b/src/lib/dhcp/option_int.h index fd5d233320..1a13050845 100644 --- a/src/lib/dhcp/option_int.h +++ b/src/lib/dhcp/option_int.h @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -48,6 +48,7 @@ template<typename T> class OptionInt: public Option { private: + /// @brief Pointer to the option object for a specified type T. typedef boost::shared_ptr<OptionInt<T> > OptionIntTypePtr; public: @@ -93,6 +94,7 @@ public: unpack(begin, end); } + /// @brief Copies this option and returns a pointer to the copy. virtual OptionPtr clone() const { return (cloneInternal<OptionInt<T> >()); } diff --git a/src/lib/dhcp/option_int_array.h b/src/lib/dhcp/option_int_array.h index d29bc89bf3..ef379bb5c0 100644 --- a/src/lib/dhcp/option_int_array.h +++ b/src/lib/dhcp/option_int_array.h @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -56,6 +56,7 @@ template<typename T> class OptionIntArray: public Option { private: + /// @brief Pointer to the option type for the specified T. typedef boost::shared_ptr<OptionIntArray<T> > OptionIntArrayTypePtr; public: @@ -120,6 +121,7 @@ public: unpack(begin, end); } + /// @brief Copies this option and returns a pointer to the copy. virtual OptionPtr clone() const { return (cloneInternal<OptionIntArray<T> >()); } diff --git a/src/lib/dhcp/option_opaque_data_tuples.h b/src/lib/dhcp/option_opaque_data_tuples.h index 64823ee8bf..69d4e1cd25 100644 --- a/src/lib/dhcp/option_opaque_data_tuples.h +++ b/src/lib/dhcp/option_opaque_data_tuples.h @@ -62,6 +62,7 @@ public: OptionBufferConstIter begin, OptionBufferConstIter end); + /// @brief Copies this option and returns a pointer to the copy. OptionPtr clone() const; /// @brief Renders option into the buffer in the wire format. diff --git a/src/lib/dhcp/option_string.cc b/src/lib/dhcp/option_string.cc index 553f84fee5..ddf3052025 100644 --- a/src/lib/dhcp/option_string.cc +++ b/src/lib/dhcp/option_string.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/lib/dhcp/option_string.h b/src/lib/dhcp/option_string.h index 701c370507..dfc907f77a 100644 --- a/src/lib/dhcp/option_string.h +++ b/src/lib/dhcp/option_string.h @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -56,6 +56,7 @@ public: OptionString(const Option::Universe u, const uint16_t type, OptionBufferConstIter begin, OptionBufferConstIter end); + /// @brief Copies this option and returns a pointer to the copy. OptionPtr clone() const; /// @brief Returns length of the whole option, including header. diff --git a/src/lib/dhcp/option_vendor.cc b/src/lib/dhcp/option_vendor.cc index 25fed0047e..7b0220c1c5 100644 --- a/src/lib/dhcp/option_vendor.cc +++ b/src/lib/dhcp/option_vendor.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/lib/dhcp/option_vendor.h b/src/lib/dhcp/option_vendor.h index 7dddf42e00..f8a55a54a7 100644 --- a/src/lib/dhcp/option_vendor.h +++ b/src/lib/dhcp/option_vendor.h @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -50,6 +50,7 @@ public: OptionVendor(Option::Universe u, OptionBufferConstIter begin, OptionBufferConstIter end); + /// @brief Copies this option and returns a pointer to the copy. OptionPtr clone() const; /// @brief Writes option in wire-format to buf, returns pointer to first diff --git a/src/lib/dhcp/option_vendor_class.cc b/src/lib/dhcp/option_vendor_class.cc index 3e1ec161d1..e6ae79c754 100644 --- a/src/lib/dhcp/option_vendor_class.cc +++ b/src/lib/dhcp/option_vendor_class.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/lib/dhcp/option_vendor_class.h b/src/lib/dhcp/option_vendor_class.h index b00f9f189c..14a29a3030 100644 --- a/src/lib/dhcp/option_vendor_class.h +++ b/src/lib/dhcp/option_vendor_class.h @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -69,6 +69,7 @@ public: OptionVendorClass(Option::Universe u, OptionBufferConstIter begin, OptionBufferConstIter end); + /// @brief Copies this option and returns a pointer to the copy. OptionPtr clone() const; /// @brief Renders option into the buffer in the wire format. |