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.39 2001/02/12 03:05:01 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
	dns_name_t name;
199
	dns_offsets_t offsets;
Mark Andrews's avatar
Mark Andrews committed
200 201 202
	isc_region_t sr;

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

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

David Lawrence's avatar
David Lawrence committed
214 215 216
	/*
	 * Flags.
	 */
Mark Andrews's avatar
Mark Andrews committed
217 218 219
	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
220 221 222
	/*
	 * Service.
	 */
Mark Andrews's avatar
Mark Andrews committed
223 224 225
	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
226 227 228
	/*
	 * Regexp.
	 */
Mark Andrews's avatar
Mark Andrews committed
229 230 231
	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
232 233 234
	/*
	 * Replacement.
	 */
235
	dns_name_init(&name, offsets);
Mark Andrews's avatar
Mark Andrews committed
236 237 238 239
	dns_name_fromregion(&name, &sr);
	return (dns_name_towire(&name, cctx, target));
}

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

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

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

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

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

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

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

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

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

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

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

	REQUIRE(type == 35);
315
	REQUIRE(rdclass == 1);
316 317 318 319 320 321 322 323 324 325
	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));

326 327
	UNUSED(rdclass);

328 329 330 331 332 333 334 335 336 337
	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
338 339
}

340
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
341
tostruct_in_naptr(ARGS_TOSTRUCT) {
342 343 344 345 346
	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
347
	REQUIRE(rdata->type == 35);
348
	REQUIRE(rdata->rdclass == 1);
349
	REQUIRE(target != NULL);
350
	REQUIRE(rdata->length != 0);
Mark Andrews's avatar
Mark Andrews committed
351

352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
	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) {
371
		INSIST(naptr->flags_len <= r.length);
372 373 374 375 376
		naptr->flags = mem_maybedup(mctx, r.base, naptr->flags_len);
		if (naptr->flags == NULL)
			goto cleanup;
		isc_region_consume(&r, naptr->flags_len);
	}
377

378 379 380
	naptr->service_len = uint8_fromregion(&r);
	isc_region_consume(&r, 1);
	if (naptr->service_len != 0) {
381
		INSIST(naptr->service_len <= r.length);
382 383 384 385 386 387 388 389 390 391
		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) {
392
		INSIST(naptr->regexp_len <= r.length);
393 394 395 396 397 398
		naptr->regexp = mem_maybedup(mctx, r.base, naptr->regexp_len);
		if (naptr->regexp == NULL)
			goto cleanup;
		isc_region_consume(&r, naptr->regexp_len);
	}

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

 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
416
}
417

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

422
	REQUIRE(source != NULL);
423 424 425 426 427 428 429 430 431 432 433 434 435 436
	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;
437
}
438

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

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

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

David Lawrence's avatar
David Lawrence committed
457 458 459
	/*
	 * Flags.
	 */
Bob Halley's avatar
Bob Halley committed
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474
	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
475 476 477
	/*
	 * Service.
	 */
Bob Halley's avatar
Bob Halley committed
478 479
	isc_region_consume(&sr, sr.base[0] + 1);

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

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

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

494
	return (ISC_R_SUCCESS);
495 496
}

497
static inline isc_result_t
David Lawrence's avatar
David Lawrence committed
498
digest_in_naptr(ARGS_DIGEST) {
499 500
	isc_region_t r1, r2;
	unsigned int length, n;
501
	isc_result_t result;
502 503 504 505 506 507 508 509 510
	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
511 512 513
	/*
	 * Order, preference.
	 */
514 515 516
	length += 4;
	isc_region_consume(&r2, 4);

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

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

David Lawrence's avatar
David Lawrence committed
531 532 533
	/*
	 * Regexp.
	 */
534 535 536 537 538 539 540 541 542
	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);
543
	if (result != ISC_R_SUCCESS)
544 545
		return (result);

David Lawrence's avatar
David Lawrence committed
546 547 548
	/*
	 * Replacement.
	 */
549 550 551

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

553 554 555
	return (dns_name_digest(&name, digest, arg));
}

556
#endif	/* RDATA_IN_1_NAPTR_35_C */