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_HINFO_13_C
00025 #define RDATA_GENERIC_HINFO_13_C
00026 
00027 #define RRTYPE_HINFO_ATTRIBUTES (0)
00028 
00029 static inline isc_result_t
00030 fromtext_hinfo(ARGS_FROMTEXT) {
00031         isc_token_t token;
00032         int i;
00033 
00034         UNUSED(type);
00035         UNUSED(rdclass);
00036         UNUSED(origin);
00037         UNUSED(options);
00038         UNUSED(callbacks);
00039 
00040         REQUIRE(type == 13);
00041 
00042         for (i = 0; i < 2; i++) {
00043                 RETERR(isc_lex_getmastertoken(lexer, &token,
00044                                               isc_tokentype_qstring,
00045                                               ISC_FALSE));
00046                 RETTOK(txt_fromtext(&token.value.as_textregion, target));
00047         }
00048         return (ISC_R_SUCCESS);
00049 }
00050 
00051 static inline isc_result_t
00052 totext_hinfo(ARGS_TOTEXT) {
00053         isc_region_t region;
00054 
00055         UNUSED(tctx);
00056 
00057         REQUIRE(rdata->type == 13);
00058         REQUIRE(rdata->length != 0);
00059 
00060         dns_rdata_toregion(rdata, ®ion);
00061         RETERR(txt_totext(®ion, ISC_TRUE, target));
00062         RETERR(str_totext(" ", target));
00063         return (txt_totext(®ion, ISC_TRUE, target));
00064 }
00065 
00066 static inline isc_result_t
00067 fromwire_hinfo(ARGS_FROMWIRE) {
00068 
00069         REQUIRE(type == 13);
00070 
00071         UNUSED(type);
00072         UNUSED(dctx);
00073         UNUSED(rdclass);
00074         UNUSED(options);
00075 
00076         RETERR(txt_fromwire(source, target));
00077         return (txt_fromwire(source, target));
00078 }
00079 
00080 static inline isc_result_t
00081 towire_hinfo(ARGS_TOWIRE) {
00082 
00083         UNUSED(cctx);
00084 
00085         REQUIRE(rdata->type == 13);
00086         REQUIRE(rdata->length != 0);
00087 
00088         return (mem_tobuffer(target, rdata->data, rdata->length));
00089 }
00090 
00091 static inline int
00092 compare_hinfo(ARGS_COMPARE) {
00093         isc_region_t r1;
00094         isc_region_t r2;
00095 
00096         REQUIRE(rdata1->type == rdata2->type);
00097         REQUIRE(rdata1->rdclass == rdata2->rdclass);
00098         REQUIRE(rdata1->type == 13);
00099         REQUIRE(rdata1->length != 0);
00100         REQUIRE(rdata2->length != 0);
00101 
00102         dns_rdata_toregion(rdata1, &r1);
00103         dns_rdata_toregion(rdata2, &r2);
00104         return (isc_region_compare(&r1, &r2));
00105 }
00106 
00107 static inline isc_result_t
00108 fromstruct_hinfo(ARGS_FROMSTRUCT) {
00109         dns_rdata_hinfo_t *hinfo = source;
00110 
00111         REQUIRE(type == 13);
00112         REQUIRE(source != NULL);
00113         REQUIRE(hinfo->common.rdtype == type);
00114         REQUIRE(hinfo->common.rdclass == rdclass);
00115 
00116         UNUSED(type);
00117         UNUSED(rdclass);
00118 
00119         RETERR(uint8_tobuffer(hinfo->cpu_len, target));
00120         RETERR(mem_tobuffer(target, hinfo->cpu, hinfo->cpu_len));
00121         RETERR(uint8_tobuffer(hinfo->os_len, target));
00122         return (mem_tobuffer(target, hinfo->os, hinfo->os_len));
00123 }
00124 
00125 static inline isc_result_t
00126 tostruct_hinfo(ARGS_TOSTRUCT) {
00127         dns_rdata_hinfo_t *hinfo = target;
00128         isc_region_t region;
00129 
00130         REQUIRE(rdata->type == 13);
00131         REQUIRE(target != NULL);
00132         REQUIRE(rdata->length != 0);
00133 
00134         hinfo->common.rdclass = rdata->rdclass;
00135         hinfo->common.rdtype = rdata->type;
00136         ISC_LINK_INIT(&hinfo->common, link);
00137 
00138         dns_rdata_toregion(rdata, ®ion);
00139         hinfo->cpu_len = uint8_fromregion(®ion);
00140         isc_region_consume(®ion, 1);
00141         hinfo->cpu = mem_maybedup(mctx, region.base, hinfo->cpu_len);
00142         if (hinfo->cpu == NULL)
00143                 return (ISC_R_NOMEMORY);
00144         isc_region_consume(®ion, hinfo->cpu_len);
00145 
00146         hinfo->os_len = uint8_fromregion(®ion);
00147         isc_region_consume(®ion, 1);
00148         hinfo->os = mem_maybedup(mctx, region.base, hinfo->os_len);
00149         if (hinfo->os == NULL)
00150                 goto cleanup;
00151 
00152         hinfo->mctx = mctx;
00153         return (ISC_R_SUCCESS);
00154 
00155  cleanup:
00156         if (mctx != NULL && hinfo->cpu != NULL)
00157                 isc_mem_free(mctx, hinfo->cpu);
00158         return (ISC_R_NOMEMORY);
00159 }
00160 
00161 static inline void
00162 freestruct_hinfo(ARGS_FREESTRUCT) {
00163         dns_rdata_hinfo_t *hinfo = source;
00164 
00165         REQUIRE(source != NULL);
00166 
00167         if (hinfo->mctx == NULL)
00168                 return;
00169 
00170         if (hinfo->cpu != NULL)
00171                 isc_mem_free(hinfo->mctx, hinfo->cpu);
00172         if (hinfo->os != NULL)
00173                 isc_mem_free(hinfo->mctx, hinfo->os);
00174         hinfo->mctx = NULL;
00175 }
00176 
00177 static inline isc_result_t
00178 additionaldata_hinfo(ARGS_ADDLDATA) {
00179         REQUIRE(rdata->type == 13);
00180 
00181         UNUSED(add);
00182         UNUSED(arg);
00183         UNUSED(rdata);
00184 
00185         return (ISC_R_SUCCESS);
00186 }
00187 
00188 static inline isc_result_t
00189 digest_hinfo(ARGS_DIGEST) {
00190         isc_region_t r;
00191 
00192         REQUIRE(rdata->type == 13);
00193 
00194         dns_rdata_toregion(rdata, &r);
00195 
00196         return ((digest)(arg, &r));
00197 }
00198 
00199 static inline isc_boolean_t
00200 checkowner_hinfo(ARGS_CHECKOWNER) {
00201 
00202         REQUIRE(type == 13);
00203 
00204         UNUSED(name);
00205         UNUSED(type);
00206         UNUSED(rdclass);
00207         UNUSED(wildcard);
00208 
00209         return (ISC_TRUE);
00210 }
00211 
00212 static inline isc_boolean_t
00213 checknames_hinfo(ARGS_CHECKNAMES) {
00214 
00215         REQUIRE(rdata->type == 13);
00216 
00217         UNUSED(rdata);
00218         UNUSED(owner);
00219         UNUSED(bad);
00220 
00221         return (ISC_TRUE);
00222 }
00223 
00224 static inline int
00225 casecompare_hinfo(ARGS_COMPARE) {
00226         return (compare_hinfo(rdata1, rdata2));
00227 }
00228 #endif