<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>5. Adding new DNS record types</title><link rel="stylesheet" href="docbook.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="PowerDNS manual" /><link rel="up" href="pdns-internals.html" title="Appendix B. PDNS internals" /><link rel="prev" href="dns-to-query.html" title="4. How PDNS translates DNS queries into backend queries" /><link rel="next" href="backend-writers-guide.html" title="Appendix C. Backend writers' guide" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5. Adding new DNS record types</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="dns-to-query.html">Prev</a> </td><th width="60%" align="center">Appendix B. PDNS internals</th><td width="20%" align="right"> <a accesskey="n" href="backend-writers-guide.html">Next</a></td></tr></table><hr /></div><div class="sect1" title="5. Adding new DNS record types"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="adding-rr-types"></a>5. Adding new DNS record types</h2></div></div></div><p> Here are the full descriptions on how we added the TLSA record type to all PowerDNS products, with links to the actual source code. </p><p> First, define the TLSARecordContent class in <a class="ulink" href="http://wiki.powerdns.com/trac/browser/trunk/pdns/pdns/dnsrecords.hh?rev=2338#L307" target="_top">dnsrecords.hh</a>: </p><pre class="screen"> class TLSARecordContent : public DNSRecordContent { public: includeboilerplate(TLSA) uint8_t d_certusage, d_selector, d_matchtype; string d_cert; }; </pre><p> The 'includeboilerplate(TLSA)' generates the four methods that do everything PowerDNS would ever want to do with a record: </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p> read TLSA records from zonefile format </p></li><li class="listitem"><p> write out a TLSA record in zonefile format </p></li><li class="listitem"><p> read a TLSA record from a packet </p></li><li class="listitem"><p> write a TLSA record to a packet </p></li></ul></div><p> </p><p> The <a class="ulink" href="http://wiki.powerdns.com/trac/browser/trunk/pdns/pdns/dnsrecords.cc?rev=2638#L226" target="_top">actual parsing code</a>: </p><pre class="screen"> boilerplate_conv(TLSA, 52, conv.xfr8BitInt(d_certusage); conv.xfr8BitInt(d_selector); conv.xfr8BitInt(d_matchtype); conv.xfrHexBlob(d_cert, true); ) </pre><p> This code defines the TLSA rrtype number as 52. Secondly, it says there are 3 eight bit fields for Certificate Usage, Selector and Match type. Next, it defines that the rest of the record is the actual certificate (hash). <a class="ulink" href="http://wiki.powerdns.com/trac/browser/trunk/pdns/pdns/dnsparser.hh?rev=2338#L70" target="_top">'conv'</a> methods are supplied for all DNS data types in use. </p><p> Now add TLSRecordContent::report() to <a class="ulink" href="http://wiki.powerdns.com/trac/browser/trunk/pdns/pdns/dnsrecords.cc?rev=2338#L364" target="_top">reportOtherTypes()</a>. </p><p> And that's it. For completeness, add TLSA and 52 to the QType enum in qtype.hh, which makes it easier to refer to the TLSA record in code if so required. </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="dns-to-query.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="pdns-internals.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="backend-writers-guide.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">4. How PDNS translates DNS queries into backend queries </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Appendix C. Backend writers' guide</td></tr></table></div></body></html>