00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef RDATA_GENERIC_NS_2_C
00023 #define RDATA_GENERIC_NS_2_C
00024
00025 #define RRTYPE_NS_ATTRIBUTES (DNS_RDATATYPEATTR_ZONECUTAUTH)
00026
00027 static inline isc_result_t
00028 fromtext_ns(ARGS_FROMTEXT) {
00029 isc_token_t token;
00030 dns_name_t name;
00031 isc_buffer_t buffer;
00032 isc_boolean_t ok;
00033
00034 REQUIRE(type == 2);
00035
00036 UNUSED(type);
00037 UNUSED(rdclass);
00038 UNUSED(callbacks);
00039
00040 RETERR(isc_lex_getmastertoken(lexer, &token,isc_tokentype_string,
00041 ISC_FALSE));
00042
00043 dns_name_init(&name, NULL);
00044 buffer_fromregion(&buffer, &token.value.as_region);
00045 origin = (origin != NULL) ? origin : dns_rootname;
00046 RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
00047 ok = ISC_TRUE;
00048 if ((options & DNS_RDATA_CHECKNAMES) != 0)
00049 ok = dns_name_ishostname(&name, ISC_FALSE);
00050 if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0)
00051 RETTOK(DNS_R_BADNAME);
00052 if (!ok && callbacks != NULL)
00053 warn_badname(&name, lexer, callbacks);
00054 return (ISC_R_SUCCESS);
00055 }
00056
00057 static inline isc_result_t
00058 totext_ns(ARGS_TOTEXT) {
00059 isc_region_t region;
00060 dns_name_t name;
00061 dns_name_t prefix;
00062 isc_boolean_t sub;
00063
00064 REQUIRE(rdata->type == 2);
00065 REQUIRE(rdata->length != 0);
00066
00067 dns_name_init(&name, NULL);
00068 dns_name_init(&prefix, NULL);
00069
00070 dns_rdata_toregion(rdata, ®ion);
00071 dns_name_fromregion(&name, ®ion);
00072
00073 sub = name_prefix(&name, tctx->origin, &prefix);
00074
00075 return (dns_name_totext(&prefix, sub, target));
00076 }
00077
00078 static inline isc_result_t
00079 fromwire_ns(ARGS_FROMWIRE) {
00080 dns_name_t name;
00081
00082 REQUIRE(type == 2);
00083
00084 UNUSED(type);
00085 UNUSED(rdclass);
00086
00087 dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
00088
00089 dns_name_init(&name, NULL);
00090 return (dns_name_fromwire(&name, source, dctx, options, target));
00091 }
00092
00093 static inline isc_result_t
00094 towire_ns(ARGS_TOWIRE) {
00095 dns_name_t name;
00096 dns_offsets_t offsets;
00097 isc_region_t region;
00098
00099 REQUIRE(rdata->type == 2);
00100 REQUIRE(rdata->length != 0);
00101
00102 dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
00103
00104 dns_name_init(&name, offsets);
00105 dns_rdata_toregion(rdata, ®ion);
00106 dns_name_fromregion(&name, ®ion);
00107
00108 return (dns_name_towire(&name, cctx, target));
00109 }
00110
00111 static inline int
00112 compare_ns(ARGS_COMPARE) {
00113 dns_name_t name1;
00114 dns_name_t name2;
00115 isc_region_t region1;
00116 isc_region_t region2;
00117
00118 REQUIRE(rdata1->type == rdata2->type);
00119 REQUIRE(rdata1->rdclass == rdata2->rdclass);
00120 REQUIRE(rdata1->type == 2);
00121 REQUIRE(rdata1->length != 0);
00122 REQUIRE(rdata2->length != 0);
00123
00124 dns_name_init(&name1, NULL);
00125 dns_name_init(&name2, NULL);
00126
00127 dns_rdata_toregion(rdata1, ®ion1);
00128 dns_rdata_toregion(rdata2, ®ion2);
00129
00130 dns_name_fromregion(&name1, ®ion1);
00131 dns_name_fromregion(&name2, ®ion2);
00132
00133 return (dns_name_rdatacompare(&name1, &name2));
00134 }
00135
00136 static inline isc_result_t
00137 fromstruct_ns(ARGS_FROMSTRUCT) {
00138 dns_rdata_ns_t *ns = source;
00139 isc_region_t region;
00140
00141 REQUIRE(type == 2);
00142 REQUIRE(source != NULL);
00143 REQUIRE(ns->common.rdtype == type);
00144 REQUIRE(ns->common.rdclass == rdclass);
00145
00146 UNUSED(type);
00147 UNUSED(rdclass);
00148
00149 dns_name_toregion(&ns->name, ®ion);
00150 return (isc_buffer_copyregion(target, ®ion));
00151 }
00152
00153 static inline isc_result_t
00154 tostruct_ns(ARGS_TOSTRUCT) {
00155 isc_region_t region;
00156 dns_rdata_ns_t *ns = target;
00157 dns_name_t name;
00158
00159 REQUIRE(rdata->type == 2);
00160 REQUIRE(target != NULL);
00161 REQUIRE(rdata->length != 0);
00162
00163 ns->common.rdclass = rdata->rdclass;
00164 ns->common.rdtype = rdata->type;
00165 ISC_LINK_INIT(&ns->common, link);
00166
00167 dns_name_init(&name, NULL);
00168 dns_rdata_toregion(rdata, ®ion);
00169 dns_name_fromregion(&name, ®ion);
00170 dns_name_init(&ns->name, NULL);
00171 RETERR(name_duporclone(&name, mctx, &ns->name));
00172 ns->mctx = mctx;
00173 return (ISC_R_SUCCESS);
00174 }
00175
00176 static inline void
00177 freestruct_ns(ARGS_FREESTRUCT) {
00178 dns_rdata_ns_t *ns = source;
00179
00180 REQUIRE(source != NULL);
00181
00182 if (ns->mctx == NULL)
00183 return;
00184
00185 dns_name_free(&ns->name, ns->mctx);
00186 ns->mctx = NULL;
00187 }
00188
00189 static inline isc_result_t
00190 additionaldata_ns(ARGS_ADDLDATA) {
00191 dns_name_t name;
00192 dns_offsets_t offsets;
00193 isc_region_t region;
00194
00195 REQUIRE(rdata->type == 2);
00196
00197 dns_name_init(&name, offsets);
00198 dns_rdata_toregion(rdata, ®ion);
00199 dns_name_fromregion(&name, ®ion);
00200
00201 return ((add)(arg, &name, dns_rdatatype_a));
00202 }
00203
00204 static inline isc_result_t
00205 digest_ns(ARGS_DIGEST) {
00206 isc_region_t r;
00207 dns_name_t name;
00208
00209 REQUIRE(rdata->type == 2);
00210
00211 dns_rdata_toregion(rdata, &r);
00212 dns_name_init(&name, NULL);
00213 dns_name_fromregion(&name, &r);
00214
00215 return (dns_name_digest(&name, digest, arg));
00216 }
00217
00218 static inline isc_boolean_t
00219 checkowner_ns(ARGS_CHECKOWNER) {
00220
00221 REQUIRE(type == 2);
00222
00223 UNUSED(name);
00224 UNUSED(type);
00225 UNUSED(rdclass);
00226 UNUSED(wildcard);
00227
00228 return (ISC_TRUE);
00229 }
00230
00231 static inline isc_boolean_t
00232 checknames_ns(ARGS_CHECKNAMES) {
00233 isc_region_t region;
00234 dns_name_t name;
00235
00236 REQUIRE(rdata->type == 2);
00237
00238 UNUSED(owner);
00239
00240 dns_rdata_toregion(rdata, ®ion);
00241 dns_name_init(&name, NULL);
00242 dns_name_fromregion(&name, ®ion);
00243 if (!dns_name_ishostname(&name, ISC_FALSE)) {
00244 if (bad != NULL)
00245 dns_name_clone(&name, bad);
00246 return (ISC_FALSE);
00247 }
00248 return (ISC_TRUE);
00249 }
00250
00251 static inline int
00252 casecompare_ns(ARGS_COMPARE) {
00253 return (compare_ns(rdata1, rdata2));
00254 }
00255
00256 #endif