tsig_250.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. // Copyright (C) 2010-2013 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. // BEGIN_HEADER_GUARD
  15. #include <stdint.h>
  16. #include <string>
  17. #include <dns/name.h>
  18. #include <dns/rdata.h>
  19. // BEGIN_ISC_NAMESPACE
  20. // BEGIN_COMMON_DECLARATIONS
  21. // END_COMMON_DECLARATIONS
  22. // BEGIN_RDATA_NAMESPACE
  23. struct TSIGImpl;
  24. /// \brief \c rdata::TSIG class represents the TSIG RDATA as defined %in
  25. /// RFC2845.
  26. ///
  27. /// This class implements the basic interfaces inherited from the abstract
  28. /// \c rdata::Rdata class, and provides trivial accessors specific to the
  29. /// TSIG RDATA.
  30. class TSIG : public Rdata {
  31. public:
  32. // BEGIN_COMMON_MEMBERS
  33. // END_COMMON_MEMBERS
  34. /// \brief Constructor from RDATA field parameters.
  35. ///
  36. /// The parameters are a straightforward mapping of %TSIG RDATA
  37. /// fields as defined %in RFC2845, but there are some implementation
  38. /// specific notes as follows.
  39. ///
  40. /// \c algorithm is a \c Name object that specifies the algorithm.
  41. /// For example, if the algorithm is HMAC-SHA256, \c algorithm would be
  42. /// \c Name("hmac-sha256").
  43. ///
  44. /// \c time_signed corresponds to the Time Signed field, which is of
  45. /// 48-bit unsigned integer type, and therefore cannot exceed 2^48-1;
  46. /// otherwise, an exception of type \c OutOfRange will be thrown.
  47. ///
  48. /// \c mac_size and \c mac correspond to the MAC Size and MAC fields,
  49. /// respectively. When the MAC field is empty, \c mac must be NULL.
  50. /// \c mac_size and \c mac must be consistent %in that \c mac_size is 0 if
  51. /// and only if \c mac is NULL; otherwise an exception of type
  52. /// InvalidParameter will be thrown.
  53. ///
  54. /// The same restriction applies to \c other_len and \c other_data,
  55. /// which correspond to the Other Len and Other Data fields, respectively.
  56. ///
  57. /// This constructor internally involves resource allocation, and if
  58. /// it fails, a corresponding standard exception will be thrown.
  59. TSIG(const Name& algorithm, uint64_t time_signed, uint16_t fudge,
  60. uint16_t mac_size, const void* mac, uint16_t original_id,
  61. uint16_t error, uint16_t other_len, const void* other_data);
  62. /// \brief Assignment operator.
  63. ///
  64. /// It internally allocates a resource, and if it fails a corresponding
  65. /// standard exception will be thrown.
  66. /// This operator never throws an exception otherwise.
  67. ///
  68. /// This operator provides the strong exception guarantee: When an
  69. /// exception is thrown the content of the assignment target will be
  70. /// intact.
  71. TSIG& operator=(const TSIG& source);
  72. /// \brief The destructor.
  73. ~TSIG();
  74. /// \brief Return the algorithm name.
  75. ///
  76. /// This method never throws an exception.
  77. const Name& getAlgorithm() const;
  78. /// \brief Return the value of the Time Signed field.
  79. ///
  80. /// The returned value does not exceed 2^48-1.
  81. ///
  82. /// This method never throws an exception.
  83. uint64_t getTimeSigned() const;
  84. /// \brief Return the value of the Fudge field.
  85. ///
  86. /// This method never throws an exception.
  87. uint16_t getFudge() const;
  88. /// \brief Return the value of the MAC Size field.
  89. ///
  90. /// This method never throws an exception.
  91. uint16_t getMACSize() const;
  92. /// \brief Return the value of the MAC field.
  93. ///
  94. /// If the MAC field is empty, it returns NULL.
  95. /// Otherwise, the memory region beginning at the address returned by
  96. /// this method is valid up to the bytes specified by the return value
  97. /// of \c getMACSize().
  98. /// The memory region is only valid while the corresponding \c TSIG
  99. /// object is valid. The caller must hold the \c TSIG object while
  100. /// it needs to refer to the region or it must make a local copy of the
  101. /// region.
  102. ///
  103. /// This method never throws an exception.
  104. const void* getMAC() const;
  105. /// \brief Return the value of the Original ID field.
  106. ///
  107. /// This method never throws an exception.
  108. uint16_t getOriginalID() const;
  109. /// \brief Return the value of the Error field.
  110. ///
  111. /// This method never throws an exception.
  112. uint16_t getError() const;
  113. /// \brief Return the value of the Other Len field.
  114. ///
  115. /// This method never throws an exception.
  116. uint16_t getOtherLen() const;
  117. /// \brief Return the value of the Other Data field.
  118. ///
  119. /// The same note as \c getMAC() applies.
  120. ///
  121. /// This method never throws an exception.
  122. const void* getOtherData() const;
  123. private:
  124. TSIGImpl* constructFromLexer(MasterLexer& lexer, const Name* origin);
  125. TSIGImpl* impl_;
  126. };
  127. // END_RDATA_NAMESPACE
  128. // END_ISC_NAMESPACE
  129. // END_HEADER_GUARD
  130. // Local Variables:
  131. // mode: c++
  132. // End: