rdata.md revision 8e24455c8f0f4b4118b908c3d8ffda923d850e3e
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - Copyright (C) 1999-2001, 2004, 2007, 2016, 2017 Internet Systems Consortium, Inc. ("ISC")
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - This Source Code Form is subject to the terms of the Mozilla Public
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - License, v. 2.0. If a copy of the MPL was not distributed with this
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - file, You can obtain one at http://mozilla.org/MPL/2.0/.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync## RDATA Types
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync### Overview
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncThe dns rdata routines (`dns_rdata_fromtext()`,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync`dns_rdata_totext()`, `dns_rdata_fromwire()`,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync`dns_rdata_towire()` `dns_rdata_fromstruct()`,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync`dns_rdata_tostruct()` and `dns_rdata_compare()`)
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncare designed to provide a single set of routines
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncfor encoding, decoding and comparing dns data preventing the problems that
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncoccurred in BIND 8.x and earlier, in which there were multiple places in the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsynccode base that decoded wire format to internal format or compared rdata,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncsometimes with subtly different behaviour (bugs), and sometimes failing to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncsupport a particular type, leading to internal inconsistancy.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncEach of these generic routines calls type-specific routines that provide
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncthe type-specific details.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncFrom time to time new types are defined and it is necessary to add these types
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncinto the existing structure. This document is written to provide instruction
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncon how to do this.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync### Adding new RDATA types
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncAdding a new rdata type requires determining whether the new rdata type is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncclass-specific or generic, writing code to perform the rdata operations for the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsynctype, then integrating it into the build by placing the code into the rdata
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsynchierachy at the correct location under `lib/dns/rdata`. Running `make clean`
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncfollowed by `make` in `lib/dns` will cause the new rdata type to be picked up
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncand compiled.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncEach rdata module must perform the following operations:
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync* Convert from text format to internal format
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync* Convert from internal format to text format
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync* Convert from wire format to internal format
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync* Convert from internal format to wire format
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync* Convert from a structure to internal format
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync* Convert from internal format to a structure
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync* Compare two rdata in internal format
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncThere is an additional set of support functions and macros only available to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#### RDATA Hierarchy
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncThe `rdata` hierarchy has the following format.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync classname_classnumber/
|`class`|This argument should be ignored when used with a class-generic RR type, otherwise `REQUIRE(class == <value>)` should be present at the start of the function.|
|`type`|This should be tested with a `REQUIRE(type == <value>)` statement at the begining of the function.|
|`origin`|This is a absolute name used to qualify unqualified / partially qualified domain names in the text stream. It is passed to the name parsing routines.|
|`downcase`|This is passed to the name parsing routines to determine whether to downcase the names it generates or leave them in the case they are presented in.|
|`target`|This is a `BINARY` buffer into which to write the internal format of the rdata record being read.|
|`rdata`|This is the rdata record to be converted from internal format to text. `rdata->type` (and `rdata->class` for class-specific RR types) should be checked at the start of the function with `REQUIRE` statements.|
|`origin`|If this is not `NULL`, then any domain names with this suffix should be written out as unqualified subdomains. `name_prefix()` can be used to check whether `origin` is `NULL` and provide the correct arguments to the name conversion routines.|
|`class`|This argument should be ignored when used with a class-generic RR type otherwise `REQUIRE(class == <value>)` should be present at the start of the function.|
|`type`|This should be tested with a `REQUIRE(type == <value>)` statement at the begining of the function.|
|`source`|This is a `BINARY` buffer with the `active` region containing a resource record in wire format.|
|`dctx`|This is the decompression context and is passed to `dns_name_fromwire()`, along with `downcase`, to enable a compressed domain name to be extracted from the source.|
|`downcase`|This is passed to `dns_name_fromwire()` to say whether the extracted domain name should be downcased during the extraction.|
|`target`|This is a `BINARY` buffer into which the decompressed and checked resource record is written.|
|`rdata`|This is the rdata record to be converted from internal format to text. `rdata->type` (and `rdata->class` for class-specific RR types) should be checked at the start of the function with `REQUIRE` statements.|
|`cctx`|This is the compression context. It should be passed to `dns_name_towire()` when putting domain names on the wire.|
|`class`|This argument should be ignored when used with a class-generic RR type otherwise `REQUIRE(class == <value>)` should be present at the start of the function.|
|`type`|This should be tested with a `REQUIRE(type == <value>)` statement at the beginning of the function.|
|`target`|This is a `BINARY` buffer into which to write the internal format of the rdata record being read in.|