option6_ia.h 3.4 KB

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