naptr_35.c revision 85bdc128fcda11c89ec1d76ea4221f4fa8e4fc24
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington * Copyright (C) 1999-2001 Internet Software Consortium.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * Permission to use, copy, modify, and distribute this software for any
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User * purpose with or without fee is hereby granted, provided that the above
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User * copyright notice and this permission notice appear in all copies.
0b062f4990db5cc6db2fe3398926f71b92a67407Brian Wellington * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
d6fa26d0adaec6c910115be34fe7a5a5f402c14fMark Andrews * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User/* $Id: naptr_35.c,v 1.42 2001/06/21 04:00:45 marka Exp $ */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User/* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User/* RFC 2915 */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(uint16_tobuffer(token.value.as_ulong, target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Preference.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(uint16_tobuffer(token.value.as_ulong, target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETTOK(txt_fromtext(&token.value.as_textregion, target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETTOK(txt_fromtext(&token.value.as_textregion, target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETTOK(txt_fromtext(&token.value.as_textregion, target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Replacement.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein buffer_fromregion(&buffer, &token.value.as_region);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein origin = (origin != NULL) ? origin : dns_rootname;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User unsigned short num;
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Replacement.
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User sub = name_prefix(&name, tctx->origin, &prefix);
6ea2385360e9e2167e65f9286447da9eea189457Tinderbox User return (dns_name_totext(&prefix, sub, target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Order, preference.
0e1dece22e128f9dfa723316a35c4b3f06912381Tinderbox User * Replacement.
0e1dece22e128f9dfa723316a35c4b3f06912381Tinderbox User return (dns_name_fromwire(&name, source, dctx, downcase, target));
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * Order, preference.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein RETERR(mem_tobuffer(target, sr.base, sr.base[0] + 1));
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater RETERR(mem_tobuffer(target, sr.base, sr.base[0] + 1));
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater RETERR(mem_tobuffer(target, sr.base, sr.base[0] + 1));
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater * Replacement.
60a900e83bab52c3f023be66654f3ab023172778Automatic Updater return (dns_name_towire(&name, cctx, target));
60a900e83bab52c3f023be66654f3ab023172778Automatic Updaterstatic inline int
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * Order, preference.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User order = memcmp(region1.base, region2.base, 4);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User len = ISC_MIN(region1.base[0], region2.base[0]);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User order = memcmp(region1.base, region2.base, len + 1);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_consume(®ion1, region1.base[0] + 1);
d71e2e0c61df16ff37c9934c371a4a60c08974f7Mark Andrews isc_region_consume(®ion2, region2.base[0] + 1);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein len = ISC_MIN(region1.base[0], region2.base[0]);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein order = memcmp(region1.base, region2.base, len + 1);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein isc_region_consume(®ion1, region1.base[0] + 1);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein isc_region_consume(®ion2, region2.base[0] + 1);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein len = ISC_MIN(region1.base[0], region2.base[0]);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein order = memcmp(region1.base, region2.base, len + 1);
94fc951a9b5679def2a05387a5c251f5cb8eb9c9Mark Andrews isc_region_consume(®ion1, region1.base[0] + 1);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_region_consume(®ion2, region2.base[0] + 1);
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User * Replacement.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User return (dns_name_rdatacompare(&name1, &name2));
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein REQUIRE(naptr->flags != NULL || naptr->flags_len == 0);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User REQUIRE(naptr->service != NULL && naptr->service_len == 0);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein REQUIRE(naptr->regexp != NULL && naptr->regexp_len == 0);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(uint16_tobuffer(naptr->preference, target));
97e74139b19368e385a3564746d42db70879195eAutomatic Updater RETERR(uint8_tobuffer(naptr->flags_len, target));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(mem_tobuffer(target, naptr->flags, naptr->flags_len));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User RETERR(uint8_tobuffer(naptr->service_len, target));
43b94483957d3168796a816ed86cf097518817dcTinderbox User RETERR(mem_tobuffer(target, naptr->service, naptr->service_len));
dba3c818ae00b10388d31703e86a28415db398acTinderbox User RETERR(uint8_tobuffer(naptr->regexp_len, target));
dba3c818ae00b10388d31703e86a28415db398acTinderbox User RETERR(mem_tobuffer(target, naptr->regexp, naptr->regexp_len));
dba3c818ae00b10388d31703e86a28415db398acTinderbox User dns_name_toregion(&naptr->replacement, ®ion);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User return (isc_buffer_copyregion(target, ®ion));
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User naptr->flags = mem_maybedup(mctx, r.base, naptr->flags_len);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User naptr->service = mem_maybedup(mctx, r.base, naptr->service_len);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User naptr->regexp = mem_maybedup(mctx, r.base, naptr->regexp_len);
2eeb74d1cf5355dd98f6d507a10086e16bb08c4bTinderbox User result = name_duporclone(&name, mctx, &naptr->replacement);
6283056805887de88040698685b8e1936a1f7a2dAutomatic Updaterstatic inline void
7717ec7a6a898cdd3c35cbfba66010b7304ffd9bAutomatic Updater isc_mem_free(naptr->mctx, naptr->service);
7717ec7a6a898cdd3c35cbfba66010b7304ffd9bAutomatic Updater dns_name_free(&naptr->replacement, naptr->mctx);
3f9791eac42b243d9f328d604e117f91a3f67a37Tinderbox User unsigned int i, flagslen;
3f9791eac42b243d9f328d604e117f91a3f67a37Tinderbox User * Order, preference.
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater * Replacement.
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater unsigned int length, n;
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater * Order, preference.
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater * Digest the RR up to the replacement name.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Replacement.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User return (dns_name_digest(&name, digest, arg));
f3d1a0ba5228251d902a6acf3c8b05cb6842f992Automatic Updater#endif /* RDATA_IN_1_NAPTR_35_C */