/contrib/bind9/lib/dns/rdata/in_1/nsap-ptr_23.c

https://bitbucket.org/freebsd/freebsd-head/ · C · 250 lines · 171 code · 60 blank · 19 comment · 39 complexity · 2c9d8f456510ce3971f1ea0ac5f90b95 MD5 · raw file

  1. /*
  2. * Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC")
  3. * Copyright (C) 1999-2001 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: nsap-ptr_23.c,v 1.40 2009/12/04 22:06:37 tbox Exp $ */
  18. /* Reviewed: Fri Mar 17 10:16:02 PST 2000 by gson */
  19. /* RFC1348. Obsoleted in RFC 1706 - use PTR instead. */
  20. #ifndef RDATA_IN_1_NSAP_PTR_23_C
  21. #define RDATA_IN_1_NSAP_PTR_23_C
  22. #define RRTYPE_NSAP_PTR_ATTRIBUTES (0)
  23. static inline isc_result_t
  24. fromtext_in_nsap_ptr(ARGS_FROMTEXT) {
  25. isc_token_t token;
  26. dns_name_t name;
  27. isc_buffer_t buffer;
  28. REQUIRE(type == 23);
  29. REQUIRE(rdclass == 1);
  30. UNUSED(type);
  31. UNUSED(rdclass);
  32. UNUSED(callbacks);
  33. RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
  34. ISC_FALSE));
  35. dns_name_init(&name, NULL);
  36. buffer_fromregion(&buffer, &token.value.as_region);
  37. origin = (origin != NULL) ? origin : dns_rootname;
  38. RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
  39. return (ISC_R_SUCCESS);
  40. }
  41. static inline isc_result_t
  42. totext_in_nsap_ptr(ARGS_TOTEXT) {
  43. isc_region_t region;
  44. dns_name_t name;
  45. dns_name_t prefix;
  46. isc_boolean_t sub;
  47. REQUIRE(rdata->type == 23);
  48. REQUIRE(rdata->rdclass == 1);
  49. REQUIRE(rdata->length != 0);
  50. dns_name_init(&name, NULL);
  51. dns_name_init(&prefix, NULL);
  52. dns_rdata_toregion(rdata, &region);
  53. dns_name_fromregion(&name, &region);
  54. sub = name_prefix(&name, tctx->origin, &prefix);
  55. return (dns_name_totext(&prefix, sub, target));
  56. }
  57. static inline isc_result_t
  58. fromwire_in_nsap_ptr(ARGS_FROMWIRE) {
  59. dns_name_t name;
  60. REQUIRE(type == 23);
  61. REQUIRE(rdclass == 1);
  62. UNUSED(type);
  63. UNUSED(rdclass);
  64. dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
  65. dns_name_init(&name, NULL);
  66. return (dns_name_fromwire(&name, source, dctx, options, target));
  67. }
  68. static inline isc_result_t
  69. towire_in_nsap_ptr(ARGS_TOWIRE) {
  70. dns_name_t name;
  71. dns_offsets_t offsets;
  72. isc_region_t region;
  73. REQUIRE(rdata->type == 23);
  74. REQUIRE(rdata->rdclass == 1);
  75. REQUIRE(rdata->length != 0);
  76. dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
  77. dns_name_init(&name, offsets);
  78. dns_rdata_toregion(rdata, &region);
  79. dns_name_fromregion(&name, &region);
  80. return (dns_name_towire(&name, cctx, target));
  81. }
  82. static inline int
  83. compare_in_nsap_ptr(ARGS_COMPARE) {
  84. dns_name_t name1;
  85. dns_name_t name2;
  86. isc_region_t region1;
  87. isc_region_t region2;
  88. REQUIRE(rdata1->type == rdata2->type);
  89. REQUIRE(rdata1->rdclass == rdata2->rdclass);
  90. REQUIRE(rdata1->type == 23);
  91. REQUIRE(rdata1->rdclass == 1);
  92. REQUIRE(rdata1->length != 0);
  93. REQUIRE(rdata2->length != 0);
  94. dns_name_init(&name1, NULL);
  95. dns_name_init(&name2, NULL);
  96. dns_rdata_toregion(rdata1, &region1);
  97. dns_rdata_toregion(rdata2, &region2);
  98. dns_name_fromregion(&name1, &region1);
  99. dns_name_fromregion(&name2, &region2);
  100. return (dns_name_rdatacompare(&name1, &name2));
  101. }
  102. static inline isc_result_t
  103. fromstruct_in_nsap_ptr(ARGS_FROMSTRUCT) {
  104. dns_rdata_in_nsap_ptr_t *nsap_ptr = source;
  105. isc_region_t region;
  106. REQUIRE(type == 23);
  107. REQUIRE(rdclass == 1);
  108. REQUIRE(source != NULL);
  109. REQUIRE(nsap_ptr->common.rdtype == type);
  110. REQUIRE(nsap_ptr->common.rdclass == rdclass);
  111. UNUSED(type);
  112. UNUSED(rdclass);
  113. dns_name_toregion(&nsap_ptr->owner, &region);
  114. return (isc_buffer_copyregion(target, &region));
  115. }
  116. static inline isc_result_t
  117. tostruct_in_nsap_ptr(ARGS_TOSTRUCT) {
  118. isc_region_t region;
  119. dns_rdata_in_nsap_ptr_t *nsap_ptr = target;
  120. dns_name_t name;
  121. REQUIRE(rdata->type == 23);
  122. REQUIRE(rdata->rdclass == 1);
  123. REQUIRE(target != NULL);
  124. REQUIRE(rdata->length != 0);
  125. nsap_ptr->common.rdclass = rdata->rdclass;
  126. nsap_ptr->common.rdtype = rdata->type;
  127. ISC_LINK_INIT(&nsap_ptr->common, link);
  128. dns_name_init(&name, NULL);
  129. dns_rdata_toregion(rdata, &region);
  130. dns_name_fromregion(&name, &region);
  131. dns_name_init(&nsap_ptr->owner, NULL);
  132. RETERR(name_duporclone(&name, mctx, &nsap_ptr->owner));
  133. nsap_ptr->mctx = mctx;
  134. return (ISC_R_SUCCESS);
  135. }
  136. static inline void
  137. freestruct_in_nsap_ptr(ARGS_FREESTRUCT) {
  138. dns_rdata_in_nsap_ptr_t *nsap_ptr = source;
  139. REQUIRE(source != NULL);
  140. REQUIRE(nsap_ptr->common.rdclass == 1);
  141. REQUIRE(nsap_ptr->common.rdtype == 23);
  142. if (nsap_ptr->mctx == NULL)
  143. return;
  144. dns_name_free(&nsap_ptr->owner, nsap_ptr->mctx);
  145. nsap_ptr->mctx = NULL;
  146. }
  147. static inline isc_result_t
  148. additionaldata_in_nsap_ptr(ARGS_ADDLDATA) {
  149. REQUIRE(rdata->type == 23);
  150. REQUIRE(rdata->rdclass == 1);
  151. UNUSED(rdata);
  152. UNUSED(add);
  153. UNUSED(arg);
  154. return (ISC_R_SUCCESS);
  155. }
  156. static inline isc_result_t
  157. digest_in_nsap_ptr(ARGS_DIGEST) {
  158. isc_region_t r;
  159. dns_name_t name;
  160. REQUIRE(rdata->type == 23);
  161. REQUIRE(rdata->rdclass == 1);
  162. dns_rdata_toregion(rdata, &r);
  163. dns_name_init(&name, NULL);
  164. dns_name_fromregion(&name, &r);
  165. return (dns_name_digest(&name, digest, arg));
  166. }
  167. static inline isc_boolean_t
  168. checkowner_in_nsap_ptr(ARGS_CHECKOWNER) {
  169. REQUIRE(type == 23);
  170. REQUIRE(rdclass == 1);
  171. UNUSED(name);
  172. UNUSED(type);
  173. UNUSED(rdclass);
  174. UNUSED(wildcard);
  175. return (ISC_TRUE);
  176. }
  177. static inline isc_boolean_t
  178. checknames_in_nsap_ptr(ARGS_CHECKNAMES) {
  179. REQUIRE(rdata->type == 23);
  180. REQUIRE(rdata->rdclass == 1);
  181. UNUSED(rdata);
  182. UNUSED(owner);
  183. UNUSED(bad);
  184. return (ISC_TRUE);
  185. }
  186. static inline int
  187. casecompare_in_nsap_ptr(ARGS_COMPARE) {
  188. return (compare_in_nsap_ptr(rdata1, rdata2));
  189. }
  190. #endif /* RDATA_IN_1_NSAP_PTR_23_C */