/contrib/bind9/lib/dns/rdata/generic/null_10.c

https://bitbucket.org/freebsd/freebsd-head/ · C · 193 lines · 126 code · 49 blank · 18 comment · 28 complexity · 3a8ada3eadfd7f35a0e35173cbae3895 MD5 · raw file

  1. /*
  2. * Copyright (C) 2004, 2007, 2009, 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
  3. * Copyright (C) 1998-2002 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$ */
  18. /* Reviewed: Thu Mar 16 13:57:50 PST 2000 by explorer */
  19. #ifndef RDATA_GENERIC_NULL_10_C
  20. #define RDATA_GENERIC_NULL_10_C
  21. #define RRTYPE_NULL_ATTRIBUTES (0)
  22. static inline isc_result_t
  23. fromtext_null(ARGS_FROMTEXT) {
  24. REQUIRE(type == 10);
  25. UNUSED(rdclass);
  26. UNUSED(type);
  27. UNUSED(lexer);
  28. UNUSED(origin);
  29. UNUSED(options);
  30. UNUSED(target);
  31. UNUSED(callbacks);
  32. return (DNS_R_SYNTAX);
  33. }
  34. static inline isc_result_t
  35. totext_null(ARGS_TOTEXT) {
  36. REQUIRE(rdata->type == 10);
  37. return (unknown_totext(rdata, tctx, target));
  38. }
  39. static inline isc_result_t
  40. fromwire_null(ARGS_FROMWIRE) {
  41. isc_region_t sr;
  42. REQUIRE(type == 10);
  43. UNUSED(type);
  44. UNUSED(rdclass);
  45. UNUSED(dctx);
  46. UNUSED(options);
  47. isc_buffer_activeregion(source, &sr);
  48. isc_buffer_forward(source, sr.length);
  49. return (mem_tobuffer(target, sr.base, sr.length));
  50. }
  51. static inline isc_result_t
  52. towire_null(ARGS_TOWIRE) {
  53. REQUIRE(rdata->type == 10);
  54. UNUSED(cctx);
  55. return (mem_tobuffer(target, rdata->data, rdata->length));
  56. }
  57. static inline int
  58. compare_null(ARGS_COMPARE) {
  59. isc_region_t r1;
  60. isc_region_t r2;
  61. REQUIRE(rdata1->type == rdata2->type);
  62. REQUIRE(rdata1->rdclass == rdata2->rdclass);
  63. REQUIRE(rdata1->type == 10);
  64. dns_rdata_toregion(rdata1, &r1);
  65. dns_rdata_toregion(rdata2, &r2);
  66. return (isc_region_compare(&r1, &r2));
  67. }
  68. static inline isc_result_t
  69. fromstruct_null(ARGS_FROMSTRUCT) {
  70. dns_rdata_null_t *null = source;
  71. REQUIRE(type == 10);
  72. REQUIRE(source != NULL);
  73. REQUIRE(null->common.rdtype == type);
  74. REQUIRE(null->common.rdclass == rdclass);
  75. REQUIRE(null->data != NULL || null->length == 0);
  76. UNUSED(type);
  77. UNUSED(rdclass);
  78. return (mem_tobuffer(target, null->data, null->length));
  79. }
  80. static inline isc_result_t
  81. tostruct_null(ARGS_TOSTRUCT) {
  82. dns_rdata_null_t *null = target;
  83. isc_region_t r;
  84. REQUIRE(rdata->type == 10);
  85. REQUIRE(target != NULL);
  86. null->common.rdclass = rdata->rdclass;
  87. null->common.rdtype = rdata->type;
  88. ISC_LINK_INIT(&null->common, link);
  89. dns_rdata_toregion(rdata, &r);
  90. null->length = r.length;
  91. null->data = mem_maybedup(mctx, r.base, r.length);
  92. if (null->data == NULL)
  93. return (ISC_R_NOMEMORY);
  94. null->mctx = mctx;
  95. return (ISC_R_SUCCESS);
  96. }
  97. static inline void
  98. freestruct_null(ARGS_FREESTRUCT) {
  99. dns_rdata_null_t *null = source;
  100. REQUIRE(source != NULL);
  101. REQUIRE(null->common.rdtype == 10);
  102. if (null->mctx == NULL)
  103. return;
  104. if (null->data != NULL)
  105. isc_mem_free(null->mctx, null->data);
  106. null->mctx = NULL;
  107. }
  108. static inline isc_result_t
  109. additionaldata_null(ARGS_ADDLDATA) {
  110. UNUSED(rdata);
  111. UNUSED(add);
  112. UNUSED(arg);
  113. REQUIRE(rdata->type == 10);
  114. return (ISC_R_SUCCESS);
  115. }
  116. static inline isc_result_t
  117. digest_null(ARGS_DIGEST) {
  118. isc_region_t r;
  119. REQUIRE(rdata->type == 10);
  120. dns_rdata_toregion(rdata, &r);
  121. return ((digest)(arg, &r));
  122. }
  123. static inline isc_boolean_t
  124. checkowner_null(ARGS_CHECKOWNER) {
  125. REQUIRE(type == 10);
  126. UNUSED(name);
  127. UNUSED(type);
  128. UNUSED(rdclass);
  129. UNUSED(wildcard);
  130. return (ISC_TRUE);
  131. }
  132. static inline isc_boolean_t
  133. checknames_null(ARGS_CHECKNAMES) {
  134. REQUIRE(rdata->type == 10);
  135. UNUSED(rdata);
  136. UNUSED(owner);
  137. UNUSED(bad);
  138. return (ISC_TRUE);
  139. }
  140. static inline int
  141. casecompare_null(ARGS_COMPARE) {
  142. return (compare_null(rdata1, rdata2));
  143. }
  144. #endif /* RDATA_GENERIC_NULL_10_C */