rdata.html revision dafcb997e390efa4423883dafd100c975c4095d6
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User<!--
75c0816e8295e180f4bc7f10db3d0d880383bc1cMark Andrews - Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein - Copyright (C) 1999-2001 Internet Software Consortium.
4a14ce5ba00ab7bc55c99ffdcf59c7a4ab902721Automatic Updater -
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein - Permission to use, copy, modify, and distribute this software for any
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein - purpose with or without fee is hereby granted, provided that the above
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein - copyright notice and this permission notice appear in all copies.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein -
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein - PERFORMANCE OF THIS SOFTWARE.
ea94d370123a5892f6c47a97f21d1b28d44bb168Tinderbox User-->
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<!-- $Id: rdata.html,v 1.13 2004/03/05 05:04:50 marka Exp $ -->
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<HTML>
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews<HEAD>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <TITLE>Adding new RDATA type</TITLE>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein</HEAD>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<BODY>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<H2>Overview</H2>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinThe dns rdata routines (<CODE>dns_rdata_fromtext()</CODE>,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<CODE>dns_rdata_totext()</CODE>, <CODE>dns_rdata_fromwire()</CODE>,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<CODE>dns_rdata_towire()</CODE> <CODE>dns_rdata_fromstruct()</CODE>,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<CODE>dns_rdata_tostruct()</CODE> and <CODE>dns_rdata_compare()</CODE>)
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinare designed to provide a single set of routines
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinfor encoding, decoding and comparing dns data preventing the problems that
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinoccurred in BIND 8.x and earlier where there were multiple places in the
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeincode base that
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeindecoded wire format to internal format or compared rdata sometimes with
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinsubtly different behaviour (bugs) or didn't support a particular type leading
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinto internal inconsistancy.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<P>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinEach of these generic routines calls type specific routines that provide
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinthe type specific details.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<P>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinFrom time to time new types are defined and it is necessary to add these types
ea94d370123a5892f6c47a97f21d1b28d44bb168Tinderbox Userinto the existing structure.
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox UserThis document is written to provide instruction on how to do this.
75c0816e8295e180f4bc7f10db3d0d880383bc1cMark Andrews<H2>Adding new RDATA types</H2>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinAdding a new rdata type requires determining if the new rdata type is class
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinspecific or generic.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinWriting code to perform the following set of operations
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinand then integrating it into the build by placing the code into the rdata
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinhierachy at the correct place.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinRunning <CODE>make clean</CODE> followed <CODE>make</CODE> in
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<CODE>lib/dns</CODE> will cause the new rdata type to be picked up.
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User<P>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox UserEach rdata module must perform the following operations:
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User<DL>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User<DT>Convert from text format to internal format</DT>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DT>Convert from internal format to text format</DT>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User<DT>Convert from wire format to internal format</DT>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User<DT>Convert from internal format to wire format</DT>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User<DT>Convert from a structure to internal format</DT>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User<DT>Convert from internal format to a structure</DT>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User<DT>Compare two rdata in internal format<DT>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User</DL>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<P>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinThere is an additional set of support <A HREF="#functions">functions</A> and
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews<A HREF="#macros">macros</A> only available to
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinto rdata code.
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User<H2>RDATA Hierarchy</H2>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox UserThe <CODE>rdata</CODE> hierarchy has the following format.
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User<PRE>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User rdata/
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User generic/
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <I>typename_typenumber</I>.h
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <I>classname_classnumber</I>/
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein <I>typename_typenumber</I>.h
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<PRE>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<P>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox UserInitial rdata hierarchy:
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User<P>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<PRE>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User rdata/
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User generic/
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein ns_2.h
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User md_3.h
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User mf_4.h
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein cname_5.h
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein soa_6.h
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein mb_7.h
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein mg_8.h
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein mr_9.h
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein null_10.h
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein ptr_12.h
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein hinfo_13.h
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User minfo_14.h
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User mx_15.h
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein txt_16.h
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein rp_17.h
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User afsdb_18.h
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User x25_19.h
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User isdn_20.h
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User rt_21.h
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User sig_24.h
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User key_25.h
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein gpos_27.h
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User loc_29.h
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User nxt_30.h
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein cert_37.h
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein dname_39.h
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User unspec_103.h
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User tkey_249.h
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User in_1/
44d0f0256fbdce130a18655023c3b06bacacbd61Automatic Updater a_1.h
6f64d4ab8e68f9b2333bcbfc755396d29a4a9d7cAutomatic Updater wks_11.h
6f64d4ab8e68f9b2333bcbfc755396d29a4a9d7cAutomatic Updater nsap_22.h
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User nsap-ptr_23.h
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User px_26.h
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User aaaa_28.h
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User srv_33.h
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User naptr_35.h
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User kx_36.h
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User a6_38.h
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User any_255/
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User tsig_250.h
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User</PRE>
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<H2>CLASSNAME and TYPENAME</H2>
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox UserClass and type names must be from the following alphabet and less that 11
6f64d4ab8e68f9b2333bcbfc755396d29a4a9d7cAutomatic Updatercharacters in length or otherwise they will be ignored.
44d0f0256fbdce130a18655023c3b06bacacbd61Automatic UpdaterPermissible alphabet: a to z, 0 to 9 and dash (-).
44d0f0256fbdce130a18655023c3b06bacacbd61Automatic UpdaterDash is mapped to underscore (_) for the C function names below.
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<H2>Internal Format</H2>
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox UserThe internal format chosen is DNS wire format without any compression being
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox Userapplied to domain names in the rdata.
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<H2>Convert from text format to internal format</H2>
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox UserThe functions to convert from text format has the following call formats and
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox Useris declared as follows for class generic functions.
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<PRE>
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<CODE>static dns_result_t
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox Userfromtext_<I>typename</I>(dns_rdataclass_t class, dns_rdatatype_t type,
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User isc_lex_t *lexer, dns_name_t *origin,
44d0f0256fbdce130a18655023c3b06bacacbd61Automatic Updater isc_boolean_t downcase, isc_buffer_t *target);</CODE>
bcf15a19ae0efa72a22cdfb50666a3c6ce39eb9fTinderbox User</PRE>
44d0f0256fbdce130a18655023c3b06bacacbd61Automatic UpdaterClass specific functions contain the class name in addition to the
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox Usertype name.
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<PRE>
bcf15a19ae0efa72a22cdfb50666a3c6ce39eb9fTinderbox User<CODE>static dns_result_t
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox Userfromtext_<I>classname_typename</I>(dns_rdataclass_t class, dns_rdatatype_t type,
bcf15a19ae0efa72a22cdfb50666a3c6ce39eb9fTinderbox User isc_lex_t *lexer, dns_name_t *origin,
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User isc_boolean_t downcase, isc_buffer_t *target);</CODE>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User</PRE>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DL>
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews<DT><CODE>class</CODE></DT>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DD>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox UserThis argument should be ignored when used with a class generic RR type
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinotherwise <CODE>REQUIRE(class == #)</CODE> should be present at the start
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinof the function.
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews<DT><CODE>type</CODE></DT>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DD>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinThis should be tested with a <CODE>REQUIRE(type == #)</CODE> statement at
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinthe begining of the function.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DT><CODE>lexer</CODE></DT>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User<DD>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinThis is used to read the input text stream.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DT><CODE>origin</CODE></DT>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DD>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox UserThis is a absolute name used to qualify unqualified / partially qualified
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeindomainnames in the text stream.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinIt is passed to the name parsing routines.
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User<DT><CODE>downcase</CODE></DT>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DD>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinThis is passed to the name parsing routines to determine whether to downcase
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox Userthe names it generates or leave them in the case they are pesented in.
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User<DT><CODE>target</CODE></DT>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DD>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox UserThis is a <CODE>BINARY</CODE> buffer used to write the internal format of the rdata record being read in to.
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User</DL>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User<CODE>fromtext_<I>typename</I>()</CODE> reads tokens from <CODE>lexer</CODE>,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinup to but not including the end of line (EOL) token or end of file (EOF) token.
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox UserIf the EOL / EOF token is read it should be returned to the input stream.
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox User<A HREF="#gettoken"><CODE>gettoken()</CODE></A>
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox Usershould be used to read the next token from the input stream and
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox Userwill return EOL / EOF tokens
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinautomatically unless
990d0e893f5b70e735cdf990af66e9ec6e91fa78Tinderbox Userthey are specifcally requested.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<CODE>isc_lex_ungettoken()</CODE> should
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinbe used to return EOL / EOF (or any other token) to the input stream if
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinthe EOL / EOF token is read.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinUnused tokens will cause <CODE>dns_rdata_fromtext()</CODE> to return
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<CODE>DNS_R_EXTRATOKEN</CODE> if <CODE>fromtext_<I>typename</I>()</CODE> was successful.
a1ad6695ed6f988406cf155aa26376f84f73bcb9Automatic Updater<P>
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<CODE>fromtext_<I>typename</I>()</CODE> reads external input and as such is a high security area and must be paranoid about its input.
a1ad6695ed6f988406cf155aa26376f84f73bcb9Automatic Updater<H2>Convert from internal format to text format</H2>
44d0f0256fbdce130a18655023c3b06bacacbd61Automatic Updater<PRE>
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<CODE>static dns_result_t
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updatertotext_<I>typename</I>(dns_rdata_t *rdata, dns_name_t *origin,
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User isc_buffer_t *target);</CODE>
44d0f0256fbdce130a18655023c3b06bacacbd61Automatic Updater</PRE>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<PRE>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<CODE>static dns_result_t
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox Usertotext_<I>classname_typename</I>(dns_rdata_t *rdata, dns_name_t *origin,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein isc_buffer_t *target);</CODE>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein</PRE>
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<DL>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DT><CODE>rdata</CODE></DT>
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<DD>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinThis is the rdata record to be converted from internal format to text.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<CODE>rdata->type</CODE> and <CODE>rdata->class</CODE> for class specific
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox UserRR types should be checked at the start of the function with
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<CODE>REQUIRE(rdata->type ==�#)</CODE> statements.
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<DT><CODE>origin</CODE></DT>
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<DD>
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox UserIf this in non <CODE>NULL</CODE> then any domainnames with this suffix
7208386cd37a2092c70eddf80cf29519b16c4c80Mark Andrewsshould be written out unqualified.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<A HREF="#name_prefix"><CODE>name_prefix()</CODE></A> can be used to
507151045be68c671ffd4e2f37e17cdfa0376fc4Automatic Updatercheck if <CODE>origin</CODE> is <CODE>NULL</CODE> and provide the correct
507151045be68c671ffd4e2f37e17cdfa0376fc4Automatic Updaterarguments to the name conversion routines.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DT><CODE>target</CODE></DT>
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews<DD>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinThis is a <CODE>TEXT</CODE> buffer used to hold the output.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein</DL>
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<H2>Convert from wire format to internal format</H2>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<PRE>
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<CODE>static dns_result_t
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox Userfromwire_<I>typename</I>(dns_rdataclass_t class, dns_rdatatype_t type,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein isc_buffer_t *source, dns_decompress_t *dctx,
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein isc_boolean_t downcase, isc_buffer_t *target);</CODE>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein</PRE>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<PRE>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<CODE>static dns_result_t
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox Userfromwire_<I>classname_typename</I>(dns_rdataclass_t class, dns_rdatatype_t type,
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User isc_buffer_t *source, dns_decompress_t *dctx,
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User isc_boolean_t downcase, isc_buffer_t *target);</CODE>
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User</PRE>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<P>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<CODE>fromwire_<I>classname_typename</I>()</CODE> is required to set the valid
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeindecompression methods if there is a domain name in the rdata.
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<PRE>
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews<CODE>if (dns_decompress_edns(dctx) >= # || !dns_decompress_strict(dctx))
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinelse
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);</CODE>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein</PRE>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DL>
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<DT><CODE>class</CODE></DT>
44d0f0256fbdce130a18655023c3b06bacacbd61Automatic Updater<DD>
44d0f0256fbdce130a18655023c3b06bacacbd61Automatic UpdaterThis argument should be ignored when used with a class generic RR type
44d0f0256fbdce130a18655023c3b06bacacbd61Automatic Updaterotherwise <CODE>REQUIRE(class == #)</CODE> should be present at the start
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox Userof the function.
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<DT><CODE>type</CODE></DT>
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<DD>
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox UserThis should be tested with a <CODE>REQUIRE(type == #)</CODE> statement at
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox Userthe begining of the function.
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<DT><CODE>source</CODE></DT>
bbbf2e27d3a981163dab139497d6b2dc85449db0Tinderbox User<DD>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinThis is a <CODE>BINARY</CODE> buffer with the <CODE>active</CODE> region
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeincontaining a RR record in wire format.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews<DT><CODE>dctx</CODE></DT>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews<DD>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark AndrewsThis is the decompression context and is passed to
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews<CODE>dns_name_fromwire()</CODE>,
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsalong with <CODE>downcase</CODE>, to enable a compressed domain name
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsto be extracted from the source.
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews<DT><CODE>downcase</CODE></DT>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews<DD>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark AndrewsThis is passed to <CODE>dns_name_fromwire()</CODE> to say whether the
f9aef05653eeb454c489d5bd2bde6daab774ad4aTinderbox Userextracted domainname should be downcased during the extraction.
f9aef05653eeb454c489d5bd2bde6daab774ad4aTinderbox User<DT><CODE>target</CODE></DT>
f9aef05653eeb454c489d5bd2bde6daab774ad4aTinderbox User<DD>
f9aef05653eeb454c489d5bd2bde6daab774ad4aTinderbox UserThis is a <CODE>BINARY</CODE> buffer where the decompressed and checked
f9aef05653eeb454c489d5bd2bde6daab774ad4aTinderbox UserRR record is written.
f9aef05653eeb454c489d5bd2bde6daab774ad4aTinderbox User</DL>
922312472e2e05ebc64993d465999c5351b83036Automatic Updater<CODE>fromwire_<I>typename</I>()</CODE> is a security sensitive routine
922312472e2e05ebc64993d465999c5351b83036Automatic Updateras it reads external data and should take extreme care to ensure that
922312472e2e05ebc64993d465999c5351b83036Automatic Updaterthe input data matches its description.
28b3569d6248168e6c00caab951521cc8141a49dAutomatic Updater<P>
28b3569d6248168e6c00caab951521cc8141a49dAutomatic UpdaterIf the <CODE>active</CODE> buffer is not empty at completion and
28b3569d6248168e6c00caab951521cc8141a49dAutomatic Updater<CODE>fromwire_<I>typename</I>()</CODE> was otherwise successful
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews<CODE>dns_rdata_fromwire()</CODE> will return <CODE>DNS_R_EXTRADATA</CODE>.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews<H2>Convert from internal format to wire format</H2>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews<PRE>
2cbb4ab75757fbb656997a82c14ca07db37d481aAutomatic Updater<CODE>static dns_result_t
2cbb4ab75757fbb656997a82c14ca07db37d481aAutomatic Updatertowire_<I>typename</I>(dns_rdata_t *rdata, dns_compress_t *cctx,
2cbb4ab75757fbb656997a82c14ca07db37d481aAutomatic Updater isc_buffer_t *target);</CODE>
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater</PRE>
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater<PRE>
0a7ed88633a680bb881868b75ded4d09a7bbbc50Automatic Updater<CODE>static dns_result_t
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrewstowire_<I>classname_typename</I>(dns_rdata_t *rdata, dns_compress_t *cctx,
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews isc_buffer_t *target);<CODE>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews</PRE>
c3dc968140ab7f04795acc7835e4e89ccb0c0a27Tinderbox User<P>
c3dc968140ab7f04795acc7835e4e89ccb0c0a27Tinderbox User<CODE>towire_<I>classname_typename</I>()</CODE> is required to set the
c3dc968140ab7f04795acc7835e4e89ccb0c0a27Tinderbox Userallowed name compression methods based on EDNS version if there is a
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrewsdomain name in the rdata.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews<PRE>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews<CODE>if (dns_compress_getedns(cctx) >= #)
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewselse
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);</CODE>
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews</PRE>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews<DL>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews<DT><CODE>rdata</CODE></DT>
e2e4d321999340802f77adaacd19c797d04b4b95Automatic Updater<DD>
e2e4d321999340802f77adaacd19c797d04b4b95Automatic UpdaterThis is the rdata record to be converted from internal format to text.
e2e4d321999340802f77adaacd19c797d04b4b95Automatic Updater<CODE>rdata->type</CODE> and <CODE>rdata->class</CODE> for class specific
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic UpdaterRR types should be checked at the start of the function with
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater<CODE>REQUIRE(rdata->type ==�#)</CODE> statements.
0c6ada0a814f3c5417daa1654129bc2af56ed504Automatic Updater<DT><CODE>cctx</CODE></DT>
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews<DD>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark AndrewsThis is the compression context, it should be passed to <CODE>dns_name_towire()</CODE> when putting domainnames on the wire.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews<DT><CODE>target</CODE></DT>
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews<DD>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark AndrewsThis is a <CODE>BINARY</CODE> buffer used to write the rdata to.
9b469e3c59015b1a4899c9d8395168126fe094fdAutomatic Updater</DL>
9b469e3c59015b1a4899c9d8395168126fe094fdAutomatic UpdaterSimple RR types without domainnames can use the following code to
9b469e3c59015b1a4899c9d8395168126fe094fdAutomatic Updatertransfer the contents of the <CODE>rdata</CODE> to the target buffer.
9b469e3c59015b1a4899c9d8395168126fe094fdAutomatic Updater<PRE>
9b469e3c59015b1a4899c9d8395168126fe094fdAutomatic Updater <CODE>return (<A HREF="#mem_tobuffer">mem_tobuffer</A>(target, rdata->data, rdata->length));</CODE>
9b469e3c59015b1a4899c9d8395168126fe094fdAutomatic Updater</PRE>
e2e4d321999340802f77adaacd19c797d04b4b95Automatic Updater<H2>Convert from a structure to internal format</H2>
e2e4d321999340802f77adaacd19c797d04b4b95Automatic Updater<PRE>
e2e4d321999340802f77adaacd19c797d04b4b95Automatic Updater<CODE>static dns_result_t
e2e4d321999340802f77adaacd19c797d04b4b95Automatic Updaterfromstruct_<I>typename</I>(dns_rdataclass_t class, dns_rdatatype_t type,
e2e4d321999340802f77adaacd19c797d04b4b95Automatic Updater void *source, isc_buffer_t *target);</CODE>
e2e4d321999340802f77adaacd19c797d04b4b95Automatic Updater</PRE>
e2e4d321999340802f77adaacd19c797d04b4b95Automatic Updater<PRE>
fdd80e9a55c70b36a3bf3e409b86897301c44ff8Automatic Updater<CODE>static dns_result_t
fdd80e9a55c70b36a3bf3e409b86897301c44ff8Automatic Updaterfromstruct_<I>classname_typename</I>(dns_rdataclass_t class, dns_rdatatype_t type,
fdd80e9a55c70b36a3bf3e409b86897301c44ff8Automatic Updater void *source, isc_buffer_t *target);</CODE>
e2e4d321999340802f77adaacd19c797d04b4b95Automatic Updater</PRE>
e2e4d321999340802f77adaacd19c797d04b4b95Automatic Updater<DL>
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews<DT><CODE>class</CODE></DT>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DD>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinThis argument should be ignored when used with a class generic RR type
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinotherwise <CODE>REQUIRE(class == #)</CODE> should be present at the start
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinof the function.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DT><CODE>type</CODE></DT>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DD>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinThis should be tested with a <CODE>REQUIRE(type == #)</CODE> statement at
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinthe beginning of the function.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DT><CODE>source</CODE></DT>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DD>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinThis points to a type specific structure.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DT><CODE>target</CODE></DT>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<DD>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob AusteinThis is a <CODE>BINARY</CODE> buffer used to write the internal format of the rdata record being read in to.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein</DL>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<H2>Convert from internal format to a structure</H2>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<PRE>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<CODE>static dns_result_t
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeintostruct_<I>typename</I>(dns_rdata_t *rdata, void *target);</CODE>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein</PRE>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein<PRE>
<CODE>static dns_result_t
tostruct_<I>classname_typename</I>(dns_rdata_t *rdata, void *target);</CODE>
</PRE>
<DL>
<DT><CODE>rdata</CODE></DT>
<DD>
This is the rdata record to be converted from internal format to a structure.
<CODE>rdata->type</CODE> and <CODE>rdata->class</CODE> for class specific
RR types should be checked at the start of the function with
<CODE>REQUIRE(rdata->type ==�#)</CODE> statements.
<DT><CODE>target</CODE></DT>
<DD>
Pointer to a type specific structure.
</DL>
<H2>Compare two rdata in internal format</H2>
<PRE>
<CODE>static int
compare_<I>typename</I>(dns_rdata_t *rdata1, dns_rdata_t *rdata2);</CODE>
</PRE>
<PRE>
<CODE>static int
compare_<I>classname_typename</I>(dns_rdata_t *rdata1, dns_rdata_t *rdata2);</CODE>
</PRE>
Compares <CODE>rdata1</CODE> and <CODE>rdata2<CODE> as required for DNSSEC
ordering. The routine should
ensure that the <CODE>type</CODE> and <CODE>class</CODE> of the two rdata
match with <CODE>REQUIRE(rdata1->type == rdata2->type);</CODE> and
<CODE>REQUIRE(rdata1->class == rdata2->class);</CODE> statements. The
<CODE>rdata->type</CODE> should also be verified and if the RR type is
class specific the <CODE>rdata->class</CLASS>.
<P>
<CODE>compare_<I>classname_typename</I>()</CODE> returns -1, 0, 1.
<H2><A NAME="functions">Support Functions</A></H2>
The following static support functions are available to use.
<DL>
<DT><CODE>static unsigned int<BR>
name_length(dns_name_t *name);</CODE></DT>
<DD>
<P>
Returns the length of <CODE>name</CODE>.
<P>
<DT><CODE>static dns_result_t<BR>
txt_totext(isc_region_t *source, isc_buffer_t *target);</CODE></DT>
<DD>
<P>
Extracts the octet length tagged text string at the start of
<CODE>source</CODE> and writes it as a quoted string to <CODE>target</CODE>.
<CODE>source</CODE> is adjusted so that it points to first octet after the
text string.
<P>
Returns <CODE>DNS_R_NOSPACE</CODE> or <CODE>DNS_R_SUCCESS</CODE>.
<P>
<DT><CODE>static dns_result_t<BR>
txt_fromtext(isc_textregion_t *source, isc_buffer_t *target);</CODE></DT>
<DD>
<P>
Take the text region <CODE>source</CODE> and convert it to a length tagged
text string writing it to <CODE>target</CODE>.
<P>
Returns <CODE>DNS_R_NOSPACE</CODE>, <CODE>DNS_R_TEXTTOLONG</CODE>
or <CODE>DNS_R_SUCCESS</CODE>.
<P>
<DT><CODE>static dns_result_t<BR>
txt_fromwire(isc_buffer_t *source, isc_buffer_t *target);</CODE></DT>
<DD>
<P>
Read a octet length tagged text string from <CODE>source</CODE> and
write it to <CODE>target</CODE>.
Ensures that octet length tagged text string was wholly within the active
area of <CODE>source</CODE>.
Adjusts the active area of <CODE>source</CODE> so that it refers to the first
octet after the octet length tagged text string.
<P>
Returns <CODE>DNS_R_UNEXPECTEDEND</CODE>, <CODE>DNS_R_NOSPACE</CODE> or
<CODE>DNS_R_SUCCESS</CODE>.
<P>
<DT><A NAME="name_prefix"><CODE>static isc_boolean_t<BR>
name_prefix(dns_name_t *name, dns_name_t *origin, dns_name_t *target);</CODE>
</A></DT>
<DD>
<P>
If <CODE>origin</CODE> is NULL or the root label set <CODE>target<CODE> to
refer to <CODE>name</CODE> and return <CODE>ISC_FALSE</CODE>.
Otherwise see if <CODE>name</CODE> is a sub domain of <CODE>origin</CODE>
and are not equal.
If so make <CODE>target</CODE> refer to the prefix of <CODE>name</CODE> and
return <CODE>ISC_TRUE</CODE>.
Otherwise make <CODE>target</CODE> refer to <CODE>name</CODE> and return
<CODE>ISC_FALSE</CODE>.
<P>
Typical use:
<PRE><CODE>
static dns_result_t
totext_<I>typename</I>(dns_rdata_t *rdata, dns_name_t *origin,
isc_buffer_t * target)
{
isc_region_t region;
dns_name_t name, prefix;
isc_boolean_t sub;
dns_name_init(&amp;name, NULL);
dns_name_init(&amp;prefix, NULL);
dns_rdata_toregion(rdata, &amp;region);
dns_name_fromregion(&amp;name, &amp;region);
sub = <B>name_prefix</B>(&amp;name, origin, &amp;prefix);
return (dns_name_totext(&amp;prefix, sub, target));
}
</CODE></PRE>
<DT><CODE>static dns_result_t<BR>
str_totext(char *source, isc_buffer_t *target);</CODE></DT>
<DD>
<P>
This adds the <CODE>NULL</CODE> terminated string <CODE>source</CODE>
up to but not including <CODE>NULL</CODE> to <CODE>target</CODE>.
<P>
Returns <CODE>DNS_R_NOSPACE</CODE> and <CODE>DNS_R_SUCCESS</CODE>.
<P>
<DT><CODE>static isc_boolean_t<BR>
buffer_empty(isc_buffer_t *source);</CODE></DT>
<DD>
<P>
Returns <CODE>ISC_TRUE</CODE> if the active region of <CODE>source</CODE> is
empty otherwise <CODE>ISC_FALSE</CODE>.
<P>
<DT><CODE>static void<BR>
buffer_fromregion(isc_buffer_t *buffer, isc_region_t *region,
unsigned int type);</CODE></DT>
<DD>
<P>
Make <CODE>buffer</CODE> refer to the memory in <CODE>region</CODE> and
make it active.
<P>
<DT><CODE>static dns_result_t<BR>
uint32_tobuffer(isc_uint32_t value, isc_buffer_t *target);</CODE></DT>
<DD>
<P>
Write the 32 bit <CODE>value</CODE> in network order to <CODE>target</CODE>.
<P>
Returns <CODE>DNS_R_NOSPACE</CODE> and <CODE>DNS_R_SUCCESS</CODE>.
<P>
<DT><CODE>static dns_result_t<BR>
uint16_tobuffer(isc_uint32_t value, isc_buffer_t *target);</CODE></DT>
<DD>
<P>
Write them 16 bit <CODE>value</CODE> in network order to <CODE>target</CODE>.
<P>
Returns <CODE>ISC_R_RANGE</CODE>, <CODE>DNS_R_NOSPACE</CODE> and <CODE>DNS_R_SUCCESS</CODE>.
<P>
<DT><CODE>static isc_uint32_t<BR>
uint32_fromregion(isc_region_t *region);</CODE></DT>
<DD>
<P>
Returns the 32 bit at the start of <CODE>region</CODE> in host order.
<P>
Requires <CODE>(region->length >= 4)</CODE>.
<P>
<DT><CODE>static isc_uint16_t<BR>
uint16_fromregion(isc_region_t *region);</CODE></DT>
<DD>
<P>
Returns the 16 bit at the start of <CODE>region</CODE> in host order.
<P>
Requires <CODE>(region->length >= 2)</CODE>.
<P>
<DT><CODE>static dns_result_t<BR>
<A NAME="gettoken">gettoken</A>(isc_lex_t *lexer, isc_token_t *token, isc_tokentype_t expect, isc_boolean_t eol);</CODE></DT>
<DD>
<P>
Gets the next token from the input stream <CODE>lexer</CODE>. Ensure that the
returned token matches <CODE>expect</CODE> (isc_tokentype_qstring can also
return isc_tokentype_string), or isc_tokentype_eol and isc_tokentype_eof if
<CODE>eol</CODE> is <CODE>ISC_TRUE</CODE>.
<P>
Returns <CODE>DNS_R_UNEXPECTED</CODE>, <CODE>DNS_R_UNEXPECTEDEND</CODE>,
<CODE>DNS_R_UNEXPECTEDTOKEN</CODE> and <CODE>DNS_R_SUCCESS</CODE>.
<P>
</DT>
<DT><CODE>static dns_result_t<BR>
<A NAME="mem_tobuffer">mem_tobuffer</A>(isc_buffer_t *target, void *base, unsigned int length);</CODE></DT>
<DD>
<P>
Add the memory referred to by <CODE>base</CODE> to <CODE>target</CODE>.
<P>
Returns <CODE>DNS_R_NOSPACE</CODE> and <CODE>DNS_R_SUCCESS</CODE>.
<P>
<DT><CODE>static int<BR>
compare_region(isc_region_t *r1, isc_region_t *r2)</CODE></DT>
<DD>
<P>
Compares two regions returning -1, 0, 1 based on their DNSSEC ordering.
<P>
<DT><CODE>static int<BR>
hexvalue(char value);</CODE></DT>
<DD>
<P>
Returns the hexadecimal value of <CODE>value</CODE> or -1 if not
a hexadecimal character.
<P>
<DT><CODE>static int<BR>
decvalue(char value);</CODE></DT>
<DD>
<P>
Returns the decimal value of <CODE>value</CODE> or -1 if not
a decimal character.
<P>
<DT><CODE>static dns_result_t<BR>
base64_totext(isc_region_t *source, isc_buffer_t *target);</CODE></DT>
<DD>
<P>
Convert the region referred to by <CODE>source</CODE> to base64 encoded text
and put it into <CODE>target</CODE>.
<P>
Returns <CODE>DNS_R_NOSPACE</CODE> or <CODE>DNS_R_SUCCESS</CODE>.
<P>
<DT><CODE>static dns_result_t<BR>
base64_tobuffer(isc_lex_t *lexer, isc_buffer_t *target,
int length);</CODE></DT>
<DD>
<P>
Read a series of tokens from <CODE>lexer</CODE> that containing base64 data
until one of end of line, <CODE>length</CODE> (<CODE>length</CODE> &gt;= 0)
bytes have been read or base64 pad characters are seen.
If <CODE>length</CODE> &lt; 0 it is ignored otherwise it is an error if there
are not <CODE>length</CODE> octets of data or when processing a token
<CODE>length</CODE> octets would have been exceeded.
<P>
Returns <CODE>DNS_R_BADBASE64</CODE>, <CODE>DNS_R_UNEXPECTED</CODE>,
<CODE>DNS_R_UNEXPECTEDEND</CODE>, <CODE>DNS_R_UNEXPECTEDTOKEN</CODE>
and <CODE>DNS_R_SUCCESS</CODE>.
<P>
<DT><CODE>static dns_result_t<BR>
time_totext(unsigned long value, isc_buffer_t *target);</CODE></DT>
<DD>
<P>
Convert the date represented by <CODE>value</CODE> into YYYYMMDDHHMMSS format
taking into account the active epochs. This code is Y2K and Y2038 compliant.
<P>
Returns <CODE>DNS_R_NOSPACE</CODE> and <CODE>DNS_R_SUCCESS</CODE>.
<DT><CODE>static dns_result_t<BR>
time_tobuffer(char *source, isc_buffer_t *target);</CODE></DT>
<DD>
<P>
Take the date in <CODE>source</CODE> and convert it seconds since January 1,
1970 (ignoring leap seconds) and place the least significant 32 bits into
<CODE>target</CODE>.
<P>
Returns <CODE>ISC_R_RANGE</CODE>, <CODE>DNS_R_SYNTAX</CODE>,
<CODE>DNS_R_NOSPACE</CODE> and <CODE>DNS_R_SUCCESS</CODE>.
</DL>
<H2><A NAME="macros">Support Macros<A></H2>
The following macro is available:
<DL>
<DT><CODE>RETERR(x)</CODE><DT>
<DD>
<P>
Evaluate <CODE>x</CODE> and call <CODE>return (<I>&lt;value of x&gt;</I>);</CODE> if the result is not <CODE>DNS_R_SUCCESS</CODE>.
</DL>
</BODY>
</HTML>