00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef RDATA_IN_1_A_1_C
00023 #define RDATA_IN_1_A_1_C
00024
00025 #include <string.h>
00026
00027 #include <isc/net.h>
00028
00029 #define RRTYPE_A_ATTRIBUTES (0)
00030
00031 static inline isc_result_t
00032 fromtext_in_a(ARGS_FROMTEXT) {
00033 isc_token_t token;
00034 struct in_addr addr;
00035 isc_region_t region;
00036
00037 REQUIRE(type == 1);
00038 REQUIRE(rdclass == 1);
00039
00040 UNUSED(type);
00041 UNUSED(origin);
00042 UNUSED(options);
00043 UNUSED(rdclass);
00044
00045 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
00046 ISC_FALSE));
00047
00048 if (getquad(DNS_AS_STR(token), &addr, lexer, callbacks) != 1)
00049 RETTOK(DNS_R_BADDOTTEDQUAD);
00050 isc_buffer_availableregion(target, ®ion);
00051 if (region.length < 4)
00052 return (ISC_R_NOSPACE);
00053 memmove(region.base, &addr, 4);
00054 isc_buffer_add(target, 4);
00055 return (ISC_R_SUCCESS);
00056 }
00057
00058 static inline isc_result_t
00059 totext_in_a(ARGS_TOTEXT) {
00060 isc_region_t region;
00061
00062 REQUIRE(rdata->type == 1);
00063 REQUIRE(rdata->rdclass == 1);
00064 REQUIRE(rdata->length == 4);
00065
00066 UNUSED(tctx);
00067
00068 dns_rdata_toregion(rdata, ®ion);
00069 return (inet_totext(AF_INET, ®ion, target));
00070 }
00071
00072 static inline isc_result_t
00073 fromwire_in_a(ARGS_FROMWIRE) {
00074 isc_region_t sregion;
00075 isc_region_t tregion;
00076
00077 REQUIRE(type == 1);
00078 REQUIRE(rdclass == 1);
00079
00080 UNUSED(type);
00081 UNUSED(dctx);
00082 UNUSED(options);
00083 UNUSED(rdclass);
00084
00085 isc_buffer_activeregion(source, &sregion);
00086 isc_buffer_availableregion(target, &tregion);
00087 if (sregion.length < 4)
00088 return (ISC_R_UNEXPECTEDEND);
00089 if (tregion.length < 4)
00090 return (ISC_R_NOSPACE);
00091
00092 memmove(tregion.base, sregion.base, 4);
00093 isc_buffer_forward(source, 4);
00094 isc_buffer_add(target, 4);
00095 return (ISC_R_SUCCESS);
00096 }
00097
00098 static inline isc_result_t
00099 towire_in_a(ARGS_TOWIRE) {
00100 isc_region_t region;
00101
00102 REQUIRE(rdata->type == 1);
00103 REQUIRE(rdata->rdclass == 1);
00104 REQUIRE(rdata->length == 4);
00105
00106 UNUSED(cctx);
00107
00108 isc_buffer_availableregion(target, ®ion);
00109 if (region.length < rdata->length)
00110 return (ISC_R_NOSPACE);
00111 memmove(region.base, rdata->data, rdata->length);
00112 isc_buffer_add(target, 4);
00113 return (ISC_R_SUCCESS);
00114 }
00115
00116 static inline int
00117 compare_in_a(ARGS_COMPARE) {
00118 isc_region_t r1;
00119 isc_region_t r2;
00120
00121 REQUIRE(rdata1->type == rdata2->type);
00122 REQUIRE(rdata1->rdclass == rdata2->rdclass);
00123 REQUIRE(rdata1->type == 1);
00124 REQUIRE(rdata1->rdclass == 1);
00125 REQUIRE(rdata1->length == 4);
00126 REQUIRE(rdata2->length == 4);
00127
00128 dns_rdata_toregion(rdata1, &r1);
00129 dns_rdata_toregion(rdata2, &r2);
00130 return (isc_region_compare(&r1, &r2));
00131 }
00132
00133 static inline isc_result_t
00134 fromstruct_in_a(ARGS_FROMSTRUCT) {
00135 dns_rdata_in_a_t *a = source;
00136 isc_uint32_t n;
00137
00138 REQUIRE(type == 1);
00139 REQUIRE(rdclass == 1);
00140 REQUIRE(source != NULL);
00141 REQUIRE(a->common.rdtype == type);
00142 REQUIRE(a->common.rdclass == rdclass);
00143
00144 UNUSED(type);
00145 UNUSED(rdclass);
00146
00147 n = ntohl(a->in_addr.s_addr);
00148
00149 return (uint32_tobuffer(n, target));
00150 }
00151
00152
00153 static inline isc_result_t
00154 tostruct_in_a(ARGS_TOSTRUCT) {
00155 dns_rdata_in_a_t *a = target;
00156 isc_uint32_t n;
00157 isc_region_t region;
00158
00159 REQUIRE(rdata->type == 1);
00160 REQUIRE(rdata->rdclass == 1);
00161 REQUIRE(rdata->length == 4);
00162
00163 UNUSED(mctx);
00164
00165 a->common.rdclass = rdata->rdclass;
00166 a->common.rdtype = rdata->type;
00167 ISC_LINK_INIT(&a->common, link);
00168
00169 dns_rdata_toregion(rdata, ®ion);
00170 n = uint32_fromregion(®ion);
00171 a->in_addr.s_addr = htonl(n);
00172
00173 return (ISC_R_SUCCESS);
00174 }
00175
00176 static inline void
00177 freestruct_in_a(ARGS_FREESTRUCT) {
00178 dns_rdata_in_a_t *a = source;
00179
00180 REQUIRE(source != NULL);
00181 REQUIRE(a->common.rdtype == 1);
00182 REQUIRE(a->common.rdclass == 1);
00183
00184 UNUSED(a);
00185 }
00186
00187 static inline isc_result_t
00188 additionaldata_in_a(ARGS_ADDLDATA) {
00189 REQUIRE(rdata->type == 1);
00190 REQUIRE(rdata->rdclass == 1);
00191
00192 UNUSED(rdata);
00193 UNUSED(add);
00194 UNUSED(arg);
00195
00196 return (ISC_R_SUCCESS);
00197 }
00198
00199 static inline isc_result_t
00200 digest_in_a(ARGS_DIGEST) {
00201 isc_region_t r;
00202
00203 REQUIRE(rdata->type == 1);
00204 REQUIRE(rdata->rdclass == 1);
00205
00206 dns_rdata_toregion(rdata, &r);
00207
00208 return ((digest)(arg, &r));
00209 }
00210
00211 static inline isc_boolean_t
00212 checkowner_in_a(ARGS_CHECKOWNER) {
00213
00214 REQUIRE(type == 1);
00215 REQUIRE(rdclass == 1);
00216
00217 UNUSED(type);
00218 UNUSED(rdclass);
00219
00220 return (dns_name_ishostname(name, wildcard));
00221 }
00222
00223 static inline isc_boolean_t
00224 checknames_in_a(ARGS_CHECKNAMES) {
00225
00226 REQUIRE(rdata->type == 1);
00227 REQUIRE(rdata->rdclass == 1);
00228
00229 UNUSED(rdata);
00230 UNUSED(owner);
00231 UNUSED(bad);
00232
00233 return (ISC_TRUE);
00234 }
00235
00236 static inline int
00237 casecompare_in_a(ARGS_COMPARE) {
00238 return (compare_in_a(rdata1, rdata2));
00239 }
00240
00241 #endif