resolve.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // Copyright (C) 2011 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 _ISC_RESOLVE_H
  15. #define _ISC_RESOLVE_H 1
  16. /// This file includes all other libresolve headers, and provides
  17. /// several helper functions used in resolving.
  18. #include <resolve/resolver_interface.h>
  19. #include <resolve/resolver_callback.h>
  20. #include <resolve/response_classifier.h>
  21. #include <dns/rcode.h>
  22. namespace isc {
  23. namespace resolve {
  24. /// \brief Create an error response
  25. ///
  26. /// Clears the answer, authority, and additional section of the
  27. /// given MessagePtr and sets the given error code
  28. ///
  29. /// Notes: Assuming you have already done initial preparations
  30. /// on the given answer message (copy the opcode, qid and question
  31. /// section), you can simply use this to create an error response.
  32. ///
  33. /// \param answer_message The message to clear and place the error in
  34. /// \param error_code The error Rcode
  35. void makeErrorMessage(isc::dns::MessagePtr answer_message,
  36. const isc::dns::Rcode& error_code);
  37. /// \brief Initialize a response message
  38. ///
  39. /// Based on the given query message, this fills in the very
  40. /// first details of the response (i.e. the Question section and
  41. /// the Opcode). This allows for direct usage of makeErrorMessage(),
  42. /// as well as ResolveCache.lookup().
  43. ///
  44. /// Raises an isc::dns::InvalidMessageOperation if reponse_message is
  45. /// not in RENDER mode.
  46. ///
  47. /// \param query_message The query message to take the Question, Qid,
  48. /// and Opcode from.
  49. /// \param response_message The fresh response message to initialize
  50. /// (must be in RENDER mode)
  51. void initResponseMessage(const isc::dns::Message& query_message,
  52. isc::dns::Message& response_message);
  53. /// \brief Initialize a response message
  54. ///
  55. /// Based on the given question, this fills in the very
  56. /// first details of the response (i.e. the Question section and the
  57. /// Opcode Query). This allows for direct usage of makeErrorMessage(),
  58. /// as well as ResolveCache.lookup().
  59. ///
  60. /// Raises an isc::dns::InvalidMessageOperation if reponse_message is
  61. /// not in RENDER mode.
  62. ///
  63. /// \param question The question to place in the Question section
  64. /// \param response_message The fresh response message to initialize
  65. /// (must be in RENDER mode)
  66. void initResponseMessage(const isc::dns::Question& question,
  67. isc::dns::Message& response_message);
  68. /// \brief Copies the parts relevant for a DNS response to the
  69. /// target message
  70. ///
  71. /// This adds all the RRsets in the answer, authority and
  72. /// additional sections to the target, as well as the response
  73. /// code
  74. /// \param source The Message to copy the data from
  75. /// \param target The Message to copy the data to
  76. void copyResponseMessage(const isc::dns::Message& source,
  77. isc::dns::MessagePtr target);
  78. } // namespace resolve
  79. } // namespace isc
  80. #endif // ISC_RESOLVE_H_