00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef RDATA_GENERIC_ISDN_20_C
00025 #define RDATA_GENERIC_ISDN_20_C
00026
00027 #define RRTYPE_ISDN_ATTRIBUTES (0)
00028
00029 static inline isc_result_t
00030 fromtext_isdn(ARGS_FROMTEXT) {
00031 isc_token_t token;
00032
00033 REQUIRE(type == 20);
00034
00035 UNUSED(type);
00036 UNUSED(rdclass);
00037 UNUSED(origin);
00038 UNUSED(options);
00039 UNUSED(callbacks);
00040
00041
00042 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
00043 ISC_FALSE));
00044 RETTOK(txt_fromtext(&token.value.as_textregion, target));
00045
00046
00047 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
00048 ISC_TRUE));
00049 if (token.type != isc_tokentype_string &&
00050 token.type != isc_tokentype_qstring) {
00051 isc_lex_ungettoken(lexer, &token);
00052 return (ISC_R_SUCCESS);
00053 }
00054 RETTOK(txt_fromtext(&token.value.as_textregion, target));
00055 return (ISC_R_SUCCESS);
00056 }
00057
00058 static inline isc_result_t
00059 totext_isdn(ARGS_TOTEXT) {
00060 isc_region_t region;
00061
00062 REQUIRE(rdata->type == 20);
00063 REQUIRE(rdata->length != 0);
00064
00065 UNUSED(tctx);
00066
00067 dns_rdata_toregion(rdata, ®ion);
00068 RETERR(txt_totext(®ion, ISC_TRUE, target));
00069 if (region.length == 0)
00070 return (ISC_R_SUCCESS);
00071 RETERR(str_totext(" ", target));
00072 return (txt_totext(®ion, ISC_TRUE, target));
00073 }
00074
00075 static inline isc_result_t
00076 fromwire_isdn(ARGS_FROMWIRE) {
00077 REQUIRE(type == 20);
00078
00079 UNUSED(type);
00080 UNUSED(dctx);
00081 UNUSED(rdclass);
00082 UNUSED(options);
00083
00084 RETERR(txt_fromwire(source, target));
00085 if (buffer_empty(source))
00086 return (ISC_R_SUCCESS);
00087 return (txt_fromwire(source, target));
00088 }
00089
00090 static inline isc_result_t
00091 towire_isdn(ARGS_TOWIRE) {
00092 UNUSED(cctx);
00093
00094 REQUIRE(rdata->type == 20);
00095 REQUIRE(rdata->length != 0);
00096
00097 return (mem_tobuffer(target, rdata->data, rdata->length));
00098 }
00099
00100 static inline int
00101 compare_isdn(ARGS_COMPARE) {
00102 isc_region_t r1;
00103 isc_region_t r2;
00104
00105 REQUIRE(rdata1->type == rdata2->type);
00106 REQUIRE(rdata1->rdclass == rdata2->rdclass);
00107 REQUIRE(rdata1->type == 20);
00108 REQUIRE(rdata1->length != 0);
00109 REQUIRE(rdata2->length != 0);
00110
00111 dns_rdata_toregion(rdata1, &r1);
00112 dns_rdata_toregion(rdata2, &r2);
00113 return (isc_region_compare(&r1, &r2));
00114 }
00115
00116 static inline isc_result_t
00117 fromstruct_isdn(ARGS_FROMSTRUCT) {
00118 dns_rdata_isdn_t *isdn = source;
00119
00120 REQUIRE(type == 20);
00121 REQUIRE(source != NULL);
00122 REQUIRE(isdn->common.rdtype == type);
00123 REQUIRE(isdn->common.rdclass == rdclass);
00124
00125 UNUSED(type);
00126 UNUSED(rdclass);
00127
00128 RETERR(uint8_tobuffer(isdn->isdn_len, target));
00129 RETERR(mem_tobuffer(target, isdn->isdn, isdn->isdn_len));
00130 if (isdn->subaddress == NULL)
00131 return (ISC_R_SUCCESS);
00132 RETERR(uint8_tobuffer(isdn->subaddress_len, target));
00133 return (mem_tobuffer(target, isdn->subaddress, isdn->subaddress_len));
00134 }
00135
00136 static inline isc_result_t
00137 tostruct_isdn(ARGS_TOSTRUCT) {
00138 dns_rdata_isdn_t *isdn = target;
00139 isc_region_t r;
00140
00141 REQUIRE(rdata->type == 20);
00142 REQUIRE(target != NULL);
00143 REQUIRE(rdata->length != 0);
00144
00145 isdn->common.rdclass = rdata->rdclass;
00146 isdn->common.rdtype = rdata->type;
00147 ISC_LINK_INIT(&isdn->common, link);
00148
00149 dns_rdata_toregion(rdata, &r);
00150
00151 isdn->isdn_len = uint8_fromregion(&r);
00152 isc_region_consume(&r, 1);
00153 isdn->isdn = mem_maybedup(mctx, r.base, isdn->isdn_len);
00154 if (isdn->isdn == NULL)
00155 return (ISC_R_NOMEMORY);
00156 isc_region_consume(&r, isdn->isdn_len);
00157
00158 if (r.length == 0) {
00159 isdn->subaddress_len = 0;
00160 isdn->subaddress = NULL;
00161 } else {
00162 isdn->subaddress_len = uint8_fromregion(&r);
00163 isc_region_consume(&r, 1);
00164 isdn->subaddress = mem_maybedup(mctx, r.base,
00165 isdn->subaddress_len);
00166 if (isdn->subaddress == NULL)
00167 goto cleanup;
00168 }
00169
00170 isdn->mctx = mctx;
00171 return (ISC_R_SUCCESS);
00172
00173 cleanup:
00174 if (mctx != NULL && isdn->isdn != NULL)
00175 isc_mem_free(mctx, isdn->isdn);
00176 return (ISC_R_NOMEMORY);
00177 }
00178
00179 static inline void
00180 freestruct_isdn(ARGS_FREESTRUCT) {
00181 dns_rdata_isdn_t *isdn = source;
00182
00183 REQUIRE(source != NULL);
00184
00185 if (isdn->mctx == NULL)
00186 return;
00187
00188 if (isdn->isdn != NULL)
00189 isc_mem_free(isdn->mctx, isdn->isdn);
00190 if (isdn->subaddress != NULL)
00191 isc_mem_free(isdn->mctx, isdn->subaddress);
00192 isdn->mctx = NULL;
00193 }
00194
00195 static inline isc_result_t
00196 additionaldata_isdn(ARGS_ADDLDATA) {
00197 REQUIRE(rdata->type == 20);
00198
00199 UNUSED(rdata);
00200 UNUSED(add);
00201 UNUSED(arg);
00202
00203 return (ISC_R_SUCCESS);
00204 }
00205
00206 static inline isc_result_t
00207 digest_isdn(ARGS_DIGEST) {
00208 isc_region_t r;
00209
00210 REQUIRE(rdata->type == 20);
00211
00212 dns_rdata_toregion(rdata, &r);
00213
00214 return ((digest)(arg, &r));
00215 }
00216
00217 static inline isc_boolean_t
00218 checkowner_isdn(ARGS_CHECKOWNER) {
00219
00220 REQUIRE(type == 20);
00221
00222 UNUSED(name);
00223 UNUSED(type);
00224 UNUSED(rdclass);
00225 UNUSED(wildcard);
00226
00227 return (ISC_TRUE);
00228 }
00229
00230 static inline isc_boolean_t
00231 checknames_isdn(ARGS_CHECKNAMES) {
00232
00233 REQUIRE(rdata->type == 20);
00234
00235 UNUSED(rdata);
00236 UNUSED(owner);
00237 UNUSED(bad);
00238
00239 return (ISC_TRUE);
00240 }
00241
00242 static inline int
00243 casecompare_isdn(ARGS_COMPARE) {
00244 return (compare_isdn(rdata1, rdata2));
00245 }
00246
00247 #endif