zone_finder.cc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (C) 2012 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 <dns/rdata.h>
  15. #include <dns/rrset.h>
  16. #include <dns/rrtype.h>
  17. #include <dns/rdataclass.h>
  18. #include <datasrc/zone.h>
  19. using namespace std;
  20. using namespace isc::dns;
  21. using namespace isc::dns::rdata;
  22. namespace isc {
  23. namespace datasrc {
  24. isc::dns::ConstRRsetPtr
  25. ZoneFinder::stripRRsigs(isc::dns::ConstRRsetPtr rp,
  26. const FindOptions options) {
  27. if (rp) {
  28. isc::dns::ConstRRsetPtr sig_rrset = rp->getRRsig();
  29. if (sig_rrset &&
  30. ((options & ZoneFinder::FIND_DNSSEC) == 0)) {
  31. isc::dns::RRsetPtr result_base
  32. (new isc::dns::RRset(rp->getName(),
  33. rp->getClass(),
  34. rp->getType(),
  35. rp->getTTL()));
  36. for (isc::dns::RdataIteratorPtr i(rp->getRdataIterator());
  37. !i->isLast();
  38. i->next()) {
  39. result_base->addRdata(i->getCurrent());
  40. }
  41. return (result_base);
  42. }
  43. }
  44. return (rp);
  45. }
  46. } // namespace datasrc
  47. } // datasrc isc