/contrib/bind9/lib/dns/zonekey.c

https://bitbucket.org/freebsd/freebsd-head/ · C · 55 lines · 27 code · 10 blank · 18 comment · 10 complexity · 0dbc91a6330c44de22f5d366452fad66 MD5 · raw file

  1. /*
  2. * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
  3. * Copyright (C) 2001, 2003 Internet Software Consortium.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  10. * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  11. * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  12. * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  13. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  14. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. * PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. /* $Id: zonekey.c,v 1.9 2007/06/19 23:47:16 tbox Exp $ */
  18. /*! \file */
  19. #include <config.h>
  20. #include <isc/result.h>
  21. #include <isc/types.h>
  22. #include <isc/util.h>
  23. #include <dns/keyvalues.h>
  24. #include <dns/rdata.h>
  25. #include <dns/rdatastruct.h>
  26. #include <dns/types.h>
  27. #include <dns/zonekey.h>
  28. isc_boolean_t
  29. dns_zonekey_iszonekey(dns_rdata_t *keyrdata) {
  30. isc_result_t result;
  31. dns_rdata_dnskey_t key;
  32. isc_boolean_t iszonekey = ISC_TRUE;
  33. REQUIRE(keyrdata != NULL);
  34. result = dns_rdata_tostruct(keyrdata, &key, NULL);
  35. if (result != ISC_R_SUCCESS)
  36. return (ISC_FALSE);
  37. if ((key.flags & DNS_KEYTYPE_NOAUTH) != 0)
  38. iszonekey = ISC_FALSE;
  39. if ((key.flags & DNS_KEYFLAG_OWNERMASK) != DNS_KEYOWNER_ZONE)
  40. iszonekey = ISC_FALSE;
  41. if (key.protocol != DNS_KEYPROTO_DNSSEC &&
  42. key.protocol != DNS_KEYPROTO_ANY)
  43. iszonekey = ISC_FALSE;
  44. return (iszonekey);
  45. }