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

https://bitbucket.org/freebsd/freebsd-head/ · C · 194 lines · 125 code · 52 blank · 17 comment · 28 complexity · 0752c755b6d863f6b29397d44eac3d2e MD5 · raw file

  1. /*
  2. * Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC")
  3. * Copyright (C) 1999-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: unspec_103.c,v 1.37 2009/12/04 22:06:37 tbox Exp $ */
  18. #ifndef RDATA_GENERIC_UNSPEC_103_C
  19. #define RDATA_GENERIC_UNSPEC_103_C
  20. #define RRTYPE_UNSPEC_ATTRIBUTES (0)
  21. static inline isc_result_t
  22. fromtext_unspec(ARGS_FROMTEXT) {
  23. REQUIRE(type == 103);
  24. UNUSED(type);
  25. UNUSED(rdclass);
  26. UNUSED(origin);
  27. UNUSED(options);
  28. UNUSED(callbacks);
  29. return (atob_tobuffer(lexer, target));
  30. }
  31. static inline isc_result_t
  32. totext_unspec(ARGS_TOTEXT) {
  33. REQUIRE(rdata->type == 103);
  34. UNUSED(tctx);
  35. return (btoa_totext(rdata->data, rdata->length, target));
  36. }
  37. static inline isc_result_t
  38. fromwire_unspec(ARGS_FROMWIRE) {
  39. isc_region_t sr;
  40. REQUIRE(type == 103);
  41. UNUSED(type);
  42. UNUSED(rdclass);
  43. UNUSED(dctx);
  44. UNUSED(options);
  45. isc_buffer_activeregion(source, &sr);
  46. isc_buffer_forward(source, sr.length);
  47. return (mem_tobuffer(target, sr.base, sr.length));
  48. }
  49. static inline isc_result_t
  50. towire_unspec(ARGS_TOWIRE) {
  51. REQUIRE(rdata->type == 103);
  52. UNUSED(cctx);
  53. return (mem_tobuffer(target, rdata->data, rdata->length));
  54. }
  55. static inline int
  56. compare_unspec(ARGS_COMPARE) {
  57. isc_region_t r1;
  58. isc_region_t r2;
  59. REQUIRE(rdata1->type == rdata2->type);
  60. REQUIRE(rdata1->rdclass == rdata2->rdclass);
  61. REQUIRE(rdata1->type == 103);
  62. dns_rdata_toregion(rdata1, &r1);
  63. dns_rdata_toregion(rdata2, &r2);
  64. return (isc_region_compare(&r1, &r2));
  65. }
  66. static inline isc_result_t
  67. fromstruct_unspec(ARGS_FROMSTRUCT) {
  68. dns_rdata_unspec_t *unspec = source;
  69. REQUIRE(type == 103);
  70. REQUIRE(source != NULL);
  71. REQUIRE(unspec->common.rdtype == type);
  72. REQUIRE(unspec->common.rdclass == rdclass);
  73. REQUIRE(unspec->data != NULL || unspec->datalen == 0);
  74. UNUSED(type);
  75. UNUSED(rdclass);
  76. return (mem_tobuffer(target, unspec->data, unspec->datalen));
  77. }
  78. static inline isc_result_t
  79. tostruct_unspec(ARGS_TOSTRUCT) {
  80. dns_rdata_unspec_t *unspec = target;
  81. isc_region_t r;
  82. REQUIRE(rdata->type == 103);
  83. REQUIRE(target != NULL);
  84. unspec->common.rdclass = rdata->rdclass;
  85. unspec->common.rdtype = rdata->type;
  86. ISC_LINK_INIT(&unspec->common, link);
  87. dns_rdata_toregion(rdata, &r);
  88. unspec->datalen = r.length;
  89. unspec->data = mem_maybedup(mctx, r.base, r.length);
  90. if (unspec->data == NULL)
  91. return (ISC_R_NOMEMORY);
  92. unspec->mctx = mctx;
  93. return (ISC_R_SUCCESS);
  94. }
  95. static inline void
  96. freestruct_unspec(ARGS_FREESTRUCT) {
  97. dns_rdata_unspec_t *unspec = source;
  98. REQUIRE(source != NULL);
  99. REQUIRE(unspec->common.rdtype == 103);
  100. if (unspec->mctx == NULL)
  101. return;
  102. if (unspec->data != NULL)
  103. isc_mem_free(unspec->mctx, unspec->data);
  104. unspec->mctx = NULL;
  105. }
  106. static inline isc_result_t
  107. additionaldata_unspec(ARGS_ADDLDATA) {
  108. REQUIRE(rdata->type == 103);
  109. UNUSED(rdata);
  110. UNUSED(add);
  111. UNUSED(arg);
  112. return (ISC_R_SUCCESS);
  113. }
  114. static inline isc_result_t
  115. digest_unspec(ARGS_DIGEST) {
  116. isc_region_t r;
  117. REQUIRE(rdata->type == 103);
  118. dns_rdata_toregion(rdata, &r);
  119. return ((digest)(arg, &r));
  120. }
  121. static inline isc_boolean_t
  122. checkowner_unspec(ARGS_CHECKOWNER) {
  123. REQUIRE(type == 103);
  124. UNUSED(name);
  125. UNUSED(type);
  126. UNUSED(rdclass);
  127. UNUSED(wildcard);
  128. return (ISC_TRUE);
  129. }
  130. static inline isc_boolean_t
  131. checknames_unspec(ARGS_CHECKNAMES) {
  132. REQUIRE(rdata->type == 103);
  133. UNUSED(rdata);
  134. UNUSED(owner);
  135. UNUSED(bad);
  136. return (ISC_TRUE);
  137. }
  138. static inline int
  139. casecompare_unspec(ARGS_COMPARE) {
  140. return (compare_unspec(rdata1, rdata2));
  141. }
  142. #endif /* RDATA_GENERIC_UNSPEC_103_C */