ns_2.cc 1.8 KB

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