5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews/*
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Copyright (C) 1998-2002, 2004, 2007, 2009, 2011, 2012, 2015, 2016 Internet Systems Consortium, Inc. ("ISC")
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews */
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
28a8f5b0de57d269cf2845c69cb6abe18cbd3b3aMark Andrews/* $Id$ */
325f2a09608144186279321cc874c7c4f0afd9b5Michael Graff
325f2a09608144186279321cc874c7c4f0afd9b5Michael Graff/* Reviewed: Thu Mar 16 13:57:50 PST 2000 by explorer */
f7b99290c31abeb20c55fc55391510450ce60423Mark Andrews
854d0238dbc2908490197984b3b9d558008a53dfMark Andrews#ifndef RDATA_GENERIC_NULL_10_C
854d0238dbc2908490197984b3b9d558008a53dfMark Andrews#define RDATA_GENERIC_NULL_10_C
3761c433912beabe43abeed2c3513b6201c59f64Mark Andrews
6324997211a5e2d82528dcde98e8981190a35faeMichael Graff#define RRTYPE_NULL_ATTRIBUTES (0)
6324997211a5e2d82528dcde98e8981190a35faeMichael Graff
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencefromtext_null(ARGS_FROMTEXT) {
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(type == dns_rdatatype_null);
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington UNUSED(rdclass);
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington UNUSED(type);
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington UNUSED(lexer);
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington UNUSED(origin);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews UNUSED(options);
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington UNUSED(target);
bddfe77128b0f16af263ff149db40f0d885f43d0Mark Andrews UNUSED(callbacks);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington return (DNS_R_SYNTAX);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencetotext_null(ARGS_TOTEXT) {
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_null);
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington
fe3472c80b76b6fed0ae674fd63471d02477a03aMark Andrews return (unknown_totext(rdata, tctx, target));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencefromwire_null(ARGS_FROMWIRE) {
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington isc_region_t sr;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(type == dns_rdatatype_null);
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington UNUSED(type);
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington UNUSED(rdclass);
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington UNUSED(dctx);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews UNUSED(options);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence isc_buffer_activeregion(source, &sr);
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington isc_buffer_forward(source, sr.length);
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington return (mem_tobuffer(target, sr.base, sr.length));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencetowire_null(ARGS_TOWIRE) {
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_null);
325f2a09608144186279321cc874c7c4f0afd9b5Michael Graff
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington UNUSED(cctx);
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington return (mem_tobuffer(target, rdata->data, rdata->length));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
4529cdaedaf1a0a5f8ff89aeca510b7a4475446cBob Halleystatic inline int
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencecompare_null(ARGS_COMPARE) {
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington isc_region_t r1;
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington isc_region_t r2;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
f3352b9bec0c21bf11b120d5cde4b2c5d45d1644Mark Andrews REQUIRE(rdata1->type == rdata2->type);
d981ca645597116d227a48bf37cc5edc061c854dBob Halley REQUIRE(rdata1->rdclass == rdata2->rdclass);
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata1->type == dns_rdatatype_null);
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington dns_rdata_toregion(rdata1, &r1);
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington dns_rdata_toregion(rdata2, &r2);
90e303b114e56db5809fdd19805243457fa43cd9Olafur Gudmundsson return (isc_region_compare(&r1, &r2));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencefromstruct_null(ARGS_FROMSTRUCT) {
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews dns_rdata_null_t *null = source;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(type == dns_rdatatype_null);
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews REQUIRE(source != NULL);
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews REQUIRE(null->common.rdtype == type);
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews REQUIRE(null->common.rdclass == rdclass);
85bdc128fcda11c89ec1d76ea4221f4fa8e4fc24Mark Andrews REQUIRE(null->data != NULL || null->length == 0);
325f2a09608144186279321cc874c7c4f0afd9b5Michael Graff
ae114ded82e773a4d9058f833f964a17514712a8Brian Wellington UNUSED(type);
63cef8bde8b92aeb30ccdcf21d4e44c9be9cc6e3Andreas Gustafsson UNUSED(rdclass);
63cef8bde8b92aeb30ccdcf21d4e44c9be9cc6e3Andreas Gustafsson
373ce67419680a398ba3dc51a14a486caaf0afb0Mark Andrews return (mem_tobuffer(target, null->data, null->length));
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencetostruct_null(ARGS_TOSTRUCT) {
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_rdata_null_t *null = target;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews isc_region_t r;
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_null);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews REQUIRE(target != NULL);
325f2a09608144186279321cc874c7c4f0afd9b5Michael Graff
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews null->common.rdclass = rdata->rdclass;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews null->common.rdtype = rdata->type;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews ISC_LINK_INIT(&null->common, link);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_rdata_toregion(rdata, &r);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews null->length = r.length;
85bdc128fcda11c89ec1d76ea4221f4fa8e4fc24Mark Andrews null->data = mem_maybedup(mctx, r.base, r.length);
85bdc128fcda11c89ec1d76ea4221f4fa8e4fc24Mark Andrews if (null->data == NULL)
85bdc128fcda11c89ec1d76ea4221f4fa8e4fc24Mark Andrews return (ISC_R_NOMEMORY);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews null->mctx = mctx;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews return (ISC_R_SUCCESS);
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews}
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews
4529cdaedaf1a0a5f8ff89aeca510b7a4475446cBob Halleystatic inline void
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencefreestruct_null(ARGS_FREESTRUCT) {
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews dns_rdata_null_t *null = source;
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
94a3bcd132e515b4baa0884ba9dd0f361d2e17bcMark Andrews REQUIRE(source != NULL);
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(null->common.rdtype == dns_rdatatype_null);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews if (null->mctx == NULL)
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews return;
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews if (null->data != NULL)
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews isc_mem_free(null->mctx, null->data);
9281e7aa775026dc47c01745fdcc438645146877Mark Andrews null->mctx = NULL;
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews}
d981ca645597116d227a48bf37cc5edc061c854dBob Halley
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrenceadditionaldata_null(ARGS_ADDLDATA) {
82ca33427bdd4f3bc4ed3431e86bd810fe751674Andreas Gustafsson UNUSED(rdata);
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington UNUSED(add);
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington UNUSED(arg);
d981ca645597116d227a48bf37cc5edc061c854dBob Halley
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_null);
325f2a09608144186279321cc874c7c4f0afd9b5Michael Graff
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff return (ISC_R_SUCCESS);
d981ca645597116d227a48bf37cc5edc061c854dBob Halley}
d981ca645597116d227a48bf37cc5edc061c854dBob Halley
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffstatic inline isc_result_t
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrencedigest_null(ARGS_DIGEST) {
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington isc_region_t r;
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_null);
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington dns_rdata_toregion(rdata, &r);
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley
763340ccb37aea6e12abaa744066bcc8ac4dacd0Brian Wellington return ((digest)(arg, &r));
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley}
e27a69f8bd9538e08f775265167ba6cc5f47c587Bob Halley
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewsstatic inline isc_boolean_t
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewscheckowner_null(ARGS_CHECKOWNER) {
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(type == dns_rdatatype_null);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews UNUSED(name);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews UNUSED(type);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews UNUSED(rdclass);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews UNUSED(wildcard);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews return (ISC_TRUE);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews}
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewsstatic inline isc_boolean_t
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewschecknames_null(ARGS_CHECKNAMES) {
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
b0ba1a6059b6d6c4b3aa77d8bc84cc443b981e01Mukund Sivaraman REQUIRE(rdata->type == dns_rdatatype_null);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews UNUSED(rdata);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews UNUSED(owner);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews UNUSED(bad);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews return (ISC_TRUE);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews}
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrewsstatic inline int
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrewscasecompare_null(ARGS_COMPARE) {
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews return (compare_null(rdata1, rdata2));
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews}
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews
854d0238dbc2908490197984b3b9d558008a53dfMark Andrews#endif /* RDATA_GENERIC_NULL_10_C */