naptr_35.c 12.5 KB
Newer Older
Mark Andrews's avatar
Mark Andrews committed
1
/*
Brian Wellington's avatar
Brian Wellington committed
2
 * Copyright (C) 1999-2001  Internet Software Consortium.
3
 *
Mark Andrews's avatar
Mark Andrews committed
4 5 6
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
7
 *
8 9 10 11 12 13 14 15
 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
 * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Mark Andrews's avatar
Mark Andrews committed
16 17
 */

18
/* $Id: naptr_35.c,v 1.38 2001/01/18 22:05:40 bwelling Exp $ */
Mark Andrews's avatar
Mark Andrews committed
19

20 21
/* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */

22
/* RFC 2915 */
Mark Andrews's avatar
Mark Andrews committed
23

24 25
#ifndef RDATA_IN_1_NAPTR_35_C
#define RDATA_IN_1_NAPTR_35_C
Mark Andrews's avatar
Mark Andrews committed
26

27 28
#define RRTYPE_NAPTR_ATTRIBUTES (0)

29
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
30
fromtext_in_naptr(ARGS_FROMTEXT) {
Mark Andrews's avatar
Mark Andrews committed
31 32 33 34 35
	isc_token_t token;
	dns_name_t name;
	isc_buffer_t buffer;

	REQUIRE(type == 35);
36
	REQUIRE(rdclass == 1);
Mark Andrews's avatar
Mark Andrews committed
37

38 39
	UNUSED(rdclass);

David Lawrence's avatar
David Lawrence committed
40 41 42
	/*
	 * Order.
	 */
43 44
	RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
				      ISC_FALSE));
45
	if (token.value.as_ulong > 0xffff)
David Lawrence's avatar
David Lawrence committed
46
		return (ISC_R_RANGE);
Mark Andrews's avatar
Mark Andrews committed
47 48
	RETERR(uint16_tobuffer(token.value.as_ulong, target));

David Lawrence's avatar
David Lawrence committed
49 50 51
	/*
	 * Preference.
	 */
52 53
	RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
				      ISC_FALSE));
54
	if (token.value.as_ulong > 0xffff)
David Lawrence's avatar
David Lawrence committed
55
		return (ISC_R_RANGE);
Mark Andrews's avatar
Mark Andrews committed
56 57
	RETERR(uint16_tobuffer(token.value.as_ulong, target));

David Lawrence's avatar
David Lawrence committed
58 59 60
	/*
	 * Flags.
	 */
61 62
	RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
				      ISC_FALSE));
Mark Andrews's avatar
Mark Andrews committed
63 64
	RETERR(txt_fromtext(&token.value.as_textregion, target));

David Lawrence's avatar
David Lawrence committed
65 66 67
	/*
	 * Service.
	 */
68 69
	RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
				      ISC_FALSE));
Mark Andrews's avatar
Mark Andrews committed
70 71
	RETERR(txt_fromtext(&token.value.as_textregion, target));

David Lawrence's avatar
David Lawrence committed
72 73 74
	/*
	 * Regexp.
	 */
75 76
	RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
				      ISC_FALSE));
Mark Andrews's avatar
Mark Andrews committed
77 78
	RETERR(txt_fromtext(&token.value.as_textregion, target));

David Lawrence's avatar
David Lawrence committed
79 80 81
	/*
	 * Replacement.
	 */
82 83
	RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
				      ISC_FALSE));
Mark Andrews's avatar
Mark Andrews committed
84
	dns_name_init(&name, NULL);
85
	buffer_fromregion(&buffer, &token.value.as_region);
Mark Andrews's avatar
Mark Andrews committed
86 87 88 89
	origin = (origin != NULL) ? origin : dns_rootname;
	return (dns_name_fromtext(&name, &buffer, origin, downcase, target));
}

90
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
91
totext_in_naptr(ARGS_TOTEXT) {
Mark Andrews's avatar
Mark Andrews committed
92 93 94 95 96 97 98 99
	isc_region_t region;
	dns_name_t name;
	dns_name_t prefix;
	isc_boolean_t sub;
	char buf[sizeof "64000"];
	unsigned short num;

	REQUIRE(rdata->type == 35);
100
	REQUIRE(rdata->rdclass == 1);
101
	REQUIRE(rdata->length != 0);
Mark Andrews's avatar
Mark Andrews committed
102 103 104 105 106

	dns_name_init(&name, NULL);
	dns_name_init(&prefix, NULL);

	dns_rdata_toregion(rdata, &region);
107

David Lawrence's avatar
David Lawrence committed
108 109 110
	/*
	 * Order.
	 */
Mark Andrews's avatar
Mark Andrews committed
111 112 113 114 115 116
	num = uint16_fromregion(&region);
	isc_region_consume(&region, 2);
	sprintf(buf, "%u", num);
	RETERR(str_totext(buf, target));
	RETERR(str_totext(" ", target));

David Lawrence's avatar
David Lawrence committed
117 118 119
	/*
	 * Preference.
	 */
Mark Andrews's avatar
Mark Andrews committed
120 121 122 123 124 125
	num = uint16_fromregion(&region);
	isc_region_consume(&region, 2);
	sprintf(buf, "%u", num);
	RETERR(str_totext(buf, target));
	RETERR(str_totext(" ", target));

David Lawrence's avatar
David Lawrence committed
126 127 128
	/*
	 * Flags.
	 */
Mark Andrews's avatar
Mark Andrews committed
129 130 131
	RETERR(txt_totext(&region, target));
	RETERR(str_totext(" ", target));

David Lawrence's avatar
David Lawrence committed
132 133 134
	/*
	 * Service.
	 */
Mark Andrews's avatar
Mark Andrews committed
135 136 137
	RETERR(txt_totext(&region, target));
	RETERR(str_totext(" ", target));

David Lawrence's avatar
David Lawrence committed
138 139 140
	/*
	 * Regexp.
	 */
Mark Andrews's avatar
Mark Andrews committed
141 142 143
	RETERR(txt_totext(&region, target));
	RETERR(str_totext(" ", target));

David Lawrence's avatar
David Lawrence committed
144 145 146
	/*
	 * Replacement.
	 */
Mark Andrews's avatar
Mark Andrews committed
147
	dns_name_fromregion(&name, &region);
148
	sub = name_prefix(&name, tctx->origin, &prefix);
149
	return (dns_name_totext(&prefix, sub, target));
Mark Andrews's avatar
Mark Andrews committed
150 151
}

152
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
153
fromwire_in_naptr(ARGS_FROMWIRE) {
Mark Andrews's avatar
Mark Andrews committed
154 155 156 157
        dns_name_t name;
	isc_region_t sr;

	REQUIRE(type == 35);
158
	REQUIRE(rdclass == 1);
Mark Andrews's avatar
Mark Andrews committed
159

160 161
	UNUSED(rdclass);

162
	dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
163

Mark Andrews's avatar
Mark Andrews committed
164 165
        dns_name_init(&name, NULL);

David Lawrence's avatar
David Lawrence committed
166 167 168
	/*
	 * Order, preference.
	 */
169
	isc_buffer_activeregion(source, &sr);
Mark Andrews's avatar
Mark Andrews committed
170
	if (sr.length < 4)
171
		return (ISC_R_UNEXPECTEDEND);
Mark Andrews's avatar
Mark Andrews committed
172 173 174
	RETERR(mem_tobuffer(target, sr.base, 4));
	isc_buffer_forward(source, 4);

David Lawrence's avatar
David Lawrence committed
175 176 177
	/*
	 * Flags.
	 */
Mark Andrews's avatar
Mark Andrews committed
178 179
	RETERR(txt_fromwire(source, target));

David Lawrence's avatar
David Lawrence committed
180 181 182
	/*
	 * Service.
	 */
Mark Andrews's avatar
Mark Andrews committed
183 184
	RETERR(txt_fromwire(source, target));

David Lawrence's avatar
David Lawrence committed
185 186 187
	/*
	 * Regexp.
	 */
Mark Andrews's avatar
Mark Andrews committed
188 189
	RETERR(txt_fromwire(source, target));

David Lawrence's avatar
David Lawrence committed
190 191 192
	/*
	 * Replacement.
	 */
Mark Andrews's avatar
Mark Andrews committed
193 194 195
	return (dns_name_fromwire(&name, source, dctx, downcase, target));
}

196
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
197
towire_in_naptr(ARGS_TOWIRE) {
Mark Andrews's avatar
Mark Andrews committed
198 199 200 201
	dns_name_t name;
	isc_region_t sr;

	REQUIRE(rdata->type == 35);
202
	REQUIRE(rdata->rdclass == 1);
203
	REQUIRE(rdata->length != 0);
Mark Andrews's avatar
Mark Andrews committed
204

205
	dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
David Lawrence's avatar
David Lawrence committed
206 207 208
	/*
	 * Order, preference.
	 */
Mark Andrews's avatar
Mark Andrews committed
209 210 211
	dns_rdata_toregion(rdata, &sr);
	RETERR(mem_tobuffer(target, sr.base, 4));
	isc_region_consume(&sr, 4);
212

David Lawrence's avatar
David Lawrence committed
213 214 215
	/*
	 * Flags.
	 */
Mark Andrews's avatar
Mark Andrews committed
216 217 218
	RETERR(mem_tobuffer(target, sr.base, sr.base[0] + 1));
	isc_region_consume(&sr, sr.base[0] + 1);

David Lawrence's avatar
David Lawrence committed
219 220 221
	/*
	 * Service.
	 */
Mark Andrews's avatar
Mark Andrews committed
222 223 224
	RETERR(mem_tobuffer(target, sr.base, sr.base[0] + 1));
	isc_region_consume(&sr, sr.base[0] + 1);

David Lawrence's avatar
David Lawrence committed
225 226 227
	/*
	 * Regexp.
	 */
Mark Andrews's avatar
Mark Andrews committed
228 229 230
	RETERR(mem_tobuffer(target, sr.base, sr.base[0] + 1));
	isc_region_consume(&sr, sr.base[0] + 1);

David Lawrence's avatar
David Lawrence committed
231 232 233
	/*
	 * Replacement.
	 */
Mark Andrews's avatar
Mark Andrews committed
234 235 236 237 238
	dns_name_init(&name, NULL);
	dns_name_fromregion(&name, &sr);
	return (dns_name_towire(&name, cctx, target));
}

239
static inline int
David Lawrence's avatar
David Lawrence committed
240
compare_in_naptr(ARGS_COMPARE) {
Mark Andrews's avatar
Mark Andrews committed
241 242 243 244
	dns_name_t name1;
	dns_name_t name2;
	isc_region_t region1;
	isc_region_t region2;
245
	int order, len;
Mark Andrews's avatar
Mark Andrews committed
246 247

	REQUIRE(rdata1->type == rdata2->type);
248
	REQUIRE(rdata1->rdclass == rdata2->rdclass);
Mark Andrews's avatar
Mark Andrews committed
249
	REQUIRE(rdata1->type == 35);
250
	REQUIRE(rdata1->rdclass == 1);
251 252
	REQUIRE(rdata1->length != 0);
	REQUIRE(rdata2->length != 0);
Mark Andrews's avatar
Mark Andrews committed
253 254 255 256

	dns_rdata_toregion(rdata1, &region1);
	dns_rdata_toregion(rdata2, &region2);

David Lawrence's avatar
David Lawrence committed
257 258 259
	/*
	 * Order, preference.
	 */
260 261 262
	order = memcmp(region1.base, region2.base, 4);
	if (order != 0)
		return (order < 0 ? -1 : 1);
Mark Andrews's avatar
Mark Andrews committed
263 264 265
	isc_region_consume(&region1, 4);
	isc_region_consume(&region2, 4);

David Lawrence's avatar
David Lawrence committed
266 267 268
	/*
	 * Flags.
	 */
269
	len = ISC_MIN(region1.base[0], region2.base[0]);
270 271 272
	order = memcmp(region1.base, region2.base, len + 1);
	if (order != 0)
		return (order < 0 ? -1 : 1);
Mark Andrews's avatar
Mark Andrews committed
273 274 275
	isc_region_consume(&region1, region1.base[0] + 1);
	isc_region_consume(&region2, region2.base[0] + 1);

David Lawrence's avatar
David Lawrence committed
276 277 278
	/*
	 * Service.
	 */
279
	len = ISC_MIN(region1.base[0], region2.base[0]);
280 281 282
	order = memcmp(region1.base, region2.base, len + 1);
	if (order != 0)
		return (order < 0 ? -1 : 1);
Mark Andrews's avatar
Mark Andrews committed
283 284 285
	isc_region_consume(&region1, region1.base[0] + 1);
	isc_region_consume(&region2, region2.base[0] + 1);

David Lawrence's avatar
David Lawrence committed
286 287 288
	/*
	 * Regexp.
	 */
289
	len = ISC_MIN(region1.base[0], region2.base[0]);
290 291 292
	order = memcmp(region1.base, region2.base, len + 1);
	if (order != 0)
		return (order < 0 ? -1 : 1);
Mark Andrews's avatar
Mark Andrews committed
293 294 295
	isc_region_consume(&region1, region1.base[0] + 1);
	isc_region_consume(&region2, region2.base[0] + 1);

David Lawrence's avatar
David Lawrence committed
296 297 298
	/*
	 * Replacement.
	 */
Mark Andrews's avatar
Mark Andrews committed
299 300 301 302 303 304
	dns_name_init(&name1, NULL);
	dns_name_init(&name2, NULL);

	dns_name_fromregion(&name1, &region1);
	dns_name_fromregion(&name2, &region2);

305
	return (dns_name_rdatacompare(&name1, &name2));
Mark Andrews's avatar
Mark Andrews committed
306 307
}

308
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
309
fromstruct_in_naptr(ARGS_FROMSTRUCT) {
310 311
	dns_rdata_in_naptr_t *naptr = source;
	isc_region_t region;
Mark Andrews's avatar
Mark Andrews committed
312 313

	REQUIRE(type == 35);
314
	REQUIRE(rdclass == 1);
315 316 317 318 319 320 321 322 323 324
	REQUIRE(source != NULL);
	REQUIRE(naptr->common.rdtype == type);
	REQUIRE(naptr->common.rdclass == rdclass);
	REQUIRE((naptr->flags == NULL && naptr->flags_len == 0) ||
		(naptr->flags != NULL && naptr->flags_len != 0));
	REQUIRE((naptr->service == NULL && naptr->service_len == 0) ||
		(naptr->service != NULL && naptr->service_len != 0));
	REQUIRE((naptr->regexp == NULL && naptr->regexp_len == 0) ||
		(naptr->regexp != NULL && naptr->regexp_len != 0));

325 326
	UNUSED(rdclass);

327 328 329 330 331 332 333 334 335 336
	RETERR(uint16_tobuffer(naptr->order, target));
	RETERR(uint16_tobuffer(naptr->preference, target));
	RETERR(uint8_tobuffer(naptr->flags_len, target));
	RETERR(mem_tobuffer(target, naptr->flags, naptr->flags_len));
	RETERR(uint8_tobuffer(naptr->service_len, target));
	RETERR(mem_tobuffer(target, naptr->service, naptr->service_len));
	RETERR(uint8_tobuffer(naptr->regexp_len, target));
	RETERR(mem_tobuffer(target, naptr->regexp, naptr->regexp_len));
	dns_name_toregion(&naptr->replacement, &region);
	return (isc_buffer_copyregion(target, &region));
Mark Andrews's avatar
Mark Andrews committed
337 338
}

339
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
340
tostruct_in_naptr(ARGS_TOSTRUCT) {
341 342 343 344 345
	dns_rdata_in_naptr_t *naptr = target;
	isc_region_t r;
	isc_result_t result;
	dns_name_t name;

Mark Andrews's avatar
Mark Andrews committed
346
	REQUIRE(rdata->type == 35);
347
	REQUIRE(rdata->rdclass == 1);
348
	REQUIRE(target != NULL);
349
	REQUIRE(rdata->length != 0);
Mark Andrews's avatar
Mark Andrews committed
350

351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369
	naptr->common.rdclass = rdata->rdclass;
	naptr->common.rdtype = rdata->type;
	ISC_LINK_INIT(&naptr->common, link);

	naptr->flags = NULL;
	naptr->service = NULL;
	naptr->regexp = NULL;

	dns_rdata_toregion(rdata, &r);

	naptr->order = uint16_fromregion(&r);
	isc_region_consume(&r, 2);

	naptr->preference = uint16_fromregion(&r);
	isc_region_consume(&r, 2);

	naptr->flags_len = uint8_fromregion(&r);
	isc_region_consume(&r, 1);
	if (naptr->flags_len != 0) {
370
		INSIST(naptr->flags_len <= r.length);
371 372 373 374 375
		naptr->flags = mem_maybedup(mctx, r.base, naptr->flags_len);
		if (naptr->flags == NULL)
			goto cleanup;
		isc_region_consume(&r, naptr->flags_len);
	}
376

377 378 379
	naptr->service_len = uint8_fromregion(&r);
	isc_region_consume(&r, 1);
	if (naptr->service_len != 0) {
380
		INSIST(naptr->service_len <= r.length);
381 382 383 384 385 386 387 388 389 390
		naptr->service = mem_maybedup(mctx, r.base,
					       naptr->service_len);
		if (naptr->service == NULL)
			goto cleanup;
		isc_region_consume(&r, naptr->service_len);
	}

	naptr->regexp_len = uint8_fromregion(&r);
	isc_region_consume(&r, 1);
	if (naptr->regexp_len != 0) {
391
		INSIST(naptr->regexp_len <= r.length);
392 393 394 395 396 397
		naptr->regexp = mem_maybedup(mctx, r.base, naptr->regexp_len);
		if (naptr->regexp == NULL)
			goto cleanup;
		isc_region_consume(&r, naptr->regexp_len);
	}

398 399 400
	dns_name_init(&name, NULL);
	dns_name_fromregion(&name, &r);
	dns_name_init(&naptr->replacement, NULL);
401 402 403 404
	result = name_duporclone(&name, mctx, &naptr->replacement);
	if (result != ISC_R_SUCCESS)
		goto cleanup;
	naptr->mctx = mctx;
405
	return (ISC_R_SUCCESS);
406 407 408 409 410 411 412 413 414

 cleanup:
	if (mctx != NULL && naptr->flags != NULL)
		isc_mem_free(mctx, naptr->flags);
	if (mctx != NULL && naptr->service != NULL)
		isc_mem_free(mctx, naptr->service);
	if (mctx != NULL && naptr->regexp != NULL)
		isc_mem_free(mctx, naptr->regexp);
	return (ISC_R_NOMEMORY);
Mark Andrews's avatar
Mark Andrews committed
415
}
416

417
static inline void
David Lawrence's avatar
David Lawrence committed
418
freestruct_in_naptr(ARGS_FREESTRUCT) {
419
	dns_rdata_in_naptr_t *naptr = source;
420

421
	REQUIRE(source != NULL);
422 423 424 425 426 427 428 429 430 431 432 433 434 435
	REQUIRE(naptr->common.rdclass == 1);
	REQUIRE(naptr->common.rdtype == 35);

	if (naptr->mctx == NULL)
		return;

	if (naptr->flags != NULL)
		isc_mem_free(naptr->mctx, naptr->flags);
	if (naptr->service != NULL)
		isc_mem_free(naptr->mctx, naptr->service);
	if (naptr->regexp != NULL)
		isc_mem_free(naptr->mctx, naptr->regexp);
	dns_name_free(&naptr->replacement, naptr->mctx);
	naptr->mctx = NULL;
436
}
437

438
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
439
additionaldata_in_naptr(ARGS_ADDLDATA) {
Bob Halley's avatar
Bob Halley committed
440 441 442 443 444 445
	dns_name_t name;
	isc_region_t sr;
	dns_rdatatype_t atype;
	unsigned int i, flagslen;
	char *cp;

446 447 448
	REQUIRE(rdata->type == 35);
	REQUIRE(rdata->rdclass == 1);

David Lawrence's avatar
David Lawrence committed
449 450 451
	/*
	 * Order, preference.
	 */
Bob Halley's avatar
Bob Halley committed
452 453
	dns_rdata_toregion(rdata, &sr);
	isc_region_consume(&sr, 4);
454

David Lawrence's avatar
David Lawrence committed
455 456 457
	/*
	 * Flags.
	 */
Bob Halley's avatar
Bob Halley committed
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472
	atype = 0;
	flagslen = sr.base[0];
	cp = (char *)&sr.base[1];
	for (i = 0; i < flagslen; i++, cp++) {
		if (*cp == 'S' || *cp == 's') {
			atype = dns_rdatatype_srv;
			break;
		}
		if (*cp == 'A' || *cp == 'a') {
			atype = dns_rdatatype_a;
			break;
		}
	}
	isc_region_consume(&sr, flagslen + 1);

David Lawrence's avatar
David Lawrence committed
473 474 475
	/*
	 * Service.
	 */
Bob Halley's avatar
Bob Halley committed
476 477
	isc_region_consume(&sr, sr.base[0] + 1);

David Lawrence's avatar
David Lawrence committed
478 479 480
	/*
	 * Regexp.
	 */
Bob Halley's avatar
Bob Halley committed
481 482
	isc_region_consume(&sr, sr.base[0] + 1);

David Lawrence's avatar
David Lawrence committed
483 484 485
	/*
	 * Replacement.
	 */
Bob Halley's avatar
Bob Halley committed
486 487 488 489 490
	dns_name_init(&name, NULL);
	dns_name_fromregion(&name, &sr);

	if (atype != 0)
		return ((add)(arg, &name, atype));
491

492
	return (ISC_R_SUCCESS);
493 494
}

495
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
496
digest_in_naptr(ARGS_DIGEST) {
497 498
	isc_region_t r1, r2;
	unsigned int length, n;
499
	isc_result_t result;
500 501 502 503 504 505 506 507 508
	dns_name_t name;

	REQUIRE(rdata->type == 35);
	REQUIRE(rdata->rdclass == 1);

	dns_rdata_toregion(rdata, &r1);
	r2 = r1;
	length = 0;

David Lawrence's avatar
David Lawrence committed
509 510 511
	/*
	 * Order, preference.
	 */
512 513 514
	length += 4;
	isc_region_consume(&r2, 4);

David Lawrence's avatar
David Lawrence committed
515 516 517
	/*
	 * Flags.
	 */
518 519 520 521
	n = r2.base[0] + 1;
	length += n;
	isc_region_consume(&r2, n);

David Lawrence's avatar
David Lawrence committed
522 523 524
	/*
	 * Service.
	 */
525 526 527 528
	n = r2.base[0] + 1;
	length += n;
	isc_region_consume(&r2, n);

David Lawrence's avatar
David Lawrence committed
529 530 531
	/*
	 * Regexp.
	 */
532 533 534 535 536 537 538 539 540
	n = r2.base[0] + 1;
	length += n;
	isc_region_consume(&r2, n);

	/*
	 * Digest the RR up to the replacement name.
	 */
	r1.length = length;
	result = (digest)(arg, &r1);
541
	if (result != ISC_R_SUCCESS)
542 543
		return (result);

David Lawrence's avatar
David Lawrence committed
544 545 546
	/*
	 * Replacement.
	 */
547 548 549

	dns_name_init(&name, NULL);
	dns_name_fromregion(&name, &r2);
550

551 552 553
	return (dns_name_digest(&name, digest, arg));
}

554
#endif	/* RDATA_IN_1_NAPTR_35_C */