cname_5.cc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright (C) 2010 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. // $Id$
  15. #include <config.h>
  16. #include <string>
  17. #include <dns/buffer.h>
  18. #include <dns/name.h>
  19. #include <dns/messagerenderer.h>
  20. #include <dns/rdata.h>
  21. #include <dns/rdataclass.h>
  22. using namespace std;
  23. // BEGIN_ISC_NAMESPACE
  24. // BEGIN_RDATA_NAMESPACE
  25. CNAME::CNAME(const std::string& namestr) :
  26. cname_(namestr)
  27. {}
  28. CNAME::CNAME(InputBuffer& buffer, size_t rdata_len UNUSED_PARAM) :
  29. Rdata(), cname_(buffer)
  30. {
  31. // we don't need rdata_len for parsing. if necessary, the caller will
  32. // check consistency.
  33. }
  34. CNAME::CNAME(const CNAME& other) :
  35. Rdata(), cname_(other.cname_)
  36. {}
  37. CNAME::CNAME(const Name& cname) :
  38. cname_(cname)
  39. {}
  40. void
  41. CNAME::toWire(OutputBuffer& buffer) const {
  42. cname_.toWire(buffer);
  43. }
  44. void
  45. CNAME::toWire(AbstractMessageRenderer& renderer) const {
  46. renderer.writeName(cname_);
  47. }
  48. string
  49. CNAME::toText() const {
  50. return (cname_.toText());
  51. }
  52. int
  53. CNAME::compare(const Rdata& other) const {
  54. const CNAME& other_cname = dynamic_cast<const CNAME&>(other);
  55. return (compareNames(cname_, other_cname.cname_));
  56. }
  57. const Name&
  58. CNAME::getCname() const {
  59. return (cname_);
  60. }
  61. // END_RDATA_NAMESPACE
  62. // END_ISC_NAMESPACE