00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef RDATA_GENERIC_L64_106_C
00018 #define RDATA_GENERIC_L64_106_C
00019
00020 #include <string.h>
00021
00022 #include <isc/net.h>
00023
00024 #define RRTYPE_L64_ATTRIBUTES (0)
00025
00026 static inline isc_result_t
00027 fromtext_l64(ARGS_FROMTEXT) {
00028 isc_token_t token;
00029 unsigned char locator[NS_LOCATORSZ];
00030
00031 REQUIRE(type == 106);
00032
00033 UNUSED(type);
00034 UNUSED(rdclass);
00035 UNUSED(origin);
00036 UNUSED(options);
00037 UNUSED(callbacks);
00038
00039 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
00040 ISC_FALSE));
00041 if (token.value.as_ulong > 0xffffU)
00042 RETTOK(ISC_R_RANGE);
00043 RETERR(uint16_tobuffer(token.value.as_ulong, target));
00044
00045 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
00046 ISC_FALSE));
00047
00048 if (locator_pton(DNS_AS_STR(token), locator) != 1)
00049 RETTOK(DNS_R_SYNTAX);
00050 return (mem_tobuffer(target, locator, NS_LOCATORSZ));
00051 }
00052
00053 static inline isc_result_t
00054 totext_l64(ARGS_TOTEXT) {
00055 isc_region_t region;
00056 char buf[sizeof("xxxx:xxxx:xxxx:xxxx")];
00057 unsigned short num;
00058
00059 REQUIRE(rdata->type == 106);
00060 REQUIRE(rdata->length == 10);
00061
00062 UNUSED(tctx);
00063
00064 dns_rdata_toregion(rdata, ®ion);
00065 num = uint16_fromregion(®ion);
00066 isc_region_consume(®ion, 2);
00067 sprintf(buf, "%u", num);
00068 RETERR(str_totext(buf, target));
00069
00070 RETERR(str_totext(" ", target));
00071
00072 sprintf(buf, "%x:%x:%x:%x",
00073 region.base[0]<<8 | region.base[1],
00074 region.base[2]<<8 | region.base[3],
00075 region.base[4]<<8 | region.base[5],
00076 region.base[6]<<8 | region.base[7]);
00077 return (str_totext(buf, target));
00078 }
00079
00080 static inline isc_result_t
00081 fromwire_l64(ARGS_FROMWIRE) {
00082 isc_region_t sregion;
00083
00084 REQUIRE(type == 106);
00085
00086 UNUSED(type);
00087 UNUSED(options);
00088 UNUSED(rdclass);
00089 UNUSED(dctx);
00090
00091 isc_buffer_activeregion(source, &sregion);
00092 if (sregion.length != 10)
00093 return (DNS_R_FORMERR);
00094 isc_buffer_forward(source, sregion.length);
00095 return (mem_tobuffer(target, sregion.base, sregion.length));
00096 }
00097
00098 static inline isc_result_t
00099 towire_l64(ARGS_TOWIRE) {
00100
00101 REQUIRE(rdata->type == 106);
00102 REQUIRE(rdata->length == 10);
00103
00104 UNUSED(cctx);
00105
00106 return (mem_tobuffer(target, rdata->data, rdata->length));
00107 }
00108
00109 static inline int
00110 compare_l64(ARGS_COMPARE) {
00111 isc_region_t region1;
00112 isc_region_t region2;
00113
00114 REQUIRE(rdata1->type == rdata2->type);
00115 REQUIRE(rdata1->rdclass == rdata2->rdclass);
00116 REQUIRE(rdata1->type == 106);
00117 REQUIRE(rdata1->length == 10);
00118 REQUIRE(rdata2->length == 10);
00119
00120 dns_rdata_toregion(rdata1, ®ion1);
00121 dns_rdata_toregion(rdata2, ®ion2);
00122 return (isc_region_compare(®ion1, ®ion2));
00123 }
00124
00125 static inline isc_result_t
00126 fromstruct_l64(ARGS_FROMSTRUCT) {
00127 dns_rdata_l64_t *l64 = source;
00128
00129 REQUIRE(type == 106);
00130 REQUIRE(source != NULL);
00131 REQUIRE(l64->common.rdtype == type);
00132 REQUIRE(l64->common.rdclass == rdclass);
00133
00134 UNUSED(type);
00135 UNUSED(rdclass);
00136
00137 RETERR(uint16_tobuffer(l64->pref, target));
00138 return (mem_tobuffer(target, l64->l64, sizeof(l64->l64)));
00139 }
00140
00141 static inline isc_result_t
00142 tostruct_l64(ARGS_TOSTRUCT) {
00143 isc_region_t region;
00144 dns_rdata_l64_t *l64 = target;
00145
00146 REQUIRE(rdata->type == 106);
00147 REQUIRE(target != NULL);
00148 REQUIRE(rdata->length == 10);
00149
00150 UNUSED(mctx);
00151
00152 l64->common.rdclass = rdata->rdclass;
00153 l64->common.rdtype = rdata->type;
00154 ISC_LINK_INIT(&l64->common, link);
00155
00156 dns_rdata_toregion(rdata, ®ion);
00157 l64->pref = uint16_fromregion(®ion);
00158 memmove(l64->l64, region.base, region.length);
00159 return (ISC_R_SUCCESS);
00160 }
00161
00162 static inline void
00163 freestruct_l64(ARGS_FREESTRUCT) {
00164 dns_rdata_l64_t *l64 = source;
00165
00166 REQUIRE(source != NULL);
00167 REQUIRE(l64->common.rdtype == 106);
00168
00169 return;
00170 }
00171
00172 static inline isc_result_t
00173 additionaldata_l64(ARGS_ADDLDATA) {
00174
00175 REQUIRE(rdata->type == 106);
00176 REQUIRE(rdata->length == 10);
00177
00178 UNUSED(rdata);
00179 UNUSED(add);
00180 UNUSED(arg);
00181
00182 return (ISC_R_SUCCESS);
00183 }
00184
00185 static inline isc_result_t
00186 digest_l64(ARGS_DIGEST) {
00187 isc_region_t r;
00188
00189 REQUIRE(rdata->type == 106);
00190 REQUIRE(rdata->length == 10);
00191
00192 dns_rdata_toregion(rdata, &r);
00193
00194 return ((digest)(arg, &r));
00195 }
00196
00197 static inline isc_boolean_t
00198 checkowner_l64(ARGS_CHECKOWNER) {
00199
00200 REQUIRE(type == 106);
00201
00202 UNUSED(name);
00203 UNUSED(type);
00204 UNUSED(rdclass);
00205 UNUSED(wildcard);
00206
00207 return (ISC_TRUE);
00208 }
00209
00210 static inline isc_boolean_t
00211 checknames_l64(ARGS_CHECKNAMES) {
00212
00213 REQUIRE(rdata->type == 106);
00214 REQUIRE(rdata->length == 10);
00215
00216 UNUSED(rdata);
00217 UNUSED(owner);
00218 UNUSED(bad);
00219
00220 return (ISC_TRUE);
00221 }
00222
00223 static inline int
00224 casecompare_l64(ARGS_COMPARE) {
00225 return (compare_l64(rdata1, rdata2));
00226 }
00227
00228 #endif