Annotation of src/external/mpl/bind/dist/lib/dns/rdata/generic/l64_106.c, Revision 1.3.2.2
1.3.2.2 ! christos 1: /* $NetBSD: l64_106.c,v 1.3 2019/01/09 16:55:13 christos Exp $ */
! 2:
! 3: /*
! 4: * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
! 5: *
! 6: * This Source Code Form is subject to the terms of the Mozilla Public
! 7: * License, v. 2.0. If a copy of the MPL was not distributed with this
! 8: * file, You can obtain one at http://mozilla.org/MPL/2.0/.
! 9: *
! 10: * See the COPYRIGHT file distributed with this work for additional
! 11: * information regarding copyright ownership.
! 12: */
! 13:
! 14: #ifndef RDATA_GENERIC_L64_106_C
! 15: #define RDATA_GENERIC_L64_106_C
! 16:
! 17: #include <string.h>
! 18:
! 19: #include <isc/net.h>
! 20:
! 21: #define RRTYPE_L64_ATTRIBUTES (0)
! 22:
! 23: static inline isc_result_t
! 24: fromtext_l64(ARGS_FROMTEXT) {
! 25: isc_token_t token;
! 26: unsigned char locator[NS_LOCATORSZ];
! 27:
! 28: REQUIRE(type == dns_rdatatype_l64);
! 29:
! 30: UNUSED(type);
! 31: UNUSED(rdclass);
! 32: UNUSED(origin);
! 33: UNUSED(options);
! 34: UNUSED(callbacks);
! 35:
! 36: RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
! 37: false));
! 38: if (token.value.as_ulong > 0xffffU)
! 39: RETTOK(ISC_R_RANGE);
! 40: RETERR(uint16_tobuffer(token.value.as_ulong, target));
! 41:
! 42: RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
! 43: false));
! 44:
! 45: if (locator_pton(DNS_AS_STR(token), locator) != 1)
! 46: RETTOK(DNS_R_SYNTAX);
! 47: return (mem_tobuffer(target, locator, NS_LOCATORSZ));
! 48: }
! 49:
! 50: static inline isc_result_t
! 51: totext_l64(ARGS_TOTEXT) {
! 52: isc_region_t region;
! 53: char buf[sizeof("xxxx:xxxx:xxxx:xxxx")];
! 54: unsigned short num;
! 55:
! 56: REQUIRE(rdata->type == dns_rdatatype_l64);
! 57: REQUIRE(rdata->length == 10);
! 58:
! 59: UNUSED(tctx);
! 60:
! 61: dns_rdata_toregion(rdata, ®ion);
! 62: num = uint16_fromregion(®ion);
! 63: isc_region_consume(®ion, 2);
! 64: snprintf(buf, sizeof(buf), "%u", num);
! 65: RETERR(str_totext(buf, target));
! 66:
! 67: RETERR(str_totext(" ", target));
! 68:
! 69: snprintf(buf, sizeof(buf), "%x:%x:%x:%x",
! 70: region.base[0]<<8 | region.base[1],
! 71: region.base[2]<<8 | region.base[3],
! 72: region.base[4]<<8 | region.base[5],
! 73: region.base[6]<<8 | region.base[7]);
! 74: return (str_totext(buf, target));
! 75: }
! 76:
! 77: static inline isc_result_t
! 78: fromwire_l64(ARGS_FROMWIRE) {
! 79: isc_region_t sregion;
! 80:
! 81: REQUIRE(type == dns_rdatatype_l64);
! 82:
! 83: UNUSED(type);
! 84: UNUSED(options);
! 85: UNUSED(rdclass);
! 86: UNUSED(dctx);
! 87:
! 88: isc_buffer_activeregion(source, &sregion);
! 89: if (sregion.length != 10)
! 90: return (DNS_R_FORMERR);
! 91: isc_buffer_forward(source, sregion.length);
! 92: return (mem_tobuffer(target, sregion.base, sregion.length));
! 93: }
! 94:
! 95: static inline isc_result_t
! 96: towire_l64(ARGS_TOWIRE) {
! 97:
! 98: REQUIRE(rdata->type == dns_rdatatype_l64);
! 99: REQUIRE(rdata->length == 10);
! 100:
! 101: UNUSED(cctx);
! 102:
! 103: return (mem_tobuffer(target, rdata->data, rdata->length));
! 104: }
! 105:
! 106: static inline int
! 107: compare_l64(ARGS_COMPARE) {
! 108: isc_region_t region1;
! 109: isc_region_t region2;
! 110:
! 111: REQUIRE(rdata1->type == rdata2->type);
! 112: REQUIRE(rdata1->rdclass == rdata2->rdclass);
! 113: REQUIRE(rdata1->type == dns_rdatatype_l64);
! 114: REQUIRE(rdata1->length == 10);
! 115: REQUIRE(rdata2->length == 10);
! 116:
! 117: dns_rdata_toregion(rdata1, ®ion1);
! 118: dns_rdata_toregion(rdata2, ®ion2);
! 119: return (isc_region_compare(®ion1, ®ion2));
! 120: }
! 121:
! 122: static inline isc_result_t
! 123: fromstruct_l64(ARGS_FROMSTRUCT) {
! 124: dns_rdata_l64_t *l64 = source;
! 125:
! 126: REQUIRE(type == dns_rdatatype_l64);
! 127: REQUIRE(source != NULL);
! 128: REQUIRE(l64->common.rdtype == type);
! 129: REQUIRE(l64->common.rdclass == rdclass);
! 130:
! 131: UNUSED(type);
! 132: UNUSED(rdclass);
! 133:
! 134: RETERR(uint16_tobuffer(l64->pref, target));
! 135: return (mem_tobuffer(target, l64->l64, sizeof(l64->l64)));
! 136: }
! 137:
! 138: static inline isc_result_t
! 139: tostruct_l64(ARGS_TOSTRUCT) {
! 140: isc_region_t region;
! 141: dns_rdata_l64_t *l64 = target;
! 142:
! 143: REQUIRE(rdata->type == dns_rdatatype_l64);
! 144: REQUIRE(target != NULL);
! 145: REQUIRE(rdata->length == 10);
! 146:
! 147: UNUSED(mctx);
! 148:
! 149: l64->common.rdclass = rdata->rdclass;
! 150: l64->common.rdtype = rdata->type;
! 151: ISC_LINK_INIT(&l64->common, link);
! 152:
! 153: dns_rdata_toregion(rdata, ®ion);
! 154: l64->pref = uint16_fromregion(®ion);
! 155: memmove(l64->l64, region.base, region.length);
! 156: return (ISC_R_SUCCESS);
! 157: }
! 158:
! 159: static inline void
! 160: freestruct_l64(ARGS_FREESTRUCT) {
! 161: dns_rdata_l64_t *l64 = source;
! 162:
! 163: REQUIRE(source != NULL);
! 164: REQUIRE(l64->common.rdtype == dns_rdatatype_l64);
! 165:
! 166: return;
! 167: }
! 168:
! 169: static inline isc_result_t
! 170: additionaldata_l64(ARGS_ADDLDATA) {
! 171:
! 172: REQUIRE(rdata->type == dns_rdatatype_l64);
! 173: REQUIRE(rdata->length == 10);
! 174:
! 175: UNUSED(rdata);
! 176: UNUSED(add);
! 177: UNUSED(arg);
! 178:
! 179: return (ISC_R_SUCCESS);
! 180: }
! 181:
! 182: static inline isc_result_t
! 183: digest_l64(ARGS_DIGEST) {
! 184: isc_region_t r;
! 185:
! 186: REQUIRE(rdata->type == dns_rdatatype_l64);
! 187: REQUIRE(rdata->length == 10);
! 188:
! 189: dns_rdata_toregion(rdata, &r);
! 190:
! 191: return ((digest)(arg, &r));
! 192: }
! 193:
! 194: static inline bool
! 195: checkowner_l64(ARGS_CHECKOWNER) {
! 196:
! 197: REQUIRE(type == dns_rdatatype_l64);
! 198:
! 199: UNUSED(name);
! 200: UNUSED(type);
! 201: UNUSED(rdclass);
! 202: UNUSED(wildcard);
! 203:
! 204: return (true);
! 205: }
! 206:
! 207: static inline bool
! 208: checknames_l64(ARGS_CHECKNAMES) {
! 209:
! 210: REQUIRE(rdata->type == dns_rdatatype_l64);
! 211: REQUIRE(rdata->length == 10);
! 212:
! 213: UNUSED(rdata);
! 214: UNUSED(owner);
! 215: UNUSED(bad);
! 216:
! 217: return (true);
! 218: }
! 219:
! 220: static inline int
! 221: casecompare_l64(ARGS_COMPARE) {
! 222: return (compare_l64(rdata1, rdata2));
! 223: }
! 224:
! 225: #endif /* RDATA_GENERIC_L64_106_C */
CVSweb <webmaster@jp.NetBSD.org>