resolve.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. namespace isc {
  22. namespace resolve {
  23. /// \brief Create an error response
  24. ///
  25. /// Clears the answer, authority, and additional section of the
  26. /// given MessagePtr and sets the given error code
  27. ///
  28. /// Notes: Assuming you have already done initial preparations
  29. /// on the given answer message (copy the opcode, qid and question
  30. /// section), you can simply use this to create an error response.
  31. ///
  32. /// \param answer_message The message to clear and place the error in
  33. /// \param question The question to add to the
  34. /// \param error_code The error Rcode
  35. void makeErrorMessage(isc::dns::MessagePtr answer_message,
  36. const isc::dns::Rcode::Rcode& error_code);
  37. /// \brief Copies all rrsets in the given section from source
  38. /// to target
  39. ///
  40. /// \param source The source Message
  41. /// \param target The target MessagePtr
  42. /// \param section the section to copy
  43. void copySection(const isc::dns::Message& source,
  44. isc::dns::MessagePtr target,
  45. isc::dns::Message::Section section);
  46. /// \brief Copies the parts relevant for a DNS answer to the
  47. /// target message
  48. ///
  49. /// This adds all the RRsets in the answer, authority and
  50. /// additional sections to the target, as well as the response
  51. /// code
  52. void copyAnswerMessage(const isc::dns::Message& source,
  53. isc::dns::MessagePtr target);
  54. } // namespace resolve
  55. } // namespace isc
  56. #endif // ISC_RESOLVE_H_