Defines all Resource Record Generators. More...
Go to the source code of this file.
Classes | |
struct | DNSStringReader |
Class that reads a string in 'zonefile format' on behalf of an RRGen. More... | |
struct | AGen |
IP address, A record generator. More... | |
struct | AAAAGen |
Generates an AAAA (IPv6 address) record. More... | |
struct | SOAGen |
Generates a SOA Resource Record. More... | |
struct | SRVGen |
Generates a SRV Resource Record. More... | |
struct | NAPTRGen |
Generates a NAPTR Resource Record. More... | |
struct | CNAMEGen |
Generates a CNAME Resource Record. More... | |
struct | PTRGen |
Generates a PTR Resource Record. More... | |
struct | NSGen |
Generates an NS Resource Record. More... | |
struct | MXGen |
Generates an MX Resource Record. More... | |
struct | RRSIGGen |
Generates an RRSIG Resource Record. More... | |
struct | TXTGen |
Generates an TXT Resource Record. More... | |
struct | UnknownGen |
This implements 'unknown record types'. More... | |
struct | ClockTXTGen |
This implements a fun dynamic TXT record type. More... | |
Defines all Resource Record Generators.
Generators know about a record type's contents. They also know how to inject themselves into a DNSMessageWriter, parse themselves from a DNSMessageReader and how to convert themselves into a master file representation.
The "Magic" behind this is that a RRGen instance uses methods like:
To (de)serialize itself from/to DNS Messages and 'master file format strings'. Since these methods have the same name over all four classes, the same code can be used to (de)serialize to both messages and human readable strings.
All generators have 'native' constructors, which allows for example the construction of an IP(v6) address from a struct sockaddr. In addition, the contents of a resource record are available natively. As an example:
``` DNSMessageReader dmr(resp);
DNSSection rrsection; DNSName dn; DNSType dt; uint32_t ttl; std::unique_ptr<RRGen> rr;
if(dmr.getRR(rrsection, dn, dt, ttl, rr)) { auto aaaa = dynamic_cast<AAAAGen*>(rr.get()); if(aaaa) { sendto(sock, "hello", 5, aaaa->getIP(), aaaa->getIP().getSocklen(), 0); } } ```