null_10.c revision 6d12fdf96621801e80f3f4c2a8a569fe48766a20
1ccbfca64ae86ace521053773001cb995352f96fBob Halley/*
1ccbfca64ae86ace521053773001cb995352f96fBob Halley * Copyright (C) 1998, 1999, 2000 Internet Software Consortium.
1ccbfca64ae86ace521053773001cb995352f96fBob Halley *
1ccbfca64ae86ace521053773001cb995352f96fBob Halley * Permission to use, copy, modify, and distribute this software for any
1ccbfca64ae86ace521053773001cb995352f96fBob Halley * purpose with or without fee is hereby granted, provided that the above
1ccbfca64ae86ace521053773001cb995352f96fBob Halley * copyright notice and this permission notice appear in all copies.
1ccbfca64ae86ace521053773001cb995352f96fBob Halley *
1ccbfca64ae86ace521053773001cb995352f96fBob Halley * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
1ccbfca64ae86ace521053773001cb995352f96fBob Halley * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
1ccbfca64ae86ace521053773001cb995352f96fBob Halley * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
1ccbfca64ae86ace521053773001cb995352f96fBob Halley * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
1ccbfca64ae86ace521053773001cb995352f96fBob Halley * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
1ccbfca64ae86ace521053773001cb995352f96fBob Halley * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
1ccbfca64ae86ace521053773001cb995352f96fBob Halley * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
1ccbfca64ae86ace521053773001cb995352f96fBob Halley * SOFTWARE.
1ccbfca64ae86ace521053773001cb995352f96fBob Halley */
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley/* $Id: null_10.c,v 1.25 2000/06/01 18:26:23 tale Exp $ */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley/* Reviewed: Thu Mar 16 13:57:50 PST 2000 by explorer */
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halley#ifndef RDATA_GENERIC_NULL_10_C
1ccbfca64ae86ace521053773001cb995352f96fBob Halley#define RDATA_GENERIC_NULL_10_C
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halley#define RRTYPE_NULL_ATTRIBUTES (0)
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halleystatic inline isc_result_t
1ccbfca64ae86ace521053773001cb995352f96fBob Halleyfromtext_null(ARGS_FROMTEXT) {
1ccbfca64ae86ace521053773001cb995352f96fBob Halley UNUSED(rdclass);
7d44d8aacda98eb2b526af34757a6bbcc97cd388Bob Halley UNUSED(type);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley UNUSED(lexer);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley UNUSED(origin);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley UNUSED(downcase);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley UNUSED(target);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley REQUIRE(type == 10);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley return (DNS_R_SYNTAX);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley}
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
0e3ad060581e366d3e682caf2dd5d9ea2e0f4893Bob Halleystatic inline isc_result_t
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halleytotext_null(ARGS_TOTEXT) {
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley UNUSED(rdata);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley UNUSED(tctx);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley UNUSED(target);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley REQUIRE(rdata->type == 10);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley return (DNS_R_SYNTAX);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley}
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halleystatic inline isc_result_t
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halleyfromwire_null(ARGS_FROMWIRE) {
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley isc_region_t sr;
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halley UNUSED(rdclass);
0e3ad060581e366d3e682caf2dd5d9ea2e0f4893Bob Halley UNUSED(dctx);
1ccbfca64ae86ace521053773001cb995352f96fBob Halley UNUSED(downcase);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley REQUIRE(type == 10);
0e3ad060581e366d3e682caf2dd5d9ea2e0f4893Bob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley isc_buffer_activeregion(source, &sr);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley isc_buffer_forward(source, sr.length);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley return (mem_tobuffer(target, sr.base, sr.length));
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley}
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halleystatic inline isc_result_t
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halleytowire_null(ARGS_TOWIRE) {
1ccbfca64ae86ace521053773001cb995352f96fBob Halley UNUSED(cctx);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
0e3ad060581e366d3e682caf2dd5d9ea2e0f4893Bob Halley REQUIRE(rdata->type == 10);
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halley return (mem_tobuffer(target, rdata->data, rdata->length));
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley}
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halleystatic inline int
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halleycompare_null(ARGS_COMPARE) {
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley isc_region_t r1;
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley isc_region_t r2;
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley REQUIRE(rdata1->type == rdata1->type);
1ccbfca64ae86ace521053773001cb995352f96fBob Halley REQUIRE(rdata1->rdclass == rdata2->rdclass);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley REQUIRE(rdata1->type == 10);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
0e3ad060581e366d3e682caf2dd5d9ea2e0f4893Bob Halley dns_rdata_toregion(rdata1, &r1);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley dns_rdata_toregion(rdata2, &r2);
1ccbfca64ae86ace521053773001cb995352f96fBob Halley return (compare_region(&r1, &r2));
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley}
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halleystatic inline isc_result_t
1ccbfca64ae86ace521053773001cb995352f96fBob Halleyfromstruct_null(ARGS_FROMSTRUCT) {
1ccbfca64ae86ace521053773001cb995352f96fBob Halley dns_rdata_null_t *null = source;
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley REQUIRE(type == 10);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley REQUIRE(source != NULL);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley REQUIRE(null->common.rdtype == type);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley REQUIRE(null->common.rdclass == rdclass);
1ccbfca64ae86ace521053773001cb995352f96fBob Halley REQUIRE((null->data != NULL && null->length != 0) ||
1ccbfca64ae86ace521053773001cb995352f96fBob Halley (null->data == NULL && null->length == 0));
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halley return (mem_tobuffer(target, null->data, null->length));
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley}
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halleystatic inline isc_result_t
1ccbfca64ae86ace521053773001cb995352f96fBob Halleytostruct_null(ARGS_TOSTRUCT) {
1ccbfca64ae86ace521053773001cb995352f96fBob Halley dns_rdata_null_t *null = target;
1ccbfca64ae86ace521053773001cb995352f96fBob Halley isc_region_t r;
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halley REQUIRE(rdata->type == 10);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley REQUIRE(target != NULL);
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halley null->common.rdclass = rdata->rdclass;
1ccbfca64ae86ace521053773001cb995352f96fBob Halley null->common.rdtype = rdata->type;
1ccbfca64ae86ace521053773001cb995352f96fBob Halley ISC_LINK_INIT(&null->common, link);
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halley dns_rdata_toregion(rdata, &r);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley null->length = r.length;
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley if (null->length != 0) {
1ccbfca64ae86ace521053773001cb995352f96fBob Halley null->data = mem_maybedup(mctx, r.base, r.length);
1ccbfca64ae86ace521053773001cb995352f96fBob Halley if (null->data == NULL)
1ccbfca64ae86ace521053773001cb995352f96fBob Halley return (ISC_R_NOMEMORY);
1ccbfca64ae86ace521053773001cb995352f96fBob Halley } else
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley null->data = NULL;
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley null->mctx = mctx;
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley return (ISC_R_SUCCESS);
1ccbfca64ae86ace521053773001cb995352f96fBob Halley}
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halleystatic inline void
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halleyfreestruct_null(ARGS_FREESTRUCT) {
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley dns_rdata_null_t *null = source;
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley REQUIRE(source != NULL);
1ccbfca64ae86ace521053773001cb995352f96fBob Halley REQUIRE(null->common.rdtype == 10);
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halley if (null->mctx == NULL)
1ccbfca64ae86ace521053773001cb995352f96fBob Halley return;
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley if (null->data != NULL)
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley isc_mem_free(null->mctx, null->data);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley null->mctx = NULL;
1ccbfca64ae86ace521053773001cb995352f96fBob Halley}
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halleystatic inline isc_result_t
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halleyadditionaldata_null(ARGS_ADDLDATA) {
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley UNUSED(rdata);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley UNUSED(add);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley UNUSED(arg);
1ccbfca64ae86ace521053773001cb995352f96fBob Halley
1ccbfca64ae86ace521053773001cb995352f96fBob Halley REQUIRE(rdata->type == 10);
a99979c686ae04efd55ba8f0aacf32493b4aa7faBob Halley
a99979c686ae04efd55ba8f0aacf32493b4aa7faBob Halley return (ISC_R_SUCCESS);
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley}
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halleystatic inline isc_result_t
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halleydigest_null(ARGS_DIGEST) {
a99979c686ae04efd55ba8f0aacf32493b4aa7faBob Halley isc_region_t r;
a99979c686ae04efd55ba8f0aacf32493b4aa7faBob Halley
62837b832f6a9999976d607eb0a9125bbbbb138bBob Halley REQUIRE(rdata->type == 10);
a99979c686ae04efd55ba8f0aacf32493b4aa7faBob Halley
a99979c686ae04efd55ba8f0aacf32493b4aa7faBob Halley dns_rdata_toregion(rdata, &r);
48481c9b6e19501457bcbc2995555412f352b99fBob Halley
48481c9b6e19501457bcbc2995555412f352b99fBob Halley return ((digest)(arg, &r));
48481c9b6e19501457bcbc2995555412f352b99fBob Halley}
48481c9b6e19501457bcbc2995555412f352b99fBob Halley
48481c9b6e19501457bcbc2995555412f352b99fBob Halley#endif /* RDATA_GENERIC_NULL_10_C */
48481c9b6e19501457bcbc2995555412f352b99fBob Halley