option6_ia.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // Copyright (C) 2011-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 OPTION_IA_H
  7. #define OPTION_IA_H
  8. #include <dhcp/option.h>
  9. #include <boost/shared_ptr.hpp>
  10. #include <stdint.h>
  11. namespace isc {
  12. namespace dhcp {
  13. class Option6IA;
  14. /// A pointer to the @c Option6IA object.
  15. typedef boost::shared_ptr<Option6IA> Option6IAPtr;
  16. class Option6IA: public Option {
  17. public:
  18. /// Length of IA_NA and IA_PD content
  19. const static size_t OPTION6_IA_LEN = 12;
  20. /// @brief Ctor, used for constructed options, usually during transmission.
  21. ///
  22. /// @param type option type (usually 4 for IA_NA, 25 for IA_PD)
  23. /// @param iaid identity association identifier (id of IA)
  24. Option6IA(uint16_t type, uint32_t iaid);
  25. /// @brief Ctor, used for received options.
  26. ///
  27. /// @param type option type (usually 4 for IA_NA, 25 for IA_PD)
  28. /// @param begin iterator to first byte of option data
  29. /// @param end iterator to end of option data (first byte after option end)
  30. Option6IA(uint16_t type, OptionBuffer::const_iterator begin,
  31. OptionBuffer::const_iterator end);
  32. /// @brief Copies this option and returns a pointer to the copy.
  33. virtual OptionPtr clone() const;
  34. /// Writes option in wire-format to buf, returns pointer to first unused
  35. /// byte after stored option.
  36. ///
  37. /// @param buf buffer (option will be stored here)
  38. void pack(isc::util::OutputBuffer& buf) const;
  39. /// @brief Parses received buffer
  40. ///
  41. /// Parses received buffer and returns offset to the first unused byte after
  42. /// parsed option.
  43. ///
  44. /// @param begin iterator to first byte of option data
  45. /// @param end iterator to end of option data (first byte after option end)
  46. virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end);
  47. /// Provides human readable text representation
  48. ///
  49. /// @param indent number of leading space characters
  50. ///
  51. /// @return string with text representation
  52. virtual std::string toText(int indent = 0) const;
  53. /// Sets T1 timer.
  54. ///
  55. /// @param t1 t1 value to be set
  56. void setT1(uint32_t t1) { t1_ = t1; }
  57. /// Sets T2 timer.
  58. ///
  59. /// @param t2 t2 value to be set
  60. void setT2(uint32_t t2) { t2_ = t2; }
  61. /// Sets Identity Association Identifier.
  62. ///
  63. /// @param iaid IAID value to be set
  64. void setIAID(uint32_t iaid) { iaid_ = iaid; }
  65. /// Returns IA identifier.
  66. ///
  67. /// @return IAID value.
  68. ///
  69. uint32_t getIAID() const { return iaid_; }
  70. /// Returns T1 timer.
  71. ///
  72. /// @return T1 value.
  73. uint32_t getT1() const { return t1_; }
  74. /// Returns T2 timer.
  75. ///
  76. /// @return T2 value.
  77. uint32_t getT2() const { return t2_; }
  78. /// @brief returns complete length of option
  79. ///
  80. /// Returns length of this option, including option header and suboptions
  81. ///
  82. /// @return length of this option
  83. virtual uint16_t len() const;
  84. protected:
  85. /// keeps IA identifier
  86. uint32_t iaid_;
  87. /// keeps T1 timer value
  88. uint32_t t1_;
  89. /// keeps T2 timer value
  90. uint32_t t2_;
  91. };
  92. } // isc::dhcp namespace
  93. } // isc namespace
  94. #endif // OPTION_IA_H